Update TinyMCE to 3.5.3, enable stripping of Word styles on paste

This commit is contained in:
grahamtriggs 2015-10-14 22:17:16 +01:00
parent 83404c2c80
commit 48790b7525
274 changed files with 25268 additions and 14504 deletions

1
webapp/web/js/tiny_mce/plugins/style/css/props.css vendored Executable file → Normal file
View file

@ -5,6 +5,7 @@ select, #block_text_indent, #box_width, #box_height, #box_padding_top, #box_padd
#box_margin_top, #box_margin_right, #box_margin_bottom, #box_margin_left, #positioning_width, #positioning_height, #positioning_zindex {width:70px;}
#positioning_placement_top, #positioning_placement_right, #positioning_placement_bottom, #positioning_placement_left {width:70px;}
#positioning_clip_top, #positioning_clip_right, #positioning_clip_bottom, #positioning_clip_left {width:70px;}
.panel_toggle_insert_span {padding-top:10px;}
.panel_wrapper div.current {padding-top:10px;height:230px;}
.delim {border-left:1px solid gray;}
.tdelim {border-bottom:1px solid gray;}

2
webapp/web/js/tiny_mce/plugins/style/editor_plugin.js vendored Executable file → Normal file
View file

@ -1 +1 @@
(function(){tinymce.create('tinymce.plugins.StylePlugin',{init:function(ed,url){ed.addCommand('mceStyleProps',function(){ed.windowManager.open({file:url+'/props.htm',width:480+parseInt(ed.getLang('style.delta_width',0)),height:320+parseInt(ed.getLang('style.delta_height',0)),inline:1},{plugin_url:url,style_text:ed.selection.getNode().style.cssText});});ed.addCommand('mceSetElementStyle',function(ui,v){if(e=ed.selection.getNode()){ed.dom.setAttrib(e,'style',v);ed.execCommand('mceRepaint');}});ed.onNodeChange.add(function(ed,cm,n){cm.setDisabled('styleprops',n.nodeName==='BODY');});ed.addButton('styleprops',{title:'style.desc',cmd:'mceStyleProps'});},getInfo:function(){return{longname:'Style',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style',version:tinymce.majorVersion+"."+tinymce.minorVersion};}});tinymce.PluginManager.add('style',tinymce.plugins.StylePlugin);})();
(function(){tinymce.create("tinymce.plugins.StylePlugin",{init:function(a,b){a.addCommand("mceStyleProps",function(){var c=false;var f=a.selection.getSelectedBlocks();var d=[];if(f.length===1){d.push(a.selection.getNode().style.cssText)}else{tinymce.each(f,function(g){d.push(a.dom.getAttrib(g,"style"))});c=true}a.windowManager.open({file:b+"/props.htm",width:480+parseInt(a.getLang("style.delta_width",0)),height:340+parseInt(a.getLang("style.delta_height",0)),inline:1},{applyStyleToBlocks:c,plugin_url:b,styles:d})});a.addCommand("mceSetElementStyle",function(d,c){if(e=a.selection.getNode()){a.dom.setAttrib(e,"style",c);a.execCommand("mceRepaint")}});a.onNodeChange.add(function(d,c,f){c.setDisabled("styleprops",f.nodeName==="BODY")});a.addButton("styleprops",{title:"style.desc",cmd:"mceStyleProps"})},getInfo:function(){return{longname:"Style",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("style",tinymce.plugins.StylePlugin)})();

31
webapp/web/js/tiny_mce/plugins/style/editor_plugin_src.js vendored Executable file → Normal file
View file

@ -1,8 +1,11 @@
/**
* $Id: editor_plugin_src.js 787 2008-04-10 11:40:57Z spocke $
* editor_plugin_src.js
*
* @author Moxiecode
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
* Copyright 2009, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://tinymce.moxiecode.com/license
* Contributing: http://tinymce.moxiecode.com/contributing
*/
(function() {
@ -10,14 +13,30 @@
init : function(ed, url) {
// Register commands
ed.addCommand('mceStyleProps', function() {
var applyStyleToBlocks = false;
var blocks = ed.selection.getSelectedBlocks();
var styles = [];
if (blocks.length === 1) {
styles.push(ed.selection.getNode().style.cssText);
}
else {
tinymce.each(blocks, function(block) {
styles.push(ed.dom.getAttrib(block, 'style'));
});
applyStyleToBlocks = true;
}
ed.windowManager.open({
file : url + '/props.htm',
width : 480 + parseInt(ed.getLang('style.delta_width', 0)),
height : 320 + parseInt(ed.getLang('style.delta_height', 0)),
height : 340 + parseInt(ed.getLang('style.delta_height', 0)),
inline : 1
}, {
applyStyleToBlocks : applyStyleToBlocks,
plugin_url : url,
style_text : ed.selection.getNode().style.cssText
styles : styles
});
});
@ -49,4 +68,4 @@
// Register plugin
tinymce.PluginManager.add('style', tinymce.plugins.StylePlugin);
})();
})();

104
webapp/web/js/tiny_mce/plugins/style/js/props.js vendored Executable file → Normal file
View file

@ -10,9 +10,9 @@ var defaultFonts = "" +
"Geneva, Arial, Helvetica, sans-serif=Geneva, Arial, Helvetica, sans-serif";
var defaultSizes = "9;10;12;14;16;18;24;xx-small;x-small;small;medium;large;x-large;xx-large;smaller;larger";
var defaultMeasurement = "+pixels=px;points=pt;em;in;cm;mm;picas;ems;exs;%";
var defaultSpacingMeasurement = "pixels=px;points=pt;in;cm;mm;picas;+ems;exs;%";
var defaultIndentMeasurement = "pixels=px;+points=pt;in;cm;mm;picas;ems;exs;%";
var defaultMeasurement = "+pixels=px;points=pt;inches=in;centimetres=cm;millimetres=mm;picas=pc;ems=em;exs=ex;%";
var defaultSpacingMeasurement = "pixels=px;points=pt;inches=in;centimetres=cm;millimetres=mm;picas=pc;+ems=em;exs=ex;%";
var defaultIndentMeasurement = "pixels=px;+points=pt;inches=in;centimetres=cm;millimetres=mm;picas=pc;ems=em;exs=ex;%";
var defaultWeight = "normal;bold;bolder;lighter;100;200;300;400;500;600;700;800;900";
var defaultTextStyle = "normal;italic;oblique";
var defaultVariant = "normal;small-caps";
@ -27,10 +27,41 @@ var defaultBorderStyle = "none;solid;dashed;dotted;double;groove;ridge;inset;out
var defaultBorderWidth = "thin;medium;thick";
var defaultListType = "disc;circle;square;decimal;lower-roman;upper-roman;lower-alpha;upper-alpha;none";
function init() {
function aggregateStyles(allStyles) {
var mergedStyles = {};
tinymce.each(allStyles, function(style) {
if (style !== '') {
var parsedStyles = tinyMCEPopup.editor.dom.parseStyle(style);
for (var name in parsedStyles) {
if (parsedStyles.hasOwnProperty(name)) {
if (mergedStyles[name] === undefined) {
mergedStyles[name] = parsedStyles[name];
}
else if (name === 'text-decoration') {
if (mergedStyles[name].indexOf(parsedStyles[name]) === -1) {
mergedStyles[name] = mergedStyles[name] +' '+ parsedStyles[name];
}
}
}
}
}
});
return mergedStyles;
}
var applyActionIsInsert;
var existingStyles;
function init(ed) {
var ce = document.getElementById('container'), h;
ce.style.cssText = tinyMCEPopup.getWindowArg('style_text');
existingStyles = aggregateStyles(tinyMCEPopup.getWindowArg('styles'));
ce.style.cssText = tinyMCEPopup.editor.dom.serializeStyle(existingStyles);
applyActionIsInsert = ed.getParam("edit_css_style_insert_span", false);
document.getElementById('toggle_insert_span').checked = applyActionIsInsert;
h = getBrowserHTML('background_image_browser','background_image','image','advimage');
document.getElementById("background_image_browser").innerHTML = h;
@ -144,6 +175,8 @@ function setupFormData() {
f.text_overline.checked = inStr(ce.style.textDecoration, 'overline');
f.text_linethrough.checked = inStr(ce.style.textDecoration, 'line-through');
f.text_blink.checked = inStr(ce.style.textDecoration, 'blink');
f.text_none.checked = inStr(ce.style.textDecoration, 'none');
updateTextDecorations();
// Setup background fields
@ -177,11 +210,7 @@ function setupFormData() {
f.box_height.value = getNum(ce.style.height);
selectByValue(f, 'box_height_measurement', getMeasurement(ce.style.height));
if (tinymce.isGecko)
selectByValue(f, 'box_float', ce.style.cssFloat, true, true);
else
selectByValue(f, 'box_float', ce.style.styleFloat, true, true);
selectByValue(f, 'box_float', ce.style.cssFloat || ce.style.styleFloat, true, true);
selectByValue(f, 'box_clear', ce.style.clear, true, true);
@ -247,12 +276,12 @@ function setupFormData() {
}
function getMeasurement(s) {
return s.replace(/^([0-9]+)(.*)$/, "$2");
return s.replace(/^([0-9.]+)(.*)$/, "$2");
}
function getNum(s) {
if (new RegExp('^[0-9]+[a-z%]+$', 'gi').test(s))
return s.replace(/[^0-9]/g, '');
if (new RegExp('^(?:[0-9.]+)(?:[a-z%]+)$', 'gi').test(s))
return s.replace(/[^0-9.]/g, '');
return s;
}
@ -370,13 +399,41 @@ function hasEqualValues(a) {
return true;
}
function toggleApplyAction() {
applyActionIsInsert = ! applyActionIsInsert;
}
function applyAction() {
var ce = document.getElementById('container'), ed = tinyMCEPopup.editor;
generateCSS();
tinyMCEPopup.restoreSelection();
ed.dom.setAttrib(ed.selection.getNode(), 'style', tinyMCEPopup.editor.dom.serializeStyle(tinyMCEPopup.editor.dom.parseStyle(ce.style.cssText)));
var newStyles = tinyMCEPopup.editor.dom.parseStyle(ce.style.cssText);
if (applyActionIsInsert) {
ed.formatter.register('plugin_style', {
inline: 'span', styles: existingStyles
});
ed.formatter.remove('plugin_style');
ed.formatter.register('plugin_style', {
inline: 'span', styles: newStyles
});
ed.formatter.apply('plugin_style');
} else {
var nodes;
if (tinyMCEPopup.getWindowArg('applyStyleToBlocks')) {
nodes = ed.selection.getSelectedBlocks();
}
else {
nodes = ed.selection.getNode();
}
ed.dom.setAttrib(nodes, 'style', tinyMCEPopup.editor.dom.serializeStyle(newStyles));
}
}
function updateAction() {
@ -440,9 +497,7 @@ function generateCSS() {
ce.style.width = f.box_width.value + (isNum(f.box_width.value) ? f.box_width_measurement.value : "");
ce.style.height = f.box_height.value + (isNum(f.box_height.value) ? f.box_height_measurement.value : "");
ce.style.styleFloat = f.box_float.value;
if (tinymce.isGecko)
ce.style.cssFloat = f.box_float.value;
ce.style.cssFloat = f.box_float.value;
ce.style.clear = f.box_clear.value;
@ -478,7 +533,7 @@ function generateCSS() {
ce.style.borderBottomWidth = f.border_width_bottom.value + (isNum(f.border_width_bottom.value) ? f.border_width_bottom_measurement.value : "");
ce.style.borderLeftWidth = f.border_width_left.value + (isNum(f.border_width_left.value) ? f.border_width_left_measurement.value : "");
} else
ce.style.borderWidth = f.border_width_top.value;
ce.style.borderWidth = f.border_width_top.value + (isNum(f.border_width_top.value) ? f.border_width_top_measurement.value : "");
if (!f.border_color_same.checked) {
ce.style.borderTopColor = f.border_color_top.value;
@ -638,4 +693,17 @@ function synch(fr, to) {
selectByValue(f, to + "_measurement", f.elements[fr + "_measurement"].value);
}
function updateTextDecorations(){
var el = document.forms[0].elements;
var textDecorations = ["text_underline", "text_overline", "text_linethrough", "text_blink"];
var noneChecked = el["text_none"].checked;
tinymce.each(textDecorations, function(id) {
el[id].disabled = noneChecked;
if (noneChecked) {
el[id].checked = false;
}
});
}
tinyMCEPopup.onInit.add(init);

64
webapp/web/js/tiny_mce/plugins/style/langs/en_dlg.js vendored Executable file → Normal file
View file

@ -1,63 +1 @@
tinyMCE.addI18n('en.style_dlg',{
title:"Edit CSS Style",
apply:"Apply",
text_tab:"Text",
background_tab:"Background",
block_tab:"Block",
box_tab:"Box",
border_tab:"Border",
list_tab:"List",
positioning_tab:"Positioning",
text_props:"Text",
text_font:"Font",
text_size:"Size",
text_weight:"Weight",
text_style:"Style",
text_variant:"Variant",
text_lineheight:"Line height",
text_case:"Case",
text_color:"Color",
text_decoration:"Decoration",
text_overline:"overline",
text_underline:"underline",
text_striketrough:"strikethrough",
text_blink:"blink",
text_none:"none",
background_color:"Background color",
background_image:"Background image",
background_repeat:"Repeat",
background_attachment:"Attachment",
background_hpos:"Horizontal position",
background_vpos:"Vertical position",
block_wordspacing:"Word spacing",
block_letterspacing:"Letter spacing",
block_vertical_alignment:"Vertical alignment",
block_text_align:"Text align",
block_text_indent:"Text indent",
block_whitespace:"Whitespace",
block_display:"Display",
box_width:"Width",
box_height:"Height",
box_float:"Float",
box_clear:"Clear",
padding:"Padding",
same:"Same for all",
top:"Top",
right:"Right",
bottom:"Bottom",
left:"Left",
margin:"Margin",
style:"Style",
width:"Width",
height:"Height",
color:"Color",
list_type:"Type",
bullet_image:"Bullet image",
position:"Position",
positioning_type:"Type",
visibility:"Visibility",
zindex:"Z-index",
overflow:"Overflow",
placement:"Placement",
clip:"Clip"
});
tinyMCE.addI18n('en.style_dlg',{"text_lineheight":"Line Height","text_variant":"Variant","text_style":"Style","text_weight":"Weight","text_size":"Size","text_font":"Font","text_props":"Text","positioning_tab":"Positioning","list_tab":"List","border_tab":"Border","box_tab":"Box","block_tab":"Block","background_tab":"Background","text_tab":"Text",apply:"Apply",toggle_insert_span:"Insert span at selection",title:"Edit CSS Style",clip:"Clip",placement:"Placement",overflow:"Overflow",zindex:"Z-index",visibility:"Visibility","positioning_type":"Type",position:"Position","bullet_image":"Bullet Image","list_type":"Type",color:"Color",height:"Height",width:"Width",style:"Style",margin:"Margin",left:"Left",bottom:"Bottom",right:"Right",top:"Top",same:"Same for All",padding:"Padding","box_clear":"Clear","box_float":"Float","box_height":"Height","box_width":"Width","block_display":"Display","block_whitespace":"Whitespace","block_text_indent":"Text Indent","block_text_align":"Text Align","block_vertical_alignment":"Vertical Alignment","block_letterspacing":"Letter Spacing","block_wordspacing":"Word Spacing","background_vpos":"Vertical Position","background_hpos":"Horizontal Position","background_attachment":"Attachment","background_repeat":"Repeat","background_image":"Background Image","background_color":"Background Color","text_none":"None","text_blink":"Blink","text_case":"Case","text_striketrough":"Strikethrough","text_underline":"Underline","text_overline":"Overline","text_decoration":"Decoration","text_color":"Color",text:"Text",background:"Background",block:"Block",box:"Box",border:"Border",list:"List"});

922
webapp/web/js/tiny_mce/plugins/style/props.htm vendored Executable file → Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
Edit CSS Style plug-in notes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unlike WYSIWYG editor functionality that operates only on the selected text,
typically by inserting new HTML elements with the specified styles.
This plug-in operates on the HTML blocks surrounding the selected text.
No new HTML elements are created.
This plug-in only operates on the surrounding blocks and not the nearest
parent node. This means that if a block encapsulates a node,
e.g <p><span>text</span></p>, then only the styles in the block are
recognized, not those in the span.
When selecting text that includes multiple blocks at the same level (peers),
this plug-in accumulates the specified styles in all of the surrounding blocks
and populates the dialogue checkboxes accordingly. There is no differentiation
between styles set in all the blocks versus styles set in some of the blocks.
When the [Update] or [Apply] buttons are pressed, the styles selected in the
checkboxes are applied to all blocks that surround the selected text.