Skip to content

Commit

Permalink
fixed #11978: Pasting links into TinyMCE
Browse files Browse the repository at this point in the history
  • Loading branch information
frodwith committed Nov 29, 2010
1 parent b30510f commit dd05afb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/changelog/7.x.x.txt
Expand Up @@ -5,6 +5,7 @@
- fixed #11954: Can't clear packed head tags
- fixed #11957: finBrokenAsset --fix does not fix per se
- fixed #11974: Toolbar icons unclickable in Webkit using HTML5
- fixed #11978: Pasting links into TinyMCE

7.9.18
- fixed #11938: upgrade script always removes specialState
Expand Down
2 changes: 2 additions & 0 deletions lib/WebGUI/Asset/RichEdit.pm
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
56 changes: 38 additions & 18 deletions 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"), ")");
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(/&quot;/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;
}());

0 comments on commit dd05afb

Please sign in to comment.