Add WebCms

This commit is contained in:
2016-11-07 12:56:17 -05:00
parent dfe92218f4
commit 15911f33c0
2750 changed files with 365672 additions and 133 deletions
@@ -0,0 +1,123 @@
/**
* plugin.js
*
* Copyright, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
/*global tinymce:true */
tinymce.PluginManager.add('visualchars', function(editor) {
var self = this, state;
function toggleVisualChars(addBookmark) {
var node, nodeList, i, body = editor.getBody(), nodeValue, selection = editor.selection, div, bookmark;
var charMap, visualCharsRegExp;
charMap = {
'\u00a0': 'nbsp',
'\u00ad': 'shy'
};
function wrapCharWithSpan(value) {
return '<span data-mce-bogus="1" class="mce-' + charMap[value] + '">' + value + '</span>';
}
function compileCharMapToRegExp() {
var key, regExp = '';
for (key in charMap) {
regExp += key;
}
return new RegExp('[' + regExp + ']', 'g');
}
function compileCharMapToCssSelector() {
var key, selector = '';
for (key in charMap) {
if (selector) {
selector += ',';
}
selector += 'span.mce-' + charMap[key];
}
return selector;
}
state = !state;
self.state = state;
editor.fire('VisualChars', {state: state});
visualCharsRegExp = compileCharMapToRegExp();
if (addBookmark) {
bookmark = selection.getBookmark();
}
if (state) {
nodeList = [];
tinymce.walk(body, function(n) {
if (n.nodeType == 3 && n.nodeValue && visualCharsRegExp.test(n.nodeValue)) {
nodeList.push(n);
}
}, 'childNodes');
for (i = 0; i < nodeList.length; i++) {
nodeValue = nodeList[i].nodeValue;
nodeValue = nodeValue.replace(visualCharsRegExp, wrapCharWithSpan);
div = editor.dom.create('div', null, nodeValue);
while ((node = div.lastChild)) {
editor.dom.insertAfter(node, nodeList[i]);
}
editor.dom.remove(nodeList[i]);
}
} else {
nodeList = editor.dom.select(compileCharMapToCssSelector(), body);
for (i = nodeList.length - 1; i >= 0; i--) {
editor.dom.remove(nodeList[i], 1);
}
}
selection.moveToBookmark(bookmark);
}
function toggleActiveState() {
var self = this;
editor.on('VisualChars', function(e) {
self.active(e.state);
});
}
editor.addCommand('mceVisualChars', toggleVisualChars);
editor.addButton('visualchars', {
title: 'Show invisible characters',
cmd: 'mceVisualChars',
onPostRender: toggleActiveState
});
editor.addMenuItem('visualchars', {
text: 'Show invisible characters',
cmd: 'mceVisualChars',
onPostRender: toggleActiveState,
selectable: true,
context: 'view',
prependToContext: true
});
editor.on('beforegetcontent', function(e) {
if (state && e.format != 'raw' && !e.draft) {
state = true;
toggleVisualChars(false);
}
});
});
@@ -0,0 +1 @@
tinymce.PluginManager.add("visualchars",function(a){function b(b){function c(a){return'<span data-mce-bogus="1" class="mce-'+n[a]+'">'+a+"</span>"}function f(){var a,b="";for(a in n)b+=a;return new RegExp("["+b+"]","g")}function g(){var a,b="";for(a in n)b&&(b+=","),b+="span.mce-"+n[a];return b}var h,i,j,k,l,m,n,o,p=a.getBody(),q=a.selection;if(n={"\xa0":"nbsp","\xad":"shy"},d=!d,e.state=d,a.fire("VisualChars",{state:d}),o=f(),b&&(m=q.getBookmark()),d)for(i=[],tinymce.walk(p,function(a){3==a.nodeType&&a.nodeValue&&o.test(a.nodeValue)&&i.push(a)},"childNodes"),j=0;j<i.length;j++){for(k=i[j].nodeValue,k=k.replace(o,c),l=a.dom.create("div",null,k);h=l.lastChild;)a.dom.insertAfter(h,i[j]);a.dom.remove(i[j])}else for(i=a.dom.select(g(),p),j=i.length-1;j>=0;j--)a.dom.remove(i[j],1);q.moveToBookmark(m)}function c(){var b=this;a.on("VisualChars",function(a){b.active(a.state)})}var d,e=this;a.addCommand("mceVisualChars",b),a.addButton("visualchars",{title:"Show invisible characters",cmd:"mceVisualChars",onPostRender:c}),a.addMenuItem("visualchars",{text:"Show invisible characters",cmd:"mceVisualChars",onPostRender:c,selectable:!0,context:"view",prependToContext:!0}),a.on("beforegetcontent",function(a){d&&"raw"!=a.format&&!a.draft&&(d=!0,b(!1))})});