Update Umbraco to 7.12.2
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
// Exports the "advlist" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/advlist')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/advlist'
|
||||
require('./plugin.js');
|
||||
@@ -1,97 +1,160 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var advlist = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('advlist', function(editor) {
|
||||
var olMenuItems, ulMenuItems, lastStyles = {};
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
function buildMenuItems(listName, styleValues) {
|
||||
var items = [];
|
||||
var applyListFormat = function (editor, listName, styleValue) {
|
||||
var cmd = listName === 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList';
|
||||
editor.execCommand(cmd, false, styleValue === false ? null : { 'list-style-type': styleValue });
|
||||
};
|
||||
var $_fdwamj82jh8lpuc2 = { applyListFormat: applyListFormat };
|
||||
|
||||
tinymce.each(styleValues.split(/[ ,]/), function(styleValue) {
|
||||
items.push({
|
||||
text: styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function(chr) {
|
||||
return chr.toUpperCase();
|
||||
}),
|
||||
data: styleValue == 'default' ? '' : styleValue
|
||||
});
|
||||
});
|
||||
var register = function (editor) {
|
||||
editor.addCommand('ApplyUnorderedListStyle', function (ui, value) {
|
||||
$_fdwamj82jh8lpuc2.applyListFormat(editor, 'UL', value['list-style-type']);
|
||||
});
|
||||
editor.addCommand('ApplyOrderedListStyle', function (ui, value) {
|
||||
$_fdwamj82jh8lpuc2.applyListFormat(editor, 'OL', value['list-style-type']);
|
||||
});
|
||||
};
|
||||
var $_1rj6rj81jh8lpuc0 = { register: register };
|
||||
|
||||
return items;
|
||||
}
|
||||
var getNumberStyles = function (editor) {
|
||||
var styles = editor.getParam('advlist_number_styles', 'default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman');
|
||||
return styles ? styles.split(/[ ,]/) : [];
|
||||
};
|
||||
var getBulletStyles = function (editor) {
|
||||
var styles = editor.getParam('advlist_bullet_styles', 'default,circle,disc,square');
|
||||
return styles ? styles.split(/[ ,]/) : [];
|
||||
};
|
||||
var $_1c19wf84jh8lpuc8 = {
|
||||
getNumberStyles: getNumberStyles,
|
||||
getBulletStyles: getBulletStyles
|
||||
};
|
||||
|
||||
olMenuItems = buildMenuItems('OL', editor.getParam(
|
||||
"advlist_number_styles",
|
||||
"default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman"
|
||||
));
|
||||
var isChildOfBody = function (editor, elm) {
|
||||
return editor.$.contains(editor.getBody(), elm);
|
||||
};
|
||||
var isTableCellNode = function (node) {
|
||||
return node && /^(TH|TD)$/.test(node.nodeName);
|
||||
};
|
||||
var isListNode = function (editor) {
|
||||
return function (node) {
|
||||
return node && /^(OL|UL|DL)$/.test(node.nodeName) && isChildOfBody(editor, node);
|
||||
};
|
||||
};
|
||||
var getSelectedStyleType = function (editor) {
|
||||
var listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');
|
||||
return editor.dom.getStyle(listElm, 'listStyleType') || '';
|
||||
};
|
||||
var $_1dfrak85jh8lpuc9 = {
|
||||
isTableCellNode: isTableCellNode,
|
||||
isListNode: isListNode,
|
||||
getSelectedStyleType: getSelectedStyleType
|
||||
};
|
||||
|
||||
ulMenuItems = buildMenuItems('UL', editor.getParam("advlist_bullet_styles", "default,circle,disc,square"));
|
||||
var styleValueToText = function (styleValue) {
|
||||
return styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function (chr) {
|
||||
return chr.toUpperCase();
|
||||
});
|
||||
};
|
||||
var toMenuItems = function (styles) {
|
||||
return global$1.map(styles, function (styleValue) {
|
||||
var text = styleValueToText(styleValue);
|
||||
var data = styleValue === 'default' ? '' : styleValue;
|
||||
return {
|
||||
text: text,
|
||||
data: data
|
||||
};
|
||||
});
|
||||
};
|
||||
var $_et29hm86jh8lpucb = { toMenuItems: toMenuItems };
|
||||
|
||||
function applyListFormat(listName, styleValue) {
|
||||
editor.undoManager.transact(function() {
|
||||
var list, dom = editor.dom, sel = editor.selection;
|
||||
var findIndex = function (list, predicate) {
|
||||
for (var index = 0; index < list.length; index++) {
|
||||
var element = list[index];
|
||||
if (predicate(element)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
var listState = function (editor, listName) {
|
||||
return function (e) {
|
||||
var ctrl = e.control;
|
||||
editor.on('NodeChange', function (e) {
|
||||
var tableCellIndex = findIndex(e.parents, $_1dfrak85jh8lpuc9.isTableCellNode);
|
||||
var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;
|
||||
var lists = global$1.grep(parents, $_1dfrak85jh8lpuc9.isListNode(editor));
|
||||
ctrl.active(lists.length > 0 && lists[0].nodeName === listName);
|
||||
});
|
||||
};
|
||||
};
|
||||
var updateSelection = function (editor) {
|
||||
return function (e) {
|
||||
var listStyleType = $_1dfrak85jh8lpuc9.getSelectedStyleType(editor);
|
||||
e.control.items().each(function (ctrl) {
|
||||
ctrl.active(ctrl.settings.data === listStyleType);
|
||||
});
|
||||
};
|
||||
};
|
||||
var addSplitButton = function (editor, id, tooltip, cmd, nodeName, styles) {
|
||||
editor.addButton(id, {
|
||||
active: false,
|
||||
type: 'splitbutton',
|
||||
tooltip: tooltip,
|
||||
menu: $_et29hm86jh8lpucb.toMenuItems(styles),
|
||||
onPostRender: listState(editor, nodeName),
|
||||
onshow: updateSelection(editor),
|
||||
onselect: function (e) {
|
||||
$_fdwamj82jh8lpuc2.applyListFormat(editor, nodeName, e.control.settings.data);
|
||||
},
|
||||
onclick: function () {
|
||||
editor.execCommand(cmd);
|
||||
}
|
||||
});
|
||||
};
|
||||
var addButton = function (editor, id, tooltip, cmd, nodeName, styles) {
|
||||
editor.addButton(id, {
|
||||
active: false,
|
||||
type: 'button',
|
||||
tooltip: tooltip,
|
||||
onPostRender: listState(editor, nodeName),
|
||||
onclick: function () {
|
||||
editor.execCommand(cmd);
|
||||
}
|
||||
});
|
||||
};
|
||||
var addControl = function (editor, id, tooltip, cmd, nodeName, styles) {
|
||||
if (styles.length > 0) {
|
||||
addSplitButton(editor, id, tooltip, cmd, nodeName, styles);
|
||||
} else {
|
||||
addButton(editor, id, tooltip, cmd, nodeName, styles);
|
||||
}
|
||||
};
|
||||
var register$1 = function (editor) {
|
||||
addControl(editor, 'numlist', 'Numbered list', 'InsertOrderedList', 'OL', $_1c19wf84jh8lpuc8.getNumberStyles(editor));
|
||||
addControl(editor, 'bullist', 'Bullet list', 'InsertUnorderedList', 'UL', $_1c19wf84jh8lpuc8.getBulletStyles(editor));
|
||||
};
|
||||
var $_4t8tbw83jh8lpuc4 = { register: register$1 };
|
||||
|
||||
// Check for existing list element
|
||||
list = dom.getParent(sel.getNode(), 'ol,ul');
|
||||
global.add('advlist', function (editor) {
|
||||
var hasPlugin = function (editor, plugin) {
|
||||
var plugins = editor.settings.plugins ? editor.settings.plugins : '';
|
||||
return global$1.inArray(plugins.split(/[ ,]/), plugin) !== -1;
|
||||
};
|
||||
if (hasPlugin(editor, 'lists')) {
|
||||
$_4t8tbw83jh8lpuc4.register(editor);
|
||||
$_1rj6rj81jh8lpuc0.register(editor);
|
||||
}
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
// Switch/add list type if needed
|
||||
if (!list || list.nodeName != listName || styleValue === false) {
|
||||
editor.execCommand(listName == 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList');
|
||||
}
|
||||
return Plugin;
|
||||
|
||||
// Set style
|
||||
styleValue = styleValue === false ? lastStyles[listName] : styleValue;
|
||||
lastStyles[listName] = styleValue;
|
||||
|
||||
list = dom.getParent(sel.getNode(), 'ol,ul');
|
||||
if (list) {
|
||||
dom.setStyle(list, 'listStyleType', styleValue ? styleValue : null);
|
||||
list.removeAttribute('data-mce-style');
|
||||
}
|
||||
|
||||
editor.focus();
|
||||
});
|
||||
}
|
||||
|
||||
function updateSelection(e) {
|
||||
var listStyleType = editor.dom.getStyle(editor.dom.getParent(editor.selection.getNode(), 'ol,ul'), 'listStyleType') || '';
|
||||
|
||||
e.control.items().each(function(ctrl) {
|
||||
ctrl.active(ctrl.settings.data === listStyleType);
|
||||
});
|
||||
}
|
||||
|
||||
editor.addButton('numlist', {
|
||||
type: 'splitbutton',
|
||||
tooltip: 'Numbered list',
|
||||
menu: olMenuItems,
|
||||
onshow: updateSelection,
|
||||
onselect: function(e) {
|
||||
applyListFormat('OL', e.control.settings.data);
|
||||
},
|
||||
onclick: function() {
|
||||
applyListFormat('OL', false);
|
||||
}
|
||||
});
|
||||
|
||||
editor.addButton('bullist', {
|
||||
type: 'splitbutton',
|
||||
tooltip: 'Bullet list',
|
||||
menu: ulMenuItems,
|
||||
onshow: updateSelection,
|
||||
onselect: function(e) {
|
||||
applyListFormat('UL', e.control.settings.data);
|
||||
},
|
||||
onclick: function() {
|
||||
applyListFormat('UL', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("advlist",function(a){function b(a,b){var c=[];return tinymce.each(b.split(/[ ,]/),function(a){c.push({text:a.replace(/\-/g," ").replace(/\b\w/g,function(a){return a.toUpperCase()}),data:"default"==a?"":a})}),c}function c(b,c){a.undoManager.transact(function(){var d,e=a.dom,f=a.selection;d=e.getParent(f.getNode(),"ol,ul"),d&&d.nodeName==b&&c!==!1||a.execCommand("UL"==b?"InsertUnorderedList":"InsertOrderedList"),c=c===!1?g[b]:c,g[b]=c,d=e.getParent(f.getNode(),"ol,ul"),d&&(e.setStyle(d,"listStyleType",c?c:null),d.removeAttribute("data-mce-style")),a.focus()})}function d(b){var c=a.dom.getStyle(a.dom.getParent(a.selection.getNode(),"ol,ul"),"listStyleType")||"";b.control.items().each(function(a){a.active(a.settings.data===c)})}var e,f,g={};e=b("OL",a.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman")),f=b("UL",a.getParam("advlist_bullet_styles","default,circle,disc,square")),a.addButton("numlist",{type:"splitbutton",tooltip:"Numbered list",menu:e,onshow:d,onselect:function(a){c("OL",a.control.settings.data)},onclick:function(){c("OL",!1)}}),a.addButton("bullist",{type:"splitbutton",tooltip:"Bullet list",menu:f,onshow:d,onselect:function(a){c("UL",a.control.settings.data)},onclick:function(){c("UL",!1)}})});
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=tinymce.util.Tools.resolve("tinymce.util.Tools"),s=function(t,e,n){var r="UL"===e?"InsertUnorderedList":"InsertOrderedList";t.execCommand(r,!1,!1===n?null:{"list-style-type":n})},o=function(n){n.addCommand("ApplyUnorderedListStyle",function(t,e){s(n,"UL",e["list-style-type"])}),n.addCommand("ApplyOrderedListStyle",function(t,e){s(n,"OL",e["list-style-type"])})},e=function(t){var e=t.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman");return e?e.split(/[ ,]/):[]},n=function(t){var e=t.getParam("advlist_bullet_styles","default,circle,disc,square");return e?e.split(/[ ,]/):[]},u=function(t){return t&&/^(TH|TD)$/.test(t.nodeName)},c=function(r){return function(t){return t&&/^(OL|UL|DL)$/.test(t.nodeName)&&(n=t,(e=r).$.contains(e.getBody(),n));var e,n}},d=function(t){var e=t.dom.getParent(t.selection.getNode(),"ol,ul");return t.dom.getStyle(e,"listStyleType")||""},p=function(t){return a.map(t,function(t){return{text:t.replace(/\-/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()}),data:"default"===t?"":t}})},f=function(i,l){return function(t){var o=t.control;i.on("NodeChange",function(t){var e=function(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return n;return-1}(t.parents,u),n=-1!==e?t.parents.slice(0,e):t.parents,r=a.grep(n,c(i));o.active(0<r.length&&r[0].nodeName===l)})}},m=function(e,t,n,r,o,i){var l;e.addButton(t,{active:!1,type:"splitbutton",tooltip:n,menu:p(i),onPostRender:f(e,o),onshow:(l=e,function(t){var e=d(l);t.control.items().each(function(t){t.active(t.settings.data===e)})}),onselect:function(t){s(e,o,t.control.settings.data)},onclick:function(){e.execCommand(r)}})},r=function(t,e,n,r,o,i){var l,a,s,u,c;0<i.length?m(t,e,n,r,o,i):(a=e,s=n,u=r,c=o,(l=t).addButton(a,{active:!1,type:"button",tooltip:s,onPostRender:f(l,c),onclick:function(){l.execCommand(u)}}))},i=function(t){r(t,"numlist","Numbered list","InsertOrderedList","OL",e(t)),r(t,"bullist","Bullet list","InsertUnorderedList","UL",n(t))};t.add("advlist",function(t){var e,n,r;n="lists",r=(e=t).settings.plugins?e.settings.plugins:"",-1!==a.inArray(r.split(/[ ,]/),n)&&(i(t),o(t))})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "anchor" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/anchor')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/anchor'
|
||||
require('./plugin.js');
|
||||
@@ -1,45 +1,118 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var anchor = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('anchor', function(editor) {
|
||||
function showDialog() {
|
||||
var selectedNode = editor.selection.getNode(), name = '';
|
||||
var isValidId = function (id) {
|
||||
return /^[A-Za-z][A-Za-z0-9\-:._]*$/.test(id);
|
||||
};
|
||||
var getId = function (editor) {
|
||||
var selectedNode = editor.selection.getNode();
|
||||
var isAnchor = selectedNode.tagName === 'A' && editor.dom.getAttrib(selectedNode, 'href') === '';
|
||||
return isAnchor ? selectedNode.id || selectedNode.name : '';
|
||||
};
|
||||
var insert = function (editor, id) {
|
||||
var selectedNode = editor.selection.getNode();
|
||||
var isAnchor = selectedNode.tagName === 'A' && editor.dom.getAttrib(selectedNode, 'href') === '';
|
||||
if (isAnchor) {
|
||||
selectedNode.removeAttribute('name');
|
||||
selectedNode.id = id;
|
||||
editor.undoManager.add();
|
||||
} else {
|
||||
editor.focus();
|
||||
editor.selection.collapse(true);
|
||||
editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', { id: id }));
|
||||
}
|
||||
};
|
||||
var $_8muarh8bjh8lpucu = {
|
||||
isValidId: isValidId,
|
||||
getId: getId,
|
||||
insert: insert
|
||||
};
|
||||
|
||||
if (selectedNode.tagName == 'A') {
|
||||
name = selectedNode.name || selectedNode.id || '';
|
||||
}
|
||||
var insertAnchor = function (editor, newId) {
|
||||
if (!$_8muarh8bjh8lpucu.isValidId(newId)) {
|
||||
editor.windowManager.alert('Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.');
|
||||
return true;
|
||||
} else {
|
||||
$_8muarh8bjh8lpucu.insert(editor, newId);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
var open = function (editor) {
|
||||
var currentId = $_8muarh8bjh8lpucu.getId(editor);
|
||||
editor.windowManager.open({
|
||||
title: 'Anchor',
|
||||
body: {
|
||||
type: 'textbox',
|
||||
name: 'id',
|
||||
size: 40,
|
||||
label: 'Id',
|
||||
value: currentId
|
||||
},
|
||||
onsubmit: function (e) {
|
||||
var newId = e.data.id;
|
||||
if (insertAnchor(editor, newId)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
var $_ghc7qg8ajh8lpucs = { open: open };
|
||||
|
||||
editor.windowManager.open({
|
||||
title: 'Anchor',
|
||||
body: {type: 'textbox', name: 'name', size: 40, label: 'Name', value: name},
|
||||
onsubmit: function(e) {
|
||||
editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', {
|
||||
id: e.data.name
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceAnchor', function () {
|
||||
$_ghc7qg8ajh8lpucs.open(editor);
|
||||
});
|
||||
};
|
||||
var $_60epor89jh8lpucr = { register: register };
|
||||
|
||||
editor.addButton('anchor', {
|
||||
icon: 'anchor',
|
||||
tooltip: 'Anchor',
|
||||
onclick: showDialog,
|
||||
stateSelector: 'a:not([href])'
|
||||
});
|
||||
var isAnchorNode = function (node) {
|
||||
return !node.attr('href') && (node.attr('id') || node.attr('name')) && !node.firstChild;
|
||||
};
|
||||
var setContentEditable = function (state) {
|
||||
return function (nodes) {
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (isAnchorNode(nodes[i])) {
|
||||
nodes[i].attr('contenteditable', state);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
var setup = function (editor) {
|
||||
editor.on('PreInit', function () {
|
||||
editor.parser.addNodeFilter('a', setContentEditable('false'));
|
||||
editor.serializer.addNodeFilter('a', setContentEditable(null));
|
||||
});
|
||||
};
|
||||
var $_etc1gj8cjh8lpucv = { setup: setup };
|
||||
|
||||
editor.addMenuItem('anchor', {
|
||||
icon: 'anchor',
|
||||
text: 'Anchor',
|
||||
context: 'insert',
|
||||
onclick: showDialog
|
||||
});
|
||||
});
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('anchor', {
|
||||
icon: 'anchor',
|
||||
tooltip: 'Anchor',
|
||||
cmd: 'mceAnchor',
|
||||
stateSelector: 'a:not([href])'
|
||||
});
|
||||
editor.addMenuItem('anchor', {
|
||||
icon: 'anchor',
|
||||
text: 'Anchor',
|
||||
context: 'insert',
|
||||
cmd: 'mceAnchor'
|
||||
});
|
||||
};
|
||||
var $_6ikf18djh8lpucw = { register: register$1 };
|
||||
|
||||
global.add('anchor', function (editor) {
|
||||
$_etc1gj8cjh8lpucv.setup(editor);
|
||||
$_60epor89jh8lpucr.register(editor);
|
||||
$_6ikf18djh8lpucw.register(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("anchor",function(a){function b(){var b=a.selection.getNode(),c="";"A"==b.tagName&&(c=b.name||b.id||""),a.windowManager.open({title:"Anchor",body:{type:"textbox",name:"name",size:40,label:"Name",value:c},onsubmit:function(b){a.execCommand("mceInsertContent",!1,a.dom.createHTML("a",{id:b.data.name}))}})}a.addButton("anchor",{icon:"anchor",tooltip:"Anchor",onclick:b,stateSelector:"a:not([href])"}),a.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",onclick:b})});
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(t){return/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)},e=function(t){var e=t.selection.getNode();return"A"===e.tagName&&""===t.dom.getAttrib(e,"href")?e.id||e.name:""},i=function(t,e){var n=t.selection.getNode();"A"===n.tagName&&""===t.dom.getAttrib(n,"href")?(n.removeAttribute("name"),n.id=e,t.undoManager.add()):(t.focus(),t.selection.collapse(!0),t.execCommand("mceInsertContent",!1,t.dom.createHTML("a",{id:e})))},n=function(r){var t=e(r);r.windowManager.open({title:"Anchor",body:{type:"textbox",name:"id",size:40,label:"Id",value:t},onsubmit:function(t){var e,n,o=t.data.id;e=r,(a(n=o)?(i(e,n),0):(e.windowManager.alert("Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),1))&&t.preventDefault()}})},o=function(t){t.addCommand("mceAnchor",function(){n(t)})},r=function(o){return function(t){for(var e=0;e<t.length;e++)(n=t[e]).attr("href")||!n.attr("id")&&!n.attr("name")||n.firstChild||t[e].attr("contenteditable",o);var n}},c=function(t){t.on("PreInit",function(){t.parser.addNodeFilter("a",r("false")),t.serializer.addNodeFilter("a",r(null))})},d=function(t){t.addButton("anchor",{icon:"anchor",tooltip:"Anchor",cmd:"mceAnchor",stateSelector:"a:not([href])"}),t.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",cmd:"mceAnchor"})};t.add("anchor",function(t){c(t),o(t),d(t)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "autolink" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/autolink')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/autolink'
|
||||
require('./plugin.js');
|
||||
@@ -1,194 +1,180 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright 2011, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var autolink = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('autolink', function(editor) {
|
||||
var AutoUrlDetectState;
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
editor.on("keydown", function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
return handleEnter(editor);
|
||||
}
|
||||
});
|
||||
var getAutoLinkPattern = function (editor) {
|
||||
return editor.getParam('autolink_pattern', /^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i);
|
||||
};
|
||||
var getDefaultLinkTarget = function (editor) {
|
||||
return editor.getParam('default_link_target', '');
|
||||
};
|
||||
var $_4bcsa48ijh8lpudd = {
|
||||
getAutoLinkPattern: getAutoLinkPattern,
|
||||
getDefaultLinkTarget: getDefaultLinkTarget
|
||||
};
|
||||
|
||||
// Internet Explorer has built-in automatic linking for most cases
|
||||
if (tinymce.Env.ie) {
|
||||
editor.on("focus", function() {
|
||||
if (!AutoUrlDetectState) {
|
||||
AutoUrlDetectState = true;
|
||||
var rangeEqualsDelimiterOrSpace = function (rangeString, delimiter) {
|
||||
return rangeString === delimiter || rangeString === ' ' || rangeString.charCodeAt(0) === 160;
|
||||
};
|
||||
var handleEclipse = function (editor) {
|
||||
parseCurrentLine(editor, -1, '(');
|
||||
};
|
||||
var handleSpacebar = function (editor) {
|
||||
parseCurrentLine(editor, 0, '');
|
||||
};
|
||||
var handleEnter = function (editor) {
|
||||
parseCurrentLine(editor, -1, '');
|
||||
};
|
||||
var scopeIndex = function (container, index) {
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (container.nodeType === 3) {
|
||||
var len = container.data.length;
|
||||
if (index > len) {
|
||||
index = len;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
};
|
||||
var setStart = function (rng, container, offset) {
|
||||
if (container.nodeType !== 1 || container.hasChildNodes()) {
|
||||
rng.setStart(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setStartBefore(container);
|
||||
}
|
||||
};
|
||||
var setEnd = function (rng, container, offset) {
|
||||
if (container.nodeType !== 1 || container.hasChildNodes()) {
|
||||
rng.setEnd(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setEndAfter(container);
|
||||
}
|
||||
};
|
||||
var parseCurrentLine = function (editor, endOffset, delimiter) {
|
||||
var rng, end, start, endContainer, bookmark, text, matches, prev, len, rngText;
|
||||
var autoLinkPattern = $_4bcsa48ijh8lpudd.getAutoLinkPattern(editor);
|
||||
var defaultLinkTarget = $_4bcsa48ijh8lpudd.getDefaultLinkTarget(editor);
|
||||
if (editor.selection.getNode().tagName === 'A') {
|
||||
return;
|
||||
}
|
||||
rng = editor.selection.getRng(true).cloneRange();
|
||||
if (rng.startOffset < 5) {
|
||||
prev = rng.endContainer.previousSibling;
|
||||
if (!prev) {
|
||||
if (!rng.endContainer.firstChild || !rng.endContainer.firstChild.nextSibling) {
|
||||
return;
|
||||
}
|
||||
prev = rng.endContainer.firstChild.nextSibling;
|
||||
}
|
||||
len = prev.length;
|
||||
setStart(rng, prev, len);
|
||||
setEnd(rng, prev, len);
|
||||
if (rng.endOffset < 5) {
|
||||
return;
|
||||
}
|
||||
end = rng.endOffset;
|
||||
endContainer = prev;
|
||||
} else {
|
||||
endContainer = rng.endContainer;
|
||||
if (endContainer.nodeType !== 3 && endContainer.firstChild) {
|
||||
while (endContainer.nodeType !== 3 && endContainer.firstChild) {
|
||||
endContainer = endContainer.firstChild;
|
||||
}
|
||||
if (endContainer.nodeType === 3) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, endContainer.nodeValue.length);
|
||||
}
|
||||
}
|
||||
if (rng.endOffset === 1) {
|
||||
end = 2;
|
||||
} else {
|
||||
end = rng.endOffset - 1 - endOffset;
|
||||
}
|
||||
}
|
||||
start = end;
|
||||
do {
|
||||
setStart(rng, endContainer, end >= 2 ? end - 2 : 0);
|
||||
setEnd(rng, endContainer, end >= 1 ? end - 1 : 0);
|
||||
end -= 1;
|
||||
rngText = rng.toString();
|
||||
} while (rngText !== ' ' && rngText !== '' && rngText.charCodeAt(0) !== 160 && end - 2 >= 0 && rngText !== delimiter);
|
||||
if (rangeEqualsDelimiterOrSpace(rng.toString(), delimiter)) {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
end += 1;
|
||||
} else if (rng.startOffset === 0) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, start);
|
||||
} else {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
}
|
||||
text = rng.toString();
|
||||
if (text.charAt(text.length - 1) === '.') {
|
||||
setEnd(rng, endContainer, start - 1);
|
||||
}
|
||||
text = rng.toString().trim();
|
||||
matches = text.match(autoLinkPattern);
|
||||
if (matches) {
|
||||
if (matches[1] === 'www.') {
|
||||
matches[1] = 'http://www.';
|
||||
} else if (/@$/.test(matches[1]) && !/^mailto:/.test(matches[1])) {
|
||||
matches[1] = 'mailto:' + matches[1];
|
||||
}
|
||||
bookmark = editor.selection.getBookmark();
|
||||
editor.selection.setRng(rng);
|
||||
editor.execCommand('createlink', false, matches[1] + matches[2]);
|
||||
if (defaultLinkTarget) {
|
||||
editor.dom.setAttrib(editor.selection.getNode(), 'target', defaultLinkTarget);
|
||||
}
|
||||
editor.selection.moveToBookmark(bookmark);
|
||||
editor.nodeChanged();
|
||||
}
|
||||
};
|
||||
var setup = function (editor) {
|
||||
var autoUrlDetectState;
|
||||
editor.on('keydown', function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
return handleEnter(editor);
|
||||
}
|
||||
});
|
||||
if (global$1.ie) {
|
||||
editor.on('focus', function () {
|
||||
if (!autoUrlDetectState) {
|
||||
autoUrlDetectState = true;
|
||||
try {
|
||||
editor.execCommand('AutoUrlDetect', false, true);
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
editor.on('keypress', function (e) {
|
||||
if (e.keyCode === 41) {
|
||||
return handleEclipse(editor);
|
||||
}
|
||||
});
|
||||
editor.on('keyup', function (e) {
|
||||
if (e.keyCode === 32) {
|
||||
return handleSpacebar(editor);
|
||||
}
|
||||
});
|
||||
};
|
||||
var $_eary1x8gjh8lpud7 = { setup: setup };
|
||||
|
||||
try {
|
||||
editor.execCommand('AutoUrlDetect', false, true);
|
||||
} catch (ex) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
});
|
||||
global.add('autolink', function (editor) {
|
||||
$_eary1x8gjh8lpud7.setup(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return Plugin;
|
||||
|
||||
editor.on("keypress", function(e) {
|
||||
if (e.keyCode == 41) {
|
||||
return handleEclipse(editor);
|
||||
}
|
||||
});
|
||||
|
||||
editor.on("keyup", function(e) {
|
||||
if (e.keyCode == 32) {
|
||||
return handleSpacebar(editor);
|
||||
}
|
||||
});
|
||||
|
||||
function handleEclipse(editor) {
|
||||
parseCurrentLine(editor, -1, '(', true);
|
||||
}
|
||||
|
||||
function handleSpacebar(editor) {
|
||||
parseCurrentLine(editor, 0, '', true);
|
||||
}
|
||||
|
||||
function handleEnter(editor) {
|
||||
parseCurrentLine(editor, -1, '', false);
|
||||
}
|
||||
|
||||
function parseCurrentLine(editor, end_offset, delimiter) {
|
||||
var rng, end, start, endContainer, bookmark, text, matches, prev, len, rngText;
|
||||
|
||||
function scopeIndex(container, index) {
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (container.nodeType == 3) {
|
||||
var len = container.data.length;
|
||||
|
||||
if (index > len) {
|
||||
index = len;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
function setStart(container, offset) {
|
||||
if (container.nodeType != 1 || container.hasChildNodes()) {
|
||||
rng.setStart(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setStartBefore(container);
|
||||
}
|
||||
}
|
||||
|
||||
function setEnd(container, offset) {
|
||||
if (container.nodeType != 1 || container.hasChildNodes()) {
|
||||
rng.setEnd(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setEndAfter(container);
|
||||
}
|
||||
}
|
||||
|
||||
// We need at least five characters to form a URL,
|
||||
// hence, at minimum, five characters from the beginning of the line.
|
||||
rng = editor.selection.getRng(true).cloneRange();
|
||||
if (rng.startOffset < 5) {
|
||||
// During testing, the caret is placed inbetween two text nodes.
|
||||
// The previous text node contains the URL.
|
||||
prev = rng.endContainer.previousSibling;
|
||||
if (!prev) {
|
||||
if (!rng.endContainer.firstChild || !rng.endContainer.firstChild.nextSibling) {
|
||||
return;
|
||||
}
|
||||
|
||||
prev = rng.endContainer.firstChild.nextSibling;
|
||||
}
|
||||
|
||||
len = prev.length;
|
||||
setStart(prev, len);
|
||||
setEnd(prev, len);
|
||||
|
||||
if (rng.endOffset < 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
end = rng.endOffset;
|
||||
endContainer = prev;
|
||||
} else {
|
||||
endContainer = rng.endContainer;
|
||||
|
||||
// Get a text node
|
||||
if (endContainer.nodeType != 3 && endContainer.firstChild) {
|
||||
while (endContainer.nodeType != 3 && endContainer.firstChild) {
|
||||
endContainer = endContainer.firstChild;
|
||||
}
|
||||
|
||||
// Move range to text node
|
||||
if (endContainer.nodeType == 3) {
|
||||
setStart(endContainer, 0);
|
||||
setEnd(endContainer, endContainer.nodeValue.length);
|
||||
}
|
||||
}
|
||||
|
||||
if (rng.endOffset == 1) {
|
||||
end = 2;
|
||||
} else {
|
||||
end = rng.endOffset - 1 - end_offset;
|
||||
}
|
||||
}
|
||||
|
||||
start = end;
|
||||
|
||||
do {
|
||||
// Move the selection one character backwards.
|
||||
setStart(endContainer, end >= 2 ? end - 2 : 0);
|
||||
setEnd(endContainer, end >= 1 ? end - 1 : 0);
|
||||
end -= 1;
|
||||
rngText = rng.toString();
|
||||
|
||||
// Loop until one of the following is found: a blank space, , delimiter, (end-2) >= 0
|
||||
} while (rngText != ' ' && rngText !== '' && rngText.charCodeAt(0) != 160 && (end - 2) >= 0 && rngText != delimiter);
|
||||
|
||||
if (rng.toString() == delimiter || rng.toString().charCodeAt(0) == 160) {
|
||||
setStart(endContainer, end);
|
||||
setEnd(endContainer, start);
|
||||
end += 1;
|
||||
} else if (rng.startOffset === 0) {
|
||||
setStart(endContainer, 0);
|
||||
setEnd(endContainer, start);
|
||||
} else {
|
||||
setStart(endContainer, end);
|
||||
setEnd(endContainer, start);
|
||||
}
|
||||
|
||||
// Exclude last . from word like "www.site.com."
|
||||
text = rng.toString();
|
||||
if (text.charAt(text.length - 1) == '.') {
|
||||
setEnd(endContainer, start - 1);
|
||||
}
|
||||
|
||||
text = rng.toString();
|
||||
matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i);
|
||||
|
||||
if (matches) {
|
||||
if (matches[1] == 'www.') {
|
||||
matches[1] = 'http://www.';
|
||||
} else if (/@$/.test(matches[1]) && !/^mailto:/.test(matches[1])) {
|
||||
matches[1] = 'mailto:' + matches[1];
|
||||
}
|
||||
|
||||
bookmark = editor.selection.getBookmark();
|
||||
|
||||
editor.selection.setRng(rng);
|
||||
editor.execCommand('createlink', false, matches[1] + matches[2]);
|
||||
editor.selection.moveToBookmark(bookmark);
|
||||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("autolink",function(a){function b(a){e(a,-1,"(",!0)}function c(a){e(a,0,"",!0)}function d(a){e(a,-1,"",!1)}function e(a,b,c){function d(a,b){if(0>b&&(b=0),3==a.nodeType){var c=a.data.length;b>c&&(b=c)}return b}function e(a,b){1!=a.nodeType||a.hasChildNodes()?g.setStart(a,d(a,b)):g.setStartBefore(a)}function f(a,b){1!=a.nodeType||a.hasChildNodes()?g.setEnd(a,d(a,b)):g.setEndAfter(a)}var g,h,i,j,k,l,m,n,o,p;if(g=a.selection.getRng(!0).cloneRange(),g.startOffset<5){if(n=g.endContainer.previousSibling,!n){if(!g.endContainer.firstChild||!g.endContainer.firstChild.nextSibling)return;n=g.endContainer.firstChild.nextSibling}if(o=n.length,e(n,o),f(n,o),g.endOffset<5)return;h=g.endOffset,j=n}else{if(j=g.endContainer,3!=j.nodeType&&j.firstChild){for(;3!=j.nodeType&&j.firstChild;)j=j.firstChild;3==j.nodeType&&(e(j,0),f(j,j.nodeValue.length))}h=1==g.endOffset?2:g.endOffset-1-b}i=h;do e(j,h>=2?h-2:0),f(j,h>=1?h-1:0),h-=1,p=g.toString();while(" "!=p&&""!==p&&160!=p.charCodeAt(0)&&h-2>=0&&p!=c);g.toString()==c||160==g.toString().charCodeAt(0)?(e(j,h),f(j,i),h+=1):0===g.startOffset?(e(j,0),f(j,i)):(e(j,h),f(j,i)),l=g.toString(),"."==l.charAt(l.length-1)&&f(j,i-1),l=g.toString(),m=l.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i),m&&("www."==m[1]?m[1]="http://www.":/@$/.test(m[1])&&!/^mailto:/.test(m[1])&&(m[1]="mailto:"+m[1]),k=a.selection.getBookmark(),a.selection.setRng(g),a.execCommand("createlink",!1,m[1]+m[2]),a.selection.moveToBookmark(k),a.nodeChanged())}var f;return a.on("keydown",function(b){return 13==b.keyCode?d(a):void 0}),tinymce.Env.ie?void a.on("focus",function(){if(!f){f=!0;try{a.execCommand("AutoUrlDetect",!1,!0)}catch(b){}}}):(a.on("keypress",function(c){return 41==c.keyCode?b(a):void 0}),void a.on("keyup",function(b){return 32==b.keyCode?c(a):void 0}))});
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=tinymce.util.Tools.resolve("tinymce.Env"),m=function(e){return e.getParam("autolink_pattern",/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i)},y=function(e){return e.getParam("default_link_target","")},o=function(e,t){if(t<0&&(t=0),3===e.nodeType){var n=e.data.length;n<t&&(t=n)}return t},k=function(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setStart(t,o(t,n)):e.setStartBefore(t)},p=function(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setEnd(t,o(t,n)):e.setEndAfter(t)},r=function(e,t,n){var i,o,r,a,f,s,d,l,c,u,g=m(e),h=y(e);if("A"!==e.selection.getNode().tagName){if((i=e.selection.getRng(!0).cloneRange()).startOffset<5){if(!(l=i.endContainer.previousSibling)){if(!i.endContainer.firstChild||!i.endContainer.firstChild.nextSibling)return;l=i.endContainer.firstChild.nextSibling}if(c=l.length,k(i,l,c),p(i,l,c),i.endOffset<5)return;o=i.endOffset,a=l}else{if(3!==(a=i.endContainer).nodeType&&a.firstChild){for(;3!==a.nodeType&&a.firstChild;)a=a.firstChild;3===a.nodeType&&(k(i,a,0),p(i,a,a.nodeValue.length))}o=1===i.endOffset?2:i.endOffset-1-t}for(r=o;k(i,a,2<=o?o-2:0),p(i,a,1<=o?o-1:0),o-=1," "!==(u=i.toString())&&""!==u&&160!==u.charCodeAt(0)&&0<=o-2&&u!==n;);var C;(C=i.toString())===n||" "===C||160===C.charCodeAt(0)?(k(i,a,o),p(i,a,r),o+=1):(0===i.startOffset?k(i,a,0):k(i,a,o),p(i,a,r)),"."===(s=i.toString()).charAt(s.length-1)&&p(i,a,r-1),(d=(s=i.toString().trim()).match(g))&&("www."===d[1]?d[1]="http://www.":/@$/.test(d[1])&&!/^mailto:/.test(d[1])&&(d[1]="mailto:"+d[1]),f=e.selection.getBookmark(),e.selection.setRng(i),e.execCommand("createlink",!1,d[1]+d[2]),h&&e.dom.setAttrib(e.selection.getNode(),"target",h),e.selection.moveToBookmark(f),e.nodeChanged())}},t=function(t){var n;t.on("keydown",function(e){13!==e.keyCode||r(t,-1,"")}),i.ie?t.on("focus",function(){if(!n){n=!0;try{t.execCommand("AutoUrlDetect",!1,!0)}catch(e){}}}):(t.on("keypress",function(e){41!==e.keyCode||r(t,-1,"(")}),t.on("keyup",function(e){32!==e.keyCode||r(t,0,"")}))};e.add("autolink",function(e){t(e)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "autoresize" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/autoresize')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/autoresize'
|
||||
require('./plugin.js');
|
||||
@@ -1,162 +1,169 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var autoresize = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
/*eslint no-nested-ternary:0 */
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Auto Resize
|
||||
*
|
||||
* This plugin automatically resizes the content area to fit its content height.
|
||||
* It will retain a minimum height, which is the height of the content area when
|
||||
* it's initialized.
|
||||
*/
|
||||
tinymce.PluginManager.add('autoresize', function(editor) {
|
||||
var settings = editor.settings, oldSize = 0;
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
function isFullscreen() {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
}
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
if (editor.settings.inline) {
|
||||
return;
|
||||
}
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
||||
|
||||
/**
|
||||
* This method gets executed each time the editor needs to resize.
|
||||
*/
|
||||
function resize(e) {
|
||||
var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight,
|
||||
marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
|
||||
var getAutoResizeMinHeight = function (editor) {
|
||||
return parseInt(editor.getParam('autoresize_min_height', editor.getElement().offsetHeight), 10);
|
||||
};
|
||||
var getAutoResizeMaxHeight = function (editor) {
|
||||
return parseInt(editor.getParam('autoresize_max_height', 0), 10);
|
||||
};
|
||||
var getAutoResizeOverflowPadding = function (editor) {
|
||||
return editor.getParam('autoresize_overflow_padding', 1);
|
||||
};
|
||||
var getAutoResizeBottomMargin = function (editor) {
|
||||
return editor.getParam('autoresize_bottom_margin', 50);
|
||||
};
|
||||
var shouldAutoResizeOnInit = function (editor) {
|
||||
return editor.getParam('autoresize_on_init', true);
|
||||
};
|
||||
var $_azyemt8qjh8lpue0 = {
|
||||
getAutoResizeMinHeight: getAutoResizeMinHeight,
|
||||
getAutoResizeMaxHeight: getAutoResizeMaxHeight,
|
||||
getAutoResizeOverflowPadding: getAutoResizeOverflowPadding,
|
||||
getAutoResizeBottomMargin: getAutoResizeBottomMargin,
|
||||
shouldAutoResizeOnInit: shouldAutoResizeOnInit
|
||||
};
|
||||
|
||||
doc = editor.getDoc();
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
var isFullscreen = function (editor) {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
};
|
||||
var wait = function (editor, oldSize, times, interval, callback) {
|
||||
global$2.setEditorTimeout(editor, function () {
|
||||
resize(editor, oldSize);
|
||||
if (times--) {
|
||||
wait(editor, oldSize, times, interval, callback);
|
||||
} else if (callback) {
|
||||
callback();
|
||||
}
|
||||
}, interval);
|
||||
};
|
||||
var toggleScrolling = function (editor, state) {
|
||||
var body = editor.getBody();
|
||||
if (body) {
|
||||
body.style.overflowY = state ? '' : 'hidden';
|
||||
if (!state) {
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
var resize = function (editor, oldSize) {
|
||||
var deltaSize, doc, body, resizeHeight, myHeight;
|
||||
var marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
|
||||
var dom = editor.dom;
|
||||
doc = editor.getDoc();
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
if (isFullscreen(editor)) {
|
||||
toggleScrolling(editor, true);
|
||||
return;
|
||||
}
|
||||
body = doc.body;
|
||||
resizeHeight = $_azyemt8qjh8lpue0.getAutoResizeMinHeight(editor);
|
||||
marginTop = dom.getStyle(body, 'margin-top', true);
|
||||
marginBottom = dom.getStyle(body, 'margin-bottom', true);
|
||||
paddingTop = dom.getStyle(body, 'padding-top', true);
|
||||
paddingBottom = dom.getStyle(body, 'padding-bottom', true);
|
||||
borderTop = dom.getStyle(body, 'border-top-width', true);
|
||||
borderBottom = dom.getStyle(body, 'border-bottom-width', true);
|
||||
myHeight = body.offsetHeight + parseInt(marginTop, 10) + parseInt(marginBottom, 10) + parseInt(paddingTop, 10) + parseInt(paddingBottom, 10) + parseInt(borderTop, 10) + parseInt(borderBottom, 10);
|
||||
if (isNaN(myHeight) || myHeight <= 0) {
|
||||
myHeight = global$1.ie ? body.scrollHeight : global$1.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight;
|
||||
}
|
||||
if (myHeight > $_azyemt8qjh8lpue0.getAutoResizeMinHeight(editor)) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
var maxHeight = $_azyemt8qjh8lpue0.getAutoResizeMaxHeight(editor);
|
||||
if (maxHeight && myHeight > maxHeight) {
|
||||
resizeHeight = maxHeight;
|
||||
toggleScrolling(editor, true);
|
||||
} else {
|
||||
toggleScrolling(editor, false);
|
||||
}
|
||||
if (resizeHeight !== oldSize.get()) {
|
||||
deltaSize = resizeHeight - oldSize.get();
|
||||
dom.setStyle(editor.iframeElement, 'height', resizeHeight + 'px');
|
||||
oldSize.set(resizeHeight);
|
||||
if (global$1.webkit && deltaSize < 0) {
|
||||
resize(editor, oldSize);
|
||||
}
|
||||
}
|
||||
};
|
||||
var setup = function (editor, oldSize) {
|
||||
editor.on('init', function () {
|
||||
var overflowPadding, bottomMargin;
|
||||
var dom = editor.dom;
|
||||
overflowPadding = $_azyemt8qjh8lpue0.getAutoResizeOverflowPadding(editor);
|
||||
bottomMargin = $_azyemt8qjh8lpue0.getAutoResizeBottomMargin(editor);
|
||||
if (overflowPadding !== false) {
|
||||
dom.setStyles(editor.getBody(), {
|
||||
paddingLeft: overflowPadding,
|
||||
paddingRight: overflowPadding
|
||||
});
|
||||
}
|
||||
if (bottomMargin !== false) {
|
||||
dom.setStyles(editor.getBody(), { paddingBottom: bottomMargin });
|
||||
}
|
||||
});
|
||||
editor.on('nodechange setcontent keyup FullscreenStateChanged', function (e) {
|
||||
resize(editor, oldSize);
|
||||
});
|
||||
if ($_azyemt8qjh8lpue0.shouldAutoResizeOnInit(editor)) {
|
||||
editor.on('init', function () {
|
||||
wait(editor, oldSize, 20, 100, function () {
|
||||
wait(editor, oldSize, 5, 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
var $_rs2t18njh8lpudw = {
|
||||
setup: setup,
|
||||
resize: resize
|
||||
};
|
||||
|
||||
body = doc.body;
|
||||
docElm = doc.documentElement;
|
||||
resizeHeight = settings.autoresize_min_height;
|
||||
var register = function (editor, oldSize) {
|
||||
editor.addCommand('mceAutoResize', function () {
|
||||
$_rs2t18njh8lpudw.resize(editor, oldSize);
|
||||
});
|
||||
};
|
||||
var $_b0t1u48mjh8lpudv = { register: register };
|
||||
|
||||
if (!body || (e && e.type === "setcontent" && e.initial) || isFullscreen()) {
|
||||
if (body && docElm) {
|
||||
body.style.overflowY = "auto";
|
||||
docElm.style.overflowY = "auto"; // Old IE
|
||||
}
|
||||
global.add('autoresize', function (editor) {
|
||||
if (!editor.inline) {
|
||||
var oldSize = Cell(0);
|
||||
$_b0t1u48mjh8lpudv.register(editor, oldSize);
|
||||
$_rs2t18njh8lpudw.setup(editor, oldSize);
|
||||
}
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return Plugin;
|
||||
|
||||
// Calculate outer height of the body element using CSS styles
|
||||
marginTop = editor.dom.getStyle(body, 'margin-top', true);
|
||||
marginBottom = editor.dom.getStyle(body, 'margin-bottom', true);
|
||||
paddingTop = editor.dom.getStyle(body, 'padding-top', true);
|
||||
paddingBottom = editor.dom.getStyle(body, 'padding-bottom', true);
|
||||
borderTop = editor.dom.getStyle(body, 'border-top-width', true);
|
||||
borderBottom = editor.dom.getStyle(body, 'border-bottom-width', true);
|
||||
myHeight = body.offsetHeight + parseInt(marginTop, 10) + parseInt(marginBottom, 10) +
|
||||
parseInt(paddingTop, 10) + parseInt(paddingBottom, 10) +
|
||||
parseInt(borderTop, 10) + parseInt(borderBottom, 10);
|
||||
|
||||
// Make sure we have a valid height
|
||||
if (isNaN(myHeight) || myHeight <= 0) {
|
||||
// Get height differently depending on the browser used
|
||||
myHeight = tinymce.Env.ie ? body.scrollHeight : (tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight);
|
||||
}
|
||||
|
||||
// Don't make it smaller than the minimum height
|
||||
if (myHeight > settings.autoresize_min_height) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
// If a maximum height has been defined don't exceed this height
|
||||
if (settings.autoresize_max_height && myHeight > settings.autoresize_max_height) {
|
||||
resizeHeight = settings.autoresize_max_height;
|
||||
body.style.overflowY = "auto";
|
||||
docElm.style.overflowY = "auto"; // Old IE
|
||||
} else {
|
||||
body.style.overflowY = "hidden";
|
||||
docElm.style.overflowY = "hidden"; // Old IE
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
|
||||
// Resize content element
|
||||
if (resizeHeight !== oldSize) {
|
||||
deltaSize = resizeHeight - oldSize;
|
||||
DOM.setStyle(editor.iframeElement, 'height', resizeHeight + 'px');
|
||||
oldSize = resizeHeight;
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
||||
// So we need to continue to resize the iframe down until the size gets fixed
|
||||
if (tinymce.isWebKit && deltaSize < 0) {
|
||||
resize(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the resize x times in 100ms intervals. We can't wait for load events since
|
||||
* the CSS files might load async.
|
||||
*/
|
||||
function wait(times, interval, callback) {
|
||||
setTimeout(function() {
|
||||
resize({});
|
||||
|
||||
if (times--) {
|
||||
wait(times, interval, callback);
|
||||
} else if (callback) {
|
||||
callback();
|
||||
}
|
||||
}, interval);
|
||||
}
|
||||
|
||||
// Define minimum height
|
||||
settings.autoresize_min_height = parseInt(editor.getParam('autoresize_min_height', editor.getElement().offsetHeight), 10);
|
||||
|
||||
// Define maximum height
|
||||
settings.autoresize_max_height = parseInt(editor.getParam('autoresize_max_height', 0), 10);
|
||||
|
||||
// Add padding at the bottom for better UX
|
||||
editor.on("init", function() {
|
||||
var overflowPadding, bottomMargin;
|
||||
|
||||
overflowPadding = editor.getParam('autoresize_overflow_padding', 1);
|
||||
bottomMargin = editor.getParam('autoresize_bottom_margin', 50);
|
||||
|
||||
if (overflowPadding !== false) {
|
||||
editor.dom.setStyles(editor.getBody(), {
|
||||
paddingLeft: overflowPadding,
|
||||
paddingRight: overflowPadding
|
||||
});
|
||||
}
|
||||
|
||||
if (bottomMargin !== false) {
|
||||
editor.dom.setStyles(editor.getBody(), {
|
||||
paddingBottom: bottomMargin
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Add appropriate listeners for resizing content area
|
||||
editor.on("nodechange setcontent keyup FullscreenStateChanged", resize);
|
||||
|
||||
if (editor.getParam('autoresize_on_init', true)) {
|
||||
editor.on('init', function() {
|
||||
// Hit it 20 times in 100 ms intervals
|
||||
wait(20, 100, function() {
|
||||
// Hit it 5 times in 1 sec intervals
|
||||
wait(5, 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
||||
editor.addCommand('mceAutoResize', resize);
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("autoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(d){var g,h,i,j,k,l,m,n,o,p,q,r,s=tinymce.DOM;if(h=a.getDoc()){if(i=h.body,j=h.documentElement,k=e.autoresize_min_height,!i||d&&"setcontent"===d.type&&d.initial||b())return void(i&&j&&(i.style.overflowY="auto",j.style.overflowY="auto"));m=a.dom.getStyle(i,"margin-top",!0),n=a.dom.getStyle(i,"margin-bottom",!0),o=a.dom.getStyle(i,"padding-top",!0),p=a.dom.getStyle(i,"padding-bottom",!0),q=a.dom.getStyle(i,"border-top-width",!0),r=a.dom.getStyle(i,"border-bottom-width",!0),l=i.offsetHeight+parseInt(m,10)+parseInt(n,10)+parseInt(o,10)+parseInt(p,10)+parseInt(q,10)+parseInt(r,10),(isNaN(l)||0>=l)&&(l=tinymce.Env.ie?i.scrollHeight:tinymce.Env.webkit&&0===i.clientHeight?0:i.offsetHeight),l>e.autoresize_min_height&&(k=l),e.autoresize_max_height&&l>e.autoresize_max_height?(k=e.autoresize_max_height,i.style.overflowY="auto",j.style.overflowY="auto"):(i.style.overflowY="hidden",j.style.overflowY="hidden",i.scrollTop=0),k!==f&&(g=k-f,s.setStyle(a.iframeElement,"height",k+"px"),f=k,tinymce.isWebKit&&0>g&&c(d))}}function d(a,b,e){setTimeout(function(){c({}),a--?d(a,b,e):e&&e()},b)}var e=a.settings,f=0;a.settings.inline||(e.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),e.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),a.on("init",function(){var b,c;b=a.getParam("autoresize_overflow_padding",1),c=a.getParam("autoresize_bottom_margin",50),b!==!1&&a.dom.setStyles(a.getBody(),{paddingLeft:b,paddingRight:b}),c!==!1&&a.dom.setStyles(a.getBody(),{paddingBottom:c})}),a.on("nodechange setcontent keyup FullscreenStateChanged",c),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){d(20,100,function(){d(5,1e3)})}),a.addCommand("mceAutoResize",c))});
|
||||
!function(){"use strict";var i=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return i(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),y=tinymce.util.Tools.resolve("tinymce.Env"),r=tinymce.util.Tools.resolve("tinymce.util.Delay"),h=function(t){return parseInt(t.getParam("autoresize_min_height",t.getElement().offsetHeight),10)},v=function(t){return parseInt(t.getParam("autoresize_max_height",0),10)},o=function(t){return t.getParam("autoresize_overflow_padding",1)},a=function(t){return t.getParam("autoresize_bottom_margin",50)},n=function(t){return t.getParam("autoresize_on_init",!0)},u=function(t,e,n,i,o){r.setEditorTimeout(t,function(){_(t,e),n--?u(t,e,n,i,o):o&&o()},i)},S=function(t,e){var n=t.getBody();n&&(n.style.overflowY=e?"":"hidden",e||(n.scrollTop=0))},_=function(t,e){var n,i,o,r,a,u,s,l,g,c,f,d=t.dom;if(i=t.getDoc())if((m=t).plugins.fullscreen&&m.plugins.fullscreen.isFullscreen())S(t,!0);else{var m;o=i.body,r=h(t),u=d.getStyle(o,"margin-top",!0),s=d.getStyle(o,"margin-bottom",!0),l=d.getStyle(o,"padding-top",!0),g=d.getStyle(o,"padding-bottom",!0),c=d.getStyle(o,"border-top-width",!0),f=d.getStyle(o,"border-bottom-width",!0),a=o.offsetHeight+parseInt(u,10)+parseInt(s,10)+parseInt(l,10)+parseInt(g,10)+parseInt(c,10)+parseInt(f,10),(isNaN(a)||a<=0)&&(a=y.ie?o.scrollHeight:y.webkit&&0===o.clientHeight?0:o.offsetHeight),a>h(t)&&(r=a);var p=v(t);p&&p<a?(r=p,S(t,!0)):S(t,!1),r!==e.get()&&(n=r-e.get(),d.setStyle(t.iframeElement,"height",r+"px"),e.set(r),y.webkit&&n<0&&_(t,e))}},s={setup:function(i,e){i.on("init",function(){var t,e,n=i.dom;t=o(i),e=a(i),!1!==t&&n.setStyles(i.getBody(),{paddingLeft:t,paddingRight:t}),!1!==e&&n.setStyles(i.getBody(),{paddingBottom:e})}),i.on("nodechange setcontent keyup FullscreenStateChanged",function(t){_(i,e)}),n(i)&&i.on("init",function(){u(i,e,20,100,function(){u(i,e,5,1e3)})})},resize:_},l=function(t,e){t.addCommand("mceAutoResize",function(){s.resize(t,e)})};t.add("autoresize",function(t){if(!t.inline){var e=i(0);l(t,e),s.setup(t,e)}})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "autosave" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/autosave')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/autosave'
|
||||
require('./plugin.js');
|
||||
@@ -1,165 +1,226 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var autosave = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
// Internal unload handler will be called before the page is unloaded
|
||||
// Needs to be outside the plugin since it would otherwise keep
|
||||
// a reference to editor in closue scope
|
||||
/*eslint no-func-assign:0 */
|
||||
tinymce._beforeUnloadHandler = function() {
|
||||
var msg;
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.each(tinymce.editors, function(editor) {
|
||||
// Store a draft for each editor instance
|
||||
if (editor.plugins.autosave) {
|
||||
editor.plugins.autosave.storeDraft();
|
||||
}
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.LocalStorage');
|
||||
|
||||
// Setup a return message if the editor is dirty
|
||||
if (!msg && editor.isDirty() && editor.getParam("autosave_ask_before_unload", true)) {
|
||||
msg = editor.translate("You have unsaved changes are you sure you want to navigate away?");
|
||||
}
|
||||
});
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
return msg;
|
||||
};
|
||||
var fireRestoreDraft = function (editor) {
|
||||
return editor.fire('RestoreDraft');
|
||||
};
|
||||
var fireStoreDraft = function (editor) {
|
||||
return editor.fire('StoreDraft');
|
||||
};
|
||||
var fireRemoveDraft = function (editor) {
|
||||
return editor.fire('RemoveDraft');
|
||||
};
|
||||
var $_f1sskd8yjh8lpueq = {
|
||||
fireRestoreDraft: fireRestoreDraft,
|
||||
fireStoreDraft: fireStoreDraft,
|
||||
fireRemoveDraft: fireRemoveDraft
|
||||
};
|
||||
|
||||
tinymce.PluginManager.add('autosave', function(editor) {
|
||||
var settings = editor.settings, LocalStorage = tinymce.util.LocalStorage, prefix, started;
|
||||
var parse = function (time, defaultTime) {
|
||||
var multiples = {
|
||||
s: 1000,
|
||||
m: 60000
|
||||
};
|
||||
time = /^(\d+)([ms]?)$/.exec('' + (time || defaultTime));
|
||||
return (time[2] ? multiples[time[2]] : 1) * parseInt(time, 10);
|
||||
};
|
||||
var $_53ht7990jh8lpuet = { parse: parse };
|
||||
|
||||
prefix = settings.autosave_prefix || 'tinymce-autosave-{path}{query}-{id}-';
|
||||
prefix = prefix.replace(/\{path\}/g, document.location.pathname);
|
||||
prefix = prefix.replace(/\{query\}/g, document.location.search);
|
||||
prefix = prefix.replace(/\{id\}/g, editor.id);
|
||||
var shouldAskBeforeUnload = function (editor) {
|
||||
return editor.getParam('autosave_ask_before_unload', true);
|
||||
};
|
||||
var getAutoSavePrefix = function (editor) {
|
||||
var prefix = editor.getParam('autosave_prefix', 'tinymce-autosave-{path}{query}{hash}-{id}-');
|
||||
prefix = prefix.replace(/\{path\}/g, document.location.pathname);
|
||||
prefix = prefix.replace(/\{query\}/g, document.location.search);
|
||||
prefix = prefix.replace(/\{hash\}/g, document.location.hash);
|
||||
prefix = prefix.replace(/\{id\}/g, editor.id);
|
||||
return prefix;
|
||||
};
|
||||
var shouldRestoreWhenEmpty = function (editor) {
|
||||
return editor.getParam('autosave_restore_when_empty', false);
|
||||
};
|
||||
var getAutoSaveInterval = function (editor) {
|
||||
return $_53ht7990jh8lpuet.parse(editor.settings.autosave_interval, '30s');
|
||||
};
|
||||
var getAutoSaveRetention = function (editor) {
|
||||
return $_53ht7990jh8lpuet.parse(editor.settings.autosave_retention, '20m');
|
||||
};
|
||||
var $_2f8zxp8zjh8lpuer = {
|
||||
shouldAskBeforeUnload: shouldAskBeforeUnload,
|
||||
getAutoSavePrefix: getAutoSavePrefix,
|
||||
shouldRestoreWhenEmpty: shouldRestoreWhenEmpty,
|
||||
getAutoSaveInterval: getAutoSaveInterval,
|
||||
getAutoSaveRetention: getAutoSaveRetention
|
||||
};
|
||||
|
||||
function parseTime(time, defaultTime) {
|
||||
var multipels = {
|
||||
s: 1000,
|
||||
m: 60000
|
||||
};
|
||||
var isEmpty = function (editor, html) {
|
||||
var forcedRootBlockName = editor.settings.forced_root_block;
|
||||
html = global$2.trim(typeof html === 'undefined' ? editor.getBody().innerHTML : html);
|
||||
return html === '' || new RegExp('^<' + forcedRootBlockName + '[^>]*>((\xA0| |[ \t]|<br[^>]*>)+?|)</' + forcedRootBlockName + '>|<br>$', 'i').test(html);
|
||||
};
|
||||
var hasDraft = function (editor) {
|
||||
var time = parseInt(global$1.getItem($_2f8zxp8zjh8lpuer.getAutoSavePrefix(editor) + 'time'), 10) || 0;
|
||||
if (new Date().getTime() - time > $_2f8zxp8zjh8lpuer.getAutoSaveRetention(editor)) {
|
||||
removeDraft(editor, false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
var removeDraft = function (editor, fire) {
|
||||
var prefix = $_2f8zxp8zjh8lpuer.getAutoSavePrefix(editor);
|
||||
global$1.removeItem(prefix + 'draft');
|
||||
global$1.removeItem(prefix + 'time');
|
||||
if (fire !== false) {
|
||||
$_f1sskd8yjh8lpueq.fireRemoveDraft(editor);
|
||||
}
|
||||
};
|
||||
var storeDraft = function (editor) {
|
||||
var prefix = $_2f8zxp8zjh8lpuer.getAutoSavePrefix(editor);
|
||||
if (!isEmpty(editor) && editor.isDirty()) {
|
||||
global$1.setItem(prefix + 'draft', editor.getContent({
|
||||
format: 'raw',
|
||||
no_events: true
|
||||
}));
|
||||
global$1.setItem(prefix + 'time', new Date().getTime().toString());
|
||||
$_f1sskd8yjh8lpueq.fireStoreDraft(editor);
|
||||
}
|
||||
};
|
||||
var restoreDraft = function (editor) {
|
||||
var prefix = $_2f8zxp8zjh8lpuer.getAutoSavePrefix(editor);
|
||||
if (hasDraft(editor)) {
|
||||
editor.setContent(global$1.getItem(prefix + 'draft'), { format: 'raw' });
|
||||
$_f1sskd8yjh8lpueq.fireRestoreDraft(editor);
|
||||
}
|
||||
};
|
||||
var startStoreDraft = function (editor, started) {
|
||||
var interval = $_2f8zxp8zjh8lpuer.getAutoSaveInterval(editor);
|
||||
if (!started.get()) {
|
||||
setInterval(function () {
|
||||
if (!editor.removed) {
|
||||
storeDraft(editor);
|
||||
}
|
||||
}, interval);
|
||||
started.set(true);
|
||||
}
|
||||
};
|
||||
var restoreLastDraft = function (editor) {
|
||||
editor.undoManager.transact(function () {
|
||||
restoreDraft(editor);
|
||||
removeDraft(editor);
|
||||
});
|
||||
editor.focus();
|
||||
};
|
||||
var $_rquxx8vjh8lpuem = {
|
||||
isEmpty: isEmpty,
|
||||
hasDraft: hasDraft,
|
||||
removeDraft: removeDraft,
|
||||
storeDraft: storeDraft,
|
||||
restoreDraft: restoreDraft,
|
||||
startStoreDraft: startStoreDraft,
|
||||
restoreLastDraft: restoreLastDraft
|
||||
};
|
||||
|
||||
time = /^(\d+)([ms]?)$/.exec('' + (time || defaultTime));
|
||||
var curry = function (f, editor) {
|
||||
return function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
return f.apply(null, [editor].concat(args));
|
||||
};
|
||||
};
|
||||
var get = function (editor) {
|
||||
return {
|
||||
hasDraft: curry($_rquxx8vjh8lpuem.hasDraft, editor),
|
||||
storeDraft: curry($_rquxx8vjh8lpuem.storeDraft, editor),
|
||||
restoreDraft: curry($_rquxx8vjh8lpuem.restoreDraft, editor),
|
||||
removeDraft: curry($_rquxx8vjh8lpuem.removeDraft, editor),
|
||||
isEmpty: curry($_rquxx8vjh8lpuem.isEmpty, editor)
|
||||
};
|
||||
};
|
||||
var $_7mdhyp8ujh8lpuek = { get: get };
|
||||
|
||||
return (time[2] ? multipels[time[2]] : 1) * parseInt(time, 10);
|
||||
}
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
||||
|
||||
function hasDraft() {
|
||||
var time = parseInt(LocalStorage.getItem(prefix + "time"), 10) || 0;
|
||||
global$3._beforeUnloadHandler = function () {
|
||||
var msg;
|
||||
global$2.each(global$3.get(), function (editor) {
|
||||
if (editor.plugins.autosave) {
|
||||
editor.plugins.autosave.storeDraft();
|
||||
}
|
||||
if (!msg && editor.isDirty() && $_2f8zxp8zjh8lpuer.shouldAskBeforeUnload(editor)) {
|
||||
msg = editor.translate('You have unsaved changes are you sure you want to navigate away?');
|
||||
}
|
||||
});
|
||||
return msg;
|
||||
};
|
||||
var setup = function (editor) {
|
||||
window.onbeforeunload = global$3._beforeUnloadHandler;
|
||||
};
|
||||
var $_3yv5rq91jh8lpuev = { setup: setup };
|
||||
|
||||
if (new Date().getTime() - time > settings.autosave_retention) {
|
||||
removeDraft(false);
|
||||
return false;
|
||||
}
|
||||
var postRender = function (editor, started) {
|
||||
return function (e) {
|
||||
var ctrl = e.control;
|
||||
ctrl.disabled(!$_rquxx8vjh8lpuem.hasDraft(editor));
|
||||
editor.on('StoreDraft RestoreDraft RemoveDraft', function () {
|
||||
ctrl.disabled(!$_rquxx8vjh8lpuem.hasDraft(editor));
|
||||
});
|
||||
$_rquxx8vjh8lpuem.startStoreDraft(editor, started);
|
||||
};
|
||||
};
|
||||
var register = function (editor, started) {
|
||||
editor.addButton('restoredraft', {
|
||||
title: 'Restore last draft',
|
||||
onclick: function () {
|
||||
$_rquxx8vjh8lpuem.restoreLastDraft(editor);
|
||||
},
|
||||
onPostRender: postRender(editor, started)
|
||||
});
|
||||
editor.addMenuItem('restoredraft', {
|
||||
text: 'Restore last draft',
|
||||
onclick: function () {
|
||||
$_rquxx8vjh8lpuem.restoreLastDraft(editor);
|
||||
},
|
||||
onPostRender: postRender(editor, started),
|
||||
context: 'file'
|
||||
});
|
||||
};
|
||||
var $_sngoy93jh8lpuex = { register: register };
|
||||
|
||||
return true;
|
||||
}
|
||||
global.add('autosave', function (editor) {
|
||||
var started = Cell(false);
|
||||
$_3yv5rq91jh8lpuev.setup(editor);
|
||||
$_sngoy93jh8lpuex.register(editor, started);
|
||||
return $_7mdhyp8ujh8lpuek.get(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
function removeDraft(fire) {
|
||||
LocalStorage.removeItem(prefix + "draft");
|
||||
LocalStorage.removeItem(prefix + "time");
|
||||
return Plugin;
|
||||
|
||||
if (fire !== false) {
|
||||
editor.fire('RemoveDraft');
|
||||
}
|
||||
}
|
||||
|
||||
function storeDraft() {
|
||||
if (!isEmpty() && editor.isDirty()) {
|
||||
LocalStorage.setItem(prefix + "draft", editor.getContent({format: 'raw', no_events: true}));
|
||||
LocalStorage.setItem(prefix + "time", new Date().getTime());
|
||||
editor.fire('StoreDraft');
|
||||
}
|
||||
}
|
||||
|
||||
function restoreDraft() {
|
||||
if (hasDraft()) {
|
||||
editor.setContent(LocalStorage.getItem(prefix + "draft"), {format: 'raw'});
|
||||
editor.fire('RestoreDraft');
|
||||
}
|
||||
}
|
||||
|
||||
function startStoreDraft() {
|
||||
if (!started) {
|
||||
setInterval(function() {
|
||||
if (!editor.removed) {
|
||||
storeDraft();
|
||||
}
|
||||
}, settings.autosave_interval);
|
||||
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
|
||||
settings.autosave_interval = parseTime(settings.autosave_interval, '30s');
|
||||
settings.autosave_retention = parseTime(settings.autosave_retention, '20m');
|
||||
|
||||
function postRender() {
|
||||
var self = this;
|
||||
|
||||
self.disabled(!hasDraft());
|
||||
|
||||
editor.on('StoreDraft RestoreDraft RemoveDraft', function() {
|
||||
self.disabled(!hasDraft());
|
||||
});
|
||||
|
||||
startStoreDraft();
|
||||
}
|
||||
|
||||
function restoreLastDraft() {
|
||||
editor.undoManager.beforeChange();
|
||||
restoreDraft();
|
||||
removeDraft();
|
||||
editor.undoManager.add();
|
||||
}
|
||||
|
||||
editor.addButton('restoredraft', {
|
||||
title: 'Restore last draft',
|
||||
onclick: restoreLastDraft,
|
||||
onPostRender: postRender
|
||||
});
|
||||
|
||||
editor.addMenuItem('restoredraft', {
|
||||
text: 'Restore last draft',
|
||||
onclick: restoreLastDraft,
|
||||
onPostRender: postRender,
|
||||
context: 'file'
|
||||
});
|
||||
|
||||
function isEmpty(html) {
|
||||
var forcedRootBlockName = editor.settings.forced_root_block;
|
||||
|
||||
html = tinymce.trim(typeof html == "undefined" ? editor.getBody().innerHTML : html);
|
||||
|
||||
return html === '' || new RegExp(
|
||||
'^<' + forcedRootBlockName + '[^>]*>((\u00a0| |[ \t]|<br[^>]*>)+?|)<\/' + forcedRootBlockName + '>|<br>$', 'i'
|
||||
).test(html);
|
||||
}
|
||||
|
||||
if (editor.settings.autosave_restore_when_empty !== false) {
|
||||
editor.on('init', function() {
|
||||
if (hasDraft() && isEmpty()) {
|
||||
restoreDraft();
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('saveContent', function() {
|
||||
removeDraft();
|
||||
});
|
||||
}
|
||||
|
||||
window.onbeforeunload = tinymce._beforeUnloadHandler;
|
||||
|
||||
this.hasDraft = hasDraft;
|
||||
this.storeDraft = storeDraft;
|
||||
this.restoreDraft = restoreDraft;
|
||||
this.removeDraft = removeDraft;
|
||||
this.isEmpty = isEmpty;
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce._beforeUnloadHandler=function(){var a;return tinymce.each(tinymce.editors,function(b){b.plugins.autosave&&b.plugins.autosave.storeDraft(),!a&&b.isDirty()&&b.getParam("autosave_ask_before_unload",!0)&&(a=b.translate("You have unsaved changes are you sure you want to navigate away?"))}),a},tinymce.PluginManager.add("autosave",function(a){function b(a,b){var c={s:1e3,m:6e4};return a=/^(\d+)([ms]?)$/.exec(""+(a||b)),(a[2]?c[a[2]]:1)*parseInt(a,10)}function c(){var a=parseInt(n.getItem(k+"time"),10)||0;return(new Date).getTime()-a>m.autosave_retention?(d(!1),!1):!0}function d(b){n.removeItem(k+"draft"),n.removeItem(k+"time"),b!==!1&&a.fire("RemoveDraft")}function e(){!j()&&a.isDirty()&&(n.setItem(k+"draft",a.getContent({format:"raw",no_events:!0})),n.setItem(k+"time",(new Date).getTime()),a.fire("StoreDraft"))}function f(){c()&&(a.setContent(n.getItem(k+"draft"),{format:"raw"}),a.fire("RestoreDraft"))}function g(){l||(setInterval(function(){a.removed||e()},m.autosave_interval),l=!0)}function h(){var b=this;b.disabled(!c()),a.on("StoreDraft RestoreDraft RemoveDraft",function(){b.disabled(!c())}),g()}function i(){a.undoManager.beforeChange(),f(),d(),a.undoManager.add()}function j(b){var c=a.settings.forced_root_block;return b=tinymce.trim("undefined"==typeof b?a.getBody().innerHTML:b),""===b||new RegExp("^<"+c+"[^>]*>((\xa0| |[ ]|<br[^>]*>)+?|)</"+c+">|<br>$","i").test(b)}var k,l,m=a.settings,n=tinymce.util.LocalStorage;k=m.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",k=k.replace(/\{path\}/g,document.location.pathname),k=k.replace(/\{query\}/g,document.location.search),k=k.replace(/\{id\}/g,a.id),m.autosave_interval=b(m.autosave_interval,"30s"),m.autosave_retention=b(m.autosave_retention,"20m"),a.addButton("restoredraft",{title:"Restore last draft",onclick:i,onPostRender:h}),a.addMenuItem("restoredraft",{text:"Restore last draft",onclick:i,onPostRender:h,context:"file"}),a.settings.autosave_restore_when_empty!==!1&&(a.on("init",function(){c()&&j()&&f()}),a.on("saveContent",function(){d()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=c,this.storeDraft=e,this.restoreDraft=f,this.removeDraft=d,this.isEmpty=j});
|
||||
!function(){"use strict";var n=function(t){var e=t,r=function(){return e};return{get:r,set:function(t){e=t},clone:function(){return n(r())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),o=tinymce.util.Tools.resolve("tinymce.util.Tools"),r=function(t){return t.fire("RestoreDraft")},i=function(t){return t.fire("StoreDraft")},s=function(t){return t.fire("RemoveDraft")},e=function(t,e){return((t=/^(\d+)([ms]?)$/.exec(""+(t||e)))[2]?{s:1e3,m:6e4}[t[2]]:1)*parseInt(t,10)},u=function(t){return t.getParam("autosave_ask_before_unload",!0)},f=function(t){var e=t.getParam("autosave_prefix","tinymce-autosave-{path}{query}{hash}-{id}-");return e=(e=(e=(e=e.replace(/\{path\}/g,document.location.pathname)).replace(/\{query\}/g,document.location.search)).replace(/\{hash\}/g,document.location.hash)).replace(/\{id\}/g,t.id)},c=function(t){return e(t.settings.autosave_interval,"30s")},l=function(t){return e(t.settings.autosave_retention,"20m")},m=function(t,e){var r=t.settings.forced_root_block;return""===(e=o.trim(void 0===e?t.getBody().innerHTML:e))||new RegExp("^<"+r+"[^>]*>((\xa0| |[ \t]|<br[^>]*>)+?|)</"+r+">|<br>$","i").test(e)},v=function(t){var e=parseInt(a.getItem(f(t)+"time"),10)||0;return!((new Date).getTime()-e>l(t)&&(d(t,!1),1))},d=function(t,e){var r=f(t);a.removeItem(r+"draft"),a.removeItem(r+"time"),!1!==e&&s(t)},D=function(t){var e=f(t);!m(t)&&t.isDirty()&&(a.setItem(e+"draft",t.getContent({format:"raw",no_events:!0})),a.setItem(e+"time",(new Date).getTime().toString()),i(t))},g=function(t){var e=f(t);v(t)&&(t.setContent(a.getItem(e+"draft"),{format:"raw"}),r(t))},y={isEmpty:m,hasDraft:v,removeDraft:d,storeDraft:D,restoreDraft:g,startStoreDraft:function(t,e){var r=c(t);e.get()||(setInterval(function(){t.removed||D(t)},r),e.set(!0))},restoreLastDraft:function(t){t.undoManager.transact(function(){g(t),d(t)}),t.focus()}},p=function(e,r){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[r].concat(t))}},h=function(t){return{hasDraft:p(y.hasDraft,t),storeDraft:p(y.storeDraft,t),restoreDraft:p(y.restoreDraft,t),removeDraft:p(y.removeDraft,t),isEmpty:p(y.isEmpty,t)}},_=tinymce.util.Tools.resolve("tinymce.EditorManager");_._beforeUnloadHandler=function(){var e;return o.each(_.get(),function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&u(t)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e};var b=function(t){window.onbeforeunload=_._beforeUnloadHandler},I=function(r,n){return function(t){var e=t.control;e.disabled(!y.hasDraft(r)),r.on("StoreDraft RestoreDraft RemoveDraft",function(){e.disabled(!y.hasDraft(r))}),y.startStoreDraft(r,n)}},w=function(t,e){t.addButton("restoredraft",{title:"Restore last draft",onclick:function(){y.restoreLastDraft(t)},onPostRender:I(t,e)}),t.addMenuItem("restoredraft",{text:"Restore last draft",onclick:function(){y.restoreLastDraft(t)},onPostRender:I(t,e),context:"file"})};t.add("autosave",function(t){var e=n(!1);return b(t),w(t,e),h(t)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "bbcode" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/bbcode')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/bbcode'
|
||||
require('./plugin.js');
|
||||
@@ -1,123 +1,101 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var bbcode = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.BBCodePlugin', {
|
||||
init: function(ed) {
|
||||
var self = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase();
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
ed.on('beforeSetContent', function(e) {
|
||||
e.content = self['_' + dialect + '_bbcode2html'](e.content);
|
||||
});
|
||||
var html2bbcode = function (s) {
|
||||
s = global$1.trim(s);
|
||||
var rep = function (re, str) {
|
||||
s = s.replace(re, str);
|
||||
};
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi, '[url=$1]$2[/url]');
|
||||
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi, '[code][color=$1]$2[/color][/code]');
|
||||
rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi, '[quote][color=$1]$2[/color][/quote]');
|
||||
rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, '[code][color=$1]$2[/color][/code]');
|
||||
rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, '[quote][color=$1]$2[/color][/quote]');
|
||||
rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi, '[color=$1]$2[/color]');
|
||||
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, '[color=$1]$2[/color]');
|
||||
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi, '[size=$1]$2[/size]');
|
||||
rep(/<font>(.*?)<\/font>/gi, '$1');
|
||||
rep(/<img.*?src=\"(.*?)\".*?\/>/gi, '[img]$1[/img]');
|
||||
rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi, '[code]$1[/code]');
|
||||
rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi, '[quote]$1[/quote]');
|
||||
rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi, '[code][b]$1[/b][/code]');
|
||||
rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi, '[quote][b]$1[/b][/quote]');
|
||||
rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi, '[code][i]$1[/i][/code]');
|
||||
rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi, '[quote][i]$1[/i][/quote]');
|
||||
rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi, '[code][u]$1[/u][/code]');
|
||||
rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi, '[quote][u]$1[/u][/quote]');
|
||||
rep(/<\/(strong|b)>/gi, '[/b]');
|
||||
rep(/<(strong|b)>/gi, '[b]');
|
||||
rep(/<\/(em|i)>/gi, '[/i]');
|
||||
rep(/<(em|i)>/gi, '[i]');
|
||||
rep(/<\/u>/gi, '[/u]');
|
||||
rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi, '[u]$1[/u]');
|
||||
rep(/<u>/gi, '[u]');
|
||||
rep(/<blockquote[^>]*>/gi, '[quote]');
|
||||
rep(/<\/blockquote>/gi, '[/quote]');
|
||||
rep(/<br \/>/gi, '\n');
|
||||
rep(/<br\/>/gi, '\n');
|
||||
rep(/<br>/gi, '\n');
|
||||
rep(/<p>/gi, '');
|
||||
rep(/<\/p>/gi, '\n');
|
||||
rep(/ |\u00a0/gi, ' ');
|
||||
rep(/"/gi, '"');
|
||||
rep(/</gi, '<');
|
||||
rep(/>/gi, '>');
|
||||
rep(/&/gi, '&');
|
||||
return s;
|
||||
};
|
||||
var bbcode2html = function (s) {
|
||||
s = global$1.trim(s);
|
||||
var rep = function (re, str) {
|
||||
s = s.replace(re, str);
|
||||
};
|
||||
rep(/\n/gi, '<br />');
|
||||
rep(/\[b\]/gi, '<strong>');
|
||||
rep(/\[\/b\]/gi, '</strong>');
|
||||
rep(/\[i\]/gi, '<em>');
|
||||
rep(/\[\/i\]/gi, '</em>');
|
||||
rep(/\[u\]/gi, '<u>');
|
||||
rep(/\[\/u\]/gi, '</u>');
|
||||
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi, '<a href="$1">$2</a>');
|
||||
rep(/\[url\](.*?)\[\/url\]/gi, '<a href="$1">$1</a>');
|
||||
rep(/\[img\](.*?)\[\/img\]/gi, '<img src="$1" />');
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi, '<font color="$1">$2</font>');
|
||||
rep(/\[code\](.*?)\[\/code\]/gi, '<span class="codeStyle">$1</span> ');
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi, '<span class="quoteStyle">$1</span> ');
|
||||
return s;
|
||||
};
|
||||
var $_1c4yfk96jh8lpufd = {
|
||||
html2bbcode: html2bbcode,
|
||||
bbcode2html: bbcode2html
|
||||
};
|
||||
|
||||
ed.on('postProcess', function(e) {
|
||||
if (e.set) {
|
||||
e.content = self['_' + dialect + '_bbcode2html'](e.content);
|
||||
}
|
||||
global.add('bbcode', function () {
|
||||
return {
|
||||
init: function (editor) {
|
||||
editor.on('beforeSetContent', function (e) {
|
||||
e.content = $_1c4yfk96jh8lpufd.bbcode2html(e.content);
|
||||
});
|
||||
editor.on('postProcess', function (e) {
|
||||
if (e.set) {
|
||||
e.content = $_1c4yfk96jh8lpufd.bbcode2html(e.content);
|
||||
}
|
||||
if (e.get) {
|
||||
e.content = $_1c4yfk96jh8lpufd.html2bbcode(e.content);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
if (e.get) {
|
||||
e.content = self['_' + dialect + '_html2bbcode'](e.content);
|
||||
}
|
||||
});
|
||||
},
|
||||
return Plugin;
|
||||
|
||||
getInfo: function() {
|
||||
return {
|
||||
longname: 'BBCode Plugin',
|
||||
author: 'Moxiecode Systems AB',
|
||||
authorurl: 'http://www.tinymce.com',
|
||||
infourl: 'http://www.tinymce.com/wiki.php/Plugin:bbcode'
|
||||
};
|
||||
},
|
||||
|
||||
// Private methods
|
||||
|
||||
// HTML -> BBCode in PunBB dialect
|
||||
_punbb_html2bbcode: function(s) {
|
||||
s = tinymce.trim(s);
|
||||
|
||||
function rep(re, str) {
|
||||
s = s.replace(re, str);
|
||||
}
|
||||
|
||||
// example: <strong> to [b]
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi, "[url=$1]$2[/url]");
|
||||
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi, "[code][color=$1]$2[/color][/code]");
|
||||
rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi, "[quote][color=$1]$2[/color][/quote]");
|
||||
rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, "[code][color=$1]$2[/color][/code]");
|
||||
rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, "[quote][color=$1]$2[/color][/quote]");
|
||||
rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi, "[color=$1]$2[/color]");
|
||||
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, "[color=$1]$2[/color]");
|
||||
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi, "[size=$1]$2[/size]");
|
||||
rep(/<font>(.*?)<\/font>/gi, "$1");
|
||||
rep(/<img.*?src=\"(.*?)\".*?\/>/gi, "[img]$1[/img]");
|
||||
rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi, "[code]$1[/code]");
|
||||
rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi, "[quote]$1[/quote]");
|
||||
rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi, "[code][b]$1[/b][/code]");
|
||||
rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi, "[quote][b]$1[/b][/quote]");
|
||||
rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi, "[code][i]$1[/i][/code]");
|
||||
rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi, "[quote][i]$1[/i][/quote]");
|
||||
rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi, "[code][u]$1[/u][/code]");
|
||||
rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi, "[quote][u]$1[/u][/quote]");
|
||||
rep(/<\/(strong|b)>/gi, "[/b]");
|
||||
rep(/<(strong|b)>/gi, "[b]");
|
||||
rep(/<\/(em|i)>/gi, "[/i]");
|
||||
rep(/<(em|i)>/gi, "[i]");
|
||||
rep(/<\/u>/gi, "[/u]");
|
||||
rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi, "[u]$1[/u]");
|
||||
rep(/<u>/gi, "[u]");
|
||||
rep(/<blockquote[^>]*>/gi, "[quote]");
|
||||
rep(/<\/blockquote>/gi, "[/quote]");
|
||||
rep(/<br \/>/gi, "\n");
|
||||
rep(/<br\/>/gi, "\n");
|
||||
rep(/<br>/gi, "\n");
|
||||
rep(/<p>/gi, "");
|
||||
rep(/<\/p>/gi, "\n");
|
||||
rep(/ |\u00a0/gi, " ");
|
||||
rep(/"/gi, "\"");
|
||||
rep(/</gi, "<");
|
||||
rep(/>/gi, ">");
|
||||
rep(/&/gi, "&");
|
||||
|
||||
return s;
|
||||
},
|
||||
|
||||
// BBCode -> HTML from PunBB dialect
|
||||
_punbb_bbcode2html: function(s) {
|
||||
s = tinymce.trim(s);
|
||||
|
||||
function rep(re, str) {
|
||||
s = s.replace(re, str);
|
||||
}
|
||||
|
||||
// example: [b] to <strong>
|
||||
rep(/\n/gi, "<br />");
|
||||
rep(/\[b\]/gi, "<strong>");
|
||||
rep(/\[\/b\]/gi, "</strong>");
|
||||
rep(/\[i\]/gi, "<em>");
|
||||
rep(/\[\/i\]/gi, "</em>");
|
||||
rep(/\[u\]/gi, "<u>");
|
||||
rep(/\[\/u\]/gi, "</u>");
|
||||
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi, "<a href=\"$1\">$2</a>");
|
||||
rep(/\[url\](.*?)\[\/url\]/gi, "<a href=\"$1\">$1</a>");
|
||||
rep(/\[img\](.*?)\[\/img\]/gi, "<img src=\"$1\" />");
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi, "<font color=\"$1\">$2</font>");
|
||||
rep(/\[code\](.*?)\[\/code\]/gi, "<span class=\"codeStyle\">$1</span> ");
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi, "<span class=\"quoteStyle\">$1</span> ");
|
||||
|
||||
return s;
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
|
||||
})();
|
||||
}());
|
||||
})();
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
!function(){tinymce.create("tinymce.plugins.BBCodePlugin",{init:function(a){var b=this,c=a.getParam("bbcode_dialect","punbb").toLowerCase();a.on("beforeSetContent",function(a){a.content=b["_"+c+"_bbcode2html"](a.content)}),a.on("postProcess",function(a){a.set&&(a.content=b["_"+c+"_bbcode2html"](a.content)),a.get&&(a.content=b["_"+c+"_html2bbcode"](a.content))})},getInfo:function(){return{longname:"BBCode Plugin",author:"Moxiecode Systems AB",authorurl:"http://www.tinymce.com",infourl:"http://www.tinymce.com/wiki.php/Plugin:bbcode"}},_punbb_html2bbcode:function(a){function b(b,c){a=a.replace(b,c)}return a=tinymce.trim(a),b(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"),b(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),b(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),b(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),b(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),b(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]"),b(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"),b(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"),b(/<font>(.*?)<\/font>/gi,"$1"),b(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"),b(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"),b(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"),b(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),b(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),b(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),b(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),b(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),b(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"),b(/<\/(strong|b)>/gi,"[/b]"),b(/<(strong|b)>/gi,"[b]"),b(/<\/(em|i)>/gi,"[/i]"),b(/<(em|i)>/gi,"[i]"),b(/<\/u>/gi,"[/u]"),b(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]"),b(/<u>/gi,"[u]"),b(/<blockquote[^>]*>/gi,"[quote]"),b(/<\/blockquote>/gi,"[/quote]"),b(/<br \/>/gi,"\n"),b(/<br\/>/gi,"\n"),b(/<br>/gi,"\n"),b(/<p>/gi,""),b(/<\/p>/gi,"\n"),b(/ |\u00a0/gi," "),b(/"/gi,'"'),b(/</gi,"<"),b(/>/gi,">"),b(/&/gi,"&"),a},_punbb_bbcode2html:function(a){function b(b,c){a=a.replace(b,c)}return a=tinymce.trim(a),b(/\n/gi,"<br />"),b(/\[b\]/gi,"<strong>"),b(/\[\/b\]/gi,"</strong>"),b(/\[i\]/gi,"<em>"),b(/\[\/i\]/gi,"</em>"),b(/\[u\]/gi,"<u>"),b(/\[\/u\]/gi,"</u>"),b(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'),b(/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'),b(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'),b(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'),b(/\[code\](.*?)\[\/code\]/gi,'<span class="codeStyle">$1</span> '),b(/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quoteStyle">$1</span> '),a}}),tinymce.PluginManager.add("bbcode",tinymce.plugins.BBCodePlugin)}();
|
||||
!function(){"use strict";var o=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.util.Tools"),e=function(e){e=t.trim(e);var o=function(o,t){e=e.replace(o,t)};return o(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"),o(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),o(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),o(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),o(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),o(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]"),o(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"),o(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"),o(/<font>(.*?)<\/font>/gi,"$1"),o(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"),o(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"),o(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"),o(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),o(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),o(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),o(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),o(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),o(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"),o(/<\/(strong|b)>/gi,"[/b]"),o(/<(strong|b)>/gi,"[b]"),o(/<\/(em|i)>/gi,"[/i]"),o(/<(em|i)>/gi,"[i]"),o(/<\/u>/gi,"[/u]"),o(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]"),o(/<u>/gi,"[u]"),o(/<blockquote[^>]*>/gi,"[quote]"),o(/<\/blockquote>/gi,"[/quote]"),o(/<br \/>/gi,"\n"),o(/<br\/>/gi,"\n"),o(/<br>/gi,"\n"),o(/<p>/gi,""),o(/<\/p>/gi,"\n"),o(/ |\u00a0/gi," "),o(/"/gi,'"'),o(/</gi,"<"),o(/>/gi,">"),o(/&/gi,"&"),e},i=function(e){e=t.trim(e);var o=function(o,t){e=e.replace(o,t)};return o(/\n/gi,"<br />"),o(/\[b\]/gi,"<strong>"),o(/\[\/b\]/gi,"</strong>"),o(/\[i\]/gi,"<em>"),o(/\[\/i\]/gi,"</em>"),o(/\[u\]/gi,"<u>"),o(/\[\/u\]/gi,"</u>"),o(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'),o(/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'),o(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'),o(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'),o(/\[code\](.*?)\[\/code\]/gi,'<span class="codeStyle">$1</span> '),o(/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quoteStyle">$1</span> '),e};o.add("bbcode",function(){return{init:function(o){o.on("beforeSetContent",function(o){o.content=i(o.content)}),o.on("postProcess",function(o){o.set&&(o.content=i(o.content)),o.get&&(o.content=e(o.content))})}}})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "charmap" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/charmap')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/charmap'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "code" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/code')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/code'
|
||||
require('./plugin.js');
|
||||
@@ -1,60 +1,94 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var code = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('code', function(editor) {
|
||||
function showDialog() {
|
||||
var win = editor.windowManager.open({
|
||||
title: "Source code",
|
||||
body: {
|
||||
type: 'textbox',
|
||||
name: 'code',
|
||||
multiline: true,
|
||||
minWidth: editor.getParam("code_dialog_width", 600),
|
||||
minHeight: editor.getParam("code_dialog_height", Math.min(tinymce.DOM.getViewPort().h - 200, 500)),
|
||||
spellcheck: false,
|
||||
style: 'direction: ltr; text-align: left'
|
||||
},
|
||||
onSubmit: function(e) {
|
||||
// We get a lovely "Wrong document" error in IE 11 if we
|
||||
// don't move the focus to the editor before creating an undo
|
||||
// transation since it tries to make a bookmark for the current selection
|
||||
editor.focus();
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
editor.undoManager.transact(function() {
|
||||
editor.setContent(e.data.code);
|
||||
});
|
||||
var getMinWidth = function (editor) {
|
||||
return editor.getParam('code_dialog_width', 600);
|
||||
};
|
||||
var getMinHeight = function (editor) {
|
||||
return editor.getParam('code_dialog_height', Math.min(global$1.DOM.getViewPort().h - 200, 500));
|
||||
};
|
||||
var $_7a5bps9ojh8lpugv = {
|
||||
getMinWidth: getMinWidth,
|
||||
getMinHeight: getMinHeight
|
||||
};
|
||||
|
||||
editor.selection.setCursorLocation();
|
||||
editor.nodeChanged();
|
||||
}
|
||||
});
|
||||
var setContent = function (editor, html) {
|
||||
editor.focus();
|
||||
editor.undoManager.transact(function () {
|
||||
editor.setContent(html);
|
||||
});
|
||||
editor.selection.setCursorLocation();
|
||||
editor.nodeChanged();
|
||||
};
|
||||
var getContent = function (editor) {
|
||||
return editor.getContent({ source_view: true });
|
||||
};
|
||||
var $_4f0hos9qjh8lpugw = {
|
||||
setContent: setContent,
|
||||
getContent: getContent
|
||||
};
|
||||
|
||||
// Gecko has a major performance issue with textarea
|
||||
// contents so we need to set it when all reflows are done
|
||||
win.find('#code').value(editor.getContent({source_view: true}));
|
||||
}
|
||||
var open = function (editor) {
|
||||
var minWidth = $_7a5bps9ojh8lpugv.getMinWidth(editor);
|
||||
var minHeight = $_7a5bps9ojh8lpugv.getMinHeight(editor);
|
||||
var win = editor.windowManager.open({
|
||||
title: 'Source code',
|
||||
body: {
|
||||
type: 'textbox',
|
||||
name: 'code',
|
||||
multiline: true,
|
||||
minWidth: minWidth,
|
||||
minHeight: minHeight,
|
||||
spellcheck: false,
|
||||
style: 'direction: ltr; text-align: left'
|
||||
},
|
||||
onSubmit: function (e) {
|
||||
$_4f0hos9qjh8lpugw.setContent(editor, e.data.code);
|
||||
}
|
||||
});
|
||||
win.find('#code').value($_4f0hos9qjh8lpugw.getContent(editor));
|
||||
};
|
||||
var $_8t2ji69njh8lpugu = { open: open };
|
||||
|
||||
editor.addCommand("mceCodeEditor", showDialog);
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceCodeEditor', function () {
|
||||
$_8t2ji69njh8lpugu.open(editor);
|
||||
});
|
||||
};
|
||||
var $_1cb0ek9mjh8lpugt = { register: register };
|
||||
|
||||
editor.addButton('code', {
|
||||
icon: 'code',
|
||||
tooltip: 'Source code',
|
||||
onclick: showDialog
|
||||
});
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('code', {
|
||||
icon: 'code',
|
||||
tooltip: 'Source code',
|
||||
onclick: function () {
|
||||
$_8t2ji69njh8lpugu.open(editor);
|
||||
}
|
||||
});
|
||||
editor.addMenuItem('code', {
|
||||
icon: 'code',
|
||||
text: 'Source code',
|
||||
onclick: function () {
|
||||
$_8t2ji69njh8lpugu.open(editor);
|
||||
}
|
||||
});
|
||||
};
|
||||
var $_aziuou9rjh8lpugx = { register: register$1 };
|
||||
|
||||
editor.addMenuItem('code', {
|
||||
icon: 'code',
|
||||
text: 'Source code',
|
||||
context: 'tools',
|
||||
onclick: showDialog
|
||||
});
|
||||
});
|
||||
global.add('code', function (editor) {
|
||||
$_1cb0ek9mjh8lpugt.register(editor);
|
||||
$_aziuou9rjh8lpugx.register(editor);
|
||||
return {};
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("code",function(a){function b(){var b=a.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:a.getParam("code_dialog_width",600),minHeight:a.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(b){a.focus(),a.undoManager.transact(function(){a.setContent(b.data.code)}),a.selection.setCursorLocation(),a.nodeChanged()}});b.find("#code").value(a.getContent({source_view:!0}))}a.addCommand("mceCodeEditor",b),a.addButton("code",{icon:"code",tooltip:"Source code",onclick:b}),a.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:b})});
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),o=function(t){return t.getParam("code_dialog_width",600)},i=function(t){return t.getParam("code_dialog_height",Math.min(n.DOM.getViewPort().h-200,500))},c=function(t,n){t.focus(),t.undoManager.transact(function(){t.setContent(n)}),t.selection.setCursorLocation(),t.nodeChanged()},d=function(t){return t.getContent({source_view:!0})},e=function(n){var t=o(n),e=i(n);n.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:t,minHeight:e,spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(t){c(n,t.data.code)}}).find("#code").value(d(n))},u=function(t){t.addCommand("mceCodeEditor",function(){e(t)})},a=function(t){t.addButton("code",{icon:"code",tooltip:"Source code",onclick:function(){e(t)}}),t.addMenuItem("code",{icon:"code",text:"Source code",onclick:function(){e(t)}})};t.add("code",function(t){return u(t),a(t),{}})}();
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
tinymce.addI18n('en',{
|
||||
'HTML source code': 'HTML source code',
|
||||
'Start search': 'Start search',
|
||||
'Find next': 'Find next',
|
||||
'Find previous': 'Find previous',
|
||||
'Replace': 'Replace',
|
||||
'Replace all': 'Replace all'
|
||||
});
|
||||
@@ -0,0 +1,138 @@
|
||||
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript */
|
||||
/**
|
||||
* prism.js default theme for JavaScript, CSS and HTML
|
||||
* Based on dabblet (http://dabblet.com)
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: black;
|
||||
text-shadow: 0 1px white;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
||||
text-shadow: none;
|
||||
background: #b3d4fc;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
||||
text-shadow: none;
|
||||
background: #b3d4fc;
|
||||
}
|
||||
|
||||
@media print {
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
text-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #f5f2f0;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #905;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #690;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string {
|
||||
color: #a67f59;
|
||||
background: hsla(0, 0%, 100%, .5);
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: #07a;
|
||||
}
|
||||
|
||||
.token.function {
|
||||
color: #DD4A68;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important,
|
||||
.token.variable {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "codesample" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/codesample')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/codesample'
|
||||
require('./plugin.js');
|
||||
@@ -0,0 +1,967 @@
|
||||
(function () {
|
||||
var codesample = (function () {
|
||||
'use strict';
|
||||
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
var getContentCss = function (editor) {
|
||||
return editor.settings.codesample_content_css;
|
||||
};
|
||||
var getLanguages = function (editor) {
|
||||
return editor.settings.codesample_languages;
|
||||
};
|
||||
var getDialogMinWidth = function (editor) {
|
||||
return Math.min(global$1.DOM.getViewPort().w, editor.getParam('codesample_dialog_width', 800));
|
||||
};
|
||||
var getDialogMinHeight = function (editor) {
|
||||
return Math.min(global$1.DOM.getViewPort().w, editor.getParam('codesample_dialog_height', 650));
|
||||
};
|
||||
var $_3ew0z79xjh8lpuhi = {
|
||||
getContentCss: getContentCss,
|
||||
getLanguages: getLanguages,
|
||||
getDialogMinWidth: getDialogMinWidth,
|
||||
getDialogMinHeight: getDialogMinHeight
|
||||
};
|
||||
|
||||
var window = {};
|
||||
var global$2 = window;
|
||||
var _self = typeof window !== 'undefined' ? window : typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : {};
|
||||
var Prism = function () {
|
||||
var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
|
||||
var _ = _self.Prism = {
|
||||
util: {
|
||||
encode: function (tokens) {
|
||||
if (tokens instanceof Token) {
|
||||
return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
|
||||
} else if (_.util.type(tokens) === 'Array') {
|
||||
return tokens.map(_.util.encode);
|
||||
} else {
|
||||
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
||||
}
|
||||
},
|
||||
type: function (o) {
|
||||
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
|
||||
},
|
||||
clone: function (o) {
|
||||
var type = _.util.type(o);
|
||||
switch (type) {
|
||||
case 'Object':
|
||||
var clone = {};
|
||||
for (var key in o) {
|
||||
if (o.hasOwnProperty(key)) {
|
||||
clone[key] = _.util.clone(o[key]);
|
||||
}
|
||||
}
|
||||
return clone;
|
||||
case 'Array':
|
||||
return o.map && o.map(function (v) {
|
||||
return _.util.clone(v);
|
||||
});
|
||||
}
|
||||
return o;
|
||||
}
|
||||
},
|
||||
languages: {
|
||||
extend: function (id, redef) {
|
||||
var lang = _.util.clone(_.languages[id]);
|
||||
for (var key in redef) {
|
||||
lang[key] = redef[key];
|
||||
}
|
||||
return lang;
|
||||
},
|
||||
insertBefore: function (inside, before, insert, root) {
|
||||
root = root || _.languages;
|
||||
var grammar = root[inside];
|
||||
if (arguments.length === 2) {
|
||||
insert = arguments[1];
|
||||
for (var newToken in insert) {
|
||||
if (insert.hasOwnProperty(newToken)) {
|
||||
grammar[newToken] = insert[newToken];
|
||||
}
|
||||
}
|
||||
return grammar;
|
||||
}
|
||||
var ret = {};
|
||||
for (var token in grammar) {
|
||||
if (grammar.hasOwnProperty(token)) {
|
||||
if (token === before) {
|
||||
for (var newToken in insert) {
|
||||
if (insert.hasOwnProperty(newToken)) {
|
||||
ret[newToken] = insert[newToken];
|
||||
}
|
||||
}
|
||||
}
|
||||
ret[token] = grammar[token];
|
||||
}
|
||||
}
|
||||
_.languages.DFS(_.languages, function (key, value) {
|
||||
if (value === root[inside] && key !== inside) {
|
||||
this[key] = ret;
|
||||
}
|
||||
});
|
||||
return root[inside] = ret;
|
||||
},
|
||||
DFS: function (o, callback, type) {
|
||||
for (var i in o) {
|
||||
if (o.hasOwnProperty(i)) {
|
||||
callback.call(o, i, o[i], type || i);
|
||||
if (_.util.type(o[i]) === 'Object') {
|
||||
_.languages.DFS(o[i], callback);
|
||||
} else if (_.util.type(o[i]) === 'Array') {
|
||||
_.languages.DFS(o[i], callback, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {},
|
||||
highlightAll: function (async, callback) {
|
||||
var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
|
||||
for (var i = 0, element = void 0; element = elements[i++];) {
|
||||
_.highlightElement(element, async === true, callback);
|
||||
}
|
||||
},
|
||||
highlightElement: function (element, async, callback) {
|
||||
var language, grammar, parent = element;
|
||||
while (parent && !lang.test(parent.className)) {
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
if (parent) {
|
||||
language = (parent.className.match(lang) || [
|
||||
,
|
||||
''
|
||||
])[1];
|
||||
grammar = _.languages[language];
|
||||
}
|
||||
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
||||
parent = element.parentNode;
|
||||
if (/pre/i.test(parent.nodeName)) {
|
||||
parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
||||
}
|
||||
var code = element.textContent;
|
||||
var env = {
|
||||
element: element,
|
||||
language: language,
|
||||
grammar: grammar,
|
||||
code: code
|
||||
};
|
||||
if (!code || !grammar) {
|
||||
_.hooks.run('complete', env);
|
||||
return;
|
||||
}
|
||||
_.hooks.run('before-highlight', env);
|
||||
if (async && _self.Worker) {
|
||||
var worker = new Worker(_.filename);
|
||||
worker.onmessage = function (evt) {
|
||||
env.highlightedCode = evt.data;
|
||||
_.hooks.run('before-insert', env);
|
||||
env.element.innerHTML = env.highlightedCode;
|
||||
if (callback) {
|
||||
callback.call(env.element);
|
||||
}
|
||||
_.hooks.run('after-highlight', env);
|
||||
_.hooks.run('complete', env);
|
||||
};
|
||||
worker.postMessage(JSON.stringify({
|
||||
language: env.language,
|
||||
code: env.code,
|
||||
immediateClose: true
|
||||
}));
|
||||
} else {
|
||||
env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
|
||||
_.hooks.run('before-insert', env);
|
||||
env.element.innerHTML = env.highlightedCode;
|
||||
if (callback) {
|
||||
callback.call(element);
|
||||
}
|
||||
_.hooks.run('after-highlight', env);
|
||||
_.hooks.run('complete', env);
|
||||
}
|
||||
},
|
||||
highlight: function (text, grammar, language) {
|
||||
var tokens = _.tokenize(text, grammar);
|
||||
return Token.stringify(_.util.encode(tokens), language);
|
||||
},
|
||||
tokenize: function (text, grammar, language) {
|
||||
var Token = _.Token;
|
||||
var strarr = [text];
|
||||
var rest = grammar.rest;
|
||||
if (rest) {
|
||||
for (var token in rest) {
|
||||
grammar[token] = rest[token];
|
||||
}
|
||||
delete grammar.rest;
|
||||
}
|
||||
tokenloop:
|
||||
for (var token in grammar) {
|
||||
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
||||
continue;
|
||||
}
|
||||
var patterns = grammar[token];
|
||||
patterns = _.util.type(patterns) === 'Array' ? patterns : [patterns];
|
||||
for (var j = 0; j < patterns.length; ++j) {
|
||||
var pattern = patterns[j];
|
||||
var inside = pattern.inside;
|
||||
var lookbehind = !!pattern.lookbehind;
|
||||
var lookbehindLength = 0;
|
||||
var alias = pattern.alias;
|
||||
pattern = pattern.pattern || pattern;
|
||||
for (var i = 0; i < strarr.length; i++) {
|
||||
var str = strarr[i];
|
||||
if (strarr.length > text.length) {
|
||||
break tokenloop;
|
||||
}
|
||||
if (str instanceof Token) {
|
||||
continue;
|
||||
}
|
||||
pattern.lastIndex = 0;
|
||||
var match = pattern.exec(str);
|
||||
if (match) {
|
||||
if (lookbehind) {
|
||||
lookbehindLength = match[1].length;
|
||||
}
|
||||
var from = match.index - 1 + lookbehindLength;
|
||||
match = match[0].slice(lookbehindLength);
|
||||
var len = match.length, to = from + len, before = str.slice(0, from + 1), after = str.slice(to + 1);
|
||||
var args = [
|
||||
i,
|
||||
1
|
||||
];
|
||||
if (before) {
|
||||
args.push(before);
|
||||
}
|
||||
var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias);
|
||||
args.push(wrapped);
|
||||
if (after) {
|
||||
args.push(after);
|
||||
}
|
||||
Array.prototype.splice.apply(strarr, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return strarr;
|
||||
},
|
||||
hooks: {
|
||||
all: {},
|
||||
add: function (name, callback) {
|
||||
var hooks = _.hooks.all;
|
||||
hooks[name] = hooks[name] || [];
|
||||
hooks[name].push(callback);
|
||||
},
|
||||
run: function (name, env) {
|
||||
var callbacks = _.hooks.all[name];
|
||||
if (!callbacks || !callbacks.length) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0, callback = void 0; callback = callbacks[i++];) {
|
||||
callback(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var Token = _.Token = function (type, content, alias) {
|
||||
this.type = type;
|
||||
this.content = content;
|
||||
this.alias = alias;
|
||||
};
|
||||
Token.stringify = function (o, language, parent) {
|
||||
if (typeof o === 'string') {
|
||||
return o;
|
||||
}
|
||||
if (_.util.type(o) === 'Array') {
|
||||
return o.map(function (element) {
|
||||
return Token.stringify(element, language, o);
|
||||
}).join('');
|
||||
}
|
||||
var env = {
|
||||
type: o.type,
|
||||
content: Token.stringify(o.content, language, parent),
|
||||
tag: 'span',
|
||||
classes: [
|
||||
'token',
|
||||
o.type
|
||||
],
|
||||
attributes: {},
|
||||
language: language,
|
||||
parent: parent
|
||||
};
|
||||
if (env.type === 'comment') {
|
||||
env.attributes.spellcheck = 'true';
|
||||
}
|
||||
if (o.alias) {
|
||||
var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
|
||||
Array.prototype.push.apply(env.classes, aliases);
|
||||
}
|
||||
_.hooks.run('wrap', env);
|
||||
var attributes = '';
|
||||
for (var name_1 in env.attributes) {
|
||||
attributes += (attributes ? ' ' : '') + name_1 + '="' + (env.attributes[name_1] || '') + '"';
|
||||
}
|
||||
return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
|
||||
};
|
||||
if (!_self.document) {
|
||||
if (!_self.addEventListener) {
|
||||
return _self.Prism;
|
||||
}
|
||||
_self.addEventListener('message', function (evt) {
|
||||
var message = JSON.parse(evt.data), lang = message.language, code = message.code, immediateClose = message.immediateClose;
|
||||
_self.postMessage(_.highlight(code, _.languages[lang], lang));
|
||||
if (immediateClose) {
|
||||
_self.close();
|
||||
}
|
||||
}, false);
|
||||
return _self.Prism;
|
||||
}
|
||||
}();
|
||||
if (typeof global$2 !== 'undefined') {
|
||||
global$2.Prism = Prism;
|
||||
}
|
||||
Prism.languages.markup = {
|
||||
comment: /<!--[\w\W]*?-->/,
|
||||
prolog: /<\?[\w\W]+?\?>/,
|
||||
doctype: /<!DOCTYPE[\w\W]+?>/,
|
||||
cdata: /<!\[CDATA\[[\w\W]*?]]>/i,
|
||||
tag: {
|
||||
pattern: /<\/?[^\s>\/=.]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
|
||||
inside: {
|
||||
'tag': {
|
||||
pattern: /^<\/?[^\s>\/]+/i,
|
||||
inside: {
|
||||
punctuation: /^<\/?/,
|
||||
namespace: /^[^\s>\/:]+:/
|
||||
}
|
||||
},
|
||||
'attr-value': {
|
||||
pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
|
||||
inside: { punctuation: /[=>"']/ }
|
||||
},
|
||||
'punctuation': /\/?>/,
|
||||
'attr-name': {
|
||||
pattern: /[^\s>\/]+/,
|
||||
inside: { namespace: /^[^\s>\/:]+:/ }
|
||||
}
|
||||
}
|
||||
},
|
||||
entity: /&#?[\da-z]{1,8};/i
|
||||
};
|
||||
Prism.hooks.add('wrap', function (env) {
|
||||
if (env.type === 'entity') {
|
||||
env.attributes.title = env.content.replace(/&/, '&');
|
||||
}
|
||||
});
|
||||
Prism.languages.xml = Prism.languages.markup;
|
||||
Prism.languages.html = Prism.languages.markup;
|
||||
Prism.languages.mathml = Prism.languages.markup;
|
||||
Prism.languages.svg = Prism.languages.markup;
|
||||
Prism.languages.css = {
|
||||
comment: /\/\*[\w\W]*?\*\//,
|
||||
atrule: {
|
||||
pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
|
||||
inside: { rule: /@[\w-]+/ }
|
||||
},
|
||||
url: /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
|
||||
selector: /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
|
||||
string: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
|
||||
property: /(\b|\B)[\w-]+(?=\s*:)/i,
|
||||
important: /\B!important\b/i,
|
||||
function: /[-a-z0-9]+(?=\()/i,
|
||||
punctuation: /[(){};:]/
|
||||
};
|
||||
Prism.languages.css.atrule.inside.rest = Prism.util.clone(Prism.languages.css);
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
style: {
|
||||
pattern: /<style[\w\W]*?>[\w\W]*?<\/style>/i,
|
||||
inside: {
|
||||
tag: {
|
||||
pattern: /<style[\w\W]*?>|<\/style>/i,
|
||||
inside: Prism.languages.markup.tag.inside
|
||||
},
|
||||
rest: Prism.languages.css
|
||||
},
|
||||
alias: 'language-css'
|
||||
}
|
||||
});
|
||||
Prism.languages.insertBefore('inside', 'attr-value', {
|
||||
'style-attr': {
|
||||
pattern: /\s*style=("|').*?\1/i,
|
||||
inside: {
|
||||
'attr-name': {
|
||||
pattern: /^\s*style/i,
|
||||
inside: Prism.languages.markup.tag.inside
|
||||
},
|
||||
'punctuation': /^\s*=\s*['"]|['"]\s*$/,
|
||||
'attr-value': {
|
||||
pattern: /.+/i,
|
||||
inside: Prism.languages.css
|
||||
}
|
||||
},
|
||||
alias: 'language-css'
|
||||
}
|
||||
}, Prism.languages.markup.tag);
|
||||
}
|
||||
Prism.languages.clike = {
|
||||
'comment': [
|
||||
{
|
||||
pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
|
||||
lookbehind: true
|
||||
},
|
||||
{
|
||||
pattern: /(^|[^\\:])\/\/.*/,
|
||||
lookbehind: true
|
||||
}
|
||||
],
|
||||
'string': /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
||||
'class-name': {
|
||||
pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
|
||||
lookbehind: true,
|
||||
inside: { punctuation: /(\.|\\)/ }
|
||||
},
|
||||
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
|
||||
'boolean': /\b(true|false)\b/,
|
||||
'function': /[a-z0-9_]+(?=\()/i,
|
||||
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
|
||||
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
|
||||
'punctuation': /[{}[\];(),.:]/
|
||||
};
|
||||
Prism.languages.javascript = Prism.languages.extend('clike', {
|
||||
keyword: /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,
|
||||
number: /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
|
||||
function: /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i
|
||||
});
|
||||
Prism.languages.insertBefore('javascript', 'keyword', {
|
||||
regex: {
|
||||
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
|
||||
lookbehind: true
|
||||
}
|
||||
});
|
||||
Prism.languages.insertBefore('javascript', 'class-name', {
|
||||
'template-string': {
|
||||
pattern: /`(?:\\`|\\?[^`])*`/,
|
||||
inside: {
|
||||
interpolation: {
|
||||
pattern: /\$\{[^}]+\}/,
|
||||
inside: {
|
||||
'interpolation-punctuation': {
|
||||
pattern: /^\$\{|\}$/,
|
||||
alias: 'punctuation'
|
||||
},
|
||||
'rest': Prism.languages.javascript
|
||||
}
|
||||
},
|
||||
string: /[\s\S]+/
|
||||
}
|
||||
}
|
||||
});
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
script: {
|
||||
pattern: /<script[\w\W]*?>[\w\W]*?<\/script>/i,
|
||||
inside: {
|
||||
tag: {
|
||||
pattern: /<script[\w\W]*?>|<\/script>/i,
|
||||
inside: Prism.languages.markup.tag.inside
|
||||
},
|
||||
rest: Prism.languages.javascript
|
||||
},
|
||||
alias: 'language-javascript'
|
||||
}
|
||||
});
|
||||
}
|
||||
Prism.languages.js = Prism.languages.javascript;
|
||||
Prism.languages.c = Prism.languages.extend('clike', {
|
||||
keyword: /\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
|
||||
operator: /\-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*\/]/,
|
||||
number: /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
|
||||
});
|
||||
Prism.languages.insertBefore('c', 'string', {
|
||||
macro: {
|
||||
pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,
|
||||
lookbehind: true,
|
||||
alias: 'property',
|
||||
inside: {
|
||||
string: {
|
||||
pattern: /(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,
|
||||
lookbehind: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
delete Prism.languages.c['class-name'];
|
||||
delete Prism.languages.c.boolean;
|
||||
Prism.languages.csharp = Prism.languages.extend('clike', {
|
||||
keyword: /\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,
|
||||
string: [
|
||||
/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
|
||||
/("|')(\\?.)*?\1/
|
||||
],
|
||||
number: /\b-?(0x[\da-f]+|\d*\.?\d+)\b/i
|
||||
});
|
||||
Prism.languages.insertBefore('csharp', 'keyword', {
|
||||
preprocessor: {
|
||||
pattern: /(^\s*)#.*/m,
|
||||
lookbehind: true
|
||||
}
|
||||
});
|
||||
Prism.languages.cpp = Prism.languages.extend('c', {
|
||||
keyword: /\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
|
||||
boolean: /\b(true|false)\b/,
|
||||
operator: /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/
|
||||
});
|
||||
Prism.languages.insertBefore('cpp', 'keyword', {
|
||||
'class-name': {
|
||||
pattern: /(class\s+)[a-z0-9_]+/i,
|
||||
lookbehind: true
|
||||
}
|
||||
});
|
||||
Prism.languages.java = Prism.languages.extend('clike', {
|
||||
keyword: /\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,
|
||||
number: /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,
|
||||
operator: {
|
||||
pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
|
||||
lookbehind: true
|
||||
}
|
||||
});
|
||||
Prism.languages.php = Prism.languages.extend('clike', {
|
||||
keyword: /\b(and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
|
||||
constant: /\b[A-Z0-9_]{2,}\b/,
|
||||
comment: {
|
||||
pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
|
||||
lookbehind: true
|
||||
}
|
||||
});
|
||||
Prism.languages.insertBefore('php', 'class-name', {
|
||||
'shell-comment': {
|
||||
pattern: /(^|[^\\])#.*/,
|
||||
lookbehind: true,
|
||||
alias: 'comment'
|
||||
}
|
||||
});
|
||||
Prism.languages.insertBefore('php', 'keyword', {
|
||||
delimiter: /\?>|<\?(?:php)?/i,
|
||||
variable: /\$\w+\b/i,
|
||||
package: {
|
||||
pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
|
||||
lookbehind: true,
|
||||
inside: { punctuation: /\\/ }
|
||||
}
|
||||
});
|
||||
Prism.languages.insertBefore('php', 'operator', {
|
||||
property: {
|
||||
pattern: /(->)[\w]+/,
|
||||
lookbehind: true
|
||||
}
|
||||
});
|
||||
if (Prism.languages.markup) {
|
||||
Prism.hooks.add('before-highlight', function (env) {
|
||||
if (env.language !== 'php') {
|
||||
return;
|
||||
}
|
||||
env.tokenStack = [];
|
||||
env.backupCode = env.code;
|
||||
env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/ig, function (match) {
|
||||
env.tokenStack.push(match);
|
||||
return '{{{PHP' + env.tokenStack.length + '}}}';
|
||||
});
|
||||
});
|
||||
Prism.hooks.add('before-insert', function (env) {
|
||||
if (env.language === 'php') {
|
||||
env.code = env.backupCode;
|
||||
delete env.backupCode;
|
||||
}
|
||||
});
|
||||
Prism.hooks.add('after-highlight', function (env) {
|
||||
if (env.language !== 'php') {
|
||||
return;
|
||||
}
|
||||
for (var i = 0, t = void 0; t = env.tokenStack[i]; i++) {
|
||||
env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$'));
|
||||
}
|
||||
env.element.innerHTML = env.highlightedCode;
|
||||
});
|
||||
Prism.hooks.add('wrap', function (env) {
|
||||
if (env.language === 'php' && env.type === 'markup') {
|
||||
env.content = env.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g, '<span class="token php">$1</span>');
|
||||
}
|
||||
});
|
||||
Prism.languages.insertBefore('php', 'comment', {
|
||||
markup: {
|
||||
pattern: /<[^?]\/?(.*?)>/,
|
||||
inside: Prism.languages.markup
|
||||
},
|
||||
php: /\{\{\{PHP[0-9]+\}\}\}/
|
||||
});
|
||||
}
|
||||
Prism.languages.python = {
|
||||
'comment': {
|
||||
pattern: /(^|[^\\])#.*/,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': /"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(?:\\?.)*?\1/,
|
||||
'function': {
|
||||
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,
|
||||
lookbehind: true
|
||||
},
|
||||
'class-name': {
|
||||
pattern: /(\bclass\s+)[a-z0-9_]+/i,
|
||||
lookbehind: true
|
||||
},
|
||||
'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
|
||||
'boolean': /\b(?:True|False)\b/,
|
||||
'number': /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
|
||||
'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
|
||||
'punctuation': /[{}[\];(),.:]/
|
||||
};
|
||||
(function (Prism) {
|
||||
Prism.languages.ruby = Prism.languages.extend('clike', {
|
||||
comment: /#(?!\{[^\r\n]*?\}).*/,
|
||||
keyword: /\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
|
||||
});
|
||||
var interpolation = {
|
||||
pattern: /#\{[^}]+\}/,
|
||||
inside: {
|
||||
delimiter: {
|
||||
pattern: /^#\{|\}$/,
|
||||
alias: 'tag'
|
||||
},
|
||||
rest: Prism.util.clone(Prism.languages.ruby)
|
||||
}
|
||||
};
|
||||
Prism.languages.insertBefore('ruby', 'keyword', {
|
||||
regex: [
|
||||
{
|
||||
pattern: /%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
|
||||
lookbehind: true
|
||||
}
|
||||
],
|
||||
variable: /[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,
|
||||
symbol: /:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/
|
||||
});
|
||||
Prism.languages.insertBefore('ruby', 'number', {
|
||||
builtin: /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
|
||||
constant: /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/
|
||||
});
|
||||
Prism.languages.ruby.string = [
|
||||
{
|
||||
pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
|
||||
inside: { interpolation: interpolation }
|
||||
},
|
||||
{
|
||||
pattern: /("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,
|
||||
inside: { interpolation: interpolation }
|
||||
}
|
||||
];
|
||||
}(Prism));
|
||||
|
||||
function isCodeSample(elm) {
|
||||
return elm && elm.nodeName === 'PRE' && elm.className.indexOf('language-') !== -1;
|
||||
}
|
||||
function trimArg(predicateFn) {
|
||||
return function (arg1, arg2) {
|
||||
return predicateFn(arg2);
|
||||
};
|
||||
}
|
||||
var $_ed862ja1jh8lpuih = {
|
||||
isCodeSample: isCodeSample,
|
||||
trimArg: trimArg
|
||||
};
|
||||
|
||||
var getSelectedCodeSample = function (editor) {
|
||||
var node = editor.selection.getNode();
|
||||
if ($_ed862ja1jh8lpuih.isCodeSample(node)) {
|
||||
return node;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
var insertCodeSample = function (editor, language, code) {
|
||||
editor.undoManager.transact(function () {
|
||||
var node = getSelectedCodeSample(editor);
|
||||
code = global$1.DOM.encode(code);
|
||||
if (node) {
|
||||
editor.dom.setAttrib(node, 'class', 'language-' + language);
|
||||
node.innerHTML = code;
|
||||
Prism.highlightElement(node);
|
||||
editor.selection.select(node);
|
||||
} else {
|
||||
editor.insertContent('<pre id="__new" class="language-' + language + '">' + code + '</pre>');
|
||||
editor.selection.select(editor.$('#__new').removeAttr('id')[0]);
|
||||
}
|
||||
});
|
||||
};
|
||||
var getCurrentCode = function (editor) {
|
||||
var node = getSelectedCodeSample(editor);
|
||||
if (node) {
|
||||
return node.textContent;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
var $_2bh0wp9zjh8lpuhk = {
|
||||
getSelectedCodeSample: getSelectedCodeSample,
|
||||
insertCodeSample: insertCodeSample,
|
||||
getCurrentCode: getCurrentCode
|
||||
};
|
||||
|
||||
var getLanguages$1 = function (editor) {
|
||||
var defaultLanguages = [
|
||||
{
|
||||
text: 'HTML/XML',
|
||||
value: 'markup'
|
||||
},
|
||||
{
|
||||
text: 'JavaScript',
|
||||
value: 'javascript'
|
||||
},
|
||||
{
|
||||
text: 'CSS',
|
||||
value: 'css'
|
||||
},
|
||||
{
|
||||
text: 'PHP',
|
||||
value: 'php'
|
||||
},
|
||||
{
|
||||
text: 'Ruby',
|
||||
value: 'ruby'
|
||||
},
|
||||
{
|
||||
text: 'Python',
|
||||
value: 'python'
|
||||
},
|
||||
{
|
||||
text: 'Java',
|
||||
value: 'java'
|
||||
},
|
||||
{
|
||||
text: 'C',
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
text: 'C#',
|
||||
value: 'csharp'
|
||||
},
|
||||
{
|
||||
text: 'C++',
|
||||
value: 'cpp'
|
||||
}
|
||||
];
|
||||
var customLanguages = $_3ew0z79xjh8lpuhi.getLanguages(editor);
|
||||
return customLanguages ? customLanguages : defaultLanguages;
|
||||
};
|
||||
var getCurrentLanguage = function (editor) {
|
||||
var matches;
|
||||
var node = $_2bh0wp9zjh8lpuhk.getSelectedCodeSample(editor);
|
||||
if (node) {
|
||||
matches = node.className.match(/language-(\w+)/);
|
||||
return matches ? matches[1] : '';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
var $_dqyreda2jh8lpuii = {
|
||||
getLanguages: getLanguages$1,
|
||||
getCurrentLanguage: getCurrentLanguage
|
||||
};
|
||||
|
||||
var $_17ew2k9wjh8lpuhh = {
|
||||
open: function (editor) {
|
||||
var minWidth = $_3ew0z79xjh8lpuhi.getDialogMinWidth(editor);
|
||||
var minHeight = $_3ew0z79xjh8lpuhi.getDialogMinHeight(editor);
|
||||
var currentLanguage = $_dqyreda2jh8lpuii.getCurrentLanguage(editor);
|
||||
var currentLanguages = $_dqyreda2jh8lpuii.getLanguages(editor);
|
||||
var currentCode = $_2bh0wp9zjh8lpuhk.getCurrentCode(editor);
|
||||
editor.windowManager.open({
|
||||
title: 'Insert/Edit code sample',
|
||||
minWidth: minWidth,
|
||||
minHeight: minHeight,
|
||||
layout: 'flex',
|
||||
direction: 'column',
|
||||
align: 'stretch',
|
||||
body: [
|
||||
{
|
||||
type: 'listbox',
|
||||
name: 'language',
|
||||
label: 'Language',
|
||||
maxWidth: 200,
|
||||
value: currentLanguage,
|
||||
values: currentLanguages
|
||||
},
|
||||
{
|
||||
type: 'textbox',
|
||||
name: 'code',
|
||||
multiline: true,
|
||||
spellcheck: false,
|
||||
ariaLabel: 'Code view',
|
||||
flex: 1,
|
||||
style: 'direction: ltr; text-align: left',
|
||||
classes: 'monospace',
|
||||
value: currentCode,
|
||||
autofocus: true
|
||||
}
|
||||
],
|
||||
onSubmit: function (e) {
|
||||
$_2bh0wp9zjh8lpuhk.insertCodeSample(editor, e.data.language, e.data.code);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var register = function (editor) {
|
||||
editor.addCommand('codesample', function () {
|
||||
var node = editor.selection.getNode();
|
||||
if (editor.selection.isCollapsed() || $_ed862ja1jh8lpuih.isCodeSample(node)) {
|
||||
$_17ew2k9wjh8lpuhh.open(editor);
|
||||
} else {
|
||||
editor.formatter.toggle('code');
|
||||
}
|
||||
});
|
||||
};
|
||||
var $_g7hv619vjh8lpuhg = { register: register };
|
||||
|
||||
var setup = function (editor) {
|
||||
var $ = editor.$;
|
||||
editor.on('PreProcess', function (e) {
|
||||
$('pre[contenteditable=false]', e.node).filter($_ed862ja1jh8lpuih.trimArg($_ed862ja1jh8lpuih.isCodeSample)).each(function (idx, elm) {
|
||||
var $elm = $(elm), code = elm.textContent;
|
||||
$elm.attr('class', $.trim($elm.attr('class')));
|
||||
$elm.removeAttr('contentEditable');
|
||||
$elm.empty().append($('<code></code>').each(function () {
|
||||
this.textContent = code;
|
||||
}));
|
||||
});
|
||||
});
|
||||
editor.on('SetContent', function () {
|
||||
var unprocessedCodeSamples = $('pre').filter($_ed862ja1jh8lpuih.trimArg($_ed862ja1jh8lpuih.isCodeSample)).filter(function (idx, elm) {
|
||||
return elm.contentEditable !== 'false';
|
||||
});
|
||||
if (unprocessedCodeSamples.length) {
|
||||
editor.undoManager.transact(function () {
|
||||
unprocessedCodeSamples.each(function (idx, elm) {
|
||||
$(elm).find('br').each(function (idx, elm) {
|
||||
elm.parentNode.replaceChild(editor.getDoc().createTextNode('\n'), elm);
|
||||
});
|
||||
elm.contentEditable = false;
|
||||
elm.innerHTML = editor.dom.encode(elm.textContent);
|
||||
Prism.highlightElement(elm);
|
||||
elm.className = $.trim(elm.className);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
var $_bhr6mpa3jh8lpuik = { setup: setup };
|
||||
|
||||
var loadCss = function (editor, pluginUrl, addedInlineCss, addedCss) {
|
||||
var linkElm;
|
||||
var contentCss = $_3ew0z79xjh8lpuhi.getContentCss(editor);
|
||||
if (editor.inline && addedInlineCss.get()) {
|
||||
return;
|
||||
}
|
||||
if (!editor.inline && addedCss.get()) {
|
||||
return;
|
||||
}
|
||||
if (editor.inline) {
|
||||
addedInlineCss.set(true);
|
||||
} else {
|
||||
addedCss.set(true);
|
||||
}
|
||||
if (contentCss !== false) {
|
||||
linkElm = editor.dom.create('link', {
|
||||
rel: 'stylesheet',
|
||||
href: contentCss ? contentCss : pluginUrl + '/css/prism.css'
|
||||
});
|
||||
editor.getDoc().getElementsByTagName('head')[0].appendChild(linkElm);
|
||||
}
|
||||
};
|
||||
var $_9m8czaa4jh8lpuim = { loadCss: loadCss };
|
||||
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('codesample', {
|
||||
cmd: 'codesample',
|
||||
title: 'Insert/Edit code sample'
|
||||
});
|
||||
editor.addMenuItem('codesample', {
|
||||
cmd: 'codesample',
|
||||
text: 'Code sample',
|
||||
icon: 'codesample'
|
||||
});
|
||||
};
|
||||
var $_7n1bf0a5jh8lpuin = { register: register$1 };
|
||||
|
||||
var addedInlineCss = Cell(false);
|
||||
global.add('codesample', function (editor, pluginUrl) {
|
||||
var addedCss = Cell(false);
|
||||
$_bhr6mpa3jh8lpuik.setup(editor);
|
||||
$_7n1bf0a5jh8lpuin.register(editor);
|
||||
$_g7hv619vjh8lpuhg.register(editor);
|
||||
editor.on('init', function () {
|
||||
$_9m8czaa4jh8lpuim.loadCss(editor, pluginUrl, addedInlineCss, addedCss);
|
||||
});
|
||||
editor.on('dblclick', function (ev) {
|
||||
if ($_ed862ja1jh8lpuih.isCodeSample(ev.target)) {
|
||||
$_17ew2k9wjh8lpuhh.open(editor);
|
||||
}
|
||||
});
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "colorpicker" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/colorpicker')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/colorpicker'
|
||||
require('./plugin.js');
|
||||
@@ -1,112 +1,126 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var colorpicker = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('colorpicker', function(editor) {
|
||||
function colorPickerCallback(callback, value) {
|
||||
function setColor(value) {
|
||||
var color = new tinymce.util.Color(value), rgb = color.toRgb();
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Color');
|
||||
|
||||
win.fromJSON({
|
||||
r: rgb.r,
|
||||
g: rgb.g,
|
||||
b: rgb.b,
|
||||
hex: color.toHex().substr(1)
|
||||
});
|
||||
var showPreview = function (win, hexColor) {
|
||||
win.find('#preview')[0].getEl().style.background = hexColor;
|
||||
};
|
||||
var setColor = function (win, value) {
|
||||
var color = global$1(value), rgb = color.toRgb();
|
||||
win.fromJSON({
|
||||
r: rgb.r,
|
||||
g: rgb.g,
|
||||
b: rgb.b,
|
||||
hex: color.toHex().substr(1)
|
||||
});
|
||||
showPreview(win, color.toHex());
|
||||
};
|
||||
var open = function (editor, callback, value) {
|
||||
var win = editor.windowManager.open({
|
||||
title: 'Color',
|
||||
items: {
|
||||
type: 'container',
|
||||
layout: 'flex',
|
||||
direction: 'row',
|
||||
align: 'stretch',
|
||||
padding: 5,
|
||||
spacing: 10,
|
||||
items: [
|
||||
{
|
||||
type: 'colorpicker',
|
||||
value: value,
|
||||
onchange: function () {
|
||||
var rgb = this.rgb();
|
||||
if (win) {
|
||||
win.find('#r').value(rgb.r);
|
||||
win.find('#g').value(rgb.g);
|
||||
win.find('#b').value(rgb.b);
|
||||
win.find('#hex').value(this.value().substr(1));
|
||||
showPreview(win, this.value());
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
padding: 0,
|
||||
labelGap: 5,
|
||||
defaults: {
|
||||
type: 'textbox',
|
||||
size: 7,
|
||||
value: '0',
|
||||
flex: 1,
|
||||
spellcheck: false,
|
||||
onchange: function () {
|
||||
var colorPickerCtrl = win.find('colorpicker')[0];
|
||||
var name, value;
|
||||
name = this.name();
|
||||
value = this.value();
|
||||
if (name === 'hex') {
|
||||
value = '#' + value;
|
||||
setColor(win, value);
|
||||
colorPickerCtrl.value(value);
|
||||
return;
|
||||
}
|
||||
value = {
|
||||
r: win.find('#r').value(),
|
||||
g: win.find('#g').value(),
|
||||
b: win.find('#b').value()
|
||||
};
|
||||
colorPickerCtrl.value(value);
|
||||
setColor(win, value);
|
||||
}
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'r',
|
||||
label: 'R',
|
||||
autofocus: 1
|
||||
},
|
||||
{
|
||||
name: 'g',
|
||||
label: 'G'
|
||||
},
|
||||
{
|
||||
name: 'b',
|
||||
label: 'B'
|
||||
},
|
||||
{
|
||||
name: 'hex',
|
||||
label: '#',
|
||||
value: '000000'
|
||||
},
|
||||
{
|
||||
name: 'preview',
|
||||
type: 'container',
|
||||
border: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
onSubmit: function () {
|
||||
callback('#' + win.toJSON().hex);
|
||||
}
|
||||
});
|
||||
setColor(win, value);
|
||||
};
|
||||
var $_5qw23qa8jh8lpujn = { open: open };
|
||||
|
||||
showPreview(color.toHex());
|
||||
}
|
||||
global.add('colorpicker', function (editor) {
|
||||
if (!editor.settings.color_picker_callback) {
|
||||
editor.settings.color_picker_callback = function (callback, value) {
|
||||
$_5qw23qa8jh8lpujn.open(editor, callback, value);
|
||||
};
|
||||
}
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
function showPreview(hexColor) {
|
||||
win.find('#preview')[0].getEl().style.background = hexColor;
|
||||
}
|
||||
return Plugin;
|
||||
|
||||
var win = editor.windowManager.open({
|
||||
title: 'Color',
|
||||
items: {
|
||||
type: 'container',
|
||||
layout: 'flex',
|
||||
direction: 'row',
|
||||
align: 'stretch',
|
||||
padding: 5,
|
||||
spacing: 10,
|
||||
items: [
|
||||
{
|
||||
type: 'colorpicker',
|
||||
value: value,
|
||||
onchange: function() {
|
||||
var rgb = this.rgb();
|
||||
|
||||
if (win) {
|
||||
win.find('#r').value(rgb.r);
|
||||
win.find('#g').value(rgb.g);
|
||||
win.find('#b').value(rgb.b);
|
||||
win.find('#hex').value(this.value().substr(1));
|
||||
showPreview(this.value());
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
padding: 0,
|
||||
labelGap: 5,
|
||||
defaults: {
|
||||
type: 'textbox',
|
||||
size: 7,
|
||||
value: '0',
|
||||
flex: 1,
|
||||
spellcheck: false,
|
||||
onchange: function() {
|
||||
var colorPickerCtrl = win.find('colorpicker')[0];
|
||||
var name, value;
|
||||
|
||||
name = this.name();
|
||||
value = this.value();
|
||||
|
||||
if (name == "hex") {
|
||||
value = '#' + value;
|
||||
setColor(value);
|
||||
colorPickerCtrl.value(value);
|
||||
return;
|
||||
}
|
||||
|
||||
value = {
|
||||
r: win.find('#r').value(),
|
||||
g: win.find('#g').value(),
|
||||
b: win.find('#b').value()
|
||||
};
|
||||
|
||||
colorPickerCtrl.value(value);
|
||||
setColor(value);
|
||||
}
|
||||
},
|
||||
items: [
|
||||
{name: 'r', label: 'R', autofocus: 1},
|
||||
{name: 'g', label: 'G'},
|
||||
{name: 'b', label: 'B'},
|
||||
{name: 'hex', label: '#', value: '000000'},
|
||||
{name: 'preview', type: 'container', border: 1}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
onSubmit: function() {
|
||||
callback('#' + this.toJSON().hex);
|
||||
}
|
||||
});
|
||||
|
||||
setColor(value);
|
||||
}
|
||||
|
||||
if (!editor.settings.color_picker_callback) {
|
||||
editor.settings.color_picker_callback = colorPickerCallback;
|
||||
}
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("colorpicker",function(a){function b(b,c){function d(a){var b=new tinymce.util.Color(a),c=b.toRgb();f.fromJSON({r:c.r,g:c.g,b:c.b,hex:b.toHex().substr(1)}),e(b.toHex())}function e(a){f.find("#preview")[0].getEl().style.background=a}var f=a.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:c,onchange:function(){var a=this.rgb();f&&(f.find("#r").value(a.r),f.find("#g").value(a.g),f.find("#b").value(a.b),f.find("#hex").value(this.value().substr(1)),e(this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var a,b,c=f.find("colorpicker")[0];return a=this.name(),b=this.value(),"hex"==a?(b="#"+b,d(b),void c.value(b)):(b={r:f.find("#r").value(),g:f.find("#g").value(),b:f.find("#b").value()},c.value(b),void d(b))}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){b("#"+this.toJSON().hex)}});d(c)}a.settings.color_picker_callback||(a.settings.color_picker_callback=b)});
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),l=tinymce.util.Tools.resolve("tinymce.util.Color"),a=function(e,n){e.find("#preview")[0].getEl().style.background=n},o=function(e,n){var i=l(n),t=i.toRgb();e.fromJSON({r:t.r,g:t.g,b:t.b,hex:i.toHex().substr(1)}),a(e,i.toHex())},t=function(e,n,i){var t=e.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:i,onchange:function(){var e=this.rgb();t&&(t.find("#r").value(e.r),t.find("#g").value(e.g),t.find("#b").value(e.b),t.find("#hex").value(this.value().substr(1)),a(t,this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var e,n,i=t.find("colorpicker")[0];if(e=this.name(),n=this.value(),"hex"===e)return o(t,n="#"+n),void i.value(n);n={r:t.find("#r").value(),g:t.find("#g").value(),b:t.find("#b").value()},i.value(n),o(t,n)}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){n("#"+t.toJSON().hex)}});o(t,i)};e.add("colorpicker",function(i){i.settings.color_picker_callback||(i.settings.color_picker_callback=function(e,n){t(i,e,n)})})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "contextmenu" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/contextmenu')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/contextmenu'
|
||||
require('./plugin.js');
|
||||
@@ -1,87 +1,168 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var contextmenu = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
tinymce.PluginManager.add('contextmenu', function(editor) {
|
||||
var menu, contextmenuNeverUseNative = editor.settings.contextmenu_never_use_native;
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
editor.on('contextmenu', function(e) {
|
||||
var contextmenu, doc = editor.getDoc();
|
||||
var get = function (visibleState) {
|
||||
var isContextMenuVisible = function () {
|
||||
return visibleState.get();
|
||||
};
|
||||
return { isContextMenuVisible: isContextMenuVisible };
|
||||
};
|
||||
var $_1plr87adjh8lpuk3 = { get: get };
|
||||
|
||||
// Block TinyMCE menu on ctrlKey
|
||||
if (e.ctrlKey && !contextmenuNeverUseNative) {
|
||||
return;
|
||||
}
|
||||
var shouldNeverUseNative = function (editor) {
|
||||
return editor.settings.contextmenu_never_use_native;
|
||||
};
|
||||
var getContextMenu = function (editor) {
|
||||
return editor.getParam('contextmenu', 'link openlink image inserttable | cell row column deletetable');
|
||||
};
|
||||
var $_aqpwplafjh8lpuk5 = {
|
||||
shouldNeverUseNative: shouldNeverUseNative,
|
||||
getContextMenu: getContextMenu
|
||||
};
|
||||
|
||||
e.preventDefault();
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
/**
|
||||
* WebKit/Blink on Mac has the odd behavior of selecting the target word or line this causes
|
||||
* issues when for example inserting images see: #7022
|
||||
*/
|
||||
if (tinymce.Env.mac && tinymce.Env.webkit) {
|
||||
if (e.button == 2 && doc.caretRangeFromPoint) {
|
||||
editor.selection.setRng(doc.caretRangeFromPoint(e.x, e.y));
|
||||
}
|
||||
}
|
||||
var getUiContainer = function (editor) {
|
||||
return global$1.DOM.select(editor.settings.ui_container)[0];
|
||||
};
|
||||
|
||||
contextmenu = editor.settings.contextmenu || 'link image inserttable | cell row column deletetable';
|
||||
var nu = function (x, y) {
|
||||
return {
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
};
|
||||
var transpose = function (pos, dx, dy) {
|
||||
return nu(pos.x + dx, pos.y + dy);
|
||||
};
|
||||
var fromPageXY = function (e) {
|
||||
return nu(e.pageX, e.pageY);
|
||||
};
|
||||
var fromClientXY = function (e) {
|
||||
return nu(e.clientX, e.clientY);
|
||||
};
|
||||
var transposeUiContainer = function (element, pos) {
|
||||
if (element && global$1.DOM.getStyle(element, 'position', true) !== 'static') {
|
||||
var containerPos = global$1.DOM.getPos(element);
|
||||
var dx = containerPos.x - element.scrollLeft;
|
||||
var dy = containerPos.y - element.scrollTop;
|
||||
return transpose(pos, -dx, -dy);
|
||||
} else {
|
||||
return transpose(pos, 0, 0);
|
||||
}
|
||||
};
|
||||
var transposeContentAreaContainer = function (element, pos) {
|
||||
var containerPos = global$1.DOM.getPos(element);
|
||||
return transpose(pos, containerPos.x, containerPos.y);
|
||||
};
|
||||
var getPos = function (editor, e) {
|
||||
if (editor.inline) {
|
||||
return transposeUiContainer(getUiContainer(editor), fromPageXY(e));
|
||||
} else {
|
||||
var iframePos = transposeContentAreaContainer(editor.getContentAreaContainer(), fromClientXY(e));
|
||||
return transposeUiContainer(getUiContainer(editor), iframePos);
|
||||
}
|
||||
};
|
||||
var $_chvtdxagjh8lpuk6 = { getPos: getPos };
|
||||
|
||||
// Render menu
|
||||
if (!menu) {
|
||||
var items = [];
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.ui.Factory');
|
||||
|
||||
tinymce.each(contextmenu.split(/[ ,]/), function(name) {
|
||||
var item = editor.menuItems[name];
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
if (name == '|') {
|
||||
item = {text: name};
|
||||
}
|
||||
var renderMenu = function (editor, visibleState) {
|
||||
var menu, contextmenu;
|
||||
var items = [];
|
||||
contextmenu = $_aqpwplafjh8lpuk5.getContextMenu(editor);
|
||||
global$3.each(contextmenu.split(/[ ,]/), function (name) {
|
||||
var item = editor.menuItems[name];
|
||||
if (name === '|') {
|
||||
item = { text: name };
|
||||
}
|
||||
if (item) {
|
||||
item.shortcut = '';
|
||||
items.push(item);
|
||||
}
|
||||
});
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].text === '|') {
|
||||
if (i === 0 || i === items.length - 1) {
|
||||
items.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
menu = global$2.create('menu', {
|
||||
items: items,
|
||||
context: 'contextmenu',
|
||||
classes: 'contextmenu'
|
||||
});
|
||||
menu.uiContainer = getUiContainer(editor);
|
||||
menu.renderTo(getUiContainer(editor));
|
||||
menu.on('hide', function (e) {
|
||||
if (e.control === this) {
|
||||
visibleState.set(false);
|
||||
}
|
||||
});
|
||||
editor.on('remove', function () {
|
||||
menu.remove();
|
||||
menu = null;
|
||||
});
|
||||
return menu;
|
||||
};
|
||||
var show = function (editor, pos, visibleState, menu) {
|
||||
if (menu.get() === null) {
|
||||
menu.set(renderMenu(editor, visibleState));
|
||||
} else {
|
||||
menu.get().show();
|
||||
}
|
||||
menu.get().moveTo(pos.x, pos.y);
|
||||
visibleState.set(true);
|
||||
};
|
||||
var $_5cxb8ajjh8lpukb = { show: show };
|
||||
|
||||
if (item) {
|
||||
item.shortcut = ''; // Hide shortcuts
|
||||
items.push(item);
|
||||
}
|
||||
});
|
||||
var isNativeOverrideKeyEvent = function (editor, e) {
|
||||
return e.ctrlKey && !$_aqpwplafjh8lpuk5.shouldNeverUseNative(editor);
|
||||
};
|
||||
var setup = function (editor, visibleState, menu) {
|
||||
editor.on('contextmenu', function (e) {
|
||||
if (isNativeOverrideKeyEvent(editor, e)) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
$_5cxb8ajjh8lpukb.show(editor, $_chvtdxagjh8lpuk6.getPos(editor, e), visibleState, menu);
|
||||
});
|
||||
};
|
||||
var $_fqo42laejh8lpuk4 = { setup: setup };
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].text == '|') {
|
||||
if (i === 0 || i == items.length - 1) {
|
||||
items.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
global.add('contextmenu', function (editor) {
|
||||
var menu = Cell(null), visibleState = Cell(false);
|
||||
$_fqo42laejh8lpuk4.setup(editor, visibleState, menu);
|
||||
return $_1plr87adjh8lpuk3.get(visibleState);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
menu = new tinymce.ui.Menu({
|
||||
items: items,
|
||||
context: 'contextmenu'
|
||||
}).addClass('contextmenu').renderTo();
|
||||
return Plugin;
|
||||
|
||||
editor.on('remove', function() {
|
||||
menu.remove();
|
||||
menu = null;
|
||||
});
|
||||
} else {
|
||||
menu.show();
|
||||
}
|
||||
|
||||
// Position menu
|
||||
var pos = {x: e.pageX, y: e.pageY};
|
||||
|
||||
if (!editor.inline) {
|
||||
pos = tinymce.DOM.getPos(editor.getContentAreaContainer());
|
||||
pos.x += e.clientX;
|
||||
pos.y += e.clientY;
|
||||
}
|
||||
|
||||
menu.moveTo(pos.x, pos.y);
|
||||
});
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("contextmenu",function(a){var b,c=a.settings.contextmenu_never_use_native;a.on("contextmenu",function(d){var e,f=a.getDoc();if(!d.ctrlKey||c){if(d.preventDefault(),tinymce.Env.mac&&tinymce.Env.webkit&&2==d.button&&f.caretRangeFromPoint&&a.selection.setRng(f.caretRangeFromPoint(d.x,d.y)),e=a.settings.contextmenu||"link image inserttable | cell row column deletetable",b)b.show();else{var g=[];tinymce.each(e.split(/[ ,]/),function(b){var c=a.menuItems[b];"|"==b&&(c={text:b}),c&&(c.shortcut="",g.push(c))});for(var h=0;h<g.length;h++)"|"==g[h].text&&(0===h||h==g.length-1)&&g.splice(h,1);b=new tinymce.ui.Menu({items:g,context:"contextmenu"}).addClass("contextmenu").renderTo(),a.on("remove",function(){b.remove(),b=null})}var i={x:d.pageX,y:d.pageY};a.inline||(i=tinymce.DOM.getPos(a.getContentAreaContainer()),i.x+=d.clientX,i.y+=d.clientY),b.moveTo(i.x,i.y)}})});
|
||||
!function(){"use strict";var o=function(t){var n=t,e=function(){return n};return{get:e,set:function(t){n=t},clone:function(){return o(e())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=function(t){return{isContextMenuVisible:function(){return t.get()}}},r=function(t){return t.settings.contextmenu_never_use_native},u=function(t){return t.getParam("contextmenu","link openlink image inserttable | cell row column deletetable")},l=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=function(t){return l.DOM.select(t.settings.ui_container)[0]},a=function(t,n){return{x:t,y:n}},f=function(t,n,e){return a(t.x+n,t.y+e)},m=function(t,n){if(t&&"static"!==l.DOM.getStyle(t,"position",!0)){var e=l.DOM.getPos(t),o=e.x-t.scrollLeft,i=e.y-t.scrollTop;return f(n,-o,-i)}return f(n,0,0)},c=function(t,n){if(t.inline)return m(s(t),a((u=n).pageX,u.pageY));var e,o,i,r,u,c=(e=t.getContentAreaContainer(),o=a((r=n).clientX,r.clientY),i=l.DOM.getPos(e),f(o,i.x,i.y));return m(s(t),c)},g=tinymce.util.Tools.resolve("tinymce.ui.Factory"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),y=function(t,n,e,o){null===o.get()?o.set(function(e,n){var t,o,i=[];o=u(e),v.each(o.split(/[ ,]/),function(t){var n=e.menuItems[t];"|"===t&&(n={text:t}),n&&(n.shortcut="",i.push(n))});for(var r=0;r<i.length;r++)"|"===i[r].text&&(0!==r&&r!==i.length-1||i.splice(r,1));return(t=g.create("menu",{items:i,context:"contextmenu",classes:"contextmenu"})).uiContainer=s(e),t.renderTo(s(e)),t.on("hide",function(t){t.control===this&&n.set(!1)}),e.on("remove",function(){t.remove(),t=null}),t}(t,e)):o.get().show(),o.get().moveTo(n.x,n.y),e.set(!0)},x=function(e,o,i){e.on("contextmenu",function(t){var n;n=e,(!t.ctrlKey||r(n))&&(t.preventDefault(),y(e,c(e,t),o,i))})};t.add("contextmenu",function(t){var n=o(null),e=o(!1);return x(t,e,n),i(e)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "directionality" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/directionality')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/directionality'
|
||||
require('./plugin.js');
|
||||
@@ -1,64 +1,66 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var directionality = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('directionality', function(editor) {
|
||||
function setDir(dir) {
|
||||
var dom = editor.dom, curDir, blocks = editor.selection.getSelectedBlocks();
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
if (blocks.length) {
|
||||
curDir = dom.getAttrib(blocks[0], "dir");
|
||||
var setDir = function (editor, dir) {
|
||||
var dom = editor.dom;
|
||||
var curDir;
|
||||
var blocks = editor.selection.getSelectedBlocks();
|
||||
if (blocks.length) {
|
||||
curDir = dom.getAttrib(blocks[0], 'dir');
|
||||
global$1.each(blocks, function (block) {
|
||||
if (!dom.getParent(block.parentNode, '*[dir="' + dir + '"]', dom.getRoot())) {
|
||||
dom.setAttrib(block, 'dir', curDir !== dir ? dir : null);
|
||||
}
|
||||
});
|
||||
editor.nodeChanged();
|
||||
}
|
||||
};
|
||||
var $_buu6krapjh8lpukw = { setDir: setDir };
|
||||
|
||||
tinymce.each(blocks, function(block) {
|
||||
// Add dir to block if the parent block doesn't already have that dir
|
||||
if (!dom.getParent(block.parentNode, "*[dir='" + dir + "']", dom.getRoot())) {
|
||||
if (curDir != dir) {
|
||||
dom.setAttrib(block, "dir", dir);
|
||||
} else {
|
||||
dom.setAttrib(block, "dir", null);
|
||||
}
|
||||
}
|
||||
});
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceDirectionLTR', function () {
|
||||
$_buu6krapjh8lpukw.setDir(editor, 'ltr');
|
||||
});
|
||||
editor.addCommand('mceDirectionRTL', function () {
|
||||
$_buu6krapjh8lpukw.setDir(editor, 'rtl');
|
||||
});
|
||||
};
|
||||
var $_3sbtv0aojh8lpukv = { register: register };
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
var generateSelector = function (dir) {
|
||||
var selector = [];
|
||||
global$1.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function (name) {
|
||||
selector.push(name + '[dir=' + dir + ']');
|
||||
});
|
||||
return selector.join(',');
|
||||
};
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('ltr', {
|
||||
title: 'Left to right',
|
||||
cmd: 'mceDirectionLTR',
|
||||
stateSelector: generateSelector('ltr')
|
||||
});
|
||||
editor.addButton('rtl', {
|
||||
title: 'Right to left',
|
||||
cmd: 'mceDirectionRTL',
|
||||
stateSelector: generateSelector('rtl')
|
||||
});
|
||||
};
|
||||
var $_bdjfw5arjh8lpuky = { register: register$1 };
|
||||
|
||||
function generateSelector(dir) {
|
||||
var selector = [];
|
||||
global.add('directionality', function (editor) {
|
||||
$_3sbtv0aojh8lpukv.register(editor);
|
||||
$_bdjfw5arjh8lpuky.register(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
tinymce.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function(name) {
|
||||
selector.push(name + '[dir=' + dir + ']');
|
||||
});
|
||||
return Plugin;
|
||||
|
||||
return selector.join(',');
|
||||
}
|
||||
|
||||
editor.addCommand('mceDirectionLTR', function() {
|
||||
setDir("ltr");
|
||||
});
|
||||
|
||||
editor.addCommand('mceDirectionRTL', function() {
|
||||
setDir("rtl");
|
||||
});
|
||||
|
||||
editor.addButton('ltr', {
|
||||
title: 'Left to right',
|
||||
cmd: 'mceDirectionLTR',
|
||||
stateSelector: generateSelector('ltr')
|
||||
});
|
||||
|
||||
editor.addButton('rtl', {
|
||||
title: 'Right to left',
|
||||
cmd: 'mceDirectionRTL',
|
||||
stateSelector: generateSelector('rtl')
|
||||
});
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("directionality",function(a){function b(b){var c,d=a.dom,e=a.selection.getSelectedBlocks();e.length&&(c=d.getAttrib(e[0],"dir"),tinymce.each(e,function(a){d.getParent(a.parentNode,"*[dir='"+b+"']",d.getRoot())||(c!=b?d.setAttrib(a,"dir",b):d.setAttrib(a,"dir",null))}),a.nodeChanged())}function c(a){var b=[];return tinymce.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(c){b.push(c+"[dir="+a+"]")}),b.join(",")}a.addCommand("mceDirectionLTR",function(){b("ltr")}),a.addCommand("mceDirectionRTL",function(){b("rtl")}),a.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:c("ltr")}),a.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:c("rtl")})});
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=tinymce.util.Tools.resolve("tinymce.util.Tools"),e=function(t,e){var i,n=t.dom,o=t.selection.getSelectedBlocks();o.length&&(i=n.getAttrib(o[0],"dir"),c.each(o,function(t){n.getParent(t.parentNode,'*[dir="'+e+'"]',n.getRoot())||n.setAttrib(t,"dir",i!==e?e:null)}),t.nodeChanged())},i=function(t){t.addCommand("mceDirectionLTR",function(){e(t,"ltr")}),t.addCommand("mceDirectionRTL",function(){e(t,"rtl")})},n=function(e){var i=[];return c.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(t){i.push(t+"[dir="+e+"]")}),i.join(",")},o=function(t){t.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:n("ltr")}),t.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:n("rtl")})};t.add("directionality",function(t){i(t),o(t)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "emoticons" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/emoticons')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/emoticons'
|
||||
require('./plugin.js');
|
||||
@@ -1,65 +1,87 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var emoticons = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('emoticons', function(editor, url) {
|
||||
var emoticons = [
|
||||
["cool", "cry", "embarassed", "foot-in-mouth"],
|
||||
["frown", "innocent", "kiss", "laughing"],
|
||||
["money-mouth", "sealed", "smile", "surprised"],
|
||||
["tongue-out", "undecided", "wink", "yell"]
|
||||
];
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
function getHtml() {
|
||||
var emoticonsHtml;
|
||||
var emoticons = [
|
||||
[
|
||||
'cool',
|
||||
'cry',
|
||||
'embarassed',
|
||||
'foot-in-mouth'
|
||||
],
|
||||
[
|
||||
'frown',
|
||||
'innocent',
|
||||
'kiss',
|
||||
'laughing'
|
||||
],
|
||||
[
|
||||
'money-mouth',
|
||||
'sealed',
|
||||
'smile',
|
||||
'surprised'
|
||||
],
|
||||
[
|
||||
'tongue-out',
|
||||
'undecided',
|
||||
'wink',
|
||||
'yell'
|
||||
]
|
||||
];
|
||||
var getHtml = function (pluginUrl) {
|
||||
var emoticonsHtml;
|
||||
emoticonsHtml = '<table role="list" class="mce-grid">';
|
||||
global$1.each(emoticons, function (row) {
|
||||
emoticonsHtml += '<tr>';
|
||||
global$1.each(row, function (icon) {
|
||||
var emoticonUrl = pluginUrl + '/img/smiley-' + icon + '.gif';
|
||||
emoticonsHtml += '<td><a href="#" data-mce-url="' + emoticonUrl + '" data-mce-alt="' + icon + '" tabindex="-1" ' + 'role="option" aria-label="' + icon + '"><img src="' + emoticonUrl + '" style="width: 18px; height: 18px" role="presentation" /></a></td>';
|
||||
});
|
||||
emoticonsHtml += '</tr>';
|
||||
});
|
||||
emoticonsHtml += '</table>';
|
||||
return emoticonsHtml;
|
||||
};
|
||||
var $_ty332avjh8lpul9 = { getHtml: getHtml };
|
||||
|
||||
emoticonsHtml = '<table role="list" class="mce-grid">';
|
||||
var insertEmoticon = function (editor, src, alt) {
|
||||
editor.insertContent(editor.dom.createHTML('img', {
|
||||
src: src,
|
||||
alt: alt
|
||||
}));
|
||||
};
|
||||
var register = function (editor, pluginUrl) {
|
||||
var panelHtml = $_ty332avjh8lpul9.getHtml(pluginUrl);
|
||||
editor.addButton('emoticons', {
|
||||
type: 'panelbutton',
|
||||
panel: {
|
||||
role: 'application',
|
||||
autohide: true,
|
||||
html: panelHtml,
|
||||
onclick: function (e) {
|
||||
var linkElm = editor.dom.getParent(e.target, 'a');
|
||||
if (linkElm) {
|
||||
insertEmoticon(editor, linkElm.getAttribute('data-mce-url'), linkElm.getAttribute('data-mce-alt'));
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: 'Emoticons'
|
||||
});
|
||||
};
|
||||
var $_5iodwqaujh8lpul7 = { register: register };
|
||||
|
||||
tinymce.each(emoticons, function(row) {
|
||||
emoticonsHtml += '<tr>';
|
||||
global.add('emoticons', function (editor, pluginUrl) {
|
||||
$_5iodwqaujh8lpul7.register(editor, pluginUrl);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
tinymce.each(row, function(icon) {
|
||||
var emoticonUrl = url + '/img/smiley-' + icon + '.gif';
|
||||
return Plugin;
|
||||
|
||||
emoticonsHtml += '<td><a href="#" data-mce-url="' + emoticonUrl + '" data-mce-alt="' + icon + '" tabindex="-1" ' +
|
||||
'role="option" aria-label="' + icon + '"><img src="' +
|
||||
emoticonUrl + '" style="width: 18px; height: 18px" role="presentation" /></a></td>';
|
||||
});
|
||||
|
||||
emoticonsHtml += '</tr>';
|
||||
});
|
||||
|
||||
emoticonsHtml += '</table>';
|
||||
|
||||
return emoticonsHtml;
|
||||
}
|
||||
|
||||
editor.addButton('emoticons', {
|
||||
type: 'panelbutton',
|
||||
panel: {
|
||||
role: 'application',
|
||||
autohide: true,
|
||||
html: getHtml,
|
||||
onclick: function(e) {
|
||||
var linkElm = editor.dom.getParent(e.target, 'a');
|
||||
|
||||
if (linkElm) {
|
||||
editor.insertContent(
|
||||
'<img src="' + linkElm.getAttribute('data-mce-url') + '" alt="' + linkElm.getAttribute('data-mce-alt') + '" />'
|
||||
);
|
||||
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: 'Emoticons'
|
||||
});
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("emoticons",function(a,b){function c(){var a;return a='<table role="list" class="mce-grid">',tinymce.each(d,function(c){a+="<tr>",tinymce.each(c,function(c){var d=b+"/img/smiley-"+c+".gif";a+='<td><a href="#" data-mce-url="'+d+'" data-mce-alt="'+c+'" tabindex="-1" role="option" aria-label="'+c+'"><img src="'+d+'" style="width: 18px; height: 18px" role="presentation" /></a></td>'}),a+="</tr>"}),a+="</table>"}var d=[["cool","cry","embarassed","foot-in-mouth"],["frown","innocent","kiss","laughing"],["money-mouth","sealed","smile","surprised"],["tongue-out","undecided","wink","yell"]];a.addButton("emoticons",{type:"panelbutton",panel:{role:"application",autohide:!0,html:c,onclick:function(b){var c=a.dom.getParent(b.target,"a");c&&(a.insertContent('<img src="'+c.getAttribute("data-mce-url")+'" alt="'+c.getAttribute("data-mce-alt")+'" />'),this.hide())}},tooltip:"Emoticons"})});
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),e=tinymce.util.Tools.resolve("tinymce.util.Tools"),n=[["cool","cry","embarassed","foot-in-mouth"],["frown","innocent","kiss","laughing"],["money-mouth","sealed","smile","surprised"],["tongue-out","undecided","wink","yell"]],i=function(i){var o;return o='<table role="list" class="mce-grid">',e.each(n,function(t){o+="<tr>",e.each(t,function(t){var e=i+"/img/smiley-"+t+".gif";o+='<td><a href="#" data-mce-url="'+e+'" data-mce-alt="'+t+'" tabindex="-1" role="option" aria-label="'+t+'"><img src="'+e+'" style="width: 18px; height: 18px" role="presentation" /></a></td>'}),o+="</tr>"}),o+="</table>"},o=function(a,t){var e=i(t);a.addButton("emoticons",{type:"panelbutton",panel:{role:"application",autohide:!0,html:e,onclick:function(t){var e,i,o,n=a.dom.getParent(t.target,"a");n&&(e=a,i=n.getAttribute("data-mce-url"),o=n.getAttribute("data-mce-alt"),e.insertContent(e.dom.createHTML("img",{src:i,alt:o})),this.hide())}},tooltip:"Emoticons"})};t.add("emoticons",function(t,e){o(t,e)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "fullpage" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/fullpage')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/fullpage'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "fullscreen" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/fullscreen')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/fullscreen'
|
||||
require('./plugin.js');
|
||||
@@ -1,136 +1,177 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var fullscreen = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
tinymce.PluginManager.add('fullscreen', function(editor) {
|
||||
var fullscreenState = false, DOM = tinymce.DOM, iframeWidth, iframeHeight, resizeHandler;
|
||||
var containerWidth, containerHeight;
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
if (editor.settings.inline) {
|
||||
return;
|
||||
}
|
||||
var get = function (fullscreenState) {
|
||||
return {
|
||||
isFullscreen: function () {
|
||||
return fullscreenState.get() !== null;
|
||||
}
|
||||
};
|
||||
};
|
||||
var $_id7tbbzjh8lpupt = { get: get };
|
||||
|
||||
function getWindowSize() {
|
||||
var w, h, win = window, doc = document;
|
||||
var body = doc.body;
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
// Old IE
|
||||
if (body.offsetWidth) {
|
||||
w = body.offsetWidth;
|
||||
h = body.offsetHeight;
|
||||
}
|
||||
var fireFullscreenStateChanged = function (editor, state) {
|
||||
editor.fire('FullscreenStateChanged', { state: state });
|
||||
};
|
||||
var $_i7kzec3jh8lpupz = { fireFullscreenStateChanged: fireFullscreenStateChanged };
|
||||
|
||||
// Modern browsers
|
||||
if (win.innerWidth && win.innerHeight) {
|
||||
w = win.innerWidth;
|
||||
h = win.innerHeight;
|
||||
}
|
||||
var DOM = global$1.DOM;
|
||||
var getWindowSize = function () {
|
||||
var w;
|
||||
var h;
|
||||
var win = window;
|
||||
var doc = document;
|
||||
var body = doc.body;
|
||||
if (body.offsetWidth) {
|
||||
w = body.offsetWidth;
|
||||
h = body.offsetHeight;
|
||||
}
|
||||
if (win.innerWidth && win.innerHeight) {
|
||||
w = win.innerWidth;
|
||||
h = win.innerHeight;
|
||||
}
|
||||
return {
|
||||
w: w,
|
||||
h: h
|
||||
};
|
||||
};
|
||||
var getScrollPos = function () {
|
||||
var vp = DOM.getViewPort();
|
||||
return {
|
||||
x: vp.x,
|
||||
y: vp.y
|
||||
};
|
||||
};
|
||||
var setScrollPos = function (pos) {
|
||||
window.scrollTo(pos.x, pos.y);
|
||||
};
|
||||
var toggleFullscreen = function (editor, fullscreenState) {
|
||||
var body = document.body;
|
||||
var documentElement = document.documentElement;
|
||||
var editorContainerStyle;
|
||||
var editorContainer, iframe, iframeStyle;
|
||||
var fullscreenInfo = fullscreenState.get();
|
||||
var resize = function () {
|
||||
DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight));
|
||||
};
|
||||
var removeResize = function () {
|
||||
DOM.unbind(window, 'resize', resize);
|
||||
};
|
||||
editorContainer = editor.getContainer();
|
||||
editorContainerStyle = editorContainer.style;
|
||||
iframe = editor.getContentAreaContainer().firstChild;
|
||||
iframeStyle = iframe.style;
|
||||
if (!fullscreenInfo) {
|
||||
var newFullScreenInfo = {
|
||||
scrollPos: getScrollPos(),
|
||||
containerWidth: editorContainerStyle.width,
|
||||
containerHeight: editorContainerStyle.height,
|
||||
iframeWidth: iframeStyle.width,
|
||||
iframeHeight: iframeStyle.height,
|
||||
resizeHandler: resize,
|
||||
removeHandler: removeResize
|
||||
};
|
||||
iframeStyle.width = iframeStyle.height = '100%';
|
||||
editorContainerStyle.width = editorContainerStyle.height = '';
|
||||
DOM.addClass(body, 'mce-fullscreen');
|
||||
DOM.addClass(documentElement, 'mce-fullscreen');
|
||||
DOM.addClass(editorContainer, 'mce-fullscreen');
|
||||
DOM.bind(window, 'resize', resize);
|
||||
editor.on('remove', removeResize);
|
||||
resize();
|
||||
fullscreenState.set(newFullScreenInfo);
|
||||
$_i7kzec3jh8lpupz.fireFullscreenStateChanged(editor, true);
|
||||
} else {
|
||||
iframeStyle.width = fullscreenInfo.iframeWidth;
|
||||
iframeStyle.height = fullscreenInfo.iframeHeight;
|
||||
if (fullscreenInfo.containerWidth) {
|
||||
editorContainerStyle.width = fullscreenInfo.containerWidth;
|
||||
}
|
||||
if (fullscreenInfo.containerHeight) {
|
||||
editorContainerStyle.height = fullscreenInfo.containerHeight;
|
||||
}
|
||||
DOM.removeClass(body, 'mce-fullscreen');
|
||||
DOM.removeClass(documentElement, 'mce-fullscreen');
|
||||
DOM.removeClass(editorContainer, 'mce-fullscreen');
|
||||
setScrollPos(fullscreenInfo.scrollPos);
|
||||
DOM.unbind(window, 'resize', fullscreenInfo.resizeHandler);
|
||||
editor.off('remove', fullscreenInfo.removeHandler);
|
||||
fullscreenState.set(null);
|
||||
$_i7kzec3jh8lpupz.fireFullscreenStateChanged(editor, false);
|
||||
}
|
||||
};
|
||||
var $_971qctc1jh8lpupv = { toggleFullscreen: toggleFullscreen };
|
||||
|
||||
return {w: w, h: h};
|
||||
}
|
||||
var register = function (editor, fullscreenState) {
|
||||
editor.addCommand('mceFullScreen', function () {
|
||||
$_971qctc1jh8lpupv.toggleFullscreen(editor, fullscreenState);
|
||||
});
|
||||
};
|
||||
var $_7y4syjc0jh8lpupt = { register: register };
|
||||
|
||||
function toggleFullscreen() {
|
||||
var body = document.body, documentElement = document.documentElement, editorContainerStyle;
|
||||
var editorContainer, iframe, iframeStyle;
|
||||
var postRender = function (editor) {
|
||||
return function (e) {
|
||||
var ctrl = e.control;
|
||||
editor.on('FullscreenStateChanged', function (e) {
|
||||
ctrl.active(e.state);
|
||||
});
|
||||
};
|
||||
};
|
||||
var register$1 = function (editor) {
|
||||
editor.addMenuItem('fullscreen', {
|
||||
text: 'Fullscreen',
|
||||
shortcut: 'Ctrl+Shift+F',
|
||||
selectable: true,
|
||||
cmd: 'mceFullScreen',
|
||||
onPostRender: postRender(editor),
|
||||
context: 'view'
|
||||
});
|
||||
editor.addButton('fullscreen', {
|
||||
active: false,
|
||||
tooltip: 'Fullscreen',
|
||||
cmd: 'mceFullScreen',
|
||||
onPostRender: postRender(editor)
|
||||
});
|
||||
};
|
||||
var $_492blpc4jh8lpuq0 = { register: register$1 };
|
||||
|
||||
function resize() {
|
||||
DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight));
|
||||
}
|
||||
global.add('fullscreen', function (editor) {
|
||||
var fullscreenState = Cell(null);
|
||||
if (editor.settings.inline) {
|
||||
return $_id7tbbzjh8lpupt.get(fullscreenState);
|
||||
}
|
||||
$_7y4syjc0jh8lpupt.register(editor, fullscreenState);
|
||||
$_492blpc4jh8lpuq0.register(editor);
|
||||
editor.addShortcut('Ctrl+Shift+F', '', 'mceFullScreen');
|
||||
return $_id7tbbzjh8lpupt.get(fullscreenState);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
fullscreenState = !fullscreenState;
|
||||
return Plugin;
|
||||
|
||||
editorContainer = editor.getContainer();
|
||||
editorContainerStyle = editorContainer.style;
|
||||
iframe = editor.getContentAreaContainer().firstChild;
|
||||
iframeStyle = iframe.style;
|
||||
|
||||
if (fullscreenState) {
|
||||
iframeWidth = iframeStyle.width;
|
||||
iframeHeight = iframeStyle.height;
|
||||
iframeStyle.width = iframeStyle.height = '100%';
|
||||
containerWidth = editorContainerStyle.width;
|
||||
containerHeight = editorContainerStyle.height;
|
||||
editorContainerStyle.width = editorContainerStyle.height = '';
|
||||
|
||||
DOM.addClass(body, 'mce-fullscreen');
|
||||
DOM.addClass(documentElement, 'mce-fullscreen');
|
||||
DOM.addClass(editorContainer, 'mce-fullscreen');
|
||||
|
||||
DOM.bind(window, 'resize', resize);
|
||||
resize();
|
||||
resizeHandler = resize;
|
||||
} else {
|
||||
iframeStyle.width = iframeWidth;
|
||||
iframeStyle.height = iframeHeight;
|
||||
|
||||
if (containerWidth) {
|
||||
editorContainerStyle.width = containerWidth;
|
||||
}
|
||||
|
||||
if (containerHeight) {
|
||||
editorContainerStyle.height = containerHeight;
|
||||
}
|
||||
|
||||
DOM.removeClass(body, 'mce-fullscreen');
|
||||
DOM.removeClass(documentElement, 'mce-fullscreen');
|
||||
DOM.removeClass(editorContainer, 'mce-fullscreen');
|
||||
DOM.unbind(window, 'resize', resizeHandler);
|
||||
}
|
||||
|
||||
editor.fire('FullscreenStateChanged', {state: fullscreenState});
|
||||
}
|
||||
|
||||
editor.on('init', function() {
|
||||
editor.addShortcut('Meta+Alt+F', '', toggleFullscreen);
|
||||
});
|
||||
|
||||
editor.on('remove', function() {
|
||||
if (resizeHandler) {
|
||||
DOM.unbind(window, 'resize', resizeHandler);
|
||||
}
|
||||
});
|
||||
|
||||
editor.addCommand('mceFullScreen', toggleFullscreen);
|
||||
|
||||
editor.addMenuItem('fullscreen', {
|
||||
text: 'Fullscreen',
|
||||
shortcut: 'Meta+Alt+F',
|
||||
selectable: true,
|
||||
onClick: toggleFullscreen,
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on('FullscreenStateChanged', function(e) {
|
||||
self.active(e.state);
|
||||
});
|
||||
},
|
||||
context: 'view'
|
||||
});
|
||||
|
||||
editor.addButton('fullscreen', {
|
||||
tooltip: 'Fullscreen',
|
||||
shortcut: 'Meta+Alt+F',
|
||||
onClick: toggleFullscreen,
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on('FullscreenStateChanged', function(e) {
|
||||
self.active(e.state);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
isFullscreen: function() {
|
||||
return fullscreenState;
|
||||
}
|
||||
};
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("fullscreen",function(a){function b(){var a,b,c=window,d=document,e=d.body;return e.offsetWidth&&(a=e.offsetWidth,b=e.offsetHeight),c.innerWidth&&c.innerHeight&&(a=c.innerWidth,b=c.innerHeight),{w:a,h:b}}function c(){function c(){j.setStyle(m,"height",b().h-(l.clientHeight-m.clientHeight))}var k,l,m,n,o=document.body,p=document.documentElement;i=!i,l=a.getContainer(),k=l.style,m=a.getContentAreaContainer().firstChild,n=m.style,i?(d=n.width,e=n.height,n.width=n.height="100%",g=k.width,h=k.height,k.width=k.height="",j.addClass(o,"mce-fullscreen"),j.addClass(p,"mce-fullscreen"),j.addClass(l,"mce-fullscreen"),j.bind(window,"resize",c),c(),f=c):(n.width=d,n.height=e,g&&(k.width=g),h&&(k.height=h),j.removeClass(o,"mce-fullscreen"),j.removeClass(p,"mce-fullscreen"),j.removeClass(l,"mce-fullscreen"),j.unbind(window,"resize",f)),a.fire("FullscreenStateChanged",{state:i})}var d,e,f,g,h,i=!1,j=tinymce.DOM;return a.settings.inline?void 0:(a.on("init",function(){a.addShortcut("Meta+Alt+F","",c)}),a.on("remove",function(){f&&j.unbind(window,"resize",f)}),a.addCommand("mceFullScreen",c),a.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Meta+Alt+F",selectable:!0,onClick:c,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})},context:"view"}),a.addButton("fullscreen",{tooltip:"Fullscreen",shortcut:"Meta+Alt+F",onClick:c,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})}}),{isFullscreen:function(){return i}})});
|
||||
!function(){"use strict";var i=function(e){var n=e,t=function(){return n};return{get:t,set:function(e){n=e},clone:function(){return i(t())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(e){return{isFullscreen:function(){return null!==e.get()}}},n=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),m=function(e,n){e.fire("FullscreenStateChanged",{state:n})},g=n.DOM,r=function(e,n){var t,r,l,i,o,c,s=document.body,u=document.documentElement,d=n.get(),a=function(){var e,n,t,i;g.setStyle(l,"height",(t=window,i=document.body,i.offsetWidth&&(e=i.offsetWidth,n=i.offsetHeight),t.innerWidth&&t.innerHeight&&(e=t.innerWidth,n=t.innerHeight),{w:e,h:n}).h-(r.clientHeight-l.clientHeight))},h=function(){g.unbind(window,"resize",a)};if(t=(r=e.getContainer()).style,i=(l=e.getContentAreaContainer().firstChild).style,d)i.width=d.iframeWidth,i.height=d.iframeHeight,d.containerWidth&&(t.width=d.containerWidth),d.containerHeight&&(t.height=d.containerHeight),g.removeClass(s,"mce-fullscreen"),g.removeClass(u,"mce-fullscreen"),g.removeClass(r,"mce-fullscreen"),o=d.scrollPos,window.scrollTo(o.x,o.y),g.unbind(window,"resize",d.resizeHandler),e.off("remove",d.removeHandler),n.set(null),m(e,!1);else{var f={scrollPos:(c=g.getViewPort(),{x:c.x,y:c.y}),containerWidth:t.width,containerHeight:t.height,iframeWidth:i.width,iframeHeight:i.height,resizeHandler:a,removeHandler:h};i.width=i.height="100%",t.width=t.height="",g.addClass(s,"mce-fullscreen"),g.addClass(u,"mce-fullscreen"),g.addClass(r,"mce-fullscreen"),g.bind(window,"resize",a),e.on("remove",h),a(),n.set(f),m(e,!0)}},l=function(e,n){e.addCommand("mceFullScreen",function(){r(e,n)})},o=function(t){return function(e){var n=e.control;t.on("FullscreenStateChanged",function(e){n.active(e.state)})}},c=function(e){e.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Ctrl+Shift+F",selectable:!0,cmd:"mceFullScreen",onPostRender:o(e),context:"view"}),e.addButton("fullscreen",{active:!1,tooltip:"Fullscreen",cmd:"mceFullScreen",onPostRender:o(e)})};e.add("fullscreen",function(e){var n=i(null);return e.settings.inline||(l(e,n),c(e),e.addShortcut("Ctrl+Shift+F","","mceFullScreen")),t(n)})}();
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,7 @@
|
||||
// Exports the "help" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/help')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/help'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "hr" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/hr')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/hr'
|
||||
require('./plugin.js');
|
||||
@@ -1,30 +1,39 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var hr = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('hr', function(editor) {
|
||||
editor.addCommand('InsertHorizontalRule', function() {
|
||||
editor.execCommand('mceInsertContent', false, '<hr />');
|
||||
});
|
||||
var register = function (editor) {
|
||||
editor.addCommand('InsertHorizontalRule', function () {
|
||||
editor.execCommand('mceInsertContent', false, '<hr />');
|
||||
});
|
||||
};
|
||||
var $_fvts64c7jh8lpuqd = { register: register };
|
||||
|
||||
editor.addButton('hr', {
|
||||
icon: 'hr',
|
||||
tooltip: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule'
|
||||
});
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('hr', {
|
||||
icon: 'hr',
|
||||
tooltip: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule'
|
||||
});
|
||||
editor.addMenuItem('hr', {
|
||||
icon: 'hr',
|
||||
text: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule',
|
||||
context: 'insert'
|
||||
});
|
||||
};
|
||||
var $_fzoakwc8jh8lpuqe = { register: register$1 };
|
||||
|
||||
editor.addMenuItem('hr', {
|
||||
icon: 'hr',
|
||||
text: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule',
|
||||
context: 'insert'
|
||||
});
|
||||
});
|
||||
global.add('hr', function (editor) {
|
||||
$_fvts64c7jh8lpuqd.register(editor);
|
||||
$_fzoakwc8jh8lpuqe.register(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("hr",function(a){a.addCommand("InsertHorizontalRule",function(){a.execCommand("mceInsertContent",!1,"<hr />")}),a.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),a.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})});
|
||||
!function(){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(n){n.addCommand("InsertHorizontalRule",function(){n.execCommand("mceInsertContent",!1,"<hr />")})},o=function(n){n.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),n.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})};n.add("hr",function(n){t(n),o(n)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "image" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/image')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/image'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "imagetools" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/imagetools')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/imagetools'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "importcss" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/importcss')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/importcss'
|
||||
require('./plugin.js');
|
||||
@@ -1,195 +1,264 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var importcss = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('importcss', function(editor) {
|
||||
var self = this, each = tinymce.each;
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
function compileFilter(filter) {
|
||||
if (typeof filter == "string") {
|
||||
return function(value) {
|
||||
return value.indexOf(filter) !== -1;
|
||||
};
|
||||
} else if (filter instanceof RegExp) {
|
||||
return function(value) {
|
||||
return filter.test(value);
|
||||
};
|
||||
}
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
||||
|
||||
return filter;
|
||||
}
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
function getSelectors(doc, fileFilter) {
|
||||
var selectors = [], contentCSSUrls = {};
|
||||
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
function append(styleSheet, imported) {
|
||||
var href = styleSheet.href, rules;
|
||||
var shouldMergeClasses = function (editor) {
|
||||
return editor.getParam('importcss_merge_classes');
|
||||
};
|
||||
var shouldImportExclusive = function (editor) {
|
||||
return editor.getParam('importcss_exclusive');
|
||||
};
|
||||
var getSelectorConverter = function (editor) {
|
||||
return editor.getParam('importcss_selector_converter');
|
||||
};
|
||||
var getSelectorFilter = function (editor) {
|
||||
return editor.getParam('importcss_selector_filter');
|
||||
};
|
||||
var getCssGroups = function (editor) {
|
||||
return editor.getParam('importcss_groups');
|
||||
};
|
||||
var shouldAppend = function (editor) {
|
||||
return editor.getParam('importcss_append');
|
||||
};
|
||||
var getFileFilter = function (editor) {
|
||||
return editor.getParam('importcss_file_filter');
|
||||
};
|
||||
var $_2w9p4lerjh8lpv3v = {
|
||||
shouldMergeClasses: shouldMergeClasses,
|
||||
shouldImportExclusive: shouldImportExclusive,
|
||||
getSelectorConverter: getSelectorConverter,
|
||||
getSelectorFilter: getSelectorFilter,
|
||||
getCssGroups: getCssGroups,
|
||||
shouldAppend: shouldAppend,
|
||||
getFileFilter: getFileFilter
|
||||
};
|
||||
|
||||
if (!href || !fileFilter(href, imported)) {
|
||||
return;
|
||||
}
|
||||
var removeCacheSuffix = function (url) {
|
||||
var cacheSuffix = global$3.cacheSuffix;
|
||||
if (typeof url === 'string') {
|
||||
url = url.replace('?' + cacheSuffix, '').replace('&' + cacheSuffix, '');
|
||||
}
|
||||
return url;
|
||||
};
|
||||
var isSkinContentCss = function (editor, href) {
|
||||
var settings = editor.settings, skin = settings.skin !== false ? settings.skin || 'lightgray' : false;
|
||||
if (skin) {
|
||||
var skinUrl = settings.skin_url ? editor.documentBaseURI.toAbsolute(settings.skin_url) : global$2.baseURL + '/skins/' + skin;
|
||||
return href === skinUrl + '/content' + (editor.inline ? '.inline' : '') + '.min.css';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
var compileFilter = function (filter) {
|
||||
if (typeof filter === 'string') {
|
||||
return function (value) {
|
||||
return value.indexOf(filter) !== -1;
|
||||
};
|
||||
} else if (filter instanceof RegExp) {
|
||||
return function (value) {
|
||||
return filter.test(value);
|
||||
};
|
||||
}
|
||||
return filter;
|
||||
};
|
||||
var getSelectors = function (editor, doc, fileFilter) {
|
||||
var selectors = [], contentCSSUrls = {};
|
||||
function append(styleSheet, imported) {
|
||||
var href = styleSheet.href, rules;
|
||||
href = removeCacheSuffix(href);
|
||||
if (!href || !fileFilter(href, imported) || isSkinContentCss(editor, href)) {
|
||||
return;
|
||||
}
|
||||
global$4.each(styleSheet.imports, function (styleSheet) {
|
||||
append(styleSheet, true);
|
||||
});
|
||||
try {
|
||||
rules = styleSheet.cssRules || styleSheet.rules;
|
||||
} catch (e) {
|
||||
}
|
||||
global$4.each(rules, function (cssRule) {
|
||||
if (cssRule.styleSheet) {
|
||||
append(cssRule.styleSheet, true);
|
||||
} else if (cssRule.selectorText) {
|
||||
global$4.each(cssRule.selectorText.split(','), function (selector) {
|
||||
selectors.push(global$4.trim(selector));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
global$4.each(editor.contentCSS, function (url) {
|
||||
contentCSSUrls[url] = true;
|
||||
});
|
||||
if (!fileFilter) {
|
||||
fileFilter = function (href, imported) {
|
||||
return imported || contentCSSUrls[href];
|
||||
};
|
||||
}
|
||||
try {
|
||||
global$4.each(doc.styleSheets, function (styleSheet) {
|
||||
append(styleSheet);
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
return selectors;
|
||||
};
|
||||
var defaultConvertSelectorToFormat = function (editor, selectorText) {
|
||||
var format;
|
||||
var selector = /^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(selectorText);
|
||||
if (!selector) {
|
||||
return;
|
||||
}
|
||||
var elementName = selector[1];
|
||||
var classes = selector[2].substr(1).split('.').join(' ');
|
||||
var inlineSelectorElements = global$4.makeMap('a,img');
|
||||
if (selector[1]) {
|
||||
format = { title: selectorText };
|
||||
if (editor.schema.getTextBlockElements()[elementName]) {
|
||||
format.block = elementName;
|
||||
} else if (editor.schema.getBlockElements()[elementName] || inlineSelectorElements[elementName.toLowerCase()]) {
|
||||
format.selector = elementName;
|
||||
} else {
|
||||
format.inline = elementName;
|
||||
}
|
||||
} else if (selector[2]) {
|
||||
format = {
|
||||
inline: 'span',
|
||||
title: selectorText.substr(1),
|
||||
classes: classes
|
||||
};
|
||||
}
|
||||
if ($_2w9p4lerjh8lpv3v.shouldMergeClasses(editor) !== false) {
|
||||
format.classes = classes;
|
||||
} else {
|
||||
format.attributes = { class: classes };
|
||||
}
|
||||
return format;
|
||||
};
|
||||
var getGroupsBySelector = function (groups, selector) {
|
||||
return global$4.grep(groups, function (group) {
|
||||
return !group.filter || group.filter(selector);
|
||||
});
|
||||
};
|
||||
var compileUserDefinedGroups = function (groups) {
|
||||
return global$4.map(groups, function (group) {
|
||||
return global$4.extend({}, group, {
|
||||
original: group,
|
||||
selectors: {},
|
||||
filter: compileFilter(group.filter),
|
||||
item: {
|
||||
text: group.title,
|
||||
menu: []
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
var isExclusiveMode = function (editor, group) {
|
||||
return group === null || $_2w9p4lerjh8lpv3v.shouldImportExclusive(editor) !== false;
|
||||
};
|
||||
var isUniqueSelector = function (editor, selector, group, globallyUniqueSelectors) {
|
||||
return !(isExclusiveMode(editor, group) ? selector in globallyUniqueSelectors : selector in group.selectors);
|
||||
};
|
||||
var markUniqueSelector = function (editor, selector, group, globallyUniqueSelectors) {
|
||||
if (isExclusiveMode(editor, group)) {
|
||||
globallyUniqueSelectors[selector] = true;
|
||||
} else {
|
||||
group.selectors[selector] = true;
|
||||
}
|
||||
};
|
||||
var convertSelectorToFormat = function (editor, plugin, selector, group) {
|
||||
var selectorConverter;
|
||||
if (group && group.selector_converter) {
|
||||
selectorConverter = group.selector_converter;
|
||||
} else if ($_2w9p4lerjh8lpv3v.getSelectorConverter(editor)) {
|
||||
selectorConverter = $_2w9p4lerjh8lpv3v.getSelectorConverter(editor);
|
||||
} else {
|
||||
selectorConverter = function () {
|
||||
return defaultConvertSelectorToFormat(editor, selector);
|
||||
};
|
||||
}
|
||||
return selectorConverter.call(plugin, selector, group);
|
||||
};
|
||||
var setup = function (editor) {
|
||||
editor.on('renderFormatsMenu', function (e) {
|
||||
var globallyUniqueSelectors = {};
|
||||
var selectorFilter = compileFilter($_2w9p4lerjh8lpv3v.getSelectorFilter(editor)), ctrl = e.control;
|
||||
var groups = compileUserDefinedGroups($_2w9p4lerjh8lpv3v.getCssGroups(editor));
|
||||
var processSelector = function (selector, group) {
|
||||
if (isUniqueSelector(editor, selector, group, globallyUniqueSelectors)) {
|
||||
markUniqueSelector(editor, selector, group, globallyUniqueSelectors);
|
||||
var format = convertSelectorToFormat(editor, editor.plugins.importcss, selector, group);
|
||||
if (format) {
|
||||
var formatName = format.name || global$1.DOM.uniqueId();
|
||||
editor.formatter.register(formatName, format);
|
||||
return global$4.extend({}, ctrl.settings.itemDefaults, {
|
||||
text: format.title,
|
||||
format: formatName
|
||||
});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
if (!$_2w9p4lerjh8lpv3v.shouldAppend(editor)) {
|
||||
ctrl.items().remove();
|
||||
}
|
||||
global$4.each(getSelectors(editor, e.doc || editor.getDoc(), compileFilter($_2w9p4lerjh8lpv3v.getFileFilter(editor))), function (selector) {
|
||||
if (selector.indexOf('.mce-') === -1) {
|
||||
if (!selectorFilter || selectorFilter(selector)) {
|
||||
var selectorGroups = getGroupsBySelector(groups, selector);
|
||||
if (selectorGroups.length > 0) {
|
||||
global$4.each(selectorGroups, function (group) {
|
||||
var menuItem = processSelector(selector, group);
|
||||
if (menuItem) {
|
||||
group.item.menu.push(menuItem);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var menuItem = processSelector(selector, null);
|
||||
if (menuItem) {
|
||||
ctrl.add(menuItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
global$4.each(groups, function (group) {
|
||||
if (group.item.menu.length > 0) {
|
||||
ctrl.add(group.item);
|
||||
}
|
||||
});
|
||||
e.control.renderNew();
|
||||
});
|
||||
};
|
||||
var $_9ayvw4emjh8lpv3q = {
|
||||
defaultConvertSelectorToFormat: defaultConvertSelectorToFormat,
|
||||
setup: setup
|
||||
};
|
||||
|
||||
each(styleSheet.imports, function(styleSheet) {
|
||||
append(styleSheet, true);
|
||||
});
|
||||
var get = function (editor) {
|
||||
var convertSelectorToFormat = function (selectorText) {
|
||||
return $_9ayvw4emjh8lpv3q.defaultConvertSelectorToFormat(editor, selectorText);
|
||||
};
|
||||
return { convertSelectorToFormat: convertSelectorToFormat };
|
||||
};
|
||||
var $_5soyhmeljh8lpv3o = { get: get };
|
||||
|
||||
try {
|
||||
rules = styleSheet.cssRules || styleSheet.rules;
|
||||
} catch (e) {
|
||||
// Firefox fails on rules to remote domain for example:
|
||||
// @import url(//fonts.googleapis.com/css?family=Pathway+Gothic+One);
|
||||
}
|
||||
global.add('importcss', function (editor) {
|
||||
$_9ayvw4emjh8lpv3q.setup(editor);
|
||||
return $_5soyhmeljh8lpv3o.get(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
each(rules, function(cssRule) {
|
||||
if (cssRule.styleSheet) {
|
||||
append(cssRule.styleSheet, true);
|
||||
} else if (cssRule.selectorText) {
|
||||
each(cssRule.selectorText.split(','), function(selector) {
|
||||
selectors.push(tinymce.trim(selector));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return Plugin;
|
||||
|
||||
each(editor.contentCSS, function(url) {
|
||||
contentCSSUrls[url] = true;
|
||||
});
|
||||
|
||||
if (!fileFilter) {
|
||||
fileFilter = function(href, imported) {
|
||||
return imported || contentCSSUrls[href];
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
each(doc.styleSheets, function(styleSheet) {
|
||||
append(styleSheet);
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
return selectors;
|
||||
}
|
||||
|
||||
function convertSelectorToFormat(selectorText) {
|
||||
var format;
|
||||
|
||||
// Parse simple element.class1, .class1
|
||||
var selector = /^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(selectorText);
|
||||
if (!selector) {
|
||||
return;
|
||||
}
|
||||
|
||||
var elementName = selector[1];
|
||||
var classes = selector[2].substr(1).split('.').join(' ');
|
||||
var inlineSelectorElements = tinymce.makeMap('a,img');
|
||||
|
||||
// element.class - Produce block formats
|
||||
if (selector[1]) {
|
||||
format = {
|
||||
title: selectorText
|
||||
};
|
||||
|
||||
if (editor.schema.getTextBlockElements()[elementName]) {
|
||||
// Text block format ex: h1.class1
|
||||
format.block = elementName;
|
||||
} else if (editor.schema.getBlockElements()[elementName] || inlineSelectorElements[elementName.toLowerCase()]) {
|
||||
// Block elements such as table.class and special inline elements such as a.class or img.class
|
||||
format.selector = elementName;
|
||||
} else {
|
||||
// Inline format strong.class1
|
||||
format.inline = elementName;
|
||||
}
|
||||
} else if (selector[2]) {
|
||||
// .class - Produce inline span with classes
|
||||
format = {
|
||||
inline: 'span',
|
||||
title: selectorText.substr(1),
|
||||
classes: classes
|
||||
};
|
||||
}
|
||||
|
||||
// Append to or override class attribute
|
||||
if (editor.settings.importcss_merge_classes !== false) {
|
||||
format.classes = classes;
|
||||
} else {
|
||||
format.attributes = {"class": classes};
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
editor.on('renderFormatsMenu', function(e) {
|
||||
var settings = editor.settings, selectors = {};
|
||||
var selectorConverter = settings.importcss_selector_converter || convertSelectorToFormat;
|
||||
var selectorFilter = compileFilter(settings.importcss_selector_filter), ctrl = e.control;
|
||||
|
||||
if (!editor.settings.importcss_append) {
|
||||
ctrl.items().remove();
|
||||
}
|
||||
|
||||
// Setup new groups collection by cloning the configured one
|
||||
var groups = [];
|
||||
tinymce.each(settings.importcss_groups, function(group) {
|
||||
group = tinymce.extend({}, group);
|
||||
group.filter = compileFilter(group.filter);
|
||||
groups.push(group);
|
||||
});
|
||||
|
||||
each(getSelectors(e.doc || editor.getDoc(), compileFilter(settings.importcss_file_filter)), function(selector) {
|
||||
if (selector.indexOf('.mce-') === -1) {
|
||||
if (!selectors[selector] && (!selectorFilter || selectorFilter(selector))) {
|
||||
var format = selectorConverter.call(self, selector), menu;
|
||||
|
||||
if (format) {
|
||||
var formatName = format.name || tinymce.DOM.uniqueId();
|
||||
|
||||
if (groups) {
|
||||
for (var i = 0; i < groups.length; i++) {
|
||||
if (!groups[i].filter || groups[i].filter(selector)) {
|
||||
if (!groups[i].item) {
|
||||
groups[i].item = {text: groups[i].title, menu: []};
|
||||
}
|
||||
|
||||
menu = groups[i].item.menu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor.formatter.register(formatName, format);
|
||||
|
||||
var menuItem = tinymce.extend({}, ctrl.settings.itemDefaults, {
|
||||
text: format.title,
|
||||
format: formatName
|
||||
});
|
||||
|
||||
if (menu) {
|
||||
menu.push(menuItem);
|
||||
} else {
|
||||
ctrl.add(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
selectors[selector] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
each(groups, function(group) {
|
||||
ctrl.add(group.item);
|
||||
});
|
||||
|
||||
e.control.renderNew();
|
||||
});
|
||||
|
||||
// Expose default convertSelectorToFormat implementation
|
||||
self.convertSelectorToFormat = convertSelectorToFormat;
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("importcss",function(a){function b(a){return"string"==typeof a?function(b){return-1!==b.indexOf(a)}:a instanceof RegExp?function(b){return a.test(b)}:a}function c(b,c){function d(a,b){var g,h=a.href;if(h&&c(h,b)){f(a.imports,function(a){d(a,!0)});try{g=a.cssRules||a.rules}catch(i){}f(g,function(a){a.styleSheet?d(a.styleSheet,!0):a.selectorText&&f(a.selectorText.split(","),function(a){e.push(tinymce.trim(a))})})}}var e=[],g={};f(a.contentCSS,function(a){g[a]=!0}),c||(c=function(a,b){return b||g[a]});try{f(b.styleSheets,function(a){d(a)})}catch(h){}return e}function d(b){var c,d=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(b);if(d){var e=d[1],f=d[2].substr(1).split(".").join(" "),g=tinymce.makeMap("a,img");return d[1]?(c={title:b},a.schema.getTextBlockElements()[e]?c.block=e:a.schema.getBlockElements()[e]||g[e.toLowerCase()]?c.selector=e:c.inline=e):d[2]&&(c={inline:"span",title:b.substr(1),classes:f}),a.settings.importcss_merge_classes!==!1?c.classes=f:c.attributes={"class":f},c}}var e=this,f=tinymce.each;a.on("renderFormatsMenu",function(g){var h=a.settings,i={},j=h.importcss_selector_converter||d,k=b(h.importcss_selector_filter),l=g.control;a.settings.importcss_append||l.items().remove();var m=[];tinymce.each(h.importcss_groups,function(a){a=tinymce.extend({},a),a.filter=b(a.filter),m.push(a)}),f(c(g.doc||a.getDoc(),b(h.importcss_file_filter)),function(b){if(-1===b.indexOf(".mce-")&&!i[b]&&(!k||k(b))){var c,d=j.call(e,b);if(d){var f=d.name||tinymce.DOM.uniqueId();if(m)for(var g=0;g<m.length;g++)if(!m[g].filter||m[g].filter(b)){m[g].item||(m[g].item={text:m[g].title,menu:[]}),c=m[g].item.menu;break}a.formatter.register(f,d);var h=tinymce.extend({},l.settings.itemDefaults,{text:d.title,format:f});c?c.push(h):l.add(h)}i[b]=!0}}),f(m,function(a){l.add(a.item)}),g.control.renderNew()}),e.convertSelectorToFormat=d});
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),v=tinymce.util.Tools.resolve("tinymce.EditorManager"),h=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Tools"),o=function(e){return e.getParam("importcss_merge_classes")},n=function(e){return e.getParam("importcss_exclusive")},_=function(e){return e.getParam("importcss_selector_converter")},r=function(e){return e.getParam("importcss_selector_filter")},i=function(e){return e.getParam("importcss_groups")},u=function(e){return e.getParam("importcss_append")},l=function(e){return e.getParam("importcss_file_filter")},a=function(t){return"string"==typeof t?function(e){return-1!==e.indexOf(t)}:t instanceof RegExp?function(e){return t.test(e)}:t},f=function(f,e,m){var g=[],n={};function p(e,t){var n,r,i,c=e.href;if(r=c,i=h.cacheSuffix,"string"==typeof r&&(r=r.replace("?"+i,"").replace("&"+i,"")),(c=r)&&m(c,t)&&(o=c,u=(s=f).settings,!(l=!1!==u.skin&&(u.skin||"lightgray"))||o!==(u.skin_url?s.documentBaseURI.toAbsolute(u.skin_url):v.baseURL+"/skins/"+l)+"/content"+(s.inline?".inline":"")+".min.css")){var s,o,u,l;y.each(e.imports,function(e){p(e,!0)});try{n=e.cssRules||e.rules}catch(a){}y.each(n,function(e){e.styleSheet?p(e.styleSheet,!0):e.selectorText&&y.each(e.selectorText.split(","),function(e){g.push(y.trim(e))})})}}y.each(f.contentCSS,function(e){n[e]=!0}),m||(m=function(e,t){return t||n[e]});try{y.each(e.styleSheets,function(e){p(e)})}catch(t){}return g},x=function(e,t){var n,r=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(t);if(r){var i=r[1],c=r[2].substr(1).split(".").join(" "),s=y.makeMap("a,img");return r[1]?(n={title:t},e.schema.getTextBlockElements()[i]?n.block=i:e.schema.getBlockElements()[i]||s[i.toLowerCase()]?n.selector=i:n.inline=i):r[2]&&(n={inline:"span",title:t.substr(1),classes:c}),!1!==o(e)?n.classes=c:n.attributes={"class":c},n}},T=function(e,t){return null===t||!1!==n(e)},c=x,t=function(h){h.on("renderFormatsMenu",function(e){var t,p={},c=a(r(h)),v=e.control,s=(t=i(h),y.map(t,function(e){return y.extend({},e,{original:e,selectors:{},filter:a(e.filter),item:{text:e.title,menu:[]}})})),o=function(e,t){if(f=e,g=p,!(T(h,m=t)?f in g:f in m.selectors)){u=e,a=p,T(h,l=t)?a[u]=!0:l.selectors[u]=!0;var n=(c=(i=h).plugins.importcss,s=e,((o=t)&&o.selector_converter?o.selector_converter:_(i)?_(i):function(){return x(i,s)}).call(c,s,o));if(n){var r=n.name||d.DOM.uniqueId();return h.formatter.register(r,n),y.extend({},v.settings.itemDefaults,{text:n.title,format:r})}}var i,c,s,o,u,l,a,f,m,g;return null};u(h)||v.items().remove(),y.each(f(h,e.doc||h.getDoc(),a(l(h))),function(n){if(-1===n.indexOf(".mce-")&&(!c||c(n))){var e=(r=s,i=n,y.grep(r,function(e){return!e.filter||e.filter(i)}));if(0<e.length)y.each(e,function(e){var t=o(n,e);t&&e.item.menu.push(t)});else{var t=o(n,null);t&&v.add(t)}}var r,i}),y.each(s,function(e){0<e.item.menu.length&&v.add(e.item)}),e.control.renderNew()})},s=function(t){return{convertSelectorToFormat:function(e){return c(t,e)}}};e.add("importcss",function(e){return t(e),s(e)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "insertdatetime" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/insertdatetime')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/insertdatetime'
|
||||
require('./plugin.js');
|
||||
@@ -1,121 +1,173 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var insertdatetime = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
tinymce.PluginManager.add('insertdatetime', function(editor) {
|
||||
var daysShort = "Sun Mon Tue Wed Thu Fri Sat Sun".split(' ');
|
||||
var daysLong = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(' ');
|
||||
var monthsShort = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(' ');
|
||||
var monthsLong = "January February March April May June July August September October November December".split(' ');
|
||||
var menuItems = [], lastFormat, defaultButtonTimeFormat;
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
function getDateTime(fmt, date) {
|
||||
function addZeros(value, len) {
|
||||
value = "" + value;
|
||||
var getDateFormat = function (editor) {
|
||||
return editor.getParam('insertdatetime_dateformat', editor.translate('%Y-%m-%d'));
|
||||
};
|
||||
var getTimeFormat = function (editor) {
|
||||
return editor.getParam('insertdatetime_timeformat', editor.translate('%H:%M:%S'));
|
||||
};
|
||||
var getFormats = function (editor) {
|
||||
return editor.getParam('insertdatetime_formats', [
|
||||
'%H:%M:%S',
|
||||
'%Y-%m-%d',
|
||||
'%I:%M:%S %p',
|
||||
'%D'
|
||||
]);
|
||||
};
|
||||
var getDefaultDateTime = function (editor) {
|
||||
var formats = getFormats(editor);
|
||||
return formats.length > 0 ? formats[0] : getTimeFormat(editor);
|
||||
};
|
||||
var shouldInsertTimeElement = function (editor) {
|
||||
return editor.getParam('insertdatetime_element', false);
|
||||
};
|
||||
var $_7ti1jkewjh8lpv4i = {
|
||||
getDateFormat: getDateFormat,
|
||||
getTimeFormat: getTimeFormat,
|
||||
getFormats: getFormats,
|
||||
getDefaultDateTime: getDefaultDateTime,
|
||||
shouldInsertTimeElement: shouldInsertTimeElement
|
||||
};
|
||||
|
||||
if (value.length < len) {
|
||||
for (var i = 0; i < (len - value.length); i++) {
|
||||
value = "0" + value;
|
||||
}
|
||||
}
|
||||
var daysShort = 'Sun Mon Tue Wed Thu Fri Sat Sun'.split(' ');
|
||||
var daysLong = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday'.split(' ');
|
||||
var monthsShort = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
|
||||
var monthsLong = 'January February March April May June July August September October November December'.split(' ');
|
||||
var addZeros = function (value, len) {
|
||||
value = '' + value;
|
||||
if (value.length < len) {
|
||||
for (var i = 0; i < len - value.length; i++) {
|
||||
value = '0' + value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
};
|
||||
var getDateTime = function (editor, fmt, date) {
|
||||
date = date || new Date();
|
||||
fmt = fmt.replace('%D', '%m/%d/%Y');
|
||||
fmt = fmt.replace('%r', '%I:%M:%S %p');
|
||||
fmt = fmt.replace('%Y', '' + date.getFullYear());
|
||||
fmt = fmt.replace('%y', '' + date.getYear());
|
||||
fmt = fmt.replace('%m', addZeros(date.getMonth() + 1, 2));
|
||||
fmt = fmt.replace('%d', addZeros(date.getDate(), 2));
|
||||
fmt = fmt.replace('%H', '' + addZeros(date.getHours(), 2));
|
||||
fmt = fmt.replace('%M', '' + addZeros(date.getMinutes(), 2));
|
||||
fmt = fmt.replace('%S', '' + addZeros(date.getSeconds(), 2));
|
||||
fmt = fmt.replace('%I', '' + ((date.getHours() + 11) % 12 + 1));
|
||||
fmt = fmt.replace('%p', '' + (date.getHours() < 12 ? 'AM' : 'PM'));
|
||||
fmt = fmt.replace('%B', '' + editor.translate(monthsLong[date.getMonth()]));
|
||||
fmt = fmt.replace('%b', '' + editor.translate(monthsShort[date.getMonth()]));
|
||||
fmt = fmt.replace('%A', '' + editor.translate(daysLong[date.getDay()]));
|
||||
fmt = fmt.replace('%a', '' + editor.translate(daysShort[date.getDay()]));
|
||||
fmt = fmt.replace('%%', '%');
|
||||
return fmt;
|
||||
};
|
||||
var updateElement = function (editor, timeElm, computerTime, userTime) {
|
||||
var newTimeElm = editor.dom.create('time', { datetime: computerTime }, userTime);
|
||||
timeElm.parentNode.insertBefore(newTimeElm, timeElm);
|
||||
editor.dom.remove(timeElm);
|
||||
editor.selection.select(newTimeElm, true);
|
||||
editor.selection.collapse(false);
|
||||
};
|
||||
var insertDateTime = function (editor, format) {
|
||||
if ($_7ti1jkewjh8lpv4i.shouldInsertTimeElement(editor)) {
|
||||
var userTime = getDateTime(editor, format);
|
||||
var computerTime = void 0;
|
||||
if (/%[HMSIp]/.test(format)) {
|
||||
computerTime = getDateTime(editor, '%Y-%m-%dT%H:%M');
|
||||
} else {
|
||||
computerTime = getDateTime(editor, '%Y-%m-%d');
|
||||
}
|
||||
var timeElm = editor.dom.getParent(editor.selection.getStart(), 'time');
|
||||
if (timeElm) {
|
||||
updateElement(editor, timeElm, computerTime, userTime);
|
||||
} else {
|
||||
editor.insertContent('<time datetime="' + computerTime + '">' + userTime + '</time>');
|
||||
}
|
||||
} else {
|
||||
editor.insertContent(getDateTime(editor, format));
|
||||
}
|
||||
};
|
||||
var $_f8xhysexjh8lpv4k = {
|
||||
insertDateTime: insertDateTime,
|
||||
getDateTime: getDateTime
|
||||
};
|
||||
|
||||
return value;
|
||||
}
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceInsertDate', function () {
|
||||
$_f8xhysexjh8lpv4k.insertDateTime(editor, $_7ti1jkewjh8lpv4i.getDateFormat(editor));
|
||||
});
|
||||
editor.addCommand('mceInsertTime', function () {
|
||||
$_f8xhysexjh8lpv4k.insertDateTime(editor, $_7ti1jkewjh8lpv4i.getTimeFormat(editor));
|
||||
});
|
||||
};
|
||||
var $_3klk7oevjh8lpv4h = { register: register };
|
||||
|
||||
date = date || new Date();
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
fmt = fmt.replace("%D", "%m/%d/%Y");
|
||||
fmt = fmt.replace("%r", "%I:%M:%S %p");
|
||||
fmt = fmt.replace("%Y", "" + date.getFullYear());
|
||||
fmt = fmt.replace("%y", "" + date.getYear());
|
||||
fmt = fmt.replace("%m", addZeros(date.getMonth() + 1, 2));
|
||||
fmt = fmt.replace("%d", addZeros(date.getDate(), 2));
|
||||
fmt = fmt.replace("%H", "" + addZeros(date.getHours(), 2));
|
||||
fmt = fmt.replace("%M", "" + addZeros(date.getMinutes(), 2));
|
||||
fmt = fmt.replace("%S", "" + addZeros(date.getSeconds(), 2));
|
||||
fmt = fmt.replace("%I", "" + ((date.getHours() + 11) % 12 + 1));
|
||||
fmt = fmt.replace("%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
|
||||
fmt = fmt.replace("%B", "" + editor.translate(monthsLong[date.getMonth()]));
|
||||
fmt = fmt.replace("%b", "" + editor.translate(monthsShort[date.getMonth()]));
|
||||
fmt = fmt.replace("%A", "" + editor.translate(daysLong[date.getDay()]));
|
||||
fmt = fmt.replace("%a", "" + editor.translate(daysShort[date.getDay()]));
|
||||
fmt = fmt.replace("%%", "%");
|
||||
var createMenuItems = function (editor, lastFormatState) {
|
||||
var formats = $_7ti1jkewjh8lpv4i.getFormats(editor);
|
||||
return global$1.map(formats, function (fmt) {
|
||||
return {
|
||||
text: $_f8xhysexjh8lpv4k.getDateTime(editor, fmt),
|
||||
onclick: function () {
|
||||
lastFormatState.set(fmt);
|
||||
$_f8xhysexjh8lpv4k.insertDateTime(editor, fmt);
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
var register$1 = function (editor, lastFormatState) {
|
||||
var menuItems = createMenuItems(editor, lastFormatState);
|
||||
editor.addButton('insertdatetime', {
|
||||
type: 'splitbutton',
|
||||
title: 'Insert date/time',
|
||||
menu: menuItems,
|
||||
onclick: function () {
|
||||
var lastFormat = lastFormatState.get();
|
||||
$_f8xhysexjh8lpv4k.insertDateTime(editor, lastFormat ? lastFormat : $_7ti1jkewjh8lpv4i.getDefaultDateTime(editor));
|
||||
}
|
||||
});
|
||||
editor.addMenuItem('insertdatetime', {
|
||||
icon: 'date',
|
||||
text: 'Date/time',
|
||||
menu: menuItems,
|
||||
context: 'insert'
|
||||
});
|
||||
};
|
||||
var $_7myfffeyjh8lpv4n = { register: register$1 };
|
||||
|
||||
return fmt;
|
||||
}
|
||||
global.add('insertdatetime', function (editor) {
|
||||
var lastFormatState = Cell(null);
|
||||
$_3klk7oevjh8lpv4h.register(editor);
|
||||
$_7myfffeyjh8lpv4n.register(editor, lastFormatState);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
function insertDateTime(format) {
|
||||
var html = getDateTime(format);
|
||||
return Plugin;
|
||||
|
||||
if (editor.settings.insertdatetime_element) {
|
||||
var computerTime;
|
||||
|
||||
if (/%[HMSIp]/.test(format)) {
|
||||
computerTime = getDateTime("%Y-%m-%dT%H:%M");
|
||||
} else {
|
||||
computerTime = getDateTime("%Y-%m-%d");
|
||||
}
|
||||
|
||||
html = '<time datetime="' + computerTime + '">' + html + '</time>';
|
||||
|
||||
var timeElm = editor.dom.getParent(editor.selection.getStart(), 'time');
|
||||
if (timeElm) {
|
||||
editor.dom.setOuterHTML(timeElm, html);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
editor.insertContent(html);
|
||||
}
|
||||
|
||||
editor.addCommand('mceInsertDate', function() {
|
||||
insertDateTime(editor.getParam("insertdatetime_dateformat", editor.translate("%Y-%m-%d")));
|
||||
});
|
||||
|
||||
editor.addCommand('mceInsertTime', function() {
|
||||
insertDateTime(editor.getParam("insertdatetime_timeformat", editor.translate('%H:%M:%S')));
|
||||
});
|
||||
|
||||
editor.addButton('insertdatetime', {
|
||||
type: 'splitbutton',
|
||||
title: 'Insert date/time',
|
||||
onclick: function() {
|
||||
insertDateTime(lastFormat || defaultButtonTimeFormat);
|
||||
},
|
||||
menu: menuItems
|
||||
});
|
||||
|
||||
tinymce.each(editor.settings.insertdatetime_formats || [
|
||||
"%H:%M:%S",
|
||||
"%Y-%m-%d",
|
||||
"%I:%M:%S %p",
|
||||
"%D"
|
||||
], function(fmt) {
|
||||
if (!defaultButtonTimeFormat) {
|
||||
defaultButtonTimeFormat = fmt;
|
||||
}
|
||||
|
||||
menuItems.push({
|
||||
text: getDateTime(fmt),
|
||||
onclick: function() {
|
||||
lastFormat = fmt;
|
||||
insertDateTime(fmt);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
editor.addMenuItem('insertdatetime', {
|
||||
icon: 'date',
|
||||
text: 'Insert date/time',
|
||||
menu: menuItems,
|
||||
context: 'insert'
|
||||
});
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("insertdatetime",function(a){function b(b,c){function d(a,b){if(a=""+a,a.length<b)for(var c=0;c<b-a.length;c++)a="0"+a;return a}return c=c||new Date,b=b.replace("%D","%m/%d/%Y"),b=b.replace("%r","%I:%M:%S %p"),b=b.replace("%Y",""+c.getFullYear()),b=b.replace("%y",""+c.getYear()),b=b.replace("%m",d(c.getMonth()+1,2)),b=b.replace("%d",d(c.getDate(),2)),b=b.replace("%H",""+d(c.getHours(),2)),b=b.replace("%M",""+d(c.getMinutes(),2)),b=b.replace("%S",""+d(c.getSeconds(),2)),b=b.replace("%I",""+((c.getHours()+11)%12+1)),b=b.replace("%p",""+(c.getHours()<12?"AM":"PM")),b=b.replace("%B",""+a.translate(i[c.getMonth()])),b=b.replace("%b",""+a.translate(h[c.getMonth()])),b=b.replace("%A",""+a.translate(g[c.getDay()])),b=b.replace("%a",""+a.translate(f[c.getDay()])),b=b.replace("%%","%")}function c(c){var d=b(c);if(a.settings.insertdatetime_element){var e;e=b(/%[HMSIp]/.test(c)?"%Y-%m-%dT%H:%M":"%Y-%m-%d"),d='<time datetime="'+e+'">'+d+"</time>";var f=a.dom.getParent(a.selection.getStart(),"time");if(f)return void a.dom.setOuterHTML(f,d)}a.insertContent(d)}var d,e,f="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),g="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),h="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),i="January February March April May June July August September October November December".split(" "),j=[];a.addCommand("mceInsertDate",function(){c(a.getParam("insertdatetime_dateformat",a.translate("%Y-%m-%d")))}),a.addCommand("mceInsertTime",function(){c(a.getParam("insertdatetime_timeformat",a.translate("%H:%M:%S")))}),a.addButton("insertdatetime",{type:"splitbutton",title:"Insert date/time",onclick:function(){c(d||e)},menu:j}),tinymce.each(a.settings.insertdatetime_formats||["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"],function(a){e||(e=a),j.push({text:b(a),onclick:function(){d=a,c(a)}})}),a.addMenuItem("insertdatetime",{icon:"date",text:"Insert date/time",menu:j,context:"insert"})});
|
||||
!function(){"use strict";var r=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return r(n())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=function(e){return e.getParam("insertdatetime_timeformat",e.translate("%H:%M:%S"))},a=function(e){return e.getParam("insertdatetime_formats",["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"])},t=function(e){return e.getParam("insertdatetime_dateformat",e.translate("%Y-%m-%d"))},i=n,o=a,u=function(e){var t=a(e);return 0<t.length?t[0]:n(e)},m=function(e){return e.getParam("insertdatetime_element",!1)},c="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),s="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),d="January February March April May June July August September October November December".split(" "),p=function(e,t){if((e=""+e).length<t)for(var n=0;n<t-e.length;n++)e="0"+e;return e},f=function(e,t,n){return n=n||new Date,t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("%D","%m/%d/%Y")).replace("%r","%I:%M:%S %p")).replace("%Y",""+n.getFullYear())).replace("%y",""+n.getYear())).replace("%m",p(n.getMonth()+1,2))).replace("%d",p(n.getDate(),2))).replace("%H",""+p(n.getHours(),2))).replace("%M",""+p(n.getMinutes(),2))).replace("%S",""+p(n.getSeconds(),2))).replace("%I",""+((n.getHours()+11)%12+1))).replace("%p",n.getHours()<12?"AM":"PM")).replace("%B",""+e.translate(d[n.getMonth()]))).replace("%b",""+e.translate(s[n.getMonth()]))).replace("%A",""+e.translate(l[n.getDay()]))).replace("%a",""+e.translate(c[n.getDay()]))).replace("%%","%")},g=function(e,t){if(m(e)){var n=f(e,t),r=void 0;r=/%[HMSIp]/.test(t)?f(e,"%Y-%m-%dT%H:%M"):f(e,"%Y-%m-%d");var a=e.dom.getParent(e.selection.getStart(),"time");a?(o=a,u=r,c=n,l=(i=e).dom.create("time",{datetime:u},c),o.parentNode.insertBefore(l,o),i.dom.remove(o),i.selection.select(l,!0),i.selection.collapse(!1)):e.insertContent('<time datetime="'+r+'">'+n+"</time>")}else e.insertContent(f(e,t));var i,o,u,c,l},y=f,M=function(e){e.addCommand("mceInsertDate",function(){g(e,t(e))}),e.addCommand("mceInsertTime",function(){g(e,i(e))})},v=tinymce.util.Tools.resolve("tinymce.util.Tools"),S=function(t,n){var r,a,e,i=(a=n,e=o(r=t),v.map(e,function(e){return{text:y(r,e),onclick:function(){a.set(e),g(r,e)}}}));t.addButton("insertdatetime",{type:"splitbutton",title:"Insert date/time",menu:i,onclick:function(){var e=n.get();g(t,e||u(t))}}),t.addMenuItem("insertdatetime",{icon:"date",text:"Date/time",menu:i,context:"insert"})};e.add("insertdatetime",function(e){var t=r(null);M(e),S(e,t)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "legacyoutput" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/legacyoutput')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/legacyoutput'
|
||||
require('./plugin.js');
|
||||
@@ -1,211 +1,220 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*
|
||||
* This plugin will force TinyMCE to produce deprecated legacy output such as font elements, u elements, align
|
||||
* attributes and so forth. There are a few cases where these old items might be needed for example in email applications or with Flash
|
||||
*
|
||||
* However you should NOT use this plugin if you are building some system that produces web contents such as a CMS. All these elements are
|
||||
* not apart of the newer specifications for HTML and XHTML.
|
||||
*/
|
||||
(function () {
|
||||
var legacyoutput = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
(function(tinymce) {
|
||||
// Override inline_styles setting to force TinyMCE to produce deprecated contents
|
||||
tinymce.on('AddEditor', function(e) {
|
||||
e.editor.settings.inline_styles = false;
|
||||
});
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
tinymce.PluginManager.add('legacyoutput', function(editor, url, $) {
|
||||
editor.on('init', function() {
|
||||
var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',
|
||||
fontSizes = tinymce.explode(editor.settings.font_size_style_values),
|
||||
schema = editor.schema;
|
||||
var overrideFormats = function (editor) {
|
||||
var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', fontSizes = global$1.explode(editor.settings.font_size_style_values), schema = editor.schema;
|
||||
editor.formatter.register({
|
||||
alignleft: {
|
||||
selector: alignElements,
|
||||
attributes: { align: 'left' }
|
||||
},
|
||||
aligncenter: {
|
||||
selector: alignElements,
|
||||
attributes: { align: 'center' }
|
||||
},
|
||||
alignright: {
|
||||
selector: alignElements,
|
||||
attributes: { align: 'right' }
|
||||
},
|
||||
alignjustify: {
|
||||
selector: alignElements,
|
||||
attributes: { align: 'justify' }
|
||||
},
|
||||
bold: [
|
||||
{
|
||||
inline: 'b',
|
||||
remove: 'all'
|
||||
},
|
||||
{
|
||||
inline: 'strong',
|
||||
remove: 'all'
|
||||
},
|
||||
{
|
||||
inline: 'span',
|
||||
styles: { fontWeight: 'bold' }
|
||||
}
|
||||
],
|
||||
italic: [
|
||||
{
|
||||
inline: 'i',
|
||||
remove: 'all'
|
||||
},
|
||||
{
|
||||
inline: 'em',
|
||||
remove: 'all'
|
||||
},
|
||||
{
|
||||
inline: 'span',
|
||||
styles: { fontStyle: 'italic' }
|
||||
}
|
||||
],
|
||||
underline: [
|
||||
{
|
||||
inline: 'u',
|
||||
remove: 'all'
|
||||
},
|
||||
{
|
||||
inline: 'span',
|
||||
styles: { textDecoration: 'underline' },
|
||||
exact: true
|
||||
}
|
||||
],
|
||||
strikethrough: [
|
||||
{
|
||||
inline: 'strike',
|
||||
remove: 'all'
|
||||
},
|
||||
{
|
||||
inline: 'span',
|
||||
styles: { textDecoration: 'line-through' },
|
||||
exact: true
|
||||
}
|
||||
],
|
||||
fontname: {
|
||||
inline: 'font',
|
||||
attributes: { face: '%value' }
|
||||
},
|
||||
fontsize: {
|
||||
inline: 'font',
|
||||
attributes: {
|
||||
size: function (vars) {
|
||||
return global$1.inArray(fontSizes, vars.value) + 1;
|
||||
}
|
||||
}
|
||||
},
|
||||
forecolor: {
|
||||
inline: 'font',
|
||||
attributes: { color: '%value' }
|
||||
},
|
||||
hilitecolor: {
|
||||
inline: 'font',
|
||||
styles: { backgroundColor: '%value' }
|
||||
}
|
||||
});
|
||||
global$1.each('b,i,u,strike'.split(','), function (name) {
|
||||
schema.addValidElements(name + '[*]');
|
||||
});
|
||||
if (!schema.getElementRule('font')) {
|
||||
schema.addValidElements('font[face|size|color|style]');
|
||||
}
|
||||
global$1.each(alignElements.split(','), function (name) {
|
||||
var rule = schema.getElementRule(name);
|
||||
if (rule) {
|
||||
if (!rule.attributes.align) {
|
||||
rule.attributes.align = {};
|
||||
rule.attributesOrder.push('align');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
var setup = function (editor) {
|
||||
editor.settings.inline_styles = false;
|
||||
editor.on('init', function () {
|
||||
overrideFormats(editor);
|
||||
});
|
||||
};
|
||||
var $_bw3ugif2jh8lpv52 = { setup: setup };
|
||||
|
||||
// Override some internal formats to produce legacy elements and attributes
|
||||
editor.formatter.register({
|
||||
// Change alignment formats to use the deprecated align attribute
|
||||
alignleft: {selector: alignElements, attributes: {align: 'left'}},
|
||||
aligncenter: {selector: alignElements, attributes: {align: 'center'}},
|
||||
alignright: {selector: alignElements, attributes: {align: 'right'}},
|
||||
alignjustify: {selector: alignElements, attributes: {align: 'justify'}},
|
||||
var register = function (editor) {
|
||||
editor.addButton('fontsizeselect', function () {
|
||||
var items = [], defaultFontsizeFormats = '8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7';
|
||||
var fontsizeFormats = editor.settings.fontsizeFormats || defaultFontsizeFormats;
|
||||
editor.$.each(fontsizeFormats.split(' '), function (i, item) {
|
||||
var text = item, value = item;
|
||||
var values = item.split('=');
|
||||
if (values.length > 1) {
|
||||
text = values[0];
|
||||
value = values[1];
|
||||
}
|
||||
items.push({
|
||||
text: text,
|
||||
value: value
|
||||
});
|
||||
});
|
||||
return {
|
||||
type: 'listbox',
|
||||
text: 'Font Sizes',
|
||||
tooltip: 'Font Sizes',
|
||||
values: items,
|
||||
fixedWidth: true,
|
||||
onPostRender: function () {
|
||||
var self = this;
|
||||
editor.on('NodeChange', function () {
|
||||
var fontElm;
|
||||
fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');
|
||||
if (fontElm) {
|
||||
self.value(fontElm.size);
|
||||
} else {
|
||||
self.value('');
|
||||
}
|
||||
});
|
||||
},
|
||||
onclick: function (e) {
|
||||
if (e.control.settings.value) {
|
||||
editor.execCommand('FontSize', false, e.control.settings.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
editor.addButton('fontselect', function () {
|
||||
function createFormats(formats) {
|
||||
formats = formats.replace(/;$/, '').split(';');
|
||||
var i = formats.length;
|
||||
while (i--) {
|
||||
formats[i] = formats[i].split('=');
|
||||
}
|
||||
return formats;
|
||||
}
|
||||
var defaultFontsFormats = 'Andale Mono=andale mono,monospace;' + 'Arial=arial,helvetica,sans-serif;' + 'Arial Black=arial black,sans-serif;' + 'Book Antiqua=book antiqua,palatino,serif;' + 'Comic Sans MS=comic sans ms,sans-serif;' + 'Courier New=courier new,courier,monospace;' + 'Georgia=georgia,palatino,serif;' + 'Helvetica=helvetica,arial,sans-serif;' + 'Impact=impact,sans-serif;' + 'Symbol=symbol;' + 'Tahoma=tahoma,arial,helvetica,sans-serif;' + 'Terminal=terminal,monaco,monospace;' + 'Times New Roman=times new roman,times,serif;' + 'Trebuchet MS=trebuchet ms,geneva,sans-serif;' + 'Verdana=verdana,geneva,sans-serif;' + 'Webdings=webdings;' + 'Wingdings=wingdings,zapf dingbats';
|
||||
var items = [], fonts = createFormats(editor.settings.font_formats || defaultFontsFormats);
|
||||
editor.$.each(fonts, function (i, font) {
|
||||
items.push({
|
||||
text: { raw: font[0] },
|
||||
value: font[1],
|
||||
textStyle: font[1].indexOf('dings') === -1 ? 'font-family:' + font[1] : ''
|
||||
});
|
||||
});
|
||||
return {
|
||||
type: 'listbox',
|
||||
text: 'Font Family',
|
||||
tooltip: 'Font Family',
|
||||
values: items,
|
||||
fixedWidth: true,
|
||||
onPostRender: function () {
|
||||
var self = this;
|
||||
editor.on('NodeChange', function () {
|
||||
var fontElm;
|
||||
fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');
|
||||
if (fontElm) {
|
||||
self.value(fontElm.face);
|
||||
} else {
|
||||
self.value('');
|
||||
}
|
||||
});
|
||||
},
|
||||
onselect: function (e) {
|
||||
if (e.control.settings.value) {
|
||||
editor.execCommand('FontName', false, e.control.settings.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
var $_bogc51f4jh8lpv56 = { register: register };
|
||||
|
||||
// Change the basic formatting elements to use deprecated element types
|
||||
bold: [
|
||||
{inline: 'b', remove: 'all'},
|
||||
{inline: 'strong', remove: 'all'},
|
||||
{inline: 'span', styles: {fontWeight: 'bold'}}
|
||||
],
|
||||
italic: [
|
||||
{inline: 'i', remove: 'all'},
|
||||
{inline: 'em', remove: 'all'},
|
||||
{inline: 'span', styles: {fontStyle: 'italic'}}
|
||||
],
|
||||
underline: [
|
||||
{inline: 'u', remove: 'all'},
|
||||
{inline: 'span', styles: {textDecoration: 'underline'}, exact: true}
|
||||
],
|
||||
strikethrough: [
|
||||
{inline: 'strike', remove: 'all'},
|
||||
{inline: 'span', styles: {textDecoration: 'line-through'}, exact: true}
|
||||
],
|
||||
global.add('legacyoutput', function (editor) {
|
||||
$_bw3ugif2jh8lpv52.setup(editor);
|
||||
$_bogc51f4jh8lpv56.register(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
// Change font size and font family to use the deprecated font element
|
||||
fontname: {inline: 'font', attributes: {face: '%value'}},
|
||||
fontsize: {
|
||||
inline: 'font',
|
||||
attributes: {
|
||||
size: function(vars) {
|
||||
return tinymce.inArray(fontSizes, vars.value) + 1;
|
||||
}
|
||||
}
|
||||
},
|
||||
return Plugin;
|
||||
|
||||
// Setup font elements for colors as well
|
||||
forecolor: {inline: 'font', attributes: {color: '%value'}},
|
||||
hilitecolor: {inline: 'font', styles: {backgroundColor: '%value'}}
|
||||
});
|
||||
|
||||
// Check that deprecated elements are allowed if not add them
|
||||
tinymce.each('b,i,u,strike'.split(','), function(name) {
|
||||
schema.addValidElements(name + '[*]');
|
||||
});
|
||||
|
||||
// Add font element if it's missing
|
||||
if (!schema.getElementRule("font")) {
|
||||
schema.addValidElements("font[face|size|color|style]");
|
||||
}
|
||||
|
||||
// Add the missing and depreacted align attribute for the serialization engine
|
||||
tinymce.each(alignElements.split(','), function(name) {
|
||||
var rule = schema.getElementRule(name);
|
||||
|
||||
if (rule) {
|
||||
if (!rule.attributes.align) {
|
||||
rule.attributes.align = {};
|
||||
rule.attributesOrder.push('align');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
editor.addButton('fontsizeselect', function() {
|
||||
var items = [], defaultFontsizeFormats = '8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7';
|
||||
var fontsize_formats = editor.settings.fontsize_formats || defaultFontsizeFormats;
|
||||
|
||||
editor.$.each(fontsize_formats.split(' '), function(i, item) {
|
||||
var text = item, value = item;
|
||||
var values = item.split('=');
|
||||
|
||||
if (values.length > 1) {
|
||||
text = values[0];
|
||||
value = values[1];
|
||||
}
|
||||
|
||||
items.push({text: text, value: value});
|
||||
});
|
||||
|
||||
return {
|
||||
type: 'listbox',
|
||||
text: 'Font Sizes',
|
||||
tooltip: 'Font Sizes',
|
||||
values: items,
|
||||
fixedWidth: true,
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on('NodeChange', function() {
|
||||
var fontElm;
|
||||
|
||||
fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');
|
||||
if (fontElm) {
|
||||
self.value(fontElm.size);
|
||||
} else {
|
||||
self.value('');
|
||||
}
|
||||
});
|
||||
},
|
||||
onclick: function(e) {
|
||||
if (e.control.settings.value) {
|
||||
editor.execCommand('FontSize', false, e.control.settings.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
editor.addButton('fontselect', function() {
|
||||
function createFormats(formats) {
|
||||
formats = formats.replace(/;$/, '').split(';');
|
||||
|
||||
var i = formats.length;
|
||||
while (i--) {
|
||||
formats[i] = formats[i].split('=');
|
||||
}
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
||||
var defaultFontsFormats =
|
||||
'Andale Mono=andale mono,monospace;' +
|
||||
'Arial=arial,helvetica,sans-serif;' +
|
||||
'Arial Black=arial black,sans-serif;' +
|
||||
'Book Antiqua=book antiqua,palatino,serif;' +
|
||||
'Comic Sans MS=comic sans ms,sans-serif;' +
|
||||
'Courier New=courier new,courier,monospace;' +
|
||||
'Georgia=georgia,palatino,serif;' +
|
||||
'Helvetica=helvetica,arial,sans-serif;' +
|
||||
'Impact=impact,sans-serif;' +
|
||||
'Symbol=symbol;' +
|
||||
'Tahoma=tahoma,arial,helvetica,sans-serif;' +
|
||||
'Terminal=terminal,monaco,monospace;' +
|
||||
'Times New Roman=times new roman,times,serif;' +
|
||||
'Trebuchet MS=trebuchet ms,geneva,sans-serif;' +
|
||||
'Verdana=verdana,geneva,sans-serif;' +
|
||||
'Webdings=webdings;' +
|
||||
'Wingdings=wingdings,zapf dingbats';
|
||||
|
||||
var items = [], fonts = createFormats(editor.settings.font_formats || defaultFontsFormats);
|
||||
|
||||
$.each(fonts, function(i, font) {
|
||||
items.push({
|
||||
text: {raw: font[0]},
|
||||
value: font[1],
|
||||
textStyle: font[1].indexOf('dings') == -1 ? 'font-family:' + font[1] : ''
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
type: 'listbox',
|
||||
text: 'Font Family',
|
||||
tooltip: 'Font Family',
|
||||
values: items,
|
||||
fixedWidth: true,
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on('NodeChange', function() {
|
||||
var fontElm;
|
||||
|
||||
fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');
|
||||
if (fontElm) {
|
||||
self.value(fontElm.face);
|
||||
} else {
|
||||
self.value('');
|
||||
}
|
||||
});
|
||||
},
|
||||
onselect: function(e) {
|
||||
if (e.control.settings.value) {
|
||||
editor.execCommand('FontName', false, e.control.settings.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
})(tinymce);
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(a){a.on("AddEditor",function(a){a.editor.settings.inline_styles=!1}),a.PluginManager.add("legacyoutput",function(b,c,d){b.on("init",function(){var c="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",d=a.explode(b.settings.font_size_style_values),e=b.schema;b.formatter.register({alignleft:{selector:c,attributes:{align:"left"}},aligncenter:{selector:c,attributes:{align:"center"}},alignright:{selector:c,attributes:{align:"right"}},alignjustify:{selector:c,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all"},{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all"},{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all"},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all"},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",attributes:{face:"%value"}},fontsize:{inline:"font",attributes:{size:function(b){return a.inArray(d,b.value)+1}}},forecolor:{inline:"font",attributes:{color:"%value"}},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"}}}),a.each("b,i,u,strike".split(","),function(a){e.addValidElements(a+"[*]")}),e.getElementRule("font")||e.addValidElements("font[face|size|color|style]"),a.each(c.split(","),function(a){var b=e.getElementRule(a);b&&(b.attributes.align||(b.attributes.align={},b.attributesOrder.push("align")))})}),b.addButton("fontsizeselect",function(){var a=[],c="8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7",d=b.settings.fontsize_formats||c;return b.$.each(d.split(" "),function(b,c){var d=c,e=c,f=c.split("=");f.length>1&&(d=f[0],e=f[1]),a.push({text:d,value:e})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:a,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),a.value(c?c.size:"")})},onclick:function(a){a.control.settings.value&&b.execCommand("FontSize",!1,a.control.settings.value)}}}),b.addButton("fontselect",function(){function a(a){a=a.replace(/;$/,"").split(";");for(var b=a.length;b--;)a[b]=a[b].split("=");return a}var c="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",e=[],f=a(b.settings.font_formats||c);return d.each(f,function(a,b){e.push({text:{raw:b[0]},value:b[1],textStyle:-1==b[1].indexOf("dings")?"font-family:"+b[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:e,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),a.value(c?c.face:"")})},onselect:function(a){a.control.settings.value&&b.execCommand("FontName",!1,a.control.settings.value)}}})})}(tinymce);
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),o=tinymce.util.Tools.resolve("tinymce.util.Tools"),t=function(a){a.settings.inline_styles=!1,a.on("init",function(){var e,t,n,i;e=a,t="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",n=o.explode(e.settings.font_size_style_values),i=e.schema,e.formatter.register({alignleft:{selector:t,attributes:{align:"left"}},aligncenter:{selector:t,attributes:{align:"center"}},alignright:{selector:t,attributes:{align:"right"}},alignjustify:{selector:t,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all"},{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all"},{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all"},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all"},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",attributes:{face:"%value"}},fontsize:{inline:"font",attributes:{size:function(e){return o.inArray(n,e.value)+1}}},forecolor:{inline:"font",attributes:{color:"%value"}},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"}}}),o.each("b,i,u,strike".split(","),function(e){i.addValidElements(e+"[*]")}),i.getElementRule("font")||i.addValidElements("font[face|size|color|style]"),o.each(t.split(","),function(e){var t=i.getElementRule(e);t&&(t.attributes.align||(t.attributes.align={},t.attributesOrder.push("align")))})})},n=function(i){i.addButton("fontsizeselect",function(){var o=[],e=i.settings.fontsizeFormats||"8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7";return i.$.each(e.split(" "),function(e,t){var n=t,i=t,a=t.split("=");1<a.length&&(n=a[0],i=a[1]),o.push({text:n,value:i})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:o,fixedWidth:!0,onPostRender:function(){var t=this;i.on("NodeChange",function(){var e;(e=i.dom.getParent(i.selection.getNode(),"font"))?t.value(e.size):t.value("")})},onclick:function(e){e.control.settings.value&&i.execCommand("FontSize",!1,e.control.settings.value)}}}),i.addButton("fontselect",function(){var n=[],e=function(e){for(var t=(e=e.replace(/;$/,"").split(";")).length;t--;)e[t]=e[t].split("=");return e}(i.settings.font_formats||"Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats");return i.$.each(e,function(e,t){n.push({text:{raw:t[0]},value:t[1],textStyle:-1===t[1].indexOf("dings")?"font-family:"+t[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:n,fixedWidth:!0,onPostRender:function(){var t=this;i.on("NodeChange",function(){var e;(e=i.dom.getParent(i.selection.getNode(),"font"))?t.value(e.face):t.value("")})},onselect:function(e){e.control.settings.value&&i.execCommand("FontName",!1,e.control.settings.value)}}})};e.add("legacyoutput",function(e){t(e),n(e)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "link" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/link')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/link'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "lists" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/lists')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/lists'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "media" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/media')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/media'
|
||||
require('./plugin.js');
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "nonbreaking" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/nonbreaking')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/nonbreaking'
|
||||
require('./plugin.js');
|
||||
@@ -1,53 +1,85 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var nonbreaking = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('nonbreaking', function(editor) {
|
||||
var setting = editor.getParam('nonbreaking_force_tab');
|
||||
var stringRepeat = function (string, repeats) {
|
||||
var str = '';
|
||||
for (var index = 0; index < repeats; index++) {
|
||||
str += string;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
var isVisualCharsEnabled = function (editor) {
|
||||
return editor.plugins.visualchars ? editor.plugins.visualchars.isEnabled() : false;
|
||||
};
|
||||
var insertNbsp = function (editor, times) {
|
||||
var nbsp = isVisualCharsEnabled(editor) ? '<span class="mce-nbsp"> </span>' : ' ';
|
||||
editor.insertContent(stringRepeat(nbsp, times));
|
||||
editor.dom.setAttrib(editor.dom.select('span.mce-nbsp'), 'data-mce-bogus', '1');
|
||||
};
|
||||
var $_cn5p5mh7jh8lpvcp = { insertNbsp: insertNbsp };
|
||||
|
||||
editor.addCommand('mceNonBreaking', function() {
|
||||
editor.insertContent(
|
||||
(editor.plugins.visualchars && editor.plugins.visualchars.state) ?
|
||||
'<span class="mce-nbsp"> </span>' : ' '
|
||||
);
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceNonBreaking', function () {
|
||||
$_cn5p5mh7jh8lpvcp.insertNbsp(editor, 1);
|
||||
});
|
||||
};
|
||||
var $_3698bjh6jh8lpvcn = { register: register };
|
||||
|
||||
editor.dom.setAttrib(editor.dom.select('span.mce-nbsp'), 'data-mce-bogus', '1');
|
||||
});
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
||||
|
||||
editor.addButton('nonbreaking', {
|
||||
title: 'Nonbreaking space',
|
||||
cmd: 'mceNonBreaking'
|
||||
});
|
||||
var getKeyboardSpaces = function (editor) {
|
||||
var spaces = editor.getParam('nonbreaking_force_tab', 0);
|
||||
if (typeof spaces === 'boolean') {
|
||||
return spaces === true ? 3 : 0;
|
||||
} else {
|
||||
return spaces;
|
||||
}
|
||||
};
|
||||
var $_fs2bz5hajh8lpvcs = { getKeyboardSpaces: getKeyboardSpaces };
|
||||
|
||||
editor.addMenuItem('nonbreaking', {
|
||||
text: 'Nonbreaking space',
|
||||
cmd: 'mceNonBreaking',
|
||||
context: 'insert'
|
||||
});
|
||||
var setup = function (editor) {
|
||||
var spaces = $_fs2bz5hajh8lpvcs.getKeyboardSpaces(editor);
|
||||
if (spaces > 0) {
|
||||
editor.on('keydown', function (e) {
|
||||
if (e.keyCode === global$1.TAB && !e.isDefaultPrevented()) {
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
$_cn5p5mh7jh8lpvcp.insertNbsp(editor, spaces);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
var $_74a8ghh8jh8lpvcq = { setup: setup };
|
||||
|
||||
if (setting) {
|
||||
var spaces = +setting > 1 ? +setting : 3; // defaults to 3 spaces if setting is true (or 1)
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('nonbreaking', {
|
||||
title: 'Nonbreaking space',
|
||||
cmd: 'mceNonBreaking'
|
||||
});
|
||||
editor.addMenuItem('nonbreaking', {
|
||||
icon: 'nonbreaking',
|
||||
text: 'Nonbreaking space',
|
||||
cmd: 'mceNonBreaking',
|
||||
context: 'insert'
|
||||
});
|
||||
};
|
||||
var $_evd6yvhbjh8lpvct = { register: register$1 };
|
||||
|
||||
editor.on('keydown', function(e) {
|
||||
if (e.keyCode == 9) {
|
||||
global.add('nonbreaking', function (editor) {
|
||||
$_3698bjh6jh8lpvcn.register(editor);
|
||||
$_evd6yvhbjh8lpvct.register(editor);
|
||||
$_74a8ghh8jh8lpvcq.setup(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
return Plugin;
|
||||
|
||||
e.preventDefault();
|
||||
for (var i = 0; i < spaces; i++) {
|
||||
editor.execCommand('mceNonBreaking');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
@@ -1 +1 @@
|
||||
tinymce.PluginManager.add("nonbreaking",function(a){var b=a.getParam("nonbreaking_force_tab");if(a.addCommand("mceNonBreaking",function(){a.insertContent(a.plugins.visualchars&&a.plugins.visualchars.state?'<span class="mce-nbsp"> </span>':" "),a.dom.setAttrib(a.dom.select("span.mce-nbsp"),"data-mce-bogus","1")}),a.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),a.addMenuItem("nonbreaking",{text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"}),b){var c=+b>1?+b:3;a.on("keydown",function(b){if(9==b.keyCode){if(b.shiftKey)return;b.preventDefault();for(var d=0;c>d;d++)a.execCommand("mceNonBreaking")}})}});
|
||||
!function(){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=function(n,e){var t,i=(t=n).plugins.visualchars&&t.plugins.visualchars.isEnabled()?'<span class="mce-nbsp"> </span>':" ";n.insertContent(function(n,e){for(var t="",i=0;i<e;i++)t+=n;return t}(i,e)),n.dom.setAttrib(n.dom.select("span.mce-nbsp"),"data-mce-bogus","1")},e=function(n){n.addCommand("mceNonBreaking",function(){i(n,1)})},o=tinymce.util.Tools.resolve("tinymce.util.VK"),a=function(n){var e=n.getParam("nonbreaking_force_tab",0);return"boolean"==typeof e?!0===e?3:0:e},t=function(e){var t=a(e);0<t&&e.on("keydown",function(n){if(n.keyCode===o.TAB&&!n.isDefaultPrevented()){if(n.shiftKey)return;n.preventDefault(),n.stopImmediatePropagation(),i(e,t)}})},r=function(n){n.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),n.addMenuItem("nonbreaking",{icon:"nonbreaking",text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"})};n.add("nonbreaking",function(n){e(n),r(n),t(n)})}();
|
||||
@@ -0,0 +1,7 @@
|
||||
// Exports the "noneditable" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/noneditable')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/noneditable'
|
||||
require('./plugin.js');
|
||||
@@ -1,614 +1,118 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*jshint loopfunc:true */
|
||||
/*eslint no-loop-func:0 */
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('noneditable', function(editor) {
|
||||
var TreeWalker = tinymce.dom.TreeWalker;
|
||||
var externalName = 'contenteditable', internalName = 'data-mce-' + externalName;
|
||||
var VK = tinymce.util.VK;
|
||||
|
||||
// Returns the content editable state of a node "true/false" or null
|
||||
function getContentEditable(node) {
|
||||
var contentEditable;
|
||||
|
||||
// Ignore non elements
|
||||
if (node.nodeType === 1) {
|
||||
// Check for fake content editable
|
||||
contentEditable = node.getAttribute(internalName);
|
||||
if (contentEditable && contentEditable !== "inherit") {
|
||||
return contentEditable;
|
||||
}
|
||||
|
||||
// Check for real content editable
|
||||
contentEditable = node.contentEditable;
|
||||
if (contentEditable !== "inherit") {
|
||||
return contentEditable;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Returns the noneditable parent or null if there is a editable before it or if it wasn't found
|
||||
function getNonEditableParent(node) {
|
||||
var state;
|
||||
|
||||
while (node) {
|
||||
state = getContentEditable(node);
|
||||
if (state) {
|
||||
return state === "false" ? node : null;
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
function handleContentEditableSelection() {
|
||||
var dom = editor.dom, selection = editor.selection, caretContainerId = 'mce_noneditablecaret', invisibleChar = '\uFEFF';
|
||||
|
||||
// Get caret container parent for the specified node
|
||||
function getParentCaretContainer(node) {
|
||||
while (node) {
|
||||
if (node.id === caretContainerId) {
|
||||
return node;
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
// Finds the first text node in the specified node
|
||||
function findFirstTextNode(node) {
|
||||
var walker;
|
||||
|
||||
if (node) {
|
||||
walker = new TreeWalker(node, node);
|
||||
|
||||
for (node = walker.current(); node; node = walker.next()) {
|
||||
if (node.nodeType === 3) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert caret container before/after target or expand selection to include block
|
||||
function insertCaretContainerOrExpandToBlock(target, before) {
|
||||
var caretContainer, rng;
|
||||
|
||||
// Select block
|
||||
if (getContentEditable(target) === "false") {
|
||||
if (dom.isBlock(target)) {
|
||||
selection.select(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rng = dom.createRng();
|
||||
|
||||
if (getContentEditable(target) === "true") {
|
||||
if (!target.firstChild) {
|
||||
target.appendChild(editor.getDoc().createTextNode('\u00a0'));
|
||||
}
|
||||
|
||||
target = target.firstChild;
|
||||
before = true;
|
||||
}
|
||||
|
||||
/*
|
||||
caretContainer = dom.create('span', {
|
||||
id: caretContainerId,
|
||||
'data-mce-bogus': true,
|
||||
style:'border: 1px solid red'
|
||||
}, invisibleChar);
|
||||
*/
|
||||
|
||||
caretContainer = dom.create('span', {id: caretContainerId, 'data-mce-bogus': true}, invisibleChar);
|
||||
|
||||
if (before) {
|
||||
target.parentNode.insertBefore(caretContainer, target);
|
||||
} else {
|
||||
dom.insertAfter(caretContainer, target);
|
||||
}
|
||||
|
||||
rng.setStart(caretContainer.firstChild, 1);
|
||||
rng.collapse(true);
|
||||
selection.setRng(rng);
|
||||
|
||||
return caretContainer;
|
||||
}
|
||||
|
||||
// Removes any caret container
|
||||
function removeCaretContainer(caretContainer) {
|
||||
var rng, child, lastContainer;
|
||||
|
||||
if (caretContainer) {
|
||||
rng = selection.getRng(true);
|
||||
rng.setStartBefore(caretContainer);
|
||||
rng.setEndBefore(caretContainer);
|
||||
|
||||
child = findFirstTextNode(caretContainer);
|
||||
if (child && child.nodeValue.charAt(0) == invisibleChar) {
|
||||
child = child.deleteData(0, 1);
|
||||
}
|
||||
|
||||
dom.remove(caretContainer, true);
|
||||
|
||||
selection.setRng(rng);
|
||||
} else {
|
||||
while ((caretContainer = dom.get(caretContainerId)) && caretContainer !== lastContainer) {
|
||||
child = findFirstTextNode(caretContainer);
|
||||
if (child && child.nodeValue.charAt(0) == invisibleChar) {
|
||||
child = child.deleteData(0, 1);
|
||||
}
|
||||
|
||||
dom.remove(caretContainer, true);
|
||||
|
||||
lastContainer = caretContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Modifies the selection to include contentEditable false elements or insert caret containers
|
||||
function moveSelection() {
|
||||
var nonEditableStart, nonEditableEnd, isCollapsed, rng, element;
|
||||
|
||||
// Checks if there is any contents to the left/right side of caret returns the noneditable element or
|
||||
// any editable element if it finds one inside
|
||||
function hasSideContent(element, left) {
|
||||
var container, offset, walker, node, len;
|
||||
|
||||
container = rng.startContainer;
|
||||
offset = rng.startOffset;
|
||||
|
||||
// If endpoint is in middle of text node then expand to beginning/end of element
|
||||
if (container.nodeType == 3) {
|
||||
len = container.nodeValue.length;
|
||||
if ((offset > 0 && offset < len) || (left ? offset == len : offset === 0)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Can we resolve the node by index
|
||||
if (offset < container.childNodes.length) {
|
||||
// Browser represents caret position as the offset at the start of an element. When moving right
|
||||
// this is the element we are moving into so we consider our container to be child node at offset-1
|
||||
var pos = !left && offset > 0 ? offset - 1 : offset;
|
||||
container = container.childNodes[pos];
|
||||
if (container.hasChildNodes()) {
|
||||
container = container.firstChild;
|
||||
}
|
||||
} else {
|
||||
// If not then the caret is at the last position in it's container and the caret container
|
||||
// should be inserted after the noneditable element
|
||||
return !left ? element : null;
|
||||
}
|
||||
}
|
||||
|
||||
// Walk left/right to look for contents
|
||||
walker = new TreeWalker(container, element);
|
||||
while ((node = walker[left ? 'prev' : 'next']())) {
|
||||
if (node.nodeType === 3 && node.nodeValue.length > 0) {
|
||||
return;
|
||||
} else if (getContentEditable(node) === "true") {
|
||||
// Found contentEditable=true element return this one to we can move the caret inside it
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
// Remove any existing caret containers
|
||||
removeCaretContainer();
|
||||
|
||||
// Get noneditable start/end elements
|
||||
isCollapsed = selection.isCollapsed();
|
||||
nonEditableStart = getNonEditableParent(selection.getStart());
|
||||
nonEditableEnd = getNonEditableParent(selection.getEnd());
|
||||
|
||||
// Is any fo the range endpoints noneditable
|
||||
if (nonEditableStart || nonEditableEnd) {
|
||||
rng = selection.getRng(true);
|
||||
|
||||
// If it's a caret selection then look left/right to see if we need to move the caret out side or expand
|
||||
if (isCollapsed) {
|
||||
nonEditableStart = nonEditableStart || nonEditableEnd;
|
||||
|
||||
if ((element = hasSideContent(nonEditableStart, true))) {
|
||||
// We have no contents to the left of the caret then insert a caret container before the noneditable element
|
||||
insertCaretContainerOrExpandToBlock(element, true);
|
||||
} else if ((element = hasSideContent(nonEditableStart, false))) {
|
||||
// We have no contents to the right of the caret then insert a caret container after the noneditable element
|
||||
insertCaretContainerOrExpandToBlock(element, false);
|
||||
} else {
|
||||
// We are in the middle of a noneditable so expand to select it
|
||||
selection.select(nonEditableStart);
|
||||
}
|
||||
} else {
|
||||
rng = selection.getRng(true);
|
||||
|
||||
// Expand selection to include start non editable element
|
||||
if (nonEditableStart) {
|
||||
rng.setStartBefore(nonEditableStart);
|
||||
}
|
||||
|
||||
// Expand selection to include end non editable element
|
||||
if (nonEditableEnd) {
|
||||
rng.setEndAfter(nonEditableEnd);
|
||||
}
|
||||
|
||||
selection.setRng(rng);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleKey(e) {
|
||||
var keyCode = e.keyCode, nonEditableParent, caretContainer, startElement, endElement;
|
||||
|
||||
function getNonEmptyTextNodeSibling(node, prev) {
|
||||
while ((node = node[prev ? 'previousSibling' : 'nextSibling'])) {
|
||||
if (node.nodeType !== 3 || node.nodeValue.length > 0) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function positionCaretOnElement(element, start) {
|
||||
selection.select(element);
|
||||
selection.collapse(start);
|
||||
}
|
||||
|
||||
function canDelete(backspace) {
|
||||
var rng, container, offset, nonEditableParent;
|
||||
|
||||
function removeNodeIfNotParent(node) {
|
||||
var parent = container;
|
||||
|
||||
while (parent) {
|
||||
if (parent === node) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
|
||||
dom.remove(node);
|
||||
moveSelection();
|
||||
}
|
||||
|
||||
function isNextPrevTreeNodeNonEditable() {
|
||||
var node, walker, nonEmptyElements = editor.schema.getNonEmptyElements();
|
||||
|
||||
walker = new tinymce.dom.TreeWalker(container, editor.getBody());
|
||||
while ((node = (backspace ? walker.prev() : walker.next()))) {
|
||||
// Found IMG/INPUT etc
|
||||
if (nonEmptyElements[node.nodeName.toLowerCase()]) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Found text node with contents
|
||||
if (node.nodeType === 3 && tinymce.trim(node.nodeValue).length > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Found non editable node
|
||||
if (getContentEditable(node) === "false") {
|
||||
removeNodeIfNotParent(node);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the content node is within a non editable parent
|
||||
if (getNonEditableParent(node)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selection.isCollapsed()) {
|
||||
rng = selection.getRng(true);
|
||||
container = rng.startContainer;
|
||||
offset = rng.startOffset;
|
||||
container = getParentCaretContainer(container) || container;
|
||||
|
||||
// Is in noneditable parent
|
||||
if ((nonEditableParent = getNonEditableParent(container))) {
|
||||
removeNodeIfNotParent(nonEditableParent);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the caret is in the middle of a text node
|
||||
if (container.nodeType == 3 && (backspace ? offset > 0 : offset < container.nodeValue.length)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resolve container index
|
||||
if (container.nodeType == 1) {
|
||||
container = container.childNodes[offset] || container;
|
||||
}
|
||||
|
||||
// Check if previous or next tree node is non editable then block the event
|
||||
if (isNextPrevTreeNodeNonEditable()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
moveSelection();
|
||||
|
||||
startElement = selection.getStart();
|
||||
endElement = selection.getEnd();
|
||||
|
||||
// Disable all key presses in contentEditable=false except delete or backspace
|
||||
nonEditableParent = getNonEditableParent(startElement) || getNonEditableParent(endElement);
|
||||
var currentNode = editor.selection.getNode();
|
||||
|
||||
var isDirectionKey = keyCode == VK.LEFT || keyCode == VK.RIGHT || keyCode == VK.UP || keyCode == VK.DOWN;
|
||||
var left = keyCode == VK.LEFT || keyCode == VK.UP;
|
||||
|
||||
if (nonEditableParent && (keyCode < 112 || keyCode > 124) && keyCode != VK.DELETE && keyCode != VK.BACKSPACE) {
|
||||
|
||||
// Is Ctrl+c, Ctrl+v or Ctrl+x then use default browser behavior
|
||||
if ((tinymce.isMac ? e.metaKey : e.ctrlKey) && (keyCode == 67 || keyCode == 88 || keyCode == 86)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
// Arrow left/right select the element and collapse left/right
|
||||
if (isDirectionKey) {
|
||||
|
||||
// If a block element find previous or next element to position the caret
|
||||
if (editor.dom.isBlock(nonEditableParent)) {
|
||||
var targetElement = left ? nonEditableParent.previousSibling : nonEditableParent.nextSibling;
|
||||
|
||||
// Handling for edge-cases:
|
||||
// - two nonEditables in a row -> no way to get between them
|
||||
// - nonEditable as the first/last element -> no way to get before/behind it
|
||||
if (!targetElement || targetElement && getContentEditable(targetElement) === 'false') {
|
||||
var p = dom.create('p', null, ' ');
|
||||
p.className = 'mceTmpParagraph';
|
||||
|
||||
var insertElement = left ? nonEditableParent : targetElement;
|
||||
|
||||
if (insertElement && insertElement.parentNode) {
|
||||
insertElement.parentNode.insertBefore(p, insertElement);
|
||||
} else if (!targetElement && !left) {
|
||||
nonEditableParent.parentNode.appendChild(p);
|
||||
}
|
||||
|
||||
targetElement = p;
|
||||
}
|
||||
|
||||
var walker = new TreeWalker(targetElement, targetElement);
|
||||
var caretElement = left ? walker.prev() : walker.next();
|
||||
|
||||
positionCaretOnElement(caretElement, !left);
|
||||
} else {
|
||||
positionCaretOnElement(nonEditableParent, left);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Is arrow left/right, backspace or delete
|
||||
if (isDirectionKey || keyCode == VK.BACKSPACE || keyCode == VK.DELETE) {
|
||||
caretContainer = getParentCaretContainer(startElement);
|
||||
|
||||
if (caretContainer) {
|
||||
// Arrow left or backspace
|
||||
if (keyCode == VK.LEFT || keyCode == VK.BACKSPACE) {
|
||||
nonEditableParent = getNonEmptyTextNodeSibling(caretContainer, true);
|
||||
|
||||
if (nonEditableParent && getContentEditable(nonEditableParent) === "false") {
|
||||
e.preventDefault();
|
||||
|
||||
if (keyCode == VK.LEFT) {
|
||||
positionCaretOnElement(nonEditableParent, true);
|
||||
} else {
|
||||
dom.remove(nonEditableParent);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
removeCaretContainer(caretContainer);
|
||||
}
|
||||
}
|
||||
|
||||
// Arrow right or delete
|
||||
if (keyCode == VK.RIGHT || keyCode == VK.DELETE) {
|
||||
nonEditableParent = getNonEmptyTextNodeSibling(caretContainer, true);
|
||||
|
||||
if (nonEditableParent && getContentEditable(nonEditableParent) === "false") {
|
||||
e.preventDefault();
|
||||
|
||||
if (keyCode == VK.RIGHT) {
|
||||
positionCaretOnElement(nonEditableParent, false);
|
||||
} else {
|
||||
dom.remove(nonEditableParent);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
removeCaretContainer(caretContainer);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if (isDirectionKey) {
|
||||
// Removal of separator paragraphs between two nonEditables
|
||||
// and before/after a nonEditable as the first/last element
|
||||
if (currentNode && currentNode.className.indexOf('mceTmpParagraph') !== -1 &&
|
||||
currentNode[left ? 'previousSibling' : 'nextSibling']) {
|
||||
var jumpTarget = currentNode[left ? 'previousSibling' : 'nextSibling'];
|
||||
|
||||
// current node is still empty and a separator -> remove it
|
||||
// else: remove the separator class, as it now includes content
|
||||
if (currentNode.innerHTML === ' ' || currentNode.innerHTML === '' || currentNode.innerHTML === ' ') {
|
||||
dom.remove(currentNode);
|
||||
} else {
|
||||
currentNode.className = currentNode.className.replace('mceTmpParagraph', '');
|
||||
}
|
||||
|
||||
positionCaretOnElement(jumpTarget, !left);
|
||||
}
|
||||
}
|
||||
|
||||
var rng = selection.getRng(true);
|
||||
var container = rng.endContainer;
|
||||
|
||||
// FIX: If end of node is selected, check wether next sibling is nonEditable to correctly remove it
|
||||
// (else would break for more complex nonEditables, their content would get moved to the current node)
|
||||
if (dom.isBlock(container) && dom.isBlock(container.nextSibling) && rng.endOffset == 1 && keyCode == VK.DELETE) {
|
||||
nonEditableParent = getNonEditableParent(container.nextSibling);
|
||||
}
|
||||
|
||||
// correctly remove block-level nonEditable domNode on delete/backspace
|
||||
if (nonEditableParent && (keyCode == VK.DELETE || keyCode == VK.BACKSPACE) && dom.isBlock(nonEditableParent)) {
|
||||
e.preventDefault();
|
||||
dom.remove(nonEditableParent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((keyCode == VK.BACKSPACE || keyCode == VK.DELETE) && !canDelete(keyCode == VK.BACKSPACE)) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor.on('mousedown', function(e) {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
// Also remove separator lines when clicking on another node
|
||||
if (node && node.className.indexOf('mceTmpParagraph') !== -1 && node !== e.target) {
|
||||
// current node is still empty and a separator -> remove it
|
||||
// else: remove the separator class, as it now includes content
|
||||
if (node.innerHTML === ' ' || node.innerHTML === '' || node.innerHTML === ' ') {
|
||||
dom.remove(node);
|
||||
} else {
|
||||
node.className = node.className.replace('mceTmpParagraph', '');
|
||||
}
|
||||
}
|
||||
|
||||
if (getContentEditable(node) === "false" && node == e.target) {
|
||||
// Expand selection on mouse down we can't block the default event since it's used for drag/drop
|
||||
moveSelection();
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('mouseup', moveSelection);
|
||||
|
||||
editor.on('keydown', handleKey);
|
||||
}
|
||||
|
||||
var editClass, nonEditClass, nonEditableRegExps;
|
||||
|
||||
// Converts configured regexps to noneditable span items
|
||||
function convertRegExpsToNonEditable(e) {
|
||||
var i = nonEditableRegExps.length, content = e.content, cls = tinymce.trim(nonEditClass);
|
||||
|
||||
// Don't replace the variables when raw is used for example on undo/redo
|
||||
if (e.format == "raw") {
|
||||
return;
|
||||
}
|
||||
|
||||
while (i--) {
|
||||
content = content.replace(nonEditableRegExps[i], function(match) {
|
||||
var args = arguments, index = args[args.length - 2];
|
||||
|
||||
// Is value inside an attribute then don't replace
|
||||
if (index > 0 && content.charAt(index - 1) == '"') {
|
||||
return match;
|
||||
}
|
||||
|
||||
return (
|
||||
'<span class="' + cls + '" data-mce-content="' + editor.dom.encode(args[0]) + '">' +
|
||||
editor.dom.encode(typeof args[1] === "string" ? args[1] : args[0]) + '</span>'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
e.content = content;
|
||||
}
|
||||
|
||||
editClass = " " + tinymce.trim(editor.getParam("noneditable_editable_class", "mceEditable")) + " ";
|
||||
nonEditClass = " " + tinymce.trim(editor.getParam("noneditable_noneditable_class", "mceNonEditable")) + " ";
|
||||
|
||||
// Setup noneditable regexps array
|
||||
nonEditableRegExps = editor.getParam("noneditable_regexp");
|
||||
if (nonEditableRegExps && !nonEditableRegExps.length) {
|
||||
nonEditableRegExps = [nonEditableRegExps];
|
||||
}
|
||||
|
||||
editor.on('PreInit', function() {
|
||||
handleContentEditableSelection();
|
||||
|
||||
if (nonEditableRegExps) {
|
||||
editor.on('BeforeSetContent', convertRegExpsToNonEditable);
|
||||
}
|
||||
|
||||
// Apply contentEditable true/false on elements with the noneditable/editable classes
|
||||
editor.parser.addAttributeFilter('class', function(nodes) {
|
||||
var i = nodes.length, className, node;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
className = " " + node.attr("class") + " ";
|
||||
|
||||
if (className.indexOf(editClass) !== -1) {
|
||||
node.attr(internalName, "true");
|
||||
} else if (className.indexOf(nonEditClass) !== -1) {
|
||||
node.attr(internalName, "false");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Remove internal name
|
||||
editor.serializer.addAttributeFilter(internalName, function(nodes) {
|
||||
var i = nodes.length, node;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
|
||||
if (nonEditableRegExps && node.attr('data-mce-content')) {
|
||||
node.name = "#text";
|
||||
node.type = 3;
|
||||
node.raw = true;
|
||||
node.value = node.attr('data-mce-content');
|
||||
} else {
|
||||
node.attr(externalName, null);
|
||||
node.attr(internalName, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Convert external name into internal name
|
||||
editor.parser.addAttributeFilter(externalName, function(nodes) {
|
||||
var i = nodes.length, node;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
node.attr(internalName, node.attr(externalName));
|
||||
node.attr(externalName, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
editor.on('drop', function(e) {
|
||||
if (getNonEditableParent(e.target)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
(function () {
|
||||
var noneditable = (function () {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
var getNonEditableClass = function (editor) {
|
||||
return editor.getParam('noneditable_noneditable_class', 'mceNonEditable');
|
||||
};
|
||||
var getEditableClass = function (editor) {
|
||||
return editor.getParam('noneditable_editable_class', 'mceEditable');
|
||||
};
|
||||
var getNonEditableRegExps = function (editor) {
|
||||
var nonEditableRegExps = editor.getParam('noneditable_regexp', []);
|
||||
if (nonEditableRegExps && nonEditableRegExps.constructor === RegExp) {
|
||||
return [nonEditableRegExps];
|
||||
} else {
|
||||
return nonEditableRegExps;
|
||||
}
|
||||
};
|
||||
var $_b5lblphgjh8lpvd6 = {
|
||||
getNonEditableClass: getNonEditableClass,
|
||||
getEditableClass: getEditableClass,
|
||||
getNonEditableRegExps: getNonEditableRegExps
|
||||
};
|
||||
|
||||
var hasClass = function (checkClassName) {
|
||||
return function (node) {
|
||||
return (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1;
|
||||
};
|
||||
};
|
||||
var replaceMatchWithSpan = function (editor, content, cls) {
|
||||
return function (match) {
|
||||
var args = arguments, index = args[args.length - 2];
|
||||
var prevChar = index > 0 ? content.charAt(index - 1) : '';
|
||||
if (prevChar === '"') {
|
||||
return match;
|
||||
}
|
||||
if (prevChar === '>') {
|
||||
var findStartTagIndex = content.lastIndexOf('<', index);
|
||||
if (findStartTagIndex !== -1) {
|
||||
var tagHtml = content.substring(findStartTagIndex, index);
|
||||
if (tagHtml.indexOf('contenteditable="false"') !== -1) {
|
||||
return match;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '<span class="' + cls + '" data-mce-content="' + editor.dom.encode(args[0]) + '">' + editor.dom.encode(typeof args[1] === 'string' ? args[1] : args[0]) + '</span>';
|
||||
};
|
||||
};
|
||||
var convertRegExpsToNonEditable = function (editor, nonEditableRegExps, e) {
|
||||
var i = nonEditableRegExps.length, content = e.content;
|
||||
if (e.format === 'raw') {
|
||||
return;
|
||||
}
|
||||
while (i--) {
|
||||
content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, $_b5lblphgjh8lpvd6.getNonEditableClass(editor)));
|
||||
}
|
||||
e.content = content;
|
||||
};
|
||||
var setup = function (editor) {
|
||||
var editClass, nonEditClass;
|
||||
var contentEditableAttrName = 'contenteditable';
|
||||
editClass = ' ' + global$1.trim($_b5lblphgjh8lpvd6.getEditableClass(editor)) + ' ';
|
||||
nonEditClass = ' ' + global$1.trim($_b5lblphgjh8lpvd6.getNonEditableClass(editor)) + ' ';
|
||||
var hasEditClass = hasClass(editClass);
|
||||
var hasNonEditClass = hasClass(nonEditClass);
|
||||
var nonEditableRegExps = $_b5lblphgjh8lpvd6.getNonEditableRegExps(editor);
|
||||
editor.on('PreInit', function () {
|
||||
if (nonEditableRegExps.length > 0) {
|
||||
editor.on('BeforeSetContent', function (e) {
|
||||
convertRegExpsToNonEditable(editor, nonEditableRegExps, e);
|
||||
});
|
||||
}
|
||||
editor.parser.addAttributeFilter('class', function (nodes) {
|
||||
var i = nodes.length, node;
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
if (hasEditClass(node)) {
|
||||
node.attr(contentEditableAttrName, 'true');
|
||||
} else if (hasNonEditClass(node)) {
|
||||
node.attr(contentEditableAttrName, 'false');
|
||||
}
|
||||
}
|
||||
});
|
||||
editor.serializer.addAttributeFilter(contentEditableAttrName, function (nodes) {
|
||||
var i = nodes.length, node;
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
if (!hasEditClass(node) && !hasNonEditClass(node)) {
|
||||
continue;
|
||||
}
|
||||
if (nonEditableRegExps.length > 0 && node.attr('data-mce-content')) {
|
||||
node.name = '#text';
|
||||
node.type = 3;
|
||||
node.raw = true;
|
||||
node.value = node.attr('data-mce-content');
|
||||
} else {
|
||||
node.attr(contentEditableAttrName, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
var $_90alq9hejh8lpvd3 = { setup: setup };
|
||||
|
||||
global.add('noneditable', function (editor) {
|
||||
$_90alq9hejh8lpvd3.setup(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
// Exports the "pagebreak" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/pagebreak')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/pagebreak'
|
||||
require('./plugin.js');
|
||||
@@ -1,88 +1,109 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
(function () {
|
||||
var pagebreak = (function () {
|
||||
'use strict';
|
||||
|
||||
/*global tinymce:true */
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
tinymce.PluginManager.add('pagebreak', function(editor) {
|
||||
var pageBreakClass = 'mce-pagebreak', separatorHtml = editor.getParam('pagebreak_separator', '<!-- pagebreak -->');
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
var pageBreakSeparatorRegExp = new RegExp(separatorHtml.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {
|
||||
return '\\' + a;
|
||||
}), 'gi');
|
||||
var getSeparatorHtml = function (editor) {
|
||||
return editor.getParam('pagebreak_separator', '<!-- pagebreak -->');
|
||||
};
|
||||
var shouldSplitBlock = function (editor) {
|
||||
return editor.getParam('pagebreak_split_block', false);
|
||||
};
|
||||
var $_1hv0yhhmjh8lpvdi = {
|
||||
getSeparatorHtml: getSeparatorHtml,
|
||||
shouldSplitBlock: shouldSplitBlock
|
||||
};
|
||||
|
||||
var pageBreakPlaceHolderHtml = '<img src="' + tinymce.Env.transparentSrc + '" class="' +
|
||||
pageBreakClass + '" data-mce-resize="false" />';
|
||||
var getPageBreakClass = function () {
|
||||
return 'mce-pagebreak';
|
||||
};
|
||||
var getPlaceholderHtml = function () {
|
||||
return '<img src="' + global$1.transparentSrc + '" class="' + getPageBreakClass() + '" data-mce-resize="false" data-mce-placeholder />';
|
||||
};
|
||||
var setup = function (editor) {
|
||||
var separatorHtml = $_1hv0yhhmjh8lpvdi.getSeparatorHtml(editor);
|
||||
var pageBreakSeparatorRegExp = new RegExp(separatorHtml.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function (a) {
|
||||
return '\\' + a;
|
||||
}), 'gi');
|
||||
editor.on('BeforeSetContent', function (e) {
|
||||
e.content = e.content.replace(pageBreakSeparatorRegExp, getPlaceholderHtml());
|
||||
});
|
||||
editor.on('PreInit', function () {
|
||||
editor.serializer.addNodeFilter('img', function (nodes) {
|
||||
var i = nodes.length, node, className;
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
className = node.attr('class');
|
||||
if (className && className.indexOf('mce-pagebreak') !== -1) {
|
||||
var parentNode = node.parent;
|
||||
if (editor.schema.getBlockElements()[parentNode.name] && $_1hv0yhhmjh8lpvdi.shouldSplitBlock(editor)) {
|
||||
parentNode.type = 3;
|
||||
parentNode.value = separatorHtml;
|
||||
parentNode.raw = true;
|
||||
node.remove();
|
||||
continue;
|
||||
}
|
||||
node.type = 3;
|
||||
node.value = separatorHtml;
|
||||
node.raw = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
var $_55pzfihkjh8lpvdh = {
|
||||
setup: setup,
|
||||
getPlaceholderHtml: getPlaceholderHtml,
|
||||
getPageBreakClass: getPageBreakClass
|
||||
};
|
||||
|
||||
// Register commands
|
||||
editor.addCommand('mcePageBreak', function() {
|
||||
if (editor.settings.pagebreak_split_block) {
|
||||
editor.insertContent('<p>' + pageBreakPlaceHolderHtml + '</p>');
|
||||
} else {
|
||||
editor.insertContent(pageBreakPlaceHolderHtml);
|
||||
}
|
||||
});
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mcePageBreak', function () {
|
||||
if (editor.settings.pagebreak_split_block) {
|
||||
editor.insertContent('<p>' + $_55pzfihkjh8lpvdh.getPlaceholderHtml() + '</p>');
|
||||
} else {
|
||||
editor.insertContent($_55pzfihkjh8lpvdh.getPlaceholderHtml());
|
||||
}
|
||||
});
|
||||
};
|
||||
var $_2aoouchjjh8lpvdf = { register: register };
|
||||
|
||||
// Register buttons
|
||||
editor.addButton('pagebreak', {
|
||||
title: 'Page break',
|
||||
cmd: 'mcePageBreak'
|
||||
});
|
||||
var setup$1 = function (editor) {
|
||||
editor.on('ResolveName', function (e) {
|
||||
if (e.target.nodeName === 'IMG' && editor.dom.hasClass(e.target, $_55pzfihkjh8lpvdh.getPageBreakClass())) {
|
||||
e.name = 'pagebreak';
|
||||
}
|
||||
});
|
||||
};
|
||||
var $_2mwcs9hnjh8lpvdj = { setup: setup$1 };
|
||||
|
||||
editor.addMenuItem('pagebreak', {
|
||||
text: 'Page break',
|
||||
icon: 'pagebreak',
|
||||
cmd: 'mcePageBreak',
|
||||
context: 'insert'
|
||||
});
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('pagebreak', {
|
||||
title: 'Page break',
|
||||
cmd: 'mcePageBreak'
|
||||
});
|
||||
editor.addMenuItem('pagebreak', {
|
||||
text: 'Page break',
|
||||
icon: 'pagebreak',
|
||||
cmd: 'mcePageBreak',
|
||||
context: 'insert'
|
||||
});
|
||||
};
|
||||
var $_61u3l1hojh8lpvdk = { register: register$1 };
|
||||
|
||||
editor.on('ResolveName', function(e) {
|
||||
if (e.target.nodeName == 'IMG' && editor.dom.hasClass(e.target, pageBreakClass)) {
|
||||
e.name = 'pagebreak';
|
||||
}
|
||||
});
|
||||
global.add('pagebreak', function (editor) {
|
||||
$_2aoouchjjh8lpvdf.register(editor);
|
||||
$_61u3l1hojh8lpvdk.register(editor);
|
||||
$_55pzfihkjh8lpvdh.setup(editor);
|
||||
$_2mwcs9hnjh8lpvdj.setup(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
editor.on('click', function(e) {
|
||||
e = e.target;
|
||||
return Plugin;
|
||||
|
||||
if (e.nodeName === 'IMG' && editor.dom.hasClass(e, pageBreakClass)) {
|
||||
editor.selection.select(e);
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('BeforeSetContent', function(e) {
|
||||
e.content = e.content.replace(pageBreakSeparatorRegExp, pageBreakPlaceHolderHtml);
|
||||
});
|
||||
|
||||
editor.on('PreInit', function() {
|
||||
editor.serializer.addNodeFilter('img', function(nodes) {
|
||||
var i = nodes.length, node, className;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
className = node.attr('class');
|
||||
if (className && className.indexOf('mce-pagebreak') !== -1) {
|
||||
// Replace parent block node if pagebreak_split_block is enabled
|
||||
var parentNode = node.parent;
|
||||
if (editor.schema.getBlockElements()[parentNode.name] && editor.settings.pagebreak_split_block) {
|
||||
parentNode.type = 3;
|
||||
parentNode.value = separatorHtml;
|
||||
parentNode.raw = true;
|
||||
node.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
node.type = 3;
|
||||
node.value = separatorHtml;
|
||||
node.raw = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}());
|
||||
})();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user