From 6329acbf2807915c0e0525c800ce88252f50ae6c Mon Sep 17 00:00:00 2001
From: Oliver Pulges foo foo bar doesn't need to be closed according HTML4-5 spec, we simply replace it with a
useLineBreaks: true,
// Double enter (enter on blank line) exits block element in useLineBreaks mode.
@@ -18367,16 +17124,16 @@ wysihtml5.views.View = Base.extend(
copyedFromMarking: ''
};
- wysihtml5.Editor = wysihtml5.lang.Dispatcher.extend(
- /** @scope wysihtml5.Editor.prototype */ {
+ wysihtml.Editor = wysihtml.lang.Dispatcher.extend(
+ /** @scope wysihtml.Editor.prototype */ {
constructor: function(editableElement, config) {
this.editableElement = typeof(editableElement) === "string" ? document.getElementById(editableElement) : editableElement;
- this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config).get();
- this._isCompatible = wysihtml5.browser.supported();
+ this.config = wysihtml.lang.object({}).merge(defaultConfig).merge(config).get();
+ this._isCompatible = wysihtml.browser.supported();
// merge classNames
if (config && config.classNames) {
- wysihtml5.lang.object(this.config.classNames).merge(config.classNames);
+ wysihtml.lang.object(this.config.classNames).merge(config.classNames);
}
if (this.editableElement.nodeName.toLowerCase() != "textarea") {
@@ -18384,21 +17141,21 @@ wysihtml5.views.View = Base.extend(
this.config.noTextarea = true;
}
if (!this.config.noTextarea) {
- this.textarea = new wysihtml5.views.Textarea(this, this.editableElement, this.config);
+ this.textarea = new wysihtml.views.Textarea(this, this.editableElement, this.config);
this.currentView = this.textarea;
}
// Sort out unsupported/unwanted browsers here
- if (!this._isCompatible || (!this.config.supportTouchDevices && wysihtml5.browser.isTouchDevice())) {
+ if (!this._isCompatible || (!this.config.supportTouchDevices && wysihtml.browser.isTouchDevice())) {
var that = this;
setTimeout(function() { that.fire("beforeload").fire("load"); }, 0);
return;
}
// Add class name to body, to indicate that the editor is supported
- wysihtml5.dom.addClass(document.body, this.config.classNames.body);
+ wysihtml.dom.addClass(document.body, this.config.classNames.body);
- this.composer = new wysihtml5.views.Composer(this, this.editableElement, this.config);
+ this.composer = new wysihtml.views.Composer(this, this.editableElement, this.config);
this.currentView = this.composer;
if (typeof(this.config.parser) === "function") {
@@ -18410,12 +17167,15 @@ wysihtml5.views.View = Base.extend(
handleBeforeLoad: function() {
if (!this.config.noTextarea) {
- this.synchronizer = new wysihtml5.views.Synchronizer(this, this.textarea, this.composer);
+ this.synchronizer = new wysihtml.views.Synchronizer(this, this.textarea, this.composer);
} else {
- this.sourceView = new wysihtml5.views.SourceView(this, this.composer);
+ this.sourceView = new wysihtml.views.SourceView(this, this.composer);
}
if (this.config.toolbar) {
- this.toolbar = new wysihtml5.toolbar.Toolbar(this, this.config.toolbar, this.config.showToolbarAfterInit);
+ if (typeof wysihtml.toolbar === "undefined") {
+ throw Error("Toolbar not found. Make sure you're loading wysihtml-toolbar.js or wysihtml-toolbar.min.js");
+ }
+ this.toolbar = new wysihtml.toolbar.Toolbar(this, this.config.toolbar, this.config.showToolbarAfterInit);
}
},
@@ -18496,7 +17256,7 @@ wysihtml5.views.View = Base.extend(
"clearInternals" : clearInternals
});
if (typeof(htmlOrElement) === "object") {
- wysihtml5.quirks.redraw(htmlOrElement);
+ wysihtml.quirks.redraw(htmlOrElement);
}
return returnValue;
},
@@ -18508,10 +17268,10 @@ wysihtml5.views.View = Base.extend(
_initParser: function() {
var oldHtml;
- if (wysihtml5.browser.supportsModernPaste()) {
+ if (wysihtml.browser.supportsModernPaste()) {
this.on("paste:composer", function(event) {
event.preventDefault();
- oldHtml = wysihtml5.dom.getPastedHtml(event);
+ oldHtml = wysihtml.dom.getPastedHtml(event);
if (oldHtml) {
this._cleanAndPaste(oldHtml);
}
@@ -18522,7 +17282,7 @@ wysihtml5.views.View = Base.extend(
event.preventDefault();
var scrollPos = this.composer.getScrollPos();
- wysihtml5.dom.getPastedHtmlWithDiv(this.composer, function(pastedHTML) {
+ wysihtml.dom.getPastedHtmlWithDiv(this.composer, function(pastedHTML) {
if (pastedHTML) {
this._cleanAndPaste(pastedHTML);
}
@@ -18534,7 +17294,7 @@ wysihtml5.views.View = Base.extend(
},
_cleanAndPaste: function (oldHtml) {
- var cleanHtml = wysihtml5.quirks.cleanPastedHTML(oldHtml, {
+ var cleanHtml = wysihtml.quirks.cleanPastedHTML(oldHtml, {
"referenceNode": this.composer.element,
"rules": this.config.pasteParserRulesets || [{"set": this.config.parserRules}],
"uneditableClass": this.config.classNames.uneditableContainer
@@ -18543,7 +17303,7 @@ wysihtml5.views.View = Base.extend(
this.composer.selection.insertHTML(cleanHtml);
}
});
-})(wysihtml5);
+})(wysihtml);
;/**
* Toolbar Dialog
*
@@ -18565,7 +17325,7 @@ wysihtml5.views.View = Base.extend(
*
*
*
*/
-(function(wysihtml5) {
- var dom = wysihtml5.dom,
+(function(wysihtml) {
+ var dom = wysihtml.dom,
CLASS_NAME_OPENED = "wysihtml5-command-dialog-opened",
SELECTOR_FORM_ELEMENTS = "input, select, textarea",
SELECTOR_FIELDS = "[data-wysihtml5-dialog-field]",
ATTRIBUTE_FIELDS = "data-wysihtml5-dialog-field";
- wysihtml5.toolbar.Dialog = wysihtml5.lang.Dispatcher.extend(
- /** @scope wysihtml5.toolbar.Dialog.prototype */ {
+ wysihtml.toolbar.Dialog = wysihtml.lang.Dispatcher.extend(
+ /** @scope wysihtml.toolbar.Dialog.prototype */ {
constructor: function(link, container) {
this.link = link;
this.container = container;
@@ -18611,10 +17371,10 @@ wysihtml5.views.View = Base.extend(
dom.observe(this.container, "keydown", function(event) {
var keyCode = event.keyCode;
- if (keyCode === wysihtml5.ENTER_KEY) {
+ if (keyCode === wysihtml.ENTER_KEY) {
callbackWrapper(event);
}
- if (keyCode === wysihtml5.ESCAPE_KEY) {
+ if (keyCode === wysihtml.ESCAPE_KEY) {
that.cancel();
}
});
@@ -18738,7 +17498,7 @@ wysihtml5.views.View = Base.extend(
this.fire("cancel");
}
});
-})(wysihtml5); //jshint ignore:line
+})(wysihtml); //jshint ignore:line
;/**
* Converts speech-to-text and inserts this into the editor
* As of now (2011/03/25) this only is supported in Chrome >= 11
@@ -18752,8 +17512,8 @@ wysihtml5.views.View = Base.extend(
* "Accessing Google Speech API Chrome 11"
* http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/
*/
-(function(wysihtml5) {
- var dom = wysihtml5.dom;
+(function(wysihtml) {
+ var dom = wysihtml.dom;
var linkStyles = {
position: "relative"
@@ -18787,9 +17547,9 @@ wysihtml5.views.View = Base.extend(
"speech": ""
};
- wysihtml5.toolbar.Speech = function(parent, link) {
+ wysihtml.toolbar.Speech = function(parent, link) {
var input = document.createElement("input");
- if (!wysihtml5.browser.supportsSpeechApiOn(input)) {
+ if (!wysihtml.browser.supportsSpeechApiOn(input)) {
link.style.display = "none";
return;
}
@@ -18800,7 +17560,7 @@ wysihtml5.views.View = Base.extend(
var wrapper = document.createElement("div");
- wysihtml5.lang.object(wrapperStyles).merge({
+ wysihtml.lang.object(wrapperStyles).merge({
width: link.offsetWidth + "px",
height: link.offsetHeight + "px"
});
@@ -18828,7 +17588,7 @@ wysihtml5.views.View = Base.extend(
event.stopPropagation();
});
};
-})(wysihtml5);
+})(wysihtml);
;/**
* Toolbar
*
@@ -18842,18 +17602,18 @@ wysihtml5.views.View = Base.extend(
*
*
*
*/
-(function(wysihtml5) {
+(function(wysihtml) {
var CLASS_NAME_COMMAND_DISABLED = "wysihtml5-command-disabled",
CLASS_NAME_COMMANDS_DISABLED = "wysihtml5-commands-disabled",
CLASS_NAME_COMMAND_ACTIVE = "wysihtml5-command-active",
CLASS_NAME_ACTION_ACTIVE = "wysihtml5-action-active",
- dom = wysihtml5.dom;
+ dom = wysihtml.dom;
- wysihtml5.toolbar.Toolbar = Base.extend(
- /** @scope wysihtml5.toolbar.Toolbar.prototype */ {
+ wysihtml.toolbar.Toolbar = Base.extend(
+ /** @scope wysihtml.toolbar.Toolbar.prototype */ {
constructor: function(editor, container, showOnInit) {
this.editor = editor;
this.container = typeof(container) === "string" ? document.getElementById(container) : container;
@@ -18882,12 +17642,12 @@ wysihtml5.views.View = Base.extend(
length = speechInputLinks.length,
i = 0;
for (; i 1 1
block
+ * Useful in conjuction for sytax highlight utility: highlight.js
+ *
+ * Usage:
+ *
+ * editorInstance.composer.commands.exec("formatCode", "language-html");
+*/
+wysihtml.commands.formatCode = (function() {
+ return {
+ exec: function(composer, command, classname) {
+ var pre = this.state(composer)[0],
+ code, range, selectedNodes;
+
+ if (pre) {
+ // caret is already within a
+ composer.selection.executeAndRestore(function() {
+ code = pre.querySelector("code");
+ wysihtml.dom.replaceWithChildNodes(pre);
+ if (code) {
+ wysihtml.dom.replaceWithChildNodes(code);
+ }
+ });
+ } else {
+ // Wrap in ...
+ range = composer.selection.getRange();
+ selectedNodes = range.extractContents();
+ pre = composer.doc.createElement("pre");
+ code = composer.doc.createElement("code");
+
+ if (classname) {
+ code.className = classname;
+ }
+
+ pre.appendChild(code);
+ code.appendChild(selectedNodes);
+ range.insertNode(pre);
+ composer.selection.selectNode(pre);
+ }
+ },
+
+ state: function(composer) {
+ var selectedNode = composer.selection.getSelectedNode(), node;
+ if (selectedNode && selectedNode.nodeName && selectedNode.nodeName == "PRE"&&
+ selectedNode.firstChild && selectedNode.firstChild.nodeName && selectedNode.firstChild.nodeName == "CODE") {
+ return [selectedNode];
+ } else {
+ node = wysihtml.dom.getParentElement(selectedNode, { query: "pre code" });
+ return node ? [node.parentNode] : false;
+ }
+ }
+ };
+})();
+
+});
diff --git a/dist/modules/wysihtml.command_formatCode.min.js b/dist/modules/wysihtml.command_formatCode.min.js
new file mode 100644
index 0000000..4cdd40a
--- /dev/null
+++ b/dist/modules/wysihtml.command_formatCode.min.js
@@ -0,0 +1 @@
+!function(a,b){"function"==typeof define&&define.amd?define(["wysihtml"],b):"object"==typeof module&&module.exports?module.exports=b(require("wysihtml")):b(a.wysihtml)}(this,function(a){a.commands.formatCode=function(){return{exec:function(b,c,d){var e,f,g,h=this.state(b)[0];h?b.selection.executeAndRestore(function(){e=h.querySelector("code"),a.dom.replaceWithChildNodes(h),e&&a.dom.replaceWithChildNodes(e)}):(f=b.selection.getRange(),g=f.extractContents(),h=b.doc.createElement("pre"),e=b.doc.createElement("code"),d&&(e.className=d),h.appendChild(e),e.appendChild(g),f.insertNode(h),b.selection.selectNode(h))},state:function(b){var c,d=b.selection.getSelectedNode();return d&&d.nodeName&&"PRE"==d.nodeName&&d.firstChild&&d.firstChild.nodeName&&"CODE"==d.firstChild.nodeName?[d]:(c=a.dom.getParentElement(d,{query:"pre code"}),c?[c.parentNode]:!1)}}}()});
\ No newline at end of file
diff --git a/dist/modules/wysihtml.command_insertImage.js b/dist/modules/wysihtml.command_insertImage.js
new file mode 100644
index 0000000..4aeac5a
--- /dev/null
+++ b/dist/modules/wysihtml.command_insertImage.js
@@ -0,0 +1,120 @@
+(function (root, factory) {
+ if(typeof define === 'function' && define.amd) {
+ define(['wysihtml'], factory);
+ } else if(typeof module === 'object' && module.exports) {
+ module.exports = factory(require('wysihtml'));
+ } else {
+ factory(root.wysihtml);
+ }
+})(this, function(wysihtml) {
+
+/**
+ * Inserts an ...
+ * If selection is already an image link, it removes it
+ *
+ * @example
+ * // either ...
+ * wysihtml.commands.insertImage.exec(composer, "insertImage", "http://www.google.de/logo.jpg");
+ * // ... or ...
+ * wysihtml.commands.insertImage.exec(composer, "insertImage", { src: "http://www.google.de/logo.jpg", title: "foo" });
+ */
+wysihtml.commands.insertImage = (function() {
+ var NODE_NAME = "IMG";
+ return {
+ exec: function(composer, command, value) {
+ value = typeof(value) === "object" ? value : { src: value };
+
+ var doc = composer.doc,
+ image = this.state(composer),
+ textNode,
+ parent;
+
+ // If image is selected and src ie empty, set the caret before it and delete the image
+ if (image && !value.src) {
+ composer.selection.setBefore(image);
+ parent = image.parentNode;
+ parent.removeChild(image);
+
+ // and it's parent too if it hasn't got any other relevant child nodes
+ wysihtml.dom.removeEmptyTextNodes(parent);
+ if (parent.nodeName === "A" && !parent.firstChild) {
+ composer.selection.setAfter(parent);
+ parent.parentNode.removeChild(parent);
+ }
+
+ // firefox and ie sometimes don't remove the image handles, even though the image got removed
+ wysihtml.quirks.redraw(composer.element);
+ return;
+ }
+
+ // If image selected change attributes accordingly
+ if (image) {
+ for (var key in value) {
+ if (value.hasOwnProperty(key)) {
+ image.setAttribute(key === "className" ? "class" : key, value[key]);
+ }
+ }
+ return;
+ }
+
+ // Otherwise lets create the image
+ image = doc.createElement(NODE_NAME);
+
+ for (var i in value) {
+ image.setAttribute(i === "className" ? "class" : i, value[i]);
+ }
+
+ composer.selection.insertNode(image);
+ if (wysihtml.browser.hasProblemsSettingCaretAfterImg()) {
+ textNode = doc.createTextNode(wysihtml.INVISIBLE_SPACE);
+ composer.selection.insertNode(textNode);
+ composer.selection.setAfter(textNode);
+ } else {
+ composer.selection.setAfter(image);
+ }
+ },
+
+ state: function(composer) {
+ var doc = composer.doc,
+ selectedNode,
+ text,
+ imagesInSelection;
+
+ if (!wysihtml.dom.hasElementWithTagName(doc, NODE_NAME)) {
+ return false;
+ }
+
+ selectedNode = composer.selection.getSelectedNode();
+ if (!selectedNode) {
+ return false;
+ }
+
+ if (selectedNode.nodeName === NODE_NAME) {
+ // This works perfectly in IE
+ return selectedNode;
+ }
+
+ if (selectedNode.nodeType !== wysihtml.ELEMENT_NODE) {
+ return false;
+ }
+
+ text = composer.selection.getText();
+ text = wysihtml.lang.string(text).trim();
+ if (text) {
+ return false;
+ }
+
+ imagesInSelection = composer.selection.getNodes(wysihtml.ELEMENT_NODE, function(node) {
+ return node.nodeName === "IMG";
+ });
+
+ if (imagesInSelection.length !== 1) {
+ return false;
+ }
+
+ return imagesInSelection[0];
+ }
+ };
+})();
+
+});
diff --git a/dist/modules/wysihtml.command_insertImage.min.js b/dist/modules/wysihtml.command_insertImage.min.js
new file mode 100644
index 0000000..2bf9fcd
--- /dev/null
+++ b/dist/modules/wysihtml.command_insertImage.min.js
@@ -0,0 +1 @@
+!function(a,b){"function"==typeof define&&define.amd?define(["wysihtml"],b):"object"==typeof module&&module.exports?module.exports=b(require("wysihtml")):b(a.wysihtml)}(this,function(a){a.commands.insertImage=function(){var b="IMG";return{exec:function(c,d,e){e="object"==typeof e?e:{src:e};var f,g,h=c.doc,i=this.state(c);if(i&&!e.src)return c.selection.setBefore(i),g=i.parentNode,g.removeChild(i),a.dom.removeEmptyTextNodes(g),"A"!==g.nodeName||g.firstChild||(c.selection.setAfter(g),g.parentNode.removeChild(g)),void a.quirks.redraw(c.element);if(i)for(var j in e)e.hasOwnProperty(j)&&i.setAttribute("className"===j?"class":j,e[j]);else{i=h.createElement(b);for(var k in e)i.setAttribute("className"===k?"class":k,e[k]);c.selection.insertNode(i),a.browser.hasProblemsSettingCaretAfterImg()?(f=h.createTextNode(a.INVISIBLE_SPACE),c.selection.insertNode(f),c.selection.setAfter(f)):c.selection.setAfter(i)}},state:function(c){var d,e,f,g=c.doc;return a.dom.hasElementWithTagName(g,b)&&(d=c.selection.getSelectedNode())?d.nodeName===b?d:d.nodeType!==a.ELEMENT_NODE?!1:(e=c.selection.getText(),(e=a.lang.string(e).trim())?!1:(f=c.selection.getNodes(a.ELEMENT_NODE,function(a){return"IMG"===a.nodeName}),1!==f.length?!1:f[0])):!1}}}()});
\ No newline at end of file
diff --git a/dist/modules/wysihtml.commands_basic.js b/dist/modules/wysihtml.commands_basic.js
new file mode 100644
index 0000000..e3e1da1
--- /dev/null
+++ b/dist/modules/wysihtml.commands_basic.js
@@ -0,0 +1,141 @@
+(function (root, factory) {
+ if(typeof define === 'function' && define.amd) {
+ define(['wysihtml'], factory);
+ } else if(typeof module === 'object' && module.exports) {
+ module.exports = factory(require('wysihtml'));
+ } else {
+ factory(root.wysihtml);
+ }
+})(this, function(wysihtml) {
+
+wysihtml.commands.bold = (function() {
+ var nodeOptions = {
+ nodeName: "B",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ wysihtml.commands.formatInline.exec(composer, command, nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatInline.state(composer, command, nodeOptions);
+ }
+ };
+})();
+
+wysihtml.commands.insertBlockQuote = (function() {
+ var nodeOptions = {
+ nodeName: "BLOCKQUOTE",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+wysihtml.commands.insertOrderedList = (function() {
+ return {
+ exec: function(composer, command) {
+ wysihtml.commands.insertList.exec(composer, command, "OL");
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.insertList.state(composer, command, "OL");
+ }
+ };
+})();
+
+wysihtml.commands.insertUnorderedList = (function() {
+ return {
+ exec: function(composer, command) {
+ wysihtml.commands.insertList.exec(composer, command, "UL");
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.insertList.state(composer, command, "UL");
+ }
+ };
+})();
+
+wysihtml.commands.italic = (function() {
+ var nodeOptions = {
+ nodeName: "I",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ wysihtml.commands.formatInline.exec(composer, command, nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatInline.state(composer, command, nodeOptions);
+ }
+ };
+
+})();
+
+wysihtml.commands.subscript = (function() {
+ var nodeOptions = {
+ nodeName: "SUB",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ wysihtml.commands.formatInline.exec(composer, command, nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatInline.state(composer, command, nodeOptions);
+ }
+ };
+
+})();
+
+wysihtml.commands.superscript = (function() {
+ var nodeOptions = {
+ nodeName: "SUP",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ wysihtml.commands.formatInline.exec(composer, command, nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatInline.state(composer, command, nodeOptions);
+ }
+ };
+
+})();
+
+wysihtml.commands.underline = (function() {
+ var nodeOptions = {
+ nodeName: "U",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ wysihtml.commands.formatInline.exec(composer, command, nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatInline.state(composer, command, nodeOptions);
+ }
+ };
+
+})();
+
+});
diff --git a/dist/modules/wysihtml.commands_basic.min.js b/dist/modules/wysihtml.commands_basic.min.js
new file mode 100644
index 0000000..0815171
--- /dev/null
+++ b/dist/modules/wysihtml.commands_basic.min.js
@@ -0,0 +1 @@
+!function(a,b){"function"==typeof define&&define.amd?define(["wysihtml"],b):"object"==typeof module&&module.exports?module.exports=b(require("wysihtml")):b(a.wysihtml)}(this,function(a){a.commands.bold=function(){var b={nodeName:"B",toggle:!0};return{exec:function(c,d){a.commands.formatInline.exec(c,d,b)},state:function(c,d){return a.commands.formatInline.state(c,d,b)}}}(),a.commands.insertBlockQuote=function(){var b={nodeName:"BLOCKQUOTE",toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.insertOrderedList=function(){return{exec:function(b,c){a.commands.insertList.exec(b,c,"OL")},state:function(b,c){return a.commands.insertList.state(b,c,"OL")}}}(),a.commands.insertUnorderedList=function(){return{exec:function(b,c){a.commands.insertList.exec(b,c,"UL")},state:function(b,c){return a.commands.insertList.state(b,c,"UL")}}}(),a.commands.italic=function(){var b={nodeName:"I",toggle:!0};return{exec:function(c,d){a.commands.formatInline.exec(c,d,b)},state:function(c,d){return a.commands.formatInline.state(c,d,b)}}}(),a.commands.subscript=function(){var b={nodeName:"SUB",toggle:!0};return{exec:function(c,d){a.commands.formatInline.exec(c,d,b)},state:function(c,d){return a.commands.formatInline.state(c,d,b)}}}(),a.commands.superscript=function(){var b={nodeName:"SUP",toggle:!0};return{exec:function(c,d){a.commands.formatInline.exec(c,d,b)},state:function(c,d){return a.commands.formatInline.state(c,d,b)}}}(),a.commands.underline=function(){var b={nodeName:"U",toggle:!0};return{exec:function(c,d){a.commands.formatInline.exec(c,d,b)},state:function(c,d){return a.commands.formatInline.state(c,d,b)}}}()});
\ No newline at end of file
diff --git a/dist/modules/wysihtml.commands_format_by_class.js b/dist/modules/wysihtml.commands_format_by_class.js
new file mode 100644
index 0000000..bcff708
--- /dev/null
+++ b/dist/modules/wysihtml.commands_format_by_class.js
@@ -0,0 +1,112 @@
+(function (root, factory) {
+ if(typeof define === 'function' && define.amd) {
+ define(['wysihtml'], factory);
+ } else if(typeof module === 'object' && module.exports) {
+ module.exports = factory(require('wysihtml'));
+ } else {
+ factory(root.wysihtml);
+ }
+})(this, function(wysihtml) {
+
+wysihtml.commands.fontSize = (function() {
+ var REG_EXP = /wysiwyg-font-size-[0-9a-z\-]+/g;
+
+ return {
+ exec: function(composer, command, size) {
+ wysihtml.commands.formatInline.exec(composer, command, {className: "wysiwyg-font-size-" + size, classRegExp: REG_EXP, toggle: true});
+ },
+
+ state: function(composer, command, size) {
+ return wysihtml.commands.formatInline.state(composer, command, {className: "wysiwyg-font-size-" + size});
+ }
+ };
+})();
+
+wysihtml.commands.foreColor = (function() {
+ var REG_EXP = /wysiwyg-color-[0-9a-z]+/g;
+
+ return {
+ exec: function(composer, command, color) {
+ wysihtml.commands.formatInline.exec(composer, command, {className: "wysiwyg-color-" + color, classRegExp: REG_EXP, toggle: true});
+ },
+
+ state: function(composer, command, color) {
+ return wysihtml.commands.formatInline.state(composer, command, {className: "wysiwyg-color-" + color});
+ }
+ };
+})();
+
+wysihtml.commands.justifyCenter = (function() {
+ var nodeOptions = {
+ className: "wysiwyg-text-align-center",
+ classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+
+})();
+
+wysihtml.commands.justifyFull = (function() {
+ var nodeOptions = {
+ className: "wysiwyg-text-align-justify",
+ classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+wysihtml.commands.justifyLeft = (function() {
+ var nodeOptions = {
+ className: "wysiwyg-text-align-left",
+ classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+wysihtml.commands.justifyRight = (function() {
+ var nodeOptions = {
+ className: "wysiwyg-text-align-right",
+ classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+});
diff --git a/dist/modules/wysihtml.commands_format_by_class.min.js b/dist/modules/wysihtml.commands_format_by_class.min.js
new file mode 100644
index 0000000..6ff8762
--- /dev/null
+++ b/dist/modules/wysihtml.commands_format_by_class.min.js
@@ -0,0 +1 @@
+!function(a,b){"function"==typeof define&&define.amd?define(["wysihtml"],b):"object"==typeof module&&module.exports?module.exports=b(require("wysihtml")):b(a.wysihtml)}(this,function(a){a.commands.fontSize=function(){var b=/wysiwyg-font-size-[0-9a-z\-]+/g;return{exec:function(c,d,e){a.commands.formatInline.exec(c,d,{className:"wysiwyg-font-size-"+e,classRegExp:b,toggle:!0})},state:function(b,c,d){return a.commands.formatInline.state(b,c,{className:"wysiwyg-font-size-"+d})}}}(),a.commands.foreColor=function(){var b=/wysiwyg-color-[0-9a-z]+/g;return{exec:function(c,d,e){a.commands.formatInline.exec(c,d,{className:"wysiwyg-color-"+e,classRegExp:b,toggle:!0})},state:function(b,c,d){return a.commands.formatInline.state(b,c,{className:"wysiwyg-color-"+d})}}}(),a.commands.justifyCenter=function(){var b={className:"wysiwyg-text-align-center",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.justifyFull=function(){var b={className:"wysiwyg-text-align-justify",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.justifyLeft=function(){var b={className:"wysiwyg-text-align-left",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.justifyRight=function(){var b={className:"wysiwyg-text-align-right",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}()});
\ No newline at end of file
diff --git a/dist/modules/wysihtml.commands_format_by_style.js b/dist/modules/wysihtml.commands_format_by_style.js
new file mode 100644
index 0000000..202647b
--- /dev/null
+++ b/dist/modules/wysihtml.commands_format_by_style.js
@@ -0,0 +1,221 @@
+(function (root, factory) {
+ if(typeof define === 'function' && define.amd) {
+ define(['wysihtml'], factory);
+ } else if(typeof module === 'object' && module.exports) {
+ module.exports = factory(require('wysihtml'));
+ } else {
+ factory(root.wysihtml);
+ }
+})(this, function(wysihtml) {
+
+wysihtml.commands.alignCenterStyle = (function() {
+ var nodeOptions = {
+ styleProperty: "textAlign",
+ styleValue: "center",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+wysihtml.commands.alignJustifyStyle = (function() {
+ var nodeOptions = {
+ styleProperty: "textAlign",
+ styleValue: "justify",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+wysihtml.commands.alignLeftStyle = (function() {
+ var nodeOptions = {
+ styleProperty: "textAlign",
+ styleValue: "left",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+wysihtml.commands.alignRightStyle = (function() {
+ var nodeOptions = {
+ styleProperty: "textAlign",
+ styleValue: "right",
+ toggle: true
+ };
+
+ return {
+ exec: function(composer, command) {
+ return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
+ },
+
+ state: function(composer, command) {
+ return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
+ }
+ };
+})();
+
+/* Sets text background color by inline styles */
+wysihtml.commands.bgColorStyle = (function() {
+ return {
+ exec: function(composer, command, color) {
+ var colorVals = wysihtml.quirks.styleParser.parseColor("background-color:" + (color.color || color), "background-color"),
+ colString;
+
+ if (colorVals) {
+ colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(', ') : "rgba(" + colorVals.join(', ')) + ')';
+ wysihtml.commands.formatInline.exec(composer, command, {styleProperty: 'backgroundColor', styleValue: colString});
+ }
+ },
+
+ state: function(composer, command, color) {
+ var colorVals = color ? wysihtml.quirks.styleParser.parseColor("background-color:" + (color.color || color), "background-color") : null,
+ colString;
+
+ if (colorVals) {
+ colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(', ') : "rgba(" + colorVals.join(', ')) + ')';
+ }
+
+ return wysihtml.commands.formatInline.state(composer, command, {styleProperty: 'backgroundColor', styleValue: colString});
+ },
+
+ remove: function(composer, command) {
+ return wysihtml.commands.formatInline.remove(composer, command, {styleProperty: 'backgroundColor'});
+ },
+
+ stateValue: function(composer, command, props) {
+ var st = this.state(composer, command),
+ colorStr,
+ val = false;
+
+ if (st && wysihtml.lang.object(st).isArray()) {
+ st = st[0];
+ }
+
+ if (st) {
+ colorStr = st.getAttribute('style');
+ if (colorStr) {
+ val = wysihtml.quirks.styleParser.parseColor(colorStr, "background-color");
+ return wysihtml.quirks.styleParser.unparseColor(val, props);
+ }
+ }
+ return false;
+ }
+ };
+})();
+
+/* Set font size by inline style */
+wysihtml.commands.fontSizeStyle = (function() {
+ return {
+ exec: function(composer, command, size) {
+ size = size.size || size;
+ if (!(/^\s*$/).test(size)) {
+ wysihtml.commands.formatInline.exec(composer, command, {styleProperty: "fontSize", styleValue: size, toggle: false});
+ }
+ },
+
+ state: function(composer, command, size) {
+ return wysihtml.commands.formatInline.state(composer, command, {styleProperty: "fontSize", styleValue: size || undefined});
+ },
+
+ remove: function(composer, command) {
+ return wysihtml.commands.formatInline.remove(composer, command, {styleProperty: "fontSize"});
+ },
+
+ stateValue: function(composer, command) {
+ var styleStr,
+ st = this.state(composer, command);
+
+ if (st && wysihtml.lang.object(st).isArray()) {
+ st = st[0];
+ }
+ if (st) {
+ styleStr = st.getAttribute("style");
+ if (styleStr) {
+ return wysihtml.quirks.styleParser.parseFontSize(styleStr);
+ }
+ }
+ return false;
+ }
+ };
+})();
+
+/* Sets text color by inline styles */
+wysihtml.commands.foreColorStyle = (function() {
+ return {
+ exec: function(composer, command, color) {
+ var colorVals, colString;
+
+ if (!color) { return; }
+
+ colorVals = wysihtml.quirks.styleParser.parseColor("color:" + (color.color || color), "color");
+
+ if (colorVals) {
+ colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(", ") : "rgba(" + colorVals.join(', ')) + ')';
+ wysihtml.commands.formatInline.exec(composer, command, {styleProperty: "color", styleValue: colString});
+ }
+ },
+
+ state: function(composer, command, color) {
+ var colorVals = color ? wysihtml.quirks.styleParser.parseColor("color:" + (color.color || color), "color") : null,
+ colString;
+
+
+ if (colorVals) {
+ colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(", ") : "rgba(" + colorVals.join(', ')) + ')';
+ }
+
+ return wysihtml.commands.formatInline.state(composer, command, {styleProperty: "color", styleValue: colString});
+ },
+
+ remove: function(composer, command) {
+ return wysihtml.commands.formatInline.remove(composer, command, {styleProperty: "color"});
+ },
+
+ stateValue: function(composer, command, props) {
+ var st = this.state(composer, command),
+ colorStr,
+ val = false;
+
+ if (st && wysihtml.lang.object(st).isArray()) {
+ st = st[0];
+ }
+
+ if (st) {
+ colorStr = st.getAttribute("style");
+ if (colorStr) {
+ val = wysihtml.quirks.styleParser.parseColor(colorStr, "color");
+ return wysihtml.quirks.styleParser.unparseColor(val, props);
+ }
+ }
+ return false;
+ }
+ };
+})();
+
+});
diff --git a/dist/modules/wysihtml.commands_format_by_style.min.js b/dist/modules/wysihtml.commands_format_by_style.min.js
new file mode 100644
index 0000000..be1ce12
--- /dev/null
+++ b/dist/modules/wysihtml.commands_format_by_style.min.js
@@ -0,0 +1 @@
+!function(a,b){"function"==typeof define&&define.amd?define(["wysihtml"],b):"object"==typeof module&&module.exports?module.exports=b(require("wysihtml")):b(a.wysihtml)}(this,function(a){a.commands.alignCenterStyle=function(){var b={styleProperty:"textAlign",styleValue:"center",toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.alignJustifyStyle=function(){var b={styleProperty:"textAlign",styleValue:"justify",toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.alignLeftStyle=function(){var b={styleProperty:"textAlign",styleValue:"left",toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.alignRightStyle=function(){var b={styleProperty:"textAlign",styleValue:"right",toggle:!0};return{exec:function(c,d){return a.commands.formatBlock.exec(c,"formatBlock",b)},state:function(c,d){return a.commands.formatBlock.state(c,"formatBlock",b)}}}(),a.commands.bgColorStyle=function(){return{exec:function(b,c,d){var e,f=a.quirks.styleParser.parseColor("background-color:"+(d.color||d),"background-color");f&&(e=(1===f[3]?"rgb("+[f[0],f[1],f[2]].join(", "):"rgba("+f.join(", "))+")",a.commands.formatInline.exec(b,c,{styleProperty:"backgroundColor",styleValue:e}))},state:function(b,c,d){var e,f=d?a.quirks.styleParser.parseColor("background-color:"+(d.color||d),"background-color"):null;return f&&(e=(1===f[3]?"rgb("+[f[0],f[1],f[2]].join(", "):"rgba("+f.join(", "))+")"),a.commands.formatInline.state(b,c,{styleProperty:"backgroundColor",styleValue:e})},remove:function(b,c){return a.commands.formatInline.remove(b,c,{styleProperty:"backgroundColor"})},stateValue:function(b,c,d){var e,f=this.state(b,c),g=!1;return f&&a.lang.object(f).isArray()&&(f=f[0]),f&&(e=f.getAttribute("style"))?(g=a.quirks.styleParser.parseColor(e,"background-color"),a.quirks.styleParser.unparseColor(g,d)):!1}}}(),a.commands.fontSizeStyle=function(){return{exec:function(b,c,d){d=d.size||d,/^\s*$/.test(d)||a.commands.formatInline.exec(b,c,{styleProperty:"fontSize",styleValue:d,toggle:!1})},state:function(b,c,d){return a.commands.formatInline.state(b,c,{styleProperty:"fontSize",styleValue:d||void 0})},remove:function(b,c){return a.commands.formatInline.remove(b,c,{styleProperty:"fontSize"})},stateValue:function(b,c){var d,e=this.state(b,c);return e&&a.lang.object(e).isArray()&&(e=e[0]),e&&(d=e.getAttribute("style"))?a.quirks.styleParser.parseFontSize(d):!1}}}(),a.commands.foreColorStyle=function(){return{exec:function(b,c,d){var e,f;d&&(e=a.quirks.styleParser.parseColor("color:"+(d.color||d),"color"),e&&(f=(1===e[3]?"rgb("+[e[0],e[1],e[2]].join(", "):"rgba("+e.join(", "))+")",a.commands.formatInline.exec(b,c,{styleProperty:"color",styleValue:f})))},state:function(b,c,d){var e,f=d?a.quirks.styleParser.parseColor("color:"+(d.color||d),"color"):null;return f&&(e=(1===f[3]?"rgb("+[f[0],f[1],f[2]].join(", "):"rgba("+f.join(", "))+")"),a.commands.formatInline.state(b,c,{styleProperty:"color",styleValue:e})},remove:function(b,c){return a.commands.formatInline.remove(b,c,{styleProperty:"color"})},stateValue:function(b,c,d){var e,f=this.state(b,c),g=!1;return f&&a.lang.object(f).isArray()&&(f=f[0]),f&&(e=f.getAttribute("style"))?(g=a.quirks.styleParser.parseColor(e,"color"),a.quirks.styleParser.unparseColor(g,d)):!1}}}()});
\ No newline at end of file
diff --git a/dist/wysihtml-toolbar.js b/dist/wysihtml-toolbar.js
index 26bafae..8657e8d 100644
--- a/dist/wysihtml-toolbar.js
+++ b/dist/wysihtml-toolbar.js
@@ -1,3 +1,13 @@
+(function (root, factory) {
+if(typeof define === 'function' && define.amd) {
+ define(factory);
+} else if(typeof module === 'object' && module.exports) {
+ module.exports = factory();
+} else {
+ factory();
+}
+})(this, function() {
+
/**
* @license wysihtml v0.5.5
* https://github.com/Voog/wysihtml
@@ -9,7 +19,7 @@
* Licensed under the MIT license (MIT)
*
*/
-var wysihtml5 = {
+var wysihtml = {
version: "0.5.5",
// namespaces
@@ -38,7 +48,7 @@ var wysihtml5 = {
TAB_KEY: 9,
DELETE_KEY: 46
};
-;wysihtml5.polyfills = function(win, doc) {
+;wysihtml.polyfills = function(win, doc) {
// TODO: in future try to replace most inline compability checks with polyfills for code readability
@@ -545,7 +555,7 @@ var wysihtml5 = {
})();
};
-wysihtml5.polyfills(window, document);
+wysihtml.polyfills(window, document);
;/**
* Rangy, a cross-browser JavaScript range and selection library
* https://github.com/timdown/rangy
@@ -6712,7 +6722,7 @@ Base = Base.extend({
});;/**
* Detect browser support for specific features
*/
-wysihtml5.browser = (function() {
+wysihtml.browser = (function() {
var userAgent = navigator.userAgent,
testElement = document.createElement("div"),
// Browser sniffing is unfortunately needed since some behaviors are impossible to feature detect
@@ -6867,7 +6877,7 @@ wysihtml5.browser = (function() {
* @param {Object} context The document object on which to check HTML5 support
*
* @example
- * wysihtml5.browser.supportsHTML5Tags(document);
+ * wysihtml.browser.supportsHTML5Tags(document);
*/
supportsHTML5Tags: function(context) {
var element = context.createElement("div"),
@@ -6886,7 +6896,7 @@ wysihtml5.browser = (function() {
* @return {Boolean}
*
* @example
- * wysihtml5.browser.supportsCommand(document, "bold");
+ * wysihtml.browser.supportsCommand(document, "bold");
*/
supportsCommand: (function() {
// Following commands are supported but contain bugs in some browsers
@@ -7023,7 +7033,7 @@ wysihtml5.browser = (function() {
*
* @example
* var input = document.createElement("input");
- * if (wysihtml5.browser.supportsSpeechApiOn(input)) {
+ * if (wysihtml.browser.supportsSpeechApiOn(input)) {
* // ...
* }
*/
@@ -7126,13 +7136,13 @@ wysihtml5.browser = (function() {
}
};
})();
-;wysihtml5.lang.array = function(arr) {
+;wysihtml.lang.array = function(arr) {
return {
/**
* Check whether a given object exists in an array
*
* @example
- * wysihtml5.lang.array([1, 2]).contains(1);
+ * wysihtml.lang.array([1, 2]).contains(1);
* // => true
*
* Can be used to match array with array. If intersection is found true is returned
@@ -7140,13 +7150,13 @@ wysihtml5.browser = (function() {
contains: function(needle) {
if (Array.isArray(needle)) {
for (var i = needle.length; i--;) {
- if (wysihtml5.lang.array(arr).indexOf(needle[i]) !== -1) {
+ if (wysihtml.lang.array(arr).indexOf(needle[i]) !== -1) {
return true;
}
}
return false;
} else {
- return wysihtml5.lang.array(arr).indexOf(needle) !== -1;
+ return wysihtml.lang.array(arr).indexOf(needle) !== -1;
}
},
@@ -7155,7 +7165,7 @@ wysihtml5.browser = (function() {
* If no elelemt found returns -1
*
* @example
- * wysihtml5.lang.array([1, 2]).indexOf(2);
+ * wysihtml.lang.array([1, 2]).indexOf(2);
* // => 1
*/
indexOf: function(needle) {
@@ -7173,11 +7183,11 @@ wysihtml5.browser = (function() {
* Substract one array from another
*
* @example
- * wysihtml5.lang.array([1, 2, 3, 4]).without([3, 4]);
+ * wysihtml.lang.array([1, 2, 3, 4]).without([3, 4]);
* // => [1, 2]
*/
without: function(arrayToSubstract) {
- arrayToSubstract = wysihtml5.lang.array(arrayToSubstract);
+ arrayToSubstract = wysihtml.lang.array(arrayToSubstract);
var newArr = [],
i = 0,
length = arr.length;
@@ -7194,7 +7204,7 @@ wysihtml5.browser = (function() {
*
* Following will convert a Live NodeList to a proper Array
* @example
- * var childNodes = wysihtml5.lang.array(document.body.childNodes).get();
+ * var childNodes = wysihtml.lang.array(document.body.childNodes).get();
*/
get: function() {
var i = 0,
@@ -7211,7 +7221,7 @@ wysihtml5.browser = (function() {
* optionally this can be provided as second argument
*
* @example
- * var childNodes = wysihtml5.lang.array([1,2,3,4]).map(function (value, index, array) {
+ * var childNodes = wysihtml.lang.array([1,2,3,4]).map(function (value, index, array) {
return value * 2;
* });
* // => [2,4,6,8]
@@ -7233,7 +7243,7 @@ wysihtml5.browser = (function() {
/* ReturnS new array without duplicate entries
*
* @example
- * var uniq = wysihtml5.lang.array([1,2,3,2,1,4]).unique();
+ * var uniq = wysihtml.lang.array([1,2,3,2,1,4]).unique();
* // => [1,2,3,4]
*/
unique: function() {
@@ -7242,7 +7252,7 @@ wysihtml5.browser = (function() {
idx = 0;
while (idx < max) {
- if (!wysihtml5.lang.array(vals).contains(arr[idx])) {
+ if (!wysihtml.lang.array(vals).contains(arr[idx])) {
vals.push(arr[idx]);
}
idx++;
@@ -7252,8 +7262,8 @@ wysihtml5.browser = (function() {
};
};
-;wysihtml5.lang.Dispatcher = Base.extend(
- /** @scope wysihtml5.lang.Dialog.prototype */ {
+;wysihtml.lang.Dispatcher = Base.extend(
+ /** @scope wysihtml.lang.Dialog.prototype */ {
on: function(eventName, handler) {
this.events = this.events || {};
this.events[eventName] = this.events[eventName] || [];
@@ -7302,23 +7312,23 @@ wysihtml5.browser = (function() {
return this.off.apply(this, arguments);
}
});
-;wysihtml5.lang.object = function(obj) {
+;wysihtml.lang.object = function(obj) {
return {
/**
* @example
- * wysihtml5.lang.object({ foo: 1, bar: 1 }).merge({ bar: 2, baz: 3 }).get();
+ * wysihtml.lang.object({ foo: 1, bar: 1 }).merge({ bar: 2, baz: 3 }).get();
* // => { foo: 1, bar: 2, baz: 3 }
*/
merge: function(otherObj, deep) {
for (var i in otherObj) {
- if (deep && wysihtml5.lang.object(otherObj[i]).isPlainObject() && (typeof obj[i] === "undefined" || wysihtml5.lang.object(obj[i]).isPlainObject())) {
+ if (deep && wysihtml.lang.object(otherObj[i]).isPlainObject() && (typeof obj[i] === "undefined" || wysihtml.lang.object(obj[i]).isPlainObject())) {
if (typeof obj[i] === "undefined") {
- obj[i] = wysihtml5.lang.object(otherObj[i]).clone(true);
+ obj[i] = wysihtml.lang.object(otherObj[i]).clone(true);
} else {
- wysihtml5.lang.object(obj[i]).merge(wysihtml5.lang.object(otherObj[i]).clone(true));
+ wysihtml.lang.object(obj[i]).merge(wysihtml.lang.object(otherObj[i]).clone(true));
}
} else {
- obj[i] = wysihtml5.lang.object(otherObj[i]).isPlainObject() ? wysihtml5.lang.object(otherObj[i]).clone(true) : otherObj[i];
+ obj[i] = wysihtml.lang.object(otherObj[i]).isPlainObject() ? wysihtml.lang.object(otherObj[i]).clone(true) : otherObj[i];
}
}
return this;
@@ -7353,23 +7363,23 @@ wysihtml5.browser = (function() {
/**
* @example
- * wysihtml5.lang.object({ foo: 1 }).clone();
+ * wysihtml.lang.object({ foo: 1 }).clone();
* // => { foo: 1 }
*
- * v0.4.14 adds options for deep clone : wysihtml5.lang.object({ foo: 1 }).clone(true);
+ * v0.4.14 adds options for deep clone : wysihtml.lang.object({ foo: 1 }).clone(true);
*/
clone: function(deep) {
var newObj = {},
i;
- if (obj === null || !wysihtml5.lang.object(obj).isPlainObject()) {
+ if (obj === null || !wysihtml.lang.object(obj).isPlainObject()) {
return obj;
}
for (i in obj) {
if(obj.hasOwnProperty(i)) {
if (deep) {
- newObj[i] = wysihtml5.lang.object(obj[i]).clone(deep);
+ newObj[i] = wysihtml.lang.object(obj[i]).clone(deep);
} else {
newObj[i] = obj[i];
}
@@ -7380,7 +7390,7 @@ wysihtml5.browser = (function() {
/**
* @example
- * wysihtml5.lang.object([]).isArray();
+ * wysihtml.lang.object([]).isArray();
* // => true
*/
isArray: function() {
@@ -7389,7 +7399,7 @@ wysihtml5.browser = (function() {
/**
* @example
- * wysihtml5.lang.object(function() {}).isFunction();
+ * wysihtml.lang.object(function() {}).isFunction();
* // => true
*/
isFunction: function() {
@@ -7402,7 +7412,7 @@ wysihtml5.browser = (function() {
/**
* @example
- * wysihtml5.lang.object({}).isEmpty();
+ * wysihtml.lang.object({}).isEmpty();
* // => true
*/
isEmpty: function() {
@@ -7426,12 +7436,12 @@ wysihtml5.browser = (function() {
'"': """,
'\t':" "
};
- wysihtml5.lang.string = function(str) {
+ wysihtml.lang.string = function(str) {
str = String(str);
return {
/**
* @example
- * wysihtml5.lang.string(" foo ").trim();
+ * wysihtml.lang.string(" foo ").trim();
* // => "foo"
*/
trim: function() {
@@ -7440,7 +7450,7 @@ wysihtml5.browser = (function() {
/**
* @example
- * wysihtml5.lang.string("Hello #{name}").interpolate({ name: "Christopher" });
+ * wysihtml.lang.string("Hello #{name}").interpolate({ name: "Christopher" });
* // => "Hello Christopher"
*/
interpolate: function(vars) {
@@ -7452,7 +7462,7 @@ wysihtml5.browser = (function() {
/**
* @example
- * wysihtml5.lang.string("Hello Tom").replace("Tom").with("Hans");
+ * wysihtml.lang.string("Hello Tom").replace("Tom").with("Hans");
* // => "Hello Hans"
*/
replace: function(search) {
@@ -7465,7 +7475,7 @@ wysihtml5.browser = (function() {
/**
* @example
- * wysihtml5.lang.string("hello
").escapeHTML();
+ * wysihtml.lang.string("hello
").escapeHTML();
* // => "hello<br>"
*/
escapeHTML: function(linebreaks, convertSpaces) {
@@ -7489,13 +7499,13 @@ wysihtml5.browser = (function() {
*
* @example
*
)
*/
add: function(options) {
var doc = node.ownerDocument,
- nextSibling = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
- previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});
+ nextSibling = wysihtml.dom.domNode(node).next({ignoreBlankTexts: true}),
+ previousSibling = wysihtml.dom.domNode(node).prev({ignoreBlankTexts: true});
if (nextSibling && !_isLineBreakOrBlockElement(nextSibling)) {
- wysihtml5.dom.insert(doc.createElement("br")).after(node);
+ wysihtml.dom.insert(doc.createElement("br")).after(node);
}
if (previousSibling && !_isLineBreakOrBlockElement(previousSibling)) {
- wysihtml5.dom.insert(doc.createElement("br")).before(node);
+ wysihtml.dom.insert(doc.createElement("br")).before(node);
}
},
- /* wysihtml5.dom.lineBreaks(element).remove();
+ /* wysihtml.dom.lineBreaks(element).remove();
*
* Removes line breaks before and after the given node
*/
remove: function(options) {
- var nextSibling = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
- previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});
+ var nextSibling = wysihtml.dom.domNode(node).next({ignoreBlankTexts: true}),
+ previousSibling = wysihtml.dom.domNode(node).prev({ignoreBlankTexts: true});
if (nextSibling && _isLineBreak(nextSibling)) {
nextSibling.parentNode.removeChild(nextSibling);
@@ -8638,13 +8648,13 @@ wysihtml5.dom.hasElementWithTagName = (function() {
}
};
};
-})(wysihtml5);;/**
+})(wysihtml);;/**
* Method to set dom events
*
* @example
- * wysihtml5.dom.observe(iframe.contentWindow.document.body, ["focus", "blur"], function() { ... });
+ * wysihtml.dom.observe(iframe.contentWindow.document.body, ["focus", "blur"], function() { ... });
*/
-wysihtml5.dom.observe = function(element, eventNames, handler) {
+wysihtml.dom.observe = function(element, eventNames, handler) {
eventNames = typeof(eventNames) === "string" ? [eventNames] : eventNames;
var handlerWrapper,
@@ -8703,7 +8713,7 @@ wysihtml5.dom.observe = function(element, eventNames, handler) {
*
* @example
* var userHTML = '
';
- * wysihtml5.dom.parse(userHTML);
+ * wysihtml.dom.parse(userHTML);
* // => 'I'm a table!'
*
* var userHTML = 'I'm a table!
foobar
';
* });
*/
-(function(wysihtml5) {
+(function(wysihtml) {
var /**
* Default configuration
*/
@@ -9787,12 +9797,12 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
"write", "open", "close"
];
- wysihtml5.dom.Sandbox = Base.extend(
- /** @scope wysihtml5.dom.Sandbox.prototype */ {
+ wysihtml.dom.Sandbox = Base.extend(
+ /** @scope wysihtml.dom.Sandbox.prototype */ {
constructor: function(readyCallback, config) {
- this.callback = readyCallback || wysihtml5.EMPTY_FUNCTION;
- this.config = wysihtml5.lang.object({}).merge(config).get();
+ this.callback = readyCallback || wysihtml.EMPTY_FUNCTION;
+ this.config = wysihtml.lang.object({}).merge(config).get();
if (!this.config.className) {
this.config.className = "wysihtml5-sandbox";
}
@@ -9825,7 +9835,7 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
},
_readyError: function() {
- throw new Error("wysihtml5.Sandbox: Sandbox iframe isn't loaded yet");
+ throw new Error("wysihtml.Sandbox: Sandbox iframe isn't loaded yet");
},
/**
@@ -9851,7 +9861,7 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
var that = this,
iframe = doc.createElement("iframe");
iframe.className = this.config.className;
- wysihtml5.dom.setAttributes({
+ wysihtml.dom.setAttributes({
"security": "restricted",
"allowtransparency": "true",
"frameborder": 0,
@@ -9862,7 +9872,7 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
}).on(iframe);
// Setting the src like this prevents ssl warnings in IE6
- if (wysihtml5.browser.throwsMixedContentWarningWhenIframeSrcIsEmpty()) {
+ if (wysihtml.browser.throwsMixedContentWarningWhenIframeSrcIsEmpty()) {
iframe.src = "javascript:''";
}
@@ -9886,7 +9896,7 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
*/
_onLoadIframe: function(iframe) {
// don't resume when the iframe got unloaded (eg. by removing it from the dom)
- if (!wysihtml5.dom.contains(doc.documentElement, iframe)) {
+ if (!wysihtml.dom.contains(doc.documentElement, iframe)) {
return;
}
@@ -9911,10 +9921,10 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
// addEventListener("error") doesn't work properly in some browsers
// TODO: apparently this doesn't work in IE9!
iframeWindow.onerror = function(errorMessage, fileName, lineNumber) {
- throw new Error("wysihtml5.Sandbox: " + errorMessage, fileName, lineNumber);
+ throw new Error("wysihtml.Sandbox: " + errorMessage, fileName, lineNumber);
};
- if (!wysihtml5.browser.supportsSandboxedIframes()) {
+ if (!wysihtml.browser.supportsSandboxedIframes()) {
// Unset a bunch of sensitive variables
// Please note: This isn't hack safe!
// It more or less just takes care of basic attacks and prevents accidental theft of sensitive information
@@ -9926,7 +9936,7 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
this._unset(iframeWindow, windowProperties[i]);
}
for (i=0, length=windowProperties2.length; i
block
- * Useful in conjuction for sytax highlight utility: highlight.js
- *
- * Usage:
- *
- * editorInstance.composer.commands.exec("formatCode", "language-html");
-*/
-
-(function(wysihtml5){
- wysihtml5.commands.formatCode = {
-
- exec: function(composer, command, classname) {
- var pre = this.state(composer)[0],
- code, range, selectedNodes;
-
- if (pre) {
- // caret is already within a
- composer.selection.executeAndRestore(function() {
- code = pre.querySelector("code");
- wysihtml5.dom.replaceWithChildNodes(pre);
- if (code) {
- wysihtml5.dom.replaceWithChildNodes(code);
- }
- });
- } else {
- // Wrap in ...
- range = composer.selection.getRange();
- selectedNodes = range.extractContents();
- pre = composer.doc.createElement("pre");
- code = composer.doc.createElement("code");
-
- if (classname) {
- code.className = classname;
- }
-
- pre.appendChild(code);
- code.appendChild(selectedNodes);
- range.insertNode(pre);
- composer.selection.selectNode(pre);
- }
- },
-
- state: function(composer) {
- var selectedNode = composer.selection.getSelectedNode(), node;
- if (selectedNode && selectedNode.nodeName && selectedNode.nodeName == "PRE"&&
- selectedNode.firstChild && selectedNode.firstChild.nodeName && selectedNode.firstChild.nodeName == "CODE") {
- return [selectedNode];
- } else {
- node = wysihtml5.dom.getParentElement(selectedNode, { query: "pre code" });
- return node ? [node.parentNode] : false;
- }
- }
- };
-}(wysihtml5));
+})(wysihtml);
;/**
* Unifies all inline tags additions and removals
* See https://github.com/Voog/wysihtml/pull/169 for specification of action
*/
-(function(wysihtml5) {
+(function(wysihtml) {
var defaultTag = "SPAN",
INLINE_ELEMENTS = "b, big, i, small, tt, abbr, acronym, cite, code, dfn, em, kbd, strong, samp, var, a, bdo, br, q, span, sub, sup, button, label, textarea, input, select, u",
@@ -15037,8 +14152,8 @@ wysihtml5.Commands = Base.extend(
// Associative arrays in javascript are really objects and do not have length defined
// Thus have to check emptyness in a different way
function hasNoAttributes(element) {
- var attr = wysihtml5.dom.getAttributes(element);
- return wysihtml5.lang.object(attr).isEmpty();
+ var attr = wysihtml.dom.getAttributes(element);
+ return wysihtml.lang.object(attr).isEmpty();
}
// compares two nodes if they are semantically the same
@@ -15057,14 +14172,14 @@ wysihtml5.Commands = Base.extend(
classes1 = element1.className.trim().replace(/\s+/g, ' ').split(' ');
classes2 = element2.className.trim().replace(/\s+/g, ' ').split(' ');
- if (wysihtml5.lang.array(classes1).without(classes2).length > 0) {
+ if (wysihtml.lang.array(classes1).without(classes2).length > 0) {
return false;
}
- attr1 = wysihtml5.dom.getAttributes(element1);
- attr2 = wysihtml5.dom.getAttributes(element2);
+ attr1 = wysihtml.dom.getAttributes(element1);
+ attr2 = wysihtml.dom.getAttributes(element2);
- if (attr1.length !== attr2.length || !wysihtml5.lang.object(wysihtml5.lang.object(attr1).difference(attr2)).isEmpty()) {
+ if (attr1.length !== attr2.length || !wysihtml.lang.object(wysihtml.lang.object(attr1).difference(attr2)).isEmpty()) {
return false;
}
@@ -15085,7 +14200,7 @@ wysihtml5.Commands = Base.extend(
}
if (options.styleProperty && typeof options.styleValue !== "undefined") {
- element.style[wysihtml5.browser.fixStyleKey(options.styleProperty)] = options.styleValue;
+ element.style[wysihtml.browser.fixStyleKey(options.styleProperty)] = options.styleValue;
}
if (options.attribute) {
@@ -15119,9 +14234,9 @@ wysihtml5.Commands = Base.extend(
// If attrbutes and values are the same > remove
// if attributes or values
function updateElementAttributes(element, newAttributes, toggle) {
- var attr = wysihtml5.dom.getAttributes(element),
+ var attr = wysihtml.dom.getAttributes(element),
fullContain = containsSameAttributes(newAttributes, attr),
- attrDifference = wysihtml5.lang.object(attr).difference(newAttributes),
+ attrDifference = wysihtml.lang.object(attr).difference(newAttributes),
a, b;
if (fullContain && toggle !== false) {
@@ -15132,7 +14247,7 @@ wysihtml5.Commands = Base.extend(
}
} else {
- /*if (!wysihtml5.lang.object(attrDifference).isEmpty()) {
+ /*if (!wysihtml.lang.object(attrDifference).isEmpty()) {
for (b in attrDifference) {
if (attrDifference.hasOwnProperty(b)) {
element.removeAttribute(b);
@@ -15167,10 +14282,10 @@ wysihtml5.Commands = Base.extend(
// change/remove style
if (options.styleProperty) {
- if (options.toggle !== false && element.style[wysihtml5.browser.fixStyleKey(options.styleProperty)].trim().replace(/, /g, ",") === options.styleValue) {
- element.style[wysihtml5.browser.fixStyleKey(options.styleProperty)] = '';
+ if (options.toggle !== false && element.style[wysihtml.browser.fixStyleKey(options.styleProperty)].trim().replace(/, /g, ",") === options.styleValue) {
+ element.style[wysihtml.browser.fixStyleKey(options.styleProperty)] = '';
} else {
- element.style[wysihtml5.browser.fixStyleKey(options.styleProperty)] = options.styleValue;
+ element.style[wysihtml.browser.fixStyleKey(options.styleProperty)] = options.styleValue;
}
}
if (hasNoStyle(element)) {
@@ -15190,7 +14305,7 @@ wysihtml5.Commands = Base.extend(
// Handle similar semantically same elements (queryAliasMap)
nodeNameQuery = options.nodeName ? queryAliasMap[options.nodeName.toLowerCase()] || options.nodeName.toLowerCase() : null;
- nodeQueryMatch = nodeNameQuery ? wysihtml5.dom.domNode(element).test({ query: nodeNameQuery }) : false;
+ nodeQueryMatch = nodeNameQuery ? wysihtml.dom.domNode(element).test({ query: nodeNameQuery }) : false;
// Unwrap element if no attributes present and node name given
// or no attributes and if no nodename set but node is the default
@@ -15199,7 +14314,7 @@ wysihtml5.Commands = Base.extend(
((options.toggle !== false && nodeQueryMatch) || (!options.nodeName && element.nodeName === defaultTag)) &&
hasNoClass(element) && hasNoStyle(element) && hasNoAttributes(element)
) {
- wysihtml5.dom.unwrap(element);
+ wysihtml.dom.unwrap(element);
}
}
@@ -15213,7 +14328,7 @@ wysihtml5.Commands = Base.extend(
if (!selection.isCollapsed()) {
textNodes = textNodes.concat(selection.getOwnNodes([3], function(node) {
// Exclude empty nodes except caret node
- return (!wysihtml5.dom.domNode(node).is.emptyTextNode());
+ return (!wysihtml.dom.domNode(node).is.emptyTextNode());
}, splitBounds));
}
@@ -15249,11 +14364,11 @@ wysihtml5.Commands = Base.extend(
var o;
if (options.nodeName) {
var query = queryAliasMap[options.nodeName.toLowerCase()] || options.nodeName.toLowerCase();
- return wysihtml5.dom.domNode(node).test({ query: query });
+ return wysihtml.dom.domNode(node).test({ query: query });
} else {
- o = wysihtml5.lang.object(options).clone();
+ o = wysihtml.lang.object(options).clone();
o.query = INLINE_ELEMENTS; // make sure only inline elements with styles and classes are counted
- return wysihtml5.dom.domNode(node).test(o);
+ return wysihtml.dom.domNode(node).test(o);
}
}
@@ -15269,7 +14384,7 @@ wysihtml5.Commands = Base.extend(
try {
rangy.getSelection(composer.win).addRange(range);
} catch (e) {}
- if (!composer.doc.activeElement || !wysihtml5.dom.contains(composer.element, composer.doc.activeElement)) {
+ if (!composer.doc.activeElement || !wysihtml.dom.contains(composer.element, composer.doc.activeElement)) {
composer.element.focus();
d.scrollTop = oldScrollTop;
d.scrollLeft = oldScrollLeft;
@@ -15386,7 +14501,7 @@ wysihtml5.Commands = Base.extend(
range.setStartAndEnd(anchor, offsetStart, offsetEnd);
range.splitBoundaries();
txtNodes = range.getNodes([3], function(node) {
- return (!wysihtml5.dom.domNode(node).is.emptyTextNode());
+ return (!wysihtml.dom.domNode(node).is.emptyTextNode());
});
return {
@@ -15458,7 +14573,7 @@ wysihtml5.Commands = Base.extend(
if (wrapNode) {
newWrapNode = wrapNode.cloneNode(false);
- wysihtml5.dom.domNode(textNode).escapeParent(wrapNode, newWrapNode);
+ wysihtml.dom.domNode(textNode).escapeParent(wrapNode, newWrapNode);
updateFormatOfElement(newWrapNode, options);
}
}
@@ -15469,7 +14584,7 @@ wysihtml5.Commands = Base.extend(
wrapNode = findSimilarTextNodeWrapper(textNode, options, container);
if (wrapNode) {
- wysihtml5.dom.domNode(textNode).escapeParent(wrapNode);
+ wysihtml.dom.domNode(textNode).escapeParent(wrapNode);
}
}
@@ -15503,7 +14618,7 @@ wysihtml5.Commands = Base.extend(
} else {
// Escape caret out of format
- textNode = composer.doc.createTextNode(wysihtml5.INVISIBLE_SPACE);
+ textNode = composer.doc.createTextNode(wysihtml.INVISIBLE_SPACE);
newNode = state.nodes[0].cloneNode(false);
newNode.appendChild(textNode);
composer.selection.splitElementAtCaret(state.nodes[0], newNode);
@@ -15568,7 +14683,7 @@ wysihtml5.Commands = Base.extend(
textOffset = selection.anchorOffset;
for (i = state.nodes.length; i--;) {
- wysihtml5.dom.unwrap(state.nodes[i]);
+ wysihtml.dom.unwrap(state.nodes[i]);
}
cleanupAndSetCaret(composer, textNode, textOffset, options);
@@ -15616,7 +14731,7 @@ wysihtml5.Commands = Base.extend(
return options;
}
- wysihtml5.commands.formatInline = {
+ wysihtml.commands.formatInline = {
// Basics:
// In case of plain text or inline state not set wrap all non-empty textnodes with
@@ -15662,27 +14777,9 @@ wysihtml5.Commands = Base.extend(
}
};
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- nodeName: "BLOCKQUOTE",
- toggle: true
- };
-
- wysihtml5.commands.insertBlockQuote = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-
-})(wysihtml5);
-;(function(wysihtml5){
- wysihtml5.commands.insertHTML = {
+})(wysihtml);
+;(function(wysihtml){
+ wysihtml.commands.insertHTML = {
exec: function(composer, command, html) {
composer.selection.insertHTML(html);
},
@@ -15691,120 +14788,11 @@ wysihtml5.Commands = Base.extend(
return false;
}
};
-}(wysihtml5));
-;(function(wysihtml5) {
- var NODE_NAME = "IMG";
-
- wysihtml5.commands.insertImage = {
- /**
- * Inserts an ...
- * If selection is already an image link, it removes it
- *
- * @example
- * // either ...
- * wysihtml5.commands.insertImage.exec(composer, "insertImage", "http://www.google.de/logo.jpg");
- * // ... or ...
- * wysihtml5.commands.insertImage.exec(composer, "insertImage", { src: "http://www.google.de/logo.jpg", title: "foo" });
- */
- exec: function(composer, command, value) {
- value = typeof(value) === "object" ? value : { src: value };
-
- var doc = composer.doc,
- image = this.state(composer),
- textNode,
- parent;
-
- // If image is selected and src ie empty, set the caret before it and delete the image
- if (image && !value.src) {
- composer.selection.setBefore(image);
- parent = image.parentNode;
- parent.removeChild(image);
-
- // and it's parent too if it hasn't got any other relevant child nodes
- wysihtml5.dom.removeEmptyTextNodes(parent);
- if (parent.nodeName === "A" && !parent.firstChild) {
- composer.selection.setAfter(parent);
- parent.parentNode.removeChild(parent);
- }
-
- // firefox and ie sometimes don't remove the image handles, even though the image got removed
- wysihtml5.quirks.redraw(composer.element);
- return;
- }
-
- // If image selected change attributes accordingly
- if (image) {
- for (var key in value) {
- if (value.hasOwnProperty(key)) {
- image.setAttribute(key === "className" ? "class" : key, value[key]);
- }
- }
- return;
- }
-
- // Otherwise lets create the image
- image = doc.createElement(NODE_NAME);
-
- for (var i in value) {
- image.setAttribute(i === "className" ? "class" : i, value[i]);
- }
-
- composer.selection.insertNode(image);
- if (wysihtml5.browser.hasProblemsSettingCaretAfterImg()) {
- textNode = doc.createTextNode(wysihtml5.INVISIBLE_SPACE);
- composer.selection.insertNode(textNode);
- composer.selection.setAfter(textNode);
- } else {
- composer.selection.setAfter(image);
- }
- },
-
- state: function(composer) {
- var doc = composer.doc,
- selectedNode,
- text,
- imagesInSelection;
-
- if (!wysihtml5.dom.hasElementWithTagName(doc, NODE_NAME)) {
- return false;
- }
-
- selectedNode = composer.selection.getSelectedNode();
- if (!selectedNode) {
- return false;
- }
-
- if (selectedNode.nodeName === NODE_NAME) {
- // This works perfectly in IE
- return selectedNode;
- }
-
- if (selectedNode.nodeType !== wysihtml5.ELEMENT_NODE) {
- return false;
- }
-
- text = composer.selection.getText();
- text = wysihtml5.lang.string(text).trim();
- if (text) {
- return false;
- }
-
- imagesInSelection = composer.selection.getNodes(wysihtml5.ELEMENT_NODE, function(node) {
- return node.nodeName === "IMG";
- });
-
- if (imagesInSelection.length !== 1) {
- return false;
- }
-
- return imagesInSelection[0];
- }
- };
-})(wysihtml5);
-;(function(wysihtml5) {
- var LINE_BREAK = "
" + (wysihtml5.browser.needsSpaceAfterLineBreak() ? " " : "");
+}(wysihtml));
+;(function(wysihtml) {
+ var LINE_BREAK = "
" + (wysihtml.browser.needsSpaceAfterLineBreak() ? " " : "");
- wysihtml5.commands.insertLineBreak = {
+ wysihtml.commands.insertLineBreak = {
exec: function(composer, command) {
composer.selection.insertHTML(LINE_BREAK);
},
@@ -15813,30 +14801,8 @@ wysihtml5.Commands = Base.extend(
return false;
}
};
-})(wysihtml5);
-;(function(wysihtml5){
- wysihtml5.commands.insertOrderedList = {
- exec: function(composer, command) {
- wysihtml5.commands.insertList.exec(composer, command, "OL");
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.insertList.state(composer, command, "OL");
- }
- };
-}(wysihtml5));
-;(function(wysihtml5){
- wysihtml5.commands.insertUnorderedList = {
- exec: function(composer, command) {
- wysihtml5.commands.insertList.exec(composer, command, "UL");
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.insertList.state(composer, command, "UL");
- }
- };
-}(wysihtml5));
-;wysihtml5.commands.insertList = (function(wysihtml5) {
+})(wysihtml);
+;wysihtml.commands.insertList = (function(wysihtml) {
var isNode = function(node, name) {
if (node && node.nodeName) {
@@ -15859,7 +14825,7 @@ wysihtml5.Commands = Base.extend(
};
if (node) {
- var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }, false, composer.element),
+ var parentLi = wysihtml.dom.getParentElement(node, { query: "li" }, false, composer.element),
otherNodeName = (nodeName === "UL") ? "OL" : "UL";
if (isNode(node, nodeName)) {
@@ -15901,15 +14867,15 @@ wysihtml5.Commands = Base.extend(
otherLists = getListsInSelection(otherNodeName, composer);
if (otherLists.length) {
for (var l = otherLists.length; l--;) {
- wysihtml5.dom.renameElement(otherLists[l], nodeName.toLowerCase());
+ wysihtml.dom.renameElement(otherLists[l], nodeName.toLowerCase());
}
} else {
innerLists = getListsInSelection(['OL', 'UL'], composer);
for (var i = innerLists.length; i--;) {
- wysihtml5.dom.resolveList(innerLists[i], composer.config.useLineBreaks);
+ wysihtml.dom.resolveList(innerLists[i], composer.config.useLineBreaks);
}
if (innerLists.length === 0) {
- wysihtml5.dom.resolveList(el, composer.config.useLineBreaks);
+ wysihtml.dom.resolveList(el, composer.config.useLineBreaks);
}
}
});
@@ -15927,7 +14893,7 @@ wysihtml5.Commands = Base.extend(
// All selection inner lists get renamed too
for (var l = renameLists.length; l--;) {
- wysihtml5.dom.renameElement(renameLists[l], nodeName.toLowerCase());
+ wysihtml.dom.renameElement(renameLists[l], nodeName.toLowerCase());
}
});
};
@@ -15961,10 +14927,10 @@ wysihtml5.Commands = Base.extend(
// This space causes new lists to never break on enter
var INVISIBLE_SPACE_REG_EXP = /\uFEFF/g;
- tempElement.innerHTML = tempElement.innerHTML.replace(wysihtml5.INVISIBLE_SPACE_REG_EXP, "");
+ tempElement.innerHTML = tempElement.innerHTML.replace(wysihtml.INVISIBLE_SPACE_REG_EXP, "");
if (tempElement) {
isEmpty = (/^(\s|(
))+$/i).test(tempElement.innerHTML);
- list = wysihtml5.dom.convertToList(tempElement, nodeName.toLowerCase(), composer.parent.config.classNames.uneditableContainer);
+ list = wysihtml.dom.convertToList(tempElement, nodeName.toLowerCase(), composer.parent.config.classNames.uneditableContainer);
if (sel) {
rangy.restoreSelection(sel);
}
@@ -15988,18 +14954,18 @@ wysihtml5.Commands = Base.extend(
anode = [fnode, fnode = anode][0];
}
- if (wysihtml5.dom.domNode(fnode).is.emptyTextNode(true) && fnode) {
- fnode = wysihtml5.dom.domNode(fnode).prev({nodeTypes: [1,3], ignoreBlankTexts: true});
+ if (wysihtml.dom.domNode(fnode).is.emptyTextNode(true) && fnode) {
+ fnode = wysihtml.dom.domNode(fnode).prev({nodeTypes: [1,3], ignoreBlankTexts: true});
}
- if (wysihtml5.dom.domNode(anode).is.emptyTextNode(true) && anode) {
- anode = wysihtml5.dom.domNode(anode).next({nodeTypes: [1,3], ignoreBlankTexts: true});
+ if (wysihtml.dom.domNode(anode).is.emptyTextNode(true) && anode) {
+ anode = wysihtml.dom.domNode(anode).next({nodeTypes: [1,3], ignoreBlankTexts: true});
}
if (anode && fnode) {
if (anode === fnode) {
selectedNode = anode;
} else {
- selectedNode = wysihtml5.dom.domNode(anode).commonAncestor(fnode, composer.element);
+ selectedNode = wysihtml.dom.domNode(anode).commonAncestor(fnode, composer.element);
}
} else {
selectedNode = composer.selection.getSelectedNode();
@@ -16028,174 +14994,9 @@ wysihtml5.Commands = Base.extend(
}
};
-})(wysihtml5);
-;(function(wysihtml5){
-
- var nodeOptions = {
- nodeName: "I",
- toggle: true
- };
-
- wysihtml5.commands.italic = {
- exec: function(composer, command) {
- wysihtml5.commands.formatInline.exec(composer, command, nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatInline.state(composer, command, nodeOptions);
- }
- };
-
-}(wysihtml5));
-;(function(wysihtml5) {
-
- var nodeOptions = {
- className: "wysiwyg-text-align-center",
- classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
- toggle: true
- };
-
- wysihtml5.commands.justifyCenter = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- className: "wysiwyg-text-align-left",
- classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
- toggle: true
- };
-
- wysihtml5.commands.justifyLeft = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- className: "wysiwyg-text-align-right",
- classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
- toggle: true
- };
-
- wysihtml5.commands.justifyRight = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- className: "wysiwyg-text-align-justify",
- classRegExp: /wysiwyg-text-align-[0-9a-z]+/g,
- toggle: true
- };
-
- wysihtml5.commands.justifyFull = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- styleProperty: "textAlign",
- styleValue: "right",
- toggle: true
- };
-
- wysihtml5.commands.alignRightStyle = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- styleProperty: "textAlign",
- styleValue: "left",
- toggle: true
- };
-
- wysihtml5.commands.alignLeftStyle = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- styleProperty: "textAlign",
- styleValue: "center",
- toggle: true
- };
-
- wysihtml5.commands.alignCenterStyle = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-
-})(wysihtml5);
-;(function(wysihtml5) {
-
- var nodeOptions = {
- styleProperty: "textAlign",
- styleValue: "justify",
- toggle: true
- };
-
- wysihtml5.commands.alignJustifyStyle = {
- exec: function(composer, command) {
- return wysihtml5.commands.formatBlock.exec(composer, "formatBlock", nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatBlock.state(composer, "formatBlock", nodeOptions);
- }
- };
-})(wysihtml5);
-;(function(wysihtml5){
- wysihtml5.commands.redo = {
+})(wysihtml);
+;(function(wysihtml){
+ wysihtml.commands.redo = {
exec: function(composer) {
return composer.undoManager.redo();
},
@@ -16204,27 +15005,9 @@ wysihtml5.Commands = Base.extend(
return false;
}
};
-}(wysihtml5));
-;(function(wysihtml5){
-
- var nodeOptions = {
- nodeName: "U",
- toggle: true
- };
-
- wysihtml5.commands.underline = {
- exec: function(composer, command) {
- wysihtml5.commands.formatInline.exec(composer, command, nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatInline.state(composer, command, nodeOptions);
- }
- };
-
-}(wysihtml5));
-;(function(wysihtml5){
- wysihtml5.commands.undo = {
+}(wysihtml));
+;(function(wysihtml){
+ wysihtml.commands.undo = {
exec: function(composer) {
return composer.undoManager.undo();
},
@@ -16233,9 +15016,9 @@ wysihtml5.Commands = Base.extend(
return false;
}
};
-}(wysihtml5));
-;(function(wysihtml5){
- wysihtml5.commands.createTable = {
+}(wysihtml));
+;(function(wysihtml){
+ wysihtml.commands.createTable = {
exec: function(composer, command, value) {
var col, row, html;
if (value && value.cols && value.rows && parseInt(value.cols, 10) > 0 && parseInt(value.rows, 10) > 0) {
@@ -16263,15 +15046,15 @@ wysihtml5.Commands = Base.extend(
}
};
-}(wysihtml5));
-;(function(wysihtml5){
- wysihtml5.commands.mergeTableCells = {
+}(wysihtml));
+;(function(wysihtml){
+ wysihtml.commands.mergeTableCells = {
exec: function(composer, command) {
if (composer.tableSelection && composer.tableSelection.start && composer.tableSelection.end) {
if (this.state(composer, command)) {
- wysihtml5.dom.table.unmergeCell(composer.tableSelection.start);
+ wysihtml.dom.table.unmergeCell(composer.tableSelection.start);
} else {
- wysihtml5.dom.table.mergeCellsBetween(composer.tableSelection.start, composer.tableSelection.end);
+ wysihtml.dom.table.mergeCellsBetween(composer.tableSelection.start, composer.tableSelection.end);
}
}
},
@@ -16282,11 +15065,11 @@ wysihtml5.Commands = Base.extend(
end = composer.tableSelection.end;
if (start && end && start == end &&
((
- wysihtml5.dom.getAttribute(start, "colspan") &&
- parseInt(wysihtml5.dom.getAttribute(start, "colspan"), 10) > 1
+ wysihtml.dom.getAttribute(start, "colspan") &&
+ parseInt(wysihtml.dom.getAttribute(start, "colspan"), 10) > 1
) || (
- wysihtml5.dom.getAttribute(start, "rowspan") &&
- parseInt(wysihtml5.dom.getAttribute(start, "rowspan"), 10) > 1
+ wysihtml.dom.getAttribute(start, "rowspan") &&
+ parseInt(wysihtml.dom.getAttribute(start, "rowspan"), 10) > 1
))
) {
return [start];
@@ -16295,18 +15078,18 @@ wysihtml5.Commands = Base.extend(
return false;
}
};
-}(wysihtml5));
-;(function(wysihtml5){
- wysihtml5.commands.addTableCells = {
+}(wysihtml));
+;(function(wysihtml){
+ wysihtml.commands.addTableCells = {
exec: function(composer, command, value) {
if (composer.tableSelection && composer.tableSelection.start && composer.tableSelection.end) {
// switches start and end if start is bigger than end (reverse selection)
- var tableSelect = wysihtml5.dom.table.orderSelectionEnds(composer.tableSelection.start, composer.tableSelection.end);
+ var tableSelect = wysihtml.dom.table.orderSelectionEnds(composer.tableSelection.start, composer.tableSelection.end);
if (value == "before" || value == "above") {
- wysihtml5.dom.table.addCells(tableSelect.start, value);
+ wysihtml.dom.table.addCells(tableSelect.start, value);
} else if (value == "after" || value == "below") {
- wysihtml5.dom.table.addCells(tableSelect.end, value);
+ wysihtml.dom.table.addCells(tableSelect.end, value);
}
setTimeout(function() {
composer.tableSelection.select(tableSelect.start, tableSelect.end);
@@ -16318,31 +15101,31 @@ wysihtml5.Commands = Base.extend(
return false;
}
};
-}(wysihtml5));
-;(function(wysihtml5){
- wysihtml5.commands.deleteTableCells = {
+}(wysihtml));
+;(function(wysihtml){
+ wysihtml.commands.deleteTableCells = {
exec: function(composer, command, value) {
if (composer.tableSelection && composer.tableSelection.start && composer.tableSelection.end) {
- var tableSelect = wysihtml5.dom.table.orderSelectionEnds(composer.tableSelection.start, composer.tableSelection.end),
- idx = wysihtml5.dom.table.indexOf(tableSelect.start),
+ var tableSelect = wysihtml.dom.table.orderSelectionEnds(composer.tableSelection.start, composer.tableSelection.end),
+ idx = wysihtml.dom.table.indexOf(tableSelect.start),
selCell,
table = composer.tableSelection.table;
- wysihtml5.dom.table.removeCells(tableSelect.start, value);
+ wysihtml.dom.table.removeCells(tableSelect.start, value);
setTimeout(function() {
// move selection to next or previous if not present
- selCell = wysihtml5.dom.table.findCell(table, idx);
+ selCell = wysihtml.dom.table.findCell(table, idx);
if (!selCell){
if (value == "row") {
- selCell = wysihtml5.dom.table.findCell(table, {
+ selCell = wysihtml.dom.table.findCell(table, {
"row": idx.row - 1,
"col": idx.col
});
}
if (value == "column") {
- selCell = wysihtml5.dom.table.findCell(table, {
+ selCell = wysihtml.dom.table.findCell(table, {
"row": idx.row,
"col": idx.col - 1
});
@@ -16359,9 +15142,9 @@ wysihtml5.Commands = Base.extend(
return false;
}
};
-}(wysihtml5));
-;(function(wysihtml5){
- wysihtml5.commands.indentList = {
+}(wysihtml));
+;(function(wysihtml){
+ wysihtml.commands.indentList = {
exec: function(composer, command, value) {
var listEls = composer.selection.getSelectionParentsByTag('LI');
if (listEls) {
@@ -16384,7 +15167,7 @@ wysihtml5.Commands = Base.extend(
liNode = liNodes[i];
listTag = (liNode.parentNode.nodeName === 'OL') ? 'OL' : 'UL';
list = liNode.ownerDocument.createElement(listTag);
- prevLi = wysihtml5.dom.domNode(liNode).prev({nodeTypes: [wysihtml5.ELEMENT_NODE]});
+ prevLi = wysihtml.dom.domNode(liNode).prev({nodeTypes: [wysihtml.ELEMENT_NODE]});
prevLiList = (prevLi) ? prevLi.querySelector('ul, ol') : null;
if (prevLi) {
@@ -16402,10 +15185,10 @@ wysihtml5.Commands = Base.extend(
return found;
}
};
-}(wysihtml5));
-;(function(wysihtml5){
+}(wysihtml));
+;(function(wysihtml){
- wysihtml5.commands.outdentList = {
+ wysihtml.commands.outdentList = {
exec: function(composer, command, value) {
var listEls = composer.selection.getSelectionParentsByTag('LI');
if (listEls) {
@@ -16433,8 +15216,8 @@ wysihtml5.Commands = Base.extend(
if (listNode.tagName === 'OL' || listNode.tagName === 'UL') {
found = true;
- outerListNode = wysihtml5.dom.getParentElement(listNode.parentNode, { query: 'ol, ul' }, false, composer.element);
- outerLiNode = wysihtml5.dom.getParentElement(listNode.parentNode, { query: 'li' }, false, composer.element);
+ outerListNode = wysihtml.dom.getParentElement(listNode.parentNode, { query: 'ol, ul' }, false, composer.element);
+ outerLiNode = wysihtml.dom.getParentElement(listNode.parentNode, { query: 'li' }, false, composer.element);
if (outerListNode && outerLiNode) {
@@ -16483,46 +15266,12 @@ wysihtml5.Commands = Base.extend(
}
};
-}(wysihtml5));
-;(function(wysihtml5){
-
- var nodeOptions = {
- nodeName: "SUB",
- toggle: true
- };
-
- wysihtml5.commands.subscript = {
- exec: function(composer, command) {
- wysihtml5.commands.formatInline.exec(composer, command, nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatInline.state(composer, command, nodeOptions);
- }
- };
-}(wysihtml5));
-;(function(wysihtml5) {
-
- var nodeOptions = {
- nodeName: "SUP",
- toggle: true
- };
-
- wysihtml5.commands.superscript = {
- exec: function(composer, command) {
- wysihtml5.commands.formatInline.exec(composer, command, nodeOptions);
- },
-
- state: function(composer, command) {
- return wysihtml5.commands.formatInline.state(composer, command, nodeOptions);
- }
- };
-}(wysihtml5));
+}(wysihtml));
;/**
* Undo Manager for wysihtml5
* slightly inspired by http://rniwa.com/editing/undomanager.html#the-undomanager-interface
*/
-(function(wysihtml5) {
+(function(wysihtml) {
var Z_KEY = 90,
Y_KEY = 89,
BACKSPACE_KEY = 8,
@@ -16530,9 +15279,9 @@ wysihtml5.Commands = Base.extend(
MAX_HISTORY_ENTRIES = 25,
DATA_ATTR_NODE = "data-wysihtml5-selection-node",
DATA_ATTR_OFFSET = "data-wysihtml5-selection-offset",
- UNDO_HTML = '' + wysihtml5.INVISIBLE_SPACE + '',
- REDO_HTML = '' + wysihtml5.INVISIBLE_SPACE + '',
- dom = wysihtml5.dom;
+ UNDO_HTML = '' + wysihtml.INVISIBLE_SPACE + '',
+ REDO_HTML = '' + wysihtml.INVISIBLE_SPACE + '',
+ dom = wysihtml.dom;
function cleanTempElements(doc) {
var tempElement;
@@ -16541,8 +15290,8 @@ wysihtml5.Commands = Base.extend(
}
}
- wysihtml5.UndoManager = wysihtml5.lang.Dispatcher.extend(
- /** @scope wysihtml5.UndoManager.prototype */ {
+ wysihtml.UndoManager = wysihtml.lang.Dispatcher.extend(
+ /** @scope wysihtml.UndoManager.prototype */ {
constructor: function(editor) {
this.editor = editor;
this.composer = editor.composer;
@@ -16630,7 +15379,7 @@ wysihtml5.Commands = Base.extend(
node = (range && range.startContainer) ? range.startContainer : this.element;
offset = (range && range.startOffset) ? range.startOffset : 0;
- if (node.nodeType === wysihtml5.ELEMENT_NODE) {
+ if (node.nodeType === wysihtml.ELEMENT_NODE) {
element = node;
} else {
element = node.parentNode;
@@ -16732,12 +15481,12 @@ wysihtml5.Commands = Base.extend(
return parent.childNodes[index];
}
});
-})(wysihtml5);
+})(wysihtml);
;/**
* TODO: the following methods still need unit test coverage
*/
-wysihtml5.views.View = Base.extend(
- /** @scope wysihtml5.views.View.prototype */ {
+wysihtml.views.View = Base.extend(
+ /** @scope wysihtml.views.View.prototype */ {
constructor: function(parent, textareaElement, config) {
this.parent = parent;
this.element = textareaElement;
@@ -16787,12 +15536,12 @@ wysihtml5.views.View = Base.extend(
this.element.removeAttribute("disabled");
}
});
-;(function(wysihtml5) {
- var dom = wysihtml5.dom,
- browser = wysihtml5.browser;
+;(function(wysihtml) {
+ var dom = wysihtml.dom,
+ browser = wysihtml.browser;
- wysihtml5.views.Composer = wysihtml5.views.View.extend(
- /** @scope wysihtml5.views.Composer.prototype */ {
+ wysihtml.views.Composer = wysihtml.views.View.extend(
+ /** @scope wysihtml.views.Composer.prototype */ {
name: "composer",
constructor: function(parent, editableElement, config) {
@@ -16814,7 +15563,7 @@ wysihtml5.views.View = Base.extend(
},
getValue: function(parse, clearInternals) {
- var value = this.isEmpty() ? "" : wysihtml5.quirks.getCorrectInnerHTML(this.element);
+ var value = this.isEmpty() ? "" : wysihtml.quirks.getCorrectInnerHTML(this.element);
if (parse !== false) {
value = this.parent.parse(value, (clearInternals === false) ? false : true);
}
@@ -16876,7 +15625,7 @@ wysihtml5.views.View = Base.extend(
// IE 8 fires the focus event after .focus()
// This is needed by our simulate_placeholder.js to work
// therefore we clear it ourselves this time
- if (wysihtml5.browser.doesAsyncFocus() && this.hasPlaceholderSet()) {
+ if (wysihtml.browser.doesAsyncFocus() && this.hasPlaceholderSet()) {
this.clear();
}
@@ -16996,10 +15745,10 @@ wysihtml5.views.View = Base.extend(
}
// Make sure our selection handler is ready
- this.selection = new wysihtml5.Selection(this.parent, this.element, this.config.classNames.uneditableContainer);
+ this.selection = new wysihtml.Selection(this.parent, this.element, this.config.classNames.uneditableContainer);
// Make sure commands dispatcher is ready
- this.commands = new wysihtml5.Commands(this.parent);
+ this.commands = new wysihtml.Commands(this.parent);
if (!this.config.noTextarea) {
dom.copyAttributes([
@@ -17053,7 +15802,7 @@ wysihtml5.views.View = Base.extend(
// IE sometimes leaves a single paragraph, which can't be removed by the user
if (!browser.clearsContentEditableCorrectly()) {
- wysihtml5.quirks.ensureProperClearing(this);
+ wysihtml.quirks.ensureProperClearing(this);
}
// Set up a sync that makes sure that textarea and editor have the same content
@@ -17091,7 +15840,7 @@ wysihtml5.views.View = Base.extend(
isInUneditable = false;
for (var i = uneditables.length; i--;) {
- if (wysihtml5.dom.contains(uneditables[i], nodeWithSelection)) {
+ if (wysihtml.dom.contains(uneditables[i], nodeWithSelection)) {
isInUneditable = true;
}
}
@@ -17114,7 +15863,7 @@ wysihtml5.views.View = Base.extend(
// The autoLink helper method reveals a reg exp to detect correct urls
urlRegExp = dom.autoLink.URL_REG_EXP,
getTextContent = function(element) {
- var textContent = wysihtml5.lang.string(dom.getTextContent(element)).trim();
+ var textContent = wysihtml.lang.string(dom.getTextContent(element)).trim();
if (textContent.substr(0, 4) === "www.") {
textContent = "http://" + textContent;
}
@@ -17181,13 +15930,13 @@ wysihtml5.views.View = Base.extend(
}
// After resizing IE sometimes forgets to remove the old resize handles
- wysihtml5.quirks.redraw(element);
+ wysihtml.quirks.redraw(element);
});
}
},
_initUndoManager: function() {
- this.undoManager = new wysihtml5.UndoManager(this.parent);
+ this.undoManager = new wysihtml.UndoManager(this.parent);
},
_initLineBreaking: function() {
@@ -17237,7 +15986,7 @@ wysihtml5.views.View = Base.extend(
return;
}
- if (keyCode !== wysihtml5.ENTER_KEY && keyCode !== wysihtml5.BACKSPACE_KEY) {
+ if (keyCode !== wysihtml.ENTER_KEY && keyCode !== wysihtml.BACKSPACE_KEY) {
return;
}
var blockElement = dom.getParentElement(that.selection.getSelectedNode(), { query: USE_NATIVE_LINE_BREAK_INSIDE_TAGS }, 4);
@@ -17259,22 +16008,22 @@ wysihtml5.views.View = Base.extend(
}
}
- if (keyCode === wysihtml5.ENTER_KEY && blockElement.nodeName.match(/^H[1-6]$/)) {
+ if (keyCode === wysihtml.ENTER_KEY && blockElement.nodeName.match(/^H[1-6]$/)) {
adjust(selectedNode);
}
}, 0);
return;
}
- if (that.config.useLineBreaks && keyCode === wysihtml5.ENTER_KEY && !wysihtml5.browser.insertsLineBreaksOnReturn()) {
+ if (that.config.useLineBreaks && keyCode === wysihtml.ENTER_KEY && !wysihtml.browser.insertsLineBreaksOnReturn()) {
event.preventDefault();
that.commands.exec("insertLineBreak");
}
});
}
});
-})(wysihtml5);
-;(function(wysihtml5) {
- var dom = wysihtml5.dom,
+})(wysihtml);
+;(function(wysihtml) {
+ var dom = wysihtml.dom,
doc = document,
win = window,
HOST_TEMPLATE = doc.createElement("div"),
@@ -17318,7 +16067,7 @@ wysihtml5.views.View = Base.extend(
"body { height: 100%; padding: 1px 0 0 0; margin: -1px 0 0 0; }",
"body > p:first-child { margin-top: 0; }",
"._wysihtml5-temp { display: none; }",
- wysihtml5.browser.isGecko ?
+ wysihtml.browser.isGecko ?
"body.placeholder { color: graytext !important; }" :
"body.placeholder { color: #a9a9a9 !important; }",
// Ensure that user see's broken images and can delete them
@@ -17371,7 +16120,7 @@ wysihtml5.views.View = Base.extend(
};
- wysihtml5.views.Composer.prototype.style = function() {
+ wysihtml.views.Composer.prototype.style = function() {
var that = this,
originalActiveElement = doc.querySelector(":focus"),
textareaElement = this.textarea.element,
@@ -17436,7 +16185,7 @@ wysihtml5.views.View = Base.extend(
// Make sure that we don't change the display style of the iframe when copying styles oblur/onfocus
// this is needed for when the change_view event is fired where the iframe is hidden and then
// the blur event fires and re-displays it
- var boxFormattingStyles = wysihtml5.lang.array(BOX_FORMATTING).without(["display"]);
+ var boxFormattingStyles = wysihtml.lang.array(BOX_FORMATTING).without(["display"]);
// --------- restore focus ---------
if (originalActiveElement) {
@@ -17473,7 +16222,7 @@ wysihtml5.views.View = Base.extend(
return this;
};
-})(wysihtml5);
+})(wysihtml);
;/**
* Taking care of events
* - Simulating 'change' event on contentEditable element
@@ -17482,10 +16231,10 @@ wysihtml5.views.View = Base.extend(
* - Dispatch proprietary newword:composer event
* - Keyboard shortcuts
*/
-(function(wysihtml5) {
- var dom = wysihtml5.dom,
+(function(wysihtml) {
+ var dom = wysihtml.dom,
domNode = dom.domNode,
- browser = wysihtml5.browser,
+ browser = wysihtml.browser,
/**
* Map keyCodes to query commands
*/
@@ -17494,11 +16243,11 @@ wysihtml5.views.View = Base.extend(
"73": "italic", // I
"85": "underline" // U
};
-
+
var actions = {
// Adds multiple eventlisteners to target, bound to one callback
- // TODO: If needed elsewhere make it part of wysihtml5.dom or sth
+ // TODO: If needed elsewhere make it part of wysihtml.dom or sth
addListeners: function (target, events, callback) {
for(var i = 0, max = events.length; i < max; i++) {
target.addEventListener(events[i], callback, false);
@@ -17506,7 +16255,7 @@ wysihtml5.views.View = Base.extend(
},
// Removes multiple eventlisteners from target, bound to one callback
- // TODO: If needed elsewhere make it part of wysihtml5.dom or sth
+ // TODO: If needed elsewhere make it part of wysihtml.dom or sth
removeListeners: function (target, events, callback) {
for(var i = 0, max = events.length; i < max; i++) {
target.removeEventListener(events[i], callback, false);
@@ -17518,7 +16267,7 @@ wysihtml5.views.View = Base.extend(
if (composer.selection.caretIsLastInSelection()) {
var sel = composer.selection.getSelection(),
aNode = sel.anchorNode;
- if (aNode && aNode.nodeType === 1 && (wysihtml5.dom.getParentElement(aNode, {query: 'td, th'}, false, composer.element) || force)) {
+ if (aNode && aNode.nodeType === 1 && (wysihtml.dom.getParentElement(aNode, {query: 'td, th'}, false, composer.element) || force)) {
var nextNode = aNode.childNodes[sel.anchorOffset];
if (nextNode && nextNode.nodeType === 1 & nextNode.nodeName === "BR") {
nextNode.parentNode.removeChild(nextNode);
@@ -17552,9 +16301,9 @@ wysihtml5.views.View = Base.extend(
var selection = composer.selection,
prevNode = selection.getPreviousNode();
- if (selection.caretIsFirstInSelection(wysihtml5.browser.usesControlRanges()) && prevNode) {
+ if (selection.caretIsFirstInSelection(wysihtml.browser.usesControlRanges()) && prevNode) {
if (prevNode.nodeType === 1 &&
- wysihtml5.dom.domNode(prevNode).is.block() &&
+ wysihtml.dom.domNode(prevNode).is.block() &&
!domNode(prevNode).test({
query: "ol, ul, table, tr, dl"
})
@@ -17568,7 +16317,7 @@ wysihtml5.views.View = Base.extend(
var selNode = prevNode.lastChild,
selectedNode = selection.getSelectedNode(),
commonAncestorNode = domNode(prevNode).commonAncestor(selectedNode, composer.element),
- curNode = wysihtml5.dom.getParentElement(selectedNode, {
+ curNode = wysihtml.dom.getParentElement(selectedNode, {
query: "h1, h2, h3, h4, h5, h6, p, pre, div, blockquote"
}, false, commonAncestorNode || composer.element);
@@ -17576,7 +16325,7 @@ wysihtml5.views.View = Base.extend(
domNode(curNode).transferContentTo(prevNode, true);
selection.setAfter(selNode);
return true;
- } else if (wysihtml5.browser.usesControlRanges()) {
+ } else if (wysihtml.browser.usesControlRanges()) {
selectedNode = selection.getCaretNode();
domNode(selectedNode).transferContentTo(prevNode, true);
selection.setAfter(selNode);
@@ -17592,7 +16341,7 @@ wysihtml5.views.View = Base.extend(
/* In IE when deleting with caret at the begining of LI, list gets broken into half instead of merging the LI with previous */
/* This does not match other browsers an is less intuitive from UI standpoint, thus has to be fixed */
fixDeleteInTheBeginningOfLi: function(composer) {
- if (wysihtml5.browser.hasLiDeletingProblem()) {
+ if (wysihtml.browser.hasLiDeletingProblem()) {
var selection = composer.selection.getSelection(),
aNode = selection.anchorNode,
listNode, prevNode, firstNode,
@@ -17631,7 +16380,7 @@ wysihtml5.views.View = Base.extend(
}
return false;
},
-
+
fixDeleteInTheBeginningOfControlSelection: function(composer) {
var selection = composer.selection,
prevNode = selection.getPreviousNode(),
@@ -17666,8 +16415,8 @@ wysihtml5.views.View = Base.extend(
}).bind(this);
if( this.doc.execCommand &&
- wysihtml5.browser.supportsCommand(this.doc, "enableObjectResizing") &&
- wysihtml5.browser.supportsCommand(this.doc, "enableInlineTableEditing"))
+ wysihtml.browser.supportsCommand(this.doc, "enableObjectResizing") &&
+ wysihtml.browser.supportsCommand(this.doc, "enableInlineTableEditing"))
{
if (this.sandbox.getIframe) {
actions.addListeners(this.sandbox.getIframe(), ["focus", "mouseup", "mouseover"], iframeInitiator);
@@ -17675,7 +16424,7 @@ wysihtml5.views.View = Base.extend(
window.addEventListener('load', hideHandlers);
}
}
- this.tableSelection = wysihtml5.quirks.tableCellsSelection(this.element, this.parent);
+ this.tableSelection = wysihtml.quirks.tableCellsSelection(this.element, this.parent);
},
// Fixes some misbehaviours of enters in linebreaks mode (natively a bit unsupported feature)
@@ -17723,7 +16472,7 @@ wysihtml5.views.View = Base.extend(
composer.selection.setBefore(brNode);
}
- } else if (caretInfo.caretNode.nodeType === 3 && wysihtml5.browser.hasCaretBlockElementIssue() && caretInfo.textOffset === caretInfo.caretNode.data.length && !caretInfo.nextNode) {
+ } else if (caretInfo.caretNode.nodeType === 3 && wysihtml.browser.hasCaretBlockElementIssue() && caretInfo.textOffset === caretInfo.caretNode.data.length && !caretInfo.nextNode) {
// This fixes annoying webkit issue when you press enter at the end of a block then seemingly nothing happens.
// in reality one line break is generated and cursor is reported after it, but when entering something cursor jumps before the br
@@ -17748,6 +16497,14 @@ wysihtml5.views.View = Base.extend(
element = composer.element;
if (selection.isCollapsed()) {
+ /**
+ * when the editor is empty in useLineBreaks = false mode, preserve
+ * the default value in it which is
for line breaks, set this to false to use
* toolbar.execCommand("formatBlock", "blockquote");
*/
@@ -19055,7 +17815,7 @@ wysihtml5.views.View = Base.extend(
});
this._ownerDocumentClick = function(event) {
- if (!wysihtml5.dom.contains(that.container, event.target) && !wysihtml5.dom.contains(that.composer.element, event.target)) {
+ if (!wysihtml.dom.contains(that.container, event.target) && !wysihtml.dom.contains(that.composer.element, event.target)) {
that._updateLinkStates();
that._preventInstantFocus();
}
@@ -19211,26 +17971,26 @@ wysihtml5.views.View = Base.extend(
// to avoid showing a dialog for multiple selected elements which may have different attributes
// eg. when two links with different href are selected, the state will be an array consisting of both link elements
// but the dialog interface can only update one
- if (!command.dialog.multiselect && wysihtml5.lang.object(state).isArray()) {
+ if (!command.dialog.multiselect && wysihtml.lang.object(state).isArray()) {
state = state.length === 1 ? state[0] : true;
}
return state;
}
-})(wysihtml5);
-;(function(wysihtml5) {
- wysihtml5.toolbar.Dialog_createTable = wysihtml5.toolbar.Dialog.extend({
+})(wysihtml);
+;(function(wysihtml) {
+ wysihtml.toolbar.Dialog_createTable = wysihtml.toolbar.Dialog.extend({
show: function(elementToChange) {
this.base(elementToChange);
}
});
-})(wysihtml5);
-;(function(wysihtml5) {
+})(wysihtml);
+;(function(wysihtml) {
var SELECTOR_FIELDS = "[data-wysihtml5-dialog-field]",
ATTRIBUTE_FIELDS = "data-wysihtml5-dialog-field";
- wysihtml5.toolbar.Dialog_foreColorStyle = wysihtml5.toolbar.Dialog.extend({
+ wysihtml.toolbar.Dialog_foreColorStyle = wysihtml.toolbar.Dialog.extend({
multiselect: true,
_serialize: function() {
@@ -19247,12 +18007,12 @@ wysihtml5.views.View = Base.extend(
_interpolate: function(avoidHiddenFields) {
var field, colourMode,
- styleParser = wysihtml5.quirks.styleParser,
+ styleParser = wysihtml.quirks.styleParser,
focusedElement = document.querySelector(":focus"),
fields = this.container.querySelectorAll(SELECTOR_FIELDS),
length = fields.length,
i = 0,
- firstElement = (this.elementToChange) ? ((wysihtml5.lang.object(this.elementToChange).isArray()) ? this.elementToChange[0] : this.elementToChange) : null,
+ firstElement = (this.elementToChange) ? ((wysihtml.lang.object(this.elementToChange).isArray()) ? this.elementToChange[0] : this.elementToChange) : null,
colourStr = (firstElement) ? firstElement.getAttribute("style") : null,
colour = (colourStr) ? styleParser.parseColor(colourStr, "color") : null;
@@ -19280,13 +18040,13 @@ wysihtml5.views.View = Base.extend(
}
});
-})(wysihtml5);
-;(function(wysihtml5) {
- var dom = wysihtml5.dom,
+})(wysihtml);
+;(function(wysihtml) {
+ var dom = wysihtml.dom,
SELECTOR_FIELDS = "[data-wysihtml5-dialog-field]",
ATTRIBUTE_FIELDS = "data-wysihtml5-dialog-field";
- wysihtml5.toolbar.Dialog_fontSizeStyle = wysihtml5.toolbar.Dialog.extend({
+ wysihtml.toolbar.Dialog_fontSizeStyle = wysihtml.toolbar.Dialog.extend({
multiselect: true,
_serialize: function() {
@@ -19296,13 +18056,15 @@ wysihtml5.views.View = Base.extend(
_interpolate: function(avoidHiddenFields) {
var focusedElement = document.querySelector(":focus"),
field = this.container.querySelector("[data-wysihtml5-dialog-field='size']"),
- firstElement = (this.elementToChange) ? ((wysihtml5.lang.object(this.elementToChange).isArray()) ? this.elementToChange[0] : this.elementToChange) : null,
+ firstElement = (this.elementToChange) ? ((wysihtml.lang.object(this.elementToChange).isArray()) ? this.elementToChange[0] : this.elementToChange) : null,
styleStr = (firstElement) ? firstElement.getAttribute('style') : null,
- size = (styleStr) ? wysihtml5.quirks.styleParser.parseFontSize(styleStr) : null;
+ size = (styleStr) ? wysihtml.quirks.styleParser.parseFontSize(styleStr) : null;
if (field && field !== focusedElement && size && !(/^\s*$/).test(size)) {
field.value = size;
}
}
});
-})(wysihtml5);
+})(wysihtml);
+
+});
diff --git a/dist/wysihtml-toolbar.min.js b/dist/wysihtml-toolbar.min.js
index 2bcf9ce..a5809e9 100644
--- a/dist/wysihtml-toolbar.min.js
+++ b/dist/wysihtml-toolbar.min.js
@@ -1,11 +1,11 @@
-/*! wysihtml - v0.5.5 (2016-01-06) */
+/*! wysihtml - v0.5.5 (2016-04-29) */
-var wysihtml5={version:"0.5.5",commands:{},dom:{},quirks:{},toolbar:{},lang:{},selection:{},views:{},INVISIBLE_SPACE:"\ufeff",INVISIBLE_SPACE_REG_EXP:/\uFEFF/g,VOID_ELEMENTS:"area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr",EMPTY_FUNCTION:function(){},ELEMENT_NODE:1,TEXT_NODE:3,BACKSPACE_KEY:8,ENTER_KEY:13,ESCAPE_KEY:27,SPACE_KEY:32,TAB_KEY:9,DELETE_KEY:46};wysihtml5.polyfills=function(a,b){function c(){try{var a=new CustomEvent("cat",{detail:{foo:"bar"}});return"cat"===a.type&&"bar"===a.detail.foo}catch(b){}return!1}String.prototype.trim||!function(){var a=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(a,"")}}(),function(){var c="addEventListener",d="removeEventListener";b[c]||(a.Element.prototype[c]=a[c]=b[c]=function(b,c,d){return(d=this).attachEvent("on"+b,function(b){var b=b||a.event;b.target=b.target||b.srcElement,b.preventDefault=b.preventDefault||function(){b.returnValue=!1},b.stopPropagation=b.stopPropagation||function(){b.cancelBubble=!0},b.which=b.button?2===b.button?3:4===b.button?2:b.button:b.keyCode,c.call(d,b)})},a.Element.prototype[d]=a[d]=b[d]=function(a,b){return this.detachEvent("on"+a,b)})}(),Object.defineProperty&&Object.getOwnPropertyDescriptor&&Object.getOwnPropertyDescriptor(a.Element.prototype,"textContent")&&!Object.getOwnPropertyDescriptor(a.Element.prototype,"textContent").get&&!function(){var b=Object.getOwnPropertyDescriptor(a.Element.prototype,"innerText");Object.defineProperty(a.Element.prototype,"textContent",{get:function(){return b.get.call(this)},set:function(a){return b.set.call(this,a)}})}(),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=this.length,d=-1,e=b>>>0;~(c-e);d=this[--c]===a?c:d);return d}),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),function(a){a.matches=a.matches||a.mozMatchesSelector||a.msMatchesSelector||a.oMatchesSelector||a.webkitMatchesSelector||function(a){for(var b=this,c=(b.document||b.ownerDocument).querySelectorAll(a),d=0;c[d]&&c[d]!==b;)++d;return c[d]?!0:!1},a.closest=a.closest||function(a){for(var b=this;b&&!b.matches(a);)b=b.parentElement;return b}}(Element.prototype),"document"in a&&("classList"in b.createElement("_")?"DOMTokenList"in a&&!function(){"use strict";var c=b.createElement("_");if(c.classList.add("c1","c2"),!c.classList.contains("c2")){var d=function(b){var c=a.DOMTokenList.prototype[b];a.DOMTokenList.prototype[b]=function(a){var b,d=arguments.length;for(b=0;d>b;b++)a=arguments[b],c.call(this,a)}};d("add"),d("remove")}if(c.classList.toggle("c3",!1),c.classList.contains("c3")){var e=a.DOMTokenList.prototype.toggle;a.DOMTokenList.prototype.toggle=function(a,b){return 1 in arguments&&!this.contains(a)==!b?b:e.call(this,a)}}c=null}():!function(a){"use strict";if("Element"in a){var b="classList",c="prototype",d=a.Element[c],e=Object,f=String[c].trim||function(){return this.replace(/^\s+|\s+$/g,"")},g=Array[c].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},h=function(a,b){this.name=a,this.code=DOMException[a],this.message=b},i=function(a,b){if(""===b)throw new h("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new h("INVALID_CHARACTER_ERR","String contains an invalid character");return g.call(a,b)},j=function(a){for(var b=f.call(a.getAttribute("class")||""),c=b?b.split(/\s+/):[],d=0,e=c.length;e>d;d++)this.push(c[d]);this._updateClassName=function(){a.setAttribute("class",this.toString())}},k=j[c]=[],l=function(){return new j(this)};if(h[c]=Error[c],k.item=function(a){return this[a]||null},k.contains=function(a){return a+="",-1!==i(this,a)},k.add=function(){var a,b=arguments,c=0,d=b.length,e=!1;do a=b[c]+"",-1===i(this,a)&&(this.push(a),e=!0);while(++c
",L=w(c),a.features.crashyTextNodes=L}();var M;typeof window.getComputedStyle!=F?M=function(a,b){return p(a).getComputedStyle(a,null)[b]}:typeof document.documentElement.currentStyle!=F?M=function(a,b){return a.currentStyle?a.currentStyle[b]:""}:b.fail("No means of obtaining computed style properties found"),B.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a,b,c=this._current=this._next;if(this._current)if(a=c.firstChild)this._next=a;else{for(b=null;c!==this.root&&!(b=c.nextSibling);)c=c.parentNode;this._next=b}return this._current},detach:function(){this._current=this._next=this.root=null}},D.prototype={equals:function(a){return!!a&&this.node===a.node&&this.offset==a.offset},inspect:function(){return"[DomPosition("+x(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},E.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11,INVALID_NODE_TYPE_ERR:24},E.prototype.toString=function(){return this.message},a.dom={arrayContains:K,isHtmlNamespace:c,parentElement:d,getNodeIndex:e,getNodeLength:f,getCommonAncestor:g,isAncestorOf:h,isOrIsAncestorOf:i,getClosestAncestorIn:j,isCharacterDataNode:k,isTextOrCommentNode:l,insertAfter:m,splitDataNode:n,getDocument:o,getWindow:p,getIframeWindow:r,getIframeDocument:q,getBody:H,isWindow:s,getContentDocument:t,getRootContainer:u,comparePoints:v,isBrokenNode:w,inspectNode:x,getComputedStyleProperty:M,createTestElement:z,removeNode:A,fragmentFromNodeChildren:y,createIterator:C,DomPosition:D},a.DOMException=E}),H.createCoreModule("DomRange",["DomUtil"],function(a,b){function c(a,b){return 3!=a.nodeType&&(P(a,b.startContainer)||P(a,b.endContainer))}function d(a){return a.document||Q(a.startContainer)}function e(a){return W(a.startContainer)}function f(a){return new L(a.parentNode,O(a))}function g(a){return new L(a.parentNode,O(a)+1)}function h(a,b,c){var d=11==a.nodeType?a.firstChild:a;return N(b)?c==b.length?J.insertAfter(a,b):b.parentNode.insertBefore(a,0==c?b:S(b,c)):c>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]),d}function i(a,b,c){if(z(a),z(b),d(b)!=d(a))throw new M("WRONG_DOCUMENT_ERR");var e=R(a.startContainer,a.startOffset,b.endContainer,b.endOffset),f=R(a.endContainer,a.endOffset,b.startContainer,b.startOffset);return c?0>=e&&f>=0:0>e&&f>0}function j(a){for(var b,c,e,f=d(a.range).createDocumentFragment();c=a.next();){if(b=a.isPartiallySelectedSubtree(),c=c.cloneNode(!b),b&&(e=a.getSubtreeIterator(),c.appendChild(j(e)),e.detach()),10==c.nodeType)throw new M("HIERARCHY_REQUEST_ERR");f.appendChild(c)}return f}function k(a,b,c){var d,e;c=c||{stop:!1};for(var f,g;f=a.next();)if(a.isPartiallySelectedSubtree()){if(b(f)===!1)return void(c.stop=!0);if(g=a.getSubtreeIterator(),k(g,b,c),g.detach(),c.stop)return}else for(d=J.createIterator(f);e=d.next();)if(b(e)===!1)return void(c.stop=!0)}function l(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),l(b),b.detach()):a.remove()}function m(a){for(var b,c,e=d(a.range).createDocumentFragment();b=a.next();){if(a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),c=a.getSubtreeIterator(),b.appendChild(m(c)),c.detach()):a.remove(),10==b.nodeType)throw new M("HIERARCHY_REQUEST_ERR");e.appendChild(b)}return e}function n(a,b,c){var d,e=!(!b||!b.length),f=!!c;e&&(d=new RegExp("^("+b.join("|")+")$"));var g=[];return k(new p(a,!1),function(b){if((!e||d.test(b.nodeType))&&(!f||c(b))){var h=a.startContainer;if(b!=h||!N(h)||a.startOffset!=h.length){var i=a.endContainer;b==i&&N(i)&&0==a.endOffset||g.push(b)}}}),g}function o(a){var b="undefined"==typeof a.getName?"Range":a.getName();return"["+b+"("+J.inspectNode(a.startContainer)+":"+a.startOffset+", "+J.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function p(a,b){if(this.range=a,this.clonePartiallySelectedTextNodes=b,!a.collapsed){this.sc=a.startContainer,this.so=a.startOffset,this.ec=a.endContainer,this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&N(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==c||N(this.sc)?T(this.sc,c,!0):this.sc.childNodes[this.so],this._last=this.ec!==c||N(this.ec)?T(this.ec,c,!0):this.ec.childNodes[this.eo-1])}}function q(a){return function(b,c){for(var d,e=c?b:b.parentNode;e;){if(d=e.nodeType,V(a,d))return e;e=e.parentNode}return null}}function r(a,b){if(ea(a,b))throw new M("INVALID_NODE_TYPE_ERR")}function s(a,b){if(!V(b,a.nodeType))throw new M("INVALID_NODE_TYPE_ERR")}function t(a,b){if(0>b||b>(N(a)?a.length:a.childNodes.length))throw new M("INDEX_SIZE_ERR")}function u(a,b){if(ca(a,!0)!==ca(b,!0))throw new M("WRONG_DOCUMENT_ERR")}function v(a){if(da(a,!0))throw new M("NO_MODIFICATION_ALLOWED_ERR")}function w(a,b){if(!a)throw new M(b)}function x(a,b){return b<=(N(a)?a.length:a.childNodes.length)}function y(a){return!!a.startContainer&&!!a.endContainer&&!(X&&(J.isBrokenNode(a.startContainer)||J.isBrokenNode(a.endContainer)))&&W(a.startContainer)==W(a.endContainer)&&x(a.startContainer,a.startOffset)&&x(a.endContainer,a.endOffset)}function z(a){if(!y(a))throw new Error("Range error: Range is not valid. This usually happens after DOM mutation. Range: ("+a.inspect()+")")}function A(a,b){z(a);var c=a.startContainer,d=a.startOffset,e=a.endContainer,f=a.endOffset,g=c===e;N(e)&&f>0&&f
",d.collapse(b,2),d.setStart(b.firstChild,0),ca=1==(""+d).length,b.innerHTML="1
")),b&&(f=f.replace(/ /gi," ")),f}}}}(),function(a){function b(a,b){return f(a,b)?a:(a===a.ownerDocument.documentElement&&(a=a.ownerDocument.body),g(a,b))}function c(a){return a.replace(i,function(a,b){var c=(b.match(j)||[])[1]||"",d=l[c];b=b.replace(j,""),b.split(d).length>b.split(c).length&&(b+=c,c="");var e=b,f=b;return b.length>k&&(f=f.substr(0,k)+"..."),"www."===e.substr(0,4)&&(e="http://"+e),''+f+""+c})}function d(a){var b=a._wysihtml5_tempElement;return b||(b=a._wysihtml5_tempElement=a.createElement("div")),b}function e(b){var e=b.parentNode,f=a.lang.string(b.data).escapeHTML(),g=d(e.ownerDocument);for(g.innerHTML=""+c(f),g.removeChild(g.firstChild);g.firstChild;)e.insertBefore(g.firstChild,b);e.removeChild(b)}function f(b,c){for(var d;b.parentNode;){if(b=b.parentNode,d=b.nodeName,b.className&&a.lang.array(b.className.split(" ")).contains(c))return!0;if(h.contains(d))return!0;if("body"===d)return!1}return!1}function g(b,c){if(!(h.contains(b.nodeName)||b.className&&a.lang.array(b.className.split(" ")).contains(c))){if(b.nodeType===a.TEXT_NODE&&b.data.match(i))return void e(b);for(var d=a.lang.array(b.childNodes).get(),f=d.length,j=0;f>j;j++)g(d[j],c);return b}}var h=a.lang.array(["CODE","PRE","A","SCRIPT","HEAD","TITLE","STYLE"]),i=/((https?:\/\/|www\.)[^\s<]{3,})/gi,j=/([^\w\/\-](,?))$/i,k=100,l={")":"(","]":"[","}":"{"};a.dom.autoLink=b,a.dom.autoLink.URL_REG_EXP=i}(wysihtml5),function(a){var b=a.dom;b.addClass=function(a,c){var d=a.classList;return d?d.add(c):void(b.hasClass(a,c)||(a.className+=" "+c))},b.removeClass=function(a,b){var c=a.classList;return c?c.remove(b):void(a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," "))},b.hasClass=function(a,b){var c=a.classList;if(c)return c.contains(b);var d=a.className;return d.length>0&&(d==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(d))}}(wysihtml5),wysihtml5.dom.contains=function(){var a=document.documentElement;return a.contains?function(a,b){if(b.nodeType!==wysihtml5.ELEMENT_NODE){if(b.parentNode===a)return!0;b=b.parentNode}return a!==b&&a.contains(b)}:a.compareDocumentPosition?function(a,b){return!!(16&a.compareDocumentPosition(b))}:void 0}(),wysihtml5.dom.convertToList=function(){function a(a,b){var c=a.createElement("li");return b.appendChild(c),c}function b(a,b){return a.createElement(b)}function c(c,d,e){if("UL"===c.nodeName||"OL"===c.nodeName||"MENU"===c.nodeName)return c;var f,g,h,i,j,k,l,m,n,o=c.ownerDocument,p=b(o,d),q=c.querySelectorAll("br"),r=q.length;for(n=0;r>n;n++)for(i=q[n];(j=i.parentNode)&&j!==c&&j.lastChild===i;){if("block"===wysihtml5.dom.getStyle("display").from(j)){j.removeChild(i);break}wysihtml5.dom.insert(i).after(i.parentNode)}for(f=wysihtml5.lang.array(c.childNodes).get(),g=f.length,n=0;g>n;n++)m=m||a(o,p),h=f[n],k="block"===wysihtml5.dom.getStyle("display").from(h),l="BR"===h.nodeName,!k||e&&wysihtml5.dom.hasClass(h,e)?l?m=m.firstChild?null:m:m.appendChild(h):(m=m.firstChild?a(o,p):m,m.appendChild(h),m=null);return 0===f.length&&a(o,p),c.parentNode.replaceChild(p,c),p}return c}(),wysihtml5.dom.copyAttributes=function(a){return{from:function(b){return{to:function(c){for(var d,e=0,f=a.length;f>e;e++)d=a[e],"undefined"!=typeof b[d]&&""!==b[d]&&(c[d]=b[d]);return{andTo:arguments.callee}}}}}},function(a){var b=["-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing"],c=function(b){return d(b)?parseInt(a.getStyle("width").from(b),10)
"==b||"
"==b)&&(a.innerHTML="")},0)};return function(b){wysihtml5.dom.observe(b.element,["cut","keydown"],a)}}(),function(a){var b="%7E";a.quirks.getCorrectInnerHTML=function(c){var d=c.innerHTML;if(-1===d.indexOf(b))return d;var e,f,g,h,i=c.querySelectorAll("[href*='~'], [src*='~']");for(h=0,g=i.length;g>h;h++)e=i[h].href||i[h].src,f=a.lang.string(e).replace("~").by(b),d=a.lang.string(d).replace(f).by(e);return d}}(wysihtml5),function(a){var b="wysihtml5-quirks-redraw";a.quirks.redraw=function(c){a.dom.addClass(c,b),a.dom.removeClass(c,b);try{var d=c.ownerDocument;d.execCommand("italic",!1,null),d.execCommand("italic",!1,null)}catch(e){}}}(wysihtml5),wysihtml5.quirks.tableCellsSelection=function(a,b){function c(){return a.addEventListener("mousedown",n),l}function d(c){l.start=c,l.end=c,l.cells=[c],l.table=k.getParentElement(l.start,{query:"table"},!1,a),l.table&&(e(),k.addClass(c,m),a.addEventListener("mousemove",g),a.addEventListener("mouseup",h),b.fire("tableselectstart").fire("tableselectstart:composer"))}function e(){if(a){var b=a.querySelectorAll("."+m);if(b.length>0)for(var c=0;c