diff --git a/public/js/common.js b/public/js/common.js
index c6354373..ca9ad38f 100644
--- a/public/js/common.js
+++ b/public/js/common.js
@@ -466,8 +466,9 @@ function pasteImage(e) {
insertImage(url);
});
e && e.preventDefault();
+ return true
}
- return;
+ return false;
// 以下是node-webkit版
diff --git a/public/tinymce/plugins/paste/plugin.js b/public/tinymce/plugins/paste/plugin.js
index 4a358cc8..e31c9573 100644
--- a/public/tinymce/plugins/paste/plugin.js
+++ b/public/tinymce/plugins/paste/plugin.js
@@ -6,79 +6,79 @@
/*globals $code */
(function(exports, undefined) {
- "use strict";
+ "use strict";
- var modules = {};
+ var modules = {};
- function require(ids, callback) {
- var module, defs = [];
+ function require(ids, callback) {
+ var module, defs = [];
- for (var i = 0; i < ids.length; ++i) {
- module = modules[ids[i]] || resolve(ids[i]);
- if (!module) {
- throw 'module definition dependecy not found: ' + ids[i];
- }
+ for (var i = 0; i < ids.length; ++i) {
+ module = modules[ids[i]] || resolve(ids[i]);
+ if (!module) {
+ throw 'module definition dependecy not found: ' + ids[i];
+ }
- defs.push(module);
- }
+ defs.push(module);
+ }
- callback.apply(null, defs);
- }
+ callback.apply(null, defs);
+ }
- function define(id, dependencies, definition) {
- if (typeof id !== 'string') {
- throw 'invalid module definition, module id must be defined and be a string';
- }
+ function define(id, dependencies, definition) {
+ if (typeof id !== 'string') {
+ throw 'invalid module definition, module id must be defined and be a string';
+ }
- if (dependencies === undefined) {
- throw 'invalid module definition, dependencies must be specified';
- }
+ if (dependencies === undefined) {
+ throw 'invalid module definition, dependencies must be specified';
+ }
- if (definition === undefined) {
- throw 'invalid module definition, definition function must be specified';
- }
+ if (definition === undefined) {
+ throw 'invalid module definition, definition function must be specified';
+ }
- require(dependencies, function() {
- modules[id] = definition.apply(null, arguments);
- });
- }
+ require(dependencies, function() {
+ modules[id] = definition.apply(null, arguments);
+ });
+ }
- function defined(id) {
- return !!modules[id];
- }
+ function defined(id) {
+ return !!modules[id];
+ }
- function resolve(id) {
- var target = exports;
- var fragments = id.split(/[.\/]/);
+ function resolve(id) {
+ var target = exports;
+ var fragments = id.split(/[.\/]/);
- for (var fi = 0; fi < fragments.length; ++fi) {
- if (!target[fragments[fi]]) {
- return;
- }
+ for (var fi = 0; fi < fragments.length; ++fi) {
+ if (!target[fragments[fi]]) {
+ return;
+ }
- target = target[fragments[fi]];
- }
+ target = target[fragments[fi]];
+ }
- return target;
- }
+ return target;
+ }
- function expose(ids) {
- for (var i = 0; i < ids.length; i++) {
- var target = exports;
- var id = ids[i];
- var fragments = id.split(/[.\/]/);
+ function expose(ids) {
+ for (var i = 0; i < ids.length; i++) {
+ var target = exports;
+ var id = ids[i];
+ var fragments = id.split(/[.\/]/);
- for (var fi = 0; fi < fragments.length - 1; ++fi) {
- if (target[fragments[fi]] === undefined) {
- target[fragments[fi]] = {};
- }
+ for (var fi = 0; fi < fragments.length - 1; ++fi) {
+ if (target[fragments[fi]] === undefined) {
+ target[fragments[fi]] = {};
+ }
- target = target[fragments[fi]];
- }
+ target = target[fragments[fi]];
+ }
- target[fragments[fragments.length - 1]] = modules[id];
- }
- }
+ target[fragments[fragments.length - 1]] = modules[id];
+ }
+ }
// Included from: js/tinymce/plugins/paste/classes/Utils.js
@@ -99,86 +99,86 @@
* @private
*/
define("tinymce/pasteplugin/Utils", [
- "tinymce/util/Tools",
- "tinymce/html/DomParser",
- "tinymce/html/Schema"
+ "tinymce/util/Tools",
+ "tinymce/html/DomParser",
+ "tinymce/html/Schema"
], function(Tools, DomParser, Schema) {
- function filter(content, items) {
- Tools.each(items, function(v) {
- if (v.constructor == RegExp) {
- content = content.replace(v, '');
- } else {
- content = content.replace(v[0], v[1]);
- }
- });
+ function filter(content, items) {
+ Tools.each(items, function(v) {
+ if (v.constructor == RegExp) {
+ content = content.replace(v, '');
+ } else {
+ content = content.replace(v[0], v[1]);
+ }
+ });
- return content;
- }
+ return content;
+ }
- /**
- * Gets the innerText of the specified element. It will handle edge cases
- * and works better than textContent on Gecko.
- *
- * @param {String} html HTML string to get text from.
- * @return {String} String of text with line feeds.
- */
- function innerText(html) {
- var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
- var shortEndedElements = schema.getShortEndedElements();
- var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
- var blockElements = schema.getBlockElements();
+ /**
+ * Gets the innerText of the specified element. It will handle edge cases
+ * and works better than textContent on Gecko.
+ *
+ * @param {String} html HTML string to get text from.
+ * @return {String} String of text with line feeds.
+ */
+ function innerText(html) {
+ var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
+ var shortEndedElements = schema.getShortEndedElements();
+ var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
+ var blockElements = schema.getBlockElements();
- function walk(node) {
- var name = node.name, currentNode = node;
+ function walk(node) {
+ var name = node.name, currentNode = node;
- if (name === 'br') {
- text += '\n';
- return;
- }
+ if (name === 'br') {
+ text += '\n';
+ return;
+ }
- // img/input/hr
- if (shortEndedElements[name]) {
- text += ' ';
- }
+ // img/input/hr
+ if (shortEndedElements[name]) {
+ text += ' ';
+ }
- // Ingore script, video contents
- if (ignoreElements[name]) {
- text += ' ';
- return;
- }
+ // Ingore script, video contents
+ if (ignoreElements[name]) {
+ text += ' ';
+ return;
+ }
- if (node.type == 3) {
- text += node.value;
- }
+ if (node.type == 3) {
+ text += node.value;
+ }
- // Walk all children
- if (!node.shortEnded) {
- if ((node = node.firstChild)) {
- do {
- walk(node);
- } while ((node = node.next));
- }
- }
+ // Walk all children
+ if (!node.shortEnded) {
+ if ((node = node.firstChild)) {
+ do {
+ walk(node);
+ } while ((node = node.next));
+ }
+ }
- // Add \n or \n\n for blocks or P
- if (blockElements[name] && currentNode.next) {
- text += '\n';
+ // Add \n or \n\n for blocks or P
+ if (blockElements[name] && currentNode.next) {
+ text += '\n';
- if (name == 'p') {
- text += '\n';
- }
- }
- }
+ if (name == 'p') {
+ text += '\n';
+ }
+ }
+ }
- walk(domParser.parse(html));
+ walk(domParser.parse(html));
- return text;
- }
+ return text;
+ }
- return {
- filter: filter,
- innerText: innerText
- };
+ return {
+ filter: filter,
+ innerText: innerText
+ };
});
// Included from: js/tinymce/plugins/paste/classes/Clipboard.js
@@ -213,406 +213,438 @@ define("tinymce/pasteplugin/Utils", [
* @private
*/
define("tinymce/pasteplugin/Clipboard", [
- "tinymce/Env",
- "tinymce/util/VK",
- "tinymce/pasteplugin/Utils"
+ "tinymce/Env",
+ "tinymce/util/VK",
+ "tinymce/pasteplugin/Utils"
], function(Env, VK, Utils) {
- return function(editor) {
- var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0;
- var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
+ return function(editor) {
+ var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0;
+ var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
- /**
- * 复制外链图片, copy到本地
- */
- function copyImage(src, ids) {
- FileService.copyOtherSiteImage(src, function(url) {
- if (url) {
- // 将图片替换之
- var dom = editor.dom;
- for(var i in ids) {
- var id = ids[i];
- var imgElm = dom.get(id);
- if (imgElm) {
- dom.setAttrib(imgElm, 'src', url);
- }
- }
- }
- });
- }
+ /**
+ * 复制外链图片, copy到本地
+ */
+ function copyImage(src, ids) {
+ FileService.copyOtherSiteImage(src, function(url) {
+ if (url) {
+ // 将图片替换之
+ var dom = editor.dom;
+ for(var i in ids) {
+ var id = ids[i];
+ var imgElm = dom.get(id);
+ if (imgElm) {
+ dom.setAttrib(imgElm, 'src', url);
+ }
+ }
+ }
+ });
+ }
- // 粘贴HTML
- // 当在pre下时不能粘贴成HTML
- // life add text
- function pasteHtml(html, text) {
- var args, dom = editor.dom;
+ // 粘贴HTML
+ // 当在pre下时不能粘贴成HTML
+ // life add text
+ function pasteHtml(html, text) {
+ var args, dom = editor.dom;
- // Remove all data images from paste for example from Gecko
- if (!editor.settings.paste_data_images) {
- html = html.replace(/]+src=\"data:image[^>]+>/g, '');
- }
+ // Remove all data images from paste for example from Gecko
+ if (!editor.settings.paste_data_images) {
+ html = html.replace(/
]+src=\"data:image[^>]+>/g, '');
+ }
- args = editor.fire('BeforePastePreProcess', {content: html}); // Internal event used by Quirks
- args = editor.fire('PastePreProcess', args);
- html = args.content;
+ args = editor.fire('BeforePastePreProcess', {content: html}); // Internal event used by Quirks
+ args = editor.fire('PastePreProcess', args);
+ html = args.content;
- if (!args.isDefaultPrevented()) {
- // User has bound PastePostProcess events then we need to pass it through a DOM node
- // This is not ideal but we don't want to let the browser mess up the HTML for example
- // some browsers add to P tags etc
- if (editor.hasEventListeners('PastePostProcess') && !args.isDefaultPrevented()) {
- // We need to attach the element to the DOM so Sizzle selectors work on the contents
- var tempBody = dom.add(editor.getBody(), 'div', {style: 'display:none'}, html);
- args = editor.fire('PastePostProcess', {node: tempBody});
- dom.remove(tempBody);
- html = args.node.innerHTML;
- }
-
- if (!args.isDefaultPrevented()) {
- // life
- var node = editor.selection.getNode();
- if(node.nodeName == "PRE") {
- if(!text) {
- try {
- text = $(html).text();
- } catch(e) {
- }
- }
- // HTML不能粘贴
- // 其它有错误.... TODO
- // 若有HTML, paste到其它地方有js错误
- // 貼html时自动会删除
- // 纯HTML编辑也会
- text = text.replace(//g, ">");
- // firefox下必须这个
- editor.insertRawContent(text);
- // 之前用insertRawContent()有问题, ace paste下, TODO
- // editor.insertContent(text);
- } else {
- // life 这里得到图片img, 复制到leanote下
- if(!self.copyImage) {
- editor.insertContent(html);
- } else {
- var urlPrefix = UrlPrefix;
- var needCopyImages = {}; // src => [id1,id2]
- var time = (new Date()).getTime();
- try {
- var $html = $("
- var forcedRootBlockName = editor.settings.forced_root_block; - var forcedRootBlockStartHtml; - if (forcedRootBlockName) { - forcedRootBlockStartHtml = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs); - forcedRootBlockStartHtml = forcedRootBlockStartHtml.substr(0, forcedRootBlockStartHtml.length - 3) + '>'; - } + // Create start block html for example
+ var forcedRootBlockName = editor.settings.forced_root_block;
+ var forcedRootBlockStartHtml;
+ if (forcedRootBlockName) {
+ forcedRootBlockStartHtml = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs);
+ forcedRootBlockStartHtml = forcedRootBlockStartHtml.substr(0, forcedRootBlockStartHtml.length - 3) + '>';
+ }
- if ((startBlock && /^(PRE|DIV)$/.test(startBlock.nodeName)) || !forcedRootBlockName) {
- text = Utils.filter(text, [
- [/\n/g, "
"]
- ]);
- } else {
- text = Utils.filter(text, [
- [/\n\n/g, "
)$/, forcedRootBlockStartHtml + '$1'],
- [/\n/g, "
"]
- ]);
+ if ((startBlock && /^(PRE|DIV)$/.test(startBlock.nodeName)) || !forcedRootBlockName) {
+ text = Utils.filter(text, [
+ [/\n/g, "
"]
+ ]);
+ } else {
+ text = Utils.filter(text, [
+ [/\n\n/g, "
)$/, forcedRootBlockStartHtml + '$1'],
+ [/\n/g, "
"]
+ ]);
- if (text.indexOf('
') != -1) { - text = forcedRootBlockStartHtml + text; - } - } + if (text.indexOf('
') != -1) {
+ text = forcedRootBlockStartHtml + text;
+ }
+ }
- pasteHtml(text, text2);
- }
-
- /**
- * Creates a paste bin element and moves the selection into that element. It will also move the element offscreen
- * so that resize handles doesn't get produced on IE or Drag handles or Firefox.
- */
- function createPasteBin() {
- var dom = editor.dom, body = editor.getBody(), viewport = editor.dom.getViewPort(editor.getWin());
- var scrollY = editor.inline ? body.scrollTop : viewport.y, height = editor.inline ? body.clientHeight : viewport.h;
+ pasteHtml(text, text2);
+ }
+
+ /**
+ * Creates a paste bin element and moves the selection into that element. It will also move the element offscreen
+ * so that resize handles doesn't get produced on IE or Drag handles or Firefox.
+ */
+ function createPasteBin() {
+ var dom = editor.dom, body = editor.getBody(), viewport = editor.dom.getViewPort(editor.getWin());
+ var scrollY = editor.inline ? body.scrollTop : viewport.y, height = editor.inline ? body.clientHeight : viewport.h;
- removePasteBin();
+ removePasteBin();
- // Create a pastebin
- pasteBinElm = dom.add(editor.getBody(), 'div', {
- id: "mcepastebin",
- contentEditable: true,
- "data-mce-bogus": "1",
- style: 'position: absolute; top: ' + (scrollY + 20) + 'px;' +
- 'width: 10px; height: ' + (height - 40) + 'px; overflow: hidden; opacity: 0'
- }, pasteBinDefaultContent);
+ // Create a pastebin
+ pasteBinElm = dom.add(editor.getBody(), 'div', {
+ id: "mcepastebin",
+ contentEditable: true,
+ "data-mce-bogus": "1",
+ style: 'position: absolute; top: ' + (scrollY + 20) + 'px;' +
+ 'width: 10px; height: ' + (height - 40) + 'px; overflow: hidden; opacity: 0'
+ }, pasteBinDefaultContent);
- // Move paste bin out of sight since the controlSelection rect gets displayed otherwise
- dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
+ // Move paste bin out of sight since the controlSelection rect gets displayed otherwise
+ dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
- // Prevent focus events from bubbeling fixed FocusManager issues
- dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function(e) {
- e.stopPropagation();
- });
+ // Prevent focus events from bubbeling fixed FocusManager issues
+ dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function(e) {
+ e.stopPropagation();
+ });
- lastRng = editor.selection.getRng();
- pasteBinElm.focus();
- editor.selection.select(pasteBinElm, true);
- }
+ lastRng = editor.selection.getRng();
+ pasteBinElm.focus();
+ editor.selection.select(pasteBinElm, true);
+ }
- /**
- * Removes the paste bin if it exists.
- */
- function removePasteBin() {
- if (pasteBinElm) {
- editor.dom.unbind(pasteBinElm);
- editor.dom.remove(pasteBinElm);
+ /**
+ * Removes the paste bin if it exists.
+ */
+ function removePasteBin() {
+ if (pasteBinElm) {
+ editor.dom.unbind(pasteBinElm);
+ editor.dom.remove(pasteBinElm);
- if (lastRng) {
- editor.selection.setRng(lastRng);
- }
- }
+ if (lastRng) {
+ editor.selection.setRng(lastRng);
+ }
+ }
- keyboardPastePlainTextState = false;
- pasteBinElm = lastRng = null;
- }
+ keyboardPastePlainTextState = false;
+ pasteBinElm = lastRng = null;
+ }
- /**
- * Returns the contents of the paste bin as a HTML string.
- *
- * @return {String} Get the contents of the paste bin.
- */
- function getPasteBinHtml() {
- return pasteBinElm ? pasteBinElm.innerHTML : pasteBinDefaultContent;
- }
+ /**
+ * Returns the contents of the paste bin as a HTML string.
+ *
+ * @return {String} Get the contents of the paste bin.
+ */
+ function getPasteBinHtml() {
+ return pasteBinElm ? pasteBinElm.innerHTML : pasteBinDefaultContent;
+ }
- /**
- * Gets various content types out of the Clipboard API. It will also get the
- * plain text using older IE and WebKit API:s.
- *
- * @param {ClipboardEvent} clipboardEvent Event fired on paste.
- * @return {Object} Object with mime types and data for those mime types.
- */
- function getClipboardContent(clipboardEvent) {
- var data = {}, clipboardData = clipboardEvent.clipboardData || editor.getDoc().dataTransfer;
+ /**
+ * Gets various content types out of the Clipboard API. It will also get the
+ * plain text using older IE and WebKit API:s.
+ *
+ * @param {ClipboardEvent} clipboardEvent Event fired on paste.
+ * @return {Object} Object with mime types and data for those mime types.
+ */
+ function getClipboardContent(clipboardEvent) {
+ var data = {}, clipboardData = clipboardEvent.clipboardData || editor.getDoc().dataTransfer;
- if (clipboardData && clipboardData.types) {
- data['text/plain'] = clipboardData.getData('Text');
+ if (clipboardData && clipboardData.types) {
+ data['text/plain'] = clipboardData.getData('Text');
- for (var i = 0; i < clipboardData.types.length; i++) {
- var contentType = clipboardData.types[i];
- data[contentType] = clipboardData.getData(contentType);
- }
- }
+ for (var i = 0; i < clipboardData.types.length; i++) {
+ var contentType = clipboardData.types[i];
+ data[contentType] = clipboardData.getData(contentType);
+ }
+ }
- return data;
- }
+ return data;
+ }
- function inAcePrevent() {
- // 这个事件是从哪触发的? 浏览器自带的
- // life ace 如果在pre中, 直接返回 TODO
- var ace = LeaAce.nowIsInAce();
- if(ace) {
- // log("in aceEdiotr 2 paste");
- // 原来这里focus了
- setTimeout(function() {
- ace[0].focus();
- });
- return true;
- }
- return false;
- }
+ function inAcePrevent() {
+ // 这个事件是从哪触发的? 浏览器自带的
+ // life ace 如果在pre中, 直接返回 TODO
+ var ace = LeaAce.nowIsInAce();
+ if(ace) {
+ // log("in aceEdiotr 2 paste");
+ // 原来这里focus了
+ setTimeout(function() {
+ ace[0].focus();
+ });
+ return true;
+ }
+ return false;
+ }
- editor.on('keydown', function(e) {
- if (e.isDefaultPrevented()) {
- return;
- }
+ editor.on('keydown', function(e) {
+ if (e.isDefaultPrevented()) {
+ return;
+ }
- // Ctrl+V or Shift+Insert
- if ((VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) {
+ // Ctrl+V or Shift+Insert
+ if ((VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) {
- if(inAcePrevent()) {
- return;
- }
+ if(inAcePrevent()) {
+ return;
+ }
- keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
+ keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
- // Prevent undoManager keydown handler from making an undo level with the pastebin in it
- e.stopImmediatePropagation();
+ // Prevent undoManager keydown handler from making an undo level with the pastebin in it
+ e.stopImmediatePropagation();
- keyboardPasteTimeStamp = new Date().getTime();
+ keyboardPasteTimeStamp = new Date().getTime();
- // IE doesn't support Ctrl+Shift+V and it doesn't even produce a paste event
- // so lets fake a paste event and let IE use the execCommand/dataTransfer methods
- if (Env.ie && keyboardPastePlainTextState) {
- e.preventDefault();
- editor.fire('paste', {ieFake: true});
- return;
- }
+ // IE doesn't support Ctrl+Shift+V and it doesn't even produce a paste event
+ // so lets fake a paste event and let IE use the execCommand/dataTransfer methods
+ if (Env.ie && keyboardPastePlainTextState) {
+ e.preventDefault();
+ editor.fire('paste', {ieFake: true});
+ return;
+ }
- createPasteBin();
- }
- });
-
- // 当url改变时, 得到图片的大小 copy from leanote_image
- function getImageSize(url, callback) {
- var img = document.createElement('img');
-
- function done(width, height) {
- img.parentNode.removeChild(img);
- callback({width: width, height: height});
- }
-
- img.onload = function() {
- done(img.clientWidth, img.clientHeight);
- };
-
- img.onerror = function() {
- done();
- };
-
- img.src = url;
-
- var style = img.style;
- style.visibility = 'hidden';
- style.position = 'fixed';
- style.bottom = style.left = 0;
- style.width = style.height = 'auto';
-
- document.body.appendChild(img);
- }
+ createPasteBin();
+ }
+ });
+
+ // 当url改变时, 得到图片的大小 copy from leanote_image
+ function getImageSize(url, callback) {
+ var img = document.createElement('img');
+
+ function done(width, height) {
+ img.parentNode.removeChild(img);
+ callback({width: width, height: height});
+ }
+
+ img.onload = function() {
+ done(img.clientWidth, img.clientHeight);
+ };
+
+ img.onerror = function() {
+ done();
+ };
+
+ img.src = url;
+
+ var style = img.style;
+ style.visibility = 'hidden';
+ style.position = 'fixed';
+ style.bottom = style.left = 0;
+ style.width = style.height = 'auto';
+
+ document.body.appendChild(img);
+ }
- var ever;
- editor.on('paste', function(e) {
- if(inAcePrevent()) {
- return;
- }
+ // 是否有图片的粘贴, 有则删除paste bin
+ // 因为paste bin隐藏不见了, 如果不删除, 则editor_drop_paste的图片就会在这个bin下
+ // 而且, paste bin最后会删除, 导致图片不能显示
+ function hasImage(event) {
+ var items;
+ if (event.clipboardData) {
+ items = event.clipboardData.items;
+ }
+ else if(event.originalEvent && event.originalEvent.clipboardData) {
+ items = event.originalEvent.clipboardData;
+ }
+ if (!items) {
+ return false;
+ }
+ // find pasted image among pasted items
+ for (var i = 0; i < items.length; i++) {
+ if (items[i].type.indexOf("image") === 0) {
+ return true;
+ }
+ }
+ return false;
+ }
- // start
- // 以下只是linux需要
- // -----
- // 为什么要这个, 因为linux的原因, pasteImage会触发paste事件, 导致多次复制
- if (ever && new Date().getTime() - ever < 100) {
- e.preventDefault();
- return;
- }
- ever = new Date().getTime();
- // end
+ var ever;
+ editor.on('paste', function(e) {
+ if(inAcePrevent()) {
+ return;
+ }
- var clipboardContent = getClipboardContent(e);
- var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp < 100;
- var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState;
+ if (hasImage(e)) {
+ removePasteBin();
+ // 不然会在内容中插入一个图片,
+ e.preventDefault();
+ //-----------
+ // paste image
+ try {
+ // common.js
+ pasteImage(e);
+ return;
+ } catch(e) {
+ console.error(e);
+ };
+ return;
+ }
- // Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
- if (!isKeyBoardPaste) {
- e.preventDefault();
- }
+ // start
+ // 以下只是linux需要
+ // -----
+ // 为什么要这个, 因为linux的原因, pasteImage会触发paste事件, 导致多次复制
+ if (ever && new Date().getTime() - ever < 100) {
+ e.preventDefault();
+ return;
+ }
+ ever = new Date().getTime();
+ // end
- // Try IE only method if paste isn't a keyboard paste
- if (Env.ie && (!isKeyBoardPaste || e.ieFake)) {
- createPasteBin();
+ var clipboardContent = getClipboardContent(e);
+ var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp < 100;
+ var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState;
- editor.dom.bind(pasteBinElm, 'paste', function(e) {
- e.stopPropagation();
- });
+ // Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
+ if (!isKeyBoardPaste) {
+ e.preventDefault();
+ }
- editor.getDoc().execCommand('Paste', false, null);
- clipboardContent["text/html"] = getPasteBinHtml();
- removePasteBin();
- }
+ // Try IE only method if paste isn't a keyboard paste
+ if (Env.ie && (!isKeyBoardPaste || e.ieFake)) {
+ createPasteBin();
- setTimeout(function() {
- var html = getPasteBinHtml();
+ editor.dom.bind(pasteBinElm, 'paste', function(e) {
+ e.stopPropagation();
+ });
- // WebKit has a nice bug where it clones the paste bin if you paste from for example notepad
- if (pasteBinElm && pasteBinElm.firstChild && pasteBinElm.firstChild.id === 'mcepastebin') {
- plainTextMode = true;
- }
+ editor.getDoc().execCommand('Paste', false, null);
+ clipboardContent["text/html"] = getPasteBinHtml();
+ removePasteBin();
+ }
- removePasteBin();
+ setTimeout(function() {
+ var html = getPasteBinHtml();
- if (html == pasteBinDefaultContent || !isKeyBoardPaste) {
- html = clipboardContent['text/html'] || clipboardContent['text/plain'] || pasteBinDefaultContent;
+ // WebKit has a nice bug where it clones the paste bin if you paste from for example notepad
+ if (pasteBinElm && pasteBinElm.firstChild && pasteBinElm.firstChild.id === 'mcepastebin') {
+ plainTextMode = true;
+ }
- if (html == pasteBinDefaultContent) {
- if (!isKeyBoardPaste) {
- // editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
- }
- return;
- }
- }
+ removePasteBin();
- if (plainTextMode) {
- pasteText(clipboardContent['text/plain'] || Utils.innerText(html));
- } else {
- // life
- pasteHtml(html, clipboardContent['text/plain']);
- }
- }, 0);
-
- //-----------
- // paste image
- try {
- // common.js
- pasteImage(e);
- return;
- /*
- if(pasteImage(e)) {
- return;
- }
- */
- } catch(e) {
- console.error(e);
- };
+ if (html == pasteBinDefaultContent || !isKeyBoardPaste) {
+ html = clipboardContent['text/html'] || clipboardContent['text/plain'] || pasteBinDefaultContent;
- });
-
-
+ if (html == pasteBinDefaultContent) {
+ if (!isKeyBoardPaste) {
+ // editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
+ }
+ return;
+ }
+ }
- self.pasteHtml = pasteHtml;
- self.pasteText = pasteText;
- };
+ if (plainTextMode) {
+ pasteText(clipboardContent['text/plain'] || Utils.innerText(html));
+ } else {
+ // life
+ pasteHtml(html, clipboardContent['text/plain']);
+ }
+ }, 0);
+
+ try {
+ // common.js
+ pasteImage(e);
+ return;
+ } catch(e) {
+ console.error(e);
+ };
+
+ });
+
+
+
+ self.pasteHtml = pasteHtml;
+ self.pasteText = pasteText;
+ };
});
// Included from: js/tinymce/plugins/paste/classes/WordFilter.js
@@ -634,251 +666,251 @@ define("tinymce/pasteplugin/Clipboard", [
* @private
*/
define("tinymce/pasteplugin/WordFilter", [
- "tinymce/util/Tools",
- "tinymce/html/DomParser",
- "tinymce/html/Schema",
- "tinymce/html/Serializer",
- "tinymce/html/Node",
- "tinymce/pasteplugin/Utils"
+ "tinymce/util/Tools",
+ "tinymce/html/DomParser",
+ "tinymce/html/Schema",
+ "tinymce/html/Serializer",
+ "tinymce/html/Node",
+ "tinymce/pasteplugin/Utils"
], function(Tools, DomParser, Schema, Serializer, Node, Utils) {
- function isWordContent(content) {
- return (/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i).test(content);
- }
+ function isWordContent(content) {
+ return (/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i).test(content);
+ }
- function WordFilter(editor) {
- var settings = editor.settings;
+ function WordFilter(editor) {
+ var settings = editor.settings;
- editor.on('BeforePastePreProcess', function(e) {
- var content = e.content, retainStyleProperties, validStyles;
+ editor.on('BeforePastePreProcess', function(e) {
+ var content = e.content, retainStyleProperties, validStyles;
- retainStyleProperties = settings.paste_retain_style_properties;
- if (retainStyleProperties) {
- validStyles = Tools.makeMap(retainStyleProperties);
- }
+ retainStyleProperties = settings.paste_retain_style_properties;
+ if (retainStyleProperties) {
+ validStyles = Tools.makeMap(retainStyleProperties);
+ }
- /**
- * Converts fake bullet and numbered lists to real semantic OL/UL.
- *
- * @param {tinymce.html.Node} node Root node to convert children of.
- */
- function convertFakeListsToProperLists(node) {
- var currentListNode, prevListNode, lastLevel = 1;
+ /**
+ * Converts fake bullet and numbered lists to real semantic OL/UL.
+ *
+ * @param {tinymce.html.Node} node Root node to convert children of.
+ */
+ function convertFakeListsToProperLists(node) {
+ var currentListNode, prevListNode, lastLevel = 1;
- function convertParagraphToLi(paragraphNode, listStartTextNode, listName, start) {
- var level = paragraphNode._listLevel || lastLevel;
+ function convertParagraphToLi(paragraphNode, listStartTextNode, listName, start) {
+ var level = paragraphNode._listLevel || lastLevel;
- // Handle list nesting
- if (level != lastLevel) {
- if (level < lastLevel) {
- // Move to parent list
- if (currentListNode) {
- currentListNode = currentListNode.parent.parent;
- }
- } else {
- // Create new list
- prevListNode = currentListNode;
- currentListNode = null;
- }
- }
+ // Handle list nesting
+ if (level != lastLevel) {
+ if (level < lastLevel) {
+ // Move to parent list
+ if (currentListNode) {
+ currentListNode = currentListNode.parent.parent;
+ }
+ } else {
+ // Create new list
+ prevListNode = currentListNode;
+ currentListNode = null;
+ }
+ }
- if (!currentListNode || currentListNode.name != listName) {
- prevListNode = prevListNode || currentListNode;
- currentListNode = new Node(listName, 1);
+ if (!currentListNode || currentListNode.name != listName) {
+ prevListNode = prevListNode || currentListNode;
+ currentListNode = new Node(listName, 1);
- if (start > 1) {
- currentListNode.attr('start', '' + start);
- }
+ if (start > 1) {
+ currentListNode.attr('start', '' + start);
+ }
- paragraphNode.wrap(currentListNode);
- } else {
- currentListNode.append(paragraphNode);
- }
+ paragraphNode.wrap(currentListNode);
+ } else {
+ currentListNode.append(paragraphNode);
+ }
- paragraphNode.name = 'li';
- listStartTextNode.value = '';
+ paragraphNode.name = 'li';
+ listStartTextNode.value = '';
- var nextNode = listStartTextNode.next;
- if (nextNode && nextNode.type == 3) {
- nextNode.value = nextNode.value.replace(/^\u00a0+/, '');
- }
+ var nextNode = listStartTextNode.next;
+ if (nextNode && nextNode.type == 3) {
+ nextNode.value = nextNode.value.replace(/^\u00a0+/, '');
+ }
- // Append list to previous list if it exists
- if (level > lastLevel && prevListNode) {
- prevListNode.lastChild.append(currentListNode);
- }
+ // Append list to previous list if it exists
+ if (level > lastLevel && prevListNode) {
+ prevListNode.lastChild.append(currentListNode);
+ }
- lastLevel = level;
- }
+ lastLevel = level;
+ }
- var paragraphs = node.getAll('p');
+ var paragraphs = node.getAll('p');
- for (var i = 0; i < paragraphs.length; i++) {
- node = paragraphs[i];
+ for (var i = 0; i < paragraphs.length; i++) {
+ node = paragraphs[i];
- if (node.name == 'p' && node.firstChild) {
- // Find first text node in paragraph
- var nodeText = '';
- var listStartTextNode = node.firstChild;
+ if (node.name == 'p' && node.firstChild) {
+ // Find first text node in paragraph
+ var nodeText = '';
+ var listStartTextNode = node.firstChild;
- while (listStartTextNode) {
- nodeText = listStartTextNode.value;
- if (nodeText) {
- break;
- }
+ while (listStartTextNode) {
+ nodeText = listStartTextNode.value;
+ if (nodeText) {
+ break;
+ }
- listStartTextNode = listStartTextNode.firstChild;
- }
+ listStartTextNode = listStartTextNode.firstChild;
+ }
- // Detect unordered lists look for bullets
- if (/^\s*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*$/.test(nodeText)) {
- convertParagraphToLi(node, listStartTextNode, 'ul');
- continue;
- }
+ // Detect unordered lists look for bullets
+ if (/^\s*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*$/.test(nodeText)) {
+ convertParagraphToLi(node, listStartTextNode, 'ul');
+ continue;
+ }
- // Detect ordered lists 1., a. or ixv.
- if (/^\s*\w+\.$/.test(nodeText)) {
- // Parse OL start number
- var matches = /([0-9])\./.exec(nodeText);
- var start = 1;
- if (matches) {
- start = parseInt(matches[1], 10);
- }
+ // Detect ordered lists 1., a. or ixv.
+ if (/^\s*\w+\.$/.test(nodeText)) {
+ // Parse OL start number
+ var matches = /([0-9])\./.exec(nodeText);
+ var start = 1;
+ if (matches) {
+ start = parseInt(matches[1], 10);
+ }
- convertParagraphToLi(node, listStartTextNode, 'ol', start);
- continue;
- }
+ convertParagraphToLi(node, listStartTextNode, 'ol', start);
+ continue;
+ }
- currentListNode = null;
- }
- }
- }
+ currentListNode = null;
+ }
+ }
+ }
- function filterStyles(node, styleValue) {
- // Parse out list indent level for lists
- if (node.name === 'p') {
- var matches = /mso-list:\w+ \w+([0-9]+)/.exec(styleValue);
+ function filterStyles(node, styleValue) {
+ // Parse out list indent level for lists
+ if (node.name === 'p') {
+ var matches = /mso-list:\w+ \w+([0-9]+)/.exec(styleValue);
- if (matches) {
- node._listLevel = parseInt(matches[1], 10);
- }
- }
+ if (matches) {
+ node._listLevel = parseInt(matches[1], 10);
+ }
+ }
- if (editor.getParam("paste_retain_style_properties", "none")) {
- var outputStyle = "";
+ if (editor.getParam("paste_retain_style_properties", "none")) {
+ var outputStyle = "";
- Tools.each(editor.dom.parseStyle(styleValue), function(value, name) {
- // Convert various MS styles to W3C styles
- switch (name) {
- case "horiz-align":
- name = "text-align";
- return;
+ Tools.each(editor.dom.parseStyle(styleValue), function(value, name) {
+ // Convert various MS styles to W3C styles
+ switch (name) {
+ case "horiz-align":
+ name = "text-align";
+ return;
- case "vert-align":
- name = "vertical-align";
- return;
+ case "vert-align":
+ name = "vertical-align";
+ return;
- case "font-color":
- case "mso-foreground":
- name = "color";
- return;
+ case "font-color":
+ case "mso-foreground":
+ name = "color";
+ return;
- case "mso-background":
- case "mso-highlight":
- name = "background";
- break;
- }
+ case "mso-background":
+ case "mso-highlight":
+ name = "background";
+ break;
+ }
- // Output only valid styles
- if (retainStyleProperties == "all" || (validStyles && validStyles[name])) {
- outputStyle += name + ':' + value + ';';
- }
- });
+ // Output only valid styles
+ if (retainStyleProperties == "all" || (validStyles && validStyles[name])) {
+ outputStyle += name + ':' + value + ';';
+ }
+ });
- if (outputStyle) {
- return outputStyle;
- }
- }
+ if (outputStyle) {
+ return outputStyle;
+ }
+ }
- return null;
- }
+ return null;
+ }
- if (settings.paste_enable_default_filters === false) {
- return;
- }
+ if (settings.paste_enable_default_filters === false) {
+ return;
+ }
- // Detect is the contents is Word junk HTML
- if (isWordContent(e.content)) {
- e.wordContent = true; // Mark it for other processors
+ // Detect is the contents is Word junk HTML
+ if (isWordContent(e.content)) {
+ e.wordContent = true; // Mark it for other processors
- // Remove basic Word junk
- content = Utils.filter(content, [
- // Word comments like conditional comments etc
- //gi,
+ // Remove basic Word junk
+ content = Utils.filter(content, [
+ // Word comments like conditional comments etc
+ //gi,
- // Remove comments, scripts (e.g., msoShowComment), XML tag, VML content,
- // MS Office namespaced tags, and a few other tags
- /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
+ // Remove comments, scripts (e.g., msoShowComment), XML tag, VML content,
+ // MS Office namespaced tags, and a few other tags
+ /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
- // Convert a b a b a b a b into for line-though
- [/<(\/?)s>/gi, "<$1strike>"],
+ // Convert into for line-though
+ [/<(\/?)s>/gi, "<$1strike>"],
- // Replace nsbp entites to char since it's easier to handle
- [/ /gi, "\u00a0"],
+ // Replace nsbp entites to char since it's easier to handle
+ [/ /gi, "\u00a0"],
- // Convert ___ to string of alternating
- // breaking/non-breaking spaces of same length
- [/([\s\u00a0]*)<\/span>/gi,
- function(str, spaces) {
- return (spaces.length > 0) ?
- spaces.replace(/./, " ").slice(Math.floor(spaces.length/2)).split("").join("\u00a0") : "";
- }
- ]
- ]);
+ // Convert ___ to string of alternating
+ // breaking/non-breaking spaces of same length
+ [/([\s\u00a0]*)<\/span>/gi,
+ function(str, spaces) {
+ return (spaces.length > 0) ?
+ spaces.replace(/./, " ").slice(Math.floor(spaces.length/2)).split("").join("\u00a0") : "";
+ }
+ ]
+ ]);
- var validElements = settings.paste_word_valid_elements;
- if (!validElements) {
- validElements = '@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' +
- '-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br';
- }
+ var validElements = settings.paste_word_valid_elements;
+ if (!validElements) {
+ validElements = '@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' +
+ '-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br';
+ }
- // Setup strict schema
- var schema = new Schema({
- valid_elements: validElements
- });
+ // Setup strict schema
+ var schema = new Schema({
+ valid_elements: validElements
+ });
- // Parse HTML into DOM structure
- var domParser = new DomParser({}, schema);
+ // Parse HTML into DOM structure
+ var domParser = new DomParser({}, schema);
- // Filte element style attributes
- domParser.addAttributeFilter('style', function(nodes) {
- var i = nodes.length, node;
+ // Filte element style attributes
+ domParser.addAttributeFilter('style', function(nodes) {
+ var i = nodes.length, node;
- while (i--) {
- node = nodes[i];
- node.attr('style', filterStyles(node, node.attr('style')));
+ while (i--) {
+ node = nodes[i];
+ node.attr('style', filterStyles(node, node.attr('style')));
- // Remove pointess spans
- if (node.name == 'span' && !node.attributes.length) {
- node.unwrap();
- }
- }
- });
+ // Remove pointess spans
+ if (node.name == 'span' && !node.attributes.length) {
+ node.unwrap();
+ }
+ }
+ });
- // Parse into DOM structure
- var rootNode = domParser.parse(content);
+ // Parse into DOM structure
+ var rootNode = domParser.parse(content);
- // Process DOM
- convertFakeListsToProperLists(rootNode);
+ // Process DOM
+ convertFakeListsToProperLists(rootNode);
- // Serialize DOM back to HTML
- e.content = new Serializer({}, schema).serialize(rootNode);
- }
- });
- }
+ // Serialize DOM back to HTML
+ e.content = new Serializer({}, schema).serialize(rootNode);
+ }
+ });
+ }
- WordFilter.isWordContent = isWordContent;
+ WordFilter.isWordContent = isWordContent;
- return WordFilter;
+ return WordFilter;
});
// Included from: js/tinymce/plugins/paste/classes/Quirks.js
@@ -902,109 +934,109 @@ define("tinymce/pasteplugin/WordFilter", [
* @private
*/
define("tinymce/pasteplugin/Quirks", [
- "tinymce/Env",
- "tinymce/util/Tools",
- "tinymce/pasteplugin/WordFilter",
- "tinymce/pasteplugin/Utils"
+ "tinymce/Env",
+ "tinymce/util/Tools",
+ "tinymce/pasteplugin/WordFilter",
+ "tinymce/pasteplugin/Utils"
], function(Env, Tools, WordFilter, Utils) {
- "use strict";
+ "use strict";
- return function(editor) {
- function addPreProcessFilter(filterFunc) {
- editor.on('BeforePastePreProcess', function(e) {
- e.content = filterFunc(e.content);
- });
- }
+ return function(editor) {
+ function addPreProcessFilter(filterFunc) {
+ editor.on('BeforePastePreProcess', function(e) {
+ e.content = filterFunc(e.content);
+ });
+ }
- /**
- * Removes WebKit fragment comments and converted-space spans.
- *
- * This:
- * a b
- *
- * Becomes:
- * a b
- */
- function removeWebKitFragments(html) {
- html = Utils.filter(html, [
- /^[\s\S]*|[\s\S]*$/g, // WebKit fragment
- [/\u00a0<\/span>/g, '\u00a0'], // WebKit
- /
$/ // Traling BR elements
- ]);
+ /**
+ * Removes WebKit fragment comments and converted-space spans.
+ *
+ * This:
+ * a b
+ *
+ * Becomes:
+ * a b
+ */
+ function removeWebKitFragments(html) {
+ html = Utils.filter(html, [
+ /^[\s\S]*|[\s\S]*$/g, // WebKit fragment
+ [/\u00a0<\/span>/g, '\u00a0'], // WebKit
+ /
$/ // Traling BR elements
+ ]);
- return html;
- }
+ return html;
+ }
- /**
- * Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
- * block element when pasting from word. This removes those elements.
- *
- * This:
- *
[\\s\\r\\n]+|
)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:
[\\s\\r\\n]+|
)*',
- 'g'
- );
+ var explorerBlocksRegExp = new RegExp(
+ '(?:
[\\s\\r\\n]+|
)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:
[\\s\\r\\n]+|
)*',
+ 'g'
+ );
- // Remove BR:s from:
- html = Utils.filter(html, [
- [explorerBlocksRegExp, '$1']
- ]);
+ // Remove BR:s from:
+ html = Utils.filter(html, [
+ [explorerBlocksRegExp, '$1']
+ ]);
- // IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
- html = Utils.filter(html, [
- [/
/g, '
'], // Replace multiple BR elements with uppercase BR to keep them intact
- [/
/g, ' '], // Replace single br elements with space since they are word wrap BR:s
- [/
/g, '
'] // Replace back the double brs but into a single BR
- ]);
+ // IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
+ html = Utils.filter(html, [
+ [/
/g, '
'], // Replace multiple BR elements with uppercase BR to keep them intact
+ [/
/g, ' '], // Replace single br elements with space since they are word wrap BR:s
+ [/
/g, '
'] // Replace back the double brs but into a single BR
+ ]);
- return html;
- }
+ return html;
+ }
- /**
- * WebKit has a nasty bug where the all runtime styles gets added to style attributes when copy/pasting contents.
- * This fix solves that by simply removing the whole style attribute.
- *
- * Todo: This can be made smarter. Keeping styles that override existing ones etc.
- *
- * @param {String} content Content that needs to be processed.
- * @return {String} Processed contents.
- */
- function removeWebKitStyles(content) {
- if (editor.settings.paste_remove_styles || editor.settings.paste_remove_styles_if_webkit !== false) {
- content = content.replace(/ style=\"[^\"]+\"/g, '');
- }
+ /**
+ * WebKit has a nasty bug where the all runtime styles gets added to style attributes when copy/pasting contents.
+ * This fix solves that by simply removing the whole style attribute.
+ *
+ * Todo: This can be made smarter. Keeping styles that override existing ones etc.
+ *
+ * @param {String} content Content that needs to be processed.
+ * @return {String} Processed contents.
+ */
+ function removeWebKitStyles(content) {
+ if (editor.settings.paste_remove_styles || editor.settings.paste_remove_styles_if_webkit !== false) {
+ content = content.replace(/ style=\"[^\"]+\"/g, '');
+ }
- return content;
- }
+ return content;
+ }
- // Sniff browsers and apply fixes since we can't feature detect
- if (Env.webkit) {
- addPreProcessFilter(removeWebKitStyles);
- addPreProcessFilter(removeWebKitFragments);
- }
+ // Sniff browsers and apply fixes since we can't feature detect
+ if (Env.webkit) {
+ addPreProcessFilter(removeWebKitStyles);
+ addPreProcessFilter(removeWebKitFragments);
+ }
- if (Env.ie) {
- addPreProcessFilter(removeExplorerBrElementsAfterBlocks);
- }
- };
+ if (Env.ie) {
+ addPreProcessFilter(removeExplorerBrElementsAfterBlocks);
+ }
+ };
});
// Included from: js/tinymce/plugins/paste/classes/Plugin.js
@@ -1026,100 +1058,100 @@ define("tinymce/pasteplugin/Quirks", [
* @private
*/
define("tinymce/pasteplugin/Plugin", [
- "tinymce/PluginManager",
- "tinymce/pasteplugin/Clipboard",
- "tinymce/pasteplugin/WordFilter",
- "tinymce/pasteplugin/Quirks"
+ "tinymce/PluginManager",
+ "tinymce/pasteplugin/Clipboard",
+ "tinymce/pasteplugin/WordFilter",
+ "tinymce/pasteplugin/Quirks"
], function(PluginManager, Clipboard, WordFilter, Quirks) {
- var userIsInformed;
- var userIsInformed2;
+ var userIsInformed;
+ var userIsInformed2;
- PluginManager.add('paste', function(editor) {
- var self = this, clipboard, settings = editor.settings;
+ PluginManager.add('paste', function(editor) {
+ var self = this, clipboard, settings = editor.settings;
- function togglePlainTextPaste() {
- if (clipboard.pasteFormat == "text") {
- this.active(false);
- clipboard.pasteFormat = "html";
- } else {
- clipboard.pasteFormat = "text";
- this.active(true);
+ function togglePlainTextPaste() {
+ if (clipboard.pasteFormat == "text") {
+ this.active(false);
+ clipboard.pasteFormat = "html";
+ } else {
+ clipboard.pasteFormat = "text";
+ this.active(true);
- if (!userIsInformed) {
- editor.windowManager.alert(
- 'Paste is now in plain text mode. Contents will now ' +
- 'be pasted as plain text until you toggle this option off.'
- );
+ if (!userIsInformed) {
+ editor.windowManager.alert(
+ 'Paste is now in plain text mode. Contents will now ' +
+ 'be pasted as plain text until you toggle this option off.'
+ );
- userIsInformed = true;
- }
- }
- }
+ userIsInformed = true;
+ }
+ }
+ }
- self.clipboard = clipboard = new Clipboard(editor);
- self.quirks = new Quirks(editor);
- self.wordFilter = new WordFilter(editor);
- clipboard.copyImage = true;
+ self.clipboard = clipboard = new Clipboard(editor);
+ self.quirks = new Quirks(editor);
+ self.wordFilter = new WordFilter(editor);
+ clipboard.copyImage = true;
- if (editor.settings.paste_as_text) {
- self.clipboard.pasteFormat = "text";
- }
+ if (editor.settings.paste_as_text) {
+ self.clipboard.pasteFormat = "text";
+ }
- if (settings.paste_preprocess) {
- editor.on('PastePreProcess', function(e) {
- settings.paste_preprocess.call(self, self, e);
- });
- }
+ if (settings.paste_preprocess) {
+ editor.on('PastePreProcess', function(e) {
+ settings.paste_preprocess.call(self, self, e);
+ });
+ }
- if (settings.paste_postprocess) {
- editor.on('PastePostProcess', function(e) {
- settings.paste_postprocess.call(self, self, e);
- });
- }
+ if (settings.paste_postprocess) {
+ editor.on('PastePostProcess', function(e) {
+ settings.paste_postprocess.call(self, self, e);
+ });
+ }
- editor.addCommand('mceInsertClipboardContent', function(ui, value) {
- if (value.content) {
- self.clipboard.pasteHtml(value.content);
- }
+ editor.addCommand('mceInsertClipboardContent', function(ui, value) {
+ if (value.content) {
+ self.clipboard.pasteHtml(value.content);
+ }
- if (value.text) {
- self.clipboard.pasteText(value.text);
- }
- });
+ if (value.text) {
+ self.clipboard.pasteText(value.text);
+ }
+ });
- // Block all drag/drop events
- if (editor.paste_block_drop) {
- editor.on('dragend dragover draggesture dragdrop drop drag', function(e) {
- e.preventDefault();
- e.stopPropagation();
- });
- }
+ // Block all drag/drop events
+ if (editor.paste_block_drop) {
+ editor.on('dragend dragover draggesture dragdrop drop drag', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ });
+ }
- // Prevent users from dropping data images on Gecko
- if (!editor.settings.paste_data_images) {
- editor.on('drop', function(e) {
- var dataTransfer = e.dataTransfer;
+ // Prevent users from dropping data images on Gecko
+ if (!editor.settings.paste_data_images) {
+ editor.on('drop', function(e) {
+ var dataTransfer = e.dataTransfer;
- if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
- e.preventDefault();
- }
- });
- }
+ if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
+ e.preventDefault();
+ }
+ });
+ }
- editor.addButton('pastetext', {
- icon: 'pastetext',
- tooltip: 'Paste as text',
- onclick: togglePlainTextPaste,
- active: self.clipboard.pasteFormat == "text"
- });
+ editor.addButton('pastetext', {
+ icon: 'pastetext',
+ tooltip: 'Paste as text',
+ onclick: togglePlainTextPaste,
+ active: self.clipboard.pasteFormat == "text"
+ });
- editor.addMenuItem('pastetext', {
- text: 'Paste as text',
- selectable: true,
- active: clipboard.pasteFormat,
- onclick: togglePlainTextPaste
- });
- });
+ editor.addMenuItem('pastetext', {
+ text: 'Paste as text',
+ selectable: true,
+ active: clipboard.pasteFormat,
+ onclick: togglePlainTextPaste
+ });
+ });
});
expose(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/WordFilter"]);
diff --git a/public/tinymce/plugins/paste/plugin.min.js b/public/tinymce/plugins/paste/plugin.min.js
index 209001db..86c6caf2 100644
--- a/public/tinymce/plugins/paste/plugin.min.js
+++ b/public/tinymce/plugins/paste/plugin.min.js
@@ -1 +1 @@
-!function(a,b){"use strict";function c(a,b){for(var c,d=[],f=0;f
"]]):(a=c.filter(a,[[/\n\n/g,"
)$/,e+"$1"],[/\n/g,"
"]]),-1!=a.indexOf("
")&&(a=e+a)),f(a,b)}function h(){var a=d.dom,b=d.getBody(),c=d.dom.getViewPort(d.getWin()),e=d.inline?b.scrollTop:c.y,f=d.inline?b.clientHeight:c.h;i(),m=a.add(d.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(e+20)+"px;width: 10px; height: "+(f-40)+"px; overflow: hidden; opacity: 0"},r),a.setStyle(m,"left","rtl"==a.getStyle(b,"direction",!0)?65535:-65535),a.bind(m,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),n=d.selection.getRng(),m.focus(),d.selection.select(m,!0)}function i(){m&&(d.dom.unbind(m),d.dom.remove(m),n&&d.selection.setRng(n)),o=!1,m=n=null}function j(){return m?m.innerHTML:r}function k(a){var b={},c=a.clipboardData||d.getDoc().dataTransfer;if(c&&c.types){b["text/plain"]=c.getData("Text");for(var e=0;e
$/])}function h(a){if(!c.isWordContent(a))return a;var f=[];b.each(e.schema.getBlockElements(),function(a,b){f.push(b)});var g=new RegExp("(?:
[\\s\\r\\n]+|
)*(<\\/?("+f.join("|")+")[^>]*>)(?:
[\\s\\r\\n]+|
)*","g");return a=d.filter(a,[[g,"$1"]]),a=d.filter(a,[[/
/g,"
"],[/
/g," "],[/
/g,"
"]])}function i(a){return(e.settings.paste_remove_styles||e.settings.paste_remove_styles_if_webkit!==!1)&&(a=a.replace(/ style=\"[^\"]+\"/g,"")),a}a.webkit&&(f(i),f(g)),a.ie&&f(h)}}),d("tinymce/pasteplugin/Plugin",["tinymce/PluginManager","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks"],function(a,b,c,d){var e;a.add("paste",function(a){function f(){"text"==g.pasteFormat?(this.active(!1),g.pasteFormat="html"):(g.pasteFormat="text",this.active(!0),e||(a.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),e=!0))}var g,h=this,i=a.settings;h.clipboard=g=new b(a),h.quirks=new d(a),h.wordFilter=new c(a),g.copyImage=!0,a.settings.paste_as_text&&(h.clipboard.pasteFormat="text"),i.paste_preprocess&&a.on("PastePreProcess",function(a){i.paste_preprocess.call(h,h,a)}),i.paste_postprocess&&a.on("PastePostProcess",function(a){i.paste_postprocess.call(h,h,a)}),a.addCommand("mceInsertClipboardContent",function(a,b){b.content&&h.clipboard.pasteHtml(b.content),b.text&&h.clipboard.pasteText(b.text)}),a.paste_block_drop&&a.on("dragend dragover draggesture dragdrop drop drag",function(a){a.preventDefault(),a.stopPropagation()}),a.settings.paste_data_images||a.on("drop",function(a){var b=a.dataTransfer;b&&b.files&&b.files.length>0&&a.preventDefault()}),a.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:f,active:"text"==h.clipboard.pasteFormat}),a.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:g.pasteFormat,onclick:f})})}),f(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/WordFilter"])}(this);
\ No newline at end of file
+!function(a,b){"use strict";function c(a,b){for(var c,d=[],f=0;f
"]]):(a=c.filter(a,[[/\n\n/g,"
)$/,e+"$1"],[/\n/g,"
"]]),-1!=a.indexOf("
")&&(a=e+a)),f(a,b)}function h(){var a=d.dom,b=d.getBody(),c=d.dom.getViewPort(d.getWin()),e=d.inline?b.scrollTop:c.y,f=d.inline?b.clientHeight:c.h;i(),n=a.add(d.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(e+20)+"px;width: 10px; height: "+(f-40)+"px; overflow: hidden; opacity: 0"},s),a.setStyle(n,"left","rtl"==a.getStyle(b,"direction",!0)?65535:-65535),a.bind(n,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),o=d.selection.getRng(),n.focus(),d.selection.select(n,!0)}function i(){n&&(d.dom.unbind(n),d.dom.remove(n),o&&d.selection.setRng(o)),p=!1,n=o=null}function j(){return n?n.innerHTML:s}function k(a){var b={},c=a.clipboardData||d.getDoc().dataTransfer;if(c&&c.types){b["text/plain"]=c.getData("Text");for(var e=0;e
- var forcedRootBlockName = editor.settings.forced_root_block;
- var forcedRootBlockStartHtml;
- if (forcedRootBlockName) {
- forcedRootBlockStartHtml = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs);
- forcedRootBlockStartHtml = forcedRootBlockStartHtml.substr(0, forcedRootBlockStartHtml.length - 3) + '>';
- }
+ // Create start block html for example
+ var forcedRootBlockName = editor.settings.forced_root_block;
+ var forcedRootBlockStartHtml;
+ if (forcedRootBlockName) {
+ forcedRootBlockStartHtml = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs);
+ forcedRootBlockStartHtml = forcedRootBlockStartHtml.substr(0, forcedRootBlockStartHtml.length - 3) + '>';
+ }
- if ((startBlock && /^(PRE|DIV)$/.test(startBlock.nodeName)) || !forcedRootBlockName) {
- text = Utils.filter(text, [
- [/\n/g, " )$/, forcedRootBlockStartHtml + '$1'],
- [/\n/g, " )$/, forcedRootBlockStartHtml + '$1'],
+ [/\n/g, " ') != -1) {
- text = forcedRootBlockStartHtml + text;
- }
- }
+ if (text.indexOf(' ') != -1) {
+ text = forcedRootBlockStartHtml + text;
+ }
+ }
- pasteHtml(text, text2);
- }
-
- /**
- * Creates a paste bin element and moves the selection into that element. It will also move the element offscreen
- * so that resize handles doesn't get produced on IE or Drag handles or Firefox.
- */
- function createPasteBin() {
- var dom = editor.dom, body = editor.getBody(), viewport = editor.dom.getViewPort(editor.getWin());
- var scrollY = editor.inline ? body.scrollTop : viewport.y, height = editor.inline ? body.clientHeight : viewport.h;
+ pasteHtml(text, text2);
+ }
+
+ /**
+ * Creates a paste bin element and moves the selection into that element. It will also move the element offscreen
+ * so that resize handles doesn't get produced on IE or Drag handles or Firefox.
+ */
+ function createPasteBin() {
+ var dom = editor.dom, body = editor.getBody(), viewport = editor.dom.getViewPort(editor.getWin());
+ var scrollY = editor.inline ? body.scrollTop : viewport.y, height = editor.inline ? body.clientHeight : viewport.h;
- removePasteBin();
+ removePasteBin();
- // Create a pastebin
- pasteBinElm = dom.add(editor.getBody(), 'div', {
- id: "mcepastebin",
- contentEditable: true,
- "data-mce-bogus": "1",
- style: 'position: absolute; top: ' + (scrollY + 20) + 'px;' +
- 'width: 10px; height: ' + (height - 40) + 'px; overflow: hidden; opacity: 0'
- }, pasteBinDefaultContent);
+ // Create a pastebin
+ pasteBinElm = dom.add(editor.getBody(), 'div', {
+ id: "mcepastebin",
+ contentEditable: true,
+ "data-mce-bogus": "1",
+ style: 'position: absolute; top: ' + (scrollY + 20) + 'px;' +
+ 'width: 10px; height: ' + (height - 40) + 'px; overflow: hidden; opacity: 0'
+ }, pasteBinDefaultContent);
- // Move paste bin out of sight since the controlSelection rect gets displayed otherwise
- dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
+ // Move paste bin out of sight since the controlSelection rect gets displayed otherwise
+ dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
- // Prevent focus events from bubbeling fixed FocusManager issues
- dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function(e) {
- e.stopPropagation();
- });
+ // Prevent focus events from bubbeling fixed FocusManager issues
+ dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function(e) {
+ e.stopPropagation();
+ });
- lastRng = editor.selection.getRng();
- pasteBinElm.focus();
- editor.selection.select(pasteBinElm, true);
- }
+ lastRng = editor.selection.getRng();
+ pasteBinElm.focus();
+ editor.selection.select(pasteBinElm, true);
+ }
- /**
- * Removes the paste bin if it exists.
- */
- function removePasteBin() {
- if (pasteBinElm) {
- editor.dom.unbind(pasteBinElm);
- editor.dom.remove(pasteBinElm);
+ /**
+ * Removes the paste bin if it exists.
+ */
+ function removePasteBin() {
+ if (pasteBinElm) {
+ editor.dom.unbind(pasteBinElm);
+ editor.dom.remove(pasteBinElm);
- if (lastRng) {
- editor.selection.setRng(lastRng);
- }
- }
+ if (lastRng) {
+ editor.selection.setRng(lastRng);
+ }
+ }
- keyboardPastePlainTextState = false;
- pasteBinElm = lastRng = null;
- }
+ keyboardPastePlainTextState = false;
+ pasteBinElm = lastRng = null;
+ }
- /**
- * Returns the contents of the paste bin as a HTML string.
- *
- * @return {String} Get the contents of the paste bin.
- */
- function getPasteBinHtml() {
- return pasteBinElm ? pasteBinElm.innerHTML : pasteBinDefaultContent;
- }
+ /**
+ * Returns the contents of the paste bin as a HTML string.
+ *
+ * @return {String} Get the contents of the paste bin.
+ */
+ function getPasteBinHtml() {
+ return pasteBinElm ? pasteBinElm.innerHTML : pasteBinDefaultContent;
+ }
- /**
- * Gets various content types out of the Clipboard API. It will also get the
- * plain text using older IE and WebKit API:s.
- *
- * @param {ClipboardEvent} clipboardEvent Event fired on paste.
- * @return {Object} Object with mime types and data for those mime types.
- */
- function getClipboardContent(clipboardEvent) {
- var data = {}, clipboardData = clipboardEvent.clipboardData || editor.getDoc().dataTransfer;
+ /**
+ * Gets various content types out of the Clipboard API. It will also get the
+ * plain text using older IE and WebKit API:s.
+ *
+ * @param {ClipboardEvent} clipboardEvent Event fired on paste.
+ * @return {Object} Object with mime types and data for those mime types.
+ */
+ function getClipboardContent(clipboardEvent) {
+ var data = {}, clipboardData = clipboardEvent.clipboardData || editor.getDoc().dataTransfer;
- if (clipboardData && clipboardData.types) {
- data['text/plain'] = clipboardData.getData('Text');
+ if (clipboardData && clipboardData.types) {
+ data['text/plain'] = clipboardData.getData('Text');
- for (var i = 0; i < clipboardData.types.length; i++) {
- var contentType = clipboardData.types[i];
- data[contentType] = clipboardData.getData(contentType);
- }
- }
+ for (var i = 0; i < clipboardData.types.length; i++) {
+ var contentType = clipboardData.types[i];
+ data[contentType] = clipboardData.getData(contentType);
+ }
+ }
- return data;
- }
+ return data;
+ }
- function inAcePrevent() {
- // 这个事件是从哪触发的? 浏览器自带的
- // life ace 如果在pre中, 直接返回 TODO
- var ace = LeaAce.nowIsInAce();
- if(ace) {
- // log("in aceEdiotr 2 paste");
- // 原来这里focus了
- setTimeout(function() {
- ace[0].focus();
- });
- return true;
- }
- return false;
- }
+ function inAcePrevent() {
+ // 这个事件是从哪触发的? 浏览器自带的
+ // life ace 如果在pre中, 直接返回 TODO
+ var ace = LeaAce.nowIsInAce();
+ if(ace) {
+ // log("in aceEdiotr 2 paste");
+ // 原来这里focus了
+ setTimeout(function() {
+ ace[0].focus();
+ });
+ return true;
+ }
+ return false;
+ }
- editor.on('keydown', function(e) {
- if (e.isDefaultPrevented()) {
- return;
- }
+ editor.on('keydown', function(e) {
+ if (e.isDefaultPrevented()) {
+ return;
+ }
- // Ctrl+V or Shift+Insert
- if ((VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) {
+ // Ctrl+V or Shift+Insert
+ if ((VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) {
- if(inAcePrevent()) {
- return;
- }
+ if(inAcePrevent()) {
+ return;
+ }
- keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
+ keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
- // Prevent undoManager keydown handler from making an undo level with the pastebin in it
- e.stopImmediatePropagation();
+ // Prevent undoManager keydown handler from making an undo level with the pastebin in it
+ e.stopImmediatePropagation();
- keyboardPasteTimeStamp = new Date().getTime();
+ keyboardPasteTimeStamp = new Date().getTime();
- // IE doesn't support Ctrl+Shift+V and it doesn't even produce a paste event
- // so lets fake a paste event and let IE use the execCommand/dataTransfer methods
- if (Env.ie && keyboardPastePlainTextState) {
- e.preventDefault();
- editor.fire('paste', {ieFake: true});
- return;
- }
+ // IE doesn't support Ctrl+Shift+V and it doesn't even produce a paste event
+ // so lets fake a paste event and let IE use the execCommand/dataTransfer methods
+ if (Env.ie && keyboardPastePlainTextState) {
+ e.preventDefault();
+ editor.fire('paste', {ieFake: true});
+ return;
+ }
- createPasteBin();
- }
- });
-
- // 当url改变时, 得到图片的大小 copy from leanote_image
- function getImageSize(url, callback) {
- var img = document.createElement('img');
-
- function done(width, height) {
- img.parentNode.removeChild(img);
- callback({width: width, height: height});
- }
-
- img.onload = function() {
- done(img.clientWidth, img.clientHeight);
- };
-
- img.onerror = function() {
- done();
- };
-
- img.src = url;
-
- var style = img.style;
- style.visibility = 'hidden';
- style.position = 'fixed';
- style.bottom = style.left = 0;
- style.width = style.height = 'auto';
-
- document.body.appendChild(img);
- }
+ createPasteBin();
+ }
+ });
+
+ // 当url改变时, 得到图片的大小 copy from leanote_image
+ function getImageSize(url, callback) {
+ var img = document.createElement('img');
+
+ function done(width, height) {
+ img.parentNode.removeChild(img);
+ callback({width: width, height: height});
+ }
+
+ img.onload = function() {
+ done(img.clientWidth, img.clientHeight);
+ };
+
+ img.onerror = function() {
+ done();
+ };
+
+ img.src = url;
+
+ var style = img.style;
+ style.visibility = 'hidden';
+ style.position = 'fixed';
+ style.bottom = style.left = 0;
+ style.width = style.height = 'auto';
+
+ document.body.appendChild(img);
+ }
- var ever;
- editor.on('paste', function(e) {
- if(inAcePrevent()) {
- return;
- }
+ // 是否有图片的粘贴, 有则删除paste bin
+ // 因为paste bin隐藏不见了, 如果不删除, 则editor_drop_paste的图片就会在这个bin下
+ // 而且, paste bin最后会删除, 导致图片不能显示
+ function hasImage(event) {
+ var items;
+ if (event.clipboardData) {
+ items = event.clipboardData.items;
+ }
+ else if(event.originalEvent && event.originalEvent.clipboardData) {
+ items = event.originalEvent.clipboardData;
+ }
+ if (!items) {
+ return false;
+ }
+ // find pasted image among pasted items
+ for (var i = 0; i < items.length; i++) {
+ if (items[i].type.indexOf("image") === 0) {
+ return true;
+ }
+ }
+ return false;
+ }
- // start
- // 以下只是linux需要
- // -----
- // 为什么要这个, 因为linux的原因, pasteImage会触发paste事件, 导致多次复制
- if (ever && new Date().getTime() - ever < 100) {
- e.preventDefault();
- return;
- }
- ever = new Date().getTime();
- // end
+ var ever;
+ editor.on('paste', function(e) {
+ if(inAcePrevent()) {
+ return;
+ }
- var clipboardContent = getClipboardContent(e);
- var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp < 100;
- var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState;
+ if (hasImage(e)) {
+ removePasteBin();
+ // 不然会在内容中插入一个图片,
+ e.preventDefault();
+ //-----------
+ // paste image
+ try {
+ // common.js
+ pasteImage(e);
+ return;
+ } catch(e) {
+ console.error(e);
+ };
+ return;
+ }
- // Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
- if (!isKeyBoardPaste) {
- e.preventDefault();
- }
+ // start
+ // 以下只是linux需要
+ // -----
+ // 为什么要这个, 因为linux的原因, pasteImage会触发paste事件, 导致多次复制
+ if (ever && new Date().getTime() - ever < 100) {
+ e.preventDefault();
+ return;
+ }
+ ever = new Date().getTime();
+ // end
- // Try IE only method if paste isn't a keyboard paste
- if (Env.ie && (!isKeyBoardPaste || e.ieFake)) {
- createPasteBin();
+ var clipboardContent = getClipboardContent(e);
+ var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp < 100;
+ var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState;
- editor.dom.bind(pasteBinElm, 'paste', function(e) {
- e.stopPropagation();
- });
+ // Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
+ if (!isKeyBoardPaste) {
+ e.preventDefault();
+ }
- editor.getDoc().execCommand('Paste', false, null);
- clipboardContent["text/html"] = getPasteBinHtml();
- removePasteBin();
- }
+ // Try IE only method if paste isn't a keyboard paste
+ if (Env.ie && (!isKeyBoardPaste || e.ieFake)) {
+ createPasteBin();
- setTimeout(function() {
- var html = getPasteBinHtml();
+ editor.dom.bind(pasteBinElm, 'paste', function(e) {
+ e.stopPropagation();
+ });
- // WebKit has a nice bug where it clones the paste bin if you paste from for example notepad
- if (pasteBinElm && pasteBinElm.firstChild && pasteBinElm.firstChild.id === 'mcepastebin') {
- plainTextMode = true;
- }
+ editor.getDoc().execCommand('Paste', false, null);
+ clipboardContent["text/html"] = getPasteBinHtml();
+ removePasteBin();
+ }
- removePasteBin();
+ setTimeout(function() {
+ var html = getPasteBinHtml();
- if (html == pasteBinDefaultContent || !isKeyBoardPaste) {
- html = clipboardContent['text/html'] || clipboardContent['text/plain'] || pasteBinDefaultContent;
+ // WebKit has a nice bug where it clones the paste bin if you paste from for example notepad
+ if (pasteBinElm && pasteBinElm.firstChild && pasteBinElm.firstChild.id === 'mcepastebin') {
+ plainTextMode = true;
+ }
- if (html == pasteBinDefaultContent) {
- if (!isKeyBoardPaste) {
- // editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
- }
- return;
- }
- }
+ removePasteBin();
- if (plainTextMode) {
- pasteText(clipboardContent['text/plain'] || Utils.innerText(html));
- } else {
- // life
- pasteHtml(html, clipboardContent['text/plain']);
- }
- }, 0);
-
- //-----------
- // paste image
- try {
- // common.js
- pasteImage(e);
- return;
- /*
- if(pasteImage(e)) {
- return;
- }
- */
- } catch(e) {
- console.error(e);
- };
+ if (html == pasteBinDefaultContent || !isKeyBoardPaste) {
+ html = clipboardContent['text/html'] || clipboardContent['text/plain'] || pasteBinDefaultContent;
- });
-
-
+ if (html == pasteBinDefaultContent) {
+ if (!isKeyBoardPaste) {
+ // editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
+ }
+ return;
+ }
+ }
- self.pasteHtml = pasteHtml;
- self.pasteText = pasteText;
- };
+ if (plainTextMode) {
+ pasteText(clipboardContent['text/plain'] || Utils.innerText(html));
+ } else {
+ // life
+ pasteHtml(html, clipboardContent['text/plain']);
+ }
+ }, 0);
+
+ try {
+ // common.js
+ pasteImage(e);
+ return;
+ } catch(e) {
+ console.error(e);
+ };
+
+ });
+
+
+
+ self.pasteHtml = pasteHtml;
+ self.pasteText = pasteText;
+ };
});
// Included from: js/tinymce/plugins/paste/classes/WordFilter.js
@@ -41384,251 +41416,251 @@ define("tinymce/pasteplugin/Clipboard", [
* @private
*/
define("tinymce/pasteplugin/WordFilter", [
- "tinymce/util/Tools",
- "tinymce/html/DomParser",
- "tinymce/html/Schema",
- "tinymce/html/Serializer",
- "tinymce/html/Node",
- "tinymce/pasteplugin/Utils"
+ "tinymce/util/Tools",
+ "tinymce/html/DomParser",
+ "tinymce/html/Schema",
+ "tinymce/html/Serializer",
+ "tinymce/html/Node",
+ "tinymce/pasteplugin/Utils"
], function(Tools, DomParser, Schema, Serializer, Node, Utils) {
- function isWordContent(content) {
- return (/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i).test(content);
- }
+ function isWordContent(content) {
+ return (/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i).test(content);
+ }
- function WordFilter(editor) {
- var settings = editor.settings;
+ function WordFilter(editor) {
+ var settings = editor.settings;
- editor.on('BeforePastePreProcess', function(e) {
- var content = e.content, retainStyleProperties, validStyles;
+ editor.on('BeforePastePreProcess', function(e) {
+ var content = e.content, retainStyleProperties, validStyles;
- retainStyleProperties = settings.paste_retain_style_properties;
- if (retainStyleProperties) {
- validStyles = Tools.makeMap(retainStyleProperties);
- }
+ retainStyleProperties = settings.paste_retain_style_properties;
+ if (retainStyleProperties) {
+ validStyles = Tools.makeMap(retainStyleProperties);
+ }
- /**
- * Converts fake bullet and numbered lists to real semantic OL/UL.
- *
- * @param {tinymce.html.Node} node Root node to convert children of.
- */
- function convertFakeListsToProperLists(node) {
- var currentListNode, prevListNode, lastLevel = 1;
+ /**
+ * Converts fake bullet and numbered lists to real semantic OL/UL.
+ *
+ * @param {tinymce.html.Node} node Root node to convert children of.
+ */
+ function convertFakeListsToProperLists(node) {
+ var currentListNode, prevListNode, lastLevel = 1;
- function convertParagraphToLi(paragraphNode, listStartTextNode, listName, start) {
- var level = paragraphNode._listLevel || lastLevel;
+ function convertParagraphToLi(paragraphNode, listStartTextNode, listName, start) {
+ var level = paragraphNode._listLevel || lastLevel;
- // Handle list nesting
- if (level != lastLevel) {
- if (level < lastLevel) {
- // Move to parent list
- if (currentListNode) {
- currentListNode = currentListNode.parent.parent;
- }
- } else {
- // Create new list
- prevListNode = currentListNode;
- currentListNode = null;
- }
- }
+ // Handle list nesting
+ if (level != lastLevel) {
+ if (level < lastLevel) {
+ // Move to parent list
+ if (currentListNode) {
+ currentListNode = currentListNode.parent.parent;
+ }
+ } else {
+ // Create new list
+ prevListNode = currentListNode;
+ currentListNode = null;
+ }
+ }
- if (!currentListNode || currentListNode.name != listName) {
- prevListNode = prevListNode || currentListNode;
- currentListNode = new Node(listName, 1);
+ if (!currentListNode || currentListNode.name != listName) {
+ prevListNode = prevListNode || currentListNode;
+ currentListNode = new Node(listName, 1);
- if (start > 1) {
- currentListNode.attr('start', '' + start);
- }
+ if (start > 1) {
+ currentListNode.attr('start', '' + start);
+ }
- paragraphNode.wrap(currentListNode);
- } else {
- currentListNode.append(paragraphNode);
- }
+ paragraphNode.wrap(currentListNode);
+ } else {
+ currentListNode.append(paragraphNode);
+ }
- paragraphNode.name = 'li';
- listStartTextNode.value = '';
+ paragraphNode.name = 'li';
+ listStartTextNode.value = '';
- var nextNode = listStartTextNode.next;
- if (nextNode && nextNode.type == 3) {
- nextNode.value = nextNode.value.replace(/^\u00a0+/, '');
- }
+ var nextNode = listStartTextNode.next;
+ if (nextNode && nextNode.type == 3) {
+ nextNode.value = nextNode.value.replace(/^\u00a0+/, '');
+ }
- // Append list to previous list if it exists
- if (level > lastLevel && prevListNode) {
- prevListNode.lastChild.append(currentListNode);
- }
+ // Append list to previous list if it exists
+ if (level > lastLevel && prevListNode) {
+ prevListNode.lastChild.append(currentListNode);
+ }
- lastLevel = level;
- }
+ lastLevel = level;
+ }
- var paragraphs = node.getAll('p');
+ var paragraphs = node.getAll('p');
- for (var i = 0; i < paragraphs.length; i++) {
- node = paragraphs[i];
+ for (var i = 0; i < paragraphs.length; i++) {
+ node = paragraphs[i];
- if (node.name == 'p' && node.firstChild) {
- // Find first text node in paragraph
- var nodeText = '';
- var listStartTextNode = node.firstChild;
+ if (node.name == 'p' && node.firstChild) {
+ // Find first text node in paragraph
+ var nodeText = '';
+ var listStartTextNode = node.firstChild;
- while (listStartTextNode) {
- nodeText = listStartTextNode.value;
- if (nodeText) {
- break;
- }
+ while (listStartTextNode) {
+ nodeText = listStartTextNode.value;
+ if (nodeText) {
+ break;
+ }
- listStartTextNode = listStartTextNode.firstChild;
- }
+ listStartTextNode = listStartTextNode.firstChild;
+ }
- // Detect unordered lists look for bullets
- if (/^\s*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*$/.test(nodeText)) {
- convertParagraphToLi(node, listStartTextNode, 'ul');
- continue;
- }
+ // Detect unordered lists look for bullets
+ if (/^\s*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*$/.test(nodeText)) {
+ convertParagraphToLi(node, listStartTextNode, 'ul');
+ continue;
+ }
- // Detect ordered lists 1., a. or ixv.
- if (/^\s*\w+\.$/.test(nodeText)) {
- // Parse OL start number
- var matches = /([0-9])\./.exec(nodeText);
- var start = 1;
- if (matches) {
- start = parseInt(matches[1], 10);
- }
+ // Detect ordered lists 1., a. or ixv.
+ if (/^\s*\w+\.$/.test(nodeText)) {
+ // Parse OL start number
+ var matches = /([0-9])\./.exec(nodeText);
+ var start = 1;
+ if (matches) {
+ start = parseInt(matches[1], 10);
+ }
- convertParagraphToLi(node, listStartTextNode, 'ol', start);
- continue;
- }
+ convertParagraphToLi(node, listStartTextNode, 'ol', start);
+ continue;
+ }
- currentListNode = null;
- }
- }
- }
+ currentListNode = null;
+ }
+ }
+ }
- function filterStyles(node, styleValue) {
- // Parse out list indent level for lists
- if (node.name === 'p') {
- var matches = /mso-list:\w+ \w+([0-9]+)/.exec(styleValue);
+ function filterStyles(node, styleValue) {
+ // Parse out list indent level for lists
+ if (node.name === 'p') {
+ var matches = /mso-list:\w+ \w+([0-9]+)/.exec(styleValue);
- if (matches) {
- node._listLevel = parseInt(matches[1], 10);
- }
- }
+ if (matches) {
+ node._listLevel = parseInt(matches[1], 10);
+ }
+ }
- if (editor.getParam("paste_retain_style_properties", "none")) {
- var outputStyle = "";
+ if (editor.getParam("paste_retain_style_properties", "none")) {
+ var outputStyle = "";
- Tools.each(editor.dom.parseStyle(styleValue), function(value, name) {
- // Convert various MS styles to W3C styles
- switch (name) {
- case "horiz-align":
- name = "text-align";
- return;
+ Tools.each(editor.dom.parseStyle(styleValue), function(value, name) {
+ // Convert various MS styles to W3C styles
+ switch (name) {
+ case "horiz-align":
+ name = "text-align";
+ return;
- case "vert-align":
- name = "vertical-align";
- return;
+ case "vert-align":
+ name = "vertical-align";
+ return;
- case "font-color":
- case "mso-foreground":
- name = "color";
- return;
+ case "font-color":
+ case "mso-foreground":
+ name = "color";
+ return;
- case "mso-background":
- case "mso-highlight":
- name = "background";
- break;
- }
+ case "mso-background":
+ case "mso-highlight":
+ name = "background";
+ break;
+ }
- // Output only valid styles
- if (retainStyleProperties == "all" || (validStyles && validStyles[name])) {
- outputStyle += name + ':' + value + ';';
- }
- });
+ // Output only valid styles
+ if (retainStyleProperties == "all" || (validStyles && validStyles[name])) {
+ outputStyle += name + ':' + value + ';';
+ }
+ });
- if (outputStyle) {
- return outputStyle;
- }
- }
+ if (outputStyle) {
+ return outputStyle;
+ }
+ }
- return null;
- }
+ return null;
+ }
- if (settings.paste_enable_default_filters === false) {
- return;
- }
+ if (settings.paste_enable_default_filters === false) {
+ return;
+ }
- // Detect is the contents is Word junk HTML
- if (isWordContent(e.content)) {
- e.wordContent = true; // Mark it for other processors
+ // Detect is the contents is Word junk HTML
+ if (isWordContent(e.content)) {
+ e.wordContent = true; // Mark it for other processors
- // Remove basic Word junk
- content = Utils.filter(content, [
- // Word comments like conditional comments etc
- //gi,
+ // Remove basic Word junk
+ content = Utils.filter(content, [
+ // Word comments like conditional comments etc
+ //gi,
- // Remove comments, scripts (e.g., msoShowComment), XML tag, VML content,
- // MS Office namespaced tags, and a few other tags
- /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
+ // Remove comments, scripts (e.g., msoShowComment), XML tag, VML content,
+ // MS Office namespaced tags, and a few other tags
+ /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
- // Convert a b a b a b a b ]*>( | |\s|\u00a0|)<\/p>[\r\n]*| )$/,e+"$1"],[/\n/g," ")&&(a=e+a)),f(a,b)}function h(){var a=d.dom,b=d.getBody(),c=d.dom.getViewPort(d.getWin()),e=d.inline?b.scrollTop:c.y,f=d.inline?b.clientHeight:c.h;i(),m=a.add(d.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(e+20)+"px;width: 10px; height: "+(f-40)+"px; overflow: hidden; opacity: 0"},r),a.setStyle(m,"left","rtl"==a.getStyle(b,"direction",!0)?65535:-65535),a.bind(m,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),n=d.selection.getRng(),m.focus(),d.selection.select(m,!0)}function i(){m&&(d.dom.unbind(m),d.dom.remove(m),n&&d.selection.setRng(n)),o=!1,m=n=null}function j(){return m?m.innerHTML:r}function k(a){var b={},c=a.clipboardData||d.getDoc().dataTransfer;if(c&&c.types){b["text/plain"]=c.getData("Text");for(var e=0;e "+o+" "+o+" "+o+" )$/,e+"$1"],[/\n/g," ")&&(a=e+a)),f(a,b)}function h(){var a=d.dom,b=d.getBody(),c=d.dom.getViewPort(d.getWin()),e=d.inline?b.scrollTop:c.y,f=d.inline?b.clientHeight:c.h;i(),n=a.add(d.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(e+20)+"px;width: 10px; height: "+(f-40)+"px; overflow: hidden; opacity: 0"},s),a.setStyle(n,"left","rtl"==a.getStyle(b,"direction",!0)?65535:-65535),a.bind(n,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),o=d.selection.getRng(),n.focus(),d.selection.select(n,!0)}function i(){n&&(d.dom.unbind(n),d.dom.remove(n),o&&d.selection.setRng(o)),p=!1,n=o=null}function j(){return n?n.innerHTML:s}function k(a){var b={},c=a.clipboardData||d.getDoc().dataTransfer;if(c&&c.types){b["text/plain"]=c.getData("Text");for(var e=0;e "+o+" "+o+" "+o+"
$/])}function h(a){if(!c.isWordContent(a))return a;var f=[];b.each(e.schema.getBlockElements(),function(a,b){f.push(b)});var g=new RegExp("(?:
[\\s\\r\\n]+|
)*(<\\/?("+f.join("|")+")[^>]*>)(?:
[\\s\\r\\n]+|
)*","g");return a=d.filter(a,[[g,"$1"]]),a=d.filter(a,[[/
/g,"
"],[/
/g," "],[/
/g,"
"]])}function i(a){return(e.settings.paste_remove_styles||e.settings.paste_remove_styles_if_webkit!==!1)&&(a=a.replace(/ style=\"[^\"]+\"/g,"")),a}a.webkit&&(f(i),f(g)),a.ie&&f(h)}}),d("tinymce/pasteplugin/Plugin",["tinymce/PluginManager","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks"],function(a,b,c,d){var e;a.add("paste",function(a){function f(){"text"==g.pasteFormat?(this.active(!1),g.pasteFormat="html"):(g.pasteFormat="text",this.active(!0),e||(a.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),e=!0))}var g,h=this,i=a.settings;h.clipboard=g=new b(a),h.quirks=new d(a),h.wordFilter=new c(a),g.copyImage=!0,a.settings.paste_as_text&&(h.clipboard.pasteFormat="text"),i.paste_preprocess&&a.on("PastePreProcess",function(a){i.paste_preprocess.call(h,h,a)}),i.paste_postprocess&&a.on("PastePostProcess",function(a){i.paste_postprocess.call(h,h,a)}),a.addCommand("mceInsertClipboardContent",function(a,b){b.content&&h.clipboard.pasteHtml(b.content),b.text&&h.clipboard.pasteText(b.text)}),a.paste_block_drop&&a.on("dragend dragover draggesture dragdrop drop drag",function(a){a.preventDefault(),a.stopPropagation()}),a.settings.paste_data_images||a.on("drop",function(a){var b=a.dataTransfer;b&&b.files&&b.files.length>0&&a.preventDefault()}),a.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:f,active:"text"==h.clipboard.pasteFormat}),a.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:g.pasteFormat,onclick:f})})}),f(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/WordFilter"])}(this);
\ No newline at end of file
diff --git a/public/tinymce/tinymce.dev.js b/public/tinymce/tinymce.dev.js
index fbe00724..2a540ab5 100644
--- a/public/tinymce/tinymce.dev.js
+++ b/public/tinymce/tinymce.dev.js
@@ -220,4 +220,4 @@
writeScripts();
})(this);
-// $hash: 22c5702fe3523532d768d96e707c6401
\ No newline at end of file
+// $hash: 92dd40192b582927276ae6c571d01e6f
\ No newline at end of file
diff --git a/public/tinymce/tinymce.full.js b/public/tinymce/tinymce.full.js
index 6e5ec8b5..efd4f9c3 100644
--- a/public/tinymce/tinymce.full.js
+++ b/public/tinymce/tinymce.full.js
@@ -40756,79 +40756,79 @@ tinymce.PluginManager.add('hr', function(editor) {
/*globals $code */
(function(exports, undefined) {
- "use strict";
+ "use strict";
- var modules = {};
+ var modules = {};
- function require(ids, callback) {
- var module, defs = [];
+ function require(ids, callback) {
+ var module, defs = [];
- for (var i = 0; i < ids.length; ++i) {
- module = modules[ids[i]] || resolve(ids[i]);
- if (!module) {
- throw 'module definition dependecy not found: ' + ids[i];
- }
+ for (var i = 0; i < ids.length; ++i) {
+ module = modules[ids[i]] || resolve(ids[i]);
+ if (!module) {
+ throw 'module definition dependecy not found: ' + ids[i];
+ }
- defs.push(module);
- }
+ defs.push(module);
+ }
- callback.apply(null, defs);
- }
+ callback.apply(null, defs);
+ }
- function define(id, dependencies, definition) {
- if (typeof id !== 'string') {
- throw 'invalid module definition, module id must be defined and be a string';
- }
+ function define(id, dependencies, definition) {
+ if (typeof id !== 'string') {
+ throw 'invalid module definition, module id must be defined and be a string';
+ }
- if (dependencies === undefined) {
- throw 'invalid module definition, dependencies must be specified';
- }
+ if (dependencies === undefined) {
+ throw 'invalid module definition, dependencies must be specified';
+ }
- if (definition === undefined) {
- throw 'invalid module definition, definition function must be specified';
- }
+ if (definition === undefined) {
+ throw 'invalid module definition, definition function must be specified';
+ }
- require(dependencies, function() {
- modules[id] = definition.apply(null, arguments);
- });
- }
+ require(dependencies, function() {
+ modules[id] = definition.apply(null, arguments);
+ });
+ }
- function defined(id) {
- return !!modules[id];
- }
+ function defined(id) {
+ return !!modules[id];
+ }
- function resolve(id) {
- var target = exports;
- var fragments = id.split(/[.\/]/);
+ function resolve(id) {
+ var target = exports;
+ var fragments = id.split(/[.\/]/);
- for (var fi = 0; fi < fragments.length; ++fi) {
- if (!target[fragments[fi]]) {
- return;
- }
+ for (var fi = 0; fi < fragments.length; ++fi) {
+ if (!target[fragments[fi]]) {
+ return;
+ }
- target = target[fragments[fi]];
- }
+ target = target[fragments[fi]];
+ }
- return target;
- }
+ return target;
+ }
- function expose(ids) {
- for (var i = 0; i < ids.length; i++) {
- var target = exports;
- var id = ids[i];
- var fragments = id.split(/[.\/]/);
+ function expose(ids) {
+ for (var i = 0; i < ids.length; i++) {
+ var target = exports;
+ var id = ids[i];
+ var fragments = id.split(/[.\/]/);
- for (var fi = 0; fi < fragments.length - 1; ++fi) {
- if (target[fragments[fi]] === undefined) {
- target[fragments[fi]] = {};
- }
+ for (var fi = 0; fi < fragments.length - 1; ++fi) {
+ if (target[fragments[fi]] === undefined) {
+ target[fragments[fi]] = {};
+ }
- target = target[fragments[fi]];
- }
+ target = target[fragments[fi]];
+ }
- target[fragments[fragments.length - 1]] = modules[id];
- }
- }
+ target[fragments[fragments.length - 1]] = modules[id];
+ }
+ }
// Included from: js/tinymce/plugins/paste/classes/Utils.js
@@ -40849,86 +40849,86 @@ tinymce.PluginManager.add('hr', function(editor) {
* @private
*/
define("tinymce/pasteplugin/Utils", [
- "tinymce/util/Tools",
- "tinymce/html/DomParser",
- "tinymce/html/Schema"
+ "tinymce/util/Tools",
+ "tinymce/html/DomParser",
+ "tinymce/html/Schema"
], function(Tools, DomParser, Schema) {
- function filter(content, items) {
- Tools.each(items, function(v) {
- if (v.constructor == RegExp) {
- content = content.replace(v, '');
- } else {
- content = content.replace(v[0], v[1]);
- }
- });
+ function filter(content, items) {
+ Tools.each(items, function(v) {
+ if (v.constructor == RegExp) {
+ content = content.replace(v, '');
+ } else {
+ content = content.replace(v[0], v[1]);
+ }
+ });
- return content;
- }
+ return content;
+ }
- /**
- * Gets the innerText of the specified element. It will handle edge cases
- * and works better than textContent on Gecko.
- *
- * @param {String} html HTML string to get text from.
- * @return {String} String of text with line feeds.
- */
- function innerText(html) {
- var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
- var shortEndedElements = schema.getShortEndedElements();
- var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
- var blockElements = schema.getBlockElements();
+ /**
+ * Gets the innerText of the specified element. It will handle edge cases
+ * and works better than textContent on Gecko.
+ *
+ * @param {String} html HTML string to get text from.
+ * @return {String} String of text with line feeds.
+ */
+ function innerText(html) {
+ var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
+ var shortEndedElements = schema.getShortEndedElements();
+ var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
+ var blockElements = schema.getBlockElements();
- function walk(node) {
- var name = node.name, currentNode = node;
+ function walk(node) {
+ var name = node.name, currentNode = node;
- if (name === 'br') {
- text += '\n';
- return;
- }
+ if (name === 'br') {
+ text += '\n';
+ return;
+ }
- // img/input/hr
- if (shortEndedElements[name]) {
- text += ' ';
- }
+ // img/input/hr
+ if (shortEndedElements[name]) {
+ text += ' ';
+ }
- // Ingore script, video contents
- if (ignoreElements[name]) {
- text += ' ';
- return;
- }
+ // Ingore script, video contents
+ if (ignoreElements[name]) {
+ text += ' ';
+ return;
+ }
- if (node.type == 3) {
- text += node.value;
- }
+ if (node.type == 3) {
+ text += node.value;
+ }
- // Walk all children
- if (!node.shortEnded) {
- if ((node = node.firstChild)) {
- do {
- walk(node);
- } while ((node = node.next));
- }
- }
+ // Walk all children
+ if (!node.shortEnded) {
+ if ((node = node.firstChild)) {
+ do {
+ walk(node);
+ } while ((node = node.next));
+ }
+ }
- // Add \n or \n\n for blocks or P
- if (blockElements[name] && currentNode.next) {
- text += '\n';
+ // Add \n or \n\n for blocks or P
+ if (blockElements[name] && currentNode.next) {
+ text += '\n';
- if (name == 'p') {
- text += '\n';
- }
- }
- }
+ if (name == 'p') {
+ text += '\n';
+ }
+ }
+ }
- walk(domParser.parse(html));
+ walk(domParser.parse(html));
- return text;
- }
+ return text;
+ }
- return {
- filter: filter,
- innerText: innerText
- };
+ return {
+ filter: filter,
+ innerText: innerText
+ };
});
// Included from: js/tinymce/plugins/paste/classes/Clipboard.js
@@ -40963,406 +40963,438 @@ define("tinymce/pasteplugin/Utils", [
* @private
*/
define("tinymce/pasteplugin/Clipboard", [
- "tinymce/Env",
- "tinymce/util/VK",
- "tinymce/pasteplugin/Utils"
+ "tinymce/Env",
+ "tinymce/util/VK",
+ "tinymce/pasteplugin/Utils"
], function(Env, VK, Utils) {
- return function(editor) {
- var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0;
- var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
+ return function(editor) {
+ var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0;
+ var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
- /**
- * 复制外链图片, copy到本地
- */
- function copyImage(src, ids) {
- FileService.copyOtherSiteImage(src, function(url) {
- if (url) {
- // 将图片替换之
- var dom = editor.dom;
- for(var i in ids) {
- var id = ids[i];
- var imgElm = dom.get(id);
- if (imgElm) {
- dom.setAttrib(imgElm, 'src', url);
- }
- }
- }
- });
- }
+ /**
+ * 复制外链图片, copy到本地
+ */
+ function copyImage(src, ids) {
+ FileService.copyOtherSiteImage(src, function(url) {
+ if (url) {
+ // 将图片替换之
+ var dom = editor.dom;
+ for(var i in ids) {
+ var id = ids[i];
+ var imgElm = dom.get(id);
+ if (imgElm) {
+ dom.setAttrib(imgElm, 'src', url);
+ }
+ }
+ }
+ });
+ }
- // 粘贴HTML
- // 当在pre下时不能粘贴成HTML
- // life add text
- function pasteHtml(html, text) {
- var args, dom = editor.dom;
+ // 粘贴HTML
+ // 当在pre下时不能粘贴成HTML
+ // life add text
+ function pasteHtml(html, text) {
+ var args, dom = editor.dom;
- // Remove all data images from paste for example from Gecko
- if (!editor.settings.paste_data_images) {
- html = html.replace(/]+src=\"data:image[^>]+>/g, '');
- }
+ // Remove all data images from paste for example from Gecko
+ if (!editor.settings.paste_data_images) {
+ html = html.replace(/
]+src=\"data:image[^>]+>/g, '');
+ }
- args = editor.fire('BeforePastePreProcess', {content: html}); // Internal event used by Quirks
- args = editor.fire('PastePreProcess', args);
- html = args.content;
+ args = editor.fire('BeforePastePreProcess', {content: html}); // Internal event used by Quirks
+ args = editor.fire('PastePreProcess', args);
+ html = args.content;
- if (!args.isDefaultPrevented()) {
- // User has bound PastePostProcess events then we need to pass it through a DOM node
- // This is not ideal but we don't want to let the browser mess up the HTML for example
- // some browsers add to P tags etc
- if (editor.hasEventListeners('PastePostProcess') && !args.isDefaultPrevented()) {
- // We need to attach the element to the DOM so Sizzle selectors work on the contents
- var tempBody = dom.add(editor.getBody(), 'div', {style: 'display:none'}, html);
- args = editor.fire('PastePostProcess', {node: tempBody});
- dom.remove(tempBody);
- html = args.node.innerHTML;
- }
-
- if (!args.isDefaultPrevented()) {
- // life
- var node = editor.selection.getNode();
- if(node.nodeName == "PRE") {
- if(!text) {
- try {
- text = $(html).text();
- } catch(e) {
- }
- }
- // HTML不能粘贴
- // 其它有错误.... TODO
- // 若有HTML, paste到其它地方有js错误
- // 貼html时自动会删除
- // 纯HTML编辑也会
- text = text.replace(//g, ">");
- // firefox下必须这个
- editor.insertRawContent(text);
- // 之前用insertRawContent()有问题, ace paste下, TODO
- // editor.insertContent(text);
- } else {
- // life 这里得到图片img, 复制到leanote下
- if(!self.copyImage) {
- editor.insertContent(html);
- } else {
- var urlPrefix = UrlPrefix;
- var needCopyImages = {}; // src => [id1,id2]
- var time = (new Date()).getTime();
- try {
- var $html = $("
"]
- ]);
- } else {
- text = Utils.filter(text, [
- [/\n\n/g, "
"]
- ]);
+ if ((startBlock && /^(PRE|DIV)$/.test(startBlock.nodeName)) || !forcedRootBlockName) {
+ text = Utils.filter(text, [
+ [/\n/g, "
"]
+ ]);
+ } else {
+ text = Utils.filter(text, [
+ [/\n\n/g, "
"]
+ ]);
- if (text.indexOf(' into for line-though
- [/<(\/?)s>/gi, "<$1strike>"],
+ // Convert into for line-though
+ [/<(\/?)s>/gi, "<$1strike>"],
- // Replace nsbp entites to char since it's easier to handle
- [/ /gi, "\u00a0"],
+ // Replace nsbp entites to char since it's easier to handle
+ [/ /gi, "\u00a0"],
- // Convert ___ to string of alternating
- // breaking/non-breaking spaces of same length
- [/([\s\u00a0]*)<\/span>/gi,
- function(str, spaces) {
- return (spaces.length > 0) ?
- spaces.replace(/./, " ").slice(Math.floor(spaces.length/2)).split("").join("\u00a0") : "";
- }
- ]
- ]);
+ // Convert ___ to string of alternating
+ // breaking/non-breaking spaces of same length
+ [/([\s\u00a0]*)<\/span>/gi,
+ function(str, spaces) {
+ return (spaces.length > 0) ?
+ spaces.replace(/./, " ").slice(Math.floor(spaces.length/2)).split("").join("\u00a0") : "";
+ }
+ ]
+ ]);
- var validElements = settings.paste_word_valid_elements;
- if (!validElements) {
- validElements = '@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' +
- '-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br';
- }
+ var validElements = settings.paste_word_valid_elements;
+ if (!validElements) {
+ validElements = '@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' +
+ '-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br';
+ }
- // Setup strict schema
- var schema = new Schema({
- valid_elements: validElements
- });
+ // Setup strict schema
+ var schema = new Schema({
+ valid_elements: validElements
+ });
- // Parse HTML into DOM structure
- var domParser = new DomParser({}, schema);
+ // Parse HTML into DOM structure
+ var domParser = new DomParser({}, schema);
- // Filte element style attributes
- domParser.addAttributeFilter('style', function(nodes) {
- var i = nodes.length, node;
+ // Filte element style attributes
+ domParser.addAttributeFilter('style', function(nodes) {
+ var i = nodes.length, node;
- while (i--) {
- node = nodes[i];
- node.attr('style', filterStyles(node, node.attr('style')));
+ while (i--) {
+ node = nodes[i];
+ node.attr('style', filterStyles(node, node.attr('style')));
- // Remove pointess spans
- if (node.name == 'span' && !node.attributes.length) {
- node.unwrap();
- }
- }
- });
+ // Remove pointess spans
+ if (node.name == 'span' && !node.attributes.length) {
+ node.unwrap();
+ }
+ }
+ });
- // Parse into DOM structure
- var rootNode = domParser.parse(content);
+ // Parse into DOM structure
+ var rootNode = domParser.parse(content);
- // Process DOM
- convertFakeListsToProperLists(rootNode);
+ // Process DOM
+ convertFakeListsToProperLists(rootNode);
- // Serialize DOM back to HTML
- e.content = new Serializer({}, schema).serialize(rootNode);
- }
- });
- }
+ // Serialize DOM back to HTML
+ e.content = new Serializer({}, schema).serialize(rootNode);
+ }
+ });
+ }
- WordFilter.isWordContent = isWordContent;
+ WordFilter.isWordContent = isWordContent;
- return WordFilter;
+ return WordFilter;
});
// Included from: js/tinymce/plugins/paste/classes/Quirks.js
@@ -41652,109 +41684,109 @@ define("tinymce/pasteplugin/WordFilter", [
* @private
*/
define("tinymce/pasteplugin/Quirks", [
- "tinymce/Env",
- "tinymce/util/Tools",
- "tinymce/pasteplugin/WordFilter",
- "tinymce/pasteplugin/Utils"
+ "tinymce/Env",
+ "tinymce/util/Tools",
+ "tinymce/pasteplugin/WordFilter",
+ "tinymce/pasteplugin/Utils"
], function(Env, Tools, WordFilter, Utils) {
- "use strict";
+ "use strict";
- return function(editor) {
- function addPreProcessFilter(filterFunc) {
- editor.on('BeforePastePreProcess', function(e) {
- e.content = filterFunc(e.content);
- });
- }
+ return function(editor) {
+ function addPreProcessFilter(filterFunc) {
+ editor.on('BeforePastePreProcess', function(e) {
+ e.content = filterFunc(e.content);
+ });
+ }
- /**
- * Removes WebKit fragment comments and converted-space spans.
- *
- * This:
- * a b
- *
- * Becomes:
- * a b
- */
- function removeWebKitFragments(html) {
- html = Utils.filter(html, [
- /^[\s\S]*|[\s\S]*$/g, // WebKit fragment
- [/\u00a0<\/span>/g, '\u00a0'], // WebKit
- /
$/ // Traling BR elements
- ]);
+ /**
+ * Removes WebKit fragment comments and converted-space spans.
+ *
+ * This:
+ * a b
+ *
+ * Becomes:
+ * a b
+ */
+ function removeWebKitFragments(html) {
+ html = Utils.filter(html, [
+ /^[\s\S]*|[\s\S]*$/g, // WebKit fragment
+ [/\u00a0<\/span>/g, '\u00a0'], // WebKit
+ /
$/ // Traling BR elements
+ ]);
- return html;
- }
+ return html;
+ }
- /**
- * Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
- * block element when pasting from word. This removes those elements.
- *
- * This:
- *
[\\s\\r\\n]+|
)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:
[\\s\\r\\n]+|
)*',
- 'g'
- );
+ var explorerBlocksRegExp = new RegExp(
+ '(?:
[\\s\\r\\n]+|
)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:
[\\s\\r\\n]+|
)*',
+ 'g'
+ );
- // Remove BR:s from:
- html = Utils.filter(html, [
- [explorerBlocksRegExp, '$1']
- ]);
+ // Remove BR:s from:
+ html = Utils.filter(html, [
+ [explorerBlocksRegExp, '$1']
+ ]);
- // IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
- html = Utils.filter(html, [
- [/
/g, '
'], // Replace multiple BR elements with uppercase BR to keep them intact
- [/
/g, ' '], // Replace single br elements with space since they are word wrap BR:s
- [/
/g, '
'] // Replace back the double brs but into a single BR
- ]);
+ // IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
+ html = Utils.filter(html, [
+ [/
/g, '
'], // Replace multiple BR elements with uppercase BR to keep them intact
+ [/
/g, ' '], // Replace single br elements with space since they are word wrap BR:s
+ [/
/g, '
'] // Replace back the double brs but into a single BR
+ ]);
- return html;
- }
+ return html;
+ }
- /**
- * WebKit has a nasty bug where the all runtime styles gets added to style attributes when copy/pasting contents.
- * This fix solves that by simply removing the whole style attribute.
- *
- * Todo: This can be made smarter. Keeping styles that override existing ones etc.
- *
- * @param {String} content Content that needs to be processed.
- * @return {String} Processed contents.
- */
- function removeWebKitStyles(content) {
- if (editor.settings.paste_remove_styles || editor.settings.paste_remove_styles_if_webkit !== false) {
- content = content.replace(/ style=\"[^\"]+\"/g, '');
- }
+ /**
+ * WebKit has a nasty bug where the all runtime styles gets added to style attributes when copy/pasting contents.
+ * This fix solves that by simply removing the whole style attribute.
+ *
+ * Todo: This can be made smarter. Keeping styles that override existing ones etc.
+ *
+ * @param {String} content Content that needs to be processed.
+ * @return {String} Processed contents.
+ */
+ function removeWebKitStyles(content) {
+ if (editor.settings.paste_remove_styles || editor.settings.paste_remove_styles_if_webkit !== false) {
+ content = content.replace(/ style=\"[^\"]+\"/g, '');
+ }
- return content;
- }
+ return content;
+ }
- // Sniff browsers and apply fixes since we can't feature detect
- if (Env.webkit) {
- addPreProcessFilter(removeWebKitStyles);
- addPreProcessFilter(removeWebKitFragments);
- }
+ // Sniff browsers and apply fixes since we can't feature detect
+ if (Env.webkit) {
+ addPreProcessFilter(removeWebKitStyles);
+ addPreProcessFilter(removeWebKitFragments);
+ }
- if (Env.ie) {
- addPreProcessFilter(removeExplorerBrElementsAfterBlocks);
- }
- };
+ if (Env.ie) {
+ addPreProcessFilter(removeExplorerBrElementsAfterBlocks);
+ }
+ };
});
// Included from: js/tinymce/plugins/paste/classes/Plugin.js
@@ -41776,100 +41808,100 @@ define("tinymce/pasteplugin/Quirks", [
* @private
*/
define("tinymce/pasteplugin/Plugin", [
- "tinymce/PluginManager",
- "tinymce/pasteplugin/Clipboard",
- "tinymce/pasteplugin/WordFilter",
- "tinymce/pasteplugin/Quirks"
+ "tinymce/PluginManager",
+ "tinymce/pasteplugin/Clipboard",
+ "tinymce/pasteplugin/WordFilter",
+ "tinymce/pasteplugin/Quirks"
], function(PluginManager, Clipboard, WordFilter, Quirks) {
- var userIsInformed;
- var userIsInformed2;
+ var userIsInformed;
+ var userIsInformed2;
- PluginManager.add('paste', function(editor) {
- var self = this, clipboard, settings = editor.settings;
+ PluginManager.add('paste', function(editor) {
+ var self = this, clipboard, settings = editor.settings;
- function togglePlainTextPaste() {
- if (clipboard.pasteFormat == "text") {
- this.active(false);
- clipboard.pasteFormat = "html";
- } else {
- clipboard.pasteFormat = "text";
- this.active(true);
+ function togglePlainTextPaste() {
+ if (clipboard.pasteFormat == "text") {
+ this.active(false);
+ clipboard.pasteFormat = "html";
+ } else {
+ clipboard.pasteFormat = "text";
+ this.active(true);
- if (!userIsInformed) {
- editor.windowManager.alert(
- 'Paste is now in plain text mode. Contents will now ' +
- 'be pasted as plain text until you toggle this option off.'
- );
+ if (!userIsInformed) {
+ editor.windowManager.alert(
+ 'Paste is now in plain text mode. Contents will now ' +
+ 'be pasted as plain text until you toggle this option off.'
+ );
- userIsInformed = true;
- }
- }
- }
+ userIsInformed = true;
+ }
+ }
+ }
- self.clipboard = clipboard = new Clipboard(editor);
- self.quirks = new Quirks(editor);
- self.wordFilter = new WordFilter(editor);
- clipboard.copyImage = true;
+ self.clipboard = clipboard = new Clipboard(editor);
+ self.quirks = new Quirks(editor);
+ self.wordFilter = new WordFilter(editor);
+ clipboard.copyImage = true;
- if (editor.settings.paste_as_text) {
- self.clipboard.pasteFormat = "text";
- }
+ if (editor.settings.paste_as_text) {
+ self.clipboard.pasteFormat = "text";
+ }
- if (settings.paste_preprocess) {
- editor.on('PastePreProcess', function(e) {
- settings.paste_preprocess.call(self, self, e);
- });
- }
+ if (settings.paste_preprocess) {
+ editor.on('PastePreProcess', function(e) {
+ settings.paste_preprocess.call(self, self, e);
+ });
+ }
- if (settings.paste_postprocess) {
- editor.on('PastePostProcess', function(e) {
- settings.paste_postprocess.call(self, self, e);
- });
- }
+ if (settings.paste_postprocess) {
+ editor.on('PastePostProcess', function(e) {
+ settings.paste_postprocess.call(self, self, e);
+ });
+ }
- editor.addCommand('mceInsertClipboardContent', function(ui, value) {
- if (value.content) {
- self.clipboard.pasteHtml(value.content);
- }
+ editor.addCommand('mceInsertClipboardContent', function(ui, value) {
+ if (value.content) {
+ self.clipboard.pasteHtml(value.content);
+ }
- if (value.text) {
- self.clipboard.pasteText(value.text);
- }
- });
+ if (value.text) {
+ self.clipboard.pasteText(value.text);
+ }
+ });
- // Block all drag/drop events
- if (editor.paste_block_drop) {
- editor.on('dragend dragover draggesture dragdrop drop drag', function(e) {
- e.preventDefault();
- e.stopPropagation();
- });
- }
+ // Block all drag/drop events
+ if (editor.paste_block_drop) {
+ editor.on('dragend dragover draggesture dragdrop drop drag', function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ });
+ }
- // Prevent users from dropping data images on Gecko
- if (!editor.settings.paste_data_images) {
- editor.on('drop', function(e) {
- var dataTransfer = e.dataTransfer;
+ // Prevent users from dropping data images on Gecko
+ if (!editor.settings.paste_data_images) {
+ editor.on('drop', function(e) {
+ var dataTransfer = e.dataTransfer;
- if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
- e.preventDefault();
- }
- });
- }
+ if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
+ e.preventDefault();
+ }
+ });
+ }
- editor.addButton('pastetext', {
- icon: 'pastetext',
- tooltip: 'Paste as text',
- onclick: togglePlainTextPaste,
- active: self.clipboard.pasteFormat == "text"
- });
+ editor.addButton('pastetext', {
+ icon: 'pastetext',
+ tooltip: 'Paste as text',
+ onclick: togglePlainTextPaste,
+ active: self.clipboard.pasteFormat == "text"
+ });
- editor.addMenuItem('pastetext', {
- text: 'Paste as text',
- selectable: true,
- active: clipboard.pasteFormat,
- onclick: togglePlainTextPaste
- });
- });
+ editor.addMenuItem('pastetext', {
+ text: 'Paste as text',
+ selectable: true,
+ active: clipboard.pasteFormat,
+ onclick: togglePlainTextPaste
+ });
+ });
});
expose(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/WordFilter"]);
diff --git a/public/tinymce/tinymce.full.min.js b/public/tinymce/tinymce.full.min.js
index 082af770..ece1f48f 100644
--- a/public/tinymce/tinymce.full.min.js
+++ b/public/tinymce/tinymce.full.min.js
@@ -12,4 +12,4 @@ s=n.offsetHeight,l=r.clientWidth,c=r.clientHeight,"end"==e?(i-=l-a,o-=c-s):"cent
if(!u(t)&&t.keyCode==e.BACKSPACE&&(n=Q.getRng(),r=n.startContainer,i=n.startOffset,o=J.getRoot(),a=r,n.collapsed&&0===i)){for(;a&&a.parentNode&&a.parentNode.firstChild==a&&a.parentNode!=o;)a=a.parentNode;"BLOCKQUOTE"===a.tagName&&(s.formatter.toggle("blockquote",null,a),n=J.createRng(),n.setStart(r,0),n.setEnd(r,0),Q.setRng(n))}})}function S(){function e(){s._refreshContentEditable(),l("StyleWithCSS",!1),l("enableInlineTableEditing",!1),Z.object_resizing||l("enableObjectResizing",!1)}Z.readonly||s.on("BeforeExecCommand MouseDown",e)}function T(){function e(){K(J.select("a"),function(e){var t=e.parentNode,n=J.getRoot();if(t.lastChild===e){for(;t&&!J.isBlock(t);){if(t.parentNode.lastChild!==t||t===n)return;t=t.parentNode}J.add(t,"br",{"data-mce-bogus":1})}})}s.on("SetContent ExecCommand",function(t){("setcontent"==t.type||"mceInsertLink"===t.command)&&e()})}function R(){Z.forced_root_block&&s.on("init",function(){l("DefaultParagraphSeparator",Z.forced_root_block)})}function A(){s.on("Undo Redo SetContent",function(e){e.initial||s.execCommand("mceRepaint")})}function B(){s.on("keydown",function(e){var t;u(e)||e.keyCode!=G||(t=s.getDoc().selection.createRange(),t&&t.item&&(e.preventDefault(),s.undoManager.beforeChange(),J.remove(t.item(0)),s.undoManager.add()))})}function D(){var e;c()>=10&&(e="",K("p div h1 h2 h3 h4 h5 h6".split(" "),function(t,n){e+=(n>0?",":"")+t+":empty"}),s.contentStyles.push(e+"{padding-right: 1px !important}"))}function L(){c()<9&&(ee.addNodeFilter("noscript",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.firstChild,r&&n.attr("data-mce-innertext",r.value)}),te.addNodeFilter("noscript",function(e){for(var t=e.length,n,o,a;t--;)n=e[t],o=e[t].firstChild,o?o.value=i.decode(o.value):(a=n.attributes.map["data-mce-innertext"],a&&(n.attr("data-mce-innertext",null),o=new r("#text",3),o.value=a,o.raw=!0,n.append(o)))}))}function M(){function e(e,t){var n=i.createTextRange();try{n.moveToPoint(e,t)}catch(r){n=null}return n}function t(t){var r;t.button?(r=e(t.x,t.y),r&&(r.compareEndPoints("StartToStart",a)>0?r.setEndPoint("StartToStart",a):r.setEndPoint("EndToEnd",a),r.select())):n()}function n(){var e=r.selection.createRange();a&&!e.item&&0===e.compareEndPoints("StartToEnd",e)&&a.select(),J.unbind(r,"mouseup",n),J.unbind(r,"mousemove",t),a=o=0}var r=J.doc,i=r.body,o,a,s;r.documentElement.unselectable=!0,J.bind(r,"mousedown contextmenu",function(i){if("HTML"===i.target.nodeName){if(o&&n(),s=r.documentElement,s.scrollHeight>s.clientHeight)return;o=1,a=e(i.x,i.y),a&&(J.bind(r,"mouseup",n),J.bind(r,"mousemove",t),J.getRoot().focus(),a.select())}})}function H(){s.on("keyup focusin mouseup",function(t){65==t.keyCode&&e.metaKeyPressed(t)||Q.normalize()},!0)}function P(){s.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function O(){s.inline||s.on("keydown",function(){document.activeElement==document.body&&s.getWin().focus()})}function I(){s.inline||(s.contentStyles.push("body {min-height: 150px}"),s.on("click",function(e){if("HTML"==e.target.nodeName){var t;t=s.selection.getRng(),s.getBody().focus(),s.selection.setRng(t),s.selection.normalize(),s.nodeChanged()}}))}function F(){o.mac&&s.on("keydown",function(t){!e.metaKeyPressed(t)||37!=t.keyCode&&39!=t.keyCode||(t.preventDefault(),s.selection.getSel().modify("move",37==t.keyCode?"backward":"forward","word"))})}function z(){l("AutoUrlDetect",!1)}function W(){s.inline||s.on("focus blur beforegetcontent",function(){var e=s.dom.create("br");s.getBody().appendChild(e),e.parentNode.removeChild(e)},!0)}function V(){s.on("click",function(e){var t=e.target;do if("A"===t.tagName)return void e.preventDefault();while(t=t.parentNode)}),s.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function $(){s.on("touchstart",function(e){var t,n,r,i;t=e.target,n=(new Date).getTime(),i=e.changedTouches,!i||i.length>1||(r=i[0],s.once("touchend",function(e){var i=e.changedTouches[0],o;(new Date).getTime()-n>500||Math.abs(r.clientX-i.clientX)>5||Math.abs(r.clientY-i.clientY)>5||(o={target:t},K("pageX pageY clientX clientY screenX screenY".split(" "),function(e){o[e]=i[e]}),o=s.fire("click",o),o.isDefaultPrevented()||(s.selection.placeCaretAt(i.clientX,i.clientY),s.nodeChanged()))}))})}function U(){s.on("init",function(){s.dom.bind(s.getBody(),"submit",function(e){e.preventDefault()})})}function q(){ee.addNodeFilter("br",function(e){for(var t=e.length;t--;)"Apple-interchange-newline"==e[t].attr("class")&&e[t].remove()})}function j(){s.on("dragstart",function(e){d(e)}),s.on("drop",function(e){if(!u(e)){var n=f(e);if(n){e.preventDefault();var r=t.getCaretRangeFromPoint(e.x,e.y,s.getDoc());Q.setRng(r),p(n)}}})}var K=a.each,Y=s.$,G=e.BACKSPACE,X=e.DELETE,J=s.dom,Q=s.selection,Z=s.settings,ee=s.parser,te=s.serializer,ne=o.gecko,re=o.ie,ie=o.webkit,oe="data:text/mce-internal,",ae=re?"Text":"URL";k(),m(),H(),ie&&(h(),v(),C(),R(),U(),_(),q(),$(),o.iOS?(O(),I(),V()):g()),re&&o.ie<11&&(y(),w(),E(),N(),B(),D(),L(),M()),o.ie>=11&&(I(),W(),_()),o.ie&&(g(),z(),j()),ne&&(y(),b(),x(),S(),T(),A(),P(),F(),_())}}),r(ce,[q],function(e){function t(t){return t._eventDispatcher||(t._eventDispatcher=new e({scope:t,toggleEvent:function(n,r){e.isNative(n)&&t.toggleNativeEvent&&t.toggleNativeEvent(n,r)}})),t._eventDispatcher}return{fire:function(e,n,r){var i=this;if(i.removed&&"remove"!==e)return n;if(n=t(i).fire(e,n,r),r!==!1&&i.parent)for(var o=i.parent();o&&!n.isPropagationStopped();)o.fire(e,n,!1),o=o.parent();return n},on:function(e,n,r){return t(this).on(e,n,r)},off:function(e,n){return t(this).off(e,n)},once:function(e,n){return t(this).once(e,n)},hasEventListeners:function(e){return t(this).has(e)}}}),r(ue,[ce,y,d],function(e,t,n){function r(e,t){return"selectionchange"==t?e.getDoc():!e.inline&&/^mouse|click|contextmenu|drop|dragover|dragend/.test(t)?e.getDoc().documentElement:e.settings.event_root?(e.eventRoot||(e.eventRoot=o.select(e.settings.event_root)[0]),e.eventRoot):e.getBody()}function i(e,t){var n=r(e,t),i;if(e.delegates||(e.delegates={}),!e.delegates[t])if(e.settings.event_root){if(a||(a={},e.editorManager.on("removeEditor",function(){var t;if(!e.editorManager.activeEditor&&a){for(t in a)e.dom.unbind(r(e,t));a=null}})),a[t])return;i=function(n){for(var r=n.target,i=e.editorManager.editors,a=i.length;a--;){var s=i[a].getBody();(s===r||o.isChildOf(r,s))&&(i[a].hidden||i[a].fire(t,n))}},a[t]=i,o.bind(n,t,i)}else i=function(n){e.hidden||e.fire(t,n)},o.bind(n,t,i),e.delegates[t]=i}var o=t.DOM,a,s={bindPendingEventDelegates:function(){var e=this;n.each(e._pendingNativeEvents,function(t){i(e,t)})},toggleNativeEvent:function(e,t){var n=this;n.settings.readonly||"focus"!=e&&"blur"!=e&&(t?n.initialized?i(n,e):n._pendingNativeEvents?n._pendingNativeEvents.push(e):n._pendingNativeEvents=[e]:n.initialized&&(n.dom.unbind(r(n,e),e,n.delegates[e]),delete n.delegates[e]))},unbindAllNativeEvents:function(){var e=this,t;if(e.delegates){for(t in e.delegates)e.dom.unbind(r(e,t),t,e.delegates[t]);delete e.delegates}e.inline||(e.getBody().onload=null,e.dom.unbind(e.getWin()),e.dom.unbind(e.getDoc())),e.dom.unbind(e.getBody()),e.dom.unbind(e.getContainer())}};return s=n.extend({},e,s)}),r(de,[d,u],function(e,t){var n=e.each,r=e.explode,i={f9:120,f10:121,f11:122},o=e.makeMap("alt,ctrl,shift,meta,access");return function(a){function s(e,s,l,c){var u,d,f;f={func:l,scope:c||a,desc:a.translate(s)},n(r(e,"+"),function(e){e in o?f[e]=!0:/^[0-9]{2,}$/.test(e)?f.keyCode=parseInt(e,10):(f.charCode=e.charCodeAt(0),f.keyCode=i[e]||e.toUpperCase().charCodeAt(0))}),u=[f.keyCode];for(d in o)f[d]?u.push(d):f[d]=!1;return f.id=u.join(","),f.access&&(f.alt=!0,t.mac?f.ctrl=!0:f.shift=!0),f.meta&&(t.mac?f.meta=!0:(f.ctrl=!0,f.meta=!1)),f}var l=this,c={};a.on("keyup keypress keydown",function(e){(e.altKey||e.ctrlKey||e.metaKey)&&!e.isDefaultPrevented()&&n(c,function(t){return t.ctrl==e.ctrlKey&&t.meta==e.metaKey&&t.alt==e.altKey&&t.shift==e.shiftKey&&(e.keyCode==t.keyCode||e.charCode&&e.charCode==t.charCode)?(e.preventDefault(),"keydown"==e.type&&t.func.call(t.scope),!0):void 0})}),l.add=function(t,i,o,l){var u;return u=o,"string"==typeof o?o=function(){a.execCommand(u,!1,null)}:e.isArray(u)&&(o=function(){a.execCommand(u[0],u[1],u[2])}),n(r(t.toLowerCase()),function(e){var t=s(e,i,o,l);c[t.id]=t}),!0},l.remove=function(e){var t=s(e);return c[t.id]?(delete c[t.id],!0):!1}}}),r(fe,[y,f,C,w,_,R,T,M,O,I,F,z,W,V,b,l,se,E,k,le,u,d,ue,de],function(e,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E){function N(e,t,i){var o=this,a,s;a=o.documentBaseUrl=i.documentBaseURL,s=i.baseURI,o.settings=t=R({id:e,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:a,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,padd_empty_editor:!0,render_ui:!0,indentation:"30px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",validate:!0,entity_encoding:"named",url_converter:o.convertURL,url_converter_scope:o,ie7_compat:!0},t),r.language=t.language||"en",r.languageLoad=t.language_load,r.baseURL=i.baseURL,o.id=t.id=e,o.isNotDirty=!0,o.plugins={},o.documentBaseURI=new h(t.document_base_url||a,{base_uri:s}),o.baseURI=s,o.contentCSS=[],o.contentStyles=[],o.shortcuts=new E(o),o.loadedCSS={},o.editorCommands=new p(o),t.target&&(o.targetElm=t.target),o.suffix=i.suffix,o.editorManager=i,o.inline=t.inline,t.cache_suffix&&(x.cacheSuffix=t.cache_suffix.replace(/^[\?\&]+/,"")),i.fire("SetupEditor",o),o.execCallback("setup",o),o.$=n.overrideDefaults(function(){return{context:o.inline?o.getBody():o.getDoc(),element:o.getBody()}})}var k=e.DOM,S=r.ThemeManager,T=r.PluginManager,R=w.extend,A=w.each,B=w.explode,D=w.inArray,L=w.trim,M=w.resolve,H=g.Event,P=x.gecko,O=x.ie;return N.prototype={render:function(){function e(){k.unbind(window,"ready",e),n.render()}function t(){var e=m.ScriptLoader;if(r.language&&"en"!=r.language&&!r.language_url&&(r.language_url=n.editorManager.baseURL+"/langs/"+r.language+".js"),r.language_url&&e.add(r.language_url),r.theme&&"function"!=typeof r.theme&&"-"!=r.theme.charAt(0)&&!S.urls[r.theme]){var t=r.theme_url;t=t?n.documentBaseURI.toAbsolute(t):"themes/"+r.theme+"/theme"+o+".js",S.load(r.theme,t)}w.isArray(r.plugins)&&(r.plugins=r.plugins.join(" ")),A(r.external_plugins,function(e,t){T.load(t,e),r.plugins+=" "+t}),A(r.plugins.split(/[ ,]/),function(e){if(e=L(e),e&&!T.urls[e])if("-"==e.charAt(0)){e=e.substr(1,e.length);var t=T.dependencies(e);A(t,function(e){var t={prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"};e=T.createUrl(t,e),T.load(e.resource,e)})}else T.load(e,{prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"})}),e.loadQueue(function(){n.removed||n.init()})}var n=this,r=n.settings,i=n.id,o=n.suffix;if(!H.domLoaded)return void k.bind(window,"ready",e);if(n.getElement()&&x.contentEditable){r.inline?n.inline=!0:(n.orgVisibility=n.getElement().style.visibility,n.getElement().style.visibility="hidden");var a=n.getElement().form||k.getParent(i,"form");a&&(n.formElement=a,r.hidden_input&&!/TEXTAREA|INPUT/i.test(n.getElement().nodeName)&&(k.insertAfter(k.create("input",{type:"hidden",name:i}),i),n.hasHiddenInput=!0),n.formEventDelegate=function(e){n.fire(e.type,e)},k.bind(a,"submit reset",n.formEventDelegate),n.on("reset",function(){n.setContent(n.startContent,{format:"raw"})}),!r.submit_patch||a.submit.nodeType||a.submit.length||a._mceOldSubmit||(a._mceOldSubmit=a.submit,a.submit=function(){return n.editorManager.triggerSave(),n.isNotDirty=!0,a._mceOldSubmit(a)})),n.windowManager=new v(n),"xml"==r.encoding&&n.on("GetContent",function(e){e.save&&(e.content=k.encode(e.content))}),r.add_form_submit_trigger&&n.on("submit",function(){n.initialized&&n.save()}),r.add_unload_trigger&&(n._beforeUnload=function(){!n.initialized||n.destroyed||n.isHidden()||n.save({format:"raw",no_events:!0,set_dirty:!1})},n.editorManager.on("BeforeUnload",n._beforeUnload)),t()}},init:function(){function e(n){var r=T.get(n),i,o;i=T.urls[n]||t.documentBaseUrl.replace(/\/$/,""),n=L(n),r&&-1===D(m,n)&&(A(T.dependencies(n),function(t){e(t)}),o=new r(t,i,t.$),t.plugins[n]=o,o.init&&(o.init(t,i),m.push(n)))}var t=this,n=t.settings,r=t.getElement(),i,o,a,s,l,c,u,d,f,p,h,m=[];if(this.editorManager.i18n.setCode(n.language),t.rtl=this.editorManager.i18n.rtl,t.editorManager.add(t),n.aria_label=n.aria_label||k.getAttrib(r,"aria-label",t.getLang("aria.rich_text_area")),n.theme&&("function"!=typeof n.theme?(n.theme=n.theme.replace(/-/,""),c=S.get(n.theme),t.theme=new c(t,S.urls[n.theme]),t.theme.init&&t.theme.init(t,S.urls[n.theme]||t.documentBaseUrl.replace(/\/$/,""),t.$)):t.theme=n.theme),A(n.plugins.replace(/\-/g,"").split(/[ ,]/),e),n.render_ui&&t.theme&&(t.orgDisplay=r.style.display,"function"!=typeof n.theme?(i=n.width||r.style.width||r.offsetWidth,o=n.height||r.style.height||r.offsetHeight,a=n.min_height||100,p=/^[0-9\.]+(|px)$/i,p.test(""+i)&&(i=Math.max(parseInt(i,10),100)),p.test(""+o)&&(o=Math.max(parseInt(o,10),a)),l=t.theme.renderUI({targetNode:r,width:i,height:o,deltaWidth:n.delta_width,deltaHeight:n.delta_height}),n.content_editable||(o=(l.iframeHeight||o)+("number"==typeof o?l.deltaHeight||0:""),a>o&&(o=a))):(l=n.theme(t,r),l.editorContainer.nodeType&&(l.editorContainer=l.editorContainer.id=l.editorContainer.id||t.id+"_parent"),l.iframeContainer.nodeType&&(l.iframeContainer=l.iframeContainer.id=l.iframeContainer.id||t.id+"_iframecontainer"),o=l.iframeHeight||r.offsetHeight),t.editorContainer=l.editorContainer),n.content_css&&A(B(n.content_css),function(e){t.contentCSS.push(t.documentBaseURI.toAbsolute(e))}),n.content_style&&t.contentStyles.push(n.content_style),n.content_editable)return r=s=l=null,t.initContentBody();for(t.iframeHTML=n.doctype+"",n.document_base_url!=t.documentBaseUrl&&(t.iframeHTML+='
';var v='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinymce.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.initContentBody(true);})()';document.domain!=location.hostname&&(u=v);var y=k.create("iframe",{id:t.id+"_ifr",frameBorder:"0",allowTransparency:"true",title:t.editorManager.translate("Leanote Editor"),style:{width:"100%",height:o,display:"block"}});if(y.onload=function(){y.onload=null,t.fire("load")},k.setAttrib(y,"src",u||'javascript:""'),t.contentAreaContainer=l.iframeContainer,t.iframeElement=y,s=k.add(l.iframeContainer,y),O)try{t.getDoc()}catch(b){s.src=u=v}l.editorContainer&&(k.get(l.editorContainer).style.display=t.orgDisplay,t.hidden=k.isHidden(l.editorContainer)),t.getElement().style.display="none",k.setAttrib(t.id,"aria-hidden",!0),u||t.initContentBody(),r=s=l=null},initContentBody:function(t){var n=this,r=n.settings,s=n.getElement(),p=n.getDoc(),h,m;r.inline||(n.getElement().style.visibility=n.orgVisibility),t||r.content_editable||(p.open(),p.write(n.iframeHTML),p.close()),r.content_editable&&(n.on("remove",function(){var e=this.getBody();k.removeClass(e,"mce-content-body"),k.removeClass(e,"mce-edit-focus"),k.setAttrib(e,"contentEditable",null)}),k.addClass(s,"mce-content-body"),n.contentDocument=p=r.content_document||document,n.contentWindow=r.content_window||window,n.bodyElement=s,r.content_document=r.content_window=null,r.root_name=s.nodeName.toLowerCase()),h=n.getBody(),h.disabled=!0,r.readonly||(n.inline&&"static"==k.getStyle(h,"position",!0)&&(h.style.position="relative"),h.contentEditable=n.getParam("content_editable_state",!0)),h.disabled=!1,n.schema=new y(r),n.dom=new e(p,{keep_values:!0,url_converter:n.convertURL,url_converter_scope:n,hex_colors:r.force_hex_style_colors,class_filter:r.class_filter,update_styles:!0,root_element:n.inline?n.getBody():null,collect:r.content_editable,schema:n.schema,onSetAttrib:function(e){n.fire("SetAttrib",e)}}),n.parser=new b(r,n.schema),n.parser.addAttributeFilter("src,href,style,tabindex",function(e,t){for(var r=e.length,i,o=n.dom,a,s;r--;)i=e[r],a=i.attr(t),s="data-mce-"+t,i.attributes.map[s]||("style"===t?(a=o.serializeStyle(o.parseStyle(a),i.name),a.length||(a=null),i.attr(s,a),i.attr(t,a)):"tabindex"===t?(i.attr(s,a),i.attr(t,null)):i.attr(s,n.convertURL(a,t,i.name)))}),n.parser.addNodeFilter("script",function(e){for(var t=e.length,n;t--;)n=e[t],n.attr("type","mce-"+(n.attr("type")||"no/type"))}),n.parser.addNodeFilter("#cdata",function(e){for(var t=e.length,n;t--;)n=e[t],n.type=8,n.name="#comment",n.value="[CDATA["+n.value+"]]"}),n.parser.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(e){for(var t=e.length,r,i=n.schema.getNonEmptyElements();t--;)r=e[t],r.isEmpty(i)&&(r.append(new o("br",1)).shortEnded=!0)}),n.serializer=new a(r,n),n.selection=new l(n.dom,n.getWin(),n.serializer,n),n.formatter=new c(n),n.undoManager=new u(n),n.forceBlocks=new f(n),n.enterKey=new d(n),n._nodeChangeDispatcher=new i(n),n.fire("PreInit"),r.browser_spellcheck||r.gecko_spellcheck||(p.body.spellcheck=!1,k.setAttrib(h,"spellcheck","false")),n.fire("PostRender"),n.quirks=new C(n),r.directionality&&(h.dir=r.directionality),r.nowrap&&(h.style.whiteSpace="nowrap"),r.protect&&n.on("BeforeSetContent",function(e){A(r.protect,function(t){e.content=e.content.replace(t,function(e){return""})})}),n.on("SetContent",function(){n.addVisual(n.getBody())}),r.padd_empty_editor&&n.on("PostProcess",function(e){e.content=e.content.replace(/^(
[\r\n]*)$/,"")}),n.load({initial:!0,format:"html"}),n.startContent=n.getContent({format:"raw"}),n.initialized=!0,n.bindPendingEventDelegates(),n.fire("init"),n.focus(!0),n.nodeChanged({initial:!0}),n.execCallback("init_instance_callback",n),n.contentStyles.length>0&&(m="",A(n.contentStyles,function(e){m+=e+"\r\n"}),n.dom.addStyle(m)),A(n.contentCSS,function(e){n.loadedCSS[e]||(n.dom.loadCSS(e),n.loadedCSS[e]=!0)}),r.auto_focus&&setTimeout(function(){var e;e=r.auto_focus===!0?n:n.editorManager.get(r.auto_focus),e.focus()},100),s=p=h=null},focus:function(e){var t=this,n=t.selection,r=t.settings.content_editable,i,o,a=t.getDoc(),s;if(!e){if(i=n.getRng(),i.item&&(o=i.item(0)),t._refreshContentEditable(),r||(x.opera||t.getBody().focus(),t.getWin().focus()),P||r){if(s=t.getBody(),s.setActive)try{s.setActive()}catch(l){s.focus()}else s.focus();r&&n.normalize()}o&&o.ownerDocument==a&&(i=a.body.createControlRange(),i.addElement(o),i.select())}t.editorManager.setActive(t)},execCallback:function(e){var t=this,n=t.settings[e],r;if(n)return t.callbackLookup&&(r=t.callbackLookup[e])&&(n=r.func,r=r.scope),"string"==typeof n&&(r=n.replace(/\.\w+$/,""),r=r?M(r):0,n=M(n),t.callbackLookup=t.callbackLookup||{},t.callbackLookup[e]={func:n,scope:r}),n.apply(r||t,Array.prototype.slice.call(arguments,1))},translate:function(e){var t=this.settings.language||"en",n=this.editorManager.i18n;return e?n.data[t+"."+e]||e.replace(/\{\#([^\}]+)\}/g,function(e,r){return n.data[t+"."+r]||"{#"+r+"}"}):""},getLang:function(e,n){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+e]||(n!==t?n:"{#"+e+"}")},getParam:function(e,t,n){var r=e in this.settings?this.settings[e]:t,i;return"hash"===n?(i={},"string"==typeof r?A(r.split(r.indexOf("=")>0?/[;,](?![^=;,]*(?:[;,]|$))/:","),function(e){e=e.split("="),e.length>1?i[L(e[0])]=L(e[1]):i[L(e[0])]=L(e)}):i=r,i):r},nodeChanged:function(e){this._nodeChangeDispatcher.nodeChanged(e)},addButton:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),t.text||t.icon||(t.icon=e),n.buttons=n.buttons||{},t.tooltip=t.tooltip||t.title,n.buttons[e]=t},addMenuItem:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),n.menuItems=n.menuItems||{},n.menuItems[e]=t},addCommand:function(e,t,n){this.editorCommands.addCommand(e,t,n)},addQueryStateHandler:function(e,t,n){this.editorCommands.addQueryStateHandler(e,t,n)},addQueryValueHandler:function(e,t,n){this.editorCommands.addQueryValueHandler(e,t,n)},addShortcut:function(e,t,n,r){this.shortcuts.add(e,t,n,r)},execCommand:function(e,t,n,r){return this.editorCommands.execCommand(e,t,n,r)},queryCommandState:function(e){return this.editorCommands.queryCommandState(e)},queryCommandValue:function(e){return this.editorCommands.queryCommandValue(e)},queryCommandSupported:function(e){return this.editorCommands.queryCommandSupported(e)},show:function(){var e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable=!0:(k.show(e.getContainer()),k.hide(e.id)),e.load(),e.fire("show"))},hide:function(){var e=this,t=e.getDoc();e.hidden||(O&&t&&!e.inline&&t.execCommand("SelectAll"),e.save(),e.inline?(e.getBody().contentEditable=!1,e==e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(k.hide(e.getContainer()),k.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(e,t){this.fire("ProgressState",{state:e,time:t})},load:function(e){var n=this,r=n.getElement(),i;return r?(e=e||{},e.load=!0,i=n.setContent(r.value!==t?r.value:r.innerHTML,e),e.element=r,e.no_events||n.fire("LoadContent",e),e.element=r=null,i):void 0},save:function(e){var t=this,n=t.getElement(),r,i;if(n&&t.initialized)return e=e||{},e.save=!0,e.element=n,r=e.content=t.getContent(e),e.no_events||t.fire("SaveContent",e),r=e.content,/TEXTAREA|INPUT/i.test(n.nodeName)?n.value=r:(t.inline||(n.innerHTML=r),(i=k.getParent(t.id,"form"))&&A(i.elements,function(e){return e.name==t.id?(e.value=r,!1):void 0})),e.element=n=null,e.set_dirty!==!1&&(t.isNotDirty=!0),r},setContent:function(e,t){var n=this,r=n.getBody(),i;if(window.LeaAce&&window.LeaAce.canAce){var o=$(n.getBody());o&&LeaAce.destroyAceFromContent(o)}if(t=t||{},t.format=t.format||"html",t.set=!0,t.content=e,t.no_events||n.fire("BeforeSetContent",t),e=t.content,0===e.length||/^\s+$/.test(e)?(i=n.settings.forced_root_block,i&&n.schema.isValidChild(r.nodeName.toLowerCase(),i.toLowerCase())?(e=O&&11>O?"":'
',e=n.dom.createHTML(i,n.settings.forced_root_block_attrs,e)):O||(e='
'),n.dom.setHTML(r,e),n.fire("SetContent",t)):("raw"!==t.format&&(e=new s({},n.schema).serialize(n.parser.parse(e,{isRootContent:!0}))),t.content=L(e),n.dom.setHTML(r,t.content),t.no_events||n.fire("SetContent",t)),window.LeaAce&&window.LeaAce.canAce)if(LeaAce.canAce()&&LeaAce.isAce)try{LeaAce.initAceFromContent(n)}catch(a){log(a)}else $("#editorContent pre").removeClass("ace-tomorrow ace_editor");return t.content},getContent:function(e){var t=this,n,r=t.getBody();return e=e||{},e.format=e.format||"html",e.get=!0,e.getInner=!0,e.no_events||t.fire("BeforeGetContent",e),n="raw"==e.format?r.innerHTML:"text"==e.format?r.innerText||r.textContent:t.serializer.serialize(r,e),"text"!=e.format?e.content=L(n):e.content=n,e.no_events||t.fire("GetContent",e),e.content},insertContent:function(e,t){t&&(e=R({content:e},t)),this.execCommand("mceInsertContent",!1,e)},insertRawContent:function(e){this.execCommand("mceInsertRawHTML",!1,e)},isDirty:function(){return!this.isNotDirty},getContainer:function(){var e=this;return e.container||(e.container=k.get(e.editorContainer||e.id+"_parent")),e.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return this.targetElm||(this.targetElm=k.get(this.id)),this.targetElm},getWin:function(){var e=this,t;return e.contentWindow||(t=e.iframeElement,t&&(e.contentWindow=t.contentWindow)),e.contentWindow},getDoc:function(){var e=this,t;return e.contentDocument||(t=e.getWin(),t&&(e.contentDocument=t.document)),e.contentDocument},getBody:function(){return this.bodyElement||this.getDoc().body},convertURL:function(e,t,n){var r=this,i=r.settings;return i.urlconverter_callback?r.execCallback("urlconverter_callback",e,n,!0,t):!i.convert_urls||n&&"LINK"==n.nodeName||0===e.indexOf("file:")||0===e.length?e:i.relative_urls?r.documentBaseURI.toRelative(e):e=r.documentBaseURI.toAbsolute(e,i.remove_script_host)},addVisual:function(e){var n=this,r=n.settings,i=n.dom,o;e=e||n.getBody(),n.hasVisual===t&&(n.hasVisual=r.visual),A(i.select("table,a",e),function(e){var t;switch(e.nodeName){case"TABLE":return o=r.visual_table_class||"mce-item-table",t=i.getAttrib(e,"border"),void(t&&"0"!=t||!n.hasVisual?i.removeClass(e,o):i.addClass(e,o));case"A":return void(i.getAttrib(e,"href",!1)||(t=i.getAttrib(e,"name")||e.id,o=r.visual_anchor_class||"mce-item-anchor",t&&n.hasVisual?i.addClass(e,o):i.removeClass(e,o)))}}),n.fire("VisualAid",{element:e,hasVisual:n.hasVisual})},remove:function(){var e=this;e.removed||(e.save(),e.removed=1,e.unbindAllNativeEvents(),e.hasHiddenInput&&k.remove(e.getElement().nextSibling),e.inline||(O&&10>O&&e.getDoc().execCommand("SelectAll",!1,null),k.setStyle(e.id,"display",e.orgDisplay),e.getBody().onload=null),e.fire("remove"),e.editorManager.remove(e),k.remove(e.getContainer()),e.destroy())},destroy:function(e){var t=this,n;if(!t.destroyed){if(!e&&!t.removed)return void t.remove();e||(t.editorManager.off("beforeunload",t._beforeUnload),t.theme&&t.theme.destroy&&t.theme.destroy(),t.selection.destroy(),t.dom.destroy()),n=t.formElement,n&&(n._mceOldSubmit&&(n.submit=n._mceOldSubmit,n._mceOldSubmit=null),k.unbind(n,"submit reset",t.formEventDelegate)),t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null,t.selection&&(t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null),t.destroyed=1}},_refreshContentEditable:function(){var e=this,t,n;e._isHidden()&&(t=e.getBody(),n=t.parentNode,n.removeChild(t),n.appendChild(t),t.focus())},_isHidden:function(){var e;return P?(e=this.selection.getSel(),!e||!e.rangeCount||0===e.rangeCount):0}},R(N.prototype,_),N}),r(pe,[],function(){var e={},t="en";return{setCode:function(e){e&&(t=e,this.rtl=this.data[e]?"rtl"===this.data[e]._dir:!1)},getCode:function(){return t},rtl:!1,add:function(t,n){var r=e[t];r||(e[t]=r={});for(var i in n)r[i]=n[i];this.setCode(t)},translate:function(n){var r;if(r=e[t],r||(r={}),"undefined"==typeof n)return n;if("string"!=typeof n&&n.raw)return n.raw;if(n.push){var i=n.slice(1);n=(r[n[0]]||n[0]).replace(/\{([0-9]+)\}/g,function(e,t){return i[t]})}return(r[n]||n).replace(/{context:\w+}$/,"")},data:e}}),r(he,[y,u],function(e,t){function n(e){function s(){try{return document.activeElement}catch(e){return document.body}}function l(e,t){if(t&&t.startContainer){if(!e.isChildOf(t.startContainer,e.getRoot())||!e.isChildOf(t.endContainer,e.getRoot()))return;return{startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset}}return t}function c(e,t){var n;return t.startContainer?(n=e.getDoc().createRange(),n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset)):n=t,n}function u(e){return!!a.getParent(e,n.isEditorUIElement)}function d(n){var d=n.editor;d.on("init",function(){(d.inline||t.ie)&&("onbeforedeactivate"in document&&t.ie<9?d.dom.bind(d.getBody(),"beforedeactivate",function(e){if(e.target==d.getBody())try{d.lastRng=d.selection.getRng()}catch(t){}}):d.on("nodechange mouseup keyup",function(e){var t=s();"nodechange"==e.type&&e.selectionChange||(t&&t.id==d.id+"_ifr"&&(t=d.getBody()),d.dom.isChildOf(t,d.getBody())&&(d.lastRng=d.selection.getRng()))}),t.webkit&&!r&&(r=function(){var t=e.activeEditor;if(t&&t.selection){var n=t.selection.getRng();n&&!n.collapsed&&(d.lastRng=n)}},a.bind(document,"selectionchange",r)))}),d.on("setcontent",function(){d.lastRng=null}),d.on("mousedown",function(){d.selection.lastFocusBookmark=null}),d.on("focusin",function(){var t=e.focusedEditor;d.selection.lastFocusBookmark&&(d.selection.setRng(c(d,d.selection.lastFocusBookmark)),d.selection.lastFocusBookmark=null),t!=d&&(t&&t.fire("blur",{focusedEditor:d}),e.setActive(d),e.focusedEditor=d,d.fire("focus",{blurredEditor:t}),d.focus(!0)),d.lastRng=null}),d.on("focusout",function(){window.setTimeout(function(){var t=e.focusedEditor;u(s())||t!=d||(d.fire("blur",{focusedEditor:null}),e.focusedEditor=null,d.selection&&(d.selection.lastFocusBookmark=null))},0)}),i||(i=function(t){var n=e.activeEditor;n&&t.target.ownerDocument==document&&(n.selection&&t.target!=n.getBody()&&(n.selection.lastFocusBookmark=l(n.dom,n.lastRng)),t.target==document.body||u(t.target)||e.focusedEditor!=n||(n.fire("blur",{focusedEditor:null}),e.focusedEditor=null))},a.bind(document,"focusin",i)),d.inline&&!o&&(o=function(t){var n=e.activeEditor;if(n.inline&&!n.dom.isChildOf(t.target,n.getBody())){var r=n.selection.getRng();r.collapsed||(n.lastRng=r)}},a.bind(document,"mouseup",o))}function f(t){e.focusedEditor==t.editor&&(e.focusedEditor=null),e.activeEditor||(a.unbind(document,"selectionchange",r),a.unbind(document,"focusin",i),a.unbind(document,"mouseup",o),r=i=o=null)}e.on("AddEditor",d),e.on("RemoveEditor",f)}var r,i,o,a=e.DOM;return n.isEditorUIElement=function(e){return-1!==e.className.toString().indexOf("mce-")},n}),r(me,[fe,f,y,V,u,d,ce,pe,he],function(e,t,n,r,i,o,a,s,l){function c(e){var t=v.editors,n;delete t[e.id];for(var r=0;r";a.insertContent(f),c.parent().parent().close()})}}]})}a.addButton("leaui_mindmap",{icon:"mind",tooltip:"Insert/edit mind map",onclick:c,stateSelector:"img[data-mind-json]"})});tinymce.PluginManager.add("lists",function(a){function b(a){return a&&/^(OL|UL|DL)$/.test(a.nodeName)}function c(a){return a.parentNode.firstChild==a}function d(a){return a.parentNode.lastChild==a}function e(b){return b&&!!a.schema.getTextBlockElements()[b.nodeName]}var f=this;a.on("init",function(){function g(a){function b(b){var d,e,f;e=a[b?"startContainer":"endContainer"],f=a[b?"startOffset":"endOffset"],1==e.nodeType&&(d=v.create("span",{"data-mce-type":"bookmark"}),e.hasChildNodes()?(f=Math.min(f,e.childNodes.length-1),b?e.insertBefore(d,e.childNodes[f]):v.insertAfter(d,e.childNodes[f])):e.appendChild(d),e=d,f=0),c[b?"startContainer":"endContainer"]=e,c[b?"startOffset":"endOffset"]=f}var c={};return b(!0),a.collapsed||b(),c}function h(a){function b(b){function c(a){for(var b=a.parentNode.firstChild,c=0;b;){if(b==a)return c;(1!=b.nodeType||"bookmark"!=b.getAttribute("data-mce-type"))&&c++,b=b.nextSibling}return-1}var d,e,f;d=f=a[b?"startContainer":"endContainer"],e=a[b?"startOffset":"endOffset"],d&&(1==d.nodeType&&(e=c(d),d=d.parentNode,v.remove(f)),a[b?"startContainer":"endContainer"]=d,a[b?"startOffset":"endOffset"]=e)}b(!0),b();var c=v.createRng();c.setStart(a.startContainer,a.startOffset),a.endContainer&&c.setEnd(a.endContainer,a.endOffset),w.setRng(c)}function i(b,c){var d,e,f,g=v.createFragment(),h=a.schema.getBlockElements();if(a.settings.forced_root_block&&(c=c||a.settings.forced_root_block),c&&(e=v.create(c),e.tagName===a.settings.forced_root_block&&v.setAttribs(e,a.settings.forced_root_block_attrs),g.appendChild(e)),b)for(;d=b.firstChild;){var i=d.nodeName;f||"SPAN"==i&&"bookmark"==d.getAttribute("data-mce-type")||(f=!0),h[i]?(g.appendChild(d),e=null):c?(e||(e=v.create(c),g.appendChild(e)),e.appendChild(d)):g.appendChild(d)}return a.settings.forced_root_block?f||tinymce.Env.ie&&!(tinymce.Env.ie>10)||e.appendChild(v.create("br",{"data-mce-bogus":"1"})):g.appendChild(v.create("br")),g}function j(){return tinymce.grep(w.getSelectedBlocks(),function(a){return/^(LI|DT|DD)$/.test(a.nodeName)})}function k(a,b,c){function d(a){tinymce.each(g,function(c){a.parentNode.insertBefore(c,b.parentNode)}),v.remove(a)}var e,f,g,h;for(g=v.select('span[data-mce-type="bookmark"]',a),c=c||i(b),e=v.createRng(),e.setStartAfter(b),e.setEndAfter(a),f=e.extractContents(),h=f.firstChild;h;h=h.firstChild)if("LI"==h.nodeName&&v.isEmpty(h)){v.remove(h);break}v.isEmpty(f)||v.insertAfter(f,a),v.insertAfter(c,a),v.isEmpty(b.parentNode)&&d(b.parentNode),v.remove(b),v.isEmpty(a)&&v.remove(a)}function l(a){var c,d;if(c=a.nextSibling,c&&b(c)&&c.nodeName==a.nodeName){for(;d=c.firstChild;)a.appendChild(d);v.remove(c)}if(c=a.previousSibling,c&&b(c)&&c.nodeName==a.nodeName){for(;d=c.firstChild;)a.insertBefore(d,a.firstChild);v.remove(c)}}function m(a){tinymce.each(tinymce.grep(v.select("ol,ul",a)),function(a){var c,d=a.parentNode;"LI"==d.nodeName&&d.firstChild==a&&(c=d.previousSibling,c&&"LI"==c.nodeName&&(c.appendChild(a),v.isEmpty(d)&&v.remove(d))),b(d)&&(c=d.previousSibling,c&&"LI"==c.nodeName&&c.appendChild(a))})}function n(a){function e(a){v.isEmpty(a)&&v.remove(a)}var f,g=a.parentNode,h=g.parentNode;return"DD"==a.nodeName?(v.rename(a,"DT"),!0):c(a)&&d(a)?("LI"==h.nodeName?(v.insertAfter(a,h),e(h),v.remove(g)):b(h)?v.remove(g,!0):(h.insertBefore(i(a),g),v.remove(g)),!0):c(a)?("LI"==h.nodeName?(v.insertAfter(a,h),a.appendChild(g),e(h)):b(h)?h.insertBefore(a,g):(h.insertBefore(i(a),g),v.remove(a)),!0):d(a)?("LI"==h.nodeName?v.insertAfter(a,h):b(h)?v.insertAfter(a,g):(v.insertAfter(i(a),g),v.remove(a)),!0):("LI"==h.nodeName?(g=h,f=i(a,"LI")):f=b(h)?i(a,"LI"):i(a),k(g,a,f),m(g.parentNode),!0)}function o(a){function c(c,d){var e;if(b(c)){for(;e=a.lastChild.firstChild;)d.appendChild(e);v.remove(c)}}var d,e;return"DT"==a.nodeName?(v.rename(a,"DD"),!0):(d=a.previousSibling,d&&b(d)?(d.appendChild(a),!0):d&&"LI"==d.nodeName&&b(d.lastChild)?(d.lastChild.appendChild(a),c(a.lastChild,d.lastChild),!0):(d=a.nextSibling,d&&b(d)?(d.insertBefore(a,d.firstChild),!0):d&&"LI"==d.nodeName&&b(a.lastChild)?!1:(d=a.previousSibling,d&&"LI"==d.nodeName?(e=v.create(a.parentNode.nodeName),d.appendChild(e),e.appendChild(a),c(a.lastChild,e),!0):!1)))}function p(){var b=j();if(b.length){for(var c=g(w.getRng(!0)),d=0;d
")}),a.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),a.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})});!function(a,b){"use strict";function c(a,b){for(var c,d=[],f=0;f
"]]):(a=c.filter(a,[[/\n\n/g,"
"]]),-1!=a.indexOf("
$/])}function h(a){if(!c.isWordContent(a))return a;var f=[];b.each(e.schema.getBlockElements(),function(a,b){f.push(b)});var g=new RegExp("(?:
[\\s\\r\\n]+|
)*(<\\/?("+f.join("|")+")[^>]*>)(?:
[\\s\\r\\n]+|
)*","g");return a=d.filter(a,[[g,"$1"]]),a=d.filter(a,[[/
/g,"
"],[/
/g," "],[/
/g,"
"]])}function i(a){return(e.settings.paste_remove_styles||e.settings.paste_remove_styles_if_webkit!==!1)&&(a=a.replace(/ style=\"[^\"]+\"/g,"")),a}a.webkit&&(f(i),f(g)),a.ie&&f(h)}}),d("tinymce/pasteplugin/Plugin",["tinymce/PluginManager","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks"],function(a,b,c,d){var e;a.add("paste",function(a){function f(){"text"==g.pasteFormat?(this.active(!1),g.pasteFormat="html"):(g.pasteFormat="text",this.active(!0),e||(a.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),e=!0))}var g,h=this,i=a.settings;h.clipboard=g=new b(a),h.quirks=new d(a),h.wordFilter=new c(a),g.copyImage=!0,a.settings.paste_as_text&&(h.clipboard.pasteFormat="text"),i.paste_preprocess&&a.on("PastePreProcess",function(a){i.paste_preprocess.call(h,h,a)}),i.paste_postprocess&&a.on("PastePostProcess",function(a){i.paste_postprocess.call(h,h,a)}),a.addCommand("mceInsertClipboardContent",function(a,b){b.content&&h.clipboard.pasteHtml(b.content),b.text&&h.clipboard.pasteText(b.text)}),a.paste_block_drop&&a.on("dragend dragover draggesture dragdrop drop drag",function(a){a.preventDefault(),a.stopPropagation()}),a.settings.paste_data_images||a.on("drop",function(a){var b=a.dataTransfer;b&&b.files&&b.files.length>0&&a.preventDefault()}),a.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:f,active:"text"==h.clipboard.pasteFormat}),a.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:g.pasteFormat,onclick:f})})}),f(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/WordFilter"])}(this);!function(){function a(a,b,c,d,e){function f(a,b){if(b=b||0,!a[0])throw"findAndReplaceDOMText cannot handle zero-length matches";var c=a.index;if(b>0){var d=a[b];if(!d)throw"Invalid capture group";c+=a[0].indexOf(d),a[0]=d}return[c,c+a[0].length,[a[0]]]}function g(a){var b;if(3===a.nodeType)return a.data;if(n[a.nodeName]&&!m[a.nodeName])return"";if(b="",(m[a.nodeName]||o[a.nodeName])&&(b+="\n"),a=a.firstChild)do b+=g(a);while(a=a.nextSibling);return b}function h(a,b,c){var d,e,f,g,h=[],i=0,j=a,k=b.shift(),l=0;a:for(;;){if((m[j.nodeName]||o[j.nodeName])&&i++,3===j.nodeType&&(!e&&j.length+i>=k[1]?(e=j,g=k[1]-i):d&&h.push(j),!d&&j.length+i>k[0]&&(d=j,f=k[0]-i),i+=j.length),d&&e){if(j=c({startNode:d,startNodeIndex:f,endNode:e,endNodeIndex:g,innerNodes:h,match:k[2],matchIndex:l}),i-=e.length-g,d=null,e=null,h=[],k=b.shift(),l++,!k)break}else{if((!n[j.nodeName]||m[j.nodeName])&&j.firstChild){j=j.firstChild;continue}if(j.nextSibling){j=j.nextSibling;continue}}for(;;){if(j.nextSibling){j=j.nextSibling;break}if(j.parentNode===a)break a;j=j.parentNode}}}function i(a){var b;if("function"!=typeof a){var c=a.nodeType?a:l.createElement(a);b=function(a,b){var d=c.cloneNode(!1);return d.setAttribute("data-mce-index",b),a&&d.appendChild(l.createTextNode(a)),d}}else b=a;return function(a){var c,d,e,f=a.startNode,g=a.endNode,h=a.matchIndex;if(f===g){var i=f;e=i.parentNode,a.startNodeIndex>0&&(c=l.createTextNode(i.data.substring(0,a.startNodeIndex)),e.insertBefore(c,i));var j=b(a.match[0],h);return e.insertBefore(j,i),a.endNodeIndex
/gi,"\n").replace(/<\/(p|li|div|ul|ol|hr)>/,"\n").replace(/(<([^>]+)>)/gi,"").replace(/\n\n/g,"\n")):a}function d(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\n/g,"
")):a}function e(){var a=$("#editorContent").children(),b=a&&a.length>0?a[a.length-1]:null;b&&"P"==b.tagName||$("#editorContent").append('
"),k.replaceWith("
")),void k.replaceWith(""+b+"
")):(b=c(f),$(f).replaceWith(""+b+"
"));var j=LeaAce.initAce(n);j&&(j.focus(),a&&"convert"!=a&&j.session.setMode("ace/mode/"+a),e())}LeaAce.resetAddHistory()}else if("PRE"!=f.nodeName&&(f=$(f).closest("pre").get(0)),f&&"PRE"==f.nodeName){var k=$(f),o=k.html();o&&(o=o.replace(/\n/g,"
")),k.replaceWith(""+b+"
",h.insertContent(q)):f?(b=d(f),q='"+b+"
",$(f).replaceWith(q)):(q='"+b+"
",h.insertContent(q)),q&&e()}}function g(){return function(){var b=this;a.on("nodeChange",function(){var c=null;try{var d=a.selection.getNode();if("PRE"!=d.nodeName&&(d=$(d).closest("pre").get(0)),d){var e=LeaAce.isInAce(d),f=!1,g=!1;if(e||"PRE"==d.nodeName){e?(f=e[0],g=e[1]):g=$(d);var h=LeaAce.getPreBrush(g);c=$.trim(h.split(":")[1]),b.diableValue("convert",!1)}else b.diableValue("convert",!0)}}catch(i){log(i)}"convert"!=c&&b.value(c)})}}var h=a;a.addButton("leanote_code",function(){var a=["Convert Code:convert","CSS:css","HTML:html","Javascript:javascript","C/C++:c_cpp","C#:csharp","Java:java","Objective-c:objectivec","PHP:php","Python:python","Ruby:ruby","Shell:sh","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","Latex:latex","Xml:xml","ActionScript:actionScript","Matlab:matlab","Scala:scala","Sql:sql"],b=[];for(var c in a){var d=a[c].split(":");b.push({text:d[0],value:d[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:b,fixedWidth:!0,onselect:function(a){a.control.settings.value&&f(a.control.settings.value)},onPostRender:g(b)}}),a.addButton("leanote_inline_code",{icon:"code",tooltip:"Inline Code",stateSelector:"code",onclick:function(){a.execCommand("mceToggleFormat",!1,"code")}}),LeaAce.canAce()&&a.addButton("leanote_ace_pre",{icon:"ace-pre",tooltip:"Toggle ace with raw html",active:LeaAce.isAce===!1,onclick:function(){LeaAce.isAce===!1?(this.active(!1),LeaAce.isAce=!0,LeaAce.initAceFromContent(a)):(this.active(!0),LeaAce.allToPre(a),LeaAce.isAce=!1)}}),h.addCommand("toggleCode",f),h.addShortcut("ctrl+shift+c","","toggleCode"),h.addShortcut("meta+shift+c","","toggleCode"),LeaAce.canAce()&&a.on("keydown",function(a){var b=LeaAce.nowIsInAce();return b?(setTimeout(function(){b[0].focus()}),!0):void 0}),h.on("keydown",function(a){var b=a.which?a.which:a.keyCode;if(9==b&&!a.shiftKey){var c=h.selection.getNode();return c&&("LI"==c.nodeName||$(c.closest("li")).length>0)?!0:(h.insertContent(" "),a.preventDefault(),a.stopPropagation(),!1)}})});tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(c){function f(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&f(a.parentNode)}function i(a){return/INPUT|TEXTAREA|BUTTON/.test(a.tagName)&&tinymce.get(b.id)&&-1!=a.tabIndex&&f(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),c>0){for(j=g+1;j
'),!1):void 0},"childNodes"),b=i(b,!1),k(b,"rowSpan",1),k(b,"colSpan",1),d?b.appendChild(d):(!c.ie||c.ie>10)&&(b.innerHTML='
'),b}function p(){var a,b=L.createRng();return e(L.select("tr",g),function(a){0===a.cells.length&&L.remove(a)}),0===L.select("tr",g).length?(b.setStartBefore(g),b.setEndBefore(g),K.setRng(b),void L.remove(g)):(e(L.select("thead,tbody,tfoot",g),function(a){0===a.rows.length&&L.remove(a)}),h(),void(H&&(a=F[Math.min(F.length-1,H.y)],a&&(K.select(a[Math.min(a.length-1,H.x)].elm,!0),K.collapse(!0)))))}function q(a,b,c,d){var e,f,g,h,i;for(e=F[b][a].elm.parentNode,g=1;c>=g;g++)if(e=L.getNext(e,"tr")){for(f=a;f>=0;f--)if(i=F[b+g][f].elm,i.parentNode==e){for(h=1;d>=h;h++)L.insertAfter(o(i),i);break}if(-1==f)for(h=1;d>=h;h++)e.insertBefore(o(e.cells[0]),e.cells[0])}}function r(){e(F,function(a,b){e(a,function(a,c){var e,f,g;if(l(a)&&(a=a.elm,e=d(a,"colspan"),f=d(a,"rowspan"),e>1||f>1)){for(k(a,"rowSpan",1),k(a,"colSpan",1),g=0;e-1>g;g++)L.insertAfter(o(a),a);q(c,b,f-1,e)}})})}function s(b,c,d){var f,g,i,m,n,o,q,s,t,u,v;if(b?(f=A(b),g=f.x,i=f.y,m=g+(c-1),n=i+(d-1)):(H=I=null,e(F,function(a,b){e(a,function(a,c){l(a)&&(H||(H={x:c,y:b}),I={x:c,y:b})})}),H&&(g=H.x,i=H.y,m=I.x,n=I.y)),s=j(g,i),t=j(m,n),s&&t&&s.part==t.part){for(r(),h(),s=j(g,i).elm,k(s,"colSpan",m-g+1),k(s,"rowSpan",n-i+1),q=i;n>=q;q++)for(o=g;m>=o;o++)F[q]&&F[q][o]&&(b=F[q][o].elm,b!=s&&(u=a.grep(b.childNodes),e(u,function(a){s.appendChild(a)}),u.length&&(u=a.grep(s.childNodes),v=0,e(u,function(a){"BR"==a.nodeName&&L.getAttrib(a,"data-mce-bogus")&&v++
'):c.dom.add(c.getBody(),"br",{"data-mce-bogus":"1"}))}),c.on("PreProcess",function(a){var b=a.node.lastChild;b&&("BR"==b.nodeName||1==b.childNodes.length&&("BR"==b.firstChild.nodeName||"\xa0"==b.firstChild.nodeValue))&&b.previousSibling&&"TABLE"==b.previousSibling.nodeName&&c.dom.remove(b)})}function i(){function a(a,b,c,d){var e,f,g,h=3,i=a.dom.getParent(b.startContainer,"TABLE");return i&&(e=i.parentNode),f=b.startContainer.nodeType==h&&0===b.startOffset&&0===b.endOffset&&d&&("TR"==c.nodeName||c==e),g=("TD"==c.nodeName||"TH"==c.nodeName)&&!d,f||g}function b(){var b=c.selection.getRng(),d=c.selection.getNode(),e=c.dom.getParent(b.startContainer,"TD,TH");if(a(c,b,d,e)){e||(e=d);for(var f=e.lastChild;f.lastChild;)f=f.lastChild;3==f.nodeType&&(b.setEnd(f,f.data.length),c.selection.setRng(b))}}c.on("KeyDown",function(){b()}),c.on("MouseDown",function(a){2!=a.button&&b()})}function j(){c.on("keydown",function(b){if((b.keyCode==a.DELETE||b.keyCode==a.BACKSPACE)&&!b.isDefaultPrevented()){var d=c.dom.getParent(c.selection.getStart(),"table");if(d){for(var e=c.dom.select("td,th",d),f=e.length;f--;)if(!c.dom.hasClass(e[f],"mce-item-selected"))return;b.preventDefault(),c.execCommand("mceTableDelete")}}})}j(),b.webkit&&(f(),i()),b.gecko&&(g(),h()),b.ie>10&&(g(),h())}}),d("tinymce/tableplugin/CellSelection",["tinymce/tableplugin/TableGrid","tinymce/dom/TreeWalker","tinymce/util/Tools"],function(a,b,c){return function(d){function e(a){d.getBody().style.webkitUserSelect="",(a||l)&&(d.dom.removeClass(d.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),l=!1)}function f(b){var c,e,f=b.target;if(!j&&h&&(g||f!=h)&&("TD"==f.nodeName||"TH"==f.nodeName)){e=k.getParent(f,"table"),e==i&&(g||(g=new a(d,e),g.setStartCell(h),d.getBody().style.webkitUserSelect="none"),g.setEndCell(f),l=!0),c=d.selection.getSel();try{c.removeAllRanges?c.removeAllRanges():c.empty()}catch(m){}b.preventDefault()}}var g,h,i,j,k=d.dom,l=!0;return d.on("MouseDown",function(a){2==a.button||j||(e(),h=k.getParent(a.target,"td,th"),i=k.getParent(h,"table"))}),d.on("mouseover",f),d.on("remove",function(){k.unbind(d.getDoc(),"mouseover",f)}),d.on("MouseUp",function(){function a(a,d){var f=new b(a,a);do{if(3==a.nodeType&&0!==c.trim(a.nodeValue).length)return void(d?e.setStart(a,0):e.setEnd(a,a.nodeValue.length));if("BR"==a.nodeName)return void(d?e.setStartBefore(a):e.setEndBefore(a))}while(a=d?f.next():f.prev())}var e,f,j,l,m,n=d.selection;if(h){if(g&&(d.getBody().style.webkitUserSelect=""),f=k.select("td.mce-item-selected,th.mce-item-selected"),f.length>0){e=k.createRng(),l=f[0],e.setStartBefore(l),e.setEndAfter(l),a(l,1),j=new b(l,k.getParent(f[0],"table"));do if("TD"==l.nodeName||"TH"==l.nodeName){if(!k.hasClass(l,"mce-item-selected"))break;m=l}while(l=j.next());a(m),n.setRng(e)}d.nodeChanged(),h=g=i=null}}),d.on("KeyUp Drop SetContent",function(a){e("setcontent"==a.type),h=g=i=null,j=!1}),d.on("ObjectResizeStart ObjectResized",function(a){j="objectresized"!=a.type}),{clear:e}}}),d("tinymce/tableplugin/Dialogs",["tinymce/util/Tools","tinymce/Env"],function(a,b){var c=a.each;return function(d){function e(){var a=d.settings.color_picker_callback;return a?function(){var b=this;a.call(d,function(a){b.value(a).fire("change")},b.value())}:void 0}function f(a){return{title:"Advanced",type:"form",defaults:{onchange:function(){l(a,this.parents().reverse()[0],"style"==this.name())}},items:[{label:"Style",name:"style",type:"textbox"},{type:"form",padding:0,formItemDefaults:{layout:"grid",alignH:["start","right"]},defaults:{size:7},items:[{label:"Border color",type:"colorbox",name:"borderColor",onaction:e()},{label:"Background color",type:"colorbox",name:"backgroundColor",onaction:e()}]}]}}function g(a){return a?a.replace(/px$/,""):""}function h(a){return/^[0-9]+$/.test(a)&&(a+="px"),a}function i(a){c("left center right".split(" "),function(b){d.formatter.remove("align"+b,{},a)})}function j(a){c("top middle bottom".split(" "),function(b){d.formatter.remove("valign"+b,{},a)})}function k(b,c,d){function e(b,d){return d=d||[],a.each(b,function(a){var b={text:a.text||a.title};a.menu?b.menu=e(a.menu):(b.value=a.value,c&&c(b)),d.push(b)}),d}return e(b,d||[])}function l(a,b,c){var d=b.toJSON(),e=a.parseStyle(d.style);c?(b.find("#borderColor").value(e["border-color"]||"")[0].fire("change"),b.find("#backgroundColor").value(e["background-color"]||"")[0].fire("change")):(e["border-color"]=d.borderColor,e["background-color"]=d.backgroundColor),b.find("#style").value(a.serializeStyle(a.parseStyle(a.serializeStyle(e))))}function m(a,b,c){var d=a.parseStyle(a.getAttrib(c,"style"));d["border-color"]&&(b.borderColor=d["border-color"]),d["background-color"]&&(b.backgroundColor=d["background-color"]),b.style=a.serializeStyle(d)}function n(a,b,d){var e=a.parseStyle(a.getAttrib(b,"style"));c(d,function(a){e[a.name]=a.value}),a.setAttrib(b,"style",a.serializeStyle(a.parseStyle(a.serializeStyle(e))))}var o=this;o.tableProps=function(){o.table(!0)},o.table=function(e){function j(){function c(a,b,d){if("TD"===a.tagName||"TH"===a.tagName)v.setStyle(a,b,d);else if(a.children)for(var e=0;e",d=0;a>d;d++)f+=" "}return f+="",e.undoManager.transact(function(){e.insertContent(f),h=e.dom.get("__mce"),e.dom.setAttrib(h,"id",null),e.dom.setAttribs(h,e.settings.table_default_attributes||{}),e.dom.setStyles(h,e.settings.table_default_styles||{})}),h}function i(a,b){function c(){a.disabled(!e.dom.getParent(e.selection.getStart(),b)),e.selection.selectorChanged(b,function(b){a.disabled(!b)})}e.initialized?c():e.on("init",c)}function k(){i(this,"table")}function l(){i(this,"td,th")}function m(){var a="";a='"+(g.ie?" ":" ";f+="
")+"';for(var b=0;10>b;b++){a+="
",a+='";for(var c=0;10>c;c++)a+=' "}return a+="';a+=" ',g=d.length-1,k=0;j>k;k++){for(f+="
"}function e(b,c){a.undoManager.transact(function(){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()})}function f(b){a.undoManager.transact(function(){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()})}function g(c){function d(a){k.hidePanel(),k.color(a),e(k.settings.format,a)}function g(){k.hidePanel(),k.resetColor(),f(k.settings.format)}function h(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var j,k=this.parent();tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(k.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=k.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e",h=0;i>h;h++)l=k*i+h,l>g?f+=" "}if(a.settings.color_picker_callback){for(f+='":(e=d[l],f+=b(e.color,e.text));f+=" ",f+="",h=0;i>h;h++)f+=b("","Custom color");f+=" "}return f+="";a.insertContent(f),c.parent().parent().close()})}}]})}a.addButton("leaui_mindmap",{icon:"mind",tooltip:"Insert/edit mind map",onclick:c,stateSelector:"img[data-mind-json]"})});tinymce.PluginManager.add("lists",function(a){function b(a){return a&&/^(OL|UL|DL)$/.test(a.nodeName)}function c(a){return a.parentNode.firstChild==a}function d(a){return a.parentNode.lastChild==a}function e(b){return b&&!!a.schema.getTextBlockElements()[b.nodeName]}var f=this;a.on("init",function(){function g(a){function b(b){var d,e,f;e=a[b?"startContainer":"endContainer"],f=a[b?"startOffset":"endOffset"],1==e.nodeType&&(d=v.create("span",{"data-mce-type":"bookmark"}),e.hasChildNodes()?(f=Math.min(f,e.childNodes.length-1),b?e.insertBefore(d,e.childNodes[f]):v.insertAfter(d,e.childNodes[f])):e.appendChild(d),e=d,f=0),c[b?"startContainer":"endContainer"]=e,c[b?"startOffset":"endOffset"]=f}var c={};return b(!0),a.collapsed||b(),c}function h(a){function b(b){function c(a){for(var b=a.parentNode.firstChild,c=0;b;){if(b==a)return c;(1!=b.nodeType||"bookmark"!=b.getAttribute("data-mce-type"))&&c++,b=b.nextSibling}return-1}var d,e,f;d=f=a[b?"startContainer":"endContainer"],e=a[b?"startOffset":"endOffset"],d&&(1==d.nodeType&&(e=c(d),d=d.parentNode,v.remove(f)),a[b?"startContainer":"endContainer"]=d,a[b?"startOffset":"endOffset"]=e)}b(!0),b();var c=v.createRng();c.setStart(a.startContainer,a.startOffset),a.endContainer&&c.setEnd(a.endContainer,a.endOffset),w.setRng(c)}function i(b,c){var d,e,f,g=v.createFragment(),h=a.schema.getBlockElements();if(a.settings.forced_root_block&&(c=c||a.settings.forced_root_block),c&&(e=v.create(c),e.tagName===a.settings.forced_root_block&&v.setAttribs(e,a.settings.forced_root_block_attrs),g.appendChild(e)),b)for(;d=b.firstChild;){var i=d.nodeName;f||"SPAN"==i&&"bookmark"==d.getAttribute("data-mce-type")||(f=!0),h[i]?(g.appendChild(d),e=null):c?(e||(e=v.create(c),g.appendChild(e)),e.appendChild(d)):g.appendChild(d)}return a.settings.forced_root_block?f||tinymce.Env.ie&&!(tinymce.Env.ie>10)||e.appendChild(v.create("br",{"data-mce-bogus":"1"})):g.appendChild(v.create("br")),g}function j(){return tinymce.grep(w.getSelectedBlocks(),function(a){return/^(LI|DT|DD)$/.test(a.nodeName)})}function k(a,b,c){function d(a){tinymce.each(g,function(c){a.parentNode.insertBefore(c,b.parentNode)}),v.remove(a)}var e,f,g,h;for(g=v.select('span[data-mce-type="bookmark"]',a),c=c||i(b),e=v.createRng(),e.setStartAfter(b),e.setEndAfter(a),f=e.extractContents(),h=f.firstChild;h;h=h.firstChild)if("LI"==h.nodeName&&v.isEmpty(h)){v.remove(h);break}v.isEmpty(f)||v.insertAfter(f,a),v.insertAfter(c,a),v.isEmpty(b.parentNode)&&d(b.parentNode),v.remove(b),v.isEmpty(a)&&v.remove(a)}function l(a){var c,d;if(c=a.nextSibling,c&&b(c)&&c.nodeName==a.nodeName){for(;d=c.firstChild;)a.appendChild(d);v.remove(c)}if(c=a.previousSibling,c&&b(c)&&c.nodeName==a.nodeName){for(;d=c.firstChild;)a.insertBefore(d,a.firstChild);v.remove(c)}}function m(a){tinymce.each(tinymce.grep(v.select("ol,ul",a)),function(a){var c,d=a.parentNode;"LI"==d.nodeName&&d.firstChild==a&&(c=d.previousSibling,c&&"LI"==c.nodeName&&(c.appendChild(a),v.isEmpty(d)&&v.remove(d))),b(d)&&(c=d.previousSibling,c&&"LI"==c.nodeName&&c.appendChild(a))})}function n(a){function e(a){v.isEmpty(a)&&v.remove(a)}var f,g=a.parentNode,h=g.parentNode;return"DD"==a.nodeName?(v.rename(a,"DT"),!0):c(a)&&d(a)?("LI"==h.nodeName?(v.insertAfter(a,h),e(h),v.remove(g)):b(h)?v.remove(g,!0):(h.insertBefore(i(a),g),v.remove(g)),!0):c(a)?("LI"==h.nodeName?(v.insertAfter(a,h),a.appendChild(g),e(h)):b(h)?h.insertBefore(a,g):(h.insertBefore(i(a),g),v.remove(a)),!0):d(a)?("LI"==h.nodeName?v.insertAfter(a,h):b(h)?v.insertAfter(a,g):(v.insertAfter(i(a),g),v.remove(a)),!0):("LI"==h.nodeName?(g=h,f=i(a,"LI")):f=b(h)?i(a,"LI"):i(a),k(g,a,f),m(g.parentNode),!0)}function o(a){function c(c,d){var e;if(b(c)){for(;e=a.lastChild.firstChild;)d.appendChild(e);v.remove(c)}}var d,e;return"DT"==a.nodeName?(v.rename(a,"DD"),!0):(d=a.previousSibling,d&&b(d)?(d.appendChild(a),!0):d&&"LI"==d.nodeName&&b(d.lastChild)?(d.lastChild.appendChild(a),c(a.lastChild,d.lastChild),!0):(d=a.nextSibling,d&&b(d)?(d.insertBefore(a,d.firstChild),!0):d&&"LI"==d.nodeName&&b(a.lastChild)?!1:(d=a.previousSibling,d&&"LI"==d.nodeName?(e=v.create(a.parentNode.nodeName),d.appendChild(e),e.appendChild(a),c(a.lastChild,e),!0):!1)))}function p(){var b=j();if(b.length){for(var c=g(w.getRng(!0)),d=0;d
")}),a.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),a.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})});!function(a,b){"use strict";function c(a,b){for(var c,d=[],f=0;f
"]]):(a=c.filter(a,[[/\n\n/g,"
"]]),-1!=a.indexOf("
$/])}function h(a){if(!c.isWordContent(a))return a;var f=[];b.each(e.schema.getBlockElements(),function(a,b){f.push(b)});var g=new RegExp("(?:
[\\s\\r\\n]+|
)*(<\\/?("+f.join("|")+")[^>]*>)(?:
[\\s\\r\\n]+|
)*","g");return a=d.filter(a,[[g,"$1"]]),a=d.filter(a,[[/
/g,"
"],[/
/g," "],[/
/g,"
"]])}function i(a){return(e.settings.paste_remove_styles||e.settings.paste_remove_styles_if_webkit!==!1)&&(a=a.replace(/ style=\"[^\"]+\"/g,"")),a}a.webkit&&(f(i),f(g)),a.ie&&f(h)}}),d("tinymce/pasteplugin/Plugin",["tinymce/PluginManager","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks"],function(a,b,c,d){var e;a.add("paste",function(a){function f(){"text"==g.pasteFormat?(this.active(!1),g.pasteFormat="html"):(g.pasteFormat="text",this.active(!0),e||(a.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),e=!0))}var g,h=this,i=a.settings;h.clipboard=g=new b(a),h.quirks=new d(a),h.wordFilter=new c(a),g.copyImage=!0,a.settings.paste_as_text&&(h.clipboard.pasteFormat="text"),i.paste_preprocess&&a.on("PastePreProcess",function(a){i.paste_preprocess.call(h,h,a)}),i.paste_postprocess&&a.on("PastePostProcess",function(a){i.paste_postprocess.call(h,h,a)}),a.addCommand("mceInsertClipboardContent",function(a,b){b.content&&h.clipboard.pasteHtml(b.content),b.text&&h.clipboard.pasteText(b.text)}),a.paste_block_drop&&a.on("dragend dragover draggesture dragdrop drop drag",function(a){a.preventDefault(),a.stopPropagation()}),a.settings.paste_data_images||a.on("drop",function(a){var b=a.dataTransfer;b&&b.files&&b.files.length>0&&a.preventDefault()}),a.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:f,active:"text"==h.clipboard.pasteFormat}),a.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:g.pasteFormat,onclick:f})})}),f(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/WordFilter"])}(this);!function(){function a(a,b,c,d,e){function f(a,b){if(b=b||0,!a[0])throw"findAndReplaceDOMText cannot handle zero-length matches";var c=a.index;if(b>0){var d=a[b];if(!d)throw"Invalid capture group";c+=a[0].indexOf(d),a[0]=d}return[c,c+a[0].length,[a[0]]]}function g(a){var b;if(3===a.nodeType)return a.data;if(n[a.nodeName]&&!m[a.nodeName])return"";if(b="",(m[a.nodeName]||o[a.nodeName])&&(b+="\n"),a=a.firstChild)do b+=g(a);while(a=a.nextSibling);return b}function h(a,b,c){var d,e,f,g,h=[],i=0,j=a,k=b.shift(),l=0;a:for(;;){if((m[j.nodeName]||o[j.nodeName])&&i++,3===j.nodeType&&(!e&&j.length+i>=k[1]?(e=j,g=k[1]-i):d&&h.push(j),!d&&j.length+i>k[0]&&(d=j,f=k[0]-i),i+=j.length),d&&e){if(j=c({startNode:d,startNodeIndex:f,endNode:e,endNodeIndex:g,innerNodes:h,match:k[2],matchIndex:l}),i-=e.length-g,d=null,e=null,h=[],k=b.shift(),l++,!k)break}else{if((!n[j.nodeName]||m[j.nodeName])&&j.firstChild){j=j.firstChild;continue}if(j.nextSibling){j=j.nextSibling;continue}}for(;;){if(j.nextSibling){j=j.nextSibling;break}if(j.parentNode===a)break a;j=j.parentNode}}}function i(a){var b;if("function"!=typeof a){var c=a.nodeType?a:l.createElement(a);b=function(a,b){var d=c.cloneNode(!1);return d.setAttribute("data-mce-index",b),a&&d.appendChild(l.createTextNode(a)),d}}else b=a;return function(a){var c,d,e,f=a.startNode,g=a.endNode,h=a.matchIndex;if(f===g){var i=f;e=i.parentNode,a.startNodeIndex>0&&(c=l.createTextNode(i.data.substring(0,a.startNodeIndex)),e.insertBefore(c,i));var j=b(a.match[0],h);return e.insertBefore(j,i),a.endNodeIndex
/gi,"\n").replace(/<\/(p|li|div|ul|ol|hr)>/,"\n").replace(/(<([^>]+)>)/gi,"").replace(/\n\n/g,"\n")):a}function d(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\n/g,"
")):a}function e(){var a=$("#editorContent").children(),b=a&&a.length>0?a[a.length-1]:null;b&&"P"==b.tagName||$("#editorContent").append('
"),k.replaceWith("
")),void k.replaceWith(""+b+"
")):(b=c(f),$(f).replaceWith(""+b+"
"));var j=LeaAce.initAce(n);j&&(j.focus(),a&&"convert"!=a&&j.session.setMode("ace/mode/"+a),e())}LeaAce.resetAddHistory()}else if("PRE"!=f.nodeName&&(f=$(f).closest("pre").get(0)),f&&"PRE"==f.nodeName){var k=$(f),o=k.html();o&&(o=o.replace(/\n/g,"
")),k.replaceWith(""+b+"
",h.insertContent(q)):f?(b=d(f),q='"+b+"
",$(f).replaceWith(q)):(q='"+b+"
",h.insertContent(q)),q&&e()}}function g(){return function(){var b=this;a.on("nodeChange",function(){var c=null;try{var d=a.selection.getNode();if("PRE"!=d.nodeName&&(d=$(d).closest("pre").get(0)),d){var e=LeaAce.isInAce(d),f=!1,g=!1;if(e||"PRE"==d.nodeName){e?(f=e[0],g=e[1]):g=$(d);var h=LeaAce.getPreBrush(g);c=$.trim(h.split(":")[1]),b.diableValue("convert",!1)}else b.diableValue("convert",!0)}}catch(i){log(i)}"convert"!=c&&b.value(c)})}}var h=a;a.addButton("leanote_code",function(){var a=["Convert Code:convert","CSS:css","HTML:html","Javascript:javascript","C/C++:c_cpp","C#:csharp","Java:java","Objective-c:objectivec","PHP:php","Python:python","Ruby:ruby","Shell:sh","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","Latex:latex","Xml:xml","ActionScript:actionScript","Matlab:matlab","Scala:scala","Sql:sql"],b=[];for(var c in a){var d=a[c].split(":");b.push({text:d[0],value:d[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:b,fixedWidth:!0,onselect:function(a){a.control.settings.value&&f(a.control.settings.value)},onPostRender:g(b)}}),a.addButton("leanote_inline_code",{icon:"code",tooltip:"Inline Code",stateSelector:"code",onclick:function(){a.execCommand("mceToggleFormat",!1,"code")}}),LeaAce.canAce()&&a.addButton("leanote_ace_pre",{icon:"ace-pre",tooltip:"Toggle ace with raw html",active:LeaAce.isAce===!1,onclick:function(){LeaAce.isAce===!1?(this.active(!1),LeaAce.isAce=!0,LeaAce.initAceFromContent(a)):(this.active(!0),LeaAce.allToPre(a),LeaAce.isAce=!1)}}),h.addCommand("toggleCode",f),h.addShortcut("ctrl+shift+c","","toggleCode"),h.addShortcut("meta+shift+c","","toggleCode"),LeaAce.canAce()&&a.on("keydown",function(a){var b=LeaAce.nowIsInAce();return b?(setTimeout(function(){b[0].focus()}),!0):void 0}),h.on("keydown",function(a){var b=a.which?a.which:a.keyCode;if(9==b&&!a.shiftKey){var c=h.selection.getNode();return c&&("LI"==c.nodeName||$(c.closest("li")).length>0)?!0:(h.insertContent(" "),a.preventDefault(),a.stopPropagation(),!1)}})});tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(c){function f(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&f(a.parentNode)}function i(a){return/INPUT|TEXTAREA|BUTTON/.test(a.tagName)&&tinymce.get(b.id)&&-1!=a.tabIndex&&f(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),c>0){for(j=g+1;j
'),!1):void 0},"childNodes"),b=i(b,!1),k(b,"rowSpan",1),k(b,"colSpan",1),d?b.appendChild(d):(!c.ie||c.ie>10)&&(b.innerHTML='
'),b}function p(){var a,b=L.createRng();return e(L.select("tr",g),function(a){0===a.cells.length&&L.remove(a)}),0===L.select("tr",g).length?(b.setStartBefore(g),b.setEndBefore(g),K.setRng(b),void L.remove(g)):(e(L.select("thead,tbody,tfoot",g),function(a){0===a.rows.length&&L.remove(a)}),h(),void(H&&(a=F[Math.min(F.length-1,H.y)],a&&(K.select(a[Math.min(a.length-1,H.x)].elm,!0),K.collapse(!0)))))}function q(a,b,c,d){var e,f,g,h,i;for(e=F[b][a].elm.parentNode,g=1;c>=g;g++)if(e=L.getNext(e,"tr")){for(f=a;f>=0;f--)if(i=F[b+g][f].elm,i.parentNode==e){for(h=1;d>=h;h++)L.insertAfter(o(i),i);break}if(-1==f)for(h=1;d>=h;h++)e.insertBefore(o(e.cells[0]),e.cells[0])}}function r(){e(F,function(a,b){e(a,function(a,c){var e,f,g;if(l(a)&&(a=a.elm,e=d(a,"colspan"),f=d(a,"rowspan"),e>1||f>1)){for(k(a,"rowSpan",1),k(a,"colSpan",1),g=0;e-1>g;g++)L.insertAfter(o(a),a);q(c,b,f-1,e)}})})}function s(b,c,d){var f,g,i,m,n,o,q,s,t,u,v;if(b?(f=A(b),g=f.x,i=f.y,m=g+(c-1),n=i+(d-1)):(H=I=null,e(F,function(a,b){e(a,function(a,c){l(a)&&(H||(H={x:c,y:b}),I={x:c,y:b})})}),H&&(g=H.x,i=H.y,m=I.x,n=I.y)),s=j(g,i),t=j(m,n),s&&t&&s.part==t.part){for(r(),h(),s=j(g,i).elm,k(s,"colSpan",m-g+1),k(s,"rowSpan",n-i+1),q=i;n>=q;q++)for(o=g;m>=o;o++)F[q]&&F[q][o]&&(b=F[q][o].elm,b!=s&&(u=a.grep(b.childNodes),e(u,function(a){s.appendChild(a)}),u.length&&(u=a.grep(s.childNodes),v=0,e(u,function(a){"BR"==a.nodeName&&L.getAttrib(a,"data-mce-bogus")&&v++
'):c.dom.add(c.getBody(),"br",{"data-mce-bogus":"1"}))}),c.on("PreProcess",function(a){var b=a.node.lastChild;b&&("BR"==b.nodeName||1==b.childNodes.length&&("BR"==b.firstChild.nodeName||"\xa0"==b.firstChild.nodeValue))&&b.previousSibling&&"TABLE"==b.previousSibling.nodeName&&c.dom.remove(b)})}function i(){function a(a,b,c,d){var e,f,g,h=3,i=a.dom.getParent(b.startContainer,"TABLE");return i&&(e=i.parentNode),f=b.startContainer.nodeType==h&&0===b.startOffset&&0===b.endOffset&&d&&("TR"==c.nodeName||c==e),g=("TD"==c.nodeName||"TH"==c.nodeName)&&!d,f||g}function b(){var b=c.selection.getRng(),d=c.selection.getNode(),e=c.dom.getParent(b.startContainer,"TD,TH");if(a(c,b,d,e)){e||(e=d);for(var f=e.lastChild;f.lastChild;)f=f.lastChild;3==f.nodeType&&(b.setEnd(f,f.data.length),c.selection.setRng(b))}}c.on("KeyDown",function(){b()}),c.on("MouseDown",function(a){2!=a.button&&b()})}function j(){c.on("keydown",function(b){if((b.keyCode==a.DELETE||b.keyCode==a.BACKSPACE)&&!b.isDefaultPrevented()){var d=c.dom.getParent(c.selection.getStart(),"table");if(d){for(var e=c.dom.select("td,th",d),f=e.length;f--;)if(!c.dom.hasClass(e[f],"mce-item-selected"))return;b.preventDefault(),c.execCommand("mceTableDelete")}}})}j(),b.webkit&&(f(),i()),b.gecko&&(g(),h()),b.ie>10&&(g(),h())}}),d("tinymce/tableplugin/CellSelection",["tinymce/tableplugin/TableGrid","tinymce/dom/TreeWalker","tinymce/util/Tools"],function(a,b,c){return function(d){function e(a){d.getBody().style.webkitUserSelect="",(a||l)&&(d.dom.removeClass(d.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),l=!1)}function f(b){var c,e,f=b.target;if(!j&&h&&(g||f!=h)&&("TD"==f.nodeName||"TH"==f.nodeName)){e=k.getParent(f,"table"),e==i&&(g||(g=new a(d,e),g.setStartCell(h),d.getBody().style.webkitUserSelect="none"),g.setEndCell(f),l=!0),c=d.selection.getSel();try{c.removeAllRanges?c.removeAllRanges():c.empty()}catch(m){}b.preventDefault()}}var g,h,i,j,k=d.dom,l=!0;return d.on("MouseDown",function(a){2==a.button||j||(e(),h=k.getParent(a.target,"td,th"),i=k.getParent(h,"table"))}),d.on("mouseover",f),d.on("remove",function(){k.unbind(d.getDoc(),"mouseover",f)}),d.on("MouseUp",function(){function a(a,d){var f=new b(a,a);do{if(3==a.nodeType&&0!==c.trim(a.nodeValue).length)return void(d?e.setStart(a,0):e.setEnd(a,a.nodeValue.length));if("BR"==a.nodeName)return void(d?e.setStartBefore(a):e.setEndBefore(a))}while(a=d?f.next():f.prev())}var e,f,j,l,m,n=d.selection;if(h){if(g&&(d.getBody().style.webkitUserSelect=""),f=k.select("td.mce-item-selected,th.mce-item-selected"),f.length>0){e=k.createRng(),l=f[0],e.setStartBefore(l),e.setEndAfter(l),a(l,1),j=new b(l,k.getParent(f[0],"table"));do if("TD"==l.nodeName||"TH"==l.nodeName){if(!k.hasClass(l,"mce-item-selected"))break;m=l}while(l=j.next());a(m),n.setRng(e)}d.nodeChanged(),h=g=i=null}}),d.on("KeyUp Drop SetContent",function(a){e("setcontent"==a.type),h=g=i=null,j=!1}),d.on("ObjectResizeStart ObjectResized",function(a){j="objectresized"!=a.type}),{clear:e}}}),d("tinymce/tableplugin/Dialogs",["tinymce/util/Tools","tinymce/Env"],function(a,b){var c=a.each;return function(d){function e(){var a=d.settings.color_picker_callback;return a?function(){var b=this;a.call(d,function(a){b.value(a).fire("change")},b.value())}:void 0}function f(a){return{title:"Advanced",type:"form",defaults:{onchange:function(){l(a,this.parents().reverse()[0],"style"==this.name())}},items:[{label:"Style",name:"style",type:"textbox"},{type:"form",padding:0,formItemDefaults:{layout:"grid",alignH:["start","right"]},defaults:{size:7},items:[{label:"Border color",type:"colorbox",name:"borderColor",onaction:e()},{label:"Background color",type:"colorbox",name:"backgroundColor",onaction:e()}]}]}}function g(a){return a?a.replace(/px$/,""):""}function h(a){return/^[0-9]+$/.test(a)&&(a+="px"),a}function i(a){c("left center right".split(" "),function(b){d.formatter.remove("align"+b,{},a)})}function j(a){c("top middle bottom".split(" "),function(b){d.formatter.remove("valign"+b,{},a)})}function k(b,c,d){function e(b,d){return d=d||[],a.each(b,function(a){var b={text:a.text||a.title};a.menu?b.menu=e(a.menu):(b.value=a.value,c&&c(b)),d.push(b)}),d}return e(b,d||[])}function l(a,b,c){var d=b.toJSON(),e=a.parseStyle(d.style);c?(b.find("#borderColor").value(e["border-color"]||"")[0].fire("change"),b.find("#backgroundColor").value(e["background-color"]||"")[0].fire("change")):(e["border-color"]=d.borderColor,e["background-color"]=d.backgroundColor),b.find("#style").value(a.serializeStyle(a.parseStyle(a.serializeStyle(e))))}function m(a,b,c){var d=a.parseStyle(a.getAttrib(c,"style"));d["border-color"]&&(b.borderColor=d["border-color"]),d["background-color"]&&(b.backgroundColor=d["background-color"]),b.style=a.serializeStyle(d)}function n(a,b,d){var e=a.parseStyle(a.getAttrib(b,"style"));c(d,function(a){e[a.name]=a.value}),a.setAttrib(b,"style",a.serializeStyle(a.parseStyle(a.serializeStyle(e))))}var o=this;o.tableProps=function(){o.table(!0)},o.table=function(e){function j(){function c(a,b,d){if("TD"===a.tagName||"TH"===a.tagName)v.setStyle(a,b,d);else if(a.children)for(var e=0;e",d=0;a>d;d++)f+=" "}return f+="",e.undoManager.transact(function(){e.insertContent(f),h=e.dom.get("__mce"),e.dom.setAttrib(h,"id",null),e.dom.setAttribs(h,e.settings.table_default_attributes||{}),e.dom.setStyles(h,e.settings.table_default_styles||{})}),h}function i(a,b){function c(){a.disabled(!e.dom.getParent(e.selection.getStart(),b)),e.selection.selectorChanged(b,function(b){a.disabled(!b)})}e.initialized?c():e.on("init",c)}function k(){i(this,"table")}function l(){i(this,"td,th")}function m(){var a="";a='"+(g.ie?" ":" ";f+="
")+"';for(var b=0;10>b;b++){a+="
",a+='";for(var c=0;10>c;c++)a+=' "}return a+="';a+=" ',g=d.length-1,k=0;j>k;k++){for(f+="
"}function e(b,c){a.undoManager.transact(function(){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()})}function f(b){a.undoManager.transact(function(){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()})}function g(c){function d(a){k.hidePanel(),k.color(a),e(k.settings.format,a)}function g(){k.hidePanel(),k.resetColor(),f(k.settings.format)}function h(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var j,k=this.parent();tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(k.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=k.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e",h=0;i>h;h++)l=k*i+h,l>g?f+=" "}if(a.settings.color_picker_callback){for(f+='":(e=d[l],f+=b(e.color,e.text));f+=" ",f+="",h=0;i>h;h++)f+=b("","Custom color");f+=" "}return f+="