Skip to content

Commit

Permalink
Change email address detection in TinyMCE link plugin.
Browse files Browse the repository at this point in the history
	- If link has a "@" and a ":", do not consider it an email address.
Add un-minified version of plugin.js file for link plugin.
Update build instructions to include media plugin.
Commit re-built minified JS.
Add all plugins to Jakefile.js in zip file.
Reason for this commit:
Split acceptance test was failing when TinyMCE detected a Split asset
key as an email address. Fix was to modify email address detection.
  • Loading branch information
John Eskew authored and Don Mitchell committed Oct 3, 2014
1 parent 139e10d commit 2a8529d
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 4 deletions.
4 changes: 2 additions & 2 deletions common/static/js/vendor/tinymce/BUILD_README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Instructions for creating js/tinymce.full.min.js

1. Ensure that the dependencies (NodeJS, Jake, and other dependencies) are installed. If necessary,
install them per the directions on https://github.com/tinymce/tinymce/tree/4.0.20.
2. Unzip edx-platform/vendor_extra/tinymce/jake_package.zip into this directory (so that Jakefile.js resides in this directory).
2. Unzip edx-platform/vendor_extra/tinymce/JakePackage.zip into this directory (so that Jakefile.js resides in this directory).
3. Run the following command in the tinymce directory:
jake minify bundle[themes:modern,plugins:image,link,codemirror,paste,table,textcolor]
jake minify bundle[themes:modern,plugins:image,link,codemirror,paste,table,textcolor,media]
4. Cleanup by deleting the Unversioned files that were created from unzipping jake_package.zip.

Instructions for updating tinymce to a newer version:
Expand Down
207 changes: 207 additions & 0 deletions common/static/js/vendor/tinymce/js/tinymce/plugins/link/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
tinymce.PluginManager.add("link", function(e) {
function t(t) {
return function() {
var n = e.settings.link_list;
"string" == typeof n ? tinymce.util.XHR.send({
url: n,
success: function(e) {
t(tinymce.util.JSON.parse(e))
}
}) : t(n)
}
}

function n(t) {
function n(e) {
var t = f.find("#text");
(!t.value() || e.lastControl && t.value() == e.lastControl.text()) && t.value(e.control.text()), f.find("#href").value(e.control.value())
}

function l() {
var n = [{
text: "None",
value: ""
}];
return tinymce.each(t, function(t) {
n.push({
text: t.text || t.title,
value: e.convertURL(t.value || t.url, "href"),
menu: t.menu
})
}), n
}

function i(t) {
var n = [{
text: "None",
value: ""
}];
return tinymce.each(e.settings.rel_list, function(e) {
n.push({
text: e.text || e.title,
value: e.value,
selected: t === e.value
})
}), n
}

function r(t) {
var n = [];
return e.settings.target_list || (n.push({
text: "None",
value: ""
}), n.push({
text: "New window",
value: "_blank"
})), tinymce.each(e.settings.target_list, function(e) {
n.push({
text: e.text || e.title,
value: e.value,
selected: t === e.value
})
}), n
}

function a(t) {
var l = [];
return tinymce.each(e.dom.select("a:not([href])"), function(e) {
var n = e.name || e.id;
n && l.push({
text: n,
value: "#" + n,
selected: -1 != t.indexOf("#" + n)
})
}), l.length ? (l.unshift({
text: "None",
value: ""
}), {
name: "anchor",
type: "listbox",
label: "Anchors",
values: l,
onselect: n
}) : void 0
}

function o() {
h && h.value(e.convertURL(this.value(), "href")), !c && 0 === x.text.length && k && this.parent().parent().find("#text")[0].value(this.value())
}
var u, s, c, f, d, h, v, g, x = {},
m = e.selection,
p = e.dom;
u = m.getNode(), s = p.getParent(u, "a[href]");
var k = !0;
if (/</.test(m.getContent())) k = !1;
else if (s) {
var y, b = s.childNodes;
if (0 === b.length) k = !1;
else
for (y = b.length - 1; y >= 0; y--)
if (3 != b[y].nodeType) {
k = !1;
break
}
}
x.text = c = s ? s.innerText || s.textContent : m.getContent({
format: "text"
}), x.href = s ? p.getAttrib(s, "href") : "", x.target = s ? p.getAttrib(s, "target") : e.settings.default_link_target || "", x.rel = s ? p.getAttrib(s, "rel") : "", e.fire('EditLink', x), k && (d = {
name: "text",
type: "textbox",
size: 40,
label: "Text to display",
onchange: function() {
x.text = this.value()
}
}), t && (h = {
type: "listbox",
label: "Link list",
values: l(),
onselect: n,
value: e.convertURL(x.href, "href"),
onPostRender: function() {
h = this
}
}), e.settings.target_list !== !1 && (g = {
name: "target",
type: "listbox",
label: "Target",
values: r(x.target)
}), e.settings.rel_list && (v = {
name: "rel",
type: "listbox",
label: "Rel",
values: i(x.rel)
}), f = e.windowManager.open({
title: "Insert link",
data: x,
body: [{
name: "href",
type: "filepicker",
filetype: "file",
size: 40,
autofocus: !0,
label: "Url",
onchange: o,
onkeyup: o
},
d, a(x.href), h, v, g
],
onSubmit: function(t) {
function n(t, n) {
var l = e.selection.getRng();
window.setTimeout(function() {
e.windowManager.confirm(t, function(t) {
e.selection.setRng(l), n(t)
})
}, 0)
}

function l() {
s ? (e.focus(), k && i.text != c && (s.innerText = i.text), p.setAttribs(s, {
href: r,
target: i.target ? i.target : null,
rel: i.rel ? i.rel : null
}), m.select(s), e.undoManager.add()) : k ? e.insertContent(p.createHTML("a", {
href: r,
target: i.target ? i.target : null,
rel: i.rel ? i.rel : null
}, p.encode(i.text))) : e.execCommand("mceInsertLink", !1, {
href: r,
target: i.target,
rel: i.rel ? i.rel : null
})
}
var i = t.data;
e.fire('SaveLink', i);
var r = i.href;
/* EDX - Change the email address detection, which mistakenly detected Split asset keys as email addresses.
Instead, if the link has a "@" sign *and* a colon, do not consider it an email address. */
return r ? r.indexOf("@") > 0 && -1 == r.indexOf("//") && -1 == r.indexOf(":") ? void n("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?", function(e) {
e && (r = "mailto:" + r), l()
}) : /^\s*www\./i.test(r) ? void n("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?", function(e) {
e && (r = "http://" + r), l()
}) : void l() : void e.execCommand("unlink")
}
})
}
e.addButton("link", {
icon: "link",
tooltip: "Insert/edit link",
shortcut: "Ctrl+K",
onclick: t(n),
stateSelector: "a[href]"
}), e.addButton("unlink", {
icon: "unlink",
tooltip: "Remove link",
cmd: "unlink",
stateSelector: "a[href]"
}), e.addShortcut("Ctrl+K", "", t(n)), this.showDialog = n, e.addMenuItem("link", {
icon: "link",
text: "Insert link",
shortcut: "Ctrl+K",
onclick: t(n),
stateSelector: "a[href]",
context: "insert",
prependToContext: !0
})
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Binary file modified vendor_extra/tinymce/JakePackage.zip
Binary file not shown.

0 comments on commit 2a8529d

Please sign in to comment.