diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 924cd0ebb..6708372e9 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.10.6 - fixed #11974: Toolbar icons unclickable in Webkit using HTML5 + - fixed #11978: Pasting links into TinyMCE 7.10.5 - fixed #11950: Username set to 0 when edit user diff --git a/lib/WebGUI/Asset/RichEdit.pm b/lib/WebGUI/Asset/RichEdit.pm index 993962eef..07855462d 100644 --- a/lib/WebGUI/Asset/RichEdit.pm +++ b/lib/WebGUI/Asset/RichEdit.pm @@ -467,6 +467,7 @@ sub getRichEditor { my @plugins; my %loadPlugins; push @plugins, "safari"; + push @plugins, "paste"; push @plugins, "contextmenu" if $self->getValue("enableContextMenu"); push @plugins, "inlinepopups" @@ -503,6 +504,7 @@ sub getRichEditor { theme_advanced_statusbar_location => "bottom", valid_elements => $self->getValue("validElements"), wg_userIsVisitor => $self->session->user->isVisitor ? JSON::true() : JSON::false(), + paste_postprocess => 'tinyMCE_WebGUI_paste_postprocess', ); # if ($ask) { # $config{oninit} = 'turnOffTinyMCE_'.$nameId; diff --git a/www/extras/tinymce-webgui/callbacks.js b/www/extras/tinymce-webgui/callbacks.js index f23b2f522..0197e9e20 100644 --- a/www/extras/tinymce-webgui/callbacks.js +++ b/www/extras/tinymce-webgui/callbacks.js @@ -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"), ")"); - - // if there is a macro in the line, remove everything in front of the macro - url = url.replace(/^.*(\^.*)$/,"$1"); - - return url; -} - -function tinyMCE_WebGUI_Cleanup(type,value) { - switch (type) { - case "get_from_editor": - value = value.replace(/"/g, '"'); - break; + function convert(url) { + return url.replace(carat, '^') + .replace(colon, ':') + .replace(leftParen, '(') + .replace(rightParen, ')') + .replace(front, '$1'); } - return value; -} + 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]); + } + } + + function postproc (pl, o) { + recurse(o.node); + } + + function cleanup (type, value) { + if (type === 'get_from_editor') { + value = value.replace(quot, '"'); + } + return value; + } + + window.tinyMCE_WebGUI_URLConvertor = convert; + window.tinyMCE_WebGUI_paste_postprocess = postproc; + window.tinyMCE_WebGUI_Cleanup = cleanup; +}());