Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed #11978: Pasting links into TinyMCE
- Loading branch information
Showing
3 changed files
with
41 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,46 @@ | ||
// WebGUI Specific javascript functions for TinyMCE | ||
|
||
function tinyMCE_WebGUI_URLConvertor(url, node, on_save) { | ||
// Do custom WebGUI convertion, replace back ^(); | ||
(function () { | ||
var carat = /%5E/g, | ||
colon = /%3B/g, | ||
leftParen = /%28/g, | ||
rightParen = /%29/g, | ||
front = /^.*(\^.*)$/, | ||
quot = /"/g; | ||
|
||
// turn escaped macro characters back into the real thing | ||
url = url.replace(new RegExp("%5E", "g"), "^"); | ||
url = url.replace(new RegExp("%3B", "g"), ";"); | ||
url = url.replace(new RegExp("%28", "g"), "("); | ||
url = url.replace(new RegExp("%29", "g"), ")"); | ||
function convert(url) { | ||
return url.replace(carat, '^') | ||
.replace(colon, ':') | ||
.replace(leftParen, '(') | ||
.replace(rightParen, ')') | ||
.replace(front, '$1'); | ||
} | ||
|
||
// if there is a macro in the line, remove everything in front of the macro | ||
url = url.replace(/^.*(\^.*)$/,"$1"); | ||
function recurse(el) { | ||
var i, nodes = el.childNodes, len = nodes.length; | ||
if (el.href) { | ||
el.href = convert(el.href); | ||
} | ||
if (el.src) { | ||
el.src = convert(el.src); | ||
} | ||
for (i = 0; i < len; i += 1) { | ||
recurse(nodes[i]); | ||
} | ||
} | ||
|
||
return url; | ||
} | ||
function postproc (pl, o) { | ||
recurse(o.node); | ||
} | ||
|
||
function tinyMCE_WebGUI_Cleanup(type,value) { | ||
switch (type) { | ||
case "get_from_editor": | ||
value = value.replace(/"/g, '"'); | ||
break; | ||
function cleanup (type, value) { | ||
if (type === 'get_from_editor') { | ||
value = value.replace(quot, '"'); | ||
} | ||
return value; | ||
} | ||
return value; | ||
} | ||
|
||
window.tinyMCE_WebGUI_URLConvertor = convert; | ||
window.tinyMCE_WebGUI_paste_postprocess = postproc; | ||
window.tinyMCE_WebGUI_Cleanup = cleanup; | ||
}()); |