bsw/jbe@1309: wysihtml.commands.alignCenterStyle = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: styleProperty: "textAlign", bsw/jbe@1309: styleValue: "center", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.alignJustifyStyle = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: styleProperty: "textAlign", bsw/jbe@1309: styleValue: "justify", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.alignLeftStyle = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: styleProperty: "textAlign", bsw/jbe@1309: styleValue: "left", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.alignRightStyle = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: styleProperty: "textAlign", bsw/jbe@1309: styleValue: "right", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: /* Sets text background color by inline styles */ bsw/jbe@1309: wysihtml.commands.bgColorStyle = (function() { bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command, color) { bsw/jbe@1309: var colorVals = wysihtml.quirks.styleParser.parseColor("background-color:" + (color.color || color), "background-color"), bsw/jbe@1309: colString; bsw/jbe@1309: bsw/jbe@1309: if (colorVals) { bsw/jbe@1309: colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(', ') : "rgba(" + colorVals.join(', ')) + ')'; bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, {styleProperty: 'backgroundColor', styleValue: colString}); bsw/jbe@1309: } bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command, color) { bsw/jbe@1309: var colorVals = color ? wysihtml.quirks.styleParser.parseColor("background-color:" + (color.color || color), "background-color") : null, bsw/jbe@1309: colString; bsw/jbe@1309: bsw/jbe@1309: if (colorVals) { bsw/jbe@1309: colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(', ') : "rgba(" + colorVals.join(', ')) + ')'; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, {styleProperty: 'backgroundColor', styleValue: colString}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: remove: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.remove(composer, command, {styleProperty: 'backgroundColor'}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: stateValue: function(composer, command, props) { bsw/jbe@1309: var st = this.state(composer, command), bsw/jbe@1309: colorStr, bsw/jbe@1309: val = false; bsw/jbe@1309: bsw/jbe@1309: if (st && wysihtml.lang.object(st).isArray()) { bsw/jbe@1309: st = st[0]; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: if (st) { bsw/jbe@1309: colorStr = st.getAttribute('style'); bsw/jbe@1309: if (colorStr) { bsw/jbe@1309: val = wysihtml.quirks.styleParser.parseColor(colorStr, "background-color"); bsw/jbe@1309: return wysihtml.quirks.styleParser.unparseColor(val, props); bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.bold = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: nodeName: "B", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: /* Formats block for as a
block bsw/jbe@1309: * Useful in conjuction for sytax highlight utility: highlight.js bsw/jbe@1309: * bsw/jbe@1309: * Usage: bsw/jbe@1309: * bsw/jbe@1309: * editorInstance.composer.commands.exec("formatCode", "language-html"); bsw/jbe@1309: */ bsw/jbe@1309: wysihtml.commands.formatCode = (function() { bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command, classname) { bsw/jbe@1309: var pre = this.state(composer)[0], bsw/jbe@1309: code, range, selectedNodes; bsw/jbe@1309: bsw/jbe@1309: if (pre) { bsw/jbe@1309: // caret is already within a
...
bsw/jbe@1309: composer.selection.executeAndRestore(function() { bsw/jbe@1309: code = pre.querySelector("code"); bsw/jbe@1309: wysihtml.dom.replaceWithChildNodes(pre); bsw/jbe@1309: if (code) { bsw/jbe@1309: wysihtml.dom.replaceWithChildNodes(code); bsw/jbe@1309: } bsw/jbe@1309: }); bsw/jbe@1309: } else { bsw/jbe@1309: // Wrap in
...
bsw/jbe@1309: range = composer.selection.getRange(); bsw/jbe@1309: selectedNodes = range.extractContents(); bsw/jbe@1309: pre = composer.doc.createElement("pre"); bsw/jbe@1309: code = composer.doc.createElement("code"); bsw/jbe@1309: bsw/jbe@1309: if (classname) { bsw/jbe@1309: code.className = classname; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: pre.appendChild(code); bsw/jbe@1309: code.appendChild(selectedNodes); bsw/jbe@1309: range.insertNode(pre); bsw/jbe@1309: composer.selection.selectNode(pre); bsw/jbe@1309: } bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer) { bsw/jbe@1309: var selectedNode = composer.selection.getSelectedNode(), node; bsw/jbe@1309: if (selectedNode && selectedNode.nodeName && selectedNode.nodeName == "PRE"&& bsw/jbe@1309: selectedNode.firstChild && selectedNode.firstChild.nodeName && selectedNode.firstChild.nodeName == "CODE") { bsw/jbe@1309: return [selectedNode]; bsw/jbe@1309: } else { bsw/jbe@1309: node = wysihtml.dom.getParentElement(selectedNode, { query: "pre code" }); bsw/jbe@1309: return node ? [node.parentNode] : false; bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: /** bsw/jbe@1309: * Inserts an bsw/jbe@1309: * If selection is already an image link, it removes it bsw/jbe@1309: * bsw/jbe@1309: * @example bsw/jbe@1309: * // either ... bsw/jbe@1309: * wysihtml.commands.insertImage.exec(composer, "insertImage", "http://www.google.de/logo.jpg"); bsw/jbe@1309: * // ... or ... bsw/jbe@1309: * wysihtml.commands.insertImage.exec(composer, "insertImage", { src: "http://www.google.de/logo.jpg", title: "foo" }); bsw/jbe@1309: */ bsw/jbe@1309: wysihtml.commands.insertImage = (function() { bsw/jbe@1309: var NODE_NAME = "IMG"; bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command, value) { bsw/jbe@1309: value = typeof(value) === "object" ? value : { src: value }; bsw/jbe@1309: bsw/jbe@1309: var doc = composer.doc, bsw/jbe@1309: image = this.state(composer), bsw/jbe@1309: textNode, bsw/jbe@1309: parent; bsw/jbe@1309: bsw/jbe@1309: // If image is selected and src ie empty, set the caret before it and delete the image bsw/jbe@1309: if (image && !value.src) { bsw/jbe@1309: composer.selection.setBefore(image); bsw/jbe@1309: parent = image.parentNode; bsw/jbe@1309: parent.removeChild(image); bsw/jbe@1309: bsw/jbe@1309: // and it's parent too if it hasn't got any other relevant child nodes bsw/jbe@1309: wysihtml.dom.removeEmptyTextNodes(parent); bsw/jbe@1309: if (parent.nodeName === "A" && !parent.firstChild) { bsw/jbe@1309: composer.selection.setAfter(parent); bsw/jbe@1309: parent.parentNode.removeChild(parent); bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: // firefox and ie sometimes don't remove the image handles, even though the image got removed bsw/jbe@1309: wysihtml.quirks.redraw(composer.element); bsw/jbe@1309: return; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: // If image selected change attributes accordingly bsw/jbe@1309: if (image) { bsw/jbe@1309: for (var key in value) { bsw/jbe@1309: if (value.hasOwnProperty(key)) { bsw/jbe@1309: image.setAttribute(key === "className" ? "class" : key, value[key]); bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: return; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: // Otherwise lets create the image bsw/jbe@1309: image = doc.createElement(NODE_NAME); bsw/jbe@1309: bsw/jbe@1309: for (var i in value) { bsw/jbe@1309: image.setAttribute(i === "className" ? "class" : i, value[i]); bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: composer.selection.insertNode(image); bsw/jbe@1309: if (wysihtml.browser.hasProblemsSettingCaretAfterImg()) { bsw/jbe@1309: textNode = doc.createTextNode(wysihtml.INVISIBLE_SPACE); bsw/jbe@1309: composer.selection.insertNode(textNode); bsw/jbe@1309: composer.selection.setAfter(textNode); bsw/jbe@1309: } else { bsw/jbe@1309: composer.selection.setAfter(image); bsw/jbe@1309: } bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer) { bsw/jbe@1309: var doc = composer.doc, bsw/jbe@1309: selectedNode, bsw/jbe@1309: text, bsw/jbe@1309: imagesInSelection; bsw/jbe@1309: bsw/jbe@1309: if (!wysihtml.dom.hasElementWithTagName(doc, NODE_NAME)) { bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: selectedNode = composer.selection.getSelectedNode(); bsw/jbe@1309: if (!selectedNode) { bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: if (selectedNode.nodeName === NODE_NAME) { bsw/jbe@1309: // This works perfectly in IE bsw/jbe@1309: return selectedNode; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: if (selectedNode.nodeType !== wysihtml.ELEMENT_NODE) { bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: text = composer.selection.getText(); bsw/jbe@1309: text = wysihtml.lang.string(text).trim(); bsw/jbe@1309: if (text) { bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: imagesInSelection = composer.selection.getNodes(wysihtml.ELEMENT_NODE, function(node) { bsw/jbe@1309: return node.nodeName === "IMG"; bsw/jbe@1309: }); bsw/jbe@1309: bsw/jbe@1309: if (imagesInSelection.length !== 1) { bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: return imagesInSelection[0]; bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.fontSize = (function() { bsw/jbe@1309: var REG_EXP = /wysiwyg-font-size-[0-9a-z\-]+/g; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command, size) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, {className: "wysiwyg-font-size-" + size, classRegExp: REG_EXP, toggle: true}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command, size) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, {className: "wysiwyg-font-size-" + size}); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: /* Set font size by inline style */ bsw/jbe@1309: wysihtml.commands.fontSizeStyle = (function() { bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command, size) { bsw/jbe@1309: size = size.size || size; bsw/jbe@1309: if (!(/^\s*$/).test(size)) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, {styleProperty: "fontSize", styleValue: size, toggle: false}); bsw/jbe@1309: } bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command, size) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, {styleProperty: "fontSize", styleValue: size || undefined}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: remove: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.remove(composer, command, {styleProperty: "fontSize"}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: stateValue: function(composer, command) { bsw/jbe@1309: var styleStr, bsw/jbe@1309: st = this.state(composer, command); bsw/jbe@1309: bsw/jbe@1309: if (st && wysihtml.lang.object(st).isArray()) { bsw/jbe@1309: st = st[0]; bsw/jbe@1309: } bsw/jbe@1309: if (st) { bsw/jbe@1309: styleStr = st.getAttribute("style"); bsw/jbe@1309: if (styleStr) { bsw/jbe@1309: return wysihtml.quirks.styleParser.parseFontSize(styleStr); bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.foreColor = (function() { bsw/jbe@1309: var REG_EXP = /wysiwyg-color-[0-9a-z]+/g; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command, color) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, {className: "wysiwyg-color-" + color, classRegExp: REG_EXP, toggle: true}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command, color) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, {className: "wysiwyg-color-" + color}); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: /* Sets text color by inline styles */ bsw/jbe@1309: wysihtml.commands.foreColorStyle = (function() { bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command, color) { bsw/jbe@1309: var colorVals, colString; bsw/jbe@1309: bsw/jbe@1309: if (!color) { return; } bsw/jbe@1309: bsw/jbe@1309: colorVals = wysihtml.quirks.styleParser.parseColor("color:" + (color.color || color), "color"); bsw/jbe@1309: bsw/jbe@1309: if (colorVals) { bsw/jbe@1309: colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(", ") : "rgba(" + colorVals.join(', ')) + ')'; bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, {styleProperty: "color", styleValue: colString}); bsw/jbe@1309: } bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command, color) { bsw/jbe@1309: var colorVals = color ? wysihtml.quirks.styleParser.parseColor("color:" + (color.color || color), "color") : null, bsw/jbe@1309: colString; bsw/jbe@1309: bsw/jbe@1309: bsw/jbe@1309: if (colorVals) { bsw/jbe@1309: colString = (colorVals[3] === 1 ? "rgb(" + [colorVals[0], colorVals[1], colorVals[2]].join(", ") : "rgba(" + colorVals.join(', ')) + ')'; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, {styleProperty: "color", styleValue: colString}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: remove: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.remove(composer, command, {styleProperty: "color"}); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: stateValue: function(composer, command, props) { bsw/jbe@1309: var st = this.state(composer, command), bsw/jbe@1309: colorStr, bsw/jbe@1309: val = false; bsw/jbe@1309: bsw/jbe@1309: if (st && wysihtml.lang.object(st).isArray()) { bsw/jbe@1309: st = st[0]; bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: if (st) { bsw/jbe@1309: colorStr = st.getAttribute("style"); bsw/jbe@1309: if (colorStr) { bsw/jbe@1309: val = wysihtml.quirks.styleParser.parseColor(colorStr, "color"); bsw/jbe@1309: return wysihtml.quirks.styleParser.unparseColor(val, props); bsw/jbe@1309: } bsw/jbe@1309: } bsw/jbe@1309: return false; bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.insertBlockQuote = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: nodeName: "BLOCKQUOTE", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.insertHorizontalRule = (function() { bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer) { bsw/jbe@1309: var node = composer.selection.getSelectedNode(), bsw/jbe@1309: phrasingOnlyParent = wysihtml.dom.getParentElement(node, { query: wysihtml.PERMITTED_PHRASING_CONTENT_ONLY }, null, composer.editableArea), bsw/jbe@1309: elem = document.createElement('hr'), bsw/jbe@1309: range, idx; bsw/jbe@1309: bsw/jbe@1309: // HR is not allowed into some elements (where only phrasing content is allowed) bsw/jbe@1309: // thus the HR insertion must break out of those https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories bsw/jbe@1309: if (phrasingOnlyParent) { bsw/jbe@1309: composer.selection.splitElementAtCaret(phrasingOnlyParent, elem); bsw/jbe@1309: } else { bsw/jbe@1309: composer.selection.insertNode(elem); bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: if (elem.nextSibling) { bsw/jbe@1309: composer.selection.setBefore(elem.nextSibling); bsw/jbe@1309: } else { bsw/jbe@1309: composer.selection.setAfter(elem); bsw/jbe@1309: } bsw/jbe@1309: }, bsw/jbe@1309: state: function() { bsw/jbe@1309: return false; // :( bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.insertOrderedList = (function() { bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: wysihtml.commands.insertList.exec(composer, command, "OL"); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.insertList.state(composer, command, "OL"); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.insertUnorderedList = (function() { bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: wysihtml.commands.insertList.exec(composer, command, "UL"); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.insertList.state(composer, command, "UL"); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.italic = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: nodeName: "I", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.justifyCenter = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: className: "wysiwyg-text-align-center", bsw/jbe@1309: classRegExp: /wysiwyg-text-align-[0-9a-z]+/g, bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.justifyFull = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: className: "wysiwyg-text-align-justify", bsw/jbe@1309: classRegExp: /wysiwyg-text-align-[0-9a-z]+/g, bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.justifyLeft = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: className: "wysiwyg-text-align-left", bsw/jbe@1309: classRegExp: /wysiwyg-text-align-[0-9a-z]+/g, bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.justifyRight = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: className: "wysiwyg-text-align-right", bsw/jbe@1309: classRegExp: /wysiwyg-text-align-[0-9a-z]+/g, bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.exec(composer, "formatBlock", nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatBlock.state(composer, "formatBlock", nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.subscript = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: nodeName: "SUB", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.superscript = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: nodeName: "SUP", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: })(); bsw/jbe@1309: bsw/jbe@1309: wysihtml.commands.underline = (function() { bsw/jbe@1309: var nodeOptions = { bsw/jbe@1309: nodeName: "U", bsw/jbe@1309: toggle: true bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: return { bsw/jbe@1309: exec: function(composer, command) { bsw/jbe@1309: wysihtml.commands.formatInline.exec(composer, command, nodeOptions); bsw/jbe@1309: }, bsw/jbe@1309: bsw/jbe@1309: state: function(composer, command) { bsw/jbe@1309: return wysihtml.commands.formatInline.state(composer, command, nodeOptions); bsw/jbe@1309: } bsw/jbe@1309: }; bsw/jbe@1309: bsw/jbe@1309: })();