From 8eefbb2158c43b51a8c33e6c480cbe61539b9535 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Mon, 27 Aug 2012 04:16:04 -0400 Subject: [PATCH] Add option to enable HTML editor on forwarding (#1488517) --- program/js/tiny_mce/plugins/media/editor_plugin_src.js | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff --git a/program/js/tiny_mce/plugins/media/editor_plugin_src.js b/program/js/tiny_mce/plugins/media/editor_plugin_src.js index ea79db1..33a5805 100644 --- a/program/js/tiny_mce/plugins/media/editor_plugin_src.js +++ b/program/js/tiny_mce/plugins/media/editor_plugin_src.js @@ -28,6 +28,10 @@ ["Audio"] ]; + function normalizeSize(size) { + return typeof(size) == "string" ? size.replace(/[^0-9%]/g, '') : size; + } + function toArray(obj) { var undef, out, i; @@ -258,8 +262,8 @@ 'data-mce-json' : JSON.serialize(data, "'") }); - img.width = data.width || (data.type == 'audio' ? "300" : "320"); - img.height = data.height || (data.type == 'audio' ? "32" : "240"); + img.width = data.width = normalizeSize(data.width || (data.type == 'audio' ? "300" : "320")); + img.height = data.height = normalizeSize(data.height || (data.type == 'audio' ? "32" : "240")); return img; }, @@ -378,13 +382,17 @@ data = JSON.parse(data); typeItem = this.getType(node.attr('class')); - style = node.attr('data-mce-style') + style = node.attr('data-mce-style'); if (!style) { style = node.attr('style'); if (style) style = editor.dom.serializeStyle(editor.dom.parseStyle(style, 'img')); } + + // Use node width/height to override the data width/height when the placeholder is resized + data.width = node.attr('width') || data.width; + data.height = node.attr('height') || data.height; // Handle iframe if (typeItem.name === 'Iframe') { @@ -434,8 +442,8 @@ // Create new object element video = new Node('video', 1).attr(tinymce.extend({ id : node.attr('id'), - width: node.attr('width'), - height: node.attr('height'), + width: normalizeSize(node.attr('width')), + height: normalizeSize(node.attr('height')), style : style }, data.video.attrs)); @@ -473,8 +481,8 @@ // Create new object element audio = new Node('audio', 1).attr(tinymce.extend({ id : node.attr('id'), - width: node.attr('width'), - height: node.attr('height'), + width: normalizeSize(node.attr('width')), + height: normalizeSize(node.attr('height')), style : style }, data.video.attrs)); @@ -502,8 +510,8 @@ embed.shortEnded = true; embed.attr({ id: node.attr('id'), - width: node.attr('width'), - height: node.attr('height'), + width: normalizeSize(node.attr('width')), + height: normalizeSize(node.attr('height')), style : style, type: node.attr('type') }); @@ -531,8 +539,8 @@ // Create new object element object = new Node('object', 1).attr({ id : node.attr('id'), - width: node.attr('width'), - height: node.attr('height'), + width: normalizeSize(node.attr('width')), + height: normalizeSize(node.attr('height')), style : style }); @@ -576,8 +584,8 @@ embed.shortEnded = true; embed.attr({ id: node.attr('id'), - width: node.attr('width'), - height: node.attr('height'), + width: normalizeSize(node.attr('width')), + height: normalizeSize(node.attr('height')), style : style, type: typeItem.mimes[0] }); @@ -793,8 +801,8 @@ if (iframe) { // Get width/height - width = iframe.attr('width'); - height = iframe.attr('height'); + width = normalizeSize(iframe.attr('width')); + height = normalizeSize(iframe.attr('height')); style = style || iframe.attr('style'); id = iframe.attr('id'); hspace = iframe.attr('hspace'); -- Gitblit v1.9.1