Mercurial Hosting > sceditor
changeset 0:4c4fc447baea
start with sceditor-3.1.1
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/README.md Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,138 @@ +# [SCEditor](http://www.sceditor.com/) v3.1.1 + +[![Build Status](https://github.com/samclarke/SCEditor/workflows/Node.js%20CI/badge.svg)](https://travis-ci.org/samclarke/SCEditor) +[![SemVer](http://img.shields.io/:semver-✓-brightgreen.svg)](http://semver.org) +[![License](http://img.shields.io/npm/l/sceditor.svg)](https://github.com/samclarke/SCEditor/blob/master/LICENSE.md) + +A lightweight WYSIWYG BBCode and XHTML editor. + +[![SCEditor preview](https://cdn.rawgit.com/samclarke/SCEditor/49c696b8/preview.svg)](https://www.sceditor.com/) + +For more information visit [sceditor.com](http://www.sceditor.com/) + + +## Usage + +Include the SCEditor JavaScript: + +```html +<link rel="stylesheet" href="minified/themes/default.min.css" /> +<script src="minified/sceditor.min.js"></script> +<script src="minified/formats/bbcode.js"></script> +<script src="minified/formats/xhtml.js"></script> +``` + +Then to convert a textarea into SCEditor, simply do: + +```js +var textarea = document.getElementById('id-of-textarea'); + +sceditor.create(textarea, { + format: 'xhtml', + style: 'minified/themes/content/default.min.css' +}); +``` + +or for a BBCode WYSIWYG editor do: + +```js +var textarea = document.getElementById('id-of-textarea'); + +sceditor.create(textarea, { + format: 'bbcode', + style: 'minified/themes/content/default.min.css' +}); +``` + +Finally, to get the contents of the editor: + +```js +var textarea = document.getElementById("id-of-textarea"); + +sceditor.instance(textarea).val(); +``` + + +## Options + +For a full list of options, see the [options documentation](http://www.sceditor.com/documentation/options/). + + + +## Building and testing + +You will need [Grunt](http://gruntjs.com/) installed to run the build/tests. To install Grunt run: + +```bash +npm install -g grunt-cli +``` + +Next, to install the SCEditor dev dependencies run: + +```bash +npm install +``` + +That's it! You can now build and test SCEditor with the following commands: + +```bash +# Minify the JS and convert the LESS to CSS +grunt build + +# Run the linter, unit tests and coverage +grunt test + +# Creates the final distributable ZIP file +grunt release +``` + +You can also run the dev server to test changes without having to do a full +build by running: + +```bash +npm run dev +``` + +and then going to http://localhost:9000/tests/ + + +## Contribute + +Any contributions and/or pull requests would be welcome. + +Themes, translations, bug reports, bug fixes and donations are greatly appreciated. + + + +## Donate + +If you would like to make a donation you can via +[PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AVJSF5NEETYYG) +or via [Flattr](http://flattr.com/thing/400345/SCEditor) + + + +## License + +SCEditor is licensed under the [MIT](/LICENSE.md) license: + + +Copyright (C) 2011 - 2017 Sam Clarke and contributors – sceditor.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +## Credits + +**Nomicons: The Full Monty Emoticons by:** +Oscar Gruno, aka Nominell v. 2.0 -> oscargruno@mac.com +Andy Fedosjeenko, aka Nightwolf -> bobo@animevanguard.com + +**Icons by:** +Mark James (http://www.famfamfam.com/lab/icons/silk/) +Licensed under the [Creative Commons CC-BY license](http://creativecommons.org/licenses/by/3.0/).
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/formats/bbcode.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,2686 @@ +/** + * SCEditor BBCode Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2011-2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor BBCode Format + * @author Sam Clarke + */ +(function (sceditor) { + /*eslint max-depth: off*/ + 'use strict'; + + var escapeEntities = sceditor.escapeEntities; + var escapeUriScheme = sceditor.escapeUriScheme; + var dom = sceditor.dom; + var utils = sceditor.utils; + + var css = dom.css; + var attr = dom.attr; + var is = dom.is; + var extend = utils.extend; + var each = utils.each; + + var EMOTICON_DATA_ATTR = 'data-sceditor-emoticon'; + + var getEditorCommand = sceditor.command.get; + + var QuoteType = { + /** @lends BBCodeParser.QuoteType */ + /** + * Always quote the attribute value + * @type {Number} + */ + always: 1, + + /** + * Never quote the attributes value + * @type {Number} + */ + never: 2, + + /** + * Only quote the attributes value when it contains spaces to equals + * @type {Number} + */ + auto: 3 + }; + + var defaultCommandsOverrides = { + bold: { + txtExec: ['[b]', '[/b]'] + }, + italic: { + txtExec: ['[i]', '[/i]'] + }, + underline: { + txtExec: ['[u]', '[/u]'] + }, + strike: { + txtExec: ['[s]', '[/s]'] + }, + subscript: { + txtExec: ['[sub]', '[/sub]'] + }, + superscript: { + txtExec: ['[sup]', '[/sup]'] + }, + left: { + txtExec: ['[left]', '[/left]'] + }, + center: { + txtExec: ['[center]', '[/center]'] + }, + right: { + txtExec: ['[right]', '[/right]'] + }, + justify: { + txtExec: ['[justify]', '[/justify]'] + }, + font: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('font')._dropDown( + editor, + caller, + function (fontName) { + editor.insertText( + '[font=' + fontName + ']', + '[/font]' + ); + } + ); + } + }, + size: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('size')._dropDown( + editor, + caller, + function (fontSize) { + editor.insertText( + '[size=' + fontSize + ']', + '[/size]' + ); + } + ); + } + }, + color: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('color')._dropDown( + editor, + caller, + function (color) { + editor.insertText( + '[color=' + color + ']', + '[/color]' + ); + } + ); + } + }, + bulletlist: { + txtExec: function (caller, selected) { + this.insertText( + '[ul]\n[li]' + + selected.split(/\r?\n/).join('[/li]\n[li]') + + '[/li]\n[/ul]' + ); + } + }, + orderedlist: { + txtExec: function (caller, selected) { + this.insertText( + '[ol]\n[li]' + + selected.split(/\r?\n/).join('[/li]\n[li]') + + '[/li]\n[/ol]' + ); + } + }, + table: { + txtExec: ['[table][tr][td]', '[/td][/tr][/table]'] + }, + horizontalrule: { + txtExec: ['[hr]'] + }, + code: { + txtExec: ['[code]', '[/code]'] + }, + image: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('image')._dropDown( + editor, + caller, + selected, + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width=' + width; + } + + if (height) { + attrs += ' height=' + height; + } + + editor.insertText( + '[img' + attrs + ']' + url + '[/img]' + ); + } + ); + } + }, + email: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('email')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '[email=' + url + ']' + + (text || selected || url) + + '[/email]' + ); + } + ); + } + }, + link: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('link')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '[url=' + url + ']' + + (text || selected || url) + + '[/url]' + ); + } + ); + } + }, + quote: { + txtExec: ['[quote]', '[/quote]'] + }, + youtube: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('youtube')._dropDown( + editor, + caller, + function (id) { + editor.insertText('[youtube]' + id + '[/youtube]'); + } + ); + } + }, + rtl: { + txtExec: ['[rtl]', '[/rtl]'] + }, + ltr: { + txtExec: ['[ltr]', '[/ltr]'] + } + }; + + var bbcodeHandlers = { + // START_COMMAND: Bold + b: { + tags: { + b: null, + strong: null + }, + styles: { + // 401 is for FF 3.5 + 'font-weight': ['bold', 'bolder', '401', '700', '800', '900'] + }, + format: '[b]{0}[/b]', + html: '<strong>{0}</strong>' + }, + // END_COMMAND + + // START_COMMAND: Italic + i: { + tags: { + i: null, + em: null + }, + styles: { + 'font-style': ['italic', 'oblique'] + }, + format: '[i]{0}[/i]', + html: '<em>{0}</em>' + }, + // END_COMMAND + + // START_COMMAND: Underline + u: { + tags: { + u: null + }, + styles: { + 'text-decoration': ['underline'] + }, + format: '[u]{0}[/u]', + html: '<u>{0}</u>' + }, + // END_COMMAND + + // START_COMMAND: Strikethrough + s: { + tags: { + s: null, + strike: null + }, + styles: { + 'text-decoration': ['line-through'] + }, + format: '[s]{0}[/s]', + html: '<s>{0}</s>' + }, + // END_COMMAND + + // START_COMMAND: Subscript + sub: { + tags: { + sub: null + }, + format: '[sub]{0}[/sub]', + html: '<sub>{0}</sub>' + }, + // END_COMMAND + + // START_COMMAND: Superscript + sup: { + tags: { + sup: null + }, + format: '[sup]{0}[/sup]', + html: '<sup>{0}</sup>' + }, + // END_COMMAND + + // START_COMMAND: Font + font: { + tags: { + font: { + face: null + } + }, + styles: { + 'font-family': null + }, + quoteType: QuoteType.never, + format: function (element, content) { + var font; + + if (!is(element, 'font') || !(font = attr(element, 'face'))) { + font = css(element, 'font-family'); + } + + return '[font=' + _stripQuotes(font) + ']' + + content + '[/font]'; + }, + html: '<font face="{defaultattr}">{0}</font>' + }, + // END_COMMAND + + // START_COMMAND: Size + size: { + tags: { + font: { + size: null + } + }, + styles: { + 'font-size': null + }, + format: function (element, content) { + var fontSize = attr(element, 'size'), + size = 2; + + if (!fontSize) { + fontSize = css(element, 'fontSize'); + } + + // Most browsers return px value but IE returns 1-7 + if (fontSize.indexOf('px') > -1) { + // convert size to an int + fontSize = fontSize.replace('px', '') - 0; + + if (fontSize < 12) { + size = 1; + } + if (fontSize > 15) { + size = 3; + } + if (fontSize > 17) { + size = 4; + } + if (fontSize > 23) { + size = 5; + } + if (fontSize > 31) { + size = 6; + } + if (fontSize > 47) { + size = 7; + } + } else { + size = fontSize; + } + + return '[size=' + size + ']' + content + '[/size]'; + }, + html: '<font size="{defaultattr}">{!0}</font>' + }, + // END_COMMAND + + // START_COMMAND: Color + color: { + tags: { + font: { + color: null + } + }, + styles: { + color: null + }, + quoteType: QuoteType.never, + format: function (elm, content) { + var color; + + if (!is(elm, 'font') || !(color = attr(elm, 'color'))) { + color = elm.style.color || css(elm, 'color'); + } + + return '[color=' + _normaliseColour(color) + ']' + + content + '[/color]'; + }, + html: function (token, attrs, content) { + return '<font color="' + + escapeEntities(_normaliseColour(attrs.defaultattr), true) + + '">' + content + '</font>'; + } + }, + // END_COMMAND + + // START_COMMAND: Lists + ul: { + tags: { + ul: null + }, + breakStart: true, + isInline: false, + skipLastLineBreak: true, + format: '[ul]{0}[/ul]', + html: '<ul>{0}</ul>' + }, + list: { + breakStart: true, + isInline: false, + skipLastLineBreak: true, + html: '<ul>{0}</ul>' + }, + ol: { + tags: { + ol: null + }, + breakStart: true, + isInline: false, + skipLastLineBreak: true, + format: '[ol]{0}[/ol]', + html: '<ol>{0}</ol>' + }, + li: { + tags: { + li: null + }, + isInline: false, + closedBy: ['/ul', '/ol', '/list', '*', 'li'], + format: '[li]{0}[/li]', + html: '<li>{0}</li>' + }, + '*': { + isInline: false, + closedBy: ['/ul', '/ol', '/list', '*', 'li'], + html: '<li>{0}</li>' + }, + // END_COMMAND + + // START_COMMAND: Table + table: { + tags: { + table: null + }, + isInline: false, + isHtmlInline: true, + skipLastLineBreak: true, + format: '[table]{0}[/table]', + html: '<table>{0}</table>' + }, + tr: { + tags: { + tr: null + }, + isInline: false, + skipLastLineBreak: true, + format: '[tr]{0}[/tr]', + html: '<tr>{0}</tr>' + }, + th: { + tags: { + th: null + }, + allowsEmpty: true, + isInline: false, + format: '[th]{0}[/th]', + html: '<th>{0}</th>' + }, + td: { + tags: { + td: null + }, + allowsEmpty: true, + isInline: false, + format: '[td]{0}[/td]', + html: '<td>{0}</td>' + }, + // END_COMMAND + + // START_COMMAND: Emoticons + emoticon: { + allowsEmpty: true, + tags: { + img: { + src: null, + 'data-sceditor-emoticon': null + } + }, + format: function (element, content) { + return attr(element, EMOTICON_DATA_ATTR) + content; + }, + html: '{0}' + }, + // END_COMMAND + + // START_COMMAND: Horizontal Rule + hr: { + tags: { + hr: null + }, + allowsEmpty: true, + isSelfClosing: true, + isInline: false, + format: '[hr]{0}', + html: '<hr />' + }, + // END_COMMAND + + // START_COMMAND: Image + img: { + allowsEmpty: true, + tags: { + img: { + src: null + } + }, + allowedChildren: ['#'], + quoteType: QuoteType.never, + format: function (element, content) { + var width, height, + attribs = '', + style = function (name) { + return element.style ? element.style[name] : null; + }; + + // check if this is an emoticon image + if (attr(element, EMOTICON_DATA_ATTR)) { + return content; + } + + width = attr(element, 'width') || style('width'); + height = attr(element, 'height') || style('height'); + + // only add width and height if one is specified + if ((element.complete && (width || height)) || + (width && height)) { + + attribs = '=' + dom.width(element) + 'x' + + dom.height(element); + } + + return '[img' + attribs + ']' + attr(element, 'src') + '[/img]'; + }, + html: function (token, attrs, content) { + var undef, width, height, match, + attribs = ''; + + // handle [img width=340 height=240]url[/img] + width = attrs.width; + height = attrs.height; + + // handle [img=340x240]url[/img] + if (attrs.defaultattr) { + match = attrs.defaultattr.split(/x/i); + + width = match[0]; + height = (match.length === 2 ? match[1] : match[0]); + } + + if (width !== undef) { + attribs += ' width="' + escapeEntities(width, true) + '"'; + } + + if (height !== undef) { + attribs += ' height="' + escapeEntities(height, true) + '"'; + } + + return '<img' + attribs + + ' src="' + escapeUriScheme(content) + '" />'; + } + }, + // END_COMMAND + + // START_COMMAND: URL + url: { + allowsEmpty: true, + tags: { + a: { + href: null + } + }, + quoteType: QuoteType.never, + format: function (element, content) { + var url = attr(element, 'href'); + + // make sure this link is not an e-mail, + // if it is return e-mail BBCode + if (url.substr(0, 7) === 'mailto:') { + return '[email="' + url.substr(7) + '"]' + + content + '[/email]'; + } + + return '[url=' + url + ']' + content + '[/url]'; + }, + html: function (token, attrs, content) { + attrs.defaultattr = + escapeEntities(attrs.defaultattr, true) || content; + + return '<a href="' + escapeUriScheme(attrs.defaultattr) + '">' + + content + '</a>'; + } + }, + // END_COMMAND + + // START_COMMAND: E-mail + email: { + quoteType: QuoteType.never, + html: function (token, attrs, content) { + return '<a href="mailto:' + + (escapeEntities(attrs.defaultattr, true) || content) + + '">' + content + '</a>'; + } + }, + // END_COMMAND + + // START_COMMAND: Quote + quote: { + tags: { + blockquote: null + }, + isInline: false, + quoteType: QuoteType.never, + format: function (element, content) { + var authorAttr = 'data-author'; + var author = ''; + var cite; + var children = element.children; + + for (var i = 0; !cite && i < children.length; i++) { + if (is(children[i], 'cite')) { + cite = children[i]; + } + } + + if (cite || attr(element, authorAttr)) { + author = cite && cite.textContent || + attr(element, authorAttr); + + attr(element, authorAttr, author); + + if (cite) { + element.removeChild(cite); + } + + content = this.elementToBbcode(element); + author = '=' + author.replace(/(^\s+|\s+$)/g, ''); + + if (cite) { + element.insertBefore(cite, element.firstChild); + } + } + + return '[quote' + author + ']' + content + '[/quote]'; + }, + html: function (token, attrs, content) { + if (attrs.defaultattr) { + content = '<cite>' + escapeEntities(attrs.defaultattr) + + '</cite>' + content; + } + + return '<blockquote>' + content + '</blockquote>'; + } + }, + // END_COMMAND + + // START_COMMAND: Code + code: { + tags: { + code: null + }, + isInline: false, + allowedChildren: ['#', '#newline'], + format: '[code]{0}[/code]', + html: '<code>{0}</code>' + }, + // END_COMMAND + + + // START_COMMAND: Left + left: { + styles: { + 'text-align': [ + 'left', + '-webkit-left', + '-moz-left', + '-khtml-left' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[left]{0}[/left]', + html: '<div align="left">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Centre + center: { + styles: { + 'text-align': [ + 'center', + '-webkit-center', + '-moz-center', + '-khtml-center' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[center]{0}[/center]', + html: '<div align="center">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Right + right: { + styles: { + 'text-align': [ + 'right', + '-webkit-right', + '-moz-right', + '-khtml-right' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[right]{0}[/right]', + html: '<div align="right">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Justify + justify: { + styles: { + 'text-align': [ + 'justify', + '-webkit-justify', + '-moz-justify', + '-khtml-justify' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[justify]{0}[/justify]', + html: '<div align="justify">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: YouTube + youtube: { + allowsEmpty: true, + tags: { + iframe: { + 'data-youtube-id': null + } + }, + format: function (element, content) { + element = attr(element, 'data-youtube-id'); + + return element ? '[youtube]' + element + '[/youtube]' : content; + }, + html: '<iframe width="560" height="315" frameborder="0" ' + + 'src="https://www.youtube-nocookie.com/embed/{0}?wmode=opaque" ' + + 'data-youtube-id="{0}" allowfullscreen></iframe>' + }, + // END_COMMAND + + + // START_COMMAND: Rtl + rtl: { + styles: { + direction: ['rtl'] + }, + isInline: false, + format: '[rtl]{0}[/rtl]', + html: '<div style="direction: rtl">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Ltr + ltr: { + styles: { + direction: ['ltr'] + }, + isInline: false, + format: '[ltr]{0}[/ltr]', + html: '<div style="direction: ltr">{0}</div>' + }, + // END_COMMAND + + // this is here so that commands above can be removed + // without having to remove the , after the last one. + // Needed for IE. + ignore: {} + }; + + /** + * Formats a string replacing {name} with the values of + * obj.name properties. + * + * If there is no property for the specified {name} then + * it will be left intact. + * + * @param {string} str + * @param {Object} obj + * @return {string} + * @since 2.0.0 + */ + function formatBBCodeString(str, obj) { + return str.replace(/\{([^}]+)\}/g, function (match, group) { + var undef, + escape = true; + + if (group.charAt(0) === '!') { + escape = false; + group = group.substring(1); + } + + if (group === '0') { + escape = false; + } + + if (obj[group] === undef) { + return match; + } + + return escape ? escapeEntities(obj[group], true) : obj[group]; + }); + } + + /** + * Removes the first and last divs from the HTML. + * + * This is needed for pasting + * @param {string} html + * @return {string} + * @private + */ + function removeFirstLastDiv(html) { + var node, next, removeDiv, + output = document.createElement('div'); + + removeDiv = function (node, isFirst) { + // Don't remove divs that have styling + if (dom.hasStyling(node)) { + return; + } + + if ((node.childNodes.length !== 1 || + !is(node.firstChild, 'br'))) { + while ((next = node.firstChild)) { + output.insertBefore(next, node); + } + } + + if (isFirst) { + var lastChild = output.lastChild; + + if (node !== lastChild && is(lastChild, 'div') && + node.nextSibling === lastChild) { + output.insertBefore(document.createElement('br'), node); + } + } + + output.removeChild(node); + }; + + css(output, 'display', 'none'); + output.innerHTML = html.replace(/<\/div>\n/g, '</div>'); + + if ((node = output.firstChild) && is(node, 'div')) { + removeDiv(node, true); + } + + if ((node = output.lastChild) && is(node, 'div')) { + removeDiv(node); + } + + return output.innerHTML; + } + + function isFunction(fn) { + return typeof fn === 'function'; + } + + /** + * Removes any leading or trailing quotes ('") + * + * @return string + * @since v1.4.0 + */ + function _stripQuotes(str) { + return str ? + str.replace(/\\(.)/g, '$1').replace(/^(["'])(.*?)\1$/, '$2') : str; + } + + /** + * Formats a string replacing {0}, {1}, {2}, ect. with + * the params provided + * + * @param {string} str The string to format + * @param {...string} arg The strings to replace + * @return {string} + * @since v1.4.0 + */ + function _formatString(str) { + var undef; + var args = arguments; + + return str.replace(/\{(\d+)\}/g, function (_, matchNum) { + return args[matchNum - 0 + 1] !== undef ? + args[matchNum - 0 + 1] : + '{' + matchNum + '}'; + }); + } + + var TOKEN_OPEN = 'open'; + var TOKEN_CONTENT = 'content'; + var TOKEN_NEWLINE = 'newline'; + var TOKEN_CLOSE = 'close'; + + + /* + * @typedef {Object} TokenizeToken + * @property {string} type + * @property {string} name + * @property {string} val + * @property {Object.<string, string>} attrs + * @property {array} children + * @property {TokenizeToken} closing + */ + + /** + * Tokenize token object + * + * @param {string} type The type of token this is, + * should be one of tokenType + * @param {string} name The name of this token + * @param {string} val The originally matched string + * @param {array} attrs Any attributes. Only set on + * TOKEN_TYPE_OPEN tokens + * @param {array} children Any children of this token + * @param {TokenizeToken} closing This tokens closing tag. + * Only set on TOKEN_TYPE_OPEN tokens + * @class {TokenizeToken} + * @name {TokenizeToken} + * @memberOf BBCodeParser.prototype + */ + // eslint-disable-next-line max-params + function TokenizeToken(type, name, val, attrs, children, closing) { + var base = this; + + base.type = type; + base.name = name; + base.val = val; + base.attrs = attrs || {}; + base.children = children || []; + base.closing = closing || null; + }; + + TokenizeToken.prototype = { + /** @lends BBCodeParser.prototype.TokenizeToken */ + /** + * Clones this token + * + * @return {TokenizeToken} + */ + clone: function () { + var base = this; + + return new TokenizeToken( + base.type, + base.name, + base.val, + extend({}, base.attrs), + [], + base.closing ? base.closing.clone() : null + ); + }, + /** + * Splits this token at the specified child + * + * @param {TokenizeToken} splitAt The child to split at + * @return {TokenizeToken} The right half of the split token or + * empty clone if invalid splitAt lcoation + */ + splitAt: function (splitAt) { + var offsetLength; + var base = this; + var clone = base.clone(); + var offset = base.children.indexOf(splitAt); + + if (offset > -1) { + // Work out how many items are on the right side of the split + // to pass to splice() + offsetLength = base.children.length - offset; + clone.children = base.children.splice(offset, offsetLength); + } + + return clone; + } + }; + + + /** + * SCEditor BBCode parser class + * + * @param {Object} options + * @class BBCodeParser + * @name BBCodeParser + * @since v1.4.0 + */ + function BBCodeParser(options) { + var base = this; + + base.opts = extend({}, BBCodeParser.defaults, options); + + /** + * Takes a BBCode string and splits it into open, + * content and close tags. + * + * It does no checking to verify a tag has a matching open + * or closing tag or if the tag is valid child of any tag + * before it. For that the tokens should be passed to the + * parse function. + * + * @param {string} str + * @return {array} + * @memberOf BBCodeParser.prototype + */ + base.tokenize = function (str) { + var matches, type, i; + var tokens = []; + // The token types in reverse order of precedence + // (they're looped in reverse) + var tokenTypes = [ + { + type: TOKEN_CONTENT, + regex: /^([^\[\r\n]+|\[)/ + }, + { + type: TOKEN_NEWLINE, + regex: /^(\r\n|\r|\n)/ + }, + { + type: TOKEN_OPEN, + regex: /^\[[^\[\]]+\]/ + }, + // Close must come before open as they are + // the same except close has a / at the start. + { + type: TOKEN_CLOSE, + regex: /^\[\/[^\[\]]+\]/ + } + ]; + + strloop: + while (str.length) { + i = tokenTypes.length; + while (i--) { + type = tokenTypes[i].type; + + // Check if the string matches any of the tokens + if (!(matches = str.match(tokenTypes[i].regex)) || + !matches[0]) { + continue; + } + + // Add the match to the tokens list + tokens.push(tokenizeTag(type, matches[0])); + + // Remove the match from the string + str = str.substr(matches[0].length); + + // The token has been added so start again + continue strloop; + } + + // If there is anything left in the string which doesn't match + // any of the tokens then just assume it's content and add it. + if (str.length) { + tokens.push(tokenizeTag(TOKEN_CONTENT, str)); + } + + str = ''; + } + + return tokens; + }; + + /** + * Extracts the name an params from a tag + * + * @param {string} type + * @param {string} val + * @return {Object} + * @private + */ + function tokenizeTag(type, val) { + var matches, attrs, name, + openRegex = /\[([^\]\s=]+)(?:([^\]]+))?\]/, + closeRegex = /\[\/([^\[\]]+)\]/; + + // Extract the name and attributes from opening tags and + // just the name from closing tags. + if (type === TOKEN_OPEN && (matches = val.match(openRegex))) { + name = lower(matches[1]); + + if (matches[2] && (matches[2] = matches[2].trim())) { + attrs = tokenizeAttrs(matches[2]); + } + } + + if (type === TOKEN_CLOSE && + (matches = val.match(closeRegex))) { + name = lower(matches[1]); + } + + if (type === TOKEN_NEWLINE) { + name = '#newline'; + } + + // Treat all tokens without a name and + // all unknown BBCodes as content + if (!name || ((type === TOKEN_OPEN || type === TOKEN_CLOSE) && + !bbcodeHandlers[name])) { + + type = TOKEN_CONTENT; + name = '#'; + } + + return new TokenizeToken(type, name, val, attrs); + } + + /** + * Extracts the individual attributes from a string containing + * all the attributes. + * + * @param {string} attrs + * @return {Object} Assoc array of attributes + * @private + */ + function tokenizeAttrs(attrs) { + var matches, + /* + ([^\s=]+) Anything that's not a space or equals + = Equals sign = + (?: + (?: + (["']) The opening quote + ( + (?:\\\2|[^\2])*? Anything that isn't the + unescaped opening quote + ) + \2 The opening quote again which + will close the string + ) + | If not a quoted string then match + ( + (?:.(?!\s\S+=))*.? Anything that isn't part of + [space][non-space][=] which + would be a new attribute + ) + ) + */ + attrRegex = /([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g, + ret = {}; + + // if only one attribute then remove the = from the start and + // strip any quotes + if (attrs.charAt(0) === '=' && attrs.indexOf('=', 1) < 0) { + ret.defaultattr = _stripQuotes(attrs.substr(1)); + } else { + if (attrs.charAt(0) === '=') { + attrs = 'defaultattr' + attrs; + } + + // No need to strip quotes here, the regex will do that. + while ((matches = attrRegex.exec(attrs))) { + ret[lower(matches[1])] = + _stripQuotes(matches[3]) || matches[4]; + } + } + + return ret; + } + + /** + * Parses a string into an array of BBCodes + * + * @param {string} str + * @param {boolean} preserveNewLines If to preserve all new lines, not + * strip any based on the passed + * formatting options + * @return {array} Array of BBCode objects + * @memberOf BBCodeParser.prototype + */ + base.parse = function (str, preserveNewLines) { + var ret = parseTokens(base.tokenize(str)); + var opts = base.opts; + + if (opts.fixInvalidNesting) { + fixNesting(ret); + } + + normaliseNewLines(ret, null, preserveNewLines); + + if (opts.removeEmptyTags) { + removeEmpty(ret); + } + + return ret; + }; + + /** + * Checks if an array of TokenizeToken's contains the + * specified token. + * + * Checks the tokens name and type match another tokens + * name and type in the array. + * + * @param {string} name + * @param {string} type + * @param {array} arr + * @return {Boolean} + * @private + */ + function hasTag(name, type, arr) { + var i = arr.length; + + while (i--) { + if (arr[i].type === type && arr[i].name === name) { + return true; + } + } + + return false; + } + + /** + * Checks if the child tag is allowed as one + * of the parent tags children. + * + * @param {TokenizeToken} parent + * @param {TokenizeToken} child + * @return {Boolean} + * @private + */ + function isChildAllowed(parent, child) { + var parentBBCode = parent ? bbcodeHandlers[parent.name] : {}, + allowedChildren = parentBBCode.allowedChildren; + + if (base.opts.fixInvalidChildren && allowedChildren) { + return allowedChildren.indexOf(child.name || '#') > -1; + } + + return true; + } + + // TODO: Tidy this parseTokens() function up a bit. + /** + * Parses an array of tokens created by tokenize() + * + * @param {array} toks + * @return {array} Parsed tokens + * @see tokenize() + * @private + */ + function parseTokens(toks) { + var token, bbcode, curTok, clone, i, next, + cloned = [], + output = [], + openTags = [], + /** + * Returns the currently open tag or undefined + * @return {TokenizeToken} + */ + currentTag = function () { + return last(openTags); + }, + /** + * Adds a tag to either the current tags children + * or to the output array. + * @param {TokenizeToken} token + * @private + */ + addTag = function (token) { + if (currentTag()) { + currentTag().children.push(token); + } else { + output.push(token); + } + }, + /** + * Checks if this tag closes the current tag + * @param {string} name + * @return {Void} + */ + closesCurrentTag = function (name) { + return currentTag() && + (bbcode = bbcodeHandlers[currentTag().name]) && + bbcode.closedBy && + bbcode.closedBy.indexOf(name) > -1; + }; + + while ((token = toks.shift())) { + next = toks[0]; + + /* + * Fixes any invalid children. + * + * If it is an element which isn't allowed as a child of it's + * parent then it will be converted to content of the parent + * element. i.e. + * [code]Code [b]only[/b] allows text.[/code] + * Will become: + * <code>Code [b]only[/b] allows text.</code> + * Instead of: + * <code>Code <b>only</b> allows text.</code> + */ + // Ignore tags that can't be children + if (!isChildAllowed(currentTag(), token)) { + + // exclude closing tags of current tag + if (token.type !== TOKEN_CLOSE || !currentTag() || + token.name !== currentTag().name) { + token.name = '#'; + token.type = TOKEN_CONTENT; + } + } + + switch (token.type) { + case TOKEN_OPEN: + // Check it this closes a parent, + // e.g. for lists [*]one [*]two + if (closesCurrentTag(token.name)) { + openTags.pop(); + } + + addTag(token); + bbcode = bbcodeHandlers[token.name]; + + // If this tag is not self closing and it has a closing + // tag then it is open and has children so add it to the + // list of open tags. If has the closedBy property then + // it is closed by other tags so include everything as + // it's children until one of those tags is reached. + if (bbcode && !bbcode.isSelfClosing && + (bbcode.closedBy || + hasTag(token.name, TOKEN_CLOSE, toks))) { + openTags.push(token); + } else if (!bbcode || !bbcode.isSelfClosing) { + token.type = TOKEN_CONTENT; + } + break; + + case TOKEN_CLOSE: + // check if this closes the current tag, + // e.g. [/list] would close an open [*] + if (currentTag() && token.name !== currentTag().name && + closesCurrentTag('/' + token.name)) { + + openTags.pop(); + } + + // If this is closing the currently open tag just pop + // the close tag off the open tags array + if (currentTag() && token.name === currentTag().name) { + currentTag().closing = token; + openTags.pop(); + + // If this is closing an open tag that is the parent of + // the current tag then clone all the tags including the + // current one until reaching the parent that is being + // closed. Close the parent and then add the clones back + // in. + } else if (hasTag(token.name, TOKEN_OPEN, openTags)) { + + // Remove the tag from the open tags + while ((curTok = openTags.pop())) { + + // If it's the tag that is being closed then + // discard it and break the loop. + if (curTok.name === token.name) { + curTok.closing = token; + break; + } + + // Otherwise clone this tag and then add any + // previously cloned tags as it's children + clone = curTok.clone(); + + if (cloned.length) { + clone.children.push(last(cloned)); + } + + cloned.push(clone); + } + + // Place block linebreak before cloned tags + if (next && next.type === TOKEN_NEWLINE) { + bbcode = bbcodeHandlers[token.name]; + if (bbcode && bbcode.isInline === false) { + addTag(next); + toks.shift(); + } + } + + // Add the last cloned child to the now current tag + // (the parent of the tag which was being closed) + addTag(last(cloned)); + + // Add all the cloned tags to the open tags list + i = cloned.length; + while (i--) { + openTags.push(cloned[i]); + } + + cloned.length = 0; + + // This tag is closing nothing so treat it as content + } else { + token.type = TOKEN_CONTENT; + addTag(token); + } + break; + + case TOKEN_NEWLINE: + // handle things like + // [*]list\nitem\n[*]list1 + // where it should come out as + // [*]list\nitem[/*]\n[*]list1[/*] + // instead of + // [*]list\nitem\n[/*][*]list1[/*] + if (currentTag() && next && closesCurrentTag( + (next.type === TOKEN_CLOSE ? '/' : '') + + next.name + )) { + // skip if the next tag is the closing tag for + // the option tag, i.e. [/*] + if (!(next.type === TOKEN_CLOSE && + next.name === currentTag().name)) { + bbcode = bbcodeHandlers[currentTag().name]; + + if (bbcode && bbcode.breakAfter) { + openTags.pop(); + } else if (bbcode && + bbcode.isInline === false && + base.opts.breakAfterBlock && + bbcode.breakAfter !== false) { + openTags.pop(); + } + } + } + + addTag(token); + break; + + default: // content + addTag(token); + break; + } + } + + return output; + } + + /** + * Normalise all new lines + * + * Removes any formatting new lines from the BBCode + * leaving only content ones. I.e. for a list: + * + * [list] + * [*] list item one + * with a line break + * [*] list item two + * [/list] + * + * would become + * + * [list] [*] list item one + * with a line break [*] list item two [/list] + * + * Which makes it easier to convert to HTML or add + * the formatting new lines back in when converting + * back to BBCode + * + * @param {array} children + * @param {TokenizeToken} parent + * @param {boolean} onlyRemoveBreakAfter + * @return {void} + */ + function normaliseNewLines(children, parent, onlyRemoveBreakAfter) { + var token, left, right, parentBBCode, bbcode, + removedBreakEnd, removedBreakBefore, remove; + var childrenLength = children.length; + // TODO: this function really needs tidying up + if (parent) { + parentBBCode = bbcodeHandlers[parent.name]; + } + + var i = childrenLength; + while (i--) { + if (!(token = children[i])) { + continue; + } + + if (token.type === TOKEN_NEWLINE) { + left = i > 0 ? children[i - 1] : null; + right = i < childrenLength - 1 ? children[i + 1] : null; + remove = false; + + // Handle the start and end new lines + // e.g. [tag]\n and \n[/tag] + if (!onlyRemoveBreakAfter && parentBBCode && + parentBBCode.isSelfClosing !== true) { + // First child of parent so must be opening line break + // (breakStartBlock, breakStart) e.g. [tag]\n + if (!left) { + if (parentBBCode.isInline === false && + base.opts.breakStartBlock && + parentBBCode.breakStart !== false) { + remove = true; + } + + if (parentBBCode.breakStart) { + remove = true; + } + // Last child of parent so must be end line break + // (breakEndBlock, breakEnd) + // e.g. \n[/tag] + // remove last line break (breakEndBlock, breakEnd) + } else if (!removedBreakEnd && !right) { + if (parentBBCode.isInline === false && + base.opts.breakEndBlock && + parentBBCode.breakEnd !== false) { + remove = true; + } + + if (parentBBCode.breakEnd) { + remove = true; + } + + removedBreakEnd = remove; + } + } + + if (left && left.type === TOKEN_OPEN) { + if ((bbcode = bbcodeHandlers[left.name])) { + if (!onlyRemoveBreakAfter) { + if (bbcode.isInline === false && + base.opts.breakAfterBlock && + bbcode.breakAfter !== false) { + remove = true; + } + + if (bbcode.breakAfter) { + remove = true; + } + } else if (bbcode.isInline === false) { + remove = true; + } + } + } + + if (!onlyRemoveBreakAfter && !removedBreakBefore && + right && right.type === TOKEN_OPEN) { + + if ((bbcode = bbcodeHandlers[right.name])) { + if (bbcode.isInline === false && + base.opts.breakBeforeBlock && + bbcode.breakBefore !== false) { + remove = true; + } + + if (bbcode.breakBefore) { + remove = true; + } + + removedBreakBefore = remove; + + if (remove) { + children.splice(i, 1); + continue; + } + } + } + + if (remove) { + children.splice(i, 1); + } + + // reset double removedBreakBefore removal protection. + // This is needed for cases like \n\n[\tag] where + // only 1 \n should be removed but without this they both + // would be. + removedBreakBefore = false; + } else if (token.type === TOKEN_OPEN) { + normaliseNewLines(token.children, token, + onlyRemoveBreakAfter); + } + } + } + + /** + * Fixes any invalid nesting. + * + * If it is a block level element inside 1 or more inline elements + * then those inline elements will be split at the point where the + * block level is and the block level element placed between the split + * parts. i.e. + * [inline]A[blocklevel]B[/blocklevel]C[/inline] + * Will become: + * [inline]A[/inline][blocklevel]B[/blocklevel][inline]C[/inline] + * + * @param {array} children + * @param {array} [parents] Null if there is no parents + * @param {boolea} [insideInline] If inside an inline element + * @param {array} [rootArr] Root array if there is one + * @return {array} + * @private + */ + function fixNesting(children, parents, insideInline, rootArr) { + var token, i, parent, parentIndex, parentParentChildren, right; + + var isInline = function (token) { + var bbcode = bbcodeHandlers[token.name]; + + return !bbcode || bbcode.isInline !== false; + }; + + parents = parents || []; + rootArr = rootArr || children; + + // This must check the length each time as it can change when + // tokens are moved to fix the nesting. + for (i = 0; i < children.length; i++) { + if (!(token = children[i]) || token.type !== TOKEN_OPEN) { + continue; + } + + if (insideInline && !isInline(token)) { + // if this is a blocklevel element inside an inline one then + // split the parent at the block level element + parent = last(parents); + right = parent.splitAt(token); + + parentParentChildren = parents.length > 1 ? + parents[parents.length - 2].children : rootArr; + + // If parent inline is allowed inside this tag, clone it and + // wrap this tags children in it. + if (isChildAllowed(token, parent)) { + var clone = parent.clone(); + clone.children = token.children; + token.children = [clone]; + } + + parentIndex = parentParentChildren.indexOf(parent); + if (parentIndex > -1) { + // remove the block level token from the right side of + // the split inline element + right.children.splice(0, 1); + + // insert the block level token and the right side after + // the left side of the inline token + parentParentChildren.splice( + parentIndex + 1, 0, token, right + ); + + // If token is a block and is followed by a newline, + // then move the newline along with it to the new parent + var next = right.children[0]; + if (next && next.type === TOKEN_NEWLINE) { + if (!isInline(token)) { + right.children.splice(0, 1); + parentParentChildren.splice( + parentIndex + 2, 0, next + ); + } + } + + // return to parents loop as the + // children have now increased + return; + } + + } + + parents.push(token); + + fixNesting( + token.children, + parents, + insideInline || isInline(token), + rootArr + ); + + parents.pop(); + } + } + + /** + * Removes any empty BBCodes which are not allowed to be empty. + * + * @param {array} tokens + * @private + */ + function removeEmpty(tokens) { + var token, bbcode; + + /** + * Checks if all children are whitespace or not + * @private + */ + var isTokenWhiteSpace = function (children) { + var j = children.length; + + while (j--) { + var type = children[j].type; + + if (type === TOKEN_OPEN || type === TOKEN_CLOSE) { + return false; + } + + if (type === TOKEN_CONTENT && + /\S|\u00A0/.test(children[j].val)) { + return false; + } + } + + return true; + }; + + var i = tokens.length; + while (i--) { + // So skip anything that isn't a tag since only tags can be + // empty, content can't + if (!(token = tokens[i]) || token.type !== TOKEN_OPEN) { + continue; + } + + bbcode = bbcodeHandlers[token.name]; + + // Remove any empty children of this tag first so that if they + // are all removed this one doesn't think it's not empty. + removeEmpty(token.children); + + if (isTokenWhiteSpace(token.children) && bbcode && + !bbcode.isSelfClosing && !bbcode.allowsEmpty) { + tokens.splice.apply(tokens, [i, 1].concat(token.children)); + } + } + } + + /** + * Converts a BBCode string to HTML + * + * @param {string} str + * @param {boolean} preserveNewLines If to preserve all new lines, not + * strip any based on the passed + * formatting options + * @return {string} + * @memberOf BBCodeParser.prototype + */ + base.toHTML = function (str, preserveNewLines) { + return convertToHTML(base.parse(str, preserveNewLines), true); + }; + + /** + * @private + */ + function convertToHTML(tokens, isRoot) { + var undef, token, bbcode, content, html, needsBlockWrap, + blockWrapOpen, isInline, lastChild, + ret = ''; + + isInline = function (bbcode) { + return (!bbcode || (bbcode.isHtmlInline !== undef ? + bbcode.isHtmlInline : bbcode.isInline)) !== false; + }; + + while (tokens.length > 0) { + if (!(token = tokens.shift())) { + continue; + } + + if (token.type === TOKEN_OPEN) { + lastChild = token.children[token.children.length - 1] || {}; + bbcode = bbcodeHandlers[token.name]; + needsBlockWrap = isRoot && isInline(bbcode); + content = convertToHTML(token.children, false); + + if (bbcode && bbcode.html) { + // Only add a line break to the end if this is + // blocklevel and the last child wasn't block-level + if (!isInline(bbcode) && + isInline(bbcodeHandlers[lastChild.name]) && + !bbcode.isPreFormatted && + !bbcode.skipLastLineBreak) { + // Add placeholder br to end of block level + // elements + content += '<br />'; + } + + if (!isFunction(bbcode.html)) { + token.attrs['0'] = content; + html = formatBBCodeString( + bbcode.html, + token.attrs + ); + } else { + html = bbcode.html.call( + base, + token, + token.attrs, + content + ); + } + } else { + html = token.val + content + + (token.closing ? token.closing.val : ''); + } + } else if (token.type === TOKEN_NEWLINE) { + if (!isRoot) { + ret += '<br />'; + continue; + } + + // If not already in a block wrap then start a new block + if (!blockWrapOpen) { + ret += '<div>'; + } + + ret += '<br />'; + + // Normally the div acts as a line-break with by moving + // whatever comes after onto a new line. + // If this is the last token, add an extra line-break so it + // shows as there will be nothing after it. + if (!tokens.length) { + ret += '<br />'; + } + + ret += '</div>\n'; + blockWrapOpen = false; + continue; + // content + } else { + needsBlockWrap = isRoot; + html = escapeEntities(token.val, true); + } + + if (needsBlockWrap && !blockWrapOpen) { + ret += '<div>'; + blockWrapOpen = true; + } else if (!needsBlockWrap && blockWrapOpen) { + ret += '</div>\n'; + blockWrapOpen = false; + } + + ret += html; + } + + if (blockWrapOpen) { + ret += '</div>\n'; + } + + return ret; + } + + /** + * Takes a BBCode string, parses it then converts it back to BBCode. + * + * This will auto fix the BBCode and format it with the specified + * options. + * + * @param {string} str + * @param {boolean} preserveNewLines If to preserve all new lines, not + * strip any based on the passed + * formatting options + * @return {string} + * @memberOf BBCodeParser.prototype + */ + base.toBBCode = function (str, preserveNewLines) { + return convertToBBCode(base.parse(str, preserveNewLines)); + }; + + /** + * Converts parsed tokens back into BBCode with the + * formatting specified in the options and with any + * fixes specified. + * + * @param {array} toks Array of parsed tokens from base.parse() + * @return {string} + * @private + */ + function convertToBBCode(toks) { + var token, attr, bbcode, isBlock, isSelfClosing, quoteType, + breakBefore, breakStart, breakEnd, breakAfter, + ret = ''; + + while (toks.length > 0) { + if (!(token = toks.shift())) { + continue; + } + // TODO: tidy this + bbcode = bbcodeHandlers[token.name]; + isBlock = !(!bbcode || bbcode.isInline !== false); + isSelfClosing = bbcode && bbcode.isSelfClosing; + + breakBefore = (isBlock && base.opts.breakBeforeBlock && + bbcode.breakBefore !== false) || + (bbcode && bbcode.breakBefore); + + breakStart = (isBlock && !isSelfClosing && + base.opts.breakStartBlock && + bbcode.breakStart !== false) || + (bbcode && bbcode.breakStart); + + breakEnd = (isBlock && base.opts.breakEndBlock && + bbcode.breakEnd !== false) || + (bbcode && bbcode.breakEnd); + + breakAfter = (isBlock && base.opts.breakAfterBlock && + bbcode.breakAfter !== false) || + (bbcode && bbcode.breakAfter); + + quoteType = (bbcode ? bbcode.quoteType : null) || + base.opts.quoteType || QuoteType.auto; + + if (!bbcode && token.type === TOKEN_OPEN) { + ret += token.val; + + if (token.children) { + ret += convertToBBCode(token.children); + } + + if (token.closing) { + ret += token.closing.val; + } + } else if (token.type === TOKEN_OPEN) { + if (breakBefore) { + ret += '\n'; + } + + // Convert the tag and it's attributes to BBCode + ret += '[' + token.name; + if (token.attrs) { + if (token.attrs.defaultattr) { + ret += '=' + quote( + token.attrs.defaultattr, + quoteType, + 'defaultattr' + ); + + delete token.attrs.defaultattr; + } + + for (attr in token.attrs) { + if (token.attrs.hasOwnProperty(attr)) { + ret += ' ' + attr + '=' + + quote(token.attrs[attr], quoteType, attr); + } + } + } + ret += ']'; + + if (breakStart) { + ret += '\n'; + } + + // Convert the tags children to BBCode + if (token.children) { + ret += convertToBBCode(token.children); + } + + // add closing tag if not self closing + if (!isSelfClosing && !bbcode.excludeClosing) { + if (breakEnd) { + ret += '\n'; + } + + ret += '[/' + token.name + ']'; + } + + if (breakAfter) { + ret += '\n'; + } + + // preserve whatever was recognized as the + // closing tag if it is a self closing tag + if (token.closing && isSelfClosing) { + ret += token.closing.val; + } + } else { + ret += token.val; + } + } + + return ret; + } + + /** + * Quotes an attribute + * + * @param {string} str + * @param {BBCodeParser.QuoteType} quoteType + * @param {string} name + * @return {string} + * @private + */ + function quote(str, quoteType, name) { + var needsQuotes = /\s|=/.test(str); + + if (isFunction(quoteType)) { + return quoteType(str, name); + } + + if (quoteType === QuoteType.never || + (quoteType === QuoteType.auto && !needsQuotes)) { + return str; + } + + return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"'; + } + + /** + * Returns the last element of an array or null + * + * @param {array} arr + * @return {Object} Last element + * @private + */ + function last(arr) { + if (arr.length) { + return arr[arr.length - 1]; + } + + return null; + } + + /** + * Converts a string to lowercase. + * + * @param {string} str + * @return {string} Lowercase version of str + * @private + */ + function lower(str) { + return str.toLowerCase(); + } + }; + + /** + * Quote type + * @type {Object} + * @class QuoteType + * @name BBCodeParser.QuoteType + * @since 1.4.0 + */ + BBCodeParser.QuoteType = QuoteType; + + /** + * Default BBCode parser options + * @type {Object} + */ + BBCodeParser.defaults = { + /** + * If to add a new line before block level elements + * + * @type {Boolean} + */ + breakBeforeBlock: false, + + /** + * If to add a new line after the start of block level elements + * + * @type {Boolean} + */ + breakStartBlock: false, + + /** + * If to add a new line before the end of block level elements + * + * @type {Boolean} + */ + breakEndBlock: false, + + /** + * If to add a new line after block level elements + * + * @type {Boolean} + */ + breakAfterBlock: true, + + /** + * If to remove empty tags + * + * @type {Boolean} + */ + removeEmptyTags: true, + + /** + * If to fix invalid nesting, + * i.e. block level elements inside inline elements. + * + * @type {Boolean} + */ + fixInvalidNesting: true, + + /** + * If to fix invalid children. + * i.e. A tag which is inside a parent that doesn't + * allow that type of tag. + * + * @type {Boolean} + */ + fixInvalidChildren: true, + + /** + * Attribute quote type + * + * @type {BBCodeParser.QuoteType} + * @since 1.4.1 + */ + quoteType: QuoteType.auto, + + /** + * Whether to use strict matching on attributes and styles. + * + * When true this will perform AND matching requiring all tag + * attributes and styles to match. + * + * When false will perform OR matching and will match if any of + * a tags attributes or styles match. + * + * @type {Boolean} + * @since 3.1.0 + */ + strictMatch: false + }; + + /** + * Converts a number 0-255 to hex. + * + * Will return 00 if number is not a valid number. + * + * @param {any} number + * @return {string} + * @private + */ + function toHex(number) { + number = parseInt(number, 10); + + if (isNaN(number)) { + return '00'; + } + + number = Math.max(0, Math.min(number, 255)).toString(16); + + return number.length < 2 ? '0' + number : number; + } + /** + * Normalises a CSS colour to hex #xxxxxx format + * + * @param {string} colorStr + * @return {string} + * @private + */ + function _normaliseColour(colorStr) { + var match; + + colorStr = colorStr || '#000'; + + // rgb(n,n,n); + if ((match = + colorStr.match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))) { + return '#' + + toHex(match[1]) + + toHex(match[2]) + + toHex(match[3]); + } + + // expand shorthand + if ((match = colorStr.match(/#([0-f])([0-f])([0-f])\s*?$/i))) { + return '#' + + match[1] + match[1] + + match[2] + match[2] + + match[3] + match[3]; + } + + return colorStr; + } + + /** + * SCEditor BBCode format + * @since 2.0.0 + */ + function bbcodeFormat() { + var base = this; + + base.stripQuotes = _stripQuotes; + + /** + * cache of all the tags pointing to their bbcodes to enable + * faster lookup of which bbcode a tag should have + * @private + */ + var tagsToBBCodes = {}; + + /** + * Allowed children of specific HTML tags. Empty array if no + * children other than text nodes are allowed + * @private + */ + var validChildren = { + ul: ['li', 'ol', 'ul'], + ol: ['li', 'ol', 'ul'], + table: ['tr'], + tr: ['td', 'th'], + code: ['br', 'p', 'div'] + }; + + /** + * Populates tagsToBBCodes and stylesToBBCodes for easier lookups + * + * @private + */ + function buildBbcodeCache() { + each(bbcodeHandlers, function (bbcode, handler) { + var + isBlock = handler.isInline === false, + tags = bbcodeHandlers[bbcode].tags, + styles = bbcodeHandlers[bbcode].styles; + + if (styles) { + tagsToBBCodes['*'] = tagsToBBCodes['*'] || {}; + tagsToBBCodes['*'][isBlock] = + tagsToBBCodes['*'][isBlock] || {}; + tagsToBBCodes['*'][isBlock][bbcode] = [ + ['style', Object.entries(styles)] + ]; + } + + if (tags) { + each(tags, function (tag, values) { + if (values && values.style) { + values.style = Object.entries(values.style); + } + + tagsToBBCodes[tag] = tagsToBBCodes[tag] || {}; + tagsToBBCodes[tag][isBlock] = + tagsToBBCodes[tag][isBlock] || {}; + tagsToBBCodes[tag][isBlock][bbcode] = + values && Object.entries(values); + }); + } + }); + }; + + /** + * Handles adding newlines after block level elements + * + * @param {HTMLElement} element The element to convert + * @param {string} content The tags text content + * @return {string} + * @private + */ + function handleBlockNewlines(element, content) { + var tag = element.nodeName.toLowerCase(); + var isInline = dom.isInline; + if (!isInline(element, true) || tag === 'br') { + var isLastBlockChild, parent, parentLastChild, + previousSibling = element.previousSibling; + + // Skips selection makers and ignored elements + // Skip empty inline elements + while (previousSibling && + previousSibling.nodeType === 1 && + !is(previousSibling, 'br') && + isInline(previousSibling, true) && + !previousSibling.firstChild) { + previousSibling = previousSibling.previousSibling; + } + + // If it's the last block of an inline that is the last + // child of a block then it shouldn't cause a line break + // <block><inline><br></inline></block> + do { + parent = element.parentNode; + parentLastChild = parent && parent.lastChild; + + isLastBlockChild = parentLastChild === element; + element = parent; + } while (parent && isLastBlockChild && isInline(parent, true)); + + // If this block is: + // * Not the last child of a block level element + // * Is a <li> tag (lists are blocks) + if (!isLastBlockChild || tag === 'li') { + content += '\n'; + } + + // Check for: + // <block>text<block>text</block></block> + // + // The second opening <block> opening tag should cause a + // line break because the previous sibing is inline. + if (tag !== 'br' && previousSibling && + !is(previousSibling, 'br') && + isInline(previousSibling, true)) { + content = '\n' + content; + } + } + + return content; + } + + /** + * Handles a HTML tag and finds any matching BBCodes + * + * @param {HTMLElement} element The element to convert + * @param {string} content The Tags text content + * @param {boolean} blockLevel + * @return {string} Content with any matching BBCode tags + * wrapped around it. + * @private + */ + function handleTags(element, content, blockLevel) { + function isStyleMatch(style) { + var property = style[0]; + var values = style[1]; + var val = dom.getStyle(element, property); + var parent = element.parentNode; + + // if the parent has the same style use that instead of this one + // so you don't end up with [i]parent[i]child[/i][/i] + if (!val || parent && dom.hasStyle(parent, property, val)) { + return false; + } + + return !values || values.includes(val); + } + + function createAttributeMatch(isStrict) { + return function (attribute) { + var name = attribute[0]; + var value = attribute[1]; + + // code tags should skip most styles + if (name === 'style' && element.nodeName === 'CODE') { + return false; + } + + if (name === 'style' && value) { + return value[isStrict ? 'every' : 'some'](isStyleMatch); + } else { + var val = attr(element, name); + + return val && (!value || value.includes(val)); + } + }; + } + + function handleTag(tag) { + if (!tagsToBBCodes[tag] || !tagsToBBCodes[tag][blockLevel]) { + return; + } + + // loop all bbcodes for this tag + each(tagsToBBCodes[tag][blockLevel], function (bbcode, attrs) { + var fn, format, + isStrict = bbcodeHandlers[bbcode].strictMatch; + + if (typeof isStrict === 'undefined') { + isStrict = base.opts.strictMatch; + } + + // Skip if the element doesn't have the attribute or the + // attribute doesn't match one of the required values + fn = isStrict ? 'every' : 'some'; + if (attrs && !attrs[fn](createAttributeMatch(isStrict))) { + return; + } + + format = bbcodeHandlers[bbcode].format; + if (isFunction(format)) { + content = format.call(base, element, content); + } else { + content = _formatString(format, content); + } + return false; + }); + } + + handleTag('*'); + handleTag(element.nodeName.toLowerCase()); + return content; + } + + /** + * Converts a HTML dom element to BBCode starting from + * the innermost element and working backwards + * + * @private + * @param {HTMLElement} element + * @return {string} BBCode + * @memberOf SCEditor.plugins.bbcode.prototype + */ + function elementToBbcode(element) { + var toBBCode = function (node, vChildren) { + var ret = ''; + + dom.traverse(node, function (node) { + var content = '', + nodeType = node.nodeType, + tag = node.nodeName.toLowerCase(), + vChild = validChildren[tag], + firstChild = node.firstChild, + isValidChild = true; + + if (typeof vChildren === 'object') { + isValidChild = vChildren.indexOf(tag) > -1; + + // Emoticons should always be converted + if (is(node, 'img') && attr(node, EMOTICON_DATA_ATTR)) { + isValidChild = true; + } + + // if this tag is one of the parents allowed children + // then set this tags allowed children to whatever it + // allows, otherwise set to what the parent allows + if (!isValidChild) { + vChild = vChildren; + } + } + + // 3 = text and 1 = element + if (nodeType !== 3 && nodeType !== 1) { + return; + } + + if (nodeType === 1) { + // skip empty nlf elements (new lines automatically + // added after block level elements like quotes) + if (is(node, '.sceditor-nlf') && !firstChild) { + return; + } + + // don't convert iframe contents + if (tag !== 'iframe') { + content = toBBCode(node, vChild); + } + + // TODO: isValidChild is no longer needed. Should use + // valid children bbcodes instead by creating BBCode + // tokens like the parser. + if (isValidChild) { + // code tags should skip most styles + if (tag !== 'code') { + // First parse inline codes + content = handleTags(node, content, false); + } + + content = handleTags(node, content, true); + ret += handleBlockNewlines(node, content); + } else { + ret += content; + } + } else { + ret += node.nodeValue; + } + }, false, true); + + return ret; + }; + + return toBBCode(element); + }; + + /** + * Initializer + * @private + */ + base.init = function () { + base.opts = this.opts; + base.elementToBbcode = elementToBbcode; + + // build the BBCode cache + buildBbcodeCache(); + + this.commands = extend( + true, {}, defaultCommandsOverrides, this.commands + ); + + // Add BBCode helper methods + this.toBBCode = base.toSource; + this.fromBBCode = base.toHtml; + }; + + /** + * Converts BBCode into HTML + * + * @param {boolean} asFragment + * @param {string} source + * @param {boolean} [legacyAsFragment] Used by fromBBCode() method + */ + function toHtml(asFragment, source, legacyAsFragment) { + var parser = new BBCodeParser(base.opts.parserOptions); + var html = parser.toHTML( + base.opts.bbcodeTrim ? source.trim() : source + ); + + return (asFragment || legacyAsFragment) ? + removeFirstLastDiv(html) : html; + } + + /** + * Converts HTML into BBCode + * + * @param {boolean} asFragment + * @param {string} html + * @param {!Document} [context] + * @param {!HTMLElement} [parent] + * @return {string} + * @private + */ + function toSource(asFragment, html, context, parent) { + context = context || document; + + var bbcode, elements; + var containerParent = context.createElement('div'); + var container = context.createElement('div'); + var parser = new BBCodeParser(base.opts.parserOptions); + + container.innerHTML = html; + css(containerParent, 'visibility', 'hidden'); + containerParent.appendChild(container); + context.body.appendChild(containerParent); + + if (asFragment) { + // Add text before and after so removeWhiteSpace doesn't remove + // leading and trailing whitespace + containerParent.insertBefore( + context.createTextNode('#'), + containerParent.firstChild + ); + containerParent.appendChild(context.createTextNode('#')); + } + + // Match parents white-space handling + if (parent) { + css(container, 'whiteSpace', css(parent, 'whiteSpace')); + } + + // Remove all nodes with sceditor-ignore class + elements = container.getElementsByClassName('sceditor-ignore'); + while (elements.length) { + elements[0].parentNode.removeChild(elements[0]); + } + + dom.removeWhiteSpace(containerParent); + + bbcode = elementToBbcode(container); + + context.body.removeChild(containerParent); + + bbcode = parser.toBBCode(bbcode, true); + + if (base.opts.bbcodeTrim) { + bbcode = bbcode.trim(); + } + + return bbcode; + }; + + base.toHtml = toHtml.bind(null, false); + base.fragmentToHtml = toHtml.bind(null, true); + base.toSource = toSource.bind(null, false); + base.fragmentToSource = toSource.bind(null, true); + }; + + /** + * Gets a BBCode + * + * @param {string} name + * @return {Object|null} + * @since 2.0.0 + */ + bbcodeFormat.get = function (name) { + return bbcodeHandlers[name] || null; + }; + + /** + * Adds a BBCode to the parser or updates an existing + * BBCode if a BBCode with the specified name already exists. + * + * @param {string} name + * @param {Object} bbcode + * @return {this} + * @since 2.0.0 + */ + bbcodeFormat.set = function (name, bbcode) { + if (name && bbcode) { + // merge any existing command properties + bbcode = extend(bbcodeHandlers[name] || {}, bbcode); + + bbcode.remove = function () { + delete bbcodeHandlers[name]; + }; + + bbcodeHandlers[name] = bbcode; + } + + return this; + }; + + /** + * Renames a BBCode + * + * This does not change the format or HTML handling, those must be + * changed manually. + * + * @param {string} name [description] + * @param {string} newName [description] + * @return {this|false} + * @since 2.0.0 + */ + bbcodeFormat.rename = function (name, newName) { + if (name in bbcodeHandlers) { + bbcodeHandlers[newName] = bbcodeHandlers[name]; + + delete bbcodeHandlers[name]; + } + + return this; + }; + + /** + * Removes a BBCode + * + * @param {string} name + * @return {this} + * @since 2.0.0 + */ + bbcodeFormat.remove = function (name) { + if (name in bbcodeHandlers) { + delete bbcodeHandlers[name]; + } + + return this; + }; + + bbcodeFormat.formatBBCodeString = formatBBCodeString; + + sceditor.formats.bbcode = bbcodeFormat; + sceditor.BBCodeParser = BBCodeParser; +}(sceditor));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/formats/xhtml.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1269 @@ +/** + * SCEditor XHTML Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (sceditor) { + 'use strict'; + + var dom = sceditor.dom; + var utils = sceditor.utils; + + var css = dom.css; + var attr = dom.attr; + var is = dom.is; + var removeAttr = dom.removeAttr; + var convertElement = dom.convertElement; + var extend = utils.extend; + var each = utils.each; + var isEmptyObject = utils.isEmptyObject; + + var getEditorCommand = sceditor.command.get; + + var defaultCommandsOverrides = { + bold: { + txtExec: ['<strong>', '</strong>'] + }, + italic: { + txtExec: ['<em>', '</em>'] + }, + underline: { + txtExec: ['<span style="text-decoration:underline;">', '</span>'] + }, + strike: { + txtExec: ['<span style="text-decoration:line-through;">', '</span>'] + }, + subscript: { + txtExec: ['<sub>', '</sub>'] + }, + superscript: { + txtExec: ['<sup>', '</sup>'] + }, + left: { + txtExec: ['<div style="text-align:left;">', '</div>'] + }, + center: { + txtExec: ['<div style="text-align:center;">', '</div>'] + }, + right: { + txtExec: ['<div style="text-align:right;">', '</div>'] + }, + justify: { + txtExec: ['<div style="text-align:justify;">', '</div>'] + }, + font: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('font')._dropDown( + editor, + caller, + function (font) { + editor.insertText('<span style="font-family:' + + font + ';">', '</span>'); + } + ); + } + }, + size: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('size')._dropDown( + editor, + caller, + function (size) { + editor.insertText('<span style="font-size:' + + size + ';">', '</span>'); + } + ); + } + }, + color: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('color')._dropDown( + editor, + caller, + function (color) { + editor.insertText('<span style="color:' + + color + ';">', '</span>'); + } + ); + } + }, + bulletlist: { + txtExec: ['<ul><li>', '</li></ul>'] + }, + orderedlist: { + txtExec: ['<ol><li>', '</li></ol>'] + }, + table: { + txtExec: ['<table><tr><td>', '</td></tr></table>'] + }, + horizontalrule: { + txtExec: ['<hr />'] + }, + code: { + txtExec: ['<code>', '</code>'] + }, + image: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('image')._dropDown( + editor, + caller, + selected, + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width="' + width + '"'; + } + + if (height) { + attrs += ' height="' + height + '"'; + } + + editor.insertText( + '<img' + attrs + ' src="' + url + '" />' + ); + } + ); + } + }, + email: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('email')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '<a href="mailto:' + url + '">' + + (text || selected || url) + + '</a>' + ); + } + ); + } + }, + link: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('link')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '<a href="' + url + '">' + + (text || selected || url) + + '</a>' + ); + } + ); + } + }, + quote: { + txtExec: ['<blockquote>', '</blockquote>'] + }, + youtube: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('youtube')._dropDown( + editor, + caller, + function (id, time) { + editor.insertText( + '<iframe width="560" height="315" ' + + 'src="https://www.youtube.com/embed/{id}?' + + 'wmode=opaque&start=' + time + '" ' + + 'data-youtube-id="' + id + '" ' + + 'frameborder="0" allowfullscreen></iframe>' + ); + } + ); + } + }, + rtl: { + txtExec: ['<div stlye="direction:rtl;">', '</div>'] + }, + ltr: { + txtExec: ['<div stlye="direction:ltr;">', '</div>'] + } + }; + + /** + * XHTMLSerializer part of the XHTML plugin. + * + * @class XHTMLSerializer + * @name jQuery.sceditor.XHTMLSerializer + * @since v1.4.1 + */ + sceditor.XHTMLSerializer = function () { + var base = this; + + var opts = { + indentStr: '\t' + }; + + /** + * Array containing the output, used as it's faster + * than string concatenation in slow browsers. + * @type {Array} + * @private + */ + var outputStringBuilder = []; + + /** + * Current indention level + * @type {number} + * @private + */ + var currentIndent = 0; + + // TODO: use escape.entities + /** + * Escapes XHTML entities + * + * @param {string} str + * @return {string} + * @private + */ + function escapeEntities(str) { + var entities = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\xa0': ' ' + }; + + return !str ? '' : str.replace(/[&<>"\xa0]/g, function (entity) { + return entities[entity] || entity; + }); + }; + + /** + * Replace spaces including newlines with a single + * space except for non-breaking spaces + * + * @param {string} str + * @return {string} + * @private + */ + function trim(str) { + return str.replace(/[^\S\u00A0]+/g, ' '); + }; + + /** + * Serializes a node to XHTML + * + * @param {Node} node Node to serialize + * @param {boolean} onlyChildren If to only serialize the nodes + * children and not the node + * itself + * @return {string} The serialized node + * @name serialize + * @memberOf jQuery.sceditor.XHTMLSerializer.prototype + * @since v1.4.1 + */ + base.serialize = function (node, onlyChildren) { + outputStringBuilder = []; + + if (onlyChildren) { + node = node.firstChild; + + while (node) { + serializeNode(node); + node = node.nextSibling; + } + } else { + serializeNode(node); + } + + return outputStringBuilder.join(''); + }; + + /** + * Serializes a node to the outputStringBuilder + * + * @param {Node} node + * @return {void} + * @private + */ + function serializeNode(node, parentIsPre) { + switch (node.nodeType) { + case 1: // element + handleElement(node, parentIsPre); + break; + + case 3: // text + handleText(node, parentIsPre); + break; + + case 4: // cdata section + handleCdata(node); + break; + + case 8: // comment + handleComment(node); + break; + + case 9: // document + case 11: // document fragment + handleDoc(node); + break; + + // Ignored types + case 2: // attribute + case 5: // entity ref + case 6: // entity + case 7: // processing instruction + case 10: // document type + case 12: // notation + break; + } + }; + + /** + * Handles doc node + * @param {Node} node + * @return {void} + * @private + */ + function handleDoc(node) { + var child = node.firstChild; + + while (child) { + serializeNode(child); + child = child.nextSibling; + } + }; + + /** + * Handles element nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleElement(node, parentIsPre) { + var child, attr, attrValue, + tagName = node.nodeName.toLowerCase(), + isIframe = tagName === 'iframe', + attrIdx = node.attributes.length, + firstChild = node.firstChild, + // pre || pre-wrap with any vendor prefix + isPre = parentIsPre || + /pre(?:\-wrap)?$/i.test(css(node, 'whiteSpace')), + selfClosing = !node.firstChild && !dom.canHaveChildren(node) && + !isIframe; + + if (is(node, '.sceditor-ignore')) { + return; + } + + output('<' + tagName, !parentIsPre && canIndent(node)); + while (attrIdx--) { + attr = node.attributes[attrIdx]; + + attrValue = attr.value; + + output(' ' + attr.name.toLowerCase() + '="' + + escapeEntities(attrValue) + '"', false); + } + output(selfClosing ? ' />' : '>', false); + + if (!isIframe) { + child = firstChild; + } + + while (child) { + currentIndent++; + + serializeNode(child, isPre); + child = child.nextSibling; + + currentIndent--; + } + + if (!selfClosing) { + output( + '</' + tagName + '>', + !isPre && !isIframe && canIndent(node) && + firstChild && canIndent(firstChild) + ); + } + }; + + /** + * Handles CDATA nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleCdata(node) { + output('<![CDATA[' + escapeEntities(node.nodeValue) + ']]>'); + }; + + /** + * Handles comment nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleComment(node) { + output('<!-- ' + escapeEntities(node.nodeValue) + ' -->'); + }; + + /** + * Handles text nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleText(node, parentIsPre) { + var text = node.nodeValue; + + if (!parentIsPre) { + text = trim(text); + } + + if (text) { + output(escapeEntities(text), !parentIsPre && canIndent(node)); + } + }; + + /** + * Adds a string to the outputStringBuilder. + * + * The string will be indented unless indent is set to boolean false. + * @param {string} str + * @param {boolean} indent + * @return {void} + * @private + */ + function output(str, indent) { + var i = currentIndent; + + if (indent !== false) { + // Don't add a new line if it's the first element + if (outputStringBuilder.length) { + outputStringBuilder.push('\n'); + } + + while (i--) { + outputStringBuilder.push(opts.indentStr); + } + } + + outputStringBuilder.push(str); + }; + + /** + * Checks if should indent the node or not + * @param {Node} node + * @return {boolean} + * @private + */ + function canIndent(node) { + var prev = node.previousSibling; + + if (node.nodeType !== 1 && prev) { + return !dom.isInline(prev); + } + + // first child of a block element + if (!prev && !dom.isInline(node.parentNode)) { + return true; + } + + return !dom.isInline(node); + }; + }; + + /** + * SCEditor XHTML plugin + * @class xhtml + * @name jQuery.sceditor.plugins.xhtml + * @since v1.4.1 + */ + function xhtmlFormat() { + var base = this; + + /** + * Tag converters cache + * @type {Object} + * @private + */ + var tagConvertersCache = {}; + + /** + * Attributes filter cache + * @type {Object} + * @private + */ + var attrsCache = {}; + + /** + * Init + * @return {void} + */ + base.init = function () { + if (!isEmptyObject(xhtmlFormat.converters || {})) { + each( + xhtmlFormat.converters, + function (idx, converter) { + each(converter.tags, function (tagname) { + if (!tagConvertersCache[tagname]) { + tagConvertersCache[tagname] = []; + } + + tagConvertersCache[tagname].push(converter); + }); + } + ); + } + + this.commands = extend(true, + {}, defaultCommandsOverrides, this.commands); + }; + + /** + * Converts the WYSIWYG content to XHTML + * + * @param {boolean} isFragment + * @param {string} html + * @param {Document} context + * @param {HTMLElement} [parent] + * @return {string} + * @memberOf jQuery.sceditor.plugins.xhtml.prototype + */ + function toSource(isFragment, html, context) { + var xhtml, + container = context.createElement('div'); + container.innerHTML = html; + + css(container, 'visibility', 'hidden'); + context.body.appendChild(container); + + convertTags(container); + removeTags(container); + removeAttribs(container); + + if (!isFragment) { + wrapInlines(container); + } + + xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true); + + context.body.removeChild(container); + + return xhtml; + }; + + base.toSource = toSource.bind(null, false); + + base.fragmentToSource = toSource.bind(null, true);; + + /** + * Runs all converters for the specified tagName + * against the DOM node. + * @param {string} tagName + * @return {Node} node + * @private + */ + function convertNode(tagName, node) { + if (!tagConvertersCache[tagName]) { + return; + } + + tagConvertersCache[tagName].forEach(function (converter) { + if (converter.tags[tagName]) { + each(converter.tags[tagName], function (attr, values) { + if (!node.getAttributeNode) { + return; + } + + attr = node.getAttributeNode(attr); + + if (!attr || values && values.indexOf(attr.value) < 0) { + return; + } + + converter.conv.call(base, node); + }); + } else if (converter.conv) { + converter.conv.call(base, node); + } + }); + }; + + /** + * Converts any tags/attributes to their XHTML equivalents + * @param {Node} node + * @return {void} + * @private + */ + function convertTags(node) { + dom.traverse(node, function (node) { + var tagName = node.nodeName.toLowerCase(); + + convertNode('*', node); + convertNode(tagName, node); + }, true); + }; + + /** + * Tests if a node is empty and can be removed. + * + * @param {Node} node + * @return {boolean} + * @private + */ + function isEmpty(node, excludeBr) { + var rect, + childNodes = node.childNodes, + tagName = node.nodeName.toLowerCase(), + nodeValue = node.nodeValue, + childrenLength = childNodes.length, + allowedEmpty = xhtmlFormat.allowedEmptyTags || []; + + if (excludeBr && tagName === 'br') { + return true; + } + + if (is(node, '.sceditor-ignore')) { + return true; + } + + if (allowedEmpty.indexOf(tagName) > -1 || tagName === 'td' || + !dom.canHaveChildren(node)) { + + return false; + } + + // \S|\u00A0 = any non space char + if (nodeValue && /\S|\u00A0/.test(nodeValue)) { + return false; + } + + while (childrenLength--) { + if (!isEmpty(childNodes[childrenLength], + excludeBr && !node.previousSibling && !node.nextSibling)) { + return false; + } + } + + // Treat tags with a width and height from CSS as not empty + if (node.getBoundingClientRect && + (node.className || node.hasAttributes('style'))) { + rect = node.getBoundingClientRect(); + return !rect.width || !rect.height; + } + + return true; + }; + + /** + * Removes any tags that are not white listed or if no + * tags are white listed it will remove any tags that + * are black listed. + * + * @param {Node} rootNode + * @return {void} + * @private + */ + function removeTags(rootNode) { + dom.traverse(rootNode, function (node) { + var remove, + tagName = node.nodeName.toLowerCase(), + parentNode = node.parentNode, + nodeType = node.nodeType, + isBlock = !dom.isInline(node), + previousSibling = node.previousSibling, + nextSibling = node.nextSibling, + isTopLevel = parentNode === rootNode, + noSiblings = !previousSibling && !nextSibling, + empty = tagName !== 'iframe' && isEmpty(node, + isTopLevel && noSiblings && tagName !== 'br'), + document = node.ownerDocument, + allowedTags = xhtmlFormat.allowedTags, + firstChild = node.firstChild, + disallowedTags = xhtmlFormat.disallowedTags; + + // 3 = text node + if (nodeType === 3) { + return; + } + + if (nodeType === 4) { + tagName = '!cdata'; + } else if (tagName === '!' || nodeType === 8) { + tagName = '!comment'; + } + + if (nodeType === 1) { + // skip empty nlf elements (new lines automatically + // added after block level elements like quotes) + if (is(node, '.sceditor-nlf')) { + if (!firstChild || (node.childNodes.length === 1 && + /br/i.test(firstChild.nodeName))) { + // Mark as empty,it will be removed by the next code + empty = true; + } else { + node.classList.remove('sceditor-nlf'); + + if (!node.className) { + removeAttr(node, 'class'); + } + } + } + } + + if (empty) { + remove = true; + // 3 is text node which do not get filtered + } else if (allowedTags && allowedTags.length) { + remove = (allowedTags.indexOf(tagName) < 0); + } else if (disallowedTags && disallowedTags.length) { + remove = (disallowedTags.indexOf(tagName) > -1); + } + + if (remove) { + if (!empty) { + if (isBlock && previousSibling && + dom.isInline(previousSibling)) { + parentNode.insertBefore( + document.createTextNode(' '), node); + } + + // Insert all the childen after node + while (node.firstChild) { + parentNode.insertBefore(node.firstChild, + nextSibling); + } + + if (isBlock && nextSibling && + dom.isInline(nextSibling)) { + parentNode.insertBefore( + document.createTextNode(' '), nextSibling); + } + } + + parentNode.removeChild(node); + } + }, true); + }; + + /** + * Merges two sets of attribute filters into one + * + * @param {Object} filtersA + * @param {Object} filtersB + * @return {Object} + * @private + */ + function mergeAttribsFilters(filtersA, filtersB) { + var ret = {}; + + if (filtersA) { + ret = extend({}, ret, filtersA); + } + + if (!filtersB) { + return ret; + } + + each(filtersB, function (attrName, values) { + if (Array.isArray(values)) { + ret[attrName] = (ret[attrName] || []).concat(values); + } else if (!ret[attrName]) { + ret[attrName] = null; + } + }); + + return ret; + }; + + /** + * Wraps adjacent inline child nodes of root + * in paragraphs. + * + * @param {Node} root + * @private + */ + function wrapInlines(root) { + // Strip empty text nodes so they don't get wrapped. + dom.removeWhiteSpace(root); + + var wrapper; + var node = root.firstChild; + var next; + while (node) { + next = node.nextSibling; + + if (dom.isInline(node) && !is(node, '.sceditor-ignore')) { + if (!wrapper) { + wrapper = root.ownerDocument.createElement('p'); + node.parentNode.insertBefore(wrapper, node); + } + + wrapper.appendChild(node); + } else { + wrapper = null; + } + + node = next; + } + }; + + /** + * Removes any attributes that are not white listed or + * if no attributes are white listed it will remove + * any attributes that are black listed. + * @param {Node} node + * @return {void} + * @private + */ + function removeAttribs(node) { + var tagName, attr, attrName, attrsLength, validValues, remove, + allowedAttribs = xhtmlFormat.allowedAttribs, + isAllowed = allowedAttribs && + !isEmptyObject(allowedAttribs), + disallowedAttribs = xhtmlFormat.disallowedAttribs, + isDisallowed = disallowedAttribs && + !isEmptyObject(disallowedAttribs); + + attrsCache = {}; + + dom.traverse(node, function (node) { + if (!node.attributes) { + return; + } + + tagName = node.nodeName.toLowerCase(); + attrsLength = node.attributes.length; + + if (attrsLength) { + if (!attrsCache[tagName]) { + if (isAllowed) { + attrsCache[tagName] = mergeAttribsFilters( + allowedAttribs['*'], + allowedAttribs[tagName] + ); + } else { + attrsCache[tagName] = mergeAttribsFilters( + disallowedAttribs['*'], + disallowedAttribs[tagName] + ); + } + } + + while (attrsLength--) { + attr = node.attributes[attrsLength]; + attrName = attr.name; + validValues = attrsCache[tagName][attrName]; + remove = false; + + if (isAllowed) { + remove = validValues !== null && + (!Array.isArray(validValues) || + validValues.indexOf(attr.value) < 0); + } else if (isDisallowed) { + remove = validValues === null || + (Array.isArray(validValues) && + validValues.indexOf(attr.value) > -1); + } + + if (remove) { + node.removeAttribute(attrName); + } + } + } + }); + }; + }; + + /** + * Tag conveters, a converter is applied to all + * tags that match the criteria. + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.converters + * @since v1.4.1 + */ + xhtmlFormat.converters = [ + { + tags: { + '*': { + width: null + } + }, + conv: function (node) { + css(node, 'width', attr(node, 'width')); + removeAttr(node, 'width'); + } + }, + { + tags: { + '*': { + height: null + } + }, + conv: function (node) { + css(node, 'height', attr(node, 'height')); + removeAttr(node, 'height'); + } + }, + { + tags: { + 'li': { + value: null + } + }, + conv: function (node) { + removeAttr(node, 'value'); + } + }, + { + tags: { + '*': { + text: null + } + }, + conv: function (node) { + css(node, 'color', attr(node, 'text')); + removeAttr(node, 'text'); + } + }, + { + tags: { + '*': { + color: null + } + }, + conv: function (node) { + css(node, 'color', attr(node, 'color')); + removeAttr(node, 'color'); + } + }, + { + tags: { + '*': { + face: null + } + }, + conv: function (node) { + css(node, 'fontFamily', attr(node, 'face')); + removeAttr(node, 'face'); + } + }, + { + tags: { + '*': { + align: null + } + }, + conv: function (node) { + css(node, 'textAlign', attr(node, 'align')); + removeAttr(node, 'align'); + } + }, + { + tags: { + '*': { + border: null + } + }, + conv: function (node) { + css(node, 'borderWidth', attr(node, 'border')); + removeAttr(node, 'border'); + } + }, + { + tags: { + applet: { + name: null + }, + img: { + name: null + }, + layer: { + name: null + }, + map: { + name: null + }, + object: { + name: null + }, + param: { + name: null + } + }, + conv: function (node) { + if (!attr(node, 'id')) { + attr(node, 'id', attr(node, 'name')); + } + + removeAttr(node, 'name'); + } + }, + { + tags: { + '*': { + vspace: null + } + }, + conv: function (node) { + css(node, 'marginTop', attr(node, 'vspace') - 0); + css(node, 'marginBottom', attr(node, 'vspace') - 0); + removeAttr(node, 'vspace'); + } + }, + { + tags: { + '*': { + hspace: null + } + }, + conv: function (node) { + css(node, 'marginLeft', attr(node, 'hspace') - 0); + css(node, 'marginRight', attr(node, 'hspace') - 0); + removeAttr(node, 'hspace'); + } + }, + { + tags: { + 'hr': { + noshade: null + } + }, + conv: function (node) { + css(node, 'borderStyle', 'solid'); + removeAttr(node, 'noshade'); + } + }, + { + tags: { + '*': { + nowrap: null + } + }, + conv: function (node) { + css(node, 'whiteSpace', 'nowrap'); + removeAttr(node, 'nowrap'); + } + }, + { + tags: { + big: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'fontSize', 'larger'); + } + }, + { + tags: { + small: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'fontSize', 'smaller'); + } + }, + { + tags: { + b: null + }, + conv: function (node) { + convertElement(node, 'strong'); + } + }, + { + tags: { + u: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'textDecoration', + 'underline'); + } + }, + { + tags: { + s: null, + strike: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'textDecoration', + 'line-through'); + } + }, + { + tags: { + dir: null + }, + conv: function (node) { + convertElement(node, 'ul'); + } + }, + { + tags: { + center: null + }, + conv: function (node) { + css(convertElement(node, 'div'), 'textAlign', 'center'); + } + }, + { + tags: { + font: { + size: null + } + }, + conv: function (node) { + css(node, 'fontSize', css(node, 'fontSize')); + removeAttr(node, 'size'); + } + }, + { + tags: { + font: null + }, + conv: function (node) { + // All it's attributes will be converted + // by the attribute converters + convertElement(node, 'span'); + } + }, + { + tags: { + '*': { + type: ['_moz'] + } + }, + conv: function (node) { + removeAttr(node, 'type'); + } + }, + { + tags: { + '*': { + '_moz_dirty': null + } + }, + conv: function (node) { + removeAttr(node, '_moz_dirty'); + } + }, + { + tags: { + '*': { + '_moz_editor_bogus_node': null + } + }, + conv: function (node) { + node.parentNode.removeChild(node); + } + }, + { + tags: { + '*': { + 'data-sce-target': null + } + }, + conv: function (node) { + var rel = attr(node, 'rel') || ''; + var target = attr(node, 'data-sce-target'); + + // Only allow the value _blank and only on links + if (target === '_blank' && is(node, 'a')) { + if (!/(^|\s)noopener(\s|$)/.test(rel)) { + attr(node, 'rel', 'noopener' + (rel ? ' ' + rel : '')); + } + + attr(node, 'target', target); + } + + + removeAttr(node, 'data-sce-target'); + } + }, + { + tags: { + code: null + }, + conv: function (node) { + var node, nodes = node.getElementsByTagName('div'); + while ((node = nodes[0])) { + node.style.display = 'block'; + convertElement(node, 'span'); + } + } + } + ]; + + /** + * Allowed attributes map. + * + * To allow an attribute for all tags use * as the tag name. + * + * Leave empty or null to allow all attributes. (the disallow + * list will be used to filter them instead) + * @type {Object} + * @name jQuery.sceditor.plugins.xhtml.allowedAttribs + * @since v1.4.1 + */ + xhtmlFormat.allowedAttribs = {}; + + /** + * Attributes that are not allowed. + * + * Only used if allowed attributes is null or empty. + * @type {Object} + * @name jQuery.sceditor.plugins.xhtml.disallowedAttribs + * @since v1.4.1 + */ + xhtmlFormat.disallowedAttribs = {}; + + /** + * Array containing all the allowed tags. + * + * If null or empty all tags will be allowed. + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.allowedTags + * @since v1.4.1 + */ + xhtmlFormat.allowedTags = []; + + /** + * Array containing all the disallowed tags. + * + * Only used if allowed tags is null or empty. + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.disallowedTags + * @since v1.4.1 + */ + xhtmlFormat.disallowedTags = []; + + /** + * Array containing tags which should not be removed when empty. + * + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.allowedEmptyTags + * @since v2.0.0 + */ + xhtmlFormat.allowedEmptyTags = []; + + sceditor.formats.xhtml = xhtmlFormat; +}(sceditor));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/icons/material.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,132 @@ +/** + * SCEditor SVG material icons plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (document, sceditor) { + 'use strict'; + + var dom = sceditor.dom; + + /** + * Material icons by Google (Apache license) + * https://github.com/google/material-design-icons/blob/master/LICENSE + * + * Extra icons by materialdesignicons.com and contributors (MIT license) + * https://github.com/Templarian/MaterialDesign-SVG/blob/master/LICENSE + */ + /* eslint max-len: off*/ + var icons = { + 'bold': '<path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" />', + 'bulletlist': '<path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" />', + 'center': '<path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" />', + // Cody @XT3000 - https://materialdesignicons.com/ + 'code': '<path d="M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z" />', + 'color': '<path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /><path class="sce-color" d="M0,24H24V20H0V24Z" />', + 'copy': '<path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" />', + 'cut': '<path d="M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z" />', + 'date': '<path d="M7,10H12V15H7M19,19H5V8H19M19,3H18V1H16V3H8V1H6V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3Z" />', + 'email': '<path d="M20,8L12,13L4,8V6L12,11L20,6M20,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V6C22,4.89 21.1,4 20,4Z" />', + 'emoticon': '<path d="M12,17.5C14.33,17.5 16.3,16.04 17.11,14H6.89C7.69,16.04 9.67,17.5 12,17.5M8.5,11A1.5,1.5 0 0,0 10,9.5A1.5,1.5 0 0,0 8.5,8A1.5,1.5 0 0,0 7,9.5A1.5,1.5 0 0,0 8.5,11M15.5,11A1.5,1.5 0 0,0 17,9.5A1.5,1.5 0 0,0 15.5,8A1.5,1.5 0 0,0 14,9.5A1.5,1.5 0 0,0 15.5,11M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />', + // JapanYoshi @japanyoshilol - https://materialdesignicons.com/ + 'font': '<path d="M17,8H20V20H21V21H17V20H18V17H14L12.5,20H14V21H10V20H11L17,8M18,9L14.5,16H18V9M5,3H10C11.11,3 12,3.89 12,5V16H9V11H6V16H3V5C3,3.89 3.89,3 5,3M6,5V9H9V5H6Z" />', + 'format': '<path d="M18,4V3A1,1 0 0,0 17,2H5A1,1 0 0,0 4,3V7A1,1 0 0,0 5,8H17A1,1 0 0,0 18,7V6H19V10H9V21A1,1 0 0,0 10,22H12A1,1 0 0,0 13,21V12H21V4H18Z" />', + // Austin Andrews @Templarian - https://materialdesignicons.com/ + 'grip': '<path d="M22,22H20V20H22V22M22,18H20V16H22V18M18,22H16V20H18V22M18,18H16V16H18V18M14,22H12V20H14V22M22,14H20V12H22V14Z" />', + // Sam Clarke @samclarke + 'horizontalrule': '<path d="M 3,3 21,3 21,5 3,5 3,3 M 3,7 15,7 15,9 3,9 3,7 m 0,4 18,0 0,4 -18,0 0,-4" />', + 'image': '<path d="M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z" />', + 'indent': '<path d="M11,13H21V11H11M11,9H21V7H11M3,3V5H21V3M11,17H21V15H11M3,8V16L7,12M3,21H21V19H3V21Z" />', + 'italic': '<path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" />', + 'justify': '<path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /> ', + 'left': '<path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /> ', + 'link': '<path d="M16,6H13V7.9H16C18.26,7.9 20.1,9.73 20.1,12A4.1,4.1 0 0,1 16,16.1H13V18H16A6,6 0 0,0 22,12C22,8.68 19.31,6 16,6M3.9,12C3.9,9.73 5.74,7.9 8,7.9H11V6H8A6,6 0 0,0 2,12A6,6 0 0,0 8,18H11V16.1H8C5.74,16.1 3.9,14.26 3.9,12M8,13H16V11H8V13Z" />', + 'ltr': '<path d="M21,18L17,14V17H5V19H17V22M9,10V15H11V4H13V15H15V4H17V2H9A4,4 0 0,0 5,6A4,4 0 0,0 9,10Z" />', + // Austin Andrews @Templarian - https://materialdesignicons.com/ + 'maximize': '<path d="M9.5,13.09L10.91,14.5L6.41,19H10V21H3V14H5V17.59L9.5,13.09M10.91,9.5L9.5,10.91L5,6.41V10H3V3H10V5H6.41L10.91,9.5M14.5,13.09L19,17.59V14H21V21H14V19H17.59L13.09,14.5L14.5,13.09M13.09,9.5L17.59,5H14V3H21V10H19V6.41L14.5,10.91L13.09,9.5Z" />', + 'orderedlist': '<path d="M7,13H21V11H7M7,19H21V17H7M7,7H21V5H7M2,11H3.8L2,13.1V14H5V13H3.2L5,10.9V10H2M3,8H4V4H2V5H3M2,17H4V17.5H3V18.5H4V19H2V20H5V16H2V17Z" />', + 'outdent': '<path d="M11,13H21V11H11M11,9H21V7H11M3,3V5H21V3M3,21H21V19H3M3,12L7,16V8M11,17H21V15H11V17Z" />', + 'paste': '<path d="M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z" />', + 'pastetext': '<path d="M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z" />', + 'print': '<path d="M18,3H6V7H18M19,12A1,1 0 0,1 18,11A1,1 0 0,1 19,10A1,1 0 0,1 20,11A1,1 0 0,1 19,12M16,19H8V14H16M19,8H5A3,3 0 0,0 2,11V17H6V21H18V17H22V11A3,3 0 0,0 19,8Z" />', + 'quote': '<path d="M14,17H17L19,13V7H13V13H16M6,17H9L11,13V7H5V13H8L6,17Z" />', + 'redo': '<path d="M18.4,10.6C16.55,9 14.15,8 11.5,8C6.85,8 2.92,11.03 1.54,15.22L3.9,16C4.95,12.81 7.95,10.5 11.5,10.5C13.45,10.5 15.23,11.22 16.62,12.38L13,16H22V7L18.4,10.6Z" />', + 'removeformat': '<path d="M6,5V5.18L8.82,8H11.22L10.5,9.68L12.6,11.78L14.21,8H20V5H6M3.27,5L2,6.27L8.97,13.24L6.5,19H9.5L11.07,15.34L16.73,21L18,19.73L3.55,5.27L3.27,5Z" />', + 'right': '<path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" />', + 'rtl': '<path d="M8,17V14L4,18L8,22V19H20V17M10,10V15H12V4H14V15H16V4H18V2H10A4,4 0 0,0 6,6A4,4 0 0,0 10,10Z" />', + 'size': '<path d="M3,12H6V19H9V12H12V9H3M9,4V7H14V19H17V7H22V4H9Z" />', + 'source': '<path d="M14.6,16.6L19.2,12L14.6,7.4L16,6L22,12L16,18L14.6,16.6M9.4,16.6L4.8,12L9.4,7.4L8,6L2,12L8,18L9.4,16.6Z" />', + 'strike': '<path d="M3,14H21V12H3M5,4V7H10V10H14V7H19V4M10,19H14V16H10V19Z" />', + // Austin Andrews @Templarian - https://materialdesignicons.com/ + 'subscript': '<path d="M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,21.03H16.97V20.03L17.86,19.23C18.62,18.58 19.18,18.04 19.56,17.6C19.93,17.16 20.12,16.75 20.13,16.36C20.14,16.08 20.05,15.85 19.86,15.66C19.68,15.5 19.39,15.38 19,15.38C18.69,15.38 18.42,15.44 18.16,15.56L17.5,15.94L17.05,14.77C17.32,14.56 17.64,14.38 18.03,14.24C18.42,14.1 18.85,14 19.32,14C20.1,14.04 20.7,14.25 21.1,14.66C21.5,15.07 21.72,15.59 21.72,16.23C21.71,16.79 21.53,17.31 21.18,17.78C20.84,18.25 20.42,18.7 19.91,19.14L19.27,19.66V19.68H21.85V21.03Z" />', + // Austin Andrews @Templarian - https://materialdesignicons.com/ + 'superscript': '<path d="M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,9H16.97V8L17.86,7.18C18.62,6.54 19.18,6 19.56,5.55C19.93,5.11 20.12,4.7 20.13,4.32C20.14,4.04 20.05,3.8 19.86,3.62C19.68,3.43 19.39,3.34 19,3.33C18.69,3.34 18.42,3.4 18.16,3.5L17.5,3.89L17.05,2.72C17.32,2.5 17.64,2.33 18.03,2.19C18.42,2.05 18.85,2 19.32,2C20.1,2 20.7,2.2 21.1,2.61C21.5,3 21.72,3.54 21.72,4.18C21.71,4.74 21.53,5.26 21.18,5.73C20.84,6.21 20.42,6.66 19.91,7.09L19.27,7.61V7.63H21.85V9Z" />', + // Austin Andrews @Templarian - https://materialdesignicons.com/ + 'table': '<path d="M5,4H19A2,2 0 0,1 21,6V18A2,2 0 0,1 19,20H5A2,2 0 0,1 3,18V6A2,2 0 0,1 5,4M5,8V12H11V8H5M13,8V12H19V8H13M5,14V18H11V14H5M13,14V18H19V14H13Z" />', + 'time': '<path d="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z" />', + 'underline': '<path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" />', + 'undo': '<path d="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z" />', + // Austin Andrews @Templarian - https://materialdesignicons.com/ + 'unlink': '<path d="M2,5.27L3.28,4L20,20.72L18.73,22L14.73,18H13V16.27L9.73,13H8V11.27L5.5,8.76C4.5,9.5 3.9,10.68 3.9,12C3.9,14.26 5.74,16.1 8,16.1H11V18H8A6,6 0 0,1 2,12C2,10.16 2.83,8.5 4.14,7.41L2,5.27M16,6A6,6 0 0,1 22,12C22,14.21 20.8,16.15 19,17.19L17.6,15.77C19.07,15.15 20.1,13.7 20.1,12C20.1,9.73 18.26,7.9 16,7.9H13V6H16M8,6H11V7.9H9.72L7.82,6H8M16,11V13H14.82L12.82,11H16Z" />', + 'youtube': '<path d="M10,16.5V7.5L16,12M20,4.4C19.4,4.2 15.7,4 12,4C8.3,4 4.6,4.19 4,4.38C2.44,4.9 2,8.4 2,12C2,15.59 2.44,19.1 4,19.61C4.6,19.81 8.3,20 12,20C15.7,20 19.4,19.81 20,19.61C21.56,19.1 22,15.59 22,12C22,8.4 21.56,4.91 20,4.4Z" />' + }; + + sceditor.icons.material = function () { + var nodes = {}; + + var colorPath; + + return { + create: function (command) { + if (command in icons) { + // Using viewbox="1 1 22 22" to trim off the 1 unit border + // around the SVG icons. + // Default is viewbox="0 0 24 24" + nodes[command] = sceditor.dom.parseHTML( + '<svg xmlns="http://www.w3.org/2000/svg" ' + + 'viewbox="1 1 22 22" unselectable="on">' + + icons[command] + + '</svg>' + ).firstChild; + + if (command === 'color') { + colorPath = nodes[command].querySelector('.sce-color'); + } + } + + return nodes[command]; + }, + update: function (isSourceMode, currentNode) { + if (colorPath) { + var color = 'inherit'; + + if (!isSourceMode && currentNode) { + color = currentNode.ownerDocument + .queryCommandValue('forecolor'); + } + + dom.css(colorPath, 'fill', color); + } + }, + rtl: function (isRtl) { + var gripNode = nodes.grip; + + if (gripNode) { + var transform = isRtl ? 'scaleX(-1)' : ''; + + dom.css(gripNode, 'transform', transform); + dom.css(gripNode, 'msTransform', transform); + dom.css(gripNode, 'webkitTransform', transform); + } + } + }; + }; + + sceditor.icons.material.icons = icons; +})(document, sceditor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/icons/monocons.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,112 @@ +/** + * SCEditor SVG monocons plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (document, sceditor) { + 'use strict'; + + var dom = sceditor.dom; + + /* eslint max-len: off*/ + var icons = { + 'bold': '<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-size="15" font-weight="bold">B</text>', + 'bulletlist': '<path d="M6 2h9v2H6zm0 5h9v2H6zm0 5h9v2H6z"/><circle cx="3" cy="3" r="1.75"/><circle cx="3" cy="8" r="1.75"/><circle cx="3" cy="13" r="1.75"/>', + 'center': '<path d="M1 1h14v2H1zm2 4h10v2H3zM1 9h14v2H1zm2 4h10v2H3z"/>', + 'code': '<path d="M7 6L4 9l3 3v-1.5L5.5 9 7 7.5zm2 0v1.5L10.5 9 9 10.5V12l3-3zM2.406 1A.517.517 0 0 0 2 1.5v13c0 .262.238.5.5.5h11a.52.52 0 0 0 .5-.5V4.375c.002-.102-.13-.193-.156-.219l-3-3A.506.506 0 0 0 10.5 1zM3 2h7v2.5c0 .262.238.5.5.5H13v9H3zm8 .688L12.313 4H11z"/>', + 'color': '<text x="50%" y="8" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-size="13" font-weight="bold">A</text><path class="sce-color" d="M2 13h12v2H2z"/>', + 'copy': '<path d="M6.404 5.002a.5.5 0 0 0-.406.5v10a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V8.596a.492.492 0 0 0 0-.094.662.662 0 0 0 0-.063v-.063l-.031-.063v-.031a.557.557 0 0 0-.094-.094l-.031-.031-2.875-2.844a.498.498 0 0 0-.125-.156.5.5 0 0 0-.344-.156h-5a.59.59 0 0 0-.094.001c-.239.046.031-.003 0 0zm.594 1h4v2.5a.5.5 0 0 0 .5.5h2.5v6h-7v-9zm5 .687l1.313 1.313h-1.313V6.689zM1.406.002a.517.517 0 0 0-.406.5v10c0 .262.238.5.5.5H7V6l3-.063V3.596a.492.492 0 0 0 0-.094.331.331 0 0 0 0-.063v-.063c-.009-.021-.02-.041-.031-.062v-.031a.597.597 0 0 0-.094-.094l-.031-.031L6.969.314a.484.484 0 0 0-.125-.156A.506.506 0 0 0 6.5.002h-5a.492.492 0 0 0-.094 0c-.229.044.032-.003 0 0zm.594 1h4v2.5c0 .262.238.5.5.5H9v1.029L7 5 6 6v4l-4 .002v-9zm5 .687l1.313 1.313H7V1.689z"/>', + 'cut': '<path d="M3 .5c0 2.936 3.774 7.73 3.938 7.938l-1.813 2.844A2.46 2.46 0 0 0 4 11c-1.375 0-2.5 1.125-2.5 2.5S2.625 16 4 16s2.5-1.125 2.5-2.5c0-.444-.138-.856-.344-1.22L8 9.845l1.844 2.438A2.473 2.473 0 0 0 9.5 13.5c0 1.375 1.125 2.5 2.5 2.5s2.5-1.125 2.5-2.5S13.375 11 12 11a2.46 2.46 0 0 0-1.125.28L9.062 8.439C9.226 8.232 13 3.437 13 .5h-1L8 6.78 4 .5H3zM4 12c.834 0 1.5.666 1.5 1.5S4.834 15 4 15s-1.5-.666-1.5-1.5S3.166 12 4 12zm8 0c.834 0 1.5.666 1.5 1.5S12.834 15 12 15s-1.5-.666-1.5-1.5.666-1.5 1.5-1.5z"/>', + 'date': '<path d="M8.1 7v1h2.7v1H8.094v3H11.7v-1H9v-1h2.7V7zM4.5 7v1h.8v3h-.8v1h2.7v-1h-.9V7zM.9 1v14h14.4V1h-1.8v2h-2.7V1H5.4v2H2.7V1zm.9 4h12.6v9H1.8z"/>', + 'email': '<path d="M1 4.5v8c0 .262.238.5.5.5h13a.52.52 0 0 0 .5-.5V4.594C15 4 15 4 14.5 4H1.563C1 4 1 4 1 4.5zM2 5h12v7H2V5zm-.187-.906l-.625.812 6.5 5 .312.219.313-.219 6.5-5-.625-.813L8 8.844l-6.187-4.75z"/>', + 'emoticon': '<path d="M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 1a6 6 0 1 1 0 12A6 6 0 0 1 8 2zM6 5c-.546 0-1 .454-1 1s.454 1 1 1 1-.454 1-1-.454-1-1-1zm4 0c-.547 0-1 .454-1 1s.453 1 1 1c.547 0 1-.454 1-1s-.453-1-1-1zM4.5 9.5s-.002.652.469 1.281C5.44 11.409 6.389 12 8 12c1.611 0 2.561-.591 3.031-1.219.47-.629.469-1.281.469-1.281h-1s-.002.314-.281.688c-.279.374-.83.813-2.219.813-1.389 0-1.94-.44-2.219-.813C5.502 9.814 5.5 9.5 5.5 9.5z"/>', + 'font': '<path d="M7.953 9.75h-4.06l-.395 1.141c-.132.381-.254.752-.368 1.109H.7c.391-1.119.762-2.154 1.113-3.105a104.642 104.642 0 0 1 2.024-5.079 52.23 52.23 0 0 1 1.016-2.212h2.218a80.63 80.63 0 0 1 2.011 4.605c.337.84.105.338.458 1.288s-1.455 2.63-1.587 2.253zM5.912 3.959c-.052.151-.129.357-.229.616-.1.26-.215.56-.343.901-.129.341-.273.716-.431 1.125-.159.409-.32.839-.484 1.288h2.972c-.159-.45-.312-.882-.461-1.292a46.81 46.81 0 0 0-.425-1.127c-.135-.34-.252-.641-.354-.9-.1-.26-.182-.463-.245-.611zm6.949 10.042a36.325 36.325 0 0 0-.35-1.037l-.371-1.063H8.352l-.368 1.064A41.69 41.69 0 0 0 7.64 14H5.373c.365-1.045.711-2.01 1.039-2.896.328-.886.648-1.723.962-2.506.313-.786.623-1.53.927-2.235.305-.705.62-1.393.948-2.065h2.069c.318.672.634 1.36.941 2.065.311.705.621 1.449.936 2.235.314.783.636 1.619.964 2.506.327.888.676 1.853 1.041 2.896l-2.339.001zm-2.625-7.504c-.049.141-.118.333-.213.576-.094.242-.2.521-.319.84-.121.317-.254.668-.402 1.051-.147.382-.299.783-.45 1.201h2.772c-.147-.42-.291-.822-.433-1.205a43.073 43.073 0 0 0-.396-1.053c-.125-.317-.233-.598-.33-.84a13.884 13.884 0 0 0-.229-.57z"/>', + 'format': '<path d="M10.5 2v1.5H12c.235 0 .401-.009.5 0 .008.088 0 .279 0 .5v2H14V3.437c0-.237-.01-.409-.031-.593-.022-.185-.067-.42-.25-.594s-.407-.2-.594-.219A5.693 5.693 0 0 0 12.5 2zm0-2L7.187 2.5 10.5 5zm.5 5.187L13.5 8.5 16 5.187zm-.958-.339h-2.03l-3.234 8.456c-.154.392-.336.994-.854 1.022v.518h2.744v-.518c-.644-.168-.658-.462-.434-1.036l.784-2.086h3.43l.854 2.086c.238.574.308.924-.406 1.036v.518h3.276v-.518c-.434-.056-.546-.364-.686-.728l-3.444-8.75M7.424 10l1.26-3.318L10 10H7.424M4.912.975h-1.63L.686 7.764c-.124.314-.27.798-.686.82V9h2.203v-.416c-.517-.135-.528-.37-.348-.832l.629-1.674h2.754l.685 1.674c.192.461.248.742-.325.832V9c1.73.137 1.837-.002 2.079-1L4.912.975M2.81 5.11l1.012-2.664L4.878 5.11H2.81"/>', + 'grip': '<path d="M14.656 5.156l-10 10 .688.688 10-10-.688-.688zm0 3l-7 7 .688.688 7-7-.688-.688zm0 3l-4 4 .688.688 4-4-.688-.688z"/>', + 'horizontalrule': '<path d="M2 2v1h12V2H2zm0 2v1h9V4H2zm0 2v1h12V6H2zm0 2v2h12V8H2z"/>', + 'image': '<path d="M.5 2.5v11h15v-11H.5zm1 1h13v9h-13v-9z"/><circle cx="4" cy="6" r="1.25"/><path d="M1 11h14v2H1z"/><path d="M5 12l2-4 2 4z"/><path d="M7 12l4-7 4 7z"/>', + 'indent': '<path d="M1 1h14v2H1zm5 4h9v2H6zm0 4h9v2H6zm-5 4h14v2H1zm4-5L1 5v6z"/>', + 'italic': '<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-weight="bold" font-size="15" font-style="italic">i</text>', + 'justify': '<path d="M1 1h14v2H1zm0 4h14v2H1zm0 4h14v2H1zm0 4h14v2H1z"/>', + 'left': '<path d="M1 1h14v2H1zm0 4h10v2H1zm0 4h14v2H1zm0 4h10v2H1z"/>', + 'link': '<path d="M2 4c-.625 0-1.009.438-1.188.75s-.269.63-.344.969c-.15.677-.219 1.476-.219 2.28s.068 1.605.219 2.282c.075.339.165.625.344.938s.563.78 1.188.78h4v-2H2.469c-.022-.065-.042-.06-.063-.155-.1-.447-.156-1.15-.156-1.844s.057-1.396.156-1.844c.02-.088.042-.092.063-.156H6V4H2zm8 0v2h3.531c.021.064.043.068.063.156.1.448.156 1.149.156 1.844s-.057 1.396-.156 1.844c-.021.096-.041.09-.063.156H10v2h4c.625 0 1.009-.47 1.188-.781s.269-.6.344-.938c.15-.678.219-1.476.219-2.281s-.068-1.604-.219-2.281c-.075-.34-.165-.656-.344-.97S14.625 4 14 4h-4zM5.719 7c-.523.074-.949.602-.875 1.125S5.477 9.074 6 9h4c.528.01 1-.472 1-1s-.472-1.007-1-1H6a.593.593 0 0 0-.188 0h-.093z"/>', + 'ltr': '<path d="M10.313 1.937c-.98 0-1.752.284-2.344.813-.592.529-.906 1.228-.906 2.094 0 .811.275 1.467.781 1.969.506.497 1.227.792 2.156.906V14h2V3h1v11h1V1.939zM2 4v8l4-4z"/>', + 'maximize': '<path d="M2 7l1.75-1.75-2-2L0 5V0h5L3.25 1.75l2 2L7 2v5H2zm9 9l1.75-1.75-2-2L9 14V9h5l-1.75 1.75 2 2L16 11v5h-5zm-6 0l-1.75-1.75 2-2L7 14V9H2l1.75 1.75-2 2L0 11v5h5zm6-16l1.75 1.75-2 2L9 2v5h5l-1.75-1.75 2-2L16 5V0h-5z"/>', + 'orderedlist': '<path d="M6 2h9v2H6zm0 5h9v2H6zm0 5h9v2H6zm-2.799.846q.392.1.594.352.205.25.205.636 0 .576-.441.877-.441.298-1.287.298-.298 0-.599-.05-.298-.046-.591-.142v-.77q.28.14.555.212.277.07.545.07.396 0 .607-.137.212-.138.212-.394 0-.265-.218-.4-.215-.137-.638-.137h-.4v-.644h.421q.376 0 .56-.116.185-.12.185-.36 0-.224-.18-.346-.178-.122-.505-.122-.242 0-.488.055-.246.054-.49.16v-.731q.295-.083.586-.125.29-.041.57-.041.756 0 1.13.249.375.246.375.744 0 .34-.179.558-.179.215-.529.304zm-.905-3.609H4v.734H1.186v-.734L2.599 7.99q.19-.172.28-.335.091-.163.091-.34 0-.272-.184-.438-.182-.166-.485-.166-.234 0-.511.101-.278.099-.594.296v-.851q.337-.112.667-.169.329-.06.645-.06.696 0 1.08.307.386.306.386.853 0 .317-.163.592-.164.272-.688.731l-.827.726zM1.228 4.276h.903V1.714l-.927.19V1.21l.922-.191h.971v3.258H4v.706H1.228v-.706z"/>', + 'outdent': '<path d="M1 1h14v2H1zm0 4h9v2H1zm0 4h9v2H1zm0 4h14v2H1zm10-5l4-3v6z"/>', + 'paste': '<path d="M4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5H6v2.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.436.436 0 0 0 0-.125.916.916 0 0 0-.031-.063v-.031a.749.749 0 0 0-.063-.063.749.749 0 0 0-.063-.063l-2.875-2.844a.498.498 0 0 0-.125-.156A.498.498 0 0 0 11.5 4H10V1.5a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0c-.239.045.032-.003 0 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.64.64 0 0 0-.062 0 .493.493 0 0 0-.094.031.474.474 0 0 0-.125.063l-.031.031-.031.031a.916.916 0 0 0-.063.031.47.47 0 0 0-.031.094l-.031.031A.506.506 0 0 0 6 4.5V11H2V2zm5 3h4v2.5a.5.5 0 0 0 .5.5H14v6H7v-2.406a.492.492 0 0 0 0-.094V5zm5 .688L13.313 7H12V5.688zM4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5V5h2.5a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0c-.239.045.032-.003 0 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.5.5 0 0 0-.5.5V11H2V2zm4.406 2A.5.5 0 0 0 6 4.5v10a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.331.331 0 0 0 0-.063v-.063a.916.916 0 0 0-.031-.063V7.28a.523.523 0 0 0-.094-.094l-.031-.031-2.875-2.844a.498.498 0 0 0-.125-.156A.503.503 0 0 0 11.5 4h-5a.492.492 0 0 0-.094 0c-.239.045.032-.003 0 0zM7 5h4v2.5a.5.5 0 0 0 .5.5H14v6H7V5zm5 .688L13.313 7H12V5.688zM8 12h5v1H8v-1zm0-2h5v1H8v-1zm0-2h5v1H8V8zm0-2h3v1H8V6z"/>', + 'pastetext': '<path d="M4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5H6v2.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.436.436 0 0 0 0-.125.916.916 0 0 0-.031-.063v-.031a.749.749 0 0 0-.063-.063.749.749 0 0 0-.063-.063l-2.875-2.844a.498.498 0 0 0-.125-.156A.498.498 0 0 0 11.5 4H10V1.5a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.64.64 0 0 0-.062 0 .493.493 0 0 0-.094.031.474.474 0 0 0-.125.063l-.031.031-.031.031a.916.916 0 0 0-.063.031.47.47 0 0 0-.031.094l-.031.031A.506.506 0 0 0 6 4.5V11H2V2zm5 3h4v2.5a.5.5 0 0 0 .5.5H14v6H7v-2.406a.492.492 0 0 0 0-.094V5zm5 .688L13.313 7H12V5.688zM4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5V5h2.5a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.5.5 0 0 0-.5.5V11H2V2zm4.406 2A.5.5 0 0 0 6 4.5v10a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.331.331 0 0 0 0-.063v-.062a.916.916 0 0 0-.031-.063v-.031a.523.523 0 0 0-.094-.094l-.031-.031-2.875-2.844a.498.498 0 0 0-.125-.156A.5.5 0 0 0 11.5 4h-5a.492.492 0 0 0-.094 0zM7 5h4v2.5a.5.5 0 0 0 .5.5H14v6H7V5zm5 .688L13.313 7H12V5.688z"/>', + 'print': '<path d="M4 1v3H1v8h2V6h10v6h2V4h-3V1zm1 1h6v2H5zM4 7v8h8V7zm1 1h6v6H5zm1 1v1h4V9zm0 2v1h4v-1z"/>', + 'quote': '<path d="M8 2.013c-1.998 0-3.818.382-5.188 1.125S.499 5.054.499 6.513c0 1.237.926 2.345 2.281 3.156s3.197 1.344 5.219 1.344c.344 0 .563.019.906 0l5.875 2.938c.377.18.854-.32.656-.688l-1.813-3.656c1.242-.79 1.875-2.014 1.875-3.094 0-1.46-.943-2.632-2.313-3.375S9.998 2.013 8 2.013z"/>', + 'redo': '<path d="M9 7l5-5v5z"/><path d="M9.553 2.205c1 .268 1.932.796 2.69 1.553l.706.707-1.414 1.414-.707-.707a3.995 3.995 0 0 0-3.863-1.035 3.995 3.995 0 0 0-2.828 2.828 3.995 3.995 0 0 0 1.035 3.863l.707.707-1.414 1.414-.707-.707a6.003 6.003 0 0 1-1.553-5.795 6.003 6.003 0 0 1 7.348-4.242z"/>', + 'removeformat': '<path d="M8.781 2l-.125.125L3.781 7l-.125.125-3 3-.313.313.25.344 3 4 .156.219h2.47l.125-.156 3-3 .313-.313 4.688-4.688.313-.313-.25-.344-3-4-.156-.188H8.781zm.407 1h.594l-4 4h-.594l4-4zm1.75.25l2.406 3.188-4.281 4.28-2.406-3.187 4.281-4.281z"/>', + 'right': '<path d="M1 1h14v2H1zm4 4h10v2H5zM1 9h14v2H1zm4 4h10v2H5z"/>', + 'rtl': '<path d="M5.344 2.001c-.98 0-1.783.284-2.375.813-.592.529-.875 1.227-.875 2.093 0 .811.244 1.467.75 1.969.506.497 1.227.792 2.156.906V14h2V3.001L8 3v11h1V2zM14 4l-4 4 4 4z"/>', + 'size': '<path d="M12.5.656L10 4h5L12.5.656zM4.594 4.5a49.476 49.476 0 0 0-.875 1.906c-.277.65-.581 1.334-.875 2.063-.286.729-.572 1.52-.875 2.344S1.338 12.53 1 13.5h2.094c.095-.313.2-.64.313-.97.121-.328.262-.64.375-.968h3.5c.113.329.231.64.344.969.121.329.217.656.313.969h2.188c-.338-.971-.666-1.864-.969-2.688s-.611-1.615-.906-2.344a56.045 56.045 0 0 0-.844-2.063c-.286-.66-.581-1.282-.875-1.906H4.594zM10 6l2.5 3.313L15 6h-5zm-4.5.53c.052.13.132.307.219.532.086.225.2.486.313.78.121.296.245.614.375.97s.268.734.406 1.125H4.25c.139-.391.245-.77.375-1.125.139-.355.293-.674.406-.97s.194-.555.281-.78c.087-.224.145-.401.188-.531z"/>', + 'source': '<path d="M4.937 3.939L1 8.499l3.937 4.564L6 12 3 8.499 6 5zm6.126 0L10 5.002l3 3.503-3 3.497 1.063 1.063L15 8.505z"/>', + 'strike': '<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-size="15" font-weight="bold">S</text><path d="M1 7v1h14V7H1z"/>', + 'subscript': '<path d="M11 10v1h3v1h-3v3h4v-1h-3v-1h3v-3zM1 3l3 5-3 5h2l3-5H4l3 5h2L6 8l3-5H7L4 8h2L3 3z"/>', + 'superscript': '<path d="M11 1v1h3v1h-3v3h4V5h-3V4h3V1zM1 3l3 5-3 5h2l3-5H4l3 5h2L6 8l3-5H7L4 8h2L3 3z"/>', + 'table': '<path d="M1 2h14v2H1zm0 2v10h14V4H1zm1 1h3.5v2H2V5zm4.5 0h3v2h-3V5zm4 0H14v2h-3.5V5zM2 8h3.5v2H2V8zm4.5 0h3v2h-3V8zm4 0H14v2h-3.5V8zM2 11h3.5v2H2v-2zm4.5 0h3v2h-3v-2zm4 0H14v2h-3.5v-2z"/>', + 'time': '<path d="M8 0C3 0 0 4 0 8s3 8 8 8 8-4 8-8-3-8-8-8zm0 2c3.461 0 6 2.539 6 6s-2.539 6-6 6c-3.46 0-6-2.539-6-6s2.54-6 6-6zM7 3v6l2.5 2L11 9.5 9 8V3z"/>', + 'underline': '<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-weight="bold" font-size="15" text-decoration="underline">U</text>', + 'undo': '<path d="M2 7h5L2 2z"/><path d="M6.447 2.205c-1 .268-1.932.796-2.69 1.553l-.706.707 1.414 1.414.707-.707a3.995 3.995 0 0 1 3.863-1.035 3.995 3.995 0 0 1 2.828 2.828 3.995 3.995 0 0 1-1.035 3.863l-.707.707 1.414 1.414.707-.707a6.003 6.003 0 0 0 1.553-5.795 6.003 6.003 0 0 0-7.348-4.242z"/>', + 'unlink': '<path d="M2 4c-.625 0-1.009.438-1.188.75s-.269.63-.344.969c-.15.677-.219 1.476-.219 2.28s.068 1.605.219 2.282c.075.339.165.625.344.938s.563.78 1.188.78h4v-2H2.469c-.022-.065-.042-.06-.063-.155-.1-.447-.156-1.15-.156-1.844s.057-1.396.156-1.844c.02-.088.042-.092.063-.156H6V4H2zm8 0v2h3.531c.021.064.043.068.063.156.1.448.156 1.149.156 1.844s-.057 1.396-.156 1.844c-.021.095-.041.09-.063.156H10v2h4c.625 0 1.009-.47 1.188-.781s.269-.6.344-.938c.15-.678.219-1.476.219-2.281s-.068-1.604-.219-2.281c-.075-.34-.165-.656-.344-.97S14.625 4 14 4h-4z"/>', + 'youtube': '<path d="M2 2C1 2 0 3 0 4v8c0 1 1 2 2 2h12c1 0 2-1 2-2V4c0-1-1-2-2-2H2zm4 3l6 3-6 3V5z"/>' + }; + + sceditor.icons.monocons = function () { + var nodes = {}; + var colorPath; + + return { + create: function (command) { + if (command in icons) { + nodes[command] = sceditor.dom.parseHTML( + '<svg xmlns="http://www.w3.org/2000/svg" ' + + 'viewbox="0 0 16 16" unselectable="on">' + + icons[command] + + '</svg>' + ).firstChild; + + if (command === 'color') { + colorPath = nodes[command].querySelector('.sce-color'); + } + } + + return nodes[command]; + }, + update: function (isSourceMode, currentNode) { + if (colorPath) { + var color = 'inherit'; + + if (!isSourceMode && currentNode) { + color = currentNode.ownerDocument + .queryCommandValue('forecolor'); + } + + dom.css(colorPath, 'fill', color); + } + }, + rtl: function (isRtl) { + var gripNode = nodes.grip; + + if (gripNode) { + var transform = isRtl ? 'scaleX(-1)' : ''; + + dom.css(gripNode, 'transform', transform); + dom.css(gripNode, 'msTransform', transform); + dom.css(gripNode, 'webkitTransform', transform); + } + } + }; + }; + + sceditor.icons.monocons.icons = icons; +})(document, sceditor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/jquery.sceditor.bbcode.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,11844 @@ +(function ($) { + 'use strict'; + + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var $__default = /*#__PURE__*/_interopDefaultLegacy($); + + /** + * Check if the passed argument is the + * the passed type. + * + * @param {string} type + * @param {*} arg + * @returns {boolean} + */ + function isTypeof(type, arg) { + return typeof arg === type; + } + + /** + * @type {function(*): boolean} + */ + var isString = isTypeof.bind(null, 'string'); + + /** + * @type {function(*): boolean} + */ + var isUndefined = isTypeof.bind(null, 'undefined'); + + /** + * @type {function(*): boolean} + */ + var isFunction = isTypeof.bind(null, 'function'); + + /** + * @type {function(*): boolean} + */ + var isNumber = isTypeof.bind(null, 'number'); + + + /** + * Returns true if an object has no keys + * + * @param {!Object} obj + * @returns {boolean} + */ + function isEmptyObject(obj) { + return !Object.keys(obj).length; + } + + /** + * Extends the first object with any extra objects passed + * + * If the first argument is boolean and set to true + * it will extend child arrays and objects recursively. + * + * @param {!Object|boolean} targetArg + * @param {...Object} source + * @return {Object} + */ + function extend(targetArg, sourceArg) { + var isTargetBoolean = targetArg === !!targetArg; + var i = isTargetBoolean ? 2 : 1; + var target = isTargetBoolean ? sourceArg : targetArg; + var isDeep = isTargetBoolean ? targetArg : false; + + function isObject(value) { + return value !== null && typeof value === 'object' && + Object.getPrototypeOf(value) === Object.prototype; + } + + for (; i < arguments.length; i++) { + var source = arguments[i]; + + // Copy all properties for jQuery compatibility + /* eslint guard-for-in: off */ + for (var key in source) { + var targetValue = target[key]; + var value = source[key]; + + // Skip undefined values to match jQuery + if (isUndefined(value)) { + continue; + } + + // Skip special keys to prevent prototype pollution + if (key === '__proto__' || key === 'constructor') { + continue; + } + + var isValueObject = isObject(value); + var isValueArray = Array.isArray(value); + + if (isDeep && (isValueObject || isValueArray)) { + // Can only merge if target type matches otherwise create + // new target to merge into + var isSameType = isObject(targetValue) === isValueObject && + Array.isArray(targetValue) === isValueArray; + + target[key] = extend( + true, + isSameType ? targetValue : (isValueArray ? [] : {}), + value + ); + } else { + target[key] = value; + } + } + } + + return target; + } + + /** + * Removes an item from the passed array + * + * @param {!Array} arr + * @param {*} item + */ + function arrayRemove(arr, item) { + var i = arr.indexOf(item); + + if (i > -1) { + arr.splice(i, 1); + } + } + + /** + * Iterates over an array or object + * + * @param {!Object|Array} obj + * @param {function(*, *)} fn + */ + function each(obj, fn) { + if (Array.isArray(obj) || 'length' in obj && isNumber(obj.length)) { + for (var i = 0; i < obj.length; i++) { + fn(i, obj[i]); + } + } else { + Object.keys(obj).forEach(function (key) { + fn(key, obj[key]); + }); + } + } + + /** + * Cache of camelCase CSS property names + * @type {Object<string, string>} + */ + var cssPropertyNameCache = {}; + + /** + * Node type constant for element nodes + * + * @type {number} + */ + var ELEMENT_NODE = 1; + + /** + * Node type constant for text nodes + * + * @type {number} + */ + var TEXT_NODE = 3; + + /** + * Node type constant for comment nodes + * + * @type {number} + */ + var COMMENT_NODE = 8; + + function toFloat(value) { + value = parseFloat(value); + + return isFinite(value) ? value : 0; + } + + /** + * Creates an element with the specified attributes + * + * Will create it in the current document unless context + * is specified. + * + * @param {!string} tag + * @param {!Object<string, string>} [attributes] + * @param {!Document} [context] + * @returns {!HTMLElement} + */ + function createElement(tag, attributes, context) { + var node = (context || document).createElement(tag); + + each(attributes || {}, function (key, value) { + if (key === 'style') { + node.style.cssText = value; + } else if (key in node) { + node[key] = value; + } else { + node.setAttribute(key, value); + } + }); + + return node; + } + + /** + * Gets the first parent node that matches the selector + * + * @param {!HTMLElement} node + * @param {!string} [selector] + * @returns {HTMLElement|undefined} + */ + function parent(node, selector) { + var parent = node || {}; + + while ((parent = parent.parentNode) && !/(9|11)/.test(parent.nodeType)) { + if (!selector || is(parent, selector)) { + return parent; + } + } + } + + /** + * Checks the passed node and all parents and + * returns the first matching node if any. + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {HTMLElement|undefined} + */ + function closest(node, selector) { + return is(node, selector) ? node : parent(node, selector); + } + + /** + * Removes the node from the DOM + * + * @param {!HTMLElement} node + */ + function remove(node) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + } + + /** + * Appends child to parent node + * + * @param {!HTMLElement} node + * @param {!HTMLElement} child + */ + function appendChild(node, child) { + node.appendChild(child); + } + + /** + * Finds any child nodes that match the selector + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {NodeList} + */ + function find(node, selector) { + return node.querySelectorAll(selector); + } + + /** + * For on() and off() if to add/remove the event + * to the capture phase + * + * @type {boolean} + */ + var EVENT_CAPTURE = true; + + /** + * Adds an event listener for the specified events. + * + * Events should be a space separated list of events. + * + * If selector is specified the handler will only be + * called when the event target matches the selector. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see off() + */ + // eslint-disable-next-line max-params + function on(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector] || function (e) { + var target = e.target; + while (target && target !== node) { + if (is(target, selector)) { + fn.call(target, e); + return; + } + + target = target.parentNode; + } + }; + + fn['_sce-event-' + event + selector] = handler; + } else { + handler = selector; + capture = fn; + } + + node.addEventListener(event, handler, capture || false); + }); + } + + /** + * Removes an event listener for the specified events. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see on() + */ + // eslint-disable-next-line max-params + function off(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector]; + } else { + handler = selector; + capture = fn; + } + + node.removeEventListener(event, handler, capture || false); + }); + } + + /** + * If only attr param is specified it will get + * the value of the attr param. + * + * If value is specified but null the attribute + * will be removed otherwise the attr value will + * be set to the passed value. + * + * @param {!HTMLElement} node + * @param {!string} attr + * @param {?string} [value] + */ + function attr(node, attr, value) { + if (arguments.length < 3) { + return node.getAttribute(attr); + } + + // eslint-disable-next-line eqeqeq, no-eq-null + if (value == null) { + removeAttr(node, attr); + } else { + node.setAttribute(attr, value); + } + } + + /** + * Removes the specified attribute + * + * @param {!HTMLElement} node + * @param {!string} attr + */ + function removeAttr(node, attr) { + node.removeAttribute(attr); + } + + /** + * Sets the passed elements display to none + * + * @param {!HTMLElement} node + */ + function hide(node) { + css(node, 'display', 'none'); + } + + /** + * Sets the passed elements display to default + * + * @param {!HTMLElement} node + */ + function show(node) { + css(node, 'display', ''); + } + + /** + * Toggles an elements visibility + * + * @param {!HTMLElement} node + */ + function toggle(node) { + if (isVisible(node)) { + hide(node); + } else { + show(node); + } + } + + /** + * Gets a computed CSS values or sets an inline CSS value + * + * Rules should be in camelCase format and not + * hyphenated like CSS properties. + * + * @param {!HTMLElement} node + * @param {!Object|string} rule + * @param {string|number} [value] + * @return {string|number|undefined} + */ + function css(node, rule, value) { + if (arguments.length < 3) { + if (isString(rule)) { + return node.nodeType === 1 ? getComputedStyle(node)[rule] : null; + } + + each(rule, function (key, value) { + css(node, key, value); + }); + } else { + // isNaN returns false for null, false and empty strings + // so need to check it's truthy or 0 + var isNumeric = (value || value === 0) && !isNaN(value); + node.style[rule] = isNumeric ? value + 'px' : value; + } + } + + + /** + * Gets or sets the data attributes on a node + * + * Unlike the jQuery version this only stores data + * in the DOM attributes which means only strings + * can be stored. + * + * @param {Node} node + * @param {string} [key] + * @param {string} [value] + * @return {Object|undefined} + */ + function data(node, key, value) { + var argsLength = arguments.length; + var data = {}; + + if (node.nodeType === ELEMENT_NODE) { + if (argsLength === 1) { + each(node.attributes, function (_, attr) { + if (/^data\-/i.test(attr.name)) { + data[attr.name.substr(5)] = attr.value; + } + }); + + return data; + } + + if (argsLength === 2) { + return attr(node, 'data-' + key); + } + + attr(node, 'data-' + key, String(value)); + } + } + + /** + * Checks if node matches the given selector. + * + * @param {?HTMLElement} node + * @param {string} selector + * @returns {boolean} + */ + function is(node, selector) { + var result = false; + + if (node && node.nodeType === ELEMENT_NODE) { + result = (node.matches || node.msMatchesSelector || + node.webkitMatchesSelector).call(node, selector); + } + + return result; + } + + + /** + * Returns true if node contains child otherwise false. + * + * This differs from the DOM contains() method in that + * if node and child are equal this will return false. + * + * @param {!Node} node + * @param {HTMLElement} child + * @returns {boolean} + */ + function contains(node, child) { + return node !== child && node.contains && node.contains(child); + } + + /** + * @param {Node} node + * @param {string} [selector] + * @returns {?HTMLElement} + */ + function previousElementSibling(node, selector) { + var prev = node.previousElementSibling; + + if (selector && prev) { + return is(prev, selector) ? prev : null; + } + + return prev; + } + + /** + * @param {!Node} node + * @param {!Node} refNode + * @returns {Node} + */ + function insertBefore(node, refNode) { + return refNode.parentNode.insertBefore(node, refNode); + } + + /** + * @param {?HTMLElement} node + * @returns {!Array.<string>} + */ + function classes(node) { + return node.className.trim().split(/\s+/); + } + + /** + * @param {?HTMLElement} node + * @param {string} className + * @returns {boolean} + */ + function hasClass(node, className) { + return is(node, '.' + className); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function addClass(node, className) { + var classList = classes(node); + + if (classList.indexOf(className) < 0) { + classList.push(className); + } + + node.className = classList.join(' '); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function removeClass(node, className) { + var classList = classes(node); + + arrayRemove(classList, className); + + node.className = classList.join(' '); + } + + /** + * Toggles a class on node. + * + * If state is specified and is truthy it will add + * the class. + * + * If state is specified and is falsey it will remove + * the class. + * + * @param {HTMLElement} node + * @param {string} className + * @param {boolean} [state] + */ + function toggleClass(node, className, state) { + state = isUndefined(state) ? !hasClass(node, className) : state; + + if (state) { + addClass(node, className); + } else { + removeClass(node, className); + } + } + + /** + * Gets or sets the width of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function width(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingLeft) + toFloat(cs.paddingRight); + var border = toFloat(cs.borderLeftWidth) + toFloat(cs.borderRightWidth); + + return node.offsetWidth - padding - border; + } + + css(node, 'width', value); + } + + /** + * Gets or sets the height of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function height(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingTop) + toFloat(cs.paddingBottom); + var border = toFloat(cs.borderTopWidth) + toFloat(cs.borderBottomWidth); + + return node.offsetHeight - padding - border; + } + + css(node, 'height', value); + } + + /** + * Triggers a custom event with the specified name and + * sets the detail property to the data object passed. + * + * @param {HTMLElement} node + * @param {string} eventName + * @param {Object} [data] + */ + function trigger(node, eventName, data) { + var event; + + if (isFunction(window.CustomEvent)) { + event = new CustomEvent(eventName, { + bubbles: true, + cancelable: true, + detail: data + }); + } else { + event = node.ownerDocument.createEvent('CustomEvent'); + event.initCustomEvent(eventName, true, true, data); + } + + node.dispatchEvent(event); + } + + /** + * Returns if a node is visible. + * + * @param {HTMLElement} + * @returns {boolean} + */ + function isVisible(node) { + return !!node.getClientRects().length; + } + + /** + * Convert CSS property names into camel case + * + * @param {string} string + * @returns {string} + */ + function camelCase(string) { + return string + .replace(/^-ms-/, 'ms-') + .replace(/-(\w)/g, function (match, char) { + return char.toUpperCase(); + }); + } + + + /** + * Loop all child nodes of the passed node + * + * The function should accept 1 parameter being the node. + * If the function returns false the loop will be exited. + * + * @param {HTMLElement} node + * @param {function} func Callback which is called with every + * child node as the first argument. + * @param {boolean} innermostFirst If the innermost node should be passed + * to the function before it's parents. + * @param {boolean} siblingsOnly If to only traverse the nodes siblings + * @param {boolean} [reverse=false] If to traverse the nodes in reverse + */ + // eslint-disable-next-line max-params + function traverse(node, func, innermostFirst, siblingsOnly, reverse) { + node = reverse ? node.lastChild : node.firstChild; + + while (node) { + var next = reverse ? node.previousSibling : node.nextSibling; + + if ( + (!innermostFirst && func(node) === false) || + (!siblingsOnly && traverse( + node, func, innermostFirst, siblingsOnly, reverse + ) === false) || + (innermostFirst && func(node) === false) + ) { + return false; + } + + node = next; + } + } + + /** + * Like traverse but loops in reverse + * @see traverse + */ + function rTraverse(node, func, innermostFirst, siblingsOnly) { + traverse(node, func, innermostFirst, siblingsOnly, true); + } + + /** + * Parses HTML into a document fragment + * + * @param {string} html + * @param {Document} [context] + * @since 1.4.4 + * @return {DocumentFragment} + */ + function parseHTML(html, context) { + context = context || document; + + var ret = context.createDocumentFragment(); + var tmp = createElement('div', {}, context); + + tmp.innerHTML = html; + + while (tmp.firstChild) { + appendChild(ret, tmp.firstChild); + } + + return ret; + } + + /** + * Checks if an element has any styling. + * + * It has styling if it is not a plain <div> or <p> or + * if it has a class, style attribute or data. + * + * @param {HTMLElement} elm + * @return {boolean} + * @since 1.4.4 + */ + function hasStyling(node) { + return node && (!is(node, 'p,div') || node.className || + attr(node, 'style') || !isEmptyObject(data(node))); + } + + /** + * Converts an element from one type to another. + * + * For example it can convert the element <b> to <strong> + * + * @param {HTMLElement} element + * @param {string} toTagName + * @return {HTMLElement} + * @since 1.4.4 + */ + function convertElement(element, toTagName) { + var newElement = createElement(toTagName, {}, element.ownerDocument); + + each(element.attributes, function (_, attribute) { + // Some browsers parse invalid attributes names like + // 'size"2' which throw an exception when set, just + // ignore these. + try { + attr(newElement, attribute.name, attribute.value); + } catch (ex) {} + }); + + while (element.firstChild) { + appendChild(newElement, element.firstChild); + } + + element.parentNode.replaceChild(newElement, element); + + return newElement; + } + + /** + * List of block level elements separated by bars (|) + * + * @type {string} + */ + var blockLevelList = '|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|' + + 'form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|' + + 'details|section|article|aside|nav|main|header|hgroup|footer|fieldset|' + + 'dl|dt|dd|figure|figcaption|'; + + /** + * List of elements that do not allow children separated by bars (|) + * + * @param {Node} node + * @return {boolean} + * @since 1.4.5 + */ + function canHaveChildren(node) { + // 1 = Element + // 9 = Document + // 11 = Document Fragment + if (!/11?|9/.test(node.nodeType)) { + return false; + } + + // List of empty HTML tags separated by bar (|) character. + // Source: http://www.w3.org/TR/html4/index/elements.html + // Source: http://www.w3.org/TR/html5/syntax.html#void-elements + return ('|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr' + + '|isindex|link|meta|param|command|embed|keygen|source|track|' + + 'object|').indexOf('|' + node.nodeName.toLowerCase() + '|') < 0; + } + + /** + * Checks if an element is inline + * + * @param {HTMLElement} elm + * @param {boolean} [includeCodeAsBlock=false] + * @return {boolean} + */ + function isInline(elm, includeCodeAsBlock) { + var tagName, + nodeType = (elm || {}).nodeType || TEXT_NODE; + + if (nodeType !== ELEMENT_NODE) { + return nodeType === TEXT_NODE; + } + + tagName = elm.tagName.toLowerCase(); + + if (tagName === 'code') { + return !includeCodeAsBlock; + } + + return blockLevelList.indexOf('|' + tagName + '|') < 0; + } + + /** + * Copy the CSS from 1 node to another. + * + * Only copies CSS defined on the element e.g. style attr. + * + * @param {HTMLElement} from + * @param {HTMLElement} to + * @deprecated since v3.1.0 + */ + function copyCSS(from, to) { + if (to.style && from.style) { + to.style.cssText = from.style.cssText + to.style.cssText; + } + } + + /** + * Checks if a DOM node is empty + * + * @param {Node} node + * @returns {boolean} + */ + function isEmpty(node) { + if (node.lastChild && isEmpty(node.lastChild)) { + remove(node.lastChild); + } + + return node.nodeType === 3 ? !node.nodeValue : + (canHaveChildren(node) && !node.childNodes.length); + } + + /** + * Fixes block level elements inside in inline elements. + * + * Also fixes invalid list nesting by placing nested lists + * inside the previous li tag or wrapping them in an li tag. + * + * @param {HTMLElement} node + */ + function fixNesting(node) { + traverse(node, function (node) { + var list = 'ul,ol', + isBlock = !isInline(node, true) && node.nodeType !== COMMENT_NODE, + parent = node.parentNode; + + // Any blocklevel element inside an inline element needs fixing. + // Also <p> tags that contain blocks should be fixed + if (isBlock && (isInline(parent, true) || parent.tagName === 'P')) { + // Find the last inline parent node + var lastInlineParent = node; + while (isInline(lastInlineParent.parentNode, true) || + lastInlineParent.parentNode.tagName === 'P') { + lastInlineParent = lastInlineParent.parentNode; + } + + var before = extractContents(lastInlineParent, node); + var middle = node; + + // Clone inline styling and apply it to the blocks children + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + while (middle.firstChild) { + appendChild(clone, middle.firstChild); + } + + appendChild(middle, clone); + } + parent = parent.parentNode; + } + + insertBefore(middle, lastInlineParent); + if (!isEmpty(before)) { + insertBefore(before, middle); + } + if (isEmpty(lastInlineParent)) { + remove(lastInlineParent); + } + } + + // Fix invalid nested lists which should be wrapped in an li tag + if (isBlock && is(node, list) && is(node.parentNode, list)) { + var li = previousElementSibling(node, 'li'); + + if (!li) { + li = createElement('li'); + insertBefore(li, node); + } + + appendChild(li, node); + } + }); + } + + /** + * Finds the common parent of two nodes + * + * @param {!HTMLElement} node1 + * @param {!HTMLElement} node2 + * @return {?HTMLElement} + */ + function findCommonAncestor(node1, node2) { + while ((node1 = node1.parentNode)) { + if (contains(node1, node2)) { + return node1; + } + } + } + + /** + * @param {?Node} + * @param {boolean} [previous=false] + * @returns {?Node} + */ + function getSibling(node, previous) { + if (!node) { + return null; + } + + return (previous ? node.previousSibling : node.nextSibling) || + getSibling(node.parentNode, previous); + } + + /** + * Removes unused whitespace from the root and all it's children. + * + * @param {!HTMLElement} root + * @since 1.4.3 + */ + function removeWhiteSpace(root) { + var nodeValue, nodeType, next, previous, previousSibling, + nextNode, trimStart, + cssWhiteSpace = css(root, 'whiteSpace'), + // Preserve newlines if is pre-line + preserveNewLines = /line$/i.test(cssWhiteSpace), + node = root.firstChild; + + // Skip pre & pre-wrap with any vendor prefix + if (/pre(\-wrap)?$/i.test(cssWhiteSpace)) { + return; + } + + while (node) { + nextNode = node.nextSibling; + nodeValue = node.nodeValue; + nodeType = node.nodeType; + + if (nodeType === ELEMENT_NODE && node.firstChild) { + removeWhiteSpace(node); + } + + if (nodeType === TEXT_NODE) { + next = getSibling(node); + previous = getSibling(node, true); + trimStart = false; + + while (hasClass(previous, 'sceditor-ignore')) { + previous = getSibling(previous, true); + } + + // If previous sibling isn't inline or is a textnode that + // ends in whitespace, time the start whitespace + if (isInline(node) && previous) { + previousSibling = previous; + + while (previousSibling.lastChild) { + previousSibling = previousSibling.lastChild; + + // eslint-disable-next-line max-depth + while (hasClass(previousSibling, 'sceditor-ignore')) { + previousSibling = getSibling(previousSibling, true); + } + } + + trimStart = previousSibling.nodeType === TEXT_NODE ? + /[\t\n\r ]$/.test(previousSibling.nodeValue) : + !isInline(previousSibling); + } + + // Clear zero width spaces + nodeValue = nodeValue.replace(/\u200B/g, ''); + + // Strip leading whitespace + if (!previous || !isInline(previous) || trimStart) { + nodeValue = nodeValue.replace( + preserveNewLines ? /^[\t ]+/ : /^[\t\n\r ]+/, + '' + ); + } + + // Strip trailing whitespace + if (!next || !isInline(next)) { + nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+$/ : /[\t\n\r ]+$/, + '' + ); + } + + // Remove empty text nodes + if (!nodeValue.length) { + remove(node); + } else { + node.nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+/g : /[\t\n\r ]+/g, + ' ' + ); + } + } + + node = nextNode; + } + } + + /** + * Extracts all the nodes between the start and end nodes + * + * @param {HTMLElement} startNode The node to start extracting at + * @param {HTMLElement} endNode The node to stop extracting at + * @return {DocumentFragment} + */ + function extractContents(startNode, endNode) { + var range = startNode.ownerDocument.createRange(); + + range.setStartBefore(startNode); + range.setEndAfter(endNode); + + return range.extractContents(); + } + + /** + * Gets the offset position of an element + * + * @param {HTMLElement} node + * @return {Object} An object with left and top properties + */ + function getOffset(node) { + var left = 0, + top = 0; + + while (node) { + left += node.offsetLeft; + top += node.offsetTop; + node = node.offsetParent; + } + + return { + left: left, + top: top + }; + } + + /** + * Gets the value of a CSS property from the elements style attribute + * + * @param {HTMLElement} elm + * @param {string} property + * @return {string} + */ + function getStyle(elm, property) { + var styleValue, + elmStyle = elm.style; + + if (!cssPropertyNameCache[property]) { + cssPropertyNameCache[property] = camelCase(property); + } + + property = cssPropertyNameCache[property]; + styleValue = elmStyle[property]; + + // Add an exception for text-align + if ('textAlign' === property) { + styleValue = styleValue || css(elm, property); + + if (css(elm.parentNode, property) === styleValue || + css(elm, 'display') !== 'block' || is(elm, 'hr,th')) { + return ''; + } + } + + return styleValue; + } + + /** + * Tests if an element has a style. + * + * If values are specified it will check that the styles value + * matches one of the values + * + * @param {HTMLElement} elm + * @param {string} property + * @param {string|array} [values] + * @return {boolean} + */ + function hasStyle(elm, property, values) { + var styleValue = getStyle(elm, property); + + if (!styleValue) { + return false; + } + + return !values || styleValue === values || + (Array.isArray(values) && values.indexOf(styleValue) > -1); + } + + /** + * Returns true if both nodes have the same number of inline styles and all the + * inline styles have matching values + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function stylesMatch(nodeA, nodeB) { + var i = nodeA.style.length; + if (i !== nodeB.style.length) { + return false; + } + + while (i--) { + var prop = nodeA.style[i]; + if (nodeA.style[prop] !== nodeB.style[prop]) { + return false; + } + } + + return true; + } + + /** + * Returns true if both nodes have the same number of attributes and all the + * attribute values match + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function attributesMatch(nodeA, nodeB) { + var i = nodeA.attributes.length; + if (i !== nodeB.attributes.length) { + return false; + } + + while (i--) { + var prop = nodeA.attributes[i]; + var notMatches = prop.name === 'style' ? + !stylesMatch(nodeA, nodeB) : + prop.value !== attr(nodeB, prop.name); + + if (notMatches) { + return false; + } + } + + return true; + } + + /** + * Removes an element placing its children in its place + * + * @param {HTMLElement} node + */ + function removeKeepChildren(node) { + while (node.firstChild) { + insertBefore(node.firstChild, node); + } + + remove(node); + } + + /** + * Merges inline styles and tags with parents where possible + * + * @param {Node} node + * @since 3.1.0 + */ + function merge(node) { + if (node.nodeType !== ELEMENT_NODE) { + return; + } + + var parent = node.parentNode; + var tagName = node.tagName; + var mergeTags = /B|STRONG|EM|SPAN|FONT/; + + // Merge children (in reverse as children can be removed) + var i = node.childNodes.length; + while (i--) { + merge(node.childNodes[i]); + } + + // Should only merge inline tags + if (!isInline(node)) { + return; + } + + // Remove any inline styles that match the parent style + i = node.style.length; + while (i--) { + var prop = node.style[i]; + if (css(parent, prop) === css(node, prop)) { + node.style.removeProperty(prop); + } + } + + // Can only remove / merge tags if no inline styling left. + // If there is any inline style left then it means it at least partially + // doesn't match the parent style so must stay + if (!node.style.length) { + removeAttr(node, 'style'); + + // Remove font attributes if match parent + if (tagName === 'FONT') { + if (css(node, 'fontFamily').toLowerCase() === + css(parent, 'fontFamily').toLowerCase()) { + removeAttr(node, 'face'); + } + + if (css(node, 'color') === css(parent, 'color')) { + removeAttr(node, 'color'); + } + + if (css(node, 'fontSize') === css(parent, 'fontSize')) { + removeAttr(node, 'size'); + } + } + + // Spans and font tags with no attributes can be safely removed + if (!node.attributes.length && /SPAN|FONT/.test(tagName)) { + removeKeepChildren(node); + } else if (mergeTags.test(tagName)) { + var isBold = /B|STRONG/.test(tagName); + var isItalic = tagName === 'EM'; + + while (parent && isInline(parent) && + (!isBold || /bold|700/i.test(css(parent, 'fontWeight'))) && + (!isItalic || css(parent, 'fontStyle') === 'italic')) { + + // Remove if parent match + if ((parent.tagName === tagName || + (isBold && /B|STRONG/.test(parent.tagName))) && + attributesMatch(parent, node)) { + removeKeepChildren(node); + break; + } + + parent = parent.parentNode; + } + } + } + + // Merge siblings if attributes, including inline styles, match + var next = node.nextSibling; + if (next && next.tagName === tagName && attributesMatch(next, node)) { + appendChild(node, next); + removeKeepChildren(next); + } + } + + /** + * Default options for SCEditor + * @type {Object} + */ + var defaultOptions = { + /** @lends jQuery.sceditor.defaultOptions */ + /** + * Toolbar buttons order and groups. Should be comma separated and + * have a bar | to separate groups + * + * @type {string} + */ + toolbar: 'bold,italic,underline,strike,subscript,superscript|' + + 'left,center,right,justify|font,size,color,removeformat|' + + 'cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|' + + 'table|code,quote|horizontalrule,image,email,link,unlink|' + + 'emoticon,youtube,date,time|ltr,rtl|print,maximize,source', + + /** + * Comma separated list of commands to excludes from the toolbar + * + * @type {string} + */ + toolbarExclude: null, + + /** + * Stylesheet to include in the WYSIWYG editor. This is what will style + * the WYSIWYG elements + * + * @type {string} + */ + style: 'jquery.sceditor.default.css', + + /** + * Comma separated list of fonts for the font selector + * + * @type {string} + */ + fonts: 'Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,' + + 'Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana', + + /** + * Colors should be comma separated and have a bar | to signal a new + * column. + * + * If null the colors will be auto generated. + * + * @type {string} + */ + colors: '#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|' + + '#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|' + + '#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|' + + '#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|' + + '#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|' + + '#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|' + + '#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|' + + '#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef', + + /** + * The locale to use. + * @type {string} + */ + locale: attr(document.documentElement, 'lang') || 'en', + + /** + * The Charset to use + * @type {string} + */ + charset: 'utf-8', + + /** + * Compatibility mode for emoticons. + * + * Helps if you have emoticons such as :/ which would put an emoticon + * inside http:// + * + * This mode requires emoticons to be surrounded by whitespace or end of + * line chars. This mode has limited As You Type emoticon conversion + * support. It will not replace AYT for end of line chars, only + * emoticons surrounded by whitespace. They will still be replaced + * correctly when loaded just not AYT. + * + * @type {boolean} + */ + emoticonsCompat: false, + + /** + * If to enable emoticons. Can be changes at runtime using the + * emoticons() method. + * + * @type {boolean} + * @since 1.4.2 + */ + emoticonsEnabled: true, + + /** + * Emoticon root URL + * + * @type {string} + */ + emoticonsRoot: '', + emoticons: { + dropdown: { + ':)': 'emoticons/smile.png', + ':angel:': 'emoticons/angel.png', + ':angry:': 'emoticons/angry.png', + '8-)': 'emoticons/cool.png', + ':\'(': 'emoticons/cwy.png', + ':ermm:': 'emoticons/ermm.png', + ':D': 'emoticons/grin.png', + '<3': 'emoticons/heart.png', + ':(': 'emoticons/sad.png', + ':O': 'emoticons/shocked.png', + ':P': 'emoticons/tongue.png', + ';)': 'emoticons/wink.png' + }, + more: { + ':alien:': 'emoticons/alien.png', + ':blink:': 'emoticons/blink.png', + ':blush:': 'emoticons/blush.png', + ':cheerful:': 'emoticons/cheerful.png', + ':devil:': 'emoticons/devil.png', + ':dizzy:': 'emoticons/dizzy.png', + ':getlost:': 'emoticons/getlost.png', + ':happy:': 'emoticons/happy.png', + ':kissing:': 'emoticons/kissing.png', + ':ninja:': 'emoticons/ninja.png', + ':pinch:': 'emoticons/pinch.png', + ':pouty:': 'emoticons/pouty.png', + ':sick:': 'emoticons/sick.png', + ':sideways:': 'emoticons/sideways.png', + ':silly:': 'emoticons/silly.png', + ':sleeping:': 'emoticons/sleeping.png', + ':unsure:': 'emoticons/unsure.png', + ':woot:': 'emoticons/w00t.png', + ':wassat:': 'emoticons/wassat.png' + }, + hidden: { + ':whistling:': 'emoticons/whistling.png', + ':love:': 'emoticons/wub.png' + } + }, + + /** + * Width of the editor. Set to null for automatic with + * + * @type {?number} + */ + width: null, + + /** + * Height of the editor including toolbar. Set to null for automatic + * height + * + * @type {?number} + */ + height: null, + + /** + * If to allow the editor to be resized + * + * @type {boolean} + */ + resizeEnabled: true, + + /** + * Min resize to width, set to null for half textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinWidth: null, + /** + * Min resize to height, set to null for half textarea height or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinHeight: null, + /** + * Max resize to height, set to null for double textarea height or -1 + * for unlimited + * + * @type {?number} + */ + resizeMaxHeight: null, + /** + * Max resize to width, set to null for double textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMaxWidth: null, + /** + * If resizing by height is enabled + * + * @type {boolean} + */ + resizeHeight: true, + /** + * If resizing by width is enabled + * + * @type {boolean} + */ + resizeWidth: true, + + /** + * Date format, will be overridden if locale specifies one. + * + * The words year, month and day will be replaced with the users current + * year, month and day. + * + * @type {string} + */ + dateFormat: 'year-month-day', + + /** + * Element to inset the toolbar into. + * + * @type {HTMLElement} + */ + toolbarContainer: null, + + /** + * If to enable paste filtering. This is currently experimental, please + * report any issues. + * + * @type {boolean} + */ + enablePasteFiltering: false, + + /** + * If to completely disable pasting into the editor + * + * @type {boolean} + */ + disablePasting: false, + + /** + * If the editor is read only. + * + * @type {boolean} + */ + readOnly: false, + + /** + * If to set the editor to right-to-left mode. + * + * If set to null the direction will be automatically detected. + * + * @type {boolean} + */ + rtl: false, + + /** + * If to auto focus the editor on page load + * + * @type {boolean} + */ + autofocus: false, + + /** + * If to auto focus the editor to the end of the content + * + * @type {boolean} + */ + autofocusEnd: true, + + /** + * If to auto expand the editor to fix the content + * + * @type {boolean} + */ + autoExpand: false, + + /** + * If to auto update original textbox on blur + * + * @type {boolean} + */ + autoUpdate: false, + + /** + * If to enable the browsers built in spell checker + * + * @type {boolean} + */ + spellcheck: true, + + /** + * If to run the source editor when there is no WYSIWYG support. Only + * really applies to mobile OS's. + * + * @type {boolean} + */ + runWithoutWysiwygSupport: false, + + /** + * If to load the editor in source mode and still allow switching + * between WYSIWYG and source mode + * + * @type {boolean} + */ + startInSourceMode: false, + + /** + * Optional ID to give the editor. + * + * @type {string} + */ + id: null, + + /** + * Comma separated list of plugins + * + * @type {string} + */ + plugins: '', + + /** + * z-index to set the editor container to. Needed for jQuery UI dialog. + * + * @type {?number} + */ + zIndex: null, + + /** + * If to trim the BBCode. Removes any spaces at the start and end of the + * BBCode string. + * + * @type {boolean} + */ + bbcodeTrim: false, + + /** + * If to disable removing block level elements by pressing backspace at + * the start of them + * + * @type {boolean} + */ + disableBlockRemove: false, + + /** + * Array of allowed URL (should be either strings or regex) for iframes. + * + * If it's a string then iframes where the start of the src matches the + * specified string will be allowed. + * + * If it's a regex then iframes where the src matches the regex will be + * allowed. + * + * @type {Array} + */ + allowedIframeUrls: [], + + /** + * BBCode parser options, only applies if using the editor in BBCode + * mode. + * + * See SCEditor.BBCodeParser.defaults for list of valid options + * + * @type {Object} + */ + parserOptions: { }, + + /** + * CSS that will be added to the to dropdown menu (eg. z-index) + * + * @type {Object} + */ + dropDownCss: { } + }; + + // Must start with a valid scheme + // ^ + // Schemes that are considered safe + // (https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):| + // Relative schemes (//:) are considered safe + // (\\/\\/)| + // Image data URI's are considered safe + // data:image\\/(png|bmp|gif|p?jpe?g); + var VALID_SCHEME_REGEX = + /^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i; + + /** + * Escapes a string so it's safe to use in regex + * + * @param {string} str + * @return {string} + */ + function regex(str) { + return str.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'); + } + /** + * Escapes all HTML entities in a string + * + * If noQuotes is set to false, all single and double + * quotes will also be escaped + * + * @param {string} str + * @param {boolean} [noQuotes=true] + * @return {string} + * @since 1.4.1 + */ + function entities(str, noQuotes) { + if (!str) { + return str; + } + + var replacements = { + '&': '&', + '<': '<', + '>': '>', + ' ': ' ', + '\r\n': '<br />', + '\r': '<br />', + '\n': '<br />' + }; + + if (noQuotes !== false) { + replacements['"'] = '"'; + replacements['\''] = '''; + replacements['`'] = '`'; + } + + str = str.replace(/ {2}|\r\n|[&<>\r\n'"`]/g, function (match) { + return replacements[match] || match; + }); + + return str; + } + /** + * Escape URI scheme. + * + * Appends the current URL to a url if it has a scheme that is not: + * + * http + * https + * sftp + * ftp + * mailto + * spotify + * skype + * ssh + * teamspeak + * tel + * // + * data:image/(png|jpeg|jpg|pjpeg|bmp|gif); + * + * **IMPORTANT**: This does not escape any HTML in a url, for + * that use the escape.entities() method. + * + * @param {string} url + * @return {string} + * @since 1.4.5 + */ + function uriScheme(url) { + var path, + // If there is a : before a / then it has a scheme + hasScheme = /^[^\/]*:/i, + location = window.location; + + // Has no scheme or a valid scheme + if ((!url || !hasScheme.test(url)) || VALID_SCHEME_REGEX.test(url)) { + return url; + } + + path = location.pathname.split('/'); + path.pop(); + + return location.protocol + '//' + + location.host + + path.join('/') + '/' + + url; + } + + /** + * HTML templates used by the editor and default commands + * @type {Object} + * @private + */ + var _templates = { + html: + '<!DOCTYPE html>' + + '<html{attrs}>' + + '<head>' + + '<meta http-equiv="Content-Type" ' + + 'content="text/html;charset={charset}" />' + + '<link rel="stylesheet" type="text/css" href="{style}" />' + + '</head>' + + '<body contenteditable="true" {spellcheck}><p></p></body>' + + '</html>', + + toolbarButton: '<a class="sceditor-button sceditor-button-{name}" ' + + 'data-sceditor-command="{name}" unselectable="on">' + + '<div unselectable="on">{dispName}</div></a>', + + emoticon: '<img src="{url}" data-sceditor-emoticon="{key}" ' + + 'alt="{key}" title="{tooltip}" />', + + fontOpt: '<a class="sceditor-font-option" href="#" ' + + 'data-font="{font}"><font face="{font}">{font}</font></a>', + + sizeOpt: '<a class="sceditor-fontsize-option" data-size="{size}" ' + + 'href="#"><font size="{size}">{size}</font></a>', + + pastetext: + '<div><label for="txt">{label}</label> ' + + '<textarea cols="20" rows="7" id="txt"></textarea></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + table: + '<div><label for="rows">{rows}</label><input type="text" ' + + 'id="rows" value="2" /></div>' + + '<div><label for="cols">{cols}</label><input type="text" ' + + 'id="cols" value="2" /></div>' + + '<div><input type="button" class="button" value="{insert}"' + + ' /></div>', + + image: + '<div><label for="image">{url}</label> ' + + '<input type="text" id="image" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="width">{width}</label> ' + + '<input type="text" id="width" size="2" dir="ltr" /></div>' + + '<div><label for="height">{height}</label> ' + + '<input type="text" id="height" size="2" dir="ltr" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + email: + '<div><label for="email">{label}</label> ' + + '<input type="text" id="email" dir="ltr" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + link: + '<div><label for="link">{url}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{ins}" /></div>', + + youtubeMenu: + '<div><label for="link">{label}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + youtube: + '<iframe width="560" height="315" frameborder="0" allowfullscreen ' + + 'src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" ' + + 'data-youtube-id="{id}"></iframe>' + }; + + /** + * Replaces any params in a template with the passed params. + * + * If createHtml is passed it will return a DocumentFragment + * containing the parsed template. + * + * @param {string} name + * @param {Object} [params] + * @param {boolean} [createHtml] + * @returns {string|DocumentFragment} + * @private + */ + function _tmpl (name, params, createHtml) { + var template = _templates[name]; + + Object.keys(params).forEach(function (name) { + template = template.replace( + new RegExp(regex('{' + name + '}'), 'g'), params[name] + ); + }); + + if (createHtml) { + template = parseHTML(template); + } + + return template; + } + + /** + * Fixes a bug in FF where it sometimes wraps + * new lines in their own list item. + * See issue #359 + */ + function fixFirefoxListBug(editor) { + // Only apply to Firefox as will break other browsers. + if ('mozHidden' in document) { + var node = editor.getBody(); + var next; + + while (node) { + next = node; + + if (next.firstChild) { + next = next.firstChild; + } else { + + while (next && !next.nextSibling) { + next = next.parentNode; + } + + if (next) { + next = next.nextSibling; + } + } + + if (node.nodeType === 3 && /[\n\r\t]+/.test(node.nodeValue)) { + // Only remove if newlines are collapsed + if (!/^pre/.test(css(node.parentNode, 'whiteSpace'))) { + remove(node); + } + } + + node = next; + } + } + } + + + /** + * Map of all the commands for SCEditor + * @type {Object} + * @name commands + * @memberOf jQuery.sceditor + */ + var defaultCmds = { + // START_COMMAND: Bold + bold: { + exec: 'bold', + tooltip: 'Bold', + shortcut: 'Ctrl+B' + }, + // END_COMMAND + // START_COMMAND: Italic + italic: { + exec: 'italic', + tooltip: 'Italic', + shortcut: 'Ctrl+I' + }, + // END_COMMAND + // START_COMMAND: Underline + underline: { + exec: 'underline', + tooltip: 'Underline', + shortcut: 'Ctrl+U' + }, + // END_COMMAND + // START_COMMAND: Strikethrough + strike: { + exec: 'strikethrough', + tooltip: 'Strikethrough' + }, + // END_COMMAND + // START_COMMAND: Subscript + subscript: { + exec: 'subscript', + tooltip: 'Subscript' + }, + // END_COMMAND + // START_COMMAND: Superscript + superscript: { + exec: 'superscript', + tooltip: 'Superscript' + }, + // END_COMMAND + + // START_COMMAND: Left + left: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-left + return /left/.test(align) || + align === (isLtr ? 'start' : 'end'); + } + }, + exec: 'justifyleft', + tooltip: 'Align left' + }, + // END_COMMAND + // START_COMMAND: Centre + center: { + exec: 'justifycenter', + tooltip: 'Center' + }, + // END_COMMAND + // START_COMMAND: Right + right: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-right + return /right/.test(align) || + align === (isLtr ? 'end' : 'start'); + } + }, + exec: 'justifyright', + tooltip: 'Align right' + }, + // END_COMMAND + // START_COMMAND: Justify + justify: { + exec: 'justifyfull', + tooltip: 'Justify' + }, + // END_COMMAND + + // START_COMMAND: Font + font: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'font')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.opts.fonts.split(',').forEach(function (font) { + appendChild(content, _tmpl('fontOpt', { + font: font + }, true)); + }); + + editor.createDropDown(caller, 'font-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.font._dropDown(editor, caller, function (fontName) { + editor.execCommand('fontname', fontName); + }); + }, + tooltip: 'Font Name' + }, + // END_COMMAND + // START_COMMAND: Size + size: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'size')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + for (var i = 1; i <= 7; i++) { + appendChild(content, _tmpl('sizeOpt', { + size: i + }, true)); + } + + editor.createDropDown(caller, 'fontsize-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.size._dropDown(editor, caller, function (fontSize) { + editor.execCommand('fontsize', fontSize); + }); + }, + tooltip: 'Font Size' + }, + // END_COMMAND + // START_COMMAND: Colour + color: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'), + html = '', + cmd = defaultCmds.color; + + if (!cmd._htmlCache) { + editor.opts.colors.split('|').forEach(function (column) { + html += '<div class="sceditor-color-column">'; + + column.split(',').forEach(function (color) { + html += + '<a href="#" class="sceditor-color-option"' + + ' style="background-color: ' + color + '"' + + ' data-color="' + color + '"></a>'; + }); + + html += '</div>'; + }); + + cmd._htmlCache = html; + } + + appendChild(content, parseHTML(cmd._htmlCache)); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'color')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'color-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.color._dropDown(editor, caller, function (color) { + editor.execCommand('forecolor', color); + }); + }, + tooltip: 'Font Color' + }, + // END_COMMAND + // START_COMMAND: Remove Format + removeformat: { + exec: 'removeformat', + tooltip: 'Remove Formatting' + }, + // END_COMMAND + + // START_COMMAND: Cut + cut: { + exec: 'cut', + tooltip: 'Cut', + errorMessage: 'Your browser does not allow the cut command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-X' + }, + // END_COMMAND + // START_COMMAND: Copy + copy: { + exec: 'copy', + tooltip: 'Copy', + errorMessage: 'Your browser does not allow the copy command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-C' + }, + // END_COMMAND + // START_COMMAND: Paste + paste: { + exec: 'paste', + tooltip: 'Paste', + errorMessage: 'Your browser does not allow the paste command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-V' + }, + // END_COMMAND + // START_COMMAND: Paste Text + pastetext: { + exec: function (caller) { + var val, + content = createElement('div'), + editor = this; + + appendChild(content, _tmpl('pastetext', { + label: editor._( + 'Paste your text inside the following box:' + ), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + val = find(content, '#txt')[0].value; + + if (val) { + editor.wysiwygEditorInsertText(val); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'pastetext', content); + }, + tooltip: 'Paste Text' + }, + // END_COMMAND + // START_COMMAND: Bullet List + bulletlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertunorderedlist'); + }, + tooltip: 'Bullet list' + }, + // END_COMMAND + // START_COMMAND: Ordered List + orderedlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertorderedlist'); + }, + tooltip: 'Numbered list' + }, + // END_COMMAND + // START_COMMAND: Indent + indent: { + state: function (parent, firstBlock) { + // Only works with lists, for now + var range, startParent, endParent; + + if (is(firstBlock, 'li')) { + return 0; + } + + if (is(firstBlock, 'ul,ol,menu')) { + // if the whole list is selected, then this must be + // invalidated because the browser will place a + // <blockquote> there + range = this.getRangeHelper().selectedRange(); + + startParent = range.startContainer.parentNode; + endParent = range.endContainer.parentNode; + + // TODO: could use nodeType for this? + // Maybe just check the firstBlock contains both the start + //and end containers + + // Select the tag, not the textNode + // (that's why the parentNode) + if (startParent !== + startParent.parentNode.firstElementChild || + // work around a bug in FF + (is(endParent, 'li') && endParent !== + endParent.parentNode.lastElementChild)) { + return 0; + } + } + + return -1; + }, + exec: function () { + var editor = this, + block = editor.getRangeHelper().getFirstBlockParent(); + + editor.focus(); + + // An indent system is quite complicated as there are loads + // of complications and issues around how to indent text + // As default, let's just stay with indenting the lists, + // at least, for now. + if (closest(block, 'ul,ol,menu')) { + editor.execCommand('indent'); + } + }, + tooltip: 'Add indent' + }, + // END_COMMAND + // START_COMMAND: Outdent + outdent: { + state: function (parents, firstBlock) { + return closest(firstBlock, 'ul,ol,menu') ? 0 : -1; + }, + exec: function () { + var block = this.getRangeHelper().getFirstBlockParent(); + if (closest(block, 'ul,ol,menu')) { + this.execCommand('outdent'); + } + }, + tooltip: 'Remove one indent' + }, + // END_COMMAND + + // START_COMMAND: Table + table: { + exec: function (caller) { + var editor = this, + content = createElement('div'); + + appendChild(content, _tmpl('table', { + rows: editor._('Rows:'), + cols: editor._('Cols:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var rows = Number(find(content, '#rows')[0].value), + cols = Number(find(content, '#cols')[0].value), + html = '<table>'; + + if (rows > 0 && cols > 0) { + html += Array(rows + 1).join( + '<tr>' + + Array(cols + 1).join( + '<td><br /></td>' + ) + + '</tr>' + ); + + html += '</table>'; + + editor.wysiwygEditorInsertHtml(html); + editor.closeDropDown(true); + e.preventDefault(); + } + }); + + editor.createDropDown(caller, 'inserttable', content); + }, + tooltip: 'Insert a table' + }, + // END_COMMAND + + // START_COMMAND: Horizontal Rule + horizontalrule: { + exec: 'inserthorizontalrule', + tooltip: 'Insert a horizontal rule' + }, + // END_COMMAND + + // START_COMMAND: Code + code: { + exec: function () { + this.wysiwygEditorInsertHtml( + '<code>', + '<br /></code>' + ); + }, + tooltip: 'Code' + }, + // END_COMMAND + + // START_COMMAND: Image + image: { + _dropDown: function (editor, caller, selected, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('image', { + url: editor._('URL:'), + width: editor._('Width (optional):'), + height: editor._('Height (optional):'), + insert: editor._('Insert') + }, true)); + + + var urlInput = find(content, '#image')[0]; + + urlInput.value = selected; + + on(content, 'click', '.button', function (e) { + if (urlInput.value) { + cb( + urlInput.value, + find(content, '#width')[0].value, + find(content, '#height')[0].value + ); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertimage', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.image._dropDown( + editor, + caller, + '', + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width="' + parseInt(width, 10) + '"'; + } + + if (height) { + attrs += ' height="' + parseInt(height, 10) + '"'; + } + + attrs += ' src="' + entities(url) + '"'; + + editor.wysiwygEditorInsertHtml( + '<img' + attrs + ' />' + ); + } + ); + }, + tooltip: 'Insert an image' + }, + // END_COMMAND + + // START_COMMAND: E-mail + email: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('email', { + label: editor._('E-mail:'), + desc: editor._('Description (optional):'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var email = find(content, '#email')[0].value; + + if (email) { + cb(email, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertemail', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.email._dropDown( + editor, + caller, + function (email, text) { + if (!editor.getRangeHelper().selectedHtml() || text) { + editor.wysiwygEditorInsertHtml( + '<a href="' + + 'mailto:' + entities(email) + '">' + + entities((text || email)) + + '</a>' + ); + } else { + editor.execCommand('createlink', 'mailto:' + email); + } + } + ); + }, + tooltip: 'Insert an email' + }, + // END_COMMAND + + // START_COMMAND: Link + link: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('link', { + url: editor._('URL:'), + desc: editor._('Description (optional):'), + ins: editor._('Insert') + }, true)); + + var linkInput = find(content, '#link')[0]; + + function insertUrl(e) { + if (linkInput.value) { + cb(linkInput.value, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + } + + on(content, 'click', '.button', insertUrl); + on(content, 'keypress', function (e) { + // 13 = enter key + if (e.which === 13 && linkInput.value) { + insertUrl(e); + } + }, EVENT_CAPTURE); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.link._dropDown(editor, caller, function (url, text) { + if (text || !editor.getRangeHelper().selectedHtml()) { + editor.wysiwygEditorInsertHtml( + '<a href="' + entities(url) + '">' + + entities(text || url) + + '</a>' + ); + } else { + editor.execCommand('createlink', url); + } + }); + }, + tooltip: 'Insert a link' + }, + // END_COMMAND + + // START_COMMAND: Unlink + unlink: { + state: function () { + return closest(this.currentNode(), 'a') ? 0 : -1; + }, + exec: function () { + var anchor = closest(this.currentNode(), 'a'); + + if (anchor) { + while (anchor.firstChild) { + insertBefore(anchor.firstChild, anchor); + } + + remove(anchor); + } + }, + tooltip: 'Unlink' + }, + // END_COMMAND + + + // START_COMMAND: Quote + quote: { + exec: function (caller, html, author) { + var before = '<blockquote>', + end = '</blockquote>'; + + // if there is HTML passed set end to null so any selected + // text is replaced + if (html) { + author = (author ? '<cite>' + + entities(author) + + '</cite>' : ''); + before = before + author + html + end; + end = null; + // if not add a newline to the end of the inserted quote + } else if (this.getRangeHelper().selectedHtml() === '') { + end = '<br />' + end; + } + + this.wysiwygEditorInsertHtml(before, end); + }, + tooltip: 'Insert a Quote' + }, + // END_COMMAND + + // START_COMMAND: Emoticons + emoticon: { + exec: function (caller) { + var editor = this; + + var createContent = function (includeMore) { + var moreLink, + opts = editor.opts, + emoticonsRoot = opts.emoticonsRoot || '', + emoticonsCompat = opts.emoticonsCompat, + rangeHelper = editor.getRangeHelper(), + startSpace = emoticonsCompat && + rangeHelper.getOuterText(true, 1) !== ' ' ? ' ' : '', + endSpace = emoticonsCompat && + rangeHelper.getOuterText(false, 1) !== ' ' ? ' ' : '', + content = createElement('div'), + line = createElement('div'), + perLine = 0, + emoticons = extend( + {}, + opts.emoticons.dropdown, + includeMore ? opts.emoticons.more : {} + ); + + appendChild(content, line); + + perLine = Math.sqrt(Object.keys(emoticons).length); + + on(content, 'click', 'img', function (e) { + editor.insert(startSpace + attr(this, 'alt') + endSpace, + null, false).closeDropDown(true); + + e.preventDefault(); + }); + + each(emoticons, function (code, emoticon) { + appendChild(line, createElement('img', { + src: emoticonsRoot + (emoticon.url || emoticon), + alt: code, + title: emoticon.tooltip || code + })); + + if (line.children.length >= perLine) { + line = createElement('div'); + appendChild(content, line); + } + }); + + if (!includeMore && opts.emoticons.more) { + moreLink = createElement('a', { + className: 'sceditor-more' + }); + + appendChild(moreLink, + document.createTextNode(editor._('More'))); + + on(moreLink, 'click', function (e) { + editor.createDropDown( + caller, 'more-emoticons', createContent(true) + ); + + e.preventDefault(); + }); + + appendChild(content, moreLink); + } + + return content; + }; + + editor.createDropDown(caller, 'emoticons', createContent(false)); + }, + txtExec: function (caller) { + defaultCmds.emoticon.exec.call(this, caller); + }, + tooltip: 'Insert an emoticon' + }, + // END_COMMAND + + // START_COMMAND: YouTube + youtube: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + appendChild(content, _tmpl('youtubeMenu', { + label: editor._('Video URL:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var val = find(content, '#link')[0].value; + var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/); + var timeMatch = val.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/); + var time = 0; + + if (timeMatch) { + each(timeMatch[1].split(/[hms]/), function (i, val) { + if (val !== '') { + time = (time * 60) + Number(val); + } + }); + } + + if (idMatch && /^[a-zA-Z0-9_\-]{11}$/.test(idMatch[1])) { + callback(idMatch[1], time); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (btn) { + var editor = this; + + defaultCmds.youtube._dropDown(editor, btn, function (id, time) { + editor.wysiwygEditorInsertHtml(_tmpl('youtube', { + id: id, + time: time + })); + }); + }, + tooltip: 'Insert a YouTube video' + }, + // END_COMMAND + + // START_COMMAND: Date + date: { + _date: function (editor) { + var now = new Date(), + year = now.getYear(), + month = now.getMonth() + 1, + day = now.getDate(); + + if (year < 2000) { + year = 1900 + year; + } + + if (month < 10) { + month = '0' + month; + } + + if (day < 10) { + day = '0' + day; + } + + return editor.opts.dateFormat + .replace(/year/i, year) + .replace(/month/i, month) + .replace(/day/i, day); + }, + exec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + txtExec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + tooltip: 'Insert current date' + }, + // END_COMMAND + + // START_COMMAND: Time + time: { + _time: function () { + var now = new Date(), + hours = now.getHours(), + mins = now.getMinutes(), + secs = now.getSeconds(); + + if (hours < 10) { + hours = '0' + hours; + } + + if (mins < 10) { + mins = '0' + mins; + } + + if (secs < 10) { + secs = '0' + secs; + } + + return hours + ':' + mins + ':' + secs; + }, + exec: function () { + this.insertText(defaultCmds.time._time()); + }, + txtExec: function () { + this.insertText(defaultCmds.time._time()); + }, + tooltip: 'Insert current time' + }, + // END_COMMAND + + + // START_COMMAND: Ltr + ltr: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'ltr'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'ltr' ? '' : 'ltr'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Left-to-Right' + }, + // END_COMMAND + + // START_COMMAND: Rtl + rtl: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'rtl'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'rtl' ? '' : 'rtl'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Right-to-Left' + }, + // END_COMMAND + + + // START_COMMAND: Print + print: { + exec: 'print', + tooltip: 'Print' + }, + // END_COMMAND + + // START_COMMAND: Maximize + maximize: { + state: function () { + return this.maximize(); + }, + exec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + txtExec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + tooltip: 'Maximize', + shortcut: 'Ctrl+Shift+M' + }, + // END_COMMAND + + // START_COMMAND: Source + source: { + state: function () { + return this.sourceMode(); + }, + exec: function () { + this.toggleSourceMode(); + this.focus(); + }, + txtExec: function () { + this.toggleSourceMode(); + this.focus(); + }, + tooltip: 'View source', + shortcut: 'Ctrl+Shift+S' + }, + // END_COMMAND + + // this is here so that commands above can be removed + // without having to remove the , after the last one. + // Needed for IE. + ignore: {} + }; + + var plugins = {}; + + /** + * Plugin Manager class + * @class PluginManager + * @name PluginManager + */ + function PluginManager(thisObj) { + /** + * Alias of this + * + * @private + * @type {Object} + */ + var base = this; + + /** + * Array of all currently registered plugins + * + * @type {Array} + * @private + */ + var registeredPlugins = []; + + + /** + * Changes a signals name from "name" into "signalName". + * + * @param {string} signal + * @return {string} + * @private + */ + var formatSignalName = function (signal) { + return 'signal' + signal.charAt(0).toUpperCase() + signal.slice(1); + }; + + /** + * Calls handlers for a signal + * + * @see call() + * @see callOnlyFirst() + * @param {Array} args + * @param {boolean} returnAtFirst + * @return {*} + * @private + */ + var callHandlers = function (args, returnAtFirst) { + args = [].slice.call(args); + + var idx, ret, + signal = formatSignalName(args.shift()); + + for (idx = 0; idx < registeredPlugins.length; idx++) { + if (signal in registeredPlugins[idx]) { + ret = registeredPlugins[idx][signal].apply(thisObj, args); + + if (returnAtFirst) { + return ret; + } + } + } + }; + + /** + * Calls all handlers for the passed signal + * + * @param {string} signal + * @param {...string} args + * @function + * @name call + * @memberOf PluginManager.prototype + */ + base.call = function () { + callHandlers(arguments, false); + }; + + /** + * Calls the first handler for a signal, and returns the + * + * @param {string} signal + * @param {...string} args + * @return {*} The result of calling the handler + * @function + * @name callOnlyFirst + * @memberOf PluginManager.prototype + */ + base.callOnlyFirst = function () { + return callHandlers(arguments, true); + }; + + /** + * Checks if a signal has a handler + * + * @param {string} signal + * @return {boolean} + * @function + * @name hasHandler + * @memberOf PluginManager.prototype + */ + base.hasHandler = function (signal) { + var i = registeredPlugins.length; + signal = formatSignalName(signal); + + while (i--) { + if (signal in registeredPlugins[i]) { + return true; + } + } + + return false; + }; + + /** + * Checks if the plugin exists in plugins + * + * @param {string} plugin + * @return {boolean} + * @function + * @name exists + * @memberOf PluginManager.prototype + */ + base.exists = function (plugin) { + if (plugin in plugins) { + plugin = plugins[plugin]; + + return typeof plugin === 'function' && + typeof plugin.prototype === 'object'; + } + + return false; + }; + + /** + * Checks if the passed plugin is currently registered. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name isRegistered + * @memberOf PluginManager.prototype + */ + base.isRegistered = function (plugin) { + if (base.exists(plugin)) { + var idx = registeredPlugins.length; + + while (idx--) { + if (registeredPlugins[idx] instanceof plugins[plugin]) { + return true; + } + } + } + + return false; + }; + + /** + * Registers a plugin to receive signals + * + * @param {string} plugin + * @return {boolean} + * @function + * @name register + * @memberOf PluginManager.prototype + */ + base.register = function (plugin) { + if (!base.exists(plugin) || base.isRegistered(plugin)) { + return false; + } + + plugin = new plugins[plugin](); + registeredPlugins.push(plugin); + + if ('init' in plugin) { + plugin.init.call(thisObj); + } + + return true; + }; + + /** + * Deregisters a plugin. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name deregister + * @memberOf PluginManager.prototype + */ + base.deregister = function (plugin) { + var removedPlugin, + pluginIdx = registeredPlugins.length, + removed = false; + + if (!base.isRegistered(plugin)) { + return removed; + } + + while (pluginIdx--) { + if (registeredPlugins[pluginIdx] instanceof plugins[plugin]) { + removedPlugin = registeredPlugins.splice(pluginIdx, 1)[0]; + removed = true; + + if ('destroy' in removedPlugin) { + removedPlugin.destroy.call(thisObj); + } + } + } + + return removed; + }; + + /** + * Clears all plugins and removes the owner reference. + * + * Calling any functions on this object after calling + * destroy will cause a JS error. + * + * @name destroy + * @memberOf PluginManager.prototype + */ + base.destroy = function () { + var i = registeredPlugins.length; + + while (i--) { + if ('destroy' in registeredPlugins[i]) { + registeredPlugins[i].destroy.call(thisObj); + } + } + + registeredPlugins = []; + thisObj = null; + }; + } + PluginManager.plugins = plugins; + + /** + * Gets the text, start/end node and offset for + * length chars left or right of the passed node + * at the specified offset. + * + * @param {Node} node + * @param {number} offset + * @param {boolean} isLeft + * @param {number} length + * @return {Object} + * @private + */ + var outerText = function (range, isLeft, length) { + var nodeValue, remaining, start, end, node, + text = '', + next = range.startContainer, + offset = range.startOffset; + + // Handle cases where node is a paragraph and offset + // refers to the index of a text node. + // 3 = text node + if (next && next.nodeType !== 3) { + next = next.childNodes[offset]; + offset = 0; + } + + start = end = offset; + + while (length > text.length && next && next.nodeType === 3) { + nodeValue = next.nodeValue; + remaining = length - text.length; + + // If not the first node, start and end should be at their + // max values as will be updated when getting the text + if (node) { + end = nodeValue.length; + start = 0; + } + + node = next; + + if (isLeft) { + start = Math.max(end - remaining, 0); + offset = start; + + text = nodeValue.substr(start, end - start) + text; + next = node.previousSibling; + } else { + end = Math.min(remaining, nodeValue.length); + offset = start + end; + + text += nodeValue.substr(start, end); + next = node.nextSibling; + } + } + + return { + node: node || next, + offset: offset, + text: text + }; + }; + + /** + * Range helper + * + * @class RangeHelper + * @name RangeHelper + */ + function RangeHelper(win, d, sanitize) { + var _createMarker, _prepareInput, + doc = d || win.contentDocument || win.document, + startMarker = 'sceditor-start-marker', + endMarker = 'sceditor-end-marker', + base = this; + + /** + * Inserts HTML into the current range replacing any selected + * text. + * + * If endHTML is specified the selected contents will be put between + * html and endHTML. If there is nothing selected html and endHTML are + * just concatenate together. + * + * @param {string} html + * @param {string} [endHTML] + * @return False on fail + * @function + * @name insertHTML + * @memberOf RangeHelper.prototype + */ + base.insertHTML = function (html, endHTML) { + var node, div, + range = base.selectedRange(); + + if (!range) { + return false; + } + + if (endHTML) { + html += base.selectedHtml() + endHTML; + } + + div = createElement('p', {}, doc); + node = doc.createDocumentFragment(); + div.innerHTML = sanitize(html); + + while (div.firstChild) { + appendChild(node, div.firstChild); + } + + base.insertNode(node); + }; + + /** + * Prepares HTML to be inserted by adding a zero width space + * if the last child is empty and adding the range start/end + * markers to the last child. + * + * @param {Node|string} node + * @param {Node|string} [endNode] + * @param {boolean} [returnHtml] + * @return {Node|string} + * @private + */ + _prepareInput = function (node, endNode, returnHtml) { + var lastChild, + frag = doc.createDocumentFragment(); + + if (typeof node === 'string') { + if (endNode) { + node += base.selectedHtml() + endNode; + } + + frag = parseHTML(node); + } else { + appendChild(frag, node); + + if (endNode) { + appendChild(frag, base.selectedRange().extractContents()); + appendChild(frag, endNode); + } + } + + if (!(lastChild = frag.lastChild)) { + return; + } + + while (!isInline(lastChild.lastChild, true)) { + lastChild = lastChild.lastChild; + } + + if (canHaveChildren(lastChild)) { + // Webkit won't allow the cursor to be placed inside an + // empty tag, so add a zero width space to it. + if (!lastChild.lastChild) { + appendChild(lastChild, document.createTextNode('\u200B')); + } + } else { + lastChild = frag; + } + + base.removeMarkers(); + + // Append marks to last child so when restored cursor will be in + // the right place + appendChild(lastChild, _createMarker(startMarker)); + appendChild(lastChild, _createMarker(endMarker)); + + if (returnHtml) { + var div = createElement('div'); + appendChild(div, frag); + + return div.innerHTML; + } + + return frag; + }; + + /** + * The same as insertHTML except with DOM nodes instead + * + * <strong>Warning:</strong> the nodes must belong to the + * document they are being inserted into. Some browsers + * will throw exceptions if they don't. + * + * Returns boolean false on fail + * + * @param {Node} node + * @param {Node} endNode + * @return {false|undefined} + * @function + * @name insertNode + * @memberOf RangeHelper.prototype + */ + base.insertNode = function (node, endNode) { + var first, last, + input = _prepareInput(node, endNode), + range = base.selectedRange(), + parent = range.commonAncestorContainer, + emptyNodes = []; + + if (!input) { + return false; + } + + function removeIfEmpty(node) { + // Only remove empty node if it wasn't already empty + if (node && isEmpty(node) && emptyNodes.indexOf(node) < 0) { + remove(node); + } + } + + if (range.startContainer !== range.endContainer) { + each(parent.childNodes, function (_, node) { + if (isEmpty(node)) { + emptyNodes.push(node); + } + }); + + first = input.firstChild; + last = input.lastChild; + } + + range.deleteContents(); + + // FF allows <br /> to be selected but inserting a node + // into <br /> will cause it not to be displayed so must + // insert before the <br /> in FF. + // 3 = TextNode + if (parent && parent.nodeType !== 3 && !canHaveChildren(parent)) { + insertBefore(input, parent); + } else { + range.insertNode(input); + + // If a node was split or its contents deleted, remove any resulting + // empty tags. For example: + // <p>|test</p><div>test|</div> + // When deleteContents could become: + // <p></p>|<div></div> + // So remove the empty ones + removeIfEmpty(first && first.previousSibling); + removeIfEmpty(last && last.nextSibling); + } + + base.restoreRange(); + }; + + /** + * Clones the selected Range + * + * @return {Range} + * @function + * @name cloneSelected + * @memberOf RangeHelper.prototype + */ + base.cloneSelected = function () { + var range = base.selectedRange(); + + if (range) { + return range.cloneRange(); + } + }; + + /** + * Gets the selected Range + * + * @return {Range} + * @function + * @name selectedRange + * @memberOf RangeHelper.prototype + */ + base.selectedRange = function () { + var range, firstChild, + sel = win.getSelection(); + + if (!sel) { + return; + } + + // When creating a new range, set the start to the first child + // element of the body element to avoid errors in FF. + if (sel.rangeCount <= 0) { + firstChild = doc.body; + while (firstChild.firstChild) { + firstChild = firstChild.firstChild; + } + + range = doc.createRange(); + // Must be setStartBefore otherwise it can cause infinite + // loops with lists in WebKit. See issue 442 + range.setStartBefore(firstChild); + + sel.addRange(range); + } + + if (sel.rangeCount > 0) { + range = sel.getRangeAt(0); + } + + return range; + }; + + /** + * Gets if there is currently a selection + * + * @return {boolean} + * @function + * @name hasSelection + * @since 1.4.4 + * @memberOf RangeHelper.prototype + */ + base.hasSelection = function () { + var sel = win.getSelection(); + + return sel && sel.rangeCount > 0; + }; + + /** + * Gets the currently selected HTML + * + * @return {string} + * @function + * @name selectedHtml + * @memberOf RangeHelper.prototype + */ + base.selectedHtml = function () { + var div, + range = base.selectedRange(); + + if (range) { + div = createElement('p', {}, doc); + appendChild(div, range.cloneContents()); + + return div.innerHTML; + } + + return ''; + }; + + /** + * Gets the parent node of the selected contents in the range + * + * @return {HTMLElement} + * @function + * @name parentNode + * @memberOf RangeHelper.prototype + */ + base.parentNode = function () { + var range = base.selectedRange(); + + if (range) { + return range.commonAncestorContainer; + } + }; + + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @return {HTMLElement} + * @function + * @name getFirstBlockParent + * @memberOf RangeHelper.prototype + */ + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @param {Node} [n] The element to get the first block level parent from + * @return {HTMLElement} + * @function + * @name getFirstBlockParent^2 + * @since 1.4.1 + * @memberOf RangeHelper.prototype + */ + base.getFirstBlockParent = function (node) { + var func = function (elm) { + if (!isInline(elm, true)) { + return elm; + } + + elm = elm ? elm.parentNode : null; + + return elm ? func(elm) : elm; + }; + + return func(node || base.parentNode()); + }; + + /** + * Inserts a node at either the start or end of the current selection + * + * @param {Bool} start + * @param {Node} node + * @function + * @name insertNodeAt + * @memberOf RangeHelper.prototype + */ + base.insertNodeAt = function (start, node) { + var currentRange = base.selectedRange(), + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(start); + range.insertNode(node); + + // Reselect the current range. + // Fixes issue with Chrome losing the selection. Issue#82 + base.selectRange(currentRange); + }; + + /** + * Creates a marker node + * + * @param {string} id + * @return {HTMLSpanElement} + * @private + */ + _createMarker = function (id) { + base.removeMarker(id); + + var marker = createElement('span', { + id: id, + className: 'sceditor-selection sceditor-ignore', + style: 'display:none;line-height:0' + }, doc); + + marker.innerHTML = ' '; + + return marker; + }; + + /** + * Inserts start/end markers for the current selection + * which can be used by restoreRange to re-select the + * range. + * + * @memberOf RangeHelper.prototype + * @function + * @name insertMarkers + */ + base.insertMarkers = function () { + var currentRange = base.selectedRange(); + var startNode = _createMarker(startMarker); + + base.removeMarkers(); + base.insertNodeAt(true, startNode); + + // Fixes issue with end marker sometimes being placed before + // the start marker when the range is collapsed. + if (currentRange && currentRange.collapsed) { + startNode.parentNode.insertBefore( + _createMarker(endMarker), startNode.nextSibling); + } else { + base.insertNodeAt(false, _createMarker(endMarker)); + } + }; + + /** + * Gets the marker with the specified ID + * + * @param {string} id + * @return {Node} + * @function + * @name getMarker + * @memberOf RangeHelper.prototype + */ + base.getMarker = function (id) { + return doc.getElementById(id); + }; + + /** + * Removes the marker with the specified ID + * + * @param {string} id + * @function + * @name removeMarker + * @memberOf RangeHelper.prototype + */ + base.removeMarker = function (id) { + var marker = base.getMarker(id); + + if (marker) { + remove(marker); + } + }; + + /** + * Removes the start/end markers + * + * @function + * @name removeMarkers + * @memberOf RangeHelper.prototype + */ + base.removeMarkers = function () { + base.removeMarker(startMarker); + base.removeMarker(endMarker); + }; + + /** + * Saves the current range location. Alias of insertMarkers() + * + * @function + * @name saveRage + * @memberOf RangeHelper.prototype + */ + base.saveRange = function () { + base.insertMarkers(); + }; + + /** + * Select the specified range + * + * @param {Range} range + * @function + * @name selectRange + * @memberOf RangeHelper.prototype + */ + base.selectRange = function (range) { + var lastChild; + var sel = win.getSelection(); + var container = range.endContainer; + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (range.collapsed && container && + !isInline(container, true)) { + + lastChild = container.lastChild; + while (lastChild && is(lastChild, '.sceditor-ignore')) { + lastChild = lastChild.previousSibling; + } + + if (is(lastChild, 'br')) { + var rng = doc.createRange(); + rng.setEndAfter(lastChild); + rng.collapse(false); + + if (base.compare(range, rng)) { + range.setStartBefore(lastChild); + range.collapse(true); + } + } + } + + if (sel) { + base.clear(); + sel.addRange(range); + } + }; + + /** + * Restores the last range saved by saveRange() or insertMarkers() + * + * @function + * @name restoreRange + * @memberOf RangeHelper.prototype + */ + base.restoreRange = function () { + var isCollapsed, + range = base.selectedRange(), + start = base.getMarker(startMarker), + end = base.getMarker(endMarker); + + if (!start || !end || !range) { + return false; + } + + isCollapsed = start.nextSibling === end; + + range = doc.createRange(); + range.setStartBefore(start); + range.setEndAfter(end); + + if (isCollapsed) { + range.collapse(true); + } + + base.selectRange(range); + base.removeMarkers(); + }; + + /** + * Selects the text left and right of the current selection + * + * @param {number} left + * @param {number} right + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.selectOuterText = function (left, right) { + var start, end, + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(false); + + start = outerText(range, true, left); + end = outerText(range, false, right); + + range.setStart(start.node, start.offset); + range.setEnd(end.node, end.offset); + + base.selectRange(range); + }; + + /** + * Gets the text left or right of the current selection + * + * @param {boolean} before + * @param {number} length + * @return {string} + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.getOuterText = function (before, length) { + var range = base.cloneSelected(); + + if (!range) { + return ''; + } + + range.collapse(!before); + + return outerText(range, before, length).text; + }; + + /** + * Replaces keywords with values based on the current caret position + * + * @param {Array} keywords + * @param {boolean} includeAfter If to include the text after the + * current caret position or just + * text before + * @param {boolean} keywordsSorted If the keywords array is pre + * sorted shortest to longest + * @param {number} longestKeyword Length of the longest keyword + * @param {boolean} requireWhitespace If the key must be surrounded + * by whitespace + * @param {string} keypressChar If this is being called from + * a keypress event, this should be + * set to the pressed character + * @return {boolean} + * @function + * @name replaceKeyword + * @memberOf RangeHelper.prototype + */ + // eslint-disable-next-line max-params + base.replaceKeyword = function ( + keywords, + includeAfter, + keywordsSorted, + longestKeyword, + requireWhitespace, + keypressChar + ) { + if (!keywordsSorted) { + keywords.sort(function (a, b) { + return a[0].length - b[0].length; + }); + } + + var outerText, match, matchPos, startIndex, + leftLen, charsLeft, keyword, keywordLen, + whitespaceRegex = '(^|[\\s\xA0\u2002\u2003\u2009])', + keywordIdx = keywords.length, + whitespaceLen = requireWhitespace ? 1 : 0, + maxKeyLen = longestKeyword || + keywords[keywordIdx - 1][0].length; + + if (requireWhitespace) { + maxKeyLen++; + } + + keypressChar = keypressChar || ''; + outerText = base.getOuterText(true, maxKeyLen); + leftLen = outerText.length; + outerText += keypressChar; + + if (includeAfter) { + outerText += base.getOuterText(false, maxKeyLen); + } + + while (keywordIdx--) { + keyword = keywords[keywordIdx][0]; + keywordLen = keyword.length; + startIndex = Math.max(0, leftLen - keywordLen - whitespaceLen); + matchPos = -1; + + if (requireWhitespace) { + match = outerText + .substr(startIndex) + .match(new RegExp(whitespaceRegex + + regex(keyword) + whitespaceRegex)); + + if (match) { + // Add the length of the text that was removed by + // substr() and also add 1 for the whitespace + matchPos = match.index + startIndex + match[1].length; + } + } else { + matchPos = outerText.indexOf(keyword, startIndex); + } + + if (matchPos > -1) { + // Make sure the match is between before and + // after, not just entirely in one side or the other + if (matchPos <= leftLen && + matchPos + keywordLen + whitespaceLen >= leftLen) { + charsLeft = leftLen - matchPos; + + // If the keypress char is white space then it should + // not be replaced, only chars that are part of the + // key should be replaced. + base.selectOuterText( + charsLeft, + keywordLen - charsLeft - + (/^\S/.test(keypressChar) ? 1 : 0) + ); + + base.insertHTML(keywords[keywordIdx][1]); + return true; + } + } + } + + return false; + }; + + /** + * Compares two ranges. + * + * If rangeB is undefined it will be set to + * the current selected range + * + * @param {Range} rngA + * @param {Range} [rngB] + * @return {boolean} + * @function + * @name compare + * @memberOf RangeHelper.prototype + */ + base.compare = function (rngA, rngB) { + if (!rngB) { + rngB = base.selectedRange(); + } + + if (!rngA || !rngB) { + return !rngA && !rngB; + } + + return rngA.compareBoundaryPoints(Range.END_TO_END, rngB) === 0 && + rngA.compareBoundaryPoints(Range.START_TO_START, rngB) === 0; + }; + + /** + * Removes any current selection + * + * @since 1.4.6 + * @function + * @name clear + * @memberOf RangeHelper.prototype + */ + base.clear = function () { + var sel = win.getSelection(); + + if (sel) { + if (sel.removeAllRanges) { + sel.removeAllRanges(); + } else if (sel.empty) { + sel.empty(); + } + } + }; + } + + var USER_AGENT = navigator.userAgent; + + /** + * Detects if the browser is iOS + * + * Needed to fix iOS specific bugs + * + * @function + * @name ios + * @memberOf jQuery.sceditor + * @type {boolean} + */ + var ios = /iPhone|iPod|iPad| wosbrowser\//i.test(USER_AGENT); + + /** + * If the browser supports WYSIWYG editing (e.g. older mobile browsers). + * + * @function + * @name isWysiwygSupported + * @return {boolean} + */ + var isWysiwygSupported = (function () { + var match, isUnsupported; + + // IE is the only browser to support documentMode + var ie = !!window.document.documentMode; + var legacyEdge = '-ms-ime-align' in document.documentElement.style; + + var div = document.createElement('div'); + div.contentEditable = true; + + // Check if the contentEditable attribute is supported + if (!('contentEditable' in document.documentElement) || + div.contentEditable !== 'true') { + return false; + } + + // I think blackberry supports contentEditable or will at least + // give a valid value for the contentEditable detection above + // so it isn't included in the below tests. + + // I hate having to do UA sniffing but some mobile browsers say they + // support contentediable when it isn't usable, i.e. you can't enter + // text. + // This is the only way I can think of to detect them which is also how + // every other editor I've seen deals with this issue. + + // Exclude Opera mobile and mini + isUnsupported = /Opera Mobi|Opera Mini/i.test(USER_AGENT); + + if (/Android/i.test(USER_AGENT)) { + isUnsupported = true; + + if (/Safari/.test(USER_AGENT)) { + // Android browser 534+ supports content editable + // This also matches Chrome which supports content editable too + match = /Safari\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + } + + // The current version of Amazon Silk supports it, older versions didn't + // As it uses webkit like Android, assume it's the same and started + // working at versions >= 534 + if (/ Silk\//i.test(USER_AGENT)) { + match = /AppleWebKit\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + + // iOS 5+ supports content editable + if (ios) { + // Block any version <= 4_x(_x) + isUnsupported = /OS [0-4](_\d)+ like Mac/i.test(USER_AGENT); + } + + // Firefox does support WYSIWYG on mobiles so override + // any previous value if using FF + if (/Firefox/i.test(USER_AGENT)) { + isUnsupported = false; + } + + if (/OneBrowser/i.test(USER_AGENT)) { + isUnsupported = false; + } + + // UCBrowser works but doesn't give a unique user agent + if (navigator.vendor === 'UCWEB') { + isUnsupported = false; + } + + // IE and legacy edge are not supported any more + if (ie || legacyEdge) { + isUnsupported = true; + } + + return !isUnsupported; + }()); + + /** + * Checks all emoticons are surrounded by whitespace and + * replaces any that aren't with with their emoticon code. + * + * @param {HTMLElement} node + * @param {rangeHelper} rangeHelper + * @return {void} + */ + function checkWhitespace(node, rangeHelper) { + var noneWsRegex = /[^\s\xA0\u2002\u2003\u2009]+/; + var emoticons = node && find(node, 'img[data-sceditor-emoticon]'); + + if (!node || !emoticons.length) { + return; + } + + for (var i = 0; i < emoticons.length; i++) { + var emoticon = emoticons[i]; + var parent = emoticon.parentNode; + var prev = emoticon.previousSibling; + var next = emoticon.nextSibling; + + if ((!prev || !noneWsRegex.test(prev.nodeValue.slice(-1))) && + (!next || !noneWsRegex.test((next.nodeValue || '')[0]))) { + continue; + } + + var range = rangeHelper.cloneSelected(); + var rangeStart = -1; + var rangeStartContainer = range.startContainer; + var previousText = prev.nodeValue || ''; + + previousText += data(emoticon, 'sceditor-emoticon'); + + // If the cursor is after the removed emoticon, add + // the length of the newly added text to it + if (rangeStartContainer === next) { + rangeStart = previousText.length + range.startOffset; + } + + // If the cursor is set before the next node, set it to + // the end of the new text node + if (rangeStartContainer === node && + node.childNodes[range.startOffset] === next) { + rangeStart = previousText.length; + } + + // If the cursor is set before the removed emoticon, + // just keep it at that position + if (rangeStartContainer === prev) { + rangeStart = range.startOffset; + } + + if (!next || next.nodeType !== TEXT_NODE) { + next = parent.insertBefore( + parent.ownerDocument.createTextNode(''), next + ); + } + + next.insertData(0, previousText); + remove(prev); + remove(emoticon); + + // Need to update the range starting position if it's been modified + if (rangeStart > -1) { + range.setStart(next, rangeStart); + range.collapse(true); + rangeHelper.selectRange(range); + } + } + } + /** + * Replaces any emoticons inside the root node with images. + * + * emoticons should be an object where the key is the emoticon + * code and the value is the HTML to replace it with. + * + * @param {HTMLElement} root + * @param {Object<string, string>} emoticons + * @param {boolean} emoticonsCompat + * @return {void} + */ + function replace(root, emoticons, emoticonsCompat) { + var doc = root.ownerDocument; + var space = '(^|\\s|\xA0|\u2002|\u2003|\u2009|$)'; + var emoticonCodes = []; + var emoticonRegex = {}; + + // TODO: Make this tag configurable. + if (parent(root, 'code')) { + return; + } + + each(emoticons, function (key) { + emoticonRegex[key] = new RegExp(space + regex(key) + space); + emoticonCodes.push(key); + }); + + // Sort keys longest to shortest so that longer keys + // take precedence (avoids bugs with shorter keys partially + // matching longer ones) + emoticonCodes.sort(function (a, b) { + return b.length - a.length; + }); + + (function convert(node) { + node = node.firstChild; + + while (node) { + // TODO: Make this tag configurable. + if (node.nodeType === ELEMENT_NODE && !is(node, 'code')) { + convert(node); + } + + if (node.nodeType === TEXT_NODE) { + for (var i = 0; i < emoticonCodes.length; i++) { + var text = node.nodeValue; + var key = emoticonCodes[i]; + var index = emoticonsCompat ? + text.search(emoticonRegex[key]) : + text.indexOf(key); + + if (index > -1) { + // When emoticonsCompat is enabled this will be the + // position after any white space + var startIndex = text.indexOf(key, index); + var fragment = parseHTML(emoticons[key], doc); + var after = text.substr(startIndex + key.length); + + fragment.appendChild(doc.createTextNode(after)); + + node.nodeValue = text.substr(0, startIndex); + node.parentNode + .insertBefore(fragment, node.nextSibling); + } + } + } + + node = node.nextSibling; + } + }(root)); + } + + /*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */ + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var hasOwnProperty = Object.hasOwnProperty, + setPrototypeOf = Object.setPrototypeOf, + isFrozen = Object.isFrozen, + getPrototypeOf = Object.getPrototypeOf, + getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var freeze = Object.freeze, + seal = Object.seal, + create = Object.create; // eslint-disable-line import/no-mutable-exports + + var _ref = typeof Reflect !== 'undefined' && Reflect, + apply = _ref.apply, + construct = _ref.construct; + + if (!apply) { + apply = function apply(fun, thisValue, args) { + return fun.apply(thisValue, args); + }; + } + + if (!freeze) { + freeze = function freeze(x) { + return x; + }; + } + + if (!seal) { + seal = function seal(x) { + return x; + }; + } + + if (!construct) { + construct = function construct(Func, args) { + return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); + }; + } + + var arrayForEach = unapply(Array.prototype.forEach); + var arrayPop = unapply(Array.prototype.pop); + var arrayPush = unapply(Array.prototype.push); + + var stringToLowerCase = unapply(String.prototype.toLowerCase); + var stringMatch = unapply(String.prototype.match); + var stringReplace = unapply(String.prototype.replace); + var stringIndexOf = unapply(String.prototype.indexOf); + var stringTrim = unapply(String.prototype.trim); + + var regExpTest = unapply(RegExp.prototype.test); + + var typeErrorCreate = unconstruct(TypeError); + + function unapply(func) { + return function (thisArg) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return apply(func, thisArg, args); + }; + } + + function unconstruct(func) { + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return construct(func, args); + }; + } + + /* Add properties to a lookup table */ + function addToSet(set, array) { + if (setPrototypeOf) { + // Make 'in' and truthy checks like Boolean(set.constructor) + // independent of any properties defined on Object.prototype. + // Prevent prototype setters from intercepting set as a this value. + setPrototypeOf(set, null); + } + + var l = array.length; + while (l--) { + var element = array[l]; + if (typeof element === 'string') { + var lcElement = stringToLowerCase(element); + if (lcElement !== element) { + // Config presets (e.g. tags.js, attrs.js) are immutable. + if (!isFrozen(array)) { + array[l] = lcElement; + } + + element = lcElement; + } + } + + set[element] = true; + } + + return set; + } + + /* Shallow clone an object */ + function clone(object) { + var newObject = create(null); + + var property = void 0; + for (property in object) { + if (apply(hasOwnProperty, object, [property])) { + newObject[property] = object[property]; + } + } + + return newObject; + } + + /* IE10 doesn't support __lookupGetter__ so lets' + * simulate it. It also automatically checks + * if the prop is function or getter and behaves + * accordingly. */ + function lookupGetter(object, prop) { + while (object !== null) { + var desc = getOwnPropertyDescriptor(object, prop); + if (desc) { + if (desc.get) { + return unapply(desc.get); + } + + if (typeof desc.value === 'function') { + return unapply(desc.value); + } + } + + object = getPrototypeOf(object); + } + + return null; + } + + var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); + + // SVG + var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); + + var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); + + // List of SVG elements that are disallowed by default. + // We still need to know them so that we can do namespace + // checks properly in case one wants to add them to + // allow-list. + var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); + + var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']); + + // Similarly to SVG, we want to know all MathML elements, + // even those that we disallow by default. + var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); + + var text = freeze(['#text']); + + var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns']); + + var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); + + var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); + + var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); + + // eslint-disable-next-line unicorn/better-regex + var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode + var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); + var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape + var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape + var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape + ); + var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); + var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex + ); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var getGlobal = function getGlobal() { + return typeof window === 'undefined' ? null : window; + }; + + /** + * Creates a no-op policy for internal use only. + * Don't export this function outside this module! + * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory. + * @param {Document} document The document object (to determine policy name suffix) + * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types + * are not supported). + */ + var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { + if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { + return null; + } + + // Allow the callers to control the unique policy name + // by adding a data-tt-policy-suffix to the script element with the DOMPurify. + // Policy creation with duplicate names throws in Trusted Types. + var suffix = null; + var ATTR_NAME = 'data-tt-policy-suffix'; + if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { + suffix = document.currentScript.getAttribute(ATTR_NAME); + } + + var policyName = 'dompurify' + (suffix ? '#' + suffix : ''); + + try { + return trustedTypes.createPolicy(policyName, { + createHTML: function createHTML(html$$1) { + return html$$1; + } + }); + } catch (_) { + // Policy creation failed (most likely another DOMPurify script has + // already run). Skip creating the policy, as this will only cause errors + // if TT are enforced. + console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); + return null; + } + }; + + function createDOMPurify() { + var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); + + var DOMPurify = function DOMPurify(root) { + return createDOMPurify(root); + }; + + /** + * Version label, exposed for easier checks + * if DOMPurify is up to date or not + */ + DOMPurify.version = '2.2.6'; + + /** + * Array of elements that DOMPurify removed during sanitation. + * Empty if nothing was removed. + */ + DOMPurify.removed = []; + + if (!window || !window.document || window.document.nodeType !== 9) { + // Not running in a browser, provide a factory function + // so that you can pass your own Window + DOMPurify.isSupported = false; + + return DOMPurify; + } + + var originalDocument = window.document; + + var document = window.document; + var DocumentFragment = window.DocumentFragment, + HTMLTemplateElement = window.HTMLTemplateElement, + Node = window.Node, + Element = window.Element, + NodeFilter = window.NodeFilter, + _window$NamedNodeMap = window.NamedNodeMap, + NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, + Text = window.Text, + Comment = window.Comment, + DOMParser = window.DOMParser, + trustedTypes = window.trustedTypes; + + + var ElementPrototype = Element.prototype; + + var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); + var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); + var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); + + // As per issue #47, the web-components registry is inherited by a + // new document created via createHTMLDocument. As per the spec + // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) + // a new empty registry is used when creating a template contents owner + // document, so we use that as our parent document to ensure nothing + // is inherited. + if (typeof HTMLTemplateElement === 'function') { + var template = document.createElement('template'); + if (template.content && template.content.ownerDocument) { + document = template.content.ownerDocument; + } + } + + var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); + var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : ''; + + var _document = document, + implementation = _document.implementation, + createNodeIterator = _document.createNodeIterator, + getElementsByTagName = _document.getElementsByTagName, + createDocumentFragment = _document.createDocumentFragment; + var importNode = originalDocument.importNode; + + + var documentMode = {}; + try { + documentMode = clone(document).documentMode ? document.documentMode : {}; + } catch (_) {} + + var hooks = {}; + + /** + * Expose whether this browser supports running the full DOMPurify. + */ + DOMPurify.isSupported = implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; + + var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, + ERB_EXPR$$1 = ERB_EXPR, + DATA_ATTR$$1 = DATA_ATTR, + ARIA_ATTR$$1 = ARIA_ATTR, + IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; + var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; + + /** + * We consider the elements and attributes below to be safe. Ideally + * don't add any new ones but feel free to remove unwanted ones. + */ + + /* allowed element names */ + + var ALLOWED_TAGS = null; + var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); + + /* Allowed attribute names */ + var ALLOWED_ATTR = null; + var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); + + /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ + var FORBID_TAGS = null; + + /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ + var FORBID_ATTR = null; + + /* Decide if ARIA attributes are okay */ + var ALLOW_ARIA_ATTR = true; + + /* Decide if custom data attributes are okay */ + var ALLOW_DATA_ATTR = true; + + /* Decide if unknown protocols are okay */ + var ALLOW_UNKNOWN_PROTOCOLS = false; + + /* Output should be safe for common template engines. + * This means, DOMPurify removes data attributes, mustaches and ERB + */ + var SAFE_FOR_TEMPLATES = false; + + /* Decide if document with <html>... should be returned */ + var WHOLE_DOCUMENT = false; + + /* Track whether config is already set on this instance of DOMPurify. */ + var SET_CONFIG = false; + + /* Decide if all elements (e.g. style, script) must be children of + * document.body. By default, browsers might move them to document.head */ + var FORCE_BODY = false; + + /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported). + * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead + */ + var RETURN_DOM = false; + + /* Decide if a DOM `DocumentFragment` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported) */ + var RETURN_DOM_FRAGMENT = false; + + /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM + * `Node` is imported into the current `Document`. If this flag is not enabled the + * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by + * DOMPurify. + * + * This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false` + * might cause XSS from attacks hidden in closed shadowroots in case the browser + * supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/ + */ + var RETURN_DOM_IMPORT = true; + + /* Try to return a Trusted Type object instead of a string, return a string in + * case Trusted Types are not supported */ + var RETURN_TRUSTED_TYPE = false; + + /* Output should be free from DOM clobbering attacks? */ + var SANITIZE_DOM = true; + + /* Keep element content when removing element? */ + var KEEP_CONTENT = true; + + /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead + * of importing it into a new Document and returning a sanitized copy */ + var IN_PLACE = false; + + /* Allow usage of profiles like html, svg and mathMl */ + var USE_PROFILES = {}; + + /* Tags to ignore content of when KEEP_CONTENT is true */ + var FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); + + /* Tags that are safe for data: URIs */ + var DATA_URI_TAGS = null; + var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); + + /* Attributes safe for values like "javascript:" */ + var URI_SAFE_ATTRIBUTES = null; + var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'summary', 'title', 'value', 'style', 'xmlns']); + + /* Keep a reference to config to pass to hooks */ + var CONFIG = null; + + /* Ideally, do not touch anything below this line */ + /* ______________________________________________ */ + + var formElement = document.createElement('form'); + + /** + * _parseConfig + * + * @param {Object} cfg optional config literal + */ + // eslint-disable-next-line complexity + var _parseConfig = function _parseConfig(cfg) { + if (CONFIG && CONFIG === cfg) { + return; + } + + /* Shield configuration object from tampering */ + if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { + cfg = {}; + } + + /* Shield configuration object from prototype pollution */ + cfg = clone(cfg); + + /* Set configuration parameters */ + ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; + ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; + URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES; + DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS; + FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {}; + FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {}; + USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false; + ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true + ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true + ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false + SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false + WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false + RETURN_DOM = cfg.RETURN_DOM || false; // Default false + RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false + RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true + RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false + FORCE_BODY = cfg.FORCE_BODY || false; // Default false + SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true + KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true + IN_PLACE = cfg.IN_PLACE || false; // Default false + IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; + if (SAFE_FOR_TEMPLATES) { + ALLOW_DATA_ATTR = false; + } + + if (RETURN_DOM_FRAGMENT) { + RETURN_DOM = true; + } + + /* Parse profile info */ + if (USE_PROFILES) { + ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); + ALLOWED_ATTR = []; + if (USE_PROFILES.html === true) { + addToSet(ALLOWED_TAGS, html); + addToSet(ALLOWED_ATTR, html$1); + } + + if (USE_PROFILES.svg === true) { + addToSet(ALLOWED_TAGS, svg); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.svgFilters === true) { + addToSet(ALLOWED_TAGS, svgFilters); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.mathMl === true) { + addToSet(ALLOWED_TAGS, mathMl); + addToSet(ALLOWED_ATTR, mathMl$1); + addToSet(ALLOWED_ATTR, xml); + } + } + + /* Merge configuration parameters */ + if (cfg.ADD_TAGS) { + if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { + ALLOWED_TAGS = clone(ALLOWED_TAGS); + } + + addToSet(ALLOWED_TAGS, cfg.ADD_TAGS); + } + + if (cfg.ADD_ATTR) { + if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { + ALLOWED_ATTR = clone(ALLOWED_ATTR); + } + + addToSet(ALLOWED_ATTR, cfg.ADD_ATTR); + } + + if (cfg.ADD_URI_SAFE_ATTR) { + addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR); + } + + /* Add #text in case KEEP_CONTENT is set to true */ + if (KEEP_CONTENT) { + ALLOWED_TAGS['#text'] = true; + } + + /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ + if (WHOLE_DOCUMENT) { + addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); + } + + /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ + if (ALLOWED_TAGS.table) { + addToSet(ALLOWED_TAGS, ['tbody']); + delete FORBID_TAGS.tbody; + } + + // Prevent further manipulation of configuration. + // Not available in IE8, Safari 5, etc. + if (freeze) { + freeze(cfg); + } + + CONFIG = cfg; + }; + + var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); + + var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); + + /* Keep track of all possible SVG and MathML tags + * so that we can perform the namespace checks + * correctly. */ + var ALL_SVG_TAGS = addToSet({}, svg); + addToSet(ALL_SVG_TAGS, svgFilters); + addToSet(ALL_SVG_TAGS, svgDisallowed); + + var ALL_MATHML_TAGS = addToSet({}, mathMl); + addToSet(ALL_MATHML_TAGS, mathMlDisallowed); + + var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + + /** + * + * + * @param {Element} element a DOM element whose namespace is being checked + * @returns {boolean} Return false if the element has a + * namespace that a spec-compliant parser would never + * return. Return true otherwise. + */ + var _checkValidNamespace = function _checkValidNamespace(element) { + var parent = getParentNode(element); + + // In JSDOM, if we're inside shadow DOM, then parentNode + // can be null. We just simulate parent in this case. + if (!parent || !parent.tagName) { + parent = { + namespaceURI: HTML_NAMESPACE, + tagName: 'template' + }; + } + + var tagName = stringToLowerCase(element.tagName); + var parentTagName = stringToLowerCase(parent.tagName); + + if (element.namespaceURI === SVG_NAMESPACE) { + // The only way to switch from HTML namespace to SVG + // is via <svg>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'svg'; + } + + // The only way to switch from MathML to SVG is via + // svg if parent is either <annotation-xml> or MathML + // text integration points. + if (parent.namespaceURI === MATHML_NAMESPACE) { + return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); + } + + // We only allow elements that are defined in SVG + // spec. All others are disallowed in SVG namespace. + return Boolean(ALL_SVG_TAGS[tagName]); + } + + if (element.namespaceURI === MATHML_NAMESPACE) { + // The only way to switch from HTML namespace to MathML + // is via <math>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'math'; + } + + // The only way to switch from SVG to MathML is via + // <math> and HTML integration points + if (parent.namespaceURI === SVG_NAMESPACE) { + return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; + } + + // We only allow elements that are defined in MathML + // spec. All others are disallowed in MathML namespace. + return Boolean(ALL_MATHML_TAGS[tagName]); + } + + if (element.namespaceURI === HTML_NAMESPACE) { + // The only way to switch from SVG to HTML is via + // HTML integration points, and from MathML to HTML + // is via MathML text integration points + if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + // Certain elements are allowed in both SVG and HTML + // namespace. We need to specify them explicitly + // so that they don't get erronously deleted from + // HTML namespace. + var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); + + // We disallow tags that are specific for MathML + // or SVG and should never appear in HTML namespace + return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); + } + + // The code should never reach this place (this means + // that the element somehow got namespace that is not + // HTML, SVG or MathML). Return false just in case. + return false; + }; + + /** + * _forceRemove + * + * @param {Node} node a DOM node + */ + var _forceRemove = function _forceRemove(node) { + arrayPush(DOMPurify.removed, { element: node }); + try { + node.parentNode.removeChild(node); + } catch (_) { + try { + node.outerHTML = emptyHTML; + } catch (_) { + node.remove(); + } + } + }; + + /** + * _removeAttribute + * + * @param {String} name an Attribute name + * @param {Node} node a DOM node + */ + var _removeAttribute = function _removeAttribute(name, node) { + try { + arrayPush(DOMPurify.removed, { + attribute: node.getAttributeNode(name), + from: node + }); + } catch (_) { + arrayPush(DOMPurify.removed, { + attribute: null, + from: node + }); + } + + node.removeAttribute(name); + }; + + /** + * _initDocument + * + * @param {String} dirty a string of dirty markup + * @return {Document} a DOM, filled with the dirty markup + */ + var _initDocument = function _initDocument(dirty) { + /* Create a HTML document */ + var doc = void 0; + var leadingWhitespace = void 0; + + if (FORCE_BODY) { + dirty = '<remove></remove>' + dirty; + } else { + /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ + var matches = stringMatch(dirty, /^[\r\n\t ]+/); + leadingWhitespace = matches && matches[0]; + } + + var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; + /* Use the DOMParser API by default, fallback later if needs be */ + try { + doc = new DOMParser().parseFromString(dirtyPayload, 'text/html'); + } catch (_) {} + + /* Use createHTMLDocument in case DOMParser is not available */ + if (!doc || !doc.documentElement) { + doc = implementation.createHTMLDocument(''); + var _doc = doc, + body = _doc.body; + + body.parentNode.removeChild(body.parentNode.firstElementChild); + body.outerHTML = dirtyPayload; + } + + if (dirty && leadingWhitespace) { + doc.body.insertBefore(document.createTextNode(leadingWhitespace), doc.body.childNodes[0] || null); + } + + /* Work on whole document or just its body */ + return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; + }; + + /** + * _createIterator + * + * @param {Document} root document/fragment to create iterator for + * @return {Iterator} iterator instance + */ + var _createIterator = function _createIterator(root) { + return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, function () { + return NodeFilter.FILTER_ACCEPT; + }, false); + }; + + /** + * _isClobbered + * + * @param {Node} elm element to check for clobbering attacks + * @return {Boolean} true if clobbered, false if safe + */ + var _isClobbered = function _isClobbered(elm) { + if (elm instanceof Text || elm instanceof Comment) { + return false; + } + + if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') { + return true; + } + + return false; + }; + + /** + * _isNode + * + * @param {Node} obj object to check whether it's a DOM node + * @return {Boolean} true is object is a DOM node + */ + var _isNode = function _isNode(object) { + return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; + }; + + /** + * _executeHook + * Execute user configurable hooks + * + * @param {String} entryPoint Name of the hook's entry point + * @param {Node} currentNode node to work on with the hook + * @param {Object} data additional hook parameters + */ + var _executeHook = function _executeHook(entryPoint, currentNode, data) { + if (!hooks[entryPoint]) { + return; + } + + arrayForEach(hooks[entryPoint], function (hook) { + hook.call(DOMPurify, currentNode, data, CONFIG); + }); + }; + + /** + * _sanitizeElements + * + * @protect nodeName + * @protect textContent + * @protect removeChild + * + * @param {Node} currentNode to check for permission to exist + * @return {Boolean} true if node was killed, false if left alive + */ + var _sanitizeElements = function _sanitizeElements(currentNode) { + var content = void 0; + + /* Execute a hook if present */ + _executeHook('beforeSanitizeElements', currentNode, null); + + /* Check if element is clobbered or can clobber */ + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Check if tagname contains Unicode */ + if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { + _forceRemove(currentNode); + return true; + } + + /* Now let's check the element's type and name */ + var tagName = stringToLowerCase(currentNode.nodeName); + + /* Execute a hook if present */ + _executeHook('uponSanitizeElement', currentNode, { + tagName: tagName, + allowedTags: ALLOWED_TAGS + }); + + /* Detect mXSS attempts abusing namespace confusion */ + if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { + _forceRemove(currentNode); + return true; + } + + /* Remove element if anything forbids its presence */ + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + /* Keep content except for bad-listed elements */ + if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { + var parentNode = getParentNode(currentNode); + var childNodes = getChildNodes(currentNode); + var childCount = childNodes.length; + for (var i = childCount - 1; i >= 0; --i) { + parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode)); + } + } + + _forceRemove(currentNode); + return true; + } + + /* Check whether element has a valid namespace */ + if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { + _forceRemove(currentNode); + return true; + } + + if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) { + _forceRemove(currentNode); + return true; + } + + /* Sanitize element content to be template-safe */ + if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { + /* Get the element's text content */ + content = currentNode.textContent; + content = stringReplace(content, MUSTACHE_EXPR$$1, ' '); + content = stringReplace(content, ERB_EXPR$$1, ' '); + if (currentNode.textContent !== content) { + arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); + currentNode.textContent = content; + } + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeElements', currentNode, null); + + return false; + }; + + /** + * _isValidAttribute + * + * @param {string} lcTag Lowercase tag name of containing element. + * @param {string} lcName Lowercase attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid, otherwise false. + */ + // eslint-disable-next-line complexity + var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { + /* Make sure attribute cannot clobber */ + if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { + return false; + } + + /* Allow valid data-* attributes: At least one character after "-" + (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) + XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) + We don't need to check the value; it's always URI safe. */ + if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { + return false; + + /* Check value is safe. First, is attr inert? If so, is safe */ + } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else { + return false; + } + + return true; + }; + + /** + * _sanitizeAttributes + * + * @protect attributes + * @protect nodeName + * @protect removeAttribute + * @protect setAttribute + * + * @param {Node} currentNode to sanitize + */ + var _sanitizeAttributes = function _sanitizeAttributes(currentNode) { + var attr = void 0; + var value = void 0; + var lcName = void 0; + var l = void 0; + /* Execute a hook if present */ + _executeHook('beforeSanitizeAttributes', currentNode, null); + + var attributes = currentNode.attributes; + + /* Check if we have attributes; if not we might have a text node */ + + if (!attributes) { + return; + } + + var hookEvent = { + attrName: '', + attrValue: '', + keepAttr: true, + allowedAttributes: ALLOWED_ATTR + }; + l = attributes.length; + + /* Go backwards over all attributes; safely remove bad ones */ + while (l--) { + attr = attributes[l]; + var _attr = attr, + name = _attr.name, + namespaceURI = _attr.namespaceURI; + + value = stringTrim(attr.value); + lcName = stringToLowerCase(name); + + /* Execute a hook if present */ + hookEvent.attrName = lcName; + hookEvent.attrValue = value; + hookEvent.keepAttr = true; + hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set + _executeHook('uponSanitizeAttribute', currentNode, hookEvent); + value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ + if (hookEvent.forceKeepAttr) { + continue; + } + + /* Remove attribute */ + _removeAttribute(name, currentNode); + + /* Did the hooks approve of the attribute? */ + if (!hookEvent.keepAttr) { + continue; + } + + /* Work around a security issue in jQuery 3.0 */ + if (regExpTest(/\/>/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Sanitize attribute content to be template-safe */ + if (SAFE_FOR_TEMPLATES) { + value = stringReplace(value, MUSTACHE_EXPR$$1, ' '); + value = stringReplace(value, ERB_EXPR$$1, ' '); + } + + /* Is `value` valid for this attribute? */ + var lcTag = currentNode.nodeName.toLowerCase(); + if (!_isValidAttribute(lcTag, lcName, value)) { + continue; + } + + /* Handle invalid data-* attribute set by try-catching it */ + try { + if (namespaceURI) { + currentNode.setAttributeNS(namespaceURI, name, value); + } else { + /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ + currentNode.setAttribute(name, value); + } + + arrayPop(DOMPurify.removed); + } catch (_) {} + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeAttributes', currentNode, null); + }; + + /** + * _sanitizeShadowDOM + * + * @param {DocumentFragment} fragment to iterate over recursively + */ + var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { + var shadowNode = void 0; + var shadowIterator = _createIterator(fragment); + + /* Execute a hook if present */ + _executeHook('beforeSanitizeShadowDOM', fragment, null); + + while (shadowNode = shadowIterator.nextNode()) { + /* Execute a hook if present */ + _executeHook('uponSanitizeShadowNode', shadowNode, null); + + /* Sanitize tags and elements */ + if (_sanitizeElements(shadowNode)) { + continue; + } + + /* Deep shadow DOM detected */ + if (shadowNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(shadowNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(shadowNode); + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeShadowDOM', fragment, null); + }; + + /** + * Sanitize + * Public method providing core sanitation functionality + * + * @param {String|Node} dirty string or DOM node + * @param {Object} configuration object + */ + // eslint-disable-next-line complexity + DOMPurify.sanitize = function (dirty, cfg) { + var body = void 0; + var importedNode = void 0; + var currentNode = void 0; + var oldNode = void 0; + var returnNode = void 0; + /* Make sure we have a string to sanitize. + DO NOT return early, as this will return the wrong type if + the user has requested a DOM object rather than a string */ + if (!dirty) { + dirty = '<!-->'; + } + + /* Stringify, in case dirty is an object */ + if (typeof dirty !== 'string' && !_isNode(dirty)) { + // eslint-disable-next-line no-negated-condition + if (typeof dirty.toString !== 'function') { + throw typeErrorCreate('toString is not a function'); + } else { + dirty = dirty.toString(); + if (typeof dirty !== 'string') { + throw typeErrorCreate('dirty is not a string, aborting'); + } + } + } + + /* Check we can run. Otherwise fall back or ignore */ + if (!DOMPurify.isSupported) { + if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') { + if (typeof dirty === 'string') { + return window.toStaticHTML(dirty); + } + + if (_isNode(dirty)) { + return window.toStaticHTML(dirty.outerHTML); + } + } + + return dirty; + } + + /* Assign config vars */ + if (!SET_CONFIG) { + _parseConfig(cfg); + } + + /* Clean up removed elements */ + DOMPurify.removed = []; + + /* Check if dirty is correctly typed for IN_PLACE */ + if (typeof dirty === 'string') { + IN_PLACE = false; + } + + if (IN_PLACE) ; else if (dirty instanceof Node) { + /* If dirty is a DOM element, append to an empty document to avoid + elements being stripped by the parser */ + body = _initDocument('<!---->'); + importedNode = body.ownerDocument.importNode(dirty, true); + if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') { + /* Node is already a body, use as is */ + body = importedNode; + } else if (importedNode.nodeName === 'HTML') { + body = importedNode; + } else { + // eslint-disable-next-line unicorn/prefer-node-append + body.appendChild(importedNode); + } + } else { + /* Exit directly if we have nothing to do */ + if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && + // eslint-disable-next-line unicorn/prefer-includes + dirty.indexOf('<') === -1) { + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; + } + + /* Initialize the document to work on */ + body = _initDocument(dirty); + + /* Check we have a DOM node from the data */ + if (!body) { + return RETURN_DOM ? null : emptyHTML; + } + } + + /* Remove first element node (ours) if FORCE_BODY is set */ + if (body && FORCE_BODY) { + _forceRemove(body.firstChild); + } + + /* Get node iterator */ + var nodeIterator = _createIterator(IN_PLACE ? dirty : body); + + /* Now start iterating over the created document */ + while (currentNode = nodeIterator.nextNode()) { + /* Fix IE's strange behavior with manipulated textNodes #89 */ + if (currentNode.nodeType === 3 && currentNode === oldNode) { + continue; + } + + /* Sanitize tags and elements */ + if (_sanitizeElements(currentNode)) { + continue; + } + + /* Shadow DOM detected, sanitize it */ + if (currentNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(currentNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(currentNode); + + oldNode = currentNode; + } + + oldNode = null; + + /* If we sanitized `dirty` in-place, return it. */ + if (IN_PLACE) { + return dirty; + } + + /* Return sanitized string or DOM */ + if (RETURN_DOM) { + if (RETURN_DOM_FRAGMENT) { + returnNode = createDocumentFragment.call(body.ownerDocument); + + while (body.firstChild) { + // eslint-disable-next-line unicorn/prefer-node-append + returnNode.appendChild(body.firstChild); + } + } else { + returnNode = body; + } + + if (RETURN_DOM_IMPORT) { + /* + AdoptNode() is not used because internal state is not reset + (e.g. the past names map of a HTMLFormElement), this is safe + in theory but we would rather not risk another attack vector. + The state that is cloned by importNode() is explicitly defined + by the specs. + */ + returnNode = importNode.call(originalDocument, returnNode, true); + } + + return returnNode; + } + + var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; + + /* Sanitize final string template-safe */ + if (SAFE_FOR_TEMPLATES) { + serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' '); + serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' '); + } + + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; + }; + + /** + * Public method to set the configuration once + * setConfig + * + * @param {Object} cfg configuration object + */ + DOMPurify.setConfig = function (cfg) { + _parseConfig(cfg); + SET_CONFIG = true; + }; + + /** + * Public method to remove the configuration + * clearConfig + * + */ + DOMPurify.clearConfig = function () { + CONFIG = null; + SET_CONFIG = false; + }; + + /** + * Public method to check if an attribute value is valid. + * Uses last set config, if any. Otherwise, uses config defaults. + * isValidAttribute + * + * @param {string} tag Tag name of containing element. + * @param {string} attr Attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false. + */ + DOMPurify.isValidAttribute = function (tag, attr, value) { + /* Initialize shared config vars if necessary. */ + if (!CONFIG) { + _parseConfig({}); + } + + var lcTag = stringToLowerCase(tag); + var lcName = stringToLowerCase(attr); + return _isValidAttribute(lcTag, lcName, value); + }; + + /** + * AddHook + * Public method to add DOMPurify hooks + * + * @param {String} entryPoint entry point for the hook to add + * @param {Function} hookFunction function to execute + */ + DOMPurify.addHook = function (entryPoint, hookFunction) { + if (typeof hookFunction !== 'function') { + return; + } + + hooks[entryPoint] = hooks[entryPoint] || []; + arrayPush(hooks[entryPoint], hookFunction); + }; + + /** + * RemoveHook + * Public method to remove a DOMPurify hook at a given entryPoint + * (pops it from the stack of hooks if more are present) + * + * @param {String} entryPoint entry point for the hook to remove + */ + DOMPurify.removeHook = function (entryPoint) { + if (hooks[entryPoint]) { + arrayPop(hooks[entryPoint]); + } + }; + + /** + * RemoveHooks + * Public method to remove all DOMPurify hooks at a given entryPoint + * + * @param {String} entryPoint entry point for the hooks to remove + */ + DOMPurify.removeHooks = function (entryPoint) { + if (hooks[entryPoint]) { + hooks[entryPoint] = []; + } + }; + + /** + * RemoveAllHooks + * Public method to remove all DOMPurify hooks + * + */ + DOMPurify.removeAllHooks = function () { + hooks = {}; + }; + + return DOMPurify; + } + + var purify = createDOMPurify(); + + var globalWin = window; + var globalDoc = document; + + var IMAGE_MIME_REGEX = /^image\/(p?jpe?g|gif|png|bmp)$/i; + + /** + * Wrap inlines that are in the root in paragraphs. + * + * @param {HTMLBodyElement} body + * @param {Document} doc + * @private + */ + function wrapInlines(body, doc) { + var wrapper; + + traverse(body, function (node) { + if (isInline(node, true)) { + // Ignore text nodes unless they contain non-whitespace chars as + // whitespace will be collapsed. + // Ignore sceditor-ignore elements unless wrapping siblings + // Should still wrap both if wrapping siblings. + if (wrapper || node.nodeType === TEXT_NODE ? + /\S/.test(node.nodeValue) : !is(node, '.sceditor-ignore')) { + if (!wrapper) { + wrapper = createElement('p', {}, doc); + insertBefore(wrapper, node); + } + + appendChild(wrapper, node); + } + } else { + wrapper = null; + } + }, false, true); + } + /** + * SCEditor - A lightweight WYSIWYG editor + * + * @param {HTMLTextAreaElement} original The textarea to be converted + * @param {Object} userOptions + * @class SCEditor + * @name SCEditor + */ + function SCEditor(original, userOptions) { + /** + * Alias of this + * + * @private + */ + var base = this; + + /** + * Editor format like BBCode or HTML + */ + var format; + + /** + * The div which contains the editor and toolbar + * + * @type {HTMLDivElement} + * @private + */ + var editorContainer; + + /** + * Map of events handlers bound to this instance. + * + * @type {Object} + * @private + */ + var eventHandlers = {}; + + /** + * The editors toolbar + * + * @type {HTMLDivElement} + * @private + */ + var toolbar; + + /** + * The editors iframe which should be in design mode + * + * @type {HTMLIFrameElement} + * @private + */ + var wysiwygEditor; + + /** + * The editors window + * + * @type {Window} + * @private + */ + var wysiwygWindow; + + /** + * The WYSIWYG editors body element + * + * @type {HTMLBodyElement} + * @private + */ + var wysiwygBody; + + /** + * The WYSIWYG editors document + * + * @type {Document} + * @private + */ + var wysiwygDocument; + + /** + * The editors textarea for viewing source + * + * @type {HTMLTextAreaElement} + * @private + */ + var sourceEditor; + + /** + * The current dropdown + * + * @type {HTMLDivElement} + * @private + */ + var dropdown; + + /** + * If the user is currently composing text via IME + * @type {boolean} + */ + var isComposing; + + /** + * Timer for valueChanged key handler + * @type {number} + */ + var valueChangedKeyUpTimer; + + /** + * The editors locale + * + * @private + */ + var locale; + + /** + * Stores a cache of preloaded images + * + * @private + * @type {Array.<HTMLImageElement>} + */ + var preLoadCache = []; + + /** + * The editors rangeHelper instance + * + * @type {RangeHelper} + * @private + */ + var rangeHelper; + + /** + * An array of button state handlers + * + * @type {Array.<Object>} + * @private + */ + var btnStateHandlers = []; + + /** + * Plugin manager instance + * + * @type {PluginManager} + * @private + */ + var pluginManager; + + /** + * The current node containing the selection/caret + * + * @type {Node} + * @private + */ + var currentNode; + + /** + * The first block level parent of the current node + * + * @type {node} + * @private + */ + var currentBlockNode; + + /** + * The current node selection/caret + * + * @type {Object} + * @private + */ + var currentSelection; + + /** + * Used to make sure only 1 selection changed + * check is called every 100ms. + * + * Helps improve performance as it is checked a lot. + * + * @type {boolean} + * @private + */ + var isSelectionCheckPending; + + /** + * If content is required (equivalent to the HTML5 required attribute) + * + * @type {boolean} + * @private + */ + var isRequired; + + /** + * The inline CSS style element. Will be undefined + * until css() is called for the first time. + * + * @type {HTMLStyleElement} + * @private + */ + var inlineCss; + + /** + * Object containing a list of shortcut handlers + * + * @type {Object} + * @private + */ + var shortcutHandlers = {}; + + /** + * The min and max heights that autoExpand should stay within + * + * @type {Object} + * @private + */ + var autoExpandBounds; + + /** + * Timeout for the autoExpand function to throttle calls + * + * @private + */ + var autoExpandThrottle; + + /** + * Cache of the current toolbar buttons + * + * @type {Object} + * @private + */ + var toolbarButtons = {}; + + /** + * Last scroll position before maximizing so + * it can be restored when finished. + * + * @type {number} + * @private + */ + var maximizeScrollPosition; + + /** + * Stores the contents while a paste is taking place. + * + * Needed to support browsers that lack clipboard API support. + * + * @type {?DocumentFragment} + * @private + */ + var pasteContentFragment; + + /** + * All the emoticons from dropdown, more and hidden combined + * and with the emoticons root set + * + * @type {!Object<string, string>} + * @private + */ + var allEmoticons = {}; + + /** + * Current icon set if any + * + * @type {?Object} + * @private + */ + var icons; + + /** + * Private functions + * @private + */ + var init, + replaceEmoticons, + handleCommand, + initEditor, + initLocale, + initToolBar, + initOptions, + initEvents, + initResize, + initEmoticons, + handlePasteEvt, + handleCutCopyEvt, + handlePasteData, + handleKeyDown, + handleBackSpace, + handleKeyPress, + handleFormReset, + handleMouseDown, + handleComposition, + handleEvent, + handleDocumentClick, + updateToolBar, + updateActiveButtons, + sourceEditorSelectedText, + appendNewLine, + checkSelectionChanged, + checkNodeChanged, + autofocus, + emoticonsKeyPress, + emoticonsCheckWhitespace, + currentStyledBlockNode, + triggerValueChanged, + valueChangedBlur, + valueChangedKeyUp, + autoUpdate, + autoExpand; + + /** + * All the commands supported by the editor + * @name commands + * @memberOf SCEditor.prototype + */ + base.commands = extend(true, {}, (userOptions.commands || defaultCmds)); + + /** + * Options for this editor instance + * @name opts + * @memberOf SCEditor.prototype + */ + var options = base.opts = extend( + true, {}, defaultOptions, userOptions + ); + + // Don't deep extend emoticons (fixes #565) + base.opts.emoticons = userOptions.emoticons || defaultOptions.emoticons; + + if (!Array.isArray(options.allowedIframeUrls)) { + options.allowedIframeUrls = []; + } + options.allowedIframeUrls.push('https://www.youtube-nocookie.com/embed/'); + + // Create new instance of DOMPurify for each editor instance so can + // have different allowed iframe URLs + // eslint-disable-next-line new-cap + var domPurify = purify(); + + // Allow iframes for things like YouTube, see: + // https://github.com/cure53/DOMPurify/issues/340#issuecomment-670758980 + domPurify.addHook('uponSanitizeElement', function (node, data) { + var allowedUrls = options.allowedIframeUrls; + + if (data.tagName === 'iframe') { + var src = attr(node, 'src') || ''; + + for (var i = 0; i < allowedUrls.length; i++) { + var url = allowedUrls[i]; + + if (isString(url) && src.substr(0, url.length) === url) { + return; + } + + // Handle regex + if (url.test && url.test(src)) { + return; + } + } + + // No match so remove + remove(node); + } + }); + + // Convert target attribute into data-sce-target attributes so XHTML format + // can allow them + domPurify.addHook('afterSanitizeAttributes', function (node) { + if ('target' in node) { + attr(node, 'data-sce-target', attr(node, 'target')); + } + + removeAttr(node, 'target'); + }); + + /** + * Sanitize HTML to avoid XSS + * + * @param {string} html + * @return {string} html + * @private + */ + function sanitize(html) { + return domPurify.sanitize(html, { + ADD_TAGS: ['iframe'], + ADD_ATTR: ['allowfullscreen', 'frameborder', 'target'] + }); + } + /** + * Creates the editor iframe and textarea + * @private + */ + init = function () { + original._sceditor = base; + + // Load locale + if (options.locale && options.locale !== 'en') { + initLocale(); + } + + editorContainer = createElement('div', { + className: 'sceditor-container' + }); + + insertBefore(editorContainer, original); + css(editorContainer, 'z-index', options.zIndex); + + isRequired = original.required; + original.required = false; + + var FormatCtor = SCEditor.formats[options.format]; + format = FormatCtor ? new FormatCtor() : {}; + /* + * Plugins should be initialized before the formatters since + * they may wish to add or change formatting handlers and + * since the bbcode format caches its handlers, + * such changes must be done first. + */ + pluginManager = new PluginManager(base); + (options.plugins || '').split(',').forEach(function (plugin) { + pluginManager.register(plugin.trim()); + }); + if ('init' in format) { + format.init.call(base); + } + + // create the editor + initEmoticons(); + initToolBar(); + initEditor(); + initOptions(); + initEvents(); + + // force into source mode if is a browser that can't handle + // full editing + if (!isWysiwygSupported) { + base.toggleSourceMode(); + } + + updateActiveButtons(); + + var loaded = function () { + off(globalWin, 'load', loaded); + + if (options.autofocus) { + autofocus(!!options.autofocusEnd); + } + + autoExpand(); + appendNewLine(); + // TODO: use editor doc and window? + pluginManager.call('ready'); + if ('onReady' in format) { + format.onReady.call(base); + } + }; + on(globalWin, 'load', loaded); + if (globalDoc.readyState === 'complete') { + loaded(); + } + }; + + /** + * Init the locale variable with the specified locale if possible + * @private + * @return void + */ + initLocale = function () { + var lang; + + locale = SCEditor.locale[options.locale]; + + if (!locale) { + lang = options.locale.split('-'); + locale = SCEditor.locale[lang[0]]; + } + + // Locale DateTime format overrides any specified in the options + if (locale && locale.dateFormat) { + options.dateFormat = locale.dateFormat; + } + }; + + /** + * Creates the editor iframe and textarea + * @private + */ + initEditor = function () { + sourceEditor = createElement('textarea'); + wysiwygEditor = createElement('iframe', { + frameborder: 0, + allowfullscreen: true + }); + + /* + * This needs to be done right after they are created because, + * for any reason, the user may not want the value to be tinkered + * by any filters. + */ + if (options.startInSourceMode) { + addClass(editorContainer, 'sourceMode'); + hide(wysiwygEditor); + } else { + addClass(editorContainer, 'wysiwygMode'); + hide(sourceEditor); + } + + if (!options.spellcheck) { + attr(editorContainer, 'spellcheck', 'false'); + } + + if (globalWin.location.protocol === 'https:') { + attr(wysiwygEditor, 'src', 'about:blank'); + } + + // Add the editor to the container + appendChild(editorContainer, wysiwygEditor); + appendChild(editorContainer, sourceEditor); + + // TODO: make this optional somehow + base.dimensions( + options.width || width(original), + options.height || height(original) + ); + + // Add ios to HTML so can apply CSS fix to only it + var className = ios ? ' ios' : ''; + + wysiwygDocument = wysiwygEditor.contentDocument; + wysiwygDocument.open(); + wysiwygDocument.write(_tmpl('html', { + attrs: ' class="' + className + '"', + spellcheck: options.spellcheck ? '' : 'spellcheck="false"', + charset: options.charset, + style: options.style + })); + wysiwygDocument.close(); + + wysiwygBody = wysiwygDocument.body; + wysiwygWindow = wysiwygEditor.contentWindow; + + base.readOnly(!!options.readOnly); + + // iframe overflow fix for iOS + if (ios) { + height(wysiwygBody, '100%'); + on(wysiwygBody, 'touchend', base.focus); + } + + var tabIndex = attr(original, 'tabindex'); + attr(sourceEditor, 'tabindex', tabIndex); + attr(wysiwygEditor, 'tabindex', tabIndex); + + rangeHelper = new RangeHelper(wysiwygWindow, null, sanitize); + + // load any textarea value into the editor + hide(original); + base.val(original.value); + + var placeholder = options.placeholder || + attr(original, 'placeholder'); + + if (placeholder) { + sourceEditor.placeholder = placeholder; + attr(wysiwygBody, 'placeholder', placeholder); + } + }; + + /** + * Initialises options + * @private + */ + initOptions = function () { + // auto-update original textbox on blur if option set to true + if (options.autoUpdate) { + on(wysiwygBody, 'blur', autoUpdate); + on(sourceEditor, 'blur', autoUpdate); + } + + if (options.rtl === null) { + options.rtl = css(sourceEditor, 'direction') === 'rtl'; + } + + base.rtl(!!options.rtl); + + if (options.autoExpand) { + // Need to update when images (or anything else) loads + on(wysiwygBody, 'load', autoExpand, EVENT_CAPTURE); + on(wysiwygBody, 'input keyup', autoExpand); + } + + if (options.resizeEnabled) { + initResize(); + } + + attr(editorContainer, 'id', options.id); + base.emoticons(options.emoticonsEnabled); + }; + + /** + * Initialises events + * @private + */ + initEvents = function () { + var form = original.form; + var compositionEvents = 'compositionstart compositionend'; + var eventsToForward = + 'keydown keyup keypress focus blur contextmenu input'; + var checkSelectionEvents = 'onselectionchange' in wysiwygDocument ? + 'selectionchange' : + 'keyup focus blur contextmenu mouseup touchend click'; + + on(globalDoc, 'click', handleDocumentClick); + + if (form) { + on(form, 'reset', handleFormReset); + on(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + on(window, 'pagehide', base.updateOriginal); + on(window, 'pageshow', handleFormReset); + on(wysiwygBody, 'keypress', handleKeyPress); + on(wysiwygBody, 'keydown', handleKeyDown); + on(wysiwygBody, 'keydown', handleBackSpace); + on(wysiwygBody, 'keyup', appendNewLine); + on(wysiwygBody, 'blur', valueChangedBlur); + on(wysiwygBody, 'keyup', valueChangedKeyUp); + on(wysiwygBody, 'paste', handlePasteEvt); + on(wysiwygBody, 'cut copy', handleCutCopyEvt); + on(wysiwygBody, compositionEvents, handleComposition); + on(wysiwygBody, checkSelectionEvents, checkSelectionChanged); + on(wysiwygBody, eventsToForward, handleEvent); + + if (options.emoticonsCompat && globalWin.getSelection) { + on(wysiwygBody, 'keyup', emoticonsCheckWhitespace); + } + + on(wysiwygBody, 'blur', function () { + if (!base.val()) { + addClass(wysiwygBody, 'placeholder'); + } + }); + + on(wysiwygBody, 'focus', function () { + removeClass(wysiwygBody, 'placeholder'); + }); + + on(sourceEditor, 'blur', valueChangedBlur); + on(sourceEditor, 'keyup', valueChangedKeyUp); + on(sourceEditor, 'keydown', handleKeyDown); + on(sourceEditor, compositionEvents, handleComposition); + on(sourceEditor, eventsToForward, handleEvent); + + on(wysiwygDocument, 'mousedown', handleMouseDown); + on(wysiwygDocument, checkSelectionEvents, checkSelectionChanged); + on(wysiwygDocument, 'keyup', appendNewLine); + + on(editorContainer, 'selectionchanged', checkNodeChanged); + on(editorContainer, 'selectionchanged', updateActiveButtons); + // Custom events to forward + on( + editorContainer, + 'selectionchanged valuechanged nodechanged pasteraw paste', + handleEvent + ); + }; + + /** + * Creates the toolbar and appends it to the container + * @private + */ + initToolBar = function () { + var group, + commands = base.commands, + exclude = (options.toolbarExclude || '').split(','), + groups = options.toolbar.split('|'); + + toolbar = createElement('div', { + className: 'sceditor-toolbar', + unselectable: 'on' + }); + + if (options.icons in SCEditor.icons) { + icons = new SCEditor.icons[options.icons](); + } + + each(groups, function (_, menuItems) { + group = createElement('div', { + className: 'sceditor-group' + }); + + each(menuItems.split(','), function (_, commandName) { + var button, shortcut, + command = commands[commandName]; + + // The commandName must be a valid command and not excluded + if (!command || exclude.indexOf(commandName) > -1) { + return; + } + + shortcut = command.shortcut; + button = _tmpl('toolbarButton', { + name: commandName, + dispName: base._(command.name || + command.tooltip || commandName) + }, true).firstChild; + + if (icons && icons.create) { + var icon = icons.create(commandName); + if (icon) { + insertBefore(icons.create(commandName), + button.firstChild); + addClass(button, 'has-icon'); + } + } + + button._sceTxtMode = !!command.txtExec; + button._sceWysiwygMode = !!command.exec; + toggleClass(button, 'disabled', !command.exec); + on(button, 'click', function (e) { + if (!hasClass(button, 'disabled')) { + handleCommand(button, command); + } + + updateActiveButtons(); + e.preventDefault(); + }); + // Prevent editor losing focus when button clicked + on(button, 'mousedown', function (e) { + base.closeDropDown(); + e.preventDefault(); + }); + + if (command.tooltip) { + attr(button, 'title', + base._(command.tooltip) + + (shortcut ? ' (' + shortcut + ')' : '') + ); + } + + if (shortcut) { + base.addShortcut(shortcut, commandName); + } + + if (command.state) { + btnStateHandlers.push({ + name: commandName, + state: command.state + }); + // exec string commands can be passed to queryCommandState + } else if (isString(command.exec)) { + btnStateHandlers.push({ + name: commandName, + state: command.exec + }); + } + + appendChild(group, button); + toolbarButtons[commandName] = button; + }); + + // Exclude empty groups + if (group.firstChild) { + appendChild(toolbar, group); + } + }); + + // Append the toolbar to the toolbarContainer option if given + appendChild(options.toolbarContainer || editorContainer, toolbar); + }; + + /** + * Creates the resizer. + * @private + */ + initResize = function () { + var minHeight, maxHeight, minWidth, maxWidth, + mouseMoveFunc, mouseUpFunc, + grip = createElement('div', { + className: 'sceditor-grip' + }), + // Cover is used to cover the editor iframe so document + // still gets mouse move events + cover = createElement('div', { + className: 'sceditor-resize-cover' + }), + moveEvents = 'touchmove mousemove', + endEvents = 'touchcancel touchend mouseup', + startX = 0, + startY = 0, + newX = 0, + newY = 0, + startWidth = 0, + startHeight = 0, + origWidth = width(editorContainer), + origHeight = height(editorContainer), + isDragging = false, + rtl = base.rtl(); + + minHeight = options.resizeMinHeight || origHeight / 1.5; + maxHeight = options.resizeMaxHeight || origHeight * 2.5; + minWidth = options.resizeMinWidth || origWidth / 1.25; + maxWidth = options.resizeMaxWidth || origWidth * 1.25; + + mouseMoveFunc = function (e) { + // iOS uses window.event + if (e.type === 'touchmove') { + e = globalWin.event; + newX = e.changedTouches[0].pageX; + newY = e.changedTouches[0].pageY; + } else { + newX = e.pageX; + newY = e.pageY; + } + + var newHeight = startHeight + (newY - startY), + newWidth = rtl ? + startWidth - (newX - startX) : + startWidth + (newX - startX); + + if (maxWidth > 0 && newWidth > maxWidth) { + newWidth = maxWidth; + } + if (minWidth > 0 && newWidth < minWidth) { + newWidth = minWidth; + } + if (!options.resizeWidth) { + newWidth = false; + } + + if (maxHeight > 0 && newHeight > maxHeight) { + newHeight = maxHeight; + } + if (minHeight > 0 && newHeight < minHeight) { + newHeight = minHeight; + } + if (!options.resizeHeight) { + newHeight = false; + } + + if (newWidth || newHeight) { + base.dimensions(newWidth, newHeight); + } + + e.preventDefault(); + }; + + mouseUpFunc = function (e) { + if (!isDragging) { + return; + } + + isDragging = false; + + hide(cover); + removeClass(editorContainer, 'resizing'); + off(globalDoc, moveEvents, mouseMoveFunc); + off(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }; + + if (icons && icons.create) { + var icon = icons.create('grip'); + if (icon) { + appendChild(grip, icon); + addClass(grip, 'has-icon'); + } + } + + appendChild(editorContainer, grip); + appendChild(editorContainer, cover); + hide(cover); + + on(grip, 'touchstart mousedown', function (e) { + // iOS uses window.event + if (e.type === 'touchstart') { + e = globalWin.event; + startX = e.touches[0].pageX; + startY = e.touches[0].pageY; + } else { + startX = e.pageX; + startY = e.pageY; + } + + startWidth = width(editorContainer); + startHeight = height(editorContainer); + isDragging = true; + + addClass(editorContainer, 'resizing'); + show(cover); + on(globalDoc, moveEvents, mouseMoveFunc); + on(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }); + }; + + /** + * Prefixes and preloads the emoticon images + * @private + */ + initEmoticons = function () { + var emoticons = options.emoticons; + var root = options.emoticonsRoot || ''; + + if (emoticons) { + allEmoticons = extend( + {}, emoticons.more, emoticons.dropdown, emoticons.hidden + ); + } + + each(allEmoticons, function (key, url) { + allEmoticons[key] = _tmpl('emoticon', { + key: key, + // Prefix emoticon root to emoticon urls + url: root + (url.url || url), + tooltip: url.tooltip || key + }); + + // Preload the emoticon + if (options.emoticonsEnabled) { + preLoadCache.push(createElement('img', { + src: root + (url.url || url) + })); + } + }); + }; + + /** + * Autofocus the editor + * @private + */ + autofocus = function (focusEnd) { + var range, txtPos, + node = wysiwygBody.firstChild; + + // Can't focus invisible elements + if (!isVisible(editorContainer)) { + return; + } + + if (base.sourceMode()) { + txtPos = focusEnd ? sourceEditor.value.length : 0; + + sourceEditor.setSelectionRange(txtPos, txtPos); + + return; + } + + removeWhiteSpace(wysiwygBody); + + if (focusEnd) { + if (!(node = wysiwygBody.lastChild)) { + node = createElement('p', {}, wysiwygDocument); + appendChild(wysiwygBody, node); + } + + while (node.lastChild) { + node = node.lastChild; + + // Should place the cursor before the last <br> + if (is(node, 'br') && node.previousSibling) { + node = node.previousSibling; + } + } + } + + range = wysiwygDocument.createRange(); + + if (!canHaveChildren(node)) { + range.setStartBefore(node); + + if (focusEnd) { + range.setStartAfter(node); + } + } else { + range.selectNodeContents(node); + } + + range.collapse(!focusEnd); + rangeHelper.selectRange(range); + currentSelection = range; + + if (focusEnd) { + wysiwygBody.scrollTop = wysiwygBody.scrollHeight; + } + + base.focus(); + }; + + /** + * Gets if the editor is read only + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly + * @return {boolean} + */ + /** + * Sets if the editor is read only + * + * @param {boolean} readOnly + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly^2 + * @return {this} + */ + base.readOnly = function (readOnly) { + if (typeof readOnly !== 'boolean') { + return !sourceEditor.readonly; + } + + wysiwygBody.contentEditable = !readOnly; + sourceEditor.readonly = !readOnly; + + updateToolBar(readOnly); + + return base; + }; + + /** + * Gets if the editor is in RTL mode + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl + * @return {boolean} + */ + /** + * Sets if the editor is in RTL mode + * + * @param {boolean} rtl + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl^2 + * @return {this} + */ + base.rtl = function (rtl) { + var dir = rtl ? 'rtl' : 'ltr'; + + if (typeof rtl !== 'boolean') { + return attr(sourceEditor, 'dir') === 'rtl'; + } + + attr(wysiwygBody, 'dir', dir); + attr(sourceEditor, 'dir', dir); + + removeClass(editorContainer, 'rtl'); + removeClass(editorContainer, 'ltr'); + addClass(editorContainer, dir); + + if (icons && icons.rtl) { + icons.rtl(rtl); + } + + return base; + }; + + /** + * Updates the toolbar to disable/enable the appropriate buttons + * @private + */ + updateToolBar = function (disable) { + var mode = base.inSourceMode() ? '_sceTxtMode' : '_sceWysiwygMode'; + + each(toolbarButtons, function (_, button) { + toggleClass(button, 'disabled', disable || !button[mode]); + }); + }; + + /** + * Gets the width of the editor in pixels + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width + * @return {number} + */ + /** + * Sets the width of the editor + * + * @param {number} width Width in pixels + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width^2 + * @return {this} + */ + /** + * Sets the width of the editor + * + * The saveWidth specifies if to save the width. The stored width can be + * used for things like restoring from maximized state. + * + * @param {number} width Width in pixels + * @param {boolean} [saveWidth=true] If to store the width + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name width^3 + * @return {this} + */ + base.width = function (width$1, saveWidth) { + if (!width$1 && width$1 !== 0) { + return width(editorContainer); + } + + base.dimensions(width$1, null, saveWidth); + + return base; + }; + + /** + * Returns an object with the properties width and height + * which are the width and height of the editor in px. + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions + * @return {object} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^2 + * @return {this} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * <p>The save argument specifies if to save the new sizes. + * The saved sizes can be used for things like restoring from + * maximized state. This should normally be left as true.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @param {boolean} [save=true] If to store the new sizes + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^3 + * @return {this} + */ + base.dimensions = function (width$1, height$1, save) { + // set undefined width/height to boolean false + width$1 = (!width$1 && width$1 !== 0) ? false : width$1; + height$1 = (!height$1 && height$1 !== 0) ? false : height$1; + + if (width$1 === false && height$1 === false) { + return { width: base.width(), height: base.height() }; + } + + if (width$1 !== false) { + if (save !== false) { + options.width = width$1; + } + + width(editorContainer, width$1); + } + + if (height$1 !== false) { + if (save !== false) { + options.height = height$1; + } + + height(editorContainer, height$1); + } + + return base; + }; + + /** + * Gets the height of the editor in px + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height + * @return {number} + */ + /** + * Sets the height of the editor + * + * @param {number} height Height in px + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height^2 + * @return {this} + */ + /** + * Sets the height of the editor + * + * The saveHeight specifies if to save the height. + * + * The stored height can be used for things like + * restoring from maximized state. + * + * @param {number} height Height in px + * @param {boolean} [saveHeight=true] If to store the height + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name height^3 + * @return {this} + */ + base.height = function (height$1, saveHeight) { + if (!height$1 && height$1 !== 0) { + return height(editorContainer); + } + + base.dimensions(null, height$1, saveHeight); + + return base; + }; + + /** + * Gets if the editor is maximised or not + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize + * @return {boolean} + */ + /** + * Sets if the editor is maximised or not + * + * @param {boolean} maximize If to maximise the editor + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize^2 + * @return {this} + */ + base.maximize = function (maximize) { + var maximizeSize = 'sceditor-maximize'; + + if (isUndefined(maximize)) { + return hasClass(editorContainer, maximizeSize); + } + + maximize = !!maximize; + + if (maximize) { + maximizeScrollPosition = globalWin.pageYOffset; + } + + toggleClass(globalDoc.documentElement, maximizeSize, maximize); + toggleClass(globalDoc.body, maximizeSize, maximize); + toggleClass(editorContainer, maximizeSize, maximize); + base.width(maximize ? '100%' : options.width, false); + base.height(maximize ? '100%' : options.height, false); + + if (!maximize) { + globalWin.scrollTo(0, maximizeScrollPosition); + } + + autoExpand(); + + return base; + }; + + autoExpand = function () { + if (options.autoExpand && !autoExpandThrottle) { + autoExpandThrottle = setTimeout(base.expandToContent, 200); + } + }; + + /** + * Expands or shrinks the editors height to the height of it's content + * + * Unless ignoreMaxHeight is set to true it will not expand + * higher than the maxHeight option. + * + * @since 1.3.5 + * @param {boolean} [ignoreMaxHeight=false] + * @function + * @name expandToContent + * @memberOf SCEditor.prototype + * @see #resizeToContent + */ + base.expandToContent = function (ignoreMaxHeight) { + if (base.maximize()) { + return; + } + + clearTimeout(autoExpandThrottle); + autoExpandThrottle = false; + + if (!autoExpandBounds) { + var height$1 = options.resizeMinHeight || options.height || + height(original); + + autoExpandBounds = { + min: height$1, + max: options.resizeMaxHeight || (height$1 * 2) + }; + } + + var range = globalDoc.createRange(); + range.selectNodeContents(wysiwygBody); + + var rect = range.getBoundingClientRect(); + var current = wysiwygDocument.documentElement.clientHeight - 1; + var spaceNeeded = rect.bottom - rect.top; + var newHeight = base.height() + 1 + (spaceNeeded - current); + + if (!ignoreMaxHeight && autoExpandBounds.max !== -1) { + newHeight = Math.min(newHeight, autoExpandBounds.max); + } + + base.height(Math.ceil(Math.max(newHeight, autoExpandBounds.min))); + }; + + /** + * Destroys the editor, removing all elements and + * event handlers. + * + * Leaves only the original textarea. + * + * @function + * @name destroy + * @memberOf SCEditor.prototype + */ + base.destroy = function () { + // Don't destroy if the editor has already been destroyed + if (!pluginManager) { + return; + } + + pluginManager.destroy(); + + rangeHelper = null; + pluginManager = null; + + if (dropdown) { + remove(dropdown); + } + + off(globalDoc, 'click', handleDocumentClick); + + var form = original.form; + if (form) { + off(form, 'reset', handleFormReset); + off(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + off(window, 'pagehide', base.updateOriginal); + off(window, 'pageshow', handleFormReset); + remove(sourceEditor); + remove(toolbar); + remove(editorContainer); + + delete original._sceditor; + show(original); + + original.required = isRequired; + }; + + + /** + * Creates a menu item drop down + * + * @param {HTMLElement} menuItem The button to align the dropdown with + * @param {string} name Used for styling the dropdown, will be + * a class sceditor-name + * @param {HTMLElement} content The HTML content of the dropdown + * @function + * @name createDropDown + * @memberOf SCEditor.prototype + */ + base.createDropDown = function (menuItem, name, content) { + // first click for create second click for close + var dropDownCss, + dropDownClass = 'sceditor-' + name; + + base.closeDropDown(); + + // Only close the dropdown if it was already open + if (dropdown && hasClass(dropdown, dropDownClass)) { + return; + } + + dropDownCss = extend({ + top: menuItem.offsetTop, + left: menuItem.offsetLeft, + marginTop: menuItem.clientHeight + }, options.dropDownCss); + + dropdown = createElement('div', { + className: 'sceditor-dropdown ' + dropDownClass + }); + + css(dropdown, dropDownCss); + appendChild(dropdown, content); + appendChild(editorContainer, dropdown); + on(dropdown, 'click focusin', function (e) { + // stop clicks within the dropdown from being handled + e.stopPropagation(); + }); + + if (dropdown) { + var first = find(dropdown, 'input,textarea')[0]; + if (first) { + first.focus(); + } + } + }; + + /** + * Handles any document click and closes the dropdown if open + * @private + */ + handleDocumentClick = function (e) { + // ignore right clicks + if (e.which !== 3 && dropdown && !e.defaultPrevented) { + autoUpdate(); + + base.closeDropDown(); + } + }; + + /** + * Handles the WYSIWYG editors cut & copy events + * + * By default browsers also copy inherited styling from the stylesheet and + * browser default styling which is unnecessary. + * + * This will ignore inherited styles and only copy inline styling. + * @private + */ + handleCutCopyEvt = function (e) { + var range = rangeHelper.selectedRange(); + if (range) { + var container = createElement('div', {}, wysiwygDocument); + var firstParent; + + // Copy all inline parent nodes up to the first block parent so can + // copy inline styles + var parent = range.commonAncestorContainer; + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + if (container.firstChild) { + appendChild(clone, container.firstChild); + } + + appendChild(container, clone); + firstParent = firstParent || clone; + } + parent = parent.parentNode; + } + + appendChild(firstParent || container, range.cloneContents()); + removeWhiteSpace(container); + + e.clipboardData.setData('text/html', container.innerHTML); + + // TODO: Refactor into private shared module with plaintext plugin + // innerText adds two newlines after <p> tags so convert them to + // <div> tags + each(find(container, 'p'), function (_, elm) { + convertElement(elm, 'div'); + }); + // Remove collapsed <br> tags as innerText converts them to newlines + each(find(container, 'br'), function (_, elm) { + if (!elm.nextSibling || !isInline(elm.nextSibling, true)) { + remove(elm); + } + }); + + // range.toString() doesn't include newlines so can't use that. + // selection.toString() seems to use the same method as innerText + // but needs to be normalised first so using container.innerText + appendChild(wysiwygBody, container); + e.clipboardData.setData('text/plain', container.innerText); + remove(container); + + if (e.type === 'cut') { + range.deleteContents(); + } + + e.preventDefault(); + } + }; + + /** + * Handles the WYSIWYG editors paste event + * @private + */ + handlePasteEvt = function (e) { + var editable = wysiwygBody; + var clipboard = e.clipboardData; + var loadImage = function (file) { + var reader = new FileReader(); + reader.onload = function (e) { + handlePasteData({ + html: '<img src="' + e.target.result + '" />' + }); + }; + reader.readAsDataURL(file); + }; + + // Modern browsers with clipboard API - everything other than _very_ + // old android web views and UC browser which doesn't support the + // paste event at all. + if (clipboard) { + var data = {}; + var types = clipboard.types; + var items = clipboard.items; + + e.preventDefault(); + + for (var i = 0; i < types.length; i++) { + // Word sometimes adds copied text as an image so if HTML + // exists prefer that over images + if (types.indexOf('text/html') < 0) { + // Normalise image pasting to paste as a data-uri + if (globalWin.FileReader && items && + IMAGE_MIME_REGEX.test(items[i].type)) { + return loadImage(clipboard.items[i].getAsFile()); + } + } + + data[types[i]] = clipboard.getData(types[i]); + } + // Call plugins here with file? + data.text = data['text/plain']; + data.html = sanitize(data['text/html']); + + handlePasteData(data); + // If contentsFragment exists then we are already waiting for a + // previous paste so let the handler for that handle this one too + } else if (!pasteContentFragment) { + // Save the scroll position so can be restored + // when contents is restored + var scrollTop = editable.scrollTop; + + rangeHelper.saveRange(); + + pasteContentFragment = globalDoc.createDocumentFragment(); + while (editable.firstChild) { + appendChild(pasteContentFragment, editable.firstChild); + } + + setTimeout(function () { + var html = editable.innerHTML; + + editable.innerHTML = ''; + appendChild(editable, pasteContentFragment); + editable.scrollTop = scrollTop; + pasteContentFragment = false; + + rangeHelper.restoreRange(); + + handlePasteData({ html: sanitize(html) }); + }, 0); + } + }; + + /** + * Gets the pasted data, filters it and then inserts it. + * @param {Object} data + * @private + */ + handlePasteData = function (data) { + var pasteArea = createElement('div', {}, wysiwygDocument); + + pluginManager.call('pasteRaw', data); + trigger(editorContainer, 'pasteraw', data); + + if (data.html) { + // Sanitize again in case plugins modified the HTML + pasteArea.innerHTML = sanitize(data.html); + + // fix any invalid nesting + fixNesting(pasteArea); + } else { + pasteArea.innerHTML = entities(data.text || ''); + } + + var paste = { + val: pasteArea.innerHTML + }; + + if ('fragmentToSource' in format) { + paste.val = format + .fragmentToSource(paste.val, wysiwygDocument, currentNode); + } + + pluginManager.call('paste', paste); + trigger(editorContainer, 'paste', paste); + + if ('fragmentToHtml' in format) { + paste.val = format + .fragmentToHtml(paste.val, currentNode); + } + + pluginManager.call('pasteHtml', paste); + + var parent = rangeHelper.getFirstBlockParent(); + base.wysiwygEditorInsertHtml(paste.val, null, true); + merge(parent); + }; + + /** + * Closes any currently open drop down + * + * @param {boolean} [focus=false] If to focus the editor + * after closing the drop down + * @function + * @name closeDropDown + * @memberOf SCEditor.prototype + */ + base.closeDropDown = function (focus) { + if (dropdown) { + remove(dropdown); + dropdown = null; + } + + if (focus === true) { + base.focus(); + } + }; + + + /** + * Inserts HTML into WYSIWYG editor. + * + * If endHtml is specified, any selected text will be placed + * between html and endHtml. If there is no selected text html + * and endHtml will just be concatenate together. + * + * @param {string} html + * @param {string} [endHtml=null] + * @param {boolean} [overrideCodeBlocking=false] If to insert the html + * into code tags, by + * default code tags only + * support text. + * @function + * @name wysiwygEditorInsertHtml + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertHtml = function ( + html, endHtml, overrideCodeBlocking + ) { + var marker, scrollTop, scrollTo, + editorHeight = height(wysiwygEditor); + + base.focus(); + + // TODO: This code tag should be configurable and + // should maybe convert the HTML into text instead + // Don't apply to code elements + if (!overrideCodeBlocking && closest(currentBlockNode, 'code')) { + return; + } + + // Insert the HTML and save the range so the editor can be scrolled + // to the end of the selection. Also allows emoticons to be replaced + // without affecting the cursor position + rangeHelper.insertHTML(html, endHtml); + rangeHelper.saveRange(); + replaceEmoticons(); + + // Fix any invalid nesting, e.g. if a quote or other block is inserted + // into a paragraph + fixNesting(wysiwygBody); + + // Scroll the editor after the end of the selection + marker = find(wysiwygBody, '#sceditor-end-marker')[0]; + show(marker); + scrollTop = wysiwygBody.scrollTop; + scrollTo = (getOffset(marker).top + + (marker.offsetHeight * 1.5)) - editorHeight; + hide(marker); + + // Only scroll if marker isn't already visible + if (scrollTo > scrollTop || scrollTo + editorHeight < scrollTop) { + wysiwygBody.scrollTop = scrollTo; + } + + triggerValueChanged(false); + rangeHelper.restoreRange(); + + // Add a new line after the last block element + // so can always add text after it + appendNewLine(); + }; + + /** + * Like wysiwygEditorInsertHtml except it will convert any HTML + * into text before inserting it. + * + * @param {string} text + * @param {string} [endText=null] + * @function + * @name wysiwygEditorInsertText + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertText = function (text, endText) { + base.wysiwygEditorInsertHtml( + entities(text), entities(endText) + ); + }; + + /** + * Inserts text into the WYSIWYG or source editor depending on which + * mode the editor is in. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.3.5 + * @function + * @name insertText + * @memberOf SCEditor.prototype + */ + base.insertText = function (text, endText) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(text, endText); + } else { + base.wysiwygEditorInsertText(text, endText); + } + + return base; + }; + + /** + * Like wysiwygEditorInsertHtml but inserts text into the + * source mode editor instead. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * The cursor will be placed after the text param. If endText is + * specified the cursor will be placed before endText, so passing:<br /> + * + * '[b]', '[/b]' + * + * Would cause the cursor to be placed:<br /> + * + * [b]Selected text|[/b] + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.4.0 + * @function + * @name sourceEditorInsertText + * @memberOf SCEditor.prototype + */ + base.sourceEditorInsertText = function (text, endText) { + var scrollTop, currentValue, + startPos = sourceEditor.selectionStart, + endPos = sourceEditor.selectionEnd; + + scrollTop = sourceEditor.scrollTop; + sourceEditor.focus(); + currentValue = sourceEditor.value; + + if (endText) { + text += currentValue.substring(startPos, endPos) + endText; + } + + sourceEditor.value = currentValue.substring(0, startPos) + + text + + currentValue.substring(endPos, currentValue.length); + + sourceEditor.selectionStart = (startPos + text.length) - + (endText ? endText.length : 0); + sourceEditor.selectionEnd = sourceEditor.selectionStart; + + sourceEditor.scrollTop = scrollTop; + sourceEditor.focus(); + + triggerValueChanged(); + }; + + /** + * Gets the current instance of the rangeHelper class + * for the editor. + * + * @return {RangeHelper} + * @function + * @name getRangeHelper + * @memberOf SCEditor.prototype + */ + base.getRangeHelper = function () { + return rangeHelper; + }; + + /** + * Gets or sets the source editor caret position. + * + * @param {Object} [position] + * @return {this} + * @function + * @since 1.4.5 + * @name sourceEditorCaret + * @memberOf SCEditor.prototype + */ + base.sourceEditorCaret = function (position) { + sourceEditor.focus(); + + if (position) { + sourceEditor.selectionStart = position.start; + sourceEditor.selectionEnd = position.end; + + return this; + } + + return { + start: sourceEditor.selectionStart, + end: sourceEditor.selectionEnd + }; + }; + + /** + * Gets the value of the editor. + * + * If the editor is in WYSIWYG mode it will return the filtered + * HTML from it (converted to BBCode if using the BBCode plugin). + * It it's in Source Mode it will return the unfiltered contents + * of the source editor (if using the BBCode plugin this will be + * BBCode again). + * + * @since 1.3.5 + * @return {string} + * @function + * @name val + * @memberOf SCEditor.prototype + */ + /** + * Sets the value of the editor. + * + * If filter set true the val will be passed through the filter + * function. If using the BBCode plugin it will pass the val to + * the BBCode filter to convert any BBCode into HTML. + * + * @param {string} val + * @param {boolean} [filter=true] + * @return {this} + * @since 1.3.5 + * @function + * @name val^2 + * @memberOf SCEditor.prototype + */ + base.val = function (val, filter) { + if (!isString(val)) { + return base.inSourceMode() ? + base.getSourceEditorValue(false) : + base.getWysiwygEditorValue(filter); + } + + if (!base.inSourceMode()) { + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + base.setWysiwygEditorValue(val); + } else { + base.setSourceEditorValue(val); + } + + return base; + }; + + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @return {this} + * @since 1.3.5 + * @function + * @name insert + * @memberOf SCEditor.prototype + */ + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * If the allowMixed param is set to true, HTML any will not be + * escaped + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @param {boolean} [allowMixed=false] + * @return {this} + * @since 1.4.3 + * @function + * @name insert^2 + * @memberOf SCEditor.prototype + */ + // eslint-disable-next-line max-params + base.insert = function ( + start, end, filter, convertEmoticons, allowMixed + ) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(start, end); + return base; + } + + // Add the selection between start and end + if (end) { + var html = rangeHelper.selectedHtml(); + + if (filter !== false && 'fragmentToSource' in format) { + html = format + .fragmentToSource(html, wysiwygDocument, currentNode); + } + + start += html + end; + } + // TODO: This filter should allow empty tags as it's inserting. + if (filter !== false && 'fragmentToHtml' in format) { + start = format.fragmentToHtml(start, currentNode); + } + + // Convert any escaped HTML back into HTML if mixed is allowed + if (filter !== false && allowMixed === true) { + start = start.replace(/</g, '<') + .replace(/>/g, '>') + .replace(/&/g, '&'); + } + + base.wysiwygEditorInsertHtml(start); + + return base; + }; + + /** + * Gets the WYSIWYG editors HTML value. + * + * If using a plugin that filters the Ht Ml like the BBCode plugin + * it will return the result of the filtering (BBCode) unless the + * filter param is set to false. + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @name getWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.getWysiwygEditorValue = function (filter) { + var html; + // Create a tmp node to store contents so it can be modified + // without affecting anything else. + var tmp = createElement('div', {}, wysiwygDocument); + var childNodes = wysiwygBody.childNodes; + + for (var i = 0; i < childNodes.length; i++) { + appendChild(tmp, childNodes[i].cloneNode(true)); + } + + appendChild(wysiwygBody, tmp); + fixNesting(tmp); + remove(tmp); + + html = tmp.innerHTML; + + // filter the HTML and DOM through any plugins + if (filter !== false && format.hasOwnProperty('toSource')) { + html = format.toSource(html, wysiwygDocument); + } + + return html; + }; + + /** + * Gets the WYSIWYG editor's iFrame Body. + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getBody + * @memberOf SCEditor.prototype + */ + base.getBody = function () { + return wysiwygBody; + }; + + /** + * Gets the WYSIWYG editors container area (whole iFrame). + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getContentAreaContainer + * @memberOf SCEditor.prototype + */ + base.getContentAreaContainer = function () { + return wysiwygEditor; + }; + + /** + * Gets the text editor value + * + * If using a plugin that filters the text like the BBCode plugin + * it will return the result of the filtering which is BBCode to + * HTML so it will return HTML. If filter is set to false it will + * just return the contents of the source editor (BBCode). + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @since 1.4.0 + * @name getSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.getSourceEditorValue = function (filter) { + var val = sourceEditor.value; + + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + return val; + }; + + /** + * Sets the WYSIWYG HTML editor value. Should only be the HTML + * contained within the body tags + * + * @param {string} value + * @function + * @name setWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.setWysiwygEditorValue = function (value) { + if (!value) { + value = '<p><br /></p>'; + } + + wysiwygBody.innerHTML = sanitize(value); + replaceEmoticons(); + + appendNewLine(); + triggerValueChanged(); + autoExpand(); + }; + + /** + * Sets the text editor value + * + * @param {string} value + * @function + * @name setSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.setSourceEditorValue = function (value) { + sourceEditor.value = value; + + triggerValueChanged(); + }; + + /** + * Updates the textarea that the editor is replacing + * with the value currently inside the editor. + * + * @function + * @name updateOriginal + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.updateOriginal = function () { + original.value = base.val(); + }; + + /** + * Replaces any emoticon codes in the passed HTML + * with their emoticon images + * @private + */ + replaceEmoticons = function () { + if (options.emoticonsEnabled) { + replace(wysiwygBody, allEmoticons, options.emoticonsCompat); + } + }; + + /** + * If the editor is in source code mode + * + * @return {boolean} + * @function + * @name inSourceMode + * @memberOf SCEditor.prototype + */ + base.inSourceMode = function () { + return hasClass(editorContainer, 'sourceMode'); + }; + + /** + * Gets if the editor is in sourceMode + * + * @return boolean + * @function + * @name sourceMode + * @memberOf SCEditor.prototype + */ + /** + * Sets if the editor is in sourceMode + * + * @param {boolean} enable + * @return {this} + * @function + * @name sourceMode^2 + * @memberOf SCEditor.prototype + */ + base.sourceMode = function (enable) { + var inSourceMode = base.inSourceMode(); + + if (typeof enable !== 'boolean') { + return inSourceMode; + } + + if ((inSourceMode && !enable) || (!inSourceMode && enable)) { + base.toggleSourceMode(); + } + + return base; + }; + + /** + * Switches between the WYSIWYG and source modes + * + * @function + * @name toggleSourceMode + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.toggleSourceMode = function () { + var isInSourceMode = base.inSourceMode(); + + // don't allow switching to WYSIWYG if doesn't support it + if (!isWysiwygSupported && isInSourceMode) { + return; + } + + if (!isInSourceMode) { + rangeHelper.saveRange(); + rangeHelper.clear(); + } + + currentSelection = null; + base.blur(); + + if (isInSourceMode) { + base.setWysiwygEditorValue(base.getSourceEditorValue()); + } else { + base.setSourceEditorValue(base.getWysiwygEditorValue()); + } + + toggle(sourceEditor); + toggle(wysiwygEditor); + + toggleClass(editorContainer, 'wysiwygMode', isInSourceMode); + toggleClass(editorContainer, 'sourceMode', !isInSourceMode); + + updateToolBar(); + updateActiveButtons(); + }; + + /** + * Gets the selected text of the source editor + * @return {string} + * @private + */ + sourceEditorSelectedText = function () { + sourceEditor.focus(); + + return sourceEditor.value.substring( + sourceEditor.selectionStart, + sourceEditor.selectionEnd + ); + }; + + /** + * Handles the passed command + * @private + */ + handleCommand = function (caller, cmd) { + // check if in text mode and handle text commands + if (base.inSourceMode()) { + if (cmd.txtExec) { + if (Array.isArray(cmd.txtExec)) { + base.sourceEditorInsertText.apply(base, cmd.txtExec); + } else { + cmd.txtExec.call(base, caller, sourceEditorSelectedText()); + } + } + } else if (cmd.exec) { + if (isFunction(cmd.exec)) { + cmd.exec.call(base, caller); + } else { + base.execCommand( + cmd.exec, + cmd.hasOwnProperty('execParam') ? cmd.execParam : null + ); + } + } + + }; + + /** + * Executes a command on the WYSIWYG editor + * + * @param {string} command + * @param {String|Boolean} [param] + * @function + * @name execCommand + * @memberOf SCEditor.prototype + */ + base.execCommand = function (command, param) { + var executed = false, + commandObj = base.commands[command]; + + base.focus(); + + // TODO: make configurable + // don't apply any commands to code elements + if (closest(rangeHelper.parentNode(), 'code')) { + return; + } + + try { + executed = wysiwygDocument.execCommand(command, false, param); + } catch (ex) { } + + // show error if execution failed and an error message exists + if (!executed && commandObj && commandObj.errorMessage) { + /*global alert:false*/ + alert(base._(commandObj.errorMessage)); + } + + updateActiveButtons(); + }; + + /** + * Checks if the current selection has changed and triggers + * the selectionchanged event if it has. + * + * In browsers other that don't support selectionchange event it will check + * at most once every 100ms. + * @private + */ + checkSelectionChanged = function () { + function check() { + // Don't create new selection if there isn't one (like after + // blur event in iOS) + if (wysiwygWindow.getSelection() && + wysiwygWindow.getSelection().rangeCount <= 0) { + currentSelection = null; + // rangeHelper could be null if editor was destroyed + // before the timeout had finished + } else if (rangeHelper && !rangeHelper.compare(currentSelection)) { + currentSelection = rangeHelper.cloneSelected(); + + // If the selection is in an inline wrap it in a block. + // Fixes #331 + if (currentSelection && currentSelection.collapsed) { + var parent = currentSelection.startContainer; + var offset = currentSelection.startOffset; + + // Handle if selection is placed before/after an element + if (offset && parent.nodeType !== TEXT_NODE) { + parent = parent.childNodes[offset]; + } + + while (parent && parent.parentNode !== wysiwygBody) { + parent = parent.parentNode; + } + + if (parent && isInline(parent, true)) { + rangeHelper.saveRange(); + wrapInlines(wysiwygBody, wysiwygDocument); + rangeHelper.restoreRange(); + } + } + + trigger(editorContainer, 'selectionchanged'); + } + + isSelectionCheckPending = false; + } + + if (isSelectionCheckPending) { + return; + } + + isSelectionCheckPending = true; + + // Don't need to limit checking if browser supports the Selection API + if ('onselectionchange' in wysiwygDocument) { + check(); + } else { + setTimeout(check, 100); + } + }; + + /** + * Checks if the current node has changed and triggers + * the nodechanged event if it has + * @private + */ + checkNodeChanged = function () { + // check if node has changed + var oldNode, + node = rangeHelper.parentNode(); + + if (currentNode !== node) { + oldNode = currentNode; + currentNode = node; + currentBlockNode = rangeHelper.getFirstBlockParent(node); + + trigger(editorContainer, 'nodechanged', { + oldNode: oldNode, + newNode: currentNode + }); + } + }; + + /** + * Gets the current node that contains the selection/caret in + * WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentNode + * @memberOf SCEditor.prototype + */ + base.currentNode = function () { + return currentNode; + }; + + /** + * Gets the first block level node that contains the + * selection/caret in WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentBlockNode + * @memberOf SCEditor.prototype + * @since 1.4.4 + */ + base.currentBlockNode = function () { + return currentBlockNode; + }; + + /** + * Updates if buttons are active or not + * @private + */ + updateActiveButtons = function () { + var firstBlock, parent; + var activeClass = 'active'; + var doc = wysiwygDocument; + var isSource = base.sourceMode(); + + if (base.readOnly()) { + each(find(toolbar, activeClass), function (_, menuItem) { + removeClass(menuItem, activeClass); + }); + return; + } + + if (!isSource) { + parent = rangeHelper.parentNode(); + firstBlock = rangeHelper.getFirstBlockParent(parent); + } + + for (var j = 0; j < btnStateHandlers.length; j++) { + var state = 0; + var btn = toolbarButtons[btnStateHandlers[j].name]; + var stateFn = btnStateHandlers[j].state; + var isDisabled = (isSource && !btn._sceTxtMode) || + (!isSource && !btn._sceWysiwygMode); + + if (isString(stateFn)) { + if (!isSource) { + try { + state = doc.queryCommandEnabled(stateFn) ? 0 : -1; + + // eslint-disable-next-line max-depth + if (state > -1) { + state = doc.queryCommandState(stateFn) ? 1 : 0; + } + } catch (ex) {} + } + } else if (!isDisabled) { + state = stateFn.call(base, parent, firstBlock); + } + + toggleClass(btn, 'disabled', isDisabled || state < 0); + toggleClass(btn, activeClass, state > 0); + } + + if (icons && icons.update) { + icons.update(isSource, parent, firstBlock); + } + }; + + /** + * Handles any key press in the WYSIWYG editor + * + * @private + */ + handleKeyPress = function (e) { + // FF bug: https://bugzilla.mozilla.org/show_bug.cgi?id=501496 + if (e.defaultPrevented) { + return; + } + + base.closeDropDown(); + + // 13 = enter key + if (e.which === 13) { + var LIST_TAGS = 'li,ul,ol'; + + // "Fix" (cludge) for blocklevel elements being duplicated in some + // browsers when enter is pressed instead of inserting a newline + if (!is(currentBlockNode, LIST_TAGS) && + hasStyling(currentBlockNode)) { + + var br = createElement('br', {}, wysiwygDocument); + rangeHelper.insertNode(br); + + // Last <br> of a block will be collapsed so need to make sure + // the <br> that was inserted isn't the last node of a block. + var parent = br.parentNode; + var lastChild = parent.lastChild; + + // Sometimes an empty next node is created after the <br> + if (lastChild && lastChild.nodeType === TEXT_NODE && + lastChild.nodeValue === '') { + remove(lastChild); + lastChild = parent.lastChild; + } + + // If this is the last BR of a block and the previous + // sibling is inline then will need an extra BR. This + // is needed because the last BR of a block will be + // collapsed. Fixes issue #248 + if (!isInline(parent, true) && lastChild === br && + isInline(br.previousSibling)) { + rangeHelper.insertHTML('<br>'); + } + + e.preventDefault(); + } + } + }; + + /** + * Makes sure that if there is a code or quote tag at the + * end of the editor, that there is a new line after it. + * + * If there wasn't a new line at the end you wouldn't be able + * to enter any text after a code/quote tag + * @return {void} + * @private + */ + appendNewLine = function () { + // Check all nodes in reverse until either add a new line + // or reach a non-empty textnode or BR at which point can + // stop checking. + rTraverse(wysiwygBody, function (node) { + // Last block, add new line after if has styling + if (node.nodeType === ELEMENT_NODE && + !/inline/.test(css(node, 'display'))) { + + // Add line break after if has styling + if (!is(node, '.sceditor-nlf') && hasStyling(node)) { + var paragraph = createElement('p', {}, wysiwygDocument); + paragraph.className = 'sceditor-nlf'; + paragraph.innerHTML = '<br />'; + appendChild(wysiwygBody, paragraph); + return false; + } + } + + // Last non-empty text node or line break. + // No need to add line-break after them + if ((node.nodeType === 3 && !/^\s*$/.test(node.nodeValue)) || + is(node, 'br')) { + return false; + } + }); + }; + + /** + * Handles form reset event + * @private + */ + handleFormReset = function () { + base.val(original.value); + }; + + /** + * Handles any mousedown press in the WYSIWYG editor + * @private + */ + handleMouseDown = function () { + base.closeDropDown(); + }; + + /** + * Translates the string into the locale language. + * + * Replaces any {0}, {1}, {2}, ect. with the params provided. + * + * @param {string} str + * @param {...String} args + * @return {string} + * @function + * @name _ + * @memberOf SCEditor.prototype + */ + base._ = function () { + var undef, + args = arguments; + + if (locale && locale[args[0]]) { + args[0] = locale[args[0]]; + } + + return args[0].replace(/\{(\d+)\}/g, function (str, p1) { + return args[p1 - 0 + 1] !== undef ? + args[p1 - 0 + 1] : + '{' + p1 + '}'; + }); + }; + + /** + * Passes events on to any handlers + * @private + * @return void + */ + handleEvent = function (e) { + if (pluginManager) { + // Send event to all plugins + pluginManager.call(e.type + 'Event', e, base); + } + + // convert the event into a custom event to send + var name = (e.target === sourceEditor ? 'scesrc' : 'scewys') + e.type; + + if (eventHandlers[name]) { + eventHandlers[name].forEach(function (fn) { + fn.call(base, e); + }); + } + }; + + /** + * Binds a handler to the specified events + * + * This function only binds to a limited list of + * supported events. + * + * The supported events are: + * + * * keyup + * * keydown + * * Keypress + * * blur + * * focus + * * input + * * nodechanged - When the current node containing + * the selection changes in WYSIWYG mode + * * contextmenu + * * selectionchanged + * * valuechanged + * + * + * The events param should be a string containing the event(s) + * to bind this handler to. If multiple, they should be separated + * by spaces. + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name bind + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.bind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + var wysEvent = 'scewys' + events[i]; + var srcEvent = 'scesrc' + events[i]; + // Use custom events to allow passing the instance as the + // 2nd argument. + // Also allows unbinding without unbinding the editors own + // event handlers. + if (!excludeWysiwyg) { + eventHandlers[wysEvent] = eventHandlers[wysEvent] || []; + eventHandlers[wysEvent].push(handler); + } + + if (!excludeSource) { + eventHandlers[srcEvent] = eventHandlers[srcEvent] || []; + eventHandlers[srcEvent].push(handler); + } + + // Start sending value changed events + if (events[i] === 'valuechanged') { + triggerValueChanged.hasHandler = true; + } + } + } + + return base; + }; + + /** + * Unbinds an event that was bound using bind(). + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude unbinding this + * handler from the WYSIWYG editor + * @param {boolean} excludeSource if to exclude unbinding this + * handler from the source editor + * @return {this} + * @function + * @name unbind + * @memberOf SCEditor.prototype + * @since 1.4.1 + * @see bind + */ + base.unbind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + if (!excludeWysiwyg) { + arrayRemove( + eventHandlers['scewys' + events[i]] || [], handler); + } + + if (!excludeSource) { + arrayRemove( + eventHandlers['scesrc' + events[i]] || [], handler); + } + } + } + + return base; + }; + + /** + * Blurs the editors input area + * + * @return {this} + * @function + * @name blur + * @memberOf SCEditor.prototype + * @since 1.3.6 + */ + /** + * Adds a handler to the editors blur event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name blur^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.blur = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('blur', handler, excludeWysiwyg, excludeSource); + } else if (!base.sourceMode()) { + wysiwygBody.blur(); + } else { + sourceEditor.blur(); + } + + return base; + }; + + /** + * Focuses the editors input area + * + * @return {this} + * @function + * @name focus + * @memberOf SCEditor.prototype + */ + /** + * Adds an event handler to the focus event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name focus^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.focus = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('focus', handler, excludeWysiwyg, excludeSource); + } else if (!base.inSourceMode()) { + // Already has focus so do nothing + if (find(wysiwygDocument, ':focus').length) { + return; + } + + var container; + var rng = rangeHelper.selectedRange(); + + // Fix FF bug where it shows the cursor in the wrong place + // if the editor hasn't had focus before. See issue #393 + if (!currentSelection) { + autofocus(true); + } + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (rng && rng.endOffset === 1 && rng.collapsed) { + container = rng.endContainer; + + if (container && container.childNodes.length === 1 && + is(container.firstChild, 'br')) { + rng.setStartBefore(container.firstChild); + rng.collapse(true); + rangeHelper.selectRange(rng); + } + } + + wysiwygWindow.focus(); + wysiwygBody.focus(); + } else { + sourceEditor.focus(); + } + + updateActiveButtons(); + + return base; + }; + + /** + * Adds a handler to the key down event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyDown + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyDown = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keydown', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key press event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyPress + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyPress = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('keypress', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key up event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyUp + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyUp = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keyup', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the node changed event. + * + * Happens whenever the node containing the selection/caret + * changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name nodeChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.nodeChanged = function (handler) { + return base.bind('nodechanged', handler, false, true); + }; + + /** + * Adds a handler to the selection changed event + * + * Happens whenever the selection changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name selectionChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.selectionChanged = function (handler) { + return base.bind('selectionchanged', handler, false, true); + }; + + /** + * Adds a handler to the value changed event + * + * Happens whenever the current editor value changes. + * + * Whenever anything is inserted, the value changed or + * 1.5 secs after text is typed. If a space is typed it will + * cause the event to be triggered immediately instead of + * after 1.5 seconds + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name valueChanged + * @memberOf SCEditor.prototype + * @since 1.4.5 + */ + base.valueChanged = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('valuechanged', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Emoticons keypress handler + * @private + */ + emoticonsKeyPress = function (e) { + var replacedEmoticon, + cachePos = 0, + emoticonsCache = base.emoticonsCache, + curChar = String.fromCharCode(e.which); + + // TODO: Make configurable + if (closest(currentBlockNode, 'code')) { + return; + } + + if (!emoticonsCache) { + emoticonsCache = []; + + each(allEmoticons, function (key, html) { + emoticonsCache[cachePos++] = [key, html]; + }); + + emoticonsCache.sort(function (a, b) { + return a[0].length - b[0].length; + }); + + base.emoticonsCache = emoticonsCache; + base.longestEmoticonCode = + emoticonsCache[emoticonsCache.length - 1][0].length; + } + + replacedEmoticon = rangeHelper.replaceKeyword( + base.emoticonsCache, + true, + true, + base.longestEmoticonCode, + options.emoticonsCompat, + curChar + ); + + if (replacedEmoticon) { + if (!options.emoticonsCompat || !/^\s$/.test(curChar)) { + e.preventDefault(); + } + } + }; + + /** + * Makes sure emoticons are surrounded by whitespace + * @private + */ + emoticonsCheckWhitespace = function () { + checkWhitespace(currentBlockNode, rangeHelper); + }; + + /** + * Gets if emoticons are currently enabled + * @return {boolean} + * @function + * @name emoticons + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + /** + * Enables/disables emoticons + * + * @param {boolean} enable + * @return {this} + * @function + * @name emoticons^2 + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + base.emoticons = function (enable) { + if (!enable && enable !== false) { + return options.emoticonsEnabled; + } + + options.emoticonsEnabled = enable; + + if (enable) { + on(wysiwygBody, 'keypress', emoticonsKeyPress); + + if (!base.sourceMode()) { + rangeHelper.saveRange(); + + replaceEmoticons(); + triggerValueChanged(false); + + rangeHelper.restoreRange(); + } + } else { + var emoticons = + find(wysiwygBody, 'img[data-sceditor-emoticon]'); + + each(emoticons, function (_, img) { + var text = data(img, 'sceditor-emoticon'); + var textNode = wysiwygDocument.createTextNode(text); + img.parentNode.replaceChild(textNode, img); + }); + + off(wysiwygBody, 'keypress', emoticonsKeyPress); + + triggerValueChanged(); + } + + return base; + }; + + /** + * Gets the current WYSIWYG editors inline CSS + * + * @return {string} + * @function + * @name css + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + /** + * Sets inline CSS for the WYSIWYG editor + * + * @param {string} css + * @return {this} + * @function + * @name css^2 + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + base.css = function (css) { + if (!inlineCss) { + inlineCss = createElement('style', { + id: 'inline' + }, wysiwygDocument); + + appendChild(wysiwygDocument.head, inlineCss); + } + + if (!isString(css)) { + return inlineCss.styleSheet ? + inlineCss.styleSheet.cssText : inlineCss.innerHTML; + } + + if (inlineCss.styleSheet) { + inlineCss.styleSheet.cssText = css; + } else { + inlineCss.innerHTML = css; + } + + return base; + }; + + /** + * Handles the keydown event, used for shortcuts + * @private + */ + handleKeyDown = function (e) { + var shortcut = [], + SHIFT_KEYS = { + '`': '~', + '1': '!', + '2': '@', + '3': '#', + '4': '$', + '5': '%', + '6': '^', + '7': '&', + '8': '*', + '9': '(', + '0': ')', + '-': '_', + '=': '+', + ';': ': ', + '\'': '"', + ',': '<', + '.': '>', + '/': '?', + '\\': '|', + '[': '{', + ']': '}' + }, + SPECIAL_KEYS = { + 8: 'backspace', + 9: 'tab', + 13: 'enter', + 19: 'pause', + 20: 'capslock', + 27: 'esc', + 32: 'space', + 33: 'pageup', + 34: 'pagedown', + 35: 'end', + 36: 'home', + 37: 'left', + 38: 'up', + 39: 'right', + 40: 'down', + 45: 'insert', + 46: 'del', + 91: 'win', + 92: 'win', + 93: 'select', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9', + 106: '*', + 107: '+', + 109: '-', + 110: '.', + 111: '/', + 112: 'f1', + 113: 'f2', + 114: 'f3', + 115: 'f4', + 116: 'f5', + 117: 'f6', + 118: 'f7', + 119: 'f8', + 120: 'f9', + 121: 'f10', + 122: 'f11', + 123: 'f12', + 144: 'numlock', + 145: 'scrolllock', + 186: ';', + 187: '=', + 188: ',', + 189: '-', + 190: '.', + 191: '/', + 192: '`', + 219: '[', + 220: '\\', + 221: ']', + 222: '\'' + }, + NUMPAD_SHIFT_KEYS = { + 109: '-', + 110: 'del', + 111: '/', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9' + }, + which = e.which, + character = SPECIAL_KEYS[which] || + String.fromCharCode(which).toLowerCase(); + + if (e.ctrlKey || e.metaKey) { + shortcut.push('ctrl'); + } + + if (e.altKey) { + shortcut.push('alt'); + } + + if (e.shiftKey) { + shortcut.push('shift'); + + if (NUMPAD_SHIFT_KEYS[which]) { + character = NUMPAD_SHIFT_KEYS[which]; + } else if (SHIFT_KEYS[character]) { + character = SHIFT_KEYS[character]; + } + } + + // Shift is 16, ctrl is 17 and alt is 18 + if (character && (which < 16 || which > 18)) { + shortcut.push(character); + } + + shortcut = shortcut.join('+'); + if (shortcutHandlers[shortcut] && + shortcutHandlers[shortcut].call(base) === false) { + + e.stopPropagation(); + e.preventDefault(); + } + }; + + /** + * Adds a shortcut handler to the editor + * @param {string} shortcut + * @param {String|Function} cmd + * @return {sceditor} + */ + base.addShortcut = function (shortcut, cmd) { + shortcut = shortcut.toLowerCase(); + + if (isString(cmd)) { + shortcutHandlers[shortcut] = function () { + handleCommand(toolbarButtons[cmd], base.commands[cmd]); + + return false; + }; + } else { + shortcutHandlers[shortcut] = cmd; + } + + return base; + }; + + /** + * Removes a shortcut handler + * @param {string} shortcut + * @return {sceditor} + */ + base.removeShortcut = function (shortcut) { + delete shortcutHandlers[shortcut.toLowerCase()]; + + return base; + }; + + /** + * Handles the backspace key press + * + * Will remove block styling like quotes/code ect if at the start. + * @private + */ + handleBackSpace = function (e) { + var node, offset, range, parent; + + // 8 is the backspace key + if (options.disableBlockRemove || e.which !== 8 || + !(range = rangeHelper.selectedRange())) { + return; + } + + node = range.startContainer; + offset = range.startOffset; + + if (offset !== 0 || !(parent = currentStyledBlockNode()) || + is(parent, 'body')) { + return; + } + + while (node !== parent) { + while (node.previousSibling) { + node = node.previousSibling; + + // Everything but empty text nodes before the cursor + // should prevent the style from being removed + if (node.nodeType !== TEXT_NODE || node.nodeValue) { + return; + } + } + + if (!(node = node.parentNode)) { + return; + } + } + + // The backspace was pressed at the start of + // the container so clear the style + base.clearBlockFormatting(parent); + e.preventDefault(); + }; + + /** + * Gets the first styled block node that contains the cursor + * @return {HTMLElement} + */ + currentStyledBlockNode = function () { + var block = currentBlockNode; + + while (!hasStyling(block) || isInline(block, true)) { + if (!(block = block.parentNode) || is(block, 'body')) { + return; + } + } + + return block; + }; + + /** + * Clears the formatting of the passed block element. + * + * If block is false, if will clear the styling of the first + * block level element that contains the cursor. + * @param {HTMLElement} block + * @since 1.4.4 + */ + base.clearBlockFormatting = function (block) { + block = block || currentStyledBlockNode(); + + if (!block || is(block, 'body')) { + return base; + } + + rangeHelper.saveRange(); + + block.className = ''; + + attr(block, 'style', ''); + + if (!is(block, 'p,div,td')) { + convertElement(block, 'p'); + } + + rangeHelper.restoreRange(); + return base; + }; + + /** + * Triggers the valueChanged signal if there is + * a plugin that handles it. + * + * If rangeHelper.saveRange() has already been + * called, then saveRange should be set to false + * to prevent the range being saved twice. + * + * @since 1.4.5 + * @param {boolean} saveRange If to call rangeHelper.saveRange(). + * @private + */ + triggerValueChanged = function (saveRange) { + if (!pluginManager || + (!pluginManager.hasHandler('valuechangedEvent') && + !triggerValueChanged.hasHandler)) { + return; + } + + var currentHtml, + sourceMode = base.sourceMode(), + hasSelection = !sourceMode && rangeHelper.hasSelection(); + + // Composition end isn't guaranteed to fire but must have + // ended when triggerValueChanged() is called so reset it + isComposing = false; + + // Don't need to save the range if sceditor-start-marker + // is present as the range is already saved + saveRange = saveRange !== false && + !wysiwygDocument.getElementById('sceditor-start-marker'); + + // Clear any current timeout as it's now been triggered + if (valueChangedKeyUpTimer) { + clearTimeout(valueChangedKeyUpTimer); + valueChangedKeyUpTimer = false; + } + + if (hasSelection && saveRange) { + rangeHelper.saveRange(); + } + + currentHtml = sourceMode ? sourceEditor.value : wysiwygBody.innerHTML; + + // Only trigger if something has actually changed. + if (currentHtml !== triggerValueChanged.lastVal) { + triggerValueChanged.lastVal = currentHtml; + + trigger(editorContainer, 'valuechanged', { + rawValue: sourceMode ? base.val() : currentHtml + }); + } + + if (hasSelection && saveRange) { + rangeHelper.removeMarkers(); + } + }; + + /** + * Should be called whenever there is a blur event + * @private + */ + valueChangedBlur = function () { + if (valueChangedKeyUpTimer) { + triggerValueChanged(); + } + }; + + /** + * Should be called whenever there is a keypress event + * @param {Event} e The keypress event + * @private + */ + valueChangedKeyUp = function (e) { + var which = e.which, + lastChar = valueChangedKeyUp.lastChar, + lastWasSpace = (lastChar === 13 || lastChar === 32), + lastWasDelete = (lastChar === 8 || lastChar === 46); + + valueChangedKeyUp.lastChar = which; + + if (isComposing) { + return; + } + + // 13 = return & 32 = space + if (which === 13 || which === 32) { + if (!lastWasSpace) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + // 8 = backspace & 46 = del + } else if (which === 8 || which === 46) { + if (!lastWasDelete) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + } else if (valueChangedKeyUp.triggerNext) { + triggerValueChanged(); + valueChangedKeyUp.triggerNext = false; + } + + // Clear the previous timeout and set a new one. + clearTimeout(valueChangedKeyUpTimer); + + // Trigger the event 1.5s after the last keypress if space + // isn't pressed. This might need to be lowered, will need + // to look into what the slowest average Chars Per Min is. + valueChangedKeyUpTimer = setTimeout(function () { + if (!isComposing) { + triggerValueChanged(); + } + }, 1500); + }; + + handleComposition = function (e) { + isComposing = /start/i.test(e.type); + + if (!isComposing) { + triggerValueChanged(); + } + }; + + autoUpdate = function () { + base.updateOriginal(); + }; + + // run the initializer + init(); + } + + /** + * Map containing the loaded SCEditor locales + * @type {Object} + * @name locale + * @memberOf sceditor + */ + SCEditor.locale = {}; + + SCEditor.formats = {}; + SCEditor.icons = {}; + + + /** + * Static command helper class + * @class command + * @name sceditor.command + */ + SCEditor.command = + /** @lends sceditor.command */ + { + /** + * Gets a command + * + * @param {string} name + * @return {Object|null} + * @since v1.3.5 + */ + get: function (name) { + return defaultCmds[name] || null; + }, + + /** + * <p>Adds a command to the editor or updates an existing + * command if a command with the specified name already exists.</p> + * + * <p>Once a command is add it can be included in the toolbar by + * adding it's name to the toolbar option in the constructor. It + * can also be executed manually by calling + * {@link sceditor.execCommand}</p> + * + * @example + * SCEditor.command.set("hello", + * { + * exec: function () { + * alert("Hello World!"); + * } + * }); + * + * @param {string} name + * @param {Object} cmd + * @return {this|false} Returns false if name or cmd is false + * @since v1.3.5 + */ + set: function (name, cmd) { + if (!name || !cmd) { + return false; + } + + // merge any existing command properties + cmd = extend(defaultCmds[name] || {}, cmd); + + cmd.remove = function () { + SCEditor.command.remove(name); + }; + + defaultCmds[name] = cmd; + return this; + }, + + /** + * Removes a command + * + * @param {string} name + * @return {this} + * @since v1.3.5 + */ + remove: function (name) { + if (defaultCmds[name]) { + delete defaultCmds[name]; + } + + return this; + } + }; + + /** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor - A lightweight WYSIWYG BBCode and HTML editor + * @author Sam Clarke + */ + + + window.sceditor = { + command: SCEditor.command, + commands: defaultCmds, + defaultOptions: defaultOptions, + + ios: ios, + isWysiwygSupported: isWysiwygSupported, + + regexEscape: regex, + escapeEntities: entities, + escapeUriScheme: uriScheme, + + dom: { + css: css, + attr: attr, + removeAttr: removeAttr, + is: is, + closest: closest, + width: width, + height: height, + traverse: traverse, + rTraverse: rTraverse, + parseHTML: parseHTML, + hasStyling: hasStyling, + convertElement: convertElement, + blockLevelList: blockLevelList, + canHaveChildren: canHaveChildren, + isInline: isInline, + copyCSS: copyCSS, + fixNesting: fixNesting, + findCommonAncestor: findCommonAncestor, + getSibling: getSibling, + removeWhiteSpace: removeWhiteSpace, + extractContents: extractContents, + getOffset: getOffset, + getStyle: getStyle, + hasStyle: hasStyle + }, + locale: SCEditor.locale, + icons: SCEditor.icons, + utils: { + each: each, + isEmptyObject: isEmptyObject, + extend: extend + }, + plugins: PluginManager.plugins, + formats: SCEditor.formats, + create: function (textarea, options) { + options = options || {}; + + // Don't allow the editor to be initialised + // on it's own source editor + if (parent(textarea, '.sceditor-container')) { + return; + } + + if (options.runWithoutWysiwygSupport || isWysiwygSupported) { + /*eslint no-new: off*/ + (new SCEditor(textarea, options)); + } + }, + instance: function (textarea) { + return textarea._sceditor; + } + }; + + /** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor - A lightweight WYSIWYG BBCode and HTML editor + * @author Sam Clarke + * @requires jQuery + */ + + + // For backwards compatibility + $__default['default'].sceditor = window.sceditor; + + /** + * Creates an instance of sceditor on all textareas + * matched by the jQuery selector. + * + * If options is set to "state" it will return bool value + * indicating if the editor has been initialised on the + * matched textarea(s). If there is only one textarea + * it will return the bool value for that textarea. + * If more than one textarea is matched it will + * return an array of bool values for each textarea. + * + * If options is set to "instance" it will return the + * current editor instance for the textarea(s). Like the + * state option, if only one textarea is matched this will + * return just the instance for that textarea. If more than + * one textarea is matched it will return an array of + * instances each textarea. + * + * @param {Object|string} [options] Should either be an Object of options or + * the strings "state" or "instance" + * @return {this|Array<SCEditor>|Array<boolean>|SCEditor|boolean} + */ + $__default['default'].fn.sceditor = function (options) { + var instance; + var ret = []; + + this.each(function () { + instance = this._sceditor; + + // Add state of instance to ret if that is what options is set to + if (options === 'state') { + ret.push(!!instance); + } else if (options === 'instance') { + ret.push(instance); + } else if (!instance) { + $__default['default'].sceditor.create(this, options); + } + }); + + // If nothing in the ret array then must be init so return this + if (!ret.length) { + return this; + } + + return ret.length === 1 ? ret[0] : ret; + }; + +}(jQuery)); +;/** + * SCEditor BBCode Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2011-2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor BBCode Format + * @author Sam Clarke + */ +(function (sceditor) { + /*eslint max-depth: off*/ + 'use strict'; + + var escapeEntities = sceditor.escapeEntities; + var escapeUriScheme = sceditor.escapeUriScheme; + var dom = sceditor.dom; + var utils = sceditor.utils; + + var css = dom.css; + var attr = dom.attr; + var is = dom.is; + var extend = utils.extend; + var each = utils.each; + + var EMOTICON_DATA_ATTR = 'data-sceditor-emoticon'; + + var getEditorCommand = sceditor.command.get; + + var QuoteType = { + /** @lends BBCodeParser.QuoteType */ + /** + * Always quote the attribute value + * @type {Number} + */ + always: 1, + + /** + * Never quote the attributes value + * @type {Number} + */ + never: 2, + + /** + * Only quote the attributes value when it contains spaces to equals + * @type {Number} + */ + auto: 3 + }; + + var defaultCommandsOverrides = { + bold: { + txtExec: ['[b]', '[/b]'] + }, + italic: { + txtExec: ['[i]', '[/i]'] + }, + underline: { + txtExec: ['[u]', '[/u]'] + }, + strike: { + txtExec: ['[s]', '[/s]'] + }, + subscript: { + txtExec: ['[sub]', '[/sub]'] + }, + superscript: { + txtExec: ['[sup]', '[/sup]'] + }, + left: { + txtExec: ['[left]', '[/left]'] + }, + center: { + txtExec: ['[center]', '[/center]'] + }, + right: { + txtExec: ['[right]', '[/right]'] + }, + justify: { + txtExec: ['[justify]', '[/justify]'] + }, + font: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('font')._dropDown( + editor, + caller, + function (fontName) { + editor.insertText( + '[font=' + fontName + ']', + '[/font]' + ); + } + ); + } + }, + size: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('size')._dropDown( + editor, + caller, + function (fontSize) { + editor.insertText( + '[size=' + fontSize + ']', + '[/size]' + ); + } + ); + } + }, + color: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('color')._dropDown( + editor, + caller, + function (color) { + editor.insertText( + '[color=' + color + ']', + '[/color]' + ); + } + ); + } + }, + bulletlist: { + txtExec: function (caller, selected) { + this.insertText( + '[ul]\n[li]' + + selected.split(/\r?\n/).join('[/li]\n[li]') + + '[/li]\n[/ul]' + ); + } + }, + orderedlist: { + txtExec: function (caller, selected) { + this.insertText( + '[ol]\n[li]' + + selected.split(/\r?\n/).join('[/li]\n[li]') + + '[/li]\n[/ol]' + ); + } + }, + table: { + txtExec: ['[table][tr][td]', '[/td][/tr][/table]'] + }, + horizontalrule: { + txtExec: ['[hr]'] + }, + code: { + txtExec: ['[code]', '[/code]'] + }, + image: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('image')._dropDown( + editor, + caller, + selected, + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width=' + width; + } + + if (height) { + attrs += ' height=' + height; + } + + editor.insertText( + '[img' + attrs + ']' + url + '[/img]' + ); + } + ); + } + }, + email: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('email')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '[email=' + url + ']' + + (text || selected || url) + + '[/email]' + ); + } + ); + } + }, + link: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('link')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '[url=' + url + ']' + + (text || selected || url) + + '[/url]' + ); + } + ); + } + }, + quote: { + txtExec: ['[quote]', '[/quote]'] + }, + youtube: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('youtube')._dropDown( + editor, + caller, + function (id) { + editor.insertText('[youtube]' + id + '[/youtube]'); + } + ); + } + }, + rtl: { + txtExec: ['[rtl]', '[/rtl]'] + }, + ltr: { + txtExec: ['[ltr]', '[/ltr]'] + } + }; + + var bbcodeHandlers = { + // START_COMMAND: Bold + b: { + tags: { + b: null, + strong: null + }, + styles: { + // 401 is for FF 3.5 + 'font-weight': ['bold', 'bolder', '401', '700', '800', '900'] + }, + format: '[b]{0}[/b]', + html: '<strong>{0}</strong>' + }, + // END_COMMAND + + // START_COMMAND: Italic + i: { + tags: { + i: null, + em: null + }, + styles: { + 'font-style': ['italic', 'oblique'] + }, + format: '[i]{0}[/i]', + html: '<em>{0}</em>' + }, + // END_COMMAND + + // START_COMMAND: Underline + u: { + tags: { + u: null + }, + styles: { + 'text-decoration': ['underline'] + }, + format: '[u]{0}[/u]', + html: '<u>{0}</u>' + }, + // END_COMMAND + + // START_COMMAND: Strikethrough + s: { + tags: { + s: null, + strike: null + }, + styles: { + 'text-decoration': ['line-through'] + }, + format: '[s]{0}[/s]', + html: '<s>{0}</s>' + }, + // END_COMMAND + + // START_COMMAND: Subscript + sub: { + tags: { + sub: null + }, + format: '[sub]{0}[/sub]', + html: '<sub>{0}</sub>' + }, + // END_COMMAND + + // START_COMMAND: Superscript + sup: { + tags: { + sup: null + }, + format: '[sup]{0}[/sup]', + html: '<sup>{0}</sup>' + }, + // END_COMMAND + + // START_COMMAND: Font + font: { + tags: { + font: { + face: null + } + }, + styles: { + 'font-family': null + }, + quoteType: QuoteType.never, + format: function (element, content) { + var font; + + if (!is(element, 'font') || !(font = attr(element, 'face'))) { + font = css(element, 'font-family'); + } + + return '[font=' + _stripQuotes(font) + ']' + + content + '[/font]'; + }, + html: '<font face="{defaultattr}">{0}</font>' + }, + // END_COMMAND + + // START_COMMAND: Size + size: { + tags: { + font: { + size: null + } + }, + styles: { + 'font-size': null + }, + format: function (element, content) { + var fontSize = attr(element, 'size'), + size = 2; + + if (!fontSize) { + fontSize = css(element, 'fontSize'); + } + + // Most browsers return px value but IE returns 1-7 + if (fontSize.indexOf('px') > -1) { + // convert size to an int + fontSize = fontSize.replace('px', '') - 0; + + if (fontSize < 12) { + size = 1; + } + if (fontSize > 15) { + size = 3; + } + if (fontSize > 17) { + size = 4; + } + if (fontSize > 23) { + size = 5; + } + if (fontSize > 31) { + size = 6; + } + if (fontSize > 47) { + size = 7; + } + } else { + size = fontSize; + } + + return '[size=' + size + ']' + content + '[/size]'; + }, + html: '<font size="{defaultattr}">{!0}</font>' + }, + // END_COMMAND + + // START_COMMAND: Color + color: { + tags: { + font: { + color: null + } + }, + styles: { + color: null + }, + quoteType: QuoteType.never, + format: function (elm, content) { + var color; + + if (!is(elm, 'font') || !(color = attr(elm, 'color'))) { + color = elm.style.color || css(elm, 'color'); + } + + return '[color=' + _normaliseColour(color) + ']' + + content + '[/color]'; + }, + html: function (token, attrs, content) { + return '<font color="' + + escapeEntities(_normaliseColour(attrs.defaultattr), true) + + '">' + content + '</font>'; + } + }, + // END_COMMAND + + // START_COMMAND: Lists + ul: { + tags: { + ul: null + }, + breakStart: true, + isInline: false, + skipLastLineBreak: true, + format: '[ul]{0}[/ul]', + html: '<ul>{0}</ul>' + }, + list: { + breakStart: true, + isInline: false, + skipLastLineBreak: true, + html: '<ul>{0}</ul>' + }, + ol: { + tags: { + ol: null + }, + breakStart: true, + isInline: false, + skipLastLineBreak: true, + format: '[ol]{0}[/ol]', + html: '<ol>{0}</ol>' + }, + li: { + tags: { + li: null + }, + isInline: false, + closedBy: ['/ul', '/ol', '/list', '*', 'li'], + format: '[li]{0}[/li]', + html: '<li>{0}</li>' + }, + '*': { + isInline: false, + closedBy: ['/ul', '/ol', '/list', '*', 'li'], + html: '<li>{0}</li>' + }, + // END_COMMAND + + // START_COMMAND: Table + table: { + tags: { + table: null + }, + isInline: false, + isHtmlInline: true, + skipLastLineBreak: true, + format: '[table]{0}[/table]', + html: '<table>{0}</table>' + }, + tr: { + tags: { + tr: null + }, + isInline: false, + skipLastLineBreak: true, + format: '[tr]{0}[/tr]', + html: '<tr>{0}</tr>' + }, + th: { + tags: { + th: null + }, + allowsEmpty: true, + isInline: false, + format: '[th]{0}[/th]', + html: '<th>{0}</th>' + }, + td: { + tags: { + td: null + }, + allowsEmpty: true, + isInline: false, + format: '[td]{0}[/td]', + html: '<td>{0}</td>' + }, + // END_COMMAND + + // START_COMMAND: Emoticons + emoticon: { + allowsEmpty: true, + tags: { + img: { + src: null, + 'data-sceditor-emoticon': null + } + }, + format: function (element, content) { + return attr(element, EMOTICON_DATA_ATTR) + content; + }, + html: '{0}' + }, + // END_COMMAND + + // START_COMMAND: Horizontal Rule + hr: { + tags: { + hr: null + }, + allowsEmpty: true, + isSelfClosing: true, + isInline: false, + format: '[hr]{0}', + html: '<hr />' + }, + // END_COMMAND + + // START_COMMAND: Image + img: { + allowsEmpty: true, + tags: { + img: { + src: null + } + }, + allowedChildren: ['#'], + quoteType: QuoteType.never, + format: function (element, content) { + var width, height, + attribs = '', + style = function (name) { + return element.style ? element.style[name] : null; + }; + + // check if this is an emoticon image + if (attr(element, EMOTICON_DATA_ATTR)) { + return content; + } + + width = attr(element, 'width') || style('width'); + height = attr(element, 'height') || style('height'); + + // only add width and height if one is specified + if ((element.complete && (width || height)) || + (width && height)) { + + attribs = '=' + dom.width(element) + 'x' + + dom.height(element); + } + + return '[img' + attribs + ']' + attr(element, 'src') + '[/img]'; + }, + html: function (token, attrs, content) { + var undef, width, height, match, + attribs = ''; + + // handle [img width=340 height=240]url[/img] + width = attrs.width; + height = attrs.height; + + // handle [img=340x240]url[/img] + if (attrs.defaultattr) { + match = attrs.defaultattr.split(/x/i); + + width = match[0]; + height = (match.length === 2 ? match[1] : match[0]); + } + + if (width !== undef) { + attribs += ' width="' + escapeEntities(width, true) + '"'; + } + + if (height !== undef) { + attribs += ' height="' + escapeEntities(height, true) + '"'; + } + + return '<img' + attribs + + ' src="' + escapeUriScheme(content) + '" />'; + } + }, + // END_COMMAND + + // START_COMMAND: URL + url: { + allowsEmpty: true, + tags: { + a: { + href: null + } + }, + quoteType: QuoteType.never, + format: function (element, content) { + var url = attr(element, 'href'); + + // make sure this link is not an e-mail, + // if it is return e-mail BBCode + if (url.substr(0, 7) === 'mailto:') { + return '[email="' + url.substr(7) + '"]' + + content + '[/email]'; + } + + return '[url=' + url + ']' + content + '[/url]'; + }, + html: function (token, attrs, content) { + attrs.defaultattr = + escapeEntities(attrs.defaultattr, true) || content; + + return '<a href="' + escapeUriScheme(attrs.defaultattr) + '">' + + content + '</a>'; + } + }, + // END_COMMAND + + // START_COMMAND: E-mail + email: { + quoteType: QuoteType.never, + html: function (token, attrs, content) { + return '<a href="mailto:' + + (escapeEntities(attrs.defaultattr, true) || content) + + '">' + content + '</a>'; + } + }, + // END_COMMAND + + // START_COMMAND: Quote + quote: { + tags: { + blockquote: null + }, + isInline: false, + quoteType: QuoteType.never, + format: function (element, content) { + var authorAttr = 'data-author'; + var author = ''; + var cite; + var children = element.children; + + for (var i = 0; !cite && i < children.length; i++) { + if (is(children[i], 'cite')) { + cite = children[i]; + } + } + + if (cite || attr(element, authorAttr)) { + author = cite && cite.textContent || + attr(element, authorAttr); + + attr(element, authorAttr, author); + + if (cite) { + element.removeChild(cite); + } + + content = this.elementToBbcode(element); + author = '=' + author.replace(/(^\s+|\s+$)/g, ''); + + if (cite) { + element.insertBefore(cite, element.firstChild); + } + } + + return '[quote' + author + ']' + content + '[/quote]'; + }, + html: function (token, attrs, content) { + if (attrs.defaultattr) { + content = '<cite>' + escapeEntities(attrs.defaultattr) + + '</cite>' + content; + } + + return '<blockquote>' + content + '</blockquote>'; + } + }, + // END_COMMAND + + // START_COMMAND: Code + code: { + tags: { + code: null + }, + isInline: false, + allowedChildren: ['#', '#newline'], + format: '[code]{0}[/code]', + html: '<code>{0}</code>' + }, + // END_COMMAND + + + // START_COMMAND: Left + left: { + styles: { + 'text-align': [ + 'left', + '-webkit-left', + '-moz-left', + '-khtml-left' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[left]{0}[/left]', + html: '<div align="left">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Centre + center: { + styles: { + 'text-align': [ + 'center', + '-webkit-center', + '-moz-center', + '-khtml-center' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[center]{0}[/center]', + html: '<div align="center">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Right + right: { + styles: { + 'text-align': [ + 'right', + '-webkit-right', + '-moz-right', + '-khtml-right' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[right]{0}[/right]', + html: '<div align="right">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Justify + justify: { + styles: { + 'text-align': [ + 'justify', + '-webkit-justify', + '-moz-justify', + '-khtml-justify' + ] + }, + isInline: false, + allowsEmpty: true, + format: '[justify]{0}[/justify]', + html: '<div align="justify">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: YouTube + youtube: { + allowsEmpty: true, + tags: { + iframe: { + 'data-youtube-id': null + } + }, + format: function (element, content) { + element = attr(element, 'data-youtube-id'); + + return element ? '[youtube]' + element + '[/youtube]' : content; + }, + html: '<iframe width="560" height="315" frameborder="0" ' + + 'src="https://www.youtube-nocookie.com/embed/{0}?wmode=opaque" ' + + 'data-youtube-id="{0}" allowfullscreen></iframe>' + }, + // END_COMMAND + + + // START_COMMAND: Rtl + rtl: { + styles: { + direction: ['rtl'] + }, + isInline: false, + format: '[rtl]{0}[/rtl]', + html: '<div style="direction: rtl">{0}</div>' + }, + // END_COMMAND + + // START_COMMAND: Ltr + ltr: { + styles: { + direction: ['ltr'] + }, + isInline: false, + format: '[ltr]{0}[/ltr]', + html: '<div style="direction: ltr">{0}</div>' + }, + // END_COMMAND + + // this is here so that commands above can be removed + // without having to remove the , after the last one. + // Needed for IE. + ignore: {} + }; + + /** + * Formats a string replacing {name} with the values of + * obj.name properties. + * + * If there is no property for the specified {name} then + * it will be left intact. + * + * @param {string} str + * @param {Object} obj + * @return {string} + * @since 2.0.0 + */ + function formatBBCodeString(str, obj) { + return str.replace(/\{([^}]+)\}/g, function (match, group) { + var undef, + escape = true; + + if (group.charAt(0) === '!') { + escape = false; + group = group.substring(1); + } + + if (group === '0') { + escape = false; + } + + if (obj[group] === undef) { + return match; + } + + return escape ? escapeEntities(obj[group], true) : obj[group]; + }); + } + + /** + * Removes the first and last divs from the HTML. + * + * This is needed for pasting + * @param {string} html + * @return {string} + * @private + */ + function removeFirstLastDiv(html) { + var node, next, removeDiv, + output = document.createElement('div'); + + removeDiv = function (node, isFirst) { + // Don't remove divs that have styling + if (dom.hasStyling(node)) { + return; + } + + if ((node.childNodes.length !== 1 || + !is(node.firstChild, 'br'))) { + while ((next = node.firstChild)) { + output.insertBefore(next, node); + } + } + + if (isFirst) { + var lastChild = output.lastChild; + + if (node !== lastChild && is(lastChild, 'div') && + node.nextSibling === lastChild) { + output.insertBefore(document.createElement('br'), node); + } + } + + output.removeChild(node); + }; + + css(output, 'display', 'none'); + output.innerHTML = html.replace(/<\/div>\n/g, '</div>'); + + if ((node = output.firstChild) && is(node, 'div')) { + removeDiv(node, true); + } + + if ((node = output.lastChild) && is(node, 'div')) { + removeDiv(node); + } + + return output.innerHTML; + } + + function isFunction(fn) { + return typeof fn === 'function'; + } + + /** + * Removes any leading or trailing quotes ('") + * + * @return string + * @since v1.4.0 + */ + function _stripQuotes(str) { + return str ? + str.replace(/\\(.)/g, '$1').replace(/^(["'])(.*?)\1$/, '$2') : str; + } + + /** + * Formats a string replacing {0}, {1}, {2}, ect. with + * the params provided + * + * @param {string} str The string to format + * @param {...string} arg The strings to replace + * @return {string} + * @since v1.4.0 + */ + function _formatString(str) { + var undef; + var args = arguments; + + return str.replace(/\{(\d+)\}/g, function (_, matchNum) { + return args[matchNum - 0 + 1] !== undef ? + args[matchNum - 0 + 1] : + '{' + matchNum + '}'; + }); + } + + var TOKEN_OPEN = 'open'; + var TOKEN_CONTENT = 'content'; + var TOKEN_NEWLINE = 'newline'; + var TOKEN_CLOSE = 'close'; + + + /* + * @typedef {Object} TokenizeToken + * @property {string} type + * @property {string} name + * @property {string} val + * @property {Object.<string, string>} attrs + * @property {array} children + * @property {TokenizeToken} closing + */ + + /** + * Tokenize token object + * + * @param {string} type The type of token this is, + * should be one of tokenType + * @param {string} name The name of this token + * @param {string} val The originally matched string + * @param {array} attrs Any attributes. Only set on + * TOKEN_TYPE_OPEN tokens + * @param {array} children Any children of this token + * @param {TokenizeToken} closing This tokens closing tag. + * Only set on TOKEN_TYPE_OPEN tokens + * @class {TokenizeToken} + * @name {TokenizeToken} + * @memberOf BBCodeParser.prototype + */ + // eslint-disable-next-line max-params + function TokenizeToken(type, name, val, attrs, children, closing) { + var base = this; + + base.type = type; + base.name = name; + base.val = val; + base.attrs = attrs || {}; + base.children = children || []; + base.closing = closing || null; + }; + + TokenizeToken.prototype = { + /** @lends BBCodeParser.prototype.TokenizeToken */ + /** + * Clones this token + * + * @return {TokenizeToken} + */ + clone: function () { + var base = this; + + return new TokenizeToken( + base.type, + base.name, + base.val, + extend({}, base.attrs), + [], + base.closing ? base.closing.clone() : null + ); + }, + /** + * Splits this token at the specified child + * + * @param {TokenizeToken} splitAt The child to split at + * @return {TokenizeToken} The right half of the split token or + * empty clone if invalid splitAt lcoation + */ + splitAt: function (splitAt) { + var offsetLength; + var base = this; + var clone = base.clone(); + var offset = base.children.indexOf(splitAt); + + if (offset > -1) { + // Work out how many items are on the right side of the split + // to pass to splice() + offsetLength = base.children.length - offset; + clone.children = base.children.splice(offset, offsetLength); + } + + return clone; + } + }; + + + /** + * SCEditor BBCode parser class + * + * @param {Object} options + * @class BBCodeParser + * @name BBCodeParser + * @since v1.4.0 + */ + function BBCodeParser(options) { + var base = this; + + base.opts = extend({}, BBCodeParser.defaults, options); + + /** + * Takes a BBCode string and splits it into open, + * content and close tags. + * + * It does no checking to verify a tag has a matching open + * or closing tag or if the tag is valid child of any tag + * before it. For that the tokens should be passed to the + * parse function. + * + * @param {string} str + * @return {array} + * @memberOf BBCodeParser.prototype + */ + base.tokenize = function (str) { + var matches, type, i; + var tokens = []; + // The token types in reverse order of precedence + // (they're looped in reverse) + var tokenTypes = [ + { + type: TOKEN_CONTENT, + regex: /^([^\[\r\n]+|\[)/ + }, + { + type: TOKEN_NEWLINE, + regex: /^(\r\n|\r|\n)/ + }, + { + type: TOKEN_OPEN, + regex: /^\[[^\[\]]+\]/ + }, + // Close must come before open as they are + // the same except close has a / at the start. + { + type: TOKEN_CLOSE, + regex: /^\[\/[^\[\]]+\]/ + } + ]; + + strloop: + while (str.length) { + i = tokenTypes.length; + while (i--) { + type = tokenTypes[i].type; + + // Check if the string matches any of the tokens + if (!(matches = str.match(tokenTypes[i].regex)) || + !matches[0]) { + continue; + } + + // Add the match to the tokens list + tokens.push(tokenizeTag(type, matches[0])); + + // Remove the match from the string + str = str.substr(matches[0].length); + + // The token has been added so start again + continue strloop; + } + + // If there is anything left in the string which doesn't match + // any of the tokens then just assume it's content and add it. + if (str.length) { + tokens.push(tokenizeTag(TOKEN_CONTENT, str)); + } + + str = ''; + } + + return tokens; + }; + + /** + * Extracts the name an params from a tag + * + * @param {string} type + * @param {string} val + * @return {Object} + * @private + */ + function tokenizeTag(type, val) { + var matches, attrs, name, + openRegex = /\[([^\]\s=]+)(?:([^\]]+))?\]/, + closeRegex = /\[\/([^\[\]]+)\]/; + + // Extract the name and attributes from opening tags and + // just the name from closing tags. + if (type === TOKEN_OPEN && (matches = val.match(openRegex))) { + name = lower(matches[1]); + + if (matches[2] && (matches[2] = matches[2].trim())) { + attrs = tokenizeAttrs(matches[2]); + } + } + + if (type === TOKEN_CLOSE && + (matches = val.match(closeRegex))) { + name = lower(matches[1]); + } + + if (type === TOKEN_NEWLINE) { + name = '#newline'; + } + + // Treat all tokens without a name and + // all unknown BBCodes as content + if (!name || ((type === TOKEN_OPEN || type === TOKEN_CLOSE) && + !bbcodeHandlers[name])) { + + type = TOKEN_CONTENT; + name = '#'; + } + + return new TokenizeToken(type, name, val, attrs); + } + + /** + * Extracts the individual attributes from a string containing + * all the attributes. + * + * @param {string} attrs + * @return {Object} Assoc array of attributes + * @private + */ + function tokenizeAttrs(attrs) { + var matches, + /* + ([^\s=]+) Anything that's not a space or equals + = Equals sign = + (?: + (?: + (["']) The opening quote + ( + (?:\\\2|[^\2])*? Anything that isn't the + unescaped opening quote + ) + \2 The opening quote again which + will close the string + ) + | If not a quoted string then match + ( + (?:.(?!\s\S+=))*.? Anything that isn't part of + [space][non-space][=] which + would be a new attribute + ) + ) + */ + attrRegex = /([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g, + ret = {}; + + // if only one attribute then remove the = from the start and + // strip any quotes + if (attrs.charAt(0) === '=' && attrs.indexOf('=', 1) < 0) { + ret.defaultattr = _stripQuotes(attrs.substr(1)); + } else { + if (attrs.charAt(0) === '=') { + attrs = 'defaultattr' + attrs; + } + + // No need to strip quotes here, the regex will do that. + while ((matches = attrRegex.exec(attrs))) { + ret[lower(matches[1])] = + _stripQuotes(matches[3]) || matches[4]; + } + } + + return ret; + } + + /** + * Parses a string into an array of BBCodes + * + * @param {string} str + * @param {boolean} preserveNewLines If to preserve all new lines, not + * strip any based on the passed + * formatting options + * @return {array} Array of BBCode objects + * @memberOf BBCodeParser.prototype + */ + base.parse = function (str, preserveNewLines) { + var ret = parseTokens(base.tokenize(str)); + var opts = base.opts; + + if (opts.fixInvalidNesting) { + fixNesting(ret); + } + + normaliseNewLines(ret, null, preserveNewLines); + + if (opts.removeEmptyTags) { + removeEmpty(ret); + } + + return ret; + }; + + /** + * Checks if an array of TokenizeToken's contains the + * specified token. + * + * Checks the tokens name and type match another tokens + * name and type in the array. + * + * @param {string} name + * @param {string} type + * @param {array} arr + * @return {Boolean} + * @private + */ + function hasTag(name, type, arr) { + var i = arr.length; + + while (i--) { + if (arr[i].type === type && arr[i].name === name) { + return true; + } + } + + return false; + } + + /** + * Checks if the child tag is allowed as one + * of the parent tags children. + * + * @param {TokenizeToken} parent + * @param {TokenizeToken} child + * @return {Boolean} + * @private + */ + function isChildAllowed(parent, child) { + var parentBBCode = parent ? bbcodeHandlers[parent.name] : {}, + allowedChildren = parentBBCode.allowedChildren; + + if (base.opts.fixInvalidChildren && allowedChildren) { + return allowedChildren.indexOf(child.name || '#') > -1; + } + + return true; + } + + // TODO: Tidy this parseTokens() function up a bit. + /** + * Parses an array of tokens created by tokenize() + * + * @param {array} toks + * @return {array} Parsed tokens + * @see tokenize() + * @private + */ + function parseTokens(toks) { + var token, bbcode, curTok, clone, i, next, + cloned = [], + output = [], + openTags = [], + /** + * Returns the currently open tag or undefined + * @return {TokenizeToken} + */ + currentTag = function () { + return last(openTags); + }, + /** + * Adds a tag to either the current tags children + * or to the output array. + * @param {TokenizeToken} token + * @private + */ + addTag = function (token) { + if (currentTag()) { + currentTag().children.push(token); + } else { + output.push(token); + } + }, + /** + * Checks if this tag closes the current tag + * @param {string} name + * @return {Void} + */ + closesCurrentTag = function (name) { + return currentTag() && + (bbcode = bbcodeHandlers[currentTag().name]) && + bbcode.closedBy && + bbcode.closedBy.indexOf(name) > -1; + }; + + while ((token = toks.shift())) { + next = toks[0]; + + /* + * Fixes any invalid children. + * + * If it is an element which isn't allowed as a child of it's + * parent then it will be converted to content of the parent + * element. i.e. + * [code]Code [b]only[/b] allows text.[/code] + * Will become: + * <code>Code [b]only[/b] allows text.</code> + * Instead of: + * <code>Code <b>only</b> allows text.</code> + */ + // Ignore tags that can't be children + if (!isChildAllowed(currentTag(), token)) { + + // exclude closing tags of current tag + if (token.type !== TOKEN_CLOSE || !currentTag() || + token.name !== currentTag().name) { + token.name = '#'; + token.type = TOKEN_CONTENT; + } + } + + switch (token.type) { + case TOKEN_OPEN: + // Check it this closes a parent, + // e.g. for lists [*]one [*]two + if (closesCurrentTag(token.name)) { + openTags.pop(); + } + + addTag(token); + bbcode = bbcodeHandlers[token.name]; + + // If this tag is not self closing and it has a closing + // tag then it is open and has children so add it to the + // list of open tags. If has the closedBy property then + // it is closed by other tags so include everything as + // it's children until one of those tags is reached. + if (bbcode && !bbcode.isSelfClosing && + (bbcode.closedBy || + hasTag(token.name, TOKEN_CLOSE, toks))) { + openTags.push(token); + } else if (!bbcode || !bbcode.isSelfClosing) { + token.type = TOKEN_CONTENT; + } + break; + + case TOKEN_CLOSE: + // check if this closes the current tag, + // e.g. [/list] would close an open [*] + if (currentTag() && token.name !== currentTag().name && + closesCurrentTag('/' + token.name)) { + + openTags.pop(); + } + + // If this is closing the currently open tag just pop + // the close tag off the open tags array + if (currentTag() && token.name === currentTag().name) { + currentTag().closing = token; + openTags.pop(); + + // If this is closing an open tag that is the parent of + // the current tag then clone all the tags including the + // current one until reaching the parent that is being + // closed. Close the parent and then add the clones back + // in. + } else if (hasTag(token.name, TOKEN_OPEN, openTags)) { + + // Remove the tag from the open tags + while ((curTok = openTags.pop())) { + + // If it's the tag that is being closed then + // discard it and break the loop. + if (curTok.name === token.name) { + curTok.closing = token; + break; + } + + // Otherwise clone this tag and then add any + // previously cloned tags as it's children + clone = curTok.clone(); + + if (cloned.length) { + clone.children.push(last(cloned)); + } + + cloned.push(clone); + } + + // Place block linebreak before cloned tags + if (next && next.type === TOKEN_NEWLINE) { + bbcode = bbcodeHandlers[token.name]; + if (bbcode && bbcode.isInline === false) { + addTag(next); + toks.shift(); + } + } + + // Add the last cloned child to the now current tag + // (the parent of the tag which was being closed) + addTag(last(cloned)); + + // Add all the cloned tags to the open tags list + i = cloned.length; + while (i--) { + openTags.push(cloned[i]); + } + + cloned.length = 0; + + // This tag is closing nothing so treat it as content + } else { + token.type = TOKEN_CONTENT; + addTag(token); + } + break; + + case TOKEN_NEWLINE: + // handle things like + // [*]list\nitem\n[*]list1 + // where it should come out as + // [*]list\nitem[/*]\n[*]list1[/*] + // instead of + // [*]list\nitem\n[/*][*]list1[/*] + if (currentTag() && next && closesCurrentTag( + (next.type === TOKEN_CLOSE ? '/' : '') + + next.name + )) { + // skip if the next tag is the closing tag for + // the option tag, i.e. [/*] + if (!(next.type === TOKEN_CLOSE && + next.name === currentTag().name)) { + bbcode = bbcodeHandlers[currentTag().name]; + + if (bbcode && bbcode.breakAfter) { + openTags.pop(); + } else if (bbcode && + bbcode.isInline === false && + base.opts.breakAfterBlock && + bbcode.breakAfter !== false) { + openTags.pop(); + } + } + } + + addTag(token); + break; + + default: // content + addTag(token); + break; + } + } + + return output; + } + + /** + * Normalise all new lines + * + * Removes any formatting new lines from the BBCode + * leaving only content ones. I.e. for a list: + * + * [list] + * [*] list item one + * with a line break + * [*] list item two + * [/list] + * + * would become + * + * [list] [*] list item one + * with a line break [*] list item two [/list] + * + * Which makes it easier to convert to HTML or add + * the formatting new lines back in when converting + * back to BBCode + * + * @param {array} children + * @param {TokenizeToken} parent + * @param {boolean} onlyRemoveBreakAfter + * @return {void} + */ + function normaliseNewLines(children, parent, onlyRemoveBreakAfter) { + var token, left, right, parentBBCode, bbcode, + removedBreakEnd, removedBreakBefore, remove; + var childrenLength = children.length; + // TODO: this function really needs tidying up + if (parent) { + parentBBCode = bbcodeHandlers[parent.name]; + } + + var i = childrenLength; + while (i--) { + if (!(token = children[i])) { + continue; + } + + if (token.type === TOKEN_NEWLINE) { + left = i > 0 ? children[i - 1] : null; + right = i < childrenLength - 1 ? children[i + 1] : null; + remove = false; + + // Handle the start and end new lines + // e.g. [tag]\n and \n[/tag] + if (!onlyRemoveBreakAfter && parentBBCode && + parentBBCode.isSelfClosing !== true) { + // First child of parent so must be opening line break + // (breakStartBlock, breakStart) e.g. [tag]\n + if (!left) { + if (parentBBCode.isInline === false && + base.opts.breakStartBlock && + parentBBCode.breakStart !== false) { + remove = true; + } + + if (parentBBCode.breakStart) { + remove = true; + } + // Last child of parent so must be end line break + // (breakEndBlock, breakEnd) + // e.g. \n[/tag] + // remove last line break (breakEndBlock, breakEnd) + } else if (!removedBreakEnd && !right) { + if (parentBBCode.isInline === false && + base.opts.breakEndBlock && + parentBBCode.breakEnd !== false) { + remove = true; + } + + if (parentBBCode.breakEnd) { + remove = true; + } + + removedBreakEnd = remove; + } + } + + if (left && left.type === TOKEN_OPEN) { + if ((bbcode = bbcodeHandlers[left.name])) { + if (!onlyRemoveBreakAfter) { + if (bbcode.isInline === false && + base.opts.breakAfterBlock && + bbcode.breakAfter !== false) { + remove = true; + } + + if (bbcode.breakAfter) { + remove = true; + } + } else if (bbcode.isInline === false) { + remove = true; + } + } + } + + if (!onlyRemoveBreakAfter && !removedBreakBefore && + right && right.type === TOKEN_OPEN) { + + if ((bbcode = bbcodeHandlers[right.name])) { + if (bbcode.isInline === false && + base.opts.breakBeforeBlock && + bbcode.breakBefore !== false) { + remove = true; + } + + if (bbcode.breakBefore) { + remove = true; + } + + removedBreakBefore = remove; + + if (remove) { + children.splice(i, 1); + continue; + } + } + } + + if (remove) { + children.splice(i, 1); + } + + // reset double removedBreakBefore removal protection. + // This is needed for cases like \n\n[\tag] where + // only 1 \n should be removed but without this they both + // would be. + removedBreakBefore = false; + } else if (token.type === TOKEN_OPEN) { + normaliseNewLines(token.children, token, + onlyRemoveBreakAfter); + } + } + } + + /** + * Fixes any invalid nesting. + * + * If it is a block level element inside 1 or more inline elements + * then those inline elements will be split at the point where the + * block level is and the block level element placed between the split + * parts. i.e. + * [inline]A[blocklevel]B[/blocklevel]C[/inline] + * Will become: + * [inline]A[/inline][blocklevel]B[/blocklevel][inline]C[/inline] + * + * @param {array} children + * @param {array} [parents] Null if there is no parents + * @param {boolea} [insideInline] If inside an inline element + * @param {array} [rootArr] Root array if there is one + * @return {array} + * @private + */ + function fixNesting(children, parents, insideInline, rootArr) { + var token, i, parent, parentIndex, parentParentChildren, right; + + var isInline = function (token) { + var bbcode = bbcodeHandlers[token.name]; + + return !bbcode || bbcode.isInline !== false; + }; + + parents = parents || []; + rootArr = rootArr || children; + + // This must check the length each time as it can change when + // tokens are moved to fix the nesting. + for (i = 0; i < children.length; i++) { + if (!(token = children[i]) || token.type !== TOKEN_OPEN) { + continue; + } + + if (insideInline && !isInline(token)) { + // if this is a blocklevel element inside an inline one then + // split the parent at the block level element + parent = last(parents); + right = parent.splitAt(token); + + parentParentChildren = parents.length > 1 ? + parents[parents.length - 2].children : rootArr; + + // If parent inline is allowed inside this tag, clone it and + // wrap this tags children in it. + if (isChildAllowed(token, parent)) { + var clone = parent.clone(); + clone.children = token.children; + token.children = [clone]; + } + + parentIndex = parentParentChildren.indexOf(parent); + if (parentIndex > -1) { + // remove the block level token from the right side of + // the split inline element + right.children.splice(0, 1); + + // insert the block level token and the right side after + // the left side of the inline token + parentParentChildren.splice( + parentIndex + 1, 0, token, right + ); + + // If token is a block and is followed by a newline, + // then move the newline along with it to the new parent + var next = right.children[0]; + if (next && next.type === TOKEN_NEWLINE) { + if (!isInline(token)) { + right.children.splice(0, 1); + parentParentChildren.splice( + parentIndex + 2, 0, next + ); + } + } + + // return to parents loop as the + // children have now increased + return; + } + + } + + parents.push(token); + + fixNesting( + token.children, + parents, + insideInline || isInline(token), + rootArr + ); + + parents.pop(); + } + } + + /** + * Removes any empty BBCodes which are not allowed to be empty. + * + * @param {array} tokens + * @private + */ + function removeEmpty(tokens) { + var token, bbcode; + + /** + * Checks if all children are whitespace or not + * @private + */ + var isTokenWhiteSpace = function (children) { + var j = children.length; + + while (j--) { + var type = children[j].type; + + if (type === TOKEN_OPEN || type === TOKEN_CLOSE) { + return false; + } + + if (type === TOKEN_CONTENT && + /\S|\u00A0/.test(children[j].val)) { + return false; + } + } + + return true; + }; + + var i = tokens.length; + while (i--) { + // So skip anything that isn't a tag since only tags can be + // empty, content can't + if (!(token = tokens[i]) || token.type !== TOKEN_OPEN) { + continue; + } + + bbcode = bbcodeHandlers[token.name]; + + // Remove any empty children of this tag first so that if they + // are all removed this one doesn't think it's not empty. + removeEmpty(token.children); + + if (isTokenWhiteSpace(token.children) && bbcode && + !bbcode.isSelfClosing && !bbcode.allowsEmpty) { + tokens.splice.apply(tokens, [i, 1].concat(token.children)); + } + } + } + + /** + * Converts a BBCode string to HTML + * + * @param {string} str + * @param {boolean} preserveNewLines If to preserve all new lines, not + * strip any based on the passed + * formatting options + * @return {string} + * @memberOf BBCodeParser.prototype + */ + base.toHTML = function (str, preserveNewLines) { + return convertToHTML(base.parse(str, preserveNewLines), true); + }; + + /** + * @private + */ + function convertToHTML(tokens, isRoot) { + var undef, token, bbcode, content, html, needsBlockWrap, + blockWrapOpen, isInline, lastChild, + ret = ''; + + isInline = function (bbcode) { + return (!bbcode || (bbcode.isHtmlInline !== undef ? + bbcode.isHtmlInline : bbcode.isInline)) !== false; + }; + + while (tokens.length > 0) { + if (!(token = tokens.shift())) { + continue; + } + + if (token.type === TOKEN_OPEN) { + lastChild = token.children[token.children.length - 1] || {}; + bbcode = bbcodeHandlers[token.name]; + needsBlockWrap = isRoot && isInline(bbcode); + content = convertToHTML(token.children, false); + + if (bbcode && bbcode.html) { + // Only add a line break to the end if this is + // blocklevel and the last child wasn't block-level + if (!isInline(bbcode) && + isInline(bbcodeHandlers[lastChild.name]) && + !bbcode.isPreFormatted && + !bbcode.skipLastLineBreak) { + // Add placeholder br to end of block level + // elements + content += '<br />'; + } + + if (!isFunction(bbcode.html)) { + token.attrs['0'] = content; + html = formatBBCodeString( + bbcode.html, + token.attrs + ); + } else { + html = bbcode.html.call( + base, + token, + token.attrs, + content + ); + } + } else { + html = token.val + content + + (token.closing ? token.closing.val : ''); + } + } else if (token.type === TOKEN_NEWLINE) { + if (!isRoot) { + ret += '<br />'; + continue; + } + + // If not already in a block wrap then start a new block + if (!blockWrapOpen) { + ret += '<div>'; + } + + ret += '<br />'; + + // Normally the div acts as a line-break with by moving + // whatever comes after onto a new line. + // If this is the last token, add an extra line-break so it + // shows as there will be nothing after it. + if (!tokens.length) { + ret += '<br />'; + } + + ret += '</div>\n'; + blockWrapOpen = false; + continue; + // content + } else { + needsBlockWrap = isRoot; + html = escapeEntities(token.val, true); + } + + if (needsBlockWrap && !blockWrapOpen) { + ret += '<div>'; + blockWrapOpen = true; + } else if (!needsBlockWrap && blockWrapOpen) { + ret += '</div>\n'; + blockWrapOpen = false; + } + + ret += html; + } + + if (blockWrapOpen) { + ret += '</div>\n'; + } + + return ret; + } + + /** + * Takes a BBCode string, parses it then converts it back to BBCode. + * + * This will auto fix the BBCode and format it with the specified + * options. + * + * @param {string} str + * @param {boolean} preserveNewLines If to preserve all new lines, not + * strip any based on the passed + * formatting options + * @return {string} + * @memberOf BBCodeParser.prototype + */ + base.toBBCode = function (str, preserveNewLines) { + return convertToBBCode(base.parse(str, preserveNewLines)); + }; + + /** + * Converts parsed tokens back into BBCode with the + * formatting specified in the options and with any + * fixes specified. + * + * @param {array} toks Array of parsed tokens from base.parse() + * @return {string} + * @private + */ + function convertToBBCode(toks) { + var token, attr, bbcode, isBlock, isSelfClosing, quoteType, + breakBefore, breakStart, breakEnd, breakAfter, + ret = ''; + + while (toks.length > 0) { + if (!(token = toks.shift())) { + continue; + } + // TODO: tidy this + bbcode = bbcodeHandlers[token.name]; + isBlock = !(!bbcode || bbcode.isInline !== false); + isSelfClosing = bbcode && bbcode.isSelfClosing; + + breakBefore = (isBlock && base.opts.breakBeforeBlock && + bbcode.breakBefore !== false) || + (bbcode && bbcode.breakBefore); + + breakStart = (isBlock && !isSelfClosing && + base.opts.breakStartBlock && + bbcode.breakStart !== false) || + (bbcode && bbcode.breakStart); + + breakEnd = (isBlock && base.opts.breakEndBlock && + bbcode.breakEnd !== false) || + (bbcode && bbcode.breakEnd); + + breakAfter = (isBlock && base.opts.breakAfterBlock && + bbcode.breakAfter !== false) || + (bbcode && bbcode.breakAfter); + + quoteType = (bbcode ? bbcode.quoteType : null) || + base.opts.quoteType || QuoteType.auto; + + if (!bbcode && token.type === TOKEN_OPEN) { + ret += token.val; + + if (token.children) { + ret += convertToBBCode(token.children); + } + + if (token.closing) { + ret += token.closing.val; + } + } else if (token.type === TOKEN_OPEN) { + if (breakBefore) { + ret += '\n'; + } + + // Convert the tag and it's attributes to BBCode + ret += '[' + token.name; + if (token.attrs) { + if (token.attrs.defaultattr) { + ret += '=' + quote( + token.attrs.defaultattr, + quoteType, + 'defaultattr' + ); + + delete token.attrs.defaultattr; + } + + for (attr in token.attrs) { + if (token.attrs.hasOwnProperty(attr)) { + ret += ' ' + attr + '=' + + quote(token.attrs[attr], quoteType, attr); + } + } + } + ret += ']'; + + if (breakStart) { + ret += '\n'; + } + + // Convert the tags children to BBCode + if (token.children) { + ret += convertToBBCode(token.children); + } + + // add closing tag if not self closing + if (!isSelfClosing && !bbcode.excludeClosing) { + if (breakEnd) { + ret += '\n'; + } + + ret += '[/' + token.name + ']'; + } + + if (breakAfter) { + ret += '\n'; + } + + // preserve whatever was recognized as the + // closing tag if it is a self closing tag + if (token.closing && isSelfClosing) { + ret += token.closing.val; + } + } else { + ret += token.val; + } + } + + return ret; + } + + /** + * Quotes an attribute + * + * @param {string} str + * @param {BBCodeParser.QuoteType} quoteType + * @param {string} name + * @return {string} + * @private + */ + function quote(str, quoteType, name) { + var needsQuotes = /\s|=/.test(str); + + if (isFunction(quoteType)) { + return quoteType(str, name); + } + + if (quoteType === QuoteType.never || + (quoteType === QuoteType.auto && !needsQuotes)) { + return str; + } + + return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"'; + } + + /** + * Returns the last element of an array or null + * + * @param {array} arr + * @return {Object} Last element + * @private + */ + function last(arr) { + if (arr.length) { + return arr[arr.length - 1]; + } + + return null; + } + + /** + * Converts a string to lowercase. + * + * @param {string} str + * @return {string} Lowercase version of str + * @private + */ + function lower(str) { + return str.toLowerCase(); + } + }; + + /** + * Quote type + * @type {Object} + * @class QuoteType + * @name BBCodeParser.QuoteType + * @since 1.4.0 + */ + BBCodeParser.QuoteType = QuoteType; + + /** + * Default BBCode parser options + * @type {Object} + */ + BBCodeParser.defaults = { + /** + * If to add a new line before block level elements + * + * @type {Boolean} + */ + breakBeforeBlock: false, + + /** + * If to add a new line after the start of block level elements + * + * @type {Boolean} + */ + breakStartBlock: false, + + /** + * If to add a new line before the end of block level elements + * + * @type {Boolean} + */ + breakEndBlock: false, + + /** + * If to add a new line after block level elements + * + * @type {Boolean} + */ + breakAfterBlock: true, + + /** + * If to remove empty tags + * + * @type {Boolean} + */ + removeEmptyTags: true, + + /** + * If to fix invalid nesting, + * i.e. block level elements inside inline elements. + * + * @type {Boolean} + */ + fixInvalidNesting: true, + + /** + * If to fix invalid children. + * i.e. A tag which is inside a parent that doesn't + * allow that type of tag. + * + * @type {Boolean} + */ + fixInvalidChildren: true, + + /** + * Attribute quote type + * + * @type {BBCodeParser.QuoteType} + * @since 1.4.1 + */ + quoteType: QuoteType.auto, + + /** + * Whether to use strict matching on attributes and styles. + * + * When true this will perform AND matching requiring all tag + * attributes and styles to match. + * + * When false will perform OR matching and will match if any of + * a tags attributes or styles match. + * + * @type {Boolean} + * @since 3.1.0 + */ + strictMatch: false + }; + + /** + * Converts a number 0-255 to hex. + * + * Will return 00 if number is not a valid number. + * + * @param {any} number + * @return {string} + * @private + */ + function toHex(number) { + number = parseInt(number, 10); + + if (isNaN(number)) { + return '00'; + } + + number = Math.max(0, Math.min(number, 255)).toString(16); + + return number.length < 2 ? '0' + number : number; + } + /** + * Normalises a CSS colour to hex #xxxxxx format + * + * @param {string} colorStr + * @return {string} + * @private + */ + function _normaliseColour(colorStr) { + var match; + + colorStr = colorStr || '#000'; + + // rgb(n,n,n); + if ((match = + colorStr.match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))) { + return '#' + + toHex(match[1]) + + toHex(match[2]) + + toHex(match[3]); + } + + // expand shorthand + if ((match = colorStr.match(/#([0-f])([0-f])([0-f])\s*?$/i))) { + return '#' + + match[1] + match[1] + + match[2] + match[2] + + match[3] + match[3]; + } + + return colorStr; + } + + /** + * SCEditor BBCode format + * @since 2.0.0 + */ + function bbcodeFormat() { + var base = this; + + base.stripQuotes = _stripQuotes; + + /** + * cache of all the tags pointing to their bbcodes to enable + * faster lookup of which bbcode a tag should have + * @private + */ + var tagsToBBCodes = {}; + + /** + * Allowed children of specific HTML tags. Empty array if no + * children other than text nodes are allowed + * @private + */ + var validChildren = { + ul: ['li', 'ol', 'ul'], + ol: ['li', 'ol', 'ul'], + table: ['tr'], + tr: ['td', 'th'], + code: ['br', 'p', 'div'] + }; + + /** + * Populates tagsToBBCodes and stylesToBBCodes for easier lookups + * + * @private + */ + function buildBbcodeCache() { + each(bbcodeHandlers, function (bbcode, handler) { + var + isBlock = handler.isInline === false, + tags = bbcodeHandlers[bbcode].tags, + styles = bbcodeHandlers[bbcode].styles; + + if (styles) { + tagsToBBCodes['*'] = tagsToBBCodes['*'] || {}; + tagsToBBCodes['*'][isBlock] = + tagsToBBCodes['*'][isBlock] || {}; + tagsToBBCodes['*'][isBlock][bbcode] = [ + ['style', Object.entries(styles)] + ]; + } + + if (tags) { + each(tags, function (tag, values) { + if (values && values.style) { + values.style = Object.entries(values.style); + } + + tagsToBBCodes[tag] = tagsToBBCodes[tag] || {}; + tagsToBBCodes[tag][isBlock] = + tagsToBBCodes[tag][isBlock] || {}; + tagsToBBCodes[tag][isBlock][bbcode] = + values && Object.entries(values); + }); + } + }); + }; + + /** + * Handles adding newlines after block level elements + * + * @param {HTMLElement} element The element to convert + * @param {string} content The tags text content + * @return {string} + * @private + */ + function handleBlockNewlines(element, content) { + var tag = element.nodeName.toLowerCase(); + var isInline = dom.isInline; + if (!isInline(element, true) || tag === 'br') { + var isLastBlockChild, parent, parentLastChild, + previousSibling = element.previousSibling; + + // Skips selection makers and ignored elements + // Skip empty inline elements + while (previousSibling && + previousSibling.nodeType === 1 && + !is(previousSibling, 'br') && + isInline(previousSibling, true) && + !previousSibling.firstChild) { + previousSibling = previousSibling.previousSibling; + } + + // If it's the last block of an inline that is the last + // child of a block then it shouldn't cause a line break + // <block><inline><br></inline></block> + do { + parent = element.parentNode; + parentLastChild = parent && parent.lastChild; + + isLastBlockChild = parentLastChild === element; + element = parent; + } while (parent && isLastBlockChild && isInline(parent, true)); + + // If this block is: + // * Not the last child of a block level element + // * Is a <li> tag (lists are blocks) + if (!isLastBlockChild || tag === 'li') { + content += '\n'; + } + + // Check for: + // <block>text<block>text</block></block> + // + // The second opening <block> opening tag should cause a + // line break because the previous sibing is inline. + if (tag !== 'br' && previousSibling && + !is(previousSibling, 'br') && + isInline(previousSibling, true)) { + content = '\n' + content; + } + } + + return content; + } + + /** + * Handles a HTML tag and finds any matching BBCodes + * + * @param {HTMLElement} element The element to convert + * @param {string} content The Tags text content + * @param {boolean} blockLevel + * @return {string} Content with any matching BBCode tags + * wrapped around it. + * @private + */ + function handleTags(element, content, blockLevel) { + function isStyleMatch(style) { + var property = style[0]; + var values = style[1]; + var val = dom.getStyle(element, property); + var parent = element.parentNode; + + // if the parent has the same style use that instead of this one + // so you don't end up with [i]parent[i]child[/i][/i] + if (!val || parent && dom.hasStyle(parent, property, val)) { + return false; + } + + return !values || values.includes(val); + } + + function createAttributeMatch(isStrict) { + return function (attribute) { + var name = attribute[0]; + var value = attribute[1]; + + // code tags should skip most styles + if (name === 'style' && element.nodeName === 'CODE') { + return false; + } + + if (name === 'style' && value) { + return value[isStrict ? 'every' : 'some'](isStyleMatch); + } else { + var val = attr(element, name); + + return val && (!value || value.includes(val)); + } + }; + } + + function handleTag(tag) { + if (!tagsToBBCodes[tag] || !tagsToBBCodes[tag][blockLevel]) { + return; + } + + // loop all bbcodes for this tag + each(tagsToBBCodes[tag][blockLevel], function (bbcode, attrs) { + var fn, format, + isStrict = bbcodeHandlers[bbcode].strictMatch; + + if (typeof isStrict === 'undefined') { + isStrict = base.opts.strictMatch; + } + + // Skip if the element doesn't have the attribute or the + // attribute doesn't match one of the required values + fn = isStrict ? 'every' : 'some'; + if (attrs && !attrs[fn](createAttributeMatch(isStrict))) { + return; + } + + format = bbcodeHandlers[bbcode].format; + if (isFunction(format)) { + content = format.call(base, element, content); + } else { + content = _formatString(format, content); + } + return false; + }); + } + + handleTag('*'); + handleTag(element.nodeName.toLowerCase()); + return content; + } + + /** + * Converts a HTML dom element to BBCode starting from + * the innermost element and working backwards + * + * @private + * @param {HTMLElement} element + * @return {string} BBCode + * @memberOf SCEditor.plugins.bbcode.prototype + */ + function elementToBbcode(element) { + var toBBCode = function (node, vChildren) { + var ret = ''; + + dom.traverse(node, function (node) { + var content = '', + nodeType = node.nodeType, + tag = node.nodeName.toLowerCase(), + vChild = validChildren[tag], + firstChild = node.firstChild, + isValidChild = true; + + if (typeof vChildren === 'object') { + isValidChild = vChildren.indexOf(tag) > -1; + + // Emoticons should always be converted + if (is(node, 'img') && attr(node, EMOTICON_DATA_ATTR)) { + isValidChild = true; + } + + // if this tag is one of the parents allowed children + // then set this tags allowed children to whatever it + // allows, otherwise set to what the parent allows + if (!isValidChild) { + vChild = vChildren; + } + } + + // 3 = text and 1 = element + if (nodeType !== 3 && nodeType !== 1) { + return; + } + + if (nodeType === 1) { + // skip empty nlf elements (new lines automatically + // added after block level elements like quotes) + if (is(node, '.sceditor-nlf') && !firstChild) { + return; + } + + // don't convert iframe contents + if (tag !== 'iframe') { + content = toBBCode(node, vChild); + } + + // TODO: isValidChild is no longer needed. Should use + // valid children bbcodes instead by creating BBCode + // tokens like the parser. + if (isValidChild) { + // code tags should skip most styles + if (tag !== 'code') { + // First parse inline codes + content = handleTags(node, content, false); + } + + content = handleTags(node, content, true); + ret += handleBlockNewlines(node, content); + } else { + ret += content; + } + } else { + ret += node.nodeValue; + } + }, false, true); + + return ret; + }; + + return toBBCode(element); + }; + + /** + * Initializer + * @private + */ + base.init = function () { + base.opts = this.opts; + base.elementToBbcode = elementToBbcode; + + // build the BBCode cache + buildBbcodeCache(); + + this.commands = extend( + true, {}, defaultCommandsOverrides, this.commands + ); + + // Add BBCode helper methods + this.toBBCode = base.toSource; + this.fromBBCode = base.toHtml; + }; + + /** + * Converts BBCode into HTML + * + * @param {boolean} asFragment + * @param {string} source + * @param {boolean} [legacyAsFragment] Used by fromBBCode() method + */ + function toHtml(asFragment, source, legacyAsFragment) { + var parser = new BBCodeParser(base.opts.parserOptions); + var html = parser.toHTML( + base.opts.bbcodeTrim ? source.trim() : source + ); + + return (asFragment || legacyAsFragment) ? + removeFirstLastDiv(html) : html; + } + + /** + * Converts HTML into BBCode + * + * @param {boolean} asFragment + * @param {string} html + * @param {!Document} [context] + * @param {!HTMLElement} [parent] + * @return {string} + * @private + */ + function toSource(asFragment, html, context, parent) { + context = context || document; + + var bbcode, elements; + var containerParent = context.createElement('div'); + var container = context.createElement('div'); + var parser = new BBCodeParser(base.opts.parserOptions); + + container.innerHTML = html; + css(containerParent, 'visibility', 'hidden'); + containerParent.appendChild(container); + context.body.appendChild(containerParent); + + if (asFragment) { + // Add text before and after so removeWhiteSpace doesn't remove + // leading and trailing whitespace + containerParent.insertBefore( + context.createTextNode('#'), + containerParent.firstChild + ); + containerParent.appendChild(context.createTextNode('#')); + } + + // Match parents white-space handling + if (parent) { + css(container, 'whiteSpace', css(parent, 'whiteSpace')); + } + + // Remove all nodes with sceditor-ignore class + elements = container.getElementsByClassName('sceditor-ignore'); + while (elements.length) { + elements[0].parentNode.removeChild(elements[0]); + } + + dom.removeWhiteSpace(containerParent); + + bbcode = elementToBbcode(container); + + context.body.removeChild(containerParent); + + bbcode = parser.toBBCode(bbcode, true); + + if (base.opts.bbcodeTrim) { + bbcode = bbcode.trim(); + } + + return bbcode; + }; + + base.toHtml = toHtml.bind(null, false); + base.fragmentToHtml = toHtml.bind(null, true); + base.toSource = toSource.bind(null, false); + base.fragmentToSource = toSource.bind(null, true); + }; + + /** + * Gets a BBCode + * + * @param {string} name + * @return {Object|null} + * @since 2.0.0 + */ + bbcodeFormat.get = function (name) { + return bbcodeHandlers[name] || null; + }; + + /** + * Adds a BBCode to the parser or updates an existing + * BBCode if a BBCode with the specified name already exists. + * + * @param {string} name + * @param {Object} bbcode + * @return {this} + * @since 2.0.0 + */ + bbcodeFormat.set = function (name, bbcode) { + if (name && bbcode) { + // merge any existing command properties + bbcode = extend(bbcodeHandlers[name] || {}, bbcode); + + bbcode.remove = function () { + delete bbcodeHandlers[name]; + }; + + bbcodeHandlers[name] = bbcode; + } + + return this; + }; + + /** + * Renames a BBCode + * + * This does not change the format or HTML handling, those must be + * changed manually. + * + * @param {string} name [description] + * @param {string} newName [description] + * @return {this|false} + * @since 2.0.0 + */ + bbcodeFormat.rename = function (name, newName) { + if (name in bbcodeHandlers) { + bbcodeHandlers[newName] = bbcodeHandlers[name]; + + delete bbcodeHandlers[name]; + } + + return this; + }; + + /** + * Removes a BBCode + * + * @param {string} name + * @return {this} + * @since 2.0.0 + */ + bbcodeFormat.remove = function (name) { + if (name in bbcodeHandlers) { + delete bbcodeHandlers[name]; + } + + return this; + }; + + bbcodeFormat.formatBBCodeString = formatBBCodeString; + + sceditor.formats.bbcode = bbcodeFormat; + sceditor.BBCodeParser = BBCodeParser; +}(sceditor));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/jquery.sceditor.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,9158 @@ +(function ($) { + 'use strict'; + + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var $__default = /*#__PURE__*/_interopDefaultLegacy($); + + /** + * Check if the passed argument is the + * the passed type. + * + * @param {string} type + * @param {*} arg + * @returns {boolean} + */ + function isTypeof(type, arg) { + return typeof arg === type; + } + + /** + * @type {function(*): boolean} + */ + var isString = isTypeof.bind(null, 'string'); + + /** + * @type {function(*): boolean} + */ + var isUndefined = isTypeof.bind(null, 'undefined'); + + /** + * @type {function(*): boolean} + */ + var isFunction = isTypeof.bind(null, 'function'); + + /** + * @type {function(*): boolean} + */ + var isNumber = isTypeof.bind(null, 'number'); + + + /** + * Returns true if an object has no keys + * + * @param {!Object} obj + * @returns {boolean} + */ + function isEmptyObject(obj) { + return !Object.keys(obj).length; + } + + /** + * Extends the first object with any extra objects passed + * + * If the first argument is boolean and set to true + * it will extend child arrays and objects recursively. + * + * @param {!Object|boolean} targetArg + * @param {...Object} source + * @return {Object} + */ + function extend(targetArg, sourceArg) { + var isTargetBoolean = targetArg === !!targetArg; + var i = isTargetBoolean ? 2 : 1; + var target = isTargetBoolean ? sourceArg : targetArg; + var isDeep = isTargetBoolean ? targetArg : false; + + function isObject(value) { + return value !== null && typeof value === 'object' && + Object.getPrototypeOf(value) === Object.prototype; + } + + for (; i < arguments.length; i++) { + var source = arguments[i]; + + // Copy all properties for jQuery compatibility + /* eslint guard-for-in: off */ + for (var key in source) { + var targetValue = target[key]; + var value = source[key]; + + // Skip undefined values to match jQuery + if (isUndefined(value)) { + continue; + } + + // Skip special keys to prevent prototype pollution + if (key === '__proto__' || key === 'constructor') { + continue; + } + + var isValueObject = isObject(value); + var isValueArray = Array.isArray(value); + + if (isDeep && (isValueObject || isValueArray)) { + // Can only merge if target type matches otherwise create + // new target to merge into + var isSameType = isObject(targetValue) === isValueObject && + Array.isArray(targetValue) === isValueArray; + + target[key] = extend( + true, + isSameType ? targetValue : (isValueArray ? [] : {}), + value + ); + } else { + target[key] = value; + } + } + } + + return target; + } + + /** + * Removes an item from the passed array + * + * @param {!Array} arr + * @param {*} item + */ + function arrayRemove(arr, item) { + var i = arr.indexOf(item); + + if (i > -1) { + arr.splice(i, 1); + } + } + + /** + * Iterates over an array or object + * + * @param {!Object|Array} obj + * @param {function(*, *)} fn + */ + function each(obj, fn) { + if (Array.isArray(obj) || 'length' in obj && isNumber(obj.length)) { + for (var i = 0; i < obj.length; i++) { + fn(i, obj[i]); + } + } else { + Object.keys(obj).forEach(function (key) { + fn(key, obj[key]); + }); + } + } + + /** + * Cache of camelCase CSS property names + * @type {Object<string, string>} + */ + var cssPropertyNameCache = {}; + + /** + * Node type constant for element nodes + * + * @type {number} + */ + var ELEMENT_NODE = 1; + + /** + * Node type constant for text nodes + * + * @type {number} + */ + var TEXT_NODE = 3; + + /** + * Node type constant for comment nodes + * + * @type {number} + */ + var COMMENT_NODE = 8; + + function toFloat(value) { + value = parseFloat(value); + + return isFinite(value) ? value : 0; + } + + /** + * Creates an element with the specified attributes + * + * Will create it in the current document unless context + * is specified. + * + * @param {!string} tag + * @param {!Object<string, string>} [attributes] + * @param {!Document} [context] + * @returns {!HTMLElement} + */ + function createElement(tag, attributes, context) { + var node = (context || document).createElement(tag); + + each(attributes || {}, function (key, value) { + if (key === 'style') { + node.style.cssText = value; + } else if (key in node) { + node[key] = value; + } else { + node.setAttribute(key, value); + } + }); + + return node; + } + + /** + * Gets the first parent node that matches the selector + * + * @param {!HTMLElement} node + * @param {!string} [selector] + * @returns {HTMLElement|undefined} + */ + function parent(node, selector) { + var parent = node || {}; + + while ((parent = parent.parentNode) && !/(9|11)/.test(parent.nodeType)) { + if (!selector || is(parent, selector)) { + return parent; + } + } + } + + /** + * Checks the passed node and all parents and + * returns the first matching node if any. + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {HTMLElement|undefined} + */ + function closest(node, selector) { + return is(node, selector) ? node : parent(node, selector); + } + + /** + * Removes the node from the DOM + * + * @param {!HTMLElement} node + */ + function remove(node) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + } + + /** + * Appends child to parent node + * + * @param {!HTMLElement} node + * @param {!HTMLElement} child + */ + function appendChild(node, child) { + node.appendChild(child); + } + + /** + * Finds any child nodes that match the selector + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {NodeList} + */ + function find(node, selector) { + return node.querySelectorAll(selector); + } + + /** + * For on() and off() if to add/remove the event + * to the capture phase + * + * @type {boolean} + */ + var EVENT_CAPTURE = true; + + /** + * Adds an event listener for the specified events. + * + * Events should be a space separated list of events. + * + * If selector is specified the handler will only be + * called when the event target matches the selector. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see off() + */ + // eslint-disable-next-line max-params + function on(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector] || function (e) { + var target = e.target; + while (target && target !== node) { + if (is(target, selector)) { + fn.call(target, e); + return; + } + + target = target.parentNode; + } + }; + + fn['_sce-event-' + event + selector] = handler; + } else { + handler = selector; + capture = fn; + } + + node.addEventListener(event, handler, capture || false); + }); + } + + /** + * Removes an event listener for the specified events. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see on() + */ + // eslint-disable-next-line max-params + function off(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector]; + } else { + handler = selector; + capture = fn; + } + + node.removeEventListener(event, handler, capture || false); + }); + } + + /** + * If only attr param is specified it will get + * the value of the attr param. + * + * If value is specified but null the attribute + * will be removed otherwise the attr value will + * be set to the passed value. + * + * @param {!HTMLElement} node + * @param {!string} attr + * @param {?string} [value] + */ + function attr(node, attr, value) { + if (arguments.length < 3) { + return node.getAttribute(attr); + } + + // eslint-disable-next-line eqeqeq, no-eq-null + if (value == null) { + removeAttr(node, attr); + } else { + node.setAttribute(attr, value); + } + } + + /** + * Removes the specified attribute + * + * @param {!HTMLElement} node + * @param {!string} attr + */ + function removeAttr(node, attr) { + node.removeAttribute(attr); + } + + /** + * Sets the passed elements display to none + * + * @param {!HTMLElement} node + */ + function hide(node) { + css(node, 'display', 'none'); + } + + /** + * Sets the passed elements display to default + * + * @param {!HTMLElement} node + */ + function show(node) { + css(node, 'display', ''); + } + + /** + * Toggles an elements visibility + * + * @param {!HTMLElement} node + */ + function toggle(node) { + if (isVisible(node)) { + hide(node); + } else { + show(node); + } + } + + /** + * Gets a computed CSS values or sets an inline CSS value + * + * Rules should be in camelCase format and not + * hyphenated like CSS properties. + * + * @param {!HTMLElement} node + * @param {!Object|string} rule + * @param {string|number} [value] + * @return {string|number|undefined} + */ + function css(node, rule, value) { + if (arguments.length < 3) { + if (isString(rule)) { + return node.nodeType === 1 ? getComputedStyle(node)[rule] : null; + } + + each(rule, function (key, value) { + css(node, key, value); + }); + } else { + // isNaN returns false for null, false and empty strings + // so need to check it's truthy or 0 + var isNumeric = (value || value === 0) && !isNaN(value); + node.style[rule] = isNumeric ? value + 'px' : value; + } + } + + + /** + * Gets or sets the data attributes on a node + * + * Unlike the jQuery version this only stores data + * in the DOM attributes which means only strings + * can be stored. + * + * @param {Node} node + * @param {string} [key] + * @param {string} [value] + * @return {Object|undefined} + */ + function data(node, key, value) { + var argsLength = arguments.length; + var data = {}; + + if (node.nodeType === ELEMENT_NODE) { + if (argsLength === 1) { + each(node.attributes, function (_, attr) { + if (/^data\-/i.test(attr.name)) { + data[attr.name.substr(5)] = attr.value; + } + }); + + return data; + } + + if (argsLength === 2) { + return attr(node, 'data-' + key); + } + + attr(node, 'data-' + key, String(value)); + } + } + + /** + * Checks if node matches the given selector. + * + * @param {?HTMLElement} node + * @param {string} selector + * @returns {boolean} + */ + function is(node, selector) { + var result = false; + + if (node && node.nodeType === ELEMENT_NODE) { + result = (node.matches || node.msMatchesSelector || + node.webkitMatchesSelector).call(node, selector); + } + + return result; + } + + + /** + * Returns true if node contains child otherwise false. + * + * This differs from the DOM contains() method in that + * if node and child are equal this will return false. + * + * @param {!Node} node + * @param {HTMLElement} child + * @returns {boolean} + */ + function contains(node, child) { + return node !== child && node.contains && node.contains(child); + } + + /** + * @param {Node} node + * @param {string} [selector] + * @returns {?HTMLElement} + */ + function previousElementSibling(node, selector) { + var prev = node.previousElementSibling; + + if (selector && prev) { + return is(prev, selector) ? prev : null; + } + + return prev; + } + + /** + * @param {!Node} node + * @param {!Node} refNode + * @returns {Node} + */ + function insertBefore(node, refNode) { + return refNode.parentNode.insertBefore(node, refNode); + } + + /** + * @param {?HTMLElement} node + * @returns {!Array.<string>} + */ + function classes(node) { + return node.className.trim().split(/\s+/); + } + + /** + * @param {?HTMLElement} node + * @param {string} className + * @returns {boolean} + */ + function hasClass(node, className) { + return is(node, '.' + className); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function addClass(node, className) { + var classList = classes(node); + + if (classList.indexOf(className) < 0) { + classList.push(className); + } + + node.className = classList.join(' '); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function removeClass(node, className) { + var classList = classes(node); + + arrayRemove(classList, className); + + node.className = classList.join(' '); + } + + /** + * Toggles a class on node. + * + * If state is specified and is truthy it will add + * the class. + * + * If state is specified and is falsey it will remove + * the class. + * + * @param {HTMLElement} node + * @param {string} className + * @param {boolean} [state] + */ + function toggleClass(node, className, state) { + state = isUndefined(state) ? !hasClass(node, className) : state; + + if (state) { + addClass(node, className); + } else { + removeClass(node, className); + } + } + + /** + * Gets or sets the width of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function width(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingLeft) + toFloat(cs.paddingRight); + var border = toFloat(cs.borderLeftWidth) + toFloat(cs.borderRightWidth); + + return node.offsetWidth - padding - border; + } + + css(node, 'width', value); + } + + /** + * Gets or sets the height of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function height(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingTop) + toFloat(cs.paddingBottom); + var border = toFloat(cs.borderTopWidth) + toFloat(cs.borderBottomWidth); + + return node.offsetHeight - padding - border; + } + + css(node, 'height', value); + } + + /** + * Triggers a custom event with the specified name and + * sets the detail property to the data object passed. + * + * @param {HTMLElement} node + * @param {string} eventName + * @param {Object} [data] + */ + function trigger(node, eventName, data) { + var event; + + if (isFunction(window.CustomEvent)) { + event = new CustomEvent(eventName, { + bubbles: true, + cancelable: true, + detail: data + }); + } else { + event = node.ownerDocument.createEvent('CustomEvent'); + event.initCustomEvent(eventName, true, true, data); + } + + node.dispatchEvent(event); + } + + /** + * Returns if a node is visible. + * + * @param {HTMLElement} + * @returns {boolean} + */ + function isVisible(node) { + return !!node.getClientRects().length; + } + + /** + * Convert CSS property names into camel case + * + * @param {string} string + * @returns {string} + */ + function camelCase(string) { + return string + .replace(/^-ms-/, 'ms-') + .replace(/-(\w)/g, function (match, char) { + return char.toUpperCase(); + }); + } + + + /** + * Loop all child nodes of the passed node + * + * The function should accept 1 parameter being the node. + * If the function returns false the loop will be exited. + * + * @param {HTMLElement} node + * @param {function} func Callback which is called with every + * child node as the first argument. + * @param {boolean} innermostFirst If the innermost node should be passed + * to the function before it's parents. + * @param {boolean} siblingsOnly If to only traverse the nodes siblings + * @param {boolean} [reverse=false] If to traverse the nodes in reverse + */ + // eslint-disable-next-line max-params + function traverse(node, func, innermostFirst, siblingsOnly, reverse) { + node = reverse ? node.lastChild : node.firstChild; + + while (node) { + var next = reverse ? node.previousSibling : node.nextSibling; + + if ( + (!innermostFirst && func(node) === false) || + (!siblingsOnly && traverse( + node, func, innermostFirst, siblingsOnly, reverse + ) === false) || + (innermostFirst && func(node) === false) + ) { + return false; + } + + node = next; + } + } + + /** + * Like traverse but loops in reverse + * @see traverse + */ + function rTraverse(node, func, innermostFirst, siblingsOnly) { + traverse(node, func, innermostFirst, siblingsOnly, true); + } + + /** + * Parses HTML into a document fragment + * + * @param {string} html + * @param {Document} [context] + * @since 1.4.4 + * @return {DocumentFragment} + */ + function parseHTML(html, context) { + context = context || document; + + var ret = context.createDocumentFragment(); + var tmp = createElement('div', {}, context); + + tmp.innerHTML = html; + + while (tmp.firstChild) { + appendChild(ret, tmp.firstChild); + } + + return ret; + } + + /** + * Checks if an element has any styling. + * + * It has styling if it is not a plain <div> or <p> or + * if it has a class, style attribute or data. + * + * @param {HTMLElement} elm + * @return {boolean} + * @since 1.4.4 + */ + function hasStyling(node) { + return node && (!is(node, 'p,div') || node.className || + attr(node, 'style') || !isEmptyObject(data(node))); + } + + /** + * Converts an element from one type to another. + * + * For example it can convert the element <b> to <strong> + * + * @param {HTMLElement} element + * @param {string} toTagName + * @return {HTMLElement} + * @since 1.4.4 + */ + function convertElement(element, toTagName) { + var newElement = createElement(toTagName, {}, element.ownerDocument); + + each(element.attributes, function (_, attribute) { + // Some browsers parse invalid attributes names like + // 'size"2' which throw an exception when set, just + // ignore these. + try { + attr(newElement, attribute.name, attribute.value); + } catch (ex) {} + }); + + while (element.firstChild) { + appendChild(newElement, element.firstChild); + } + + element.parentNode.replaceChild(newElement, element); + + return newElement; + } + + /** + * List of block level elements separated by bars (|) + * + * @type {string} + */ + var blockLevelList = '|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|' + + 'form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|' + + 'details|section|article|aside|nav|main|header|hgroup|footer|fieldset|' + + 'dl|dt|dd|figure|figcaption|'; + + /** + * List of elements that do not allow children separated by bars (|) + * + * @param {Node} node + * @return {boolean} + * @since 1.4.5 + */ + function canHaveChildren(node) { + // 1 = Element + // 9 = Document + // 11 = Document Fragment + if (!/11?|9/.test(node.nodeType)) { + return false; + } + + // List of empty HTML tags separated by bar (|) character. + // Source: http://www.w3.org/TR/html4/index/elements.html + // Source: http://www.w3.org/TR/html5/syntax.html#void-elements + return ('|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr' + + '|isindex|link|meta|param|command|embed|keygen|source|track|' + + 'object|').indexOf('|' + node.nodeName.toLowerCase() + '|') < 0; + } + + /** + * Checks if an element is inline + * + * @param {HTMLElement} elm + * @param {boolean} [includeCodeAsBlock=false] + * @return {boolean} + */ + function isInline(elm, includeCodeAsBlock) { + var tagName, + nodeType = (elm || {}).nodeType || TEXT_NODE; + + if (nodeType !== ELEMENT_NODE) { + return nodeType === TEXT_NODE; + } + + tagName = elm.tagName.toLowerCase(); + + if (tagName === 'code') { + return !includeCodeAsBlock; + } + + return blockLevelList.indexOf('|' + tagName + '|') < 0; + } + + /** + * Copy the CSS from 1 node to another. + * + * Only copies CSS defined on the element e.g. style attr. + * + * @param {HTMLElement} from + * @param {HTMLElement} to + * @deprecated since v3.1.0 + */ + function copyCSS(from, to) { + if (to.style && from.style) { + to.style.cssText = from.style.cssText + to.style.cssText; + } + } + + /** + * Checks if a DOM node is empty + * + * @param {Node} node + * @returns {boolean} + */ + function isEmpty(node) { + if (node.lastChild && isEmpty(node.lastChild)) { + remove(node.lastChild); + } + + return node.nodeType === 3 ? !node.nodeValue : + (canHaveChildren(node) && !node.childNodes.length); + } + + /** + * Fixes block level elements inside in inline elements. + * + * Also fixes invalid list nesting by placing nested lists + * inside the previous li tag or wrapping them in an li tag. + * + * @param {HTMLElement} node + */ + function fixNesting(node) { + traverse(node, function (node) { + var list = 'ul,ol', + isBlock = !isInline(node, true) && node.nodeType !== COMMENT_NODE, + parent = node.parentNode; + + // Any blocklevel element inside an inline element needs fixing. + // Also <p> tags that contain blocks should be fixed + if (isBlock && (isInline(parent, true) || parent.tagName === 'P')) { + // Find the last inline parent node + var lastInlineParent = node; + while (isInline(lastInlineParent.parentNode, true) || + lastInlineParent.parentNode.tagName === 'P') { + lastInlineParent = lastInlineParent.parentNode; + } + + var before = extractContents(lastInlineParent, node); + var middle = node; + + // Clone inline styling and apply it to the blocks children + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + while (middle.firstChild) { + appendChild(clone, middle.firstChild); + } + + appendChild(middle, clone); + } + parent = parent.parentNode; + } + + insertBefore(middle, lastInlineParent); + if (!isEmpty(before)) { + insertBefore(before, middle); + } + if (isEmpty(lastInlineParent)) { + remove(lastInlineParent); + } + } + + // Fix invalid nested lists which should be wrapped in an li tag + if (isBlock && is(node, list) && is(node.parentNode, list)) { + var li = previousElementSibling(node, 'li'); + + if (!li) { + li = createElement('li'); + insertBefore(li, node); + } + + appendChild(li, node); + } + }); + } + + /** + * Finds the common parent of two nodes + * + * @param {!HTMLElement} node1 + * @param {!HTMLElement} node2 + * @return {?HTMLElement} + */ + function findCommonAncestor(node1, node2) { + while ((node1 = node1.parentNode)) { + if (contains(node1, node2)) { + return node1; + } + } + } + + /** + * @param {?Node} + * @param {boolean} [previous=false] + * @returns {?Node} + */ + function getSibling(node, previous) { + if (!node) { + return null; + } + + return (previous ? node.previousSibling : node.nextSibling) || + getSibling(node.parentNode, previous); + } + + /** + * Removes unused whitespace from the root and all it's children. + * + * @param {!HTMLElement} root + * @since 1.4.3 + */ + function removeWhiteSpace(root) { + var nodeValue, nodeType, next, previous, previousSibling, + nextNode, trimStart, + cssWhiteSpace = css(root, 'whiteSpace'), + // Preserve newlines if is pre-line + preserveNewLines = /line$/i.test(cssWhiteSpace), + node = root.firstChild; + + // Skip pre & pre-wrap with any vendor prefix + if (/pre(\-wrap)?$/i.test(cssWhiteSpace)) { + return; + } + + while (node) { + nextNode = node.nextSibling; + nodeValue = node.nodeValue; + nodeType = node.nodeType; + + if (nodeType === ELEMENT_NODE && node.firstChild) { + removeWhiteSpace(node); + } + + if (nodeType === TEXT_NODE) { + next = getSibling(node); + previous = getSibling(node, true); + trimStart = false; + + while (hasClass(previous, 'sceditor-ignore')) { + previous = getSibling(previous, true); + } + + // If previous sibling isn't inline or is a textnode that + // ends in whitespace, time the start whitespace + if (isInline(node) && previous) { + previousSibling = previous; + + while (previousSibling.lastChild) { + previousSibling = previousSibling.lastChild; + + // eslint-disable-next-line max-depth + while (hasClass(previousSibling, 'sceditor-ignore')) { + previousSibling = getSibling(previousSibling, true); + } + } + + trimStart = previousSibling.nodeType === TEXT_NODE ? + /[\t\n\r ]$/.test(previousSibling.nodeValue) : + !isInline(previousSibling); + } + + // Clear zero width spaces + nodeValue = nodeValue.replace(/\u200B/g, ''); + + // Strip leading whitespace + if (!previous || !isInline(previous) || trimStart) { + nodeValue = nodeValue.replace( + preserveNewLines ? /^[\t ]+/ : /^[\t\n\r ]+/, + '' + ); + } + + // Strip trailing whitespace + if (!next || !isInline(next)) { + nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+$/ : /[\t\n\r ]+$/, + '' + ); + } + + // Remove empty text nodes + if (!nodeValue.length) { + remove(node); + } else { + node.nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+/g : /[\t\n\r ]+/g, + ' ' + ); + } + } + + node = nextNode; + } + } + + /** + * Extracts all the nodes between the start and end nodes + * + * @param {HTMLElement} startNode The node to start extracting at + * @param {HTMLElement} endNode The node to stop extracting at + * @return {DocumentFragment} + */ + function extractContents(startNode, endNode) { + var range = startNode.ownerDocument.createRange(); + + range.setStartBefore(startNode); + range.setEndAfter(endNode); + + return range.extractContents(); + } + + /** + * Gets the offset position of an element + * + * @param {HTMLElement} node + * @return {Object} An object with left and top properties + */ + function getOffset(node) { + var left = 0, + top = 0; + + while (node) { + left += node.offsetLeft; + top += node.offsetTop; + node = node.offsetParent; + } + + return { + left: left, + top: top + }; + } + + /** + * Gets the value of a CSS property from the elements style attribute + * + * @param {HTMLElement} elm + * @param {string} property + * @return {string} + */ + function getStyle(elm, property) { + var styleValue, + elmStyle = elm.style; + + if (!cssPropertyNameCache[property]) { + cssPropertyNameCache[property] = camelCase(property); + } + + property = cssPropertyNameCache[property]; + styleValue = elmStyle[property]; + + // Add an exception for text-align + if ('textAlign' === property) { + styleValue = styleValue || css(elm, property); + + if (css(elm.parentNode, property) === styleValue || + css(elm, 'display') !== 'block' || is(elm, 'hr,th')) { + return ''; + } + } + + return styleValue; + } + + /** + * Tests if an element has a style. + * + * If values are specified it will check that the styles value + * matches one of the values + * + * @param {HTMLElement} elm + * @param {string} property + * @param {string|array} [values] + * @return {boolean} + */ + function hasStyle(elm, property, values) { + var styleValue = getStyle(elm, property); + + if (!styleValue) { + return false; + } + + return !values || styleValue === values || + (Array.isArray(values) && values.indexOf(styleValue) > -1); + } + + /** + * Returns true if both nodes have the same number of inline styles and all the + * inline styles have matching values + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function stylesMatch(nodeA, nodeB) { + var i = nodeA.style.length; + if (i !== nodeB.style.length) { + return false; + } + + while (i--) { + var prop = nodeA.style[i]; + if (nodeA.style[prop] !== nodeB.style[prop]) { + return false; + } + } + + return true; + } + + /** + * Returns true if both nodes have the same number of attributes and all the + * attribute values match + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function attributesMatch(nodeA, nodeB) { + var i = nodeA.attributes.length; + if (i !== nodeB.attributes.length) { + return false; + } + + while (i--) { + var prop = nodeA.attributes[i]; + var notMatches = prop.name === 'style' ? + !stylesMatch(nodeA, nodeB) : + prop.value !== attr(nodeB, prop.name); + + if (notMatches) { + return false; + } + } + + return true; + } + + /** + * Removes an element placing its children in its place + * + * @param {HTMLElement} node + */ + function removeKeepChildren(node) { + while (node.firstChild) { + insertBefore(node.firstChild, node); + } + + remove(node); + } + + /** + * Merges inline styles and tags with parents where possible + * + * @param {Node} node + * @since 3.1.0 + */ + function merge(node) { + if (node.nodeType !== ELEMENT_NODE) { + return; + } + + var parent = node.parentNode; + var tagName = node.tagName; + var mergeTags = /B|STRONG|EM|SPAN|FONT/; + + // Merge children (in reverse as children can be removed) + var i = node.childNodes.length; + while (i--) { + merge(node.childNodes[i]); + } + + // Should only merge inline tags + if (!isInline(node)) { + return; + } + + // Remove any inline styles that match the parent style + i = node.style.length; + while (i--) { + var prop = node.style[i]; + if (css(parent, prop) === css(node, prop)) { + node.style.removeProperty(prop); + } + } + + // Can only remove / merge tags if no inline styling left. + // If there is any inline style left then it means it at least partially + // doesn't match the parent style so must stay + if (!node.style.length) { + removeAttr(node, 'style'); + + // Remove font attributes if match parent + if (tagName === 'FONT') { + if (css(node, 'fontFamily').toLowerCase() === + css(parent, 'fontFamily').toLowerCase()) { + removeAttr(node, 'face'); + } + + if (css(node, 'color') === css(parent, 'color')) { + removeAttr(node, 'color'); + } + + if (css(node, 'fontSize') === css(parent, 'fontSize')) { + removeAttr(node, 'size'); + } + } + + // Spans and font tags with no attributes can be safely removed + if (!node.attributes.length && /SPAN|FONT/.test(tagName)) { + removeKeepChildren(node); + } else if (mergeTags.test(tagName)) { + var isBold = /B|STRONG/.test(tagName); + var isItalic = tagName === 'EM'; + + while (parent && isInline(parent) && + (!isBold || /bold|700/i.test(css(parent, 'fontWeight'))) && + (!isItalic || css(parent, 'fontStyle') === 'italic')) { + + // Remove if parent match + if ((parent.tagName === tagName || + (isBold && /B|STRONG/.test(parent.tagName))) && + attributesMatch(parent, node)) { + removeKeepChildren(node); + break; + } + + parent = parent.parentNode; + } + } + } + + // Merge siblings if attributes, including inline styles, match + var next = node.nextSibling; + if (next && next.tagName === tagName && attributesMatch(next, node)) { + appendChild(node, next); + removeKeepChildren(next); + } + } + + /** + * Default options for SCEditor + * @type {Object} + */ + var defaultOptions = { + /** @lends jQuery.sceditor.defaultOptions */ + /** + * Toolbar buttons order and groups. Should be comma separated and + * have a bar | to separate groups + * + * @type {string} + */ + toolbar: 'bold,italic,underline,strike,subscript,superscript|' + + 'left,center,right,justify|font,size,color,removeformat|' + + 'cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|' + + 'table|code,quote|horizontalrule,image,email,link,unlink|' + + 'emoticon,youtube,date,time|ltr,rtl|print,maximize,source', + + /** + * Comma separated list of commands to excludes from the toolbar + * + * @type {string} + */ + toolbarExclude: null, + + /** + * Stylesheet to include in the WYSIWYG editor. This is what will style + * the WYSIWYG elements + * + * @type {string} + */ + style: 'jquery.sceditor.default.css', + + /** + * Comma separated list of fonts for the font selector + * + * @type {string} + */ + fonts: 'Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,' + + 'Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana', + + /** + * Colors should be comma separated and have a bar | to signal a new + * column. + * + * If null the colors will be auto generated. + * + * @type {string} + */ + colors: '#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|' + + '#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|' + + '#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|' + + '#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|' + + '#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|' + + '#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|' + + '#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|' + + '#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef', + + /** + * The locale to use. + * @type {string} + */ + locale: attr(document.documentElement, 'lang') || 'en', + + /** + * The Charset to use + * @type {string} + */ + charset: 'utf-8', + + /** + * Compatibility mode for emoticons. + * + * Helps if you have emoticons such as :/ which would put an emoticon + * inside http:// + * + * This mode requires emoticons to be surrounded by whitespace or end of + * line chars. This mode has limited As You Type emoticon conversion + * support. It will not replace AYT for end of line chars, only + * emoticons surrounded by whitespace. They will still be replaced + * correctly when loaded just not AYT. + * + * @type {boolean} + */ + emoticonsCompat: false, + + /** + * If to enable emoticons. Can be changes at runtime using the + * emoticons() method. + * + * @type {boolean} + * @since 1.4.2 + */ + emoticonsEnabled: true, + + /** + * Emoticon root URL + * + * @type {string} + */ + emoticonsRoot: '', + emoticons: { + dropdown: { + ':)': 'emoticons/smile.png', + ':angel:': 'emoticons/angel.png', + ':angry:': 'emoticons/angry.png', + '8-)': 'emoticons/cool.png', + ':\'(': 'emoticons/cwy.png', + ':ermm:': 'emoticons/ermm.png', + ':D': 'emoticons/grin.png', + '<3': 'emoticons/heart.png', + ':(': 'emoticons/sad.png', + ':O': 'emoticons/shocked.png', + ':P': 'emoticons/tongue.png', + ';)': 'emoticons/wink.png' + }, + more: { + ':alien:': 'emoticons/alien.png', + ':blink:': 'emoticons/blink.png', + ':blush:': 'emoticons/blush.png', + ':cheerful:': 'emoticons/cheerful.png', + ':devil:': 'emoticons/devil.png', + ':dizzy:': 'emoticons/dizzy.png', + ':getlost:': 'emoticons/getlost.png', + ':happy:': 'emoticons/happy.png', + ':kissing:': 'emoticons/kissing.png', + ':ninja:': 'emoticons/ninja.png', + ':pinch:': 'emoticons/pinch.png', + ':pouty:': 'emoticons/pouty.png', + ':sick:': 'emoticons/sick.png', + ':sideways:': 'emoticons/sideways.png', + ':silly:': 'emoticons/silly.png', + ':sleeping:': 'emoticons/sleeping.png', + ':unsure:': 'emoticons/unsure.png', + ':woot:': 'emoticons/w00t.png', + ':wassat:': 'emoticons/wassat.png' + }, + hidden: { + ':whistling:': 'emoticons/whistling.png', + ':love:': 'emoticons/wub.png' + } + }, + + /** + * Width of the editor. Set to null for automatic with + * + * @type {?number} + */ + width: null, + + /** + * Height of the editor including toolbar. Set to null for automatic + * height + * + * @type {?number} + */ + height: null, + + /** + * If to allow the editor to be resized + * + * @type {boolean} + */ + resizeEnabled: true, + + /** + * Min resize to width, set to null for half textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinWidth: null, + /** + * Min resize to height, set to null for half textarea height or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinHeight: null, + /** + * Max resize to height, set to null for double textarea height or -1 + * for unlimited + * + * @type {?number} + */ + resizeMaxHeight: null, + /** + * Max resize to width, set to null for double textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMaxWidth: null, + /** + * If resizing by height is enabled + * + * @type {boolean} + */ + resizeHeight: true, + /** + * If resizing by width is enabled + * + * @type {boolean} + */ + resizeWidth: true, + + /** + * Date format, will be overridden if locale specifies one. + * + * The words year, month and day will be replaced with the users current + * year, month and day. + * + * @type {string} + */ + dateFormat: 'year-month-day', + + /** + * Element to inset the toolbar into. + * + * @type {HTMLElement} + */ + toolbarContainer: null, + + /** + * If to enable paste filtering. This is currently experimental, please + * report any issues. + * + * @type {boolean} + */ + enablePasteFiltering: false, + + /** + * If to completely disable pasting into the editor + * + * @type {boolean} + */ + disablePasting: false, + + /** + * If the editor is read only. + * + * @type {boolean} + */ + readOnly: false, + + /** + * If to set the editor to right-to-left mode. + * + * If set to null the direction will be automatically detected. + * + * @type {boolean} + */ + rtl: false, + + /** + * If to auto focus the editor on page load + * + * @type {boolean} + */ + autofocus: false, + + /** + * If to auto focus the editor to the end of the content + * + * @type {boolean} + */ + autofocusEnd: true, + + /** + * If to auto expand the editor to fix the content + * + * @type {boolean} + */ + autoExpand: false, + + /** + * If to auto update original textbox on blur + * + * @type {boolean} + */ + autoUpdate: false, + + /** + * If to enable the browsers built in spell checker + * + * @type {boolean} + */ + spellcheck: true, + + /** + * If to run the source editor when there is no WYSIWYG support. Only + * really applies to mobile OS's. + * + * @type {boolean} + */ + runWithoutWysiwygSupport: false, + + /** + * If to load the editor in source mode and still allow switching + * between WYSIWYG and source mode + * + * @type {boolean} + */ + startInSourceMode: false, + + /** + * Optional ID to give the editor. + * + * @type {string} + */ + id: null, + + /** + * Comma separated list of plugins + * + * @type {string} + */ + plugins: '', + + /** + * z-index to set the editor container to. Needed for jQuery UI dialog. + * + * @type {?number} + */ + zIndex: null, + + /** + * If to trim the BBCode. Removes any spaces at the start and end of the + * BBCode string. + * + * @type {boolean} + */ + bbcodeTrim: false, + + /** + * If to disable removing block level elements by pressing backspace at + * the start of them + * + * @type {boolean} + */ + disableBlockRemove: false, + + /** + * Array of allowed URL (should be either strings or regex) for iframes. + * + * If it's a string then iframes where the start of the src matches the + * specified string will be allowed. + * + * If it's a regex then iframes where the src matches the regex will be + * allowed. + * + * @type {Array} + */ + allowedIframeUrls: [], + + /** + * BBCode parser options, only applies if using the editor in BBCode + * mode. + * + * See SCEditor.BBCodeParser.defaults for list of valid options + * + * @type {Object} + */ + parserOptions: { }, + + /** + * CSS that will be added to the to dropdown menu (eg. z-index) + * + * @type {Object} + */ + dropDownCss: { } + }; + + // Must start with a valid scheme + // ^ + // Schemes that are considered safe + // (https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):| + // Relative schemes (//:) are considered safe + // (\\/\\/)| + // Image data URI's are considered safe + // data:image\\/(png|bmp|gif|p?jpe?g); + var VALID_SCHEME_REGEX = + /^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i; + + /** + * Escapes a string so it's safe to use in regex + * + * @param {string} str + * @return {string} + */ + function regex(str) { + return str.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'); + } + /** + * Escapes all HTML entities in a string + * + * If noQuotes is set to false, all single and double + * quotes will also be escaped + * + * @param {string} str + * @param {boolean} [noQuotes=true] + * @return {string} + * @since 1.4.1 + */ + function entities(str, noQuotes) { + if (!str) { + return str; + } + + var replacements = { + '&': '&', + '<': '<', + '>': '>', + ' ': ' ', + '\r\n': '<br />', + '\r': '<br />', + '\n': '<br />' + }; + + if (noQuotes !== false) { + replacements['"'] = '"'; + replacements['\''] = '''; + replacements['`'] = '`'; + } + + str = str.replace(/ {2}|\r\n|[&<>\r\n'"`]/g, function (match) { + return replacements[match] || match; + }); + + return str; + } + /** + * Escape URI scheme. + * + * Appends the current URL to a url if it has a scheme that is not: + * + * http + * https + * sftp + * ftp + * mailto + * spotify + * skype + * ssh + * teamspeak + * tel + * // + * data:image/(png|jpeg|jpg|pjpeg|bmp|gif); + * + * **IMPORTANT**: This does not escape any HTML in a url, for + * that use the escape.entities() method. + * + * @param {string} url + * @return {string} + * @since 1.4.5 + */ + function uriScheme(url) { + var path, + // If there is a : before a / then it has a scheme + hasScheme = /^[^\/]*:/i, + location = window.location; + + // Has no scheme or a valid scheme + if ((!url || !hasScheme.test(url)) || VALID_SCHEME_REGEX.test(url)) { + return url; + } + + path = location.pathname.split('/'); + path.pop(); + + return location.protocol + '//' + + location.host + + path.join('/') + '/' + + url; + } + + /** + * HTML templates used by the editor and default commands + * @type {Object} + * @private + */ + var _templates = { + html: + '<!DOCTYPE html>' + + '<html{attrs}>' + + '<head>' + + '<meta http-equiv="Content-Type" ' + + 'content="text/html;charset={charset}" />' + + '<link rel="stylesheet" type="text/css" href="{style}" />' + + '</head>' + + '<body contenteditable="true" {spellcheck}><p></p></body>' + + '</html>', + + toolbarButton: '<a class="sceditor-button sceditor-button-{name}" ' + + 'data-sceditor-command="{name}" unselectable="on">' + + '<div unselectable="on">{dispName}</div></a>', + + emoticon: '<img src="{url}" data-sceditor-emoticon="{key}" ' + + 'alt="{key}" title="{tooltip}" />', + + fontOpt: '<a class="sceditor-font-option" href="#" ' + + 'data-font="{font}"><font face="{font}">{font}</font></a>', + + sizeOpt: '<a class="sceditor-fontsize-option" data-size="{size}" ' + + 'href="#"><font size="{size}">{size}</font></a>', + + pastetext: + '<div><label for="txt">{label}</label> ' + + '<textarea cols="20" rows="7" id="txt"></textarea></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + table: + '<div><label for="rows">{rows}</label><input type="text" ' + + 'id="rows" value="2" /></div>' + + '<div><label for="cols">{cols}</label><input type="text" ' + + 'id="cols" value="2" /></div>' + + '<div><input type="button" class="button" value="{insert}"' + + ' /></div>', + + image: + '<div><label for="image">{url}</label> ' + + '<input type="text" id="image" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="width">{width}</label> ' + + '<input type="text" id="width" size="2" dir="ltr" /></div>' + + '<div><label for="height">{height}</label> ' + + '<input type="text" id="height" size="2" dir="ltr" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + email: + '<div><label for="email">{label}</label> ' + + '<input type="text" id="email" dir="ltr" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + link: + '<div><label for="link">{url}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{ins}" /></div>', + + youtubeMenu: + '<div><label for="link">{label}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + youtube: + '<iframe width="560" height="315" frameborder="0" allowfullscreen ' + + 'src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" ' + + 'data-youtube-id="{id}"></iframe>' + }; + + /** + * Replaces any params in a template with the passed params. + * + * If createHtml is passed it will return a DocumentFragment + * containing the parsed template. + * + * @param {string} name + * @param {Object} [params] + * @param {boolean} [createHtml] + * @returns {string|DocumentFragment} + * @private + */ + function _tmpl (name, params, createHtml) { + var template = _templates[name]; + + Object.keys(params).forEach(function (name) { + template = template.replace( + new RegExp(regex('{' + name + '}'), 'g'), params[name] + ); + }); + + if (createHtml) { + template = parseHTML(template); + } + + return template; + } + + /** + * Fixes a bug in FF where it sometimes wraps + * new lines in their own list item. + * See issue #359 + */ + function fixFirefoxListBug(editor) { + // Only apply to Firefox as will break other browsers. + if ('mozHidden' in document) { + var node = editor.getBody(); + var next; + + while (node) { + next = node; + + if (next.firstChild) { + next = next.firstChild; + } else { + + while (next && !next.nextSibling) { + next = next.parentNode; + } + + if (next) { + next = next.nextSibling; + } + } + + if (node.nodeType === 3 && /[\n\r\t]+/.test(node.nodeValue)) { + // Only remove if newlines are collapsed + if (!/^pre/.test(css(node.parentNode, 'whiteSpace'))) { + remove(node); + } + } + + node = next; + } + } + } + + + /** + * Map of all the commands for SCEditor + * @type {Object} + * @name commands + * @memberOf jQuery.sceditor + */ + var defaultCmds = { + // START_COMMAND: Bold + bold: { + exec: 'bold', + tooltip: 'Bold', + shortcut: 'Ctrl+B' + }, + // END_COMMAND + // START_COMMAND: Italic + italic: { + exec: 'italic', + tooltip: 'Italic', + shortcut: 'Ctrl+I' + }, + // END_COMMAND + // START_COMMAND: Underline + underline: { + exec: 'underline', + tooltip: 'Underline', + shortcut: 'Ctrl+U' + }, + // END_COMMAND + // START_COMMAND: Strikethrough + strike: { + exec: 'strikethrough', + tooltip: 'Strikethrough' + }, + // END_COMMAND + // START_COMMAND: Subscript + subscript: { + exec: 'subscript', + tooltip: 'Subscript' + }, + // END_COMMAND + // START_COMMAND: Superscript + superscript: { + exec: 'superscript', + tooltip: 'Superscript' + }, + // END_COMMAND + + // START_COMMAND: Left + left: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-left + return /left/.test(align) || + align === (isLtr ? 'start' : 'end'); + } + }, + exec: 'justifyleft', + tooltip: 'Align left' + }, + // END_COMMAND + // START_COMMAND: Centre + center: { + exec: 'justifycenter', + tooltip: 'Center' + }, + // END_COMMAND + // START_COMMAND: Right + right: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-right + return /right/.test(align) || + align === (isLtr ? 'end' : 'start'); + } + }, + exec: 'justifyright', + tooltip: 'Align right' + }, + // END_COMMAND + // START_COMMAND: Justify + justify: { + exec: 'justifyfull', + tooltip: 'Justify' + }, + // END_COMMAND + + // START_COMMAND: Font + font: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'font')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.opts.fonts.split(',').forEach(function (font) { + appendChild(content, _tmpl('fontOpt', { + font: font + }, true)); + }); + + editor.createDropDown(caller, 'font-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.font._dropDown(editor, caller, function (fontName) { + editor.execCommand('fontname', fontName); + }); + }, + tooltip: 'Font Name' + }, + // END_COMMAND + // START_COMMAND: Size + size: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'size')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + for (var i = 1; i <= 7; i++) { + appendChild(content, _tmpl('sizeOpt', { + size: i + }, true)); + } + + editor.createDropDown(caller, 'fontsize-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.size._dropDown(editor, caller, function (fontSize) { + editor.execCommand('fontsize', fontSize); + }); + }, + tooltip: 'Font Size' + }, + // END_COMMAND + // START_COMMAND: Colour + color: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'), + html = '', + cmd = defaultCmds.color; + + if (!cmd._htmlCache) { + editor.opts.colors.split('|').forEach(function (column) { + html += '<div class="sceditor-color-column">'; + + column.split(',').forEach(function (color) { + html += + '<a href="#" class="sceditor-color-option"' + + ' style="background-color: ' + color + '"' + + ' data-color="' + color + '"></a>'; + }); + + html += '</div>'; + }); + + cmd._htmlCache = html; + } + + appendChild(content, parseHTML(cmd._htmlCache)); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'color')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'color-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.color._dropDown(editor, caller, function (color) { + editor.execCommand('forecolor', color); + }); + }, + tooltip: 'Font Color' + }, + // END_COMMAND + // START_COMMAND: Remove Format + removeformat: { + exec: 'removeformat', + tooltip: 'Remove Formatting' + }, + // END_COMMAND + + // START_COMMAND: Cut + cut: { + exec: 'cut', + tooltip: 'Cut', + errorMessage: 'Your browser does not allow the cut command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-X' + }, + // END_COMMAND + // START_COMMAND: Copy + copy: { + exec: 'copy', + tooltip: 'Copy', + errorMessage: 'Your browser does not allow the copy command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-C' + }, + // END_COMMAND + // START_COMMAND: Paste + paste: { + exec: 'paste', + tooltip: 'Paste', + errorMessage: 'Your browser does not allow the paste command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-V' + }, + // END_COMMAND + // START_COMMAND: Paste Text + pastetext: { + exec: function (caller) { + var val, + content = createElement('div'), + editor = this; + + appendChild(content, _tmpl('pastetext', { + label: editor._( + 'Paste your text inside the following box:' + ), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + val = find(content, '#txt')[0].value; + + if (val) { + editor.wysiwygEditorInsertText(val); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'pastetext', content); + }, + tooltip: 'Paste Text' + }, + // END_COMMAND + // START_COMMAND: Bullet List + bulletlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertunorderedlist'); + }, + tooltip: 'Bullet list' + }, + // END_COMMAND + // START_COMMAND: Ordered List + orderedlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertorderedlist'); + }, + tooltip: 'Numbered list' + }, + // END_COMMAND + // START_COMMAND: Indent + indent: { + state: function (parent, firstBlock) { + // Only works with lists, for now + var range, startParent, endParent; + + if (is(firstBlock, 'li')) { + return 0; + } + + if (is(firstBlock, 'ul,ol,menu')) { + // if the whole list is selected, then this must be + // invalidated because the browser will place a + // <blockquote> there + range = this.getRangeHelper().selectedRange(); + + startParent = range.startContainer.parentNode; + endParent = range.endContainer.parentNode; + + // TODO: could use nodeType for this? + // Maybe just check the firstBlock contains both the start + //and end containers + + // Select the tag, not the textNode + // (that's why the parentNode) + if (startParent !== + startParent.parentNode.firstElementChild || + // work around a bug in FF + (is(endParent, 'li') && endParent !== + endParent.parentNode.lastElementChild)) { + return 0; + } + } + + return -1; + }, + exec: function () { + var editor = this, + block = editor.getRangeHelper().getFirstBlockParent(); + + editor.focus(); + + // An indent system is quite complicated as there are loads + // of complications and issues around how to indent text + // As default, let's just stay with indenting the lists, + // at least, for now. + if (closest(block, 'ul,ol,menu')) { + editor.execCommand('indent'); + } + }, + tooltip: 'Add indent' + }, + // END_COMMAND + // START_COMMAND: Outdent + outdent: { + state: function (parents, firstBlock) { + return closest(firstBlock, 'ul,ol,menu') ? 0 : -1; + }, + exec: function () { + var block = this.getRangeHelper().getFirstBlockParent(); + if (closest(block, 'ul,ol,menu')) { + this.execCommand('outdent'); + } + }, + tooltip: 'Remove one indent' + }, + // END_COMMAND + + // START_COMMAND: Table + table: { + exec: function (caller) { + var editor = this, + content = createElement('div'); + + appendChild(content, _tmpl('table', { + rows: editor._('Rows:'), + cols: editor._('Cols:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var rows = Number(find(content, '#rows')[0].value), + cols = Number(find(content, '#cols')[0].value), + html = '<table>'; + + if (rows > 0 && cols > 0) { + html += Array(rows + 1).join( + '<tr>' + + Array(cols + 1).join( + '<td><br /></td>' + ) + + '</tr>' + ); + + html += '</table>'; + + editor.wysiwygEditorInsertHtml(html); + editor.closeDropDown(true); + e.preventDefault(); + } + }); + + editor.createDropDown(caller, 'inserttable', content); + }, + tooltip: 'Insert a table' + }, + // END_COMMAND + + // START_COMMAND: Horizontal Rule + horizontalrule: { + exec: 'inserthorizontalrule', + tooltip: 'Insert a horizontal rule' + }, + // END_COMMAND + + // START_COMMAND: Code + code: { + exec: function () { + this.wysiwygEditorInsertHtml( + '<code>', + '<br /></code>' + ); + }, + tooltip: 'Code' + }, + // END_COMMAND + + // START_COMMAND: Image + image: { + _dropDown: function (editor, caller, selected, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('image', { + url: editor._('URL:'), + width: editor._('Width (optional):'), + height: editor._('Height (optional):'), + insert: editor._('Insert') + }, true)); + + + var urlInput = find(content, '#image')[0]; + + urlInput.value = selected; + + on(content, 'click', '.button', function (e) { + if (urlInput.value) { + cb( + urlInput.value, + find(content, '#width')[0].value, + find(content, '#height')[0].value + ); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertimage', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.image._dropDown( + editor, + caller, + '', + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width="' + parseInt(width, 10) + '"'; + } + + if (height) { + attrs += ' height="' + parseInt(height, 10) + '"'; + } + + attrs += ' src="' + entities(url) + '"'; + + editor.wysiwygEditorInsertHtml( + '<img' + attrs + ' />' + ); + } + ); + }, + tooltip: 'Insert an image' + }, + // END_COMMAND + + // START_COMMAND: E-mail + email: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('email', { + label: editor._('E-mail:'), + desc: editor._('Description (optional):'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var email = find(content, '#email')[0].value; + + if (email) { + cb(email, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertemail', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.email._dropDown( + editor, + caller, + function (email, text) { + if (!editor.getRangeHelper().selectedHtml() || text) { + editor.wysiwygEditorInsertHtml( + '<a href="' + + 'mailto:' + entities(email) + '">' + + entities((text || email)) + + '</a>' + ); + } else { + editor.execCommand('createlink', 'mailto:' + email); + } + } + ); + }, + tooltip: 'Insert an email' + }, + // END_COMMAND + + // START_COMMAND: Link + link: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('link', { + url: editor._('URL:'), + desc: editor._('Description (optional):'), + ins: editor._('Insert') + }, true)); + + var linkInput = find(content, '#link')[0]; + + function insertUrl(e) { + if (linkInput.value) { + cb(linkInput.value, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + } + + on(content, 'click', '.button', insertUrl); + on(content, 'keypress', function (e) { + // 13 = enter key + if (e.which === 13 && linkInput.value) { + insertUrl(e); + } + }, EVENT_CAPTURE); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.link._dropDown(editor, caller, function (url, text) { + if (text || !editor.getRangeHelper().selectedHtml()) { + editor.wysiwygEditorInsertHtml( + '<a href="' + entities(url) + '">' + + entities(text || url) + + '</a>' + ); + } else { + editor.execCommand('createlink', url); + } + }); + }, + tooltip: 'Insert a link' + }, + // END_COMMAND + + // START_COMMAND: Unlink + unlink: { + state: function () { + return closest(this.currentNode(), 'a') ? 0 : -1; + }, + exec: function () { + var anchor = closest(this.currentNode(), 'a'); + + if (anchor) { + while (anchor.firstChild) { + insertBefore(anchor.firstChild, anchor); + } + + remove(anchor); + } + }, + tooltip: 'Unlink' + }, + // END_COMMAND + + + // START_COMMAND: Quote + quote: { + exec: function (caller, html, author) { + var before = '<blockquote>', + end = '</blockquote>'; + + // if there is HTML passed set end to null so any selected + // text is replaced + if (html) { + author = (author ? '<cite>' + + entities(author) + + '</cite>' : ''); + before = before + author + html + end; + end = null; + // if not add a newline to the end of the inserted quote + } else if (this.getRangeHelper().selectedHtml() === '') { + end = '<br />' + end; + } + + this.wysiwygEditorInsertHtml(before, end); + }, + tooltip: 'Insert a Quote' + }, + // END_COMMAND + + // START_COMMAND: Emoticons + emoticon: { + exec: function (caller) { + var editor = this; + + var createContent = function (includeMore) { + var moreLink, + opts = editor.opts, + emoticonsRoot = opts.emoticonsRoot || '', + emoticonsCompat = opts.emoticonsCompat, + rangeHelper = editor.getRangeHelper(), + startSpace = emoticonsCompat && + rangeHelper.getOuterText(true, 1) !== ' ' ? ' ' : '', + endSpace = emoticonsCompat && + rangeHelper.getOuterText(false, 1) !== ' ' ? ' ' : '', + content = createElement('div'), + line = createElement('div'), + perLine = 0, + emoticons = extend( + {}, + opts.emoticons.dropdown, + includeMore ? opts.emoticons.more : {} + ); + + appendChild(content, line); + + perLine = Math.sqrt(Object.keys(emoticons).length); + + on(content, 'click', 'img', function (e) { + editor.insert(startSpace + attr(this, 'alt') + endSpace, + null, false).closeDropDown(true); + + e.preventDefault(); + }); + + each(emoticons, function (code, emoticon) { + appendChild(line, createElement('img', { + src: emoticonsRoot + (emoticon.url || emoticon), + alt: code, + title: emoticon.tooltip || code + })); + + if (line.children.length >= perLine) { + line = createElement('div'); + appendChild(content, line); + } + }); + + if (!includeMore && opts.emoticons.more) { + moreLink = createElement('a', { + className: 'sceditor-more' + }); + + appendChild(moreLink, + document.createTextNode(editor._('More'))); + + on(moreLink, 'click', function (e) { + editor.createDropDown( + caller, 'more-emoticons', createContent(true) + ); + + e.preventDefault(); + }); + + appendChild(content, moreLink); + } + + return content; + }; + + editor.createDropDown(caller, 'emoticons', createContent(false)); + }, + txtExec: function (caller) { + defaultCmds.emoticon.exec.call(this, caller); + }, + tooltip: 'Insert an emoticon' + }, + // END_COMMAND + + // START_COMMAND: YouTube + youtube: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + appendChild(content, _tmpl('youtubeMenu', { + label: editor._('Video URL:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var val = find(content, '#link')[0].value; + var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/); + var timeMatch = val.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/); + var time = 0; + + if (timeMatch) { + each(timeMatch[1].split(/[hms]/), function (i, val) { + if (val !== '') { + time = (time * 60) + Number(val); + } + }); + } + + if (idMatch && /^[a-zA-Z0-9_\-]{11}$/.test(idMatch[1])) { + callback(idMatch[1], time); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (btn) { + var editor = this; + + defaultCmds.youtube._dropDown(editor, btn, function (id, time) { + editor.wysiwygEditorInsertHtml(_tmpl('youtube', { + id: id, + time: time + })); + }); + }, + tooltip: 'Insert a YouTube video' + }, + // END_COMMAND + + // START_COMMAND: Date + date: { + _date: function (editor) { + var now = new Date(), + year = now.getYear(), + month = now.getMonth() + 1, + day = now.getDate(); + + if (year < 2000) { + year = 1900 + year; + } + + if (month < 10) { + month = '0' + month; + } + + if (day < 10) { + day = '0' + day; + } + + return editor.opts.dateFormat + .replace(/year/i, year) + .replace(/month/i, month) + .replace(/day/i, day); + }, + exec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + txtExec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + tooltip: 'Insert current date' + }, + // END_COMMAND + + // START_COMMAND: Time + time: { + _time: function () { + var now = new Date(), + hours = now.getHours(), + mins = now.getMinutes(), + secs = now.getSeconds(); + + if (hours < 10) { + hours = '0' + hours; + } + + if (mins < 10) { + mins = '0' + mins; + } + + if (secs < 10) { + secs = '0' + secs; + } + + return hours + ':' + mins + ':' + secs; + }, + exec: function () { + this.insertText(defaultCmds.time._time()); + }, + txtExec: function () { + this.insertText(defaultCmds.time._time()); + }, + tooltip: 'Insert current time' + }, + // END_COMMAND + + + // START_COMMAND: Ltr + ltr: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'ltr'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'ltr' ? '' : 'ltr'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Left-to-Right' + }, + // END_COMMAND + + // START_COMMAND: Rtl + rtl: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'rtl'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'rtl' ? '' : 'rtl'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Right-to-Left' + }, + // END_COMMAND + + + // START_COMMAND: Print + print: { + exec: 'print', + tooltip: 'Print' + }, + // END_COMMAND + + // START_COMMAND: Maximize + maximize: { + state: function () { + return this.maximize(); + }, + exec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + txtExec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + tooltip: 'Maximize', + shortcut: 'Ctrl+Shift+M' + }, + // END_COMMAND + + // START_COMMAND: Source + source: { + state: function () { + return this.sourceMode(); + }, + exec: function () { + this.toggleSourceMode(); + this.focus(); + }, + txtExec: function () { + this.toggleSourceMode(); + this.focus(); + }, + tooltip: 'View source', + shortcut: 'Ctrl+Shift+S' + }, + // END_COMMAND + + // this is here so that commands above can be removed + // without having to remove the , after the last one. + // Needed for IE. + ignore: {} + }; + + var plugins = {}; + + /** + * Plugin Manager class + * @class PluginManager + * @name PluginManager + */ + function PluginManager(thisObj) { + /** + * Alias of this + * + * @private + * @type {Object} + */ + var base = this; + + /** + * Array of all currently registered plugins + * + * @type {Array} + * @private + */ + var registeredPlugins = []; + + + /** + * Changes a signals name from "name" into "signalName". + * + * @param {string} signal + * @return {string} + * @private + */ + var formatSignalName = function (signal) { + return 'signal' + signal.charAt(0).toUpperCase() + signal.slice(1); + }; + + /** + * Calls handlers for a signal + * + * @see call() + * @see callOnlyFirst() + * @param {Array} args + * @param {boolean} returnAtFirst + * @return {*} + * @private + */ + var callHandlers = function (args, returnAtFirst) { + args = [].slice.call(args); + + var idx, ret, + signal = formatSignalName(args.shift()); + + for (idx = 0; idx < registeredPlugins.length; idx++) { + if (signal in registeredPlugins[idx]) { + ret = registeredPlugins[idx][signal].apply(thisObj, args); + + if (returnAtFirst) { + return ret; + } + } + } + }; + + /** + * Calls all handlers for the passed signal + * + * @param {string} signal + * @param {...string} args + * @function + * @name call + * @memberOf PluginManager.prototype + */ + base.call = function () { + callHandlers(arguments, false); + }; + + /** + * Calls the first handler for a signal, and returns the + * + * @param {string} signal + * @param {...string} args + * @return {*} The result of calling the handler + * @function + * @name callOnlyFirst + * @memberOf PluginManager.prototype + */ + base.callOnlyFirst = function () { + return callHandlers(arguments, true); + }; + + /** + * Checks if a signal has a handler + * + * @param {string} signal + * @return {boolean} + * @function + * @name hasHandler + * @memberOf PluginManager.prototype + */ + base.hasHandler = function (signal) { + var i = registeredPlugins.length; + signal = formatSignalName(signal); + + while (i--) { + if (signal in registeredPlugins[i]) { + return true; + } + } + + return false; + }; + + /** + * Checks if the plugin exists in plugins + * + * @param {string} plugin + * @return {boolean} + * @function + * @name exists + * @memberOf PluginManager.prototype + */ + base.exists = function (plugin) { + if (plugin in plugins) { + plugin = plugins[plugin]; + + return typeof plugin === 'function' && + typeof plugin.prototype === 'object'; + } + + return false; + }; + + /** + * Checks if the passed plugin is currently registered. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name isRegistered + * @memberOf PluginManager.prototype + */ + base.isRegistered = function (plugin) { + if (base.exists(plugin)) { + var idx = registeredPlugins.length; + + while (idx--) { + if (registeredPlugins[idx] instanceof plugins[plugin]) { + return true; + } + } + } + + return false; + }; + + /** + * Registers a plugin to receive signals + * + * @param {string} plugin + * @return {boolean} + * @function + * @name register + * @memberOf PluginManager.prototype + */ + base.register = function (plugin) { + if (!base.exists(plugin) || base.isRegistered(plugin)) { + return false; + } + + plugin = new plugins[plugin](); + registeredPlugins.push(plugin); + + if ('init' in plugin) { + plugin.init.call(thisObj); + } + + return true; + }; + + /** + * Deregisters a plugin. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name deregister + * @memberOf PluginManager.prototype + */ + base.deregister = function (plugin) { + var removedPlugin, + pluginIdx = registeredPlugins.length, + removed = false; + + if (!base.isRegistered(plugin)) { + return removed; + } + + while (pluginIdx--) { + if (registeredPlugins[pluginIdx] instanceof plugins[plugin]) { + removedPlugin = registeredPlugins.splice(pluginIdx, 1)[0]; + removed = true; + + if ('destroy' in removedPlugin) { + removedPlugin.destroy.call(thisObj); + } + } + } + + return removed; + }; + + /** + * Clears all plugins and removes the owner reference. + * + * Calling any functions on this object after calling + * destroy will cause a JS error. + * + * @name destroy + * @memberOf PluginManager.prototype + */ + base.destroy = function () { + var i = registeredPlugins.length; + + while (i--) { + if ('destroy' in registeredPlugins[i]) { + registeredPlugins[i].destroy.call(thisObj); + } + } + + registeredPlugins = []; + thisObj = null; + }; + } + PluginManager.plugins = plugins; + + /** + * Gets the text, start/end node and offset for + * length chars left or right of the passed node + * at the specified offset. + * + * @param {Node} node + * @param {number} offset + * @param {boolean} isLeft + * @param {number} length + * @return {Object} + * @private + */ + var outerText = function (range, isLeft, length) { + var nodeValue, remaining, start, end, node, + text = '', + next = range.startContainer, + offset = range.startOffset; + + // Handle cases where node is a paragraph and offset + // refers to the index of a text node. + // 3 = text node + if (next && next.nodeType !== 3) { + next = next.childNodes[offset]; + offset = 0; + } + + start = end = offset; + + while (length > text.length && next && next.nodeType === 3) { + nodeValue = next.nodeValue; + remaining = length - text.length; + + // If not the first node, start and end should be at their + // max values as will be updated when getting the text + if (node) { + end = nodeValue.length; + start = 0; + } + + node = next; + + if (isLeft) { + start = Math.max(end - remaining, 0); + offset = start; + + text = nodeValue.substr(start, end - start) + text; + next = node.previousSibling; + } else { + end = Math.min(remaining, nodeValue.length); + offset = start + end; + + text += nodeValue.substr(start, end); + next = node.nextSibling; + } + } + + return { + node: node || next, + offset: offset, + text: text + }; + }; + + /** + * Range helper + * + * @class RangeHelper + * @name RangeHelper + */ + function RangeHelper(win, d, sanitize) { + var _createMarker, _prepareInput, + doc = d || win.contentDocument || win.document, + startMarker = 'sceditor-start-marker', + endMarker = 'sceditor-end-marker', + base = this; + + /** + * Inserts HTML into the current range replacing any selected + * text. + * + * If endHTML is specified the selected contents will be put between + * html and endHTML. If there is nothing selected html and endHTML are + * just concatenate together. + * + * @param {string} html + * @param {string} [endHTML] + * @return False on fail + * @function + * @name insertHTML + * @memberOf RangeHelper.prototype + */ + base.insertHTML = function (html, endHTML) { + var node, div, + range = base.selectedRange(); + + if (!range) { + return false; + } + + if (endHTML) { + html += base.selectedHtml() + endHTML; + } + + div = createElement('p', {}, doc); + node = doc.createDocumentFragment(); + div.innerHTML = sanitize(html); + + while (div.firstChild) { + appendChild(node, div.firstChild); + } + + base.insertNode(node); + }; + + /** + * Prepares HTML to be inserted by adding a zero width space + * if the last child is empty and adding the range start/end + * markers to the last child. + * + * @param {Node|string} node + * @param {Node|string} [endNode] + * @param {boolean} [returnHtml] + * @return {Node|string} + * @private + */ + _prepareInput = function (node, endNode, returnHtml) { + var lastChild, + frag = doc.createDocumentFragment(); + + if (typeof node === 'string') { + if (endNode) { + node += base.selectedHtml() + endNode; + } + + frag = parseHTML(node); + } else { + appendChild(frag, node); + + if (endNode) { + appendChild(frag, base.selectedRange().extractContents()); + appendChild(frag, endNode); + } + } + + if (!(lastChild = frag.lastChild)) { + return; + } + + while (!isInline(lastChild.lastChild, true)) { + lastChild = lastChild.lastChild; + } + + if (canHaveChildren(lastChild)) { + // Webkit won't allow the cursor to be placed inside an + // empty tag, so add a zero width space to it. + if (!lastChild.lastChild) { + appendChild(lastChild, document.createTextNode('\u200B')); + } + } else { + lastChild = frag; + } + + base.removeMarkers(); + + // Append marks to last child so when restored cursor will be in + // the right place + appendChild(lastChild, _createMarker(startMarker)); + appendChild(lastChild, _createMarker(endMarker)); + + if (returnHtml) { + var div = createElement('div'); + appendChild(div, frag); + + return div.innerHTML; + } + + return frag; + }; + + /** + * The same as insertHTML except with DOM nodes instead + * + * <strong>Warning:</strong> the nodes must belong to the + * document they are being inserted into. Some browsers + * will throw exceptions if they don't. + * + * Returns boolean false on fail + * + * @param {Node} node + * @param {Node} endNode + * @return {false|undefined} + * @function + * @name insertNode + * @memberOf RangeHelper.prototype + */ + base.insertNode = function (node, endNode) { + var first, last, + input = _prepareInput(node, endNode), + range = base.selectedRange(), + parent = range.commonAncestorContainer, + emptyNodes = []; + + if (!input) { + return false; + } + + function removeIfEmpty(node) { + // Only remove empty node if it wasn't already empty + if (node && isEmpty(node) && emptyNodes.indexOf(node) < 0) { + remove(node); + } + } + + if (range.startContainer !== range.endContainer) { + each(parent.childNodes, function (_, node) { + if (isEmpty(node)) { + emptyNodes.push(node); + } + }); + + first = input.firstChild; + last = input.lastChild; + } + + range.deleteContents(); + + // FF allows <br /> to be selected but inserting a node + // into <br /> will cause it not to be displayed so must + // insert before the <br /> in FF. + // 3 = TextNode + if (parent && parent.nodeType !== 3 && !canHaveChildren(parent)) { + insertBefore(input, parent); + } else { + range.insertNode(input); + + // If a node was split or its contents deleted, remove any resulting + // empty tags. For example: + // <p>|test</p><div>test|</div> + // When deleteContents could become: + // <p></p>|<div></div> + // So remove the empty ones + removeIfEmpty(first && first.previousSibling); + removeIfEmpty(last && last.nextSibling); + } + + base.restoreRange(); + }; + + /** + * Clones the selected Range + * + * @return {Range} + * @function + * @name cloneSelected + * @memberOf RangeHelper.prototype + */ + base.cloneSelected = function () { + var range = base.selectedRange(); + + if (range) { + return range.cloneRange(); + } + }; + + /** + * Gets the selected Range + * + * @return {Range} + * @function + * @name selectedRange + * @memberOf RangeHelper.prototype + */ + base.selectedRange = function () { + var range, firstChild, + sel = win.getSelection(); + + if (!sel) { + return; + } + + // When creating a new range, set the start to the first child + // element of the body element to avoid errors in FF. + if (sel.rangeCount <= 0) { + firstChild = doc.body; + while (firstChild.firstChild) { + firstChild = firstChild.firstChild; + } + + range = doc.createRange(); + // Must be setStartBefore otherwise it can cause infinite + // loops with lists in WebKit. See issue 442 + range.setStartBefore(firstChild); + + sel.addRange(range); + } + + if (sel.rangeCount > 0) { + range = sel.getRangeAt(0); + } + + return range; + }; + + /** + * Gets if there is currently a selection + * + * @return {boolean} + * @function + * @name hasSelection + * @since 1.4.4 + * @memberOf RangeHelper.prototype + */ + base.hasSelection = function () { + var sel = win.getSelection(); + + return sel && sel.rangeCount > 0; + }; + + /** + * Gets the currently selected HTML + * + * @return {string} + * @function + * @name selectedHtml + * @memberOf RangeHelper.prototype + */ + base.selectedHtml = function () { + var div, + range = base.selectedRange(); + + if (range) { + div = createElement('p', {}, doc); + appendChild(div, range.cloneContents()); + + return div.innerHTML; + } + + return ''; + }; + + /** + * Gets the parent node of the selected contents in the range + * + * @return {HTMLElement} + * @function + * @name parentNode + * @memberOf RangeHelper.prototype + */ + base.parentNode = function () { + var range = base.selectedRange(); + + if (range) { + return range.commonAncestorContainer; + } + }; + + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @return {HTMLElement} + * @function + * @name getFirstBlockParent + * @memberOf RangeHelper.prototype + */ + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @param {Node} [n] The element to get the first block level parent from + * @return {HTMLElement} + * @function + * @name getFirstBlockParent^2 + * @since 1.4.1 + * @memberOf RangeHelper.prototype + */ + base.getFirstBlockParent = function (node) { + var func = function (elm) { + if (!isInline(elm, true)) { + return elm; + } + + elm = elm ? elm.parentNode : null; + + return elm ? func(elm) : elm; + }; + + return func(node || base.parentNode()); + }; + + /** + * Inserts a node at either the start or end of the current selection + * + * @param {Bool} start + * @param {Node} node + * @function + * @name insertNodeAt + * @memberOf RangeHelper.prototype + */ + base.insertNodeAt = function (start, node) { + var currentRange = base.selectedRange(), + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(start); + range.insertNode(node); + + // Reselect the current range. + // Fixes issue with Chrome losing the selection. Issue#82 + base.selectRange(currentRange); + }; + + /** + * Creates a marker node + * + * @param {string} id + * @return {HTMLSpanElement} + * @private + */ + _createMarker = function (id) { + base.removeMarker(id); + + var marker = createElement('span', { + id: id, + className: 'sceditor-selection sceditor-ignore', + style: 'display:none;line-height:0' + }, doc); + + marker.innerHTML = ' '; + + return marker; + }; + + /** + * Inserts start/end markers for the current selection + * which can be used by restoreRange to re-select the + * range. + * + * @memberOf RangeHelper.prototype + * @function + * @name insertMarkers + */ + base.insertMarkers = function () { + var currentRange = base.selectedRange(); + var startNode = _createMarker(startMarker); + + base.removeMarkers(); + base.insertNodeAt(true, startNode); + + // Fixes issue with end marker sometimes being placed before + // the start marker when the range is collapsed. + if (currentRange && currentRange.collapsed) { + startNode.parentNode.insertBefore( + _createMarker(endMarker), startNode.nextSibling); + } else { + base.insertNodeAt(false, _createMarker(endMarker)); + } + }; + + /** + * Gets the marker with the specified ID + * + * @param {string} id + * @return {Node} + * @function + * @name getMarker + * @memberOf RangeHelper.prototype + */ + base.getMarker = function (id) { + return doc.getElementById(id); + }; + + /** + * Removes the marker with the specified ID + * + * @param {string} id + * @function + * @name removeMarker + * @memberOf RangeHelper.prototype + */ + base.removeMarker = function (id) { + var marker = base.getMarker(id); + + if (marker) { + remove(marker); + } + }; + + /** + * Removes the start/end markers + * + * @function + * @name removeMarkers + * @memberOf RangeHelper.prototype + */ + base.removeMarkers = function () { + base.removeMarker(startMarker); + base.removeMarker(endMarker); + }; + + /** + * Saves the current range location. Alias of insertMarkers() + * + * @function + * @name saveRage + * @memberOf RangeHelper.prototype + */ + base.saveRange = function () { + base.insertMarkers(); + }; + + /** + * Select the specified range + * + * @param {Range} range + * @function + * @name selectRange + * @memberOf RangeHelper.prototype + */ + base.selectRange = function (range) { + var lastChild; + var sel = win.getSelection(); + var container = range.endContainer; + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (range.collapsed && container && + !isInline(container, true)) { + + lastChild = container.lastChild; + while (lastChild && is(lastChild, '.sceditor-ignore')) { + lastChild = lastChild.previousSibling; + } + + if (is(lastChild, 'br')) { + var rng = doc.createRange(); + rng.setEndAfter(lastChild); + rng.collapse(false); + + if (base.compare(range, rng)) { + range.setStartBefore(lastChild); + range.collapse(true); + } + } + } + + if (sel) { + base.clear(); + sel.addRange(range); + } + }; + + /** + * Restores the last range saved by saveRange() or insertMarkers() + * + * @function + * @name restoreRange + * @memberOf RangeHelper.prototype + */ + base.restoreRange = function () { + var isCollapsed, + range = base.selectedRange(), + start = base.getMarker(startMarker), + end = base.getMarker(endMarker); + + if (!start || !end || !range) { + return false; + } + + isCollapsed = start.nextSibling === end; + + range = doc.createRange(); + range.setStartBefore(start); + range.setEndAfter(end); + + if (isCollapsed) { + range.collapse(true); + } + + base.selectRange(range); + base.removeMarkers(); + }; + + /** + * Selects the text left and right of the current selection + * + * @param {number} left + * @param {number} right + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.selectOuterText = function (left, right) { + var start, end, + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(false); + + start = outerText(range, true, left); + end = outerText(range, false, right); + + range.setStart(start.node, start.offset); + range.setEnd(end.node, end.offset); + + base.selectRange(range); + }; + + /** + * Gets the text left or right of the current selection + * + * @param {boolean} before + * @param {number} length + * @return {string} + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.getOuterText = function (before, length) { + var range = base.cloneSelected(); + + if (!range) { + return ''; + } + + range.collapse(!before); + + return outerText(range, before, length).text; + }; + + /** + * Replaces keywords with values based on the current caret position + * + * @param {Array} keywords + * @param {boolean} includeAfter If to include the text after the + * current caret position or just + * text before + * @param {boolean} keywordsSorted If the keywords array is pre + * sorted shortest to longest + * @param {number} longestKeyword Length of the longest keyword + * @param {boolean} requireWhitespace If the key must be surrounded + * by whitespace + * @param {string} keypressChar If this is being called from + * a keypress event, this should be + * set to the pressed character + * @return {boolean} + * @function + * @name replaceKeyword + * @memberOf RangeHelper.prototype + */ + // eslint-disable-next-line max-params + base.replaceKeyword = function ( + keywords, + includeAfter, + keywordsSorted, + longestKeyword, + requireWhitespace, + keypressChar + ) { + if (!keywordsSorted) { + keywords.sort(function (a, b) { + return a[0].length - b[0].length; + }); + } + + var outerText, match, matchPos, startIndex, + leftLen, charsLeft, keyword, keywordLen, + whitespaceRegex = '(^|[\\s\xA0\u2002\u2003\u2009])', + keywordIdx = keywords.length, + whitespaceLen = requireWhitespace ? 1 : 0, + maxKeyLen = longestKeyword || + keywords[keywordIdx - 1][0].length; + + if (requireWhitespace) { + maxKeyLen++; + } + + keypressChar = keypressChar || ''; + outerText = base.getOuterText(true, maxKeyLen); + leftLen = outerText.length; + outerText += keypressChar; + + if (includeAfter) { + outerText += base.getOuterText(false, maxKeyLen); + } + + while (keywordIdx--) { + keyword = keywords[keywordIdx][0]; + keywordLen = keyword.length; + startIndex = Math.max(0, leftLen - keywordLen - whitespaceLen); + matchPos = -1; + + if (requireWhitespace) { + match = outerText + .substr(startIndex) + .match(new RegExp(whitespaceRegex + + regex(keyword) + whitespaceRegex)); + + if (match) { + // Add the length of the text that was removed by + // substr() and also add 1 for the whitespace + matchPos = match.index + startIndex + match[1].length; + } + } else { + matchPos = outerText.indexOf(keyword, startIndex); + } + + if (matchPos > -1) { + // Make sure the match is between before and + // after, not just entirely in one side or the other + if (matchPos <= leftLen && + matchPos + keywordLen + whitespaceLen >= leftLen) { + charsLeft = leftLen - matchPos; + + // If the keypress char is white space then it should + // not be replaced, only chars that are part of the + // key should be replaced. + base.selectOuterText( + charsLeft, + keywordLen - charsLeft - + (/^\S/.test(keypressChar) ? 1 : 0) + ); + + base.insertHTML(keywords[keywordIdx][1]); + return true; + } + } + } + + return false; + }; + + /** + * Compares two ranges. + * + * If rangeB is undefined it will be set to + * the current selected range + * + * @param {Range} rngA + * @param {Range} [rngB] + * @return {boolean} + * @function + * @name compare + * @memberOf RangeHelper.prototype + */ + base.compare = function (rngA, rngB) { + if (!rngB) { + rngB = base.selectedRange(); + } + + if (!rngA || !rngB) { + return !rngA && !rngB; + } + + return rngA.compareBoundaryPoints(Range.END_TO_END, rngB) === 0 && + rngA.compareBoundaryPoints(Range.START_TO_START, rngB) === 0; + }; + + /** + * Removes any current selection + * + * @since 1.4.6 + * @function + * @name clear + * @memberOf RangeHelper.prototype + */ + base.clear = function () { + var sel = win.getSelection(); + + if (sel) { + if (sel.removeAllRanges) { + sel.removeAllRanges(); + } else if (sel.empty) { + sel.empty(); + } + } + }; + } + + var USER_AGENT = navigator.userAgent; + + /** + * Detects if the browser is iOS + * + * Needed to fix iOS specific bugs + * + * @function + * @name ios + * @memberOf jQuery.sceditor + * @type {boolean} + */ + var ios = /iPhone|iPod|iPad| wosbrowser\//i.test(USER_AGENT); + + /** + * If the browser supports WYSIWYG editing (e.g. older mobile browsers). + * + * @function + * @name isWysiwygSupported + * @return {boolean} + */ + var isWysiwygSupported = (function () { + var match, isUnsupported; + + // IE is the only browser to support documentMode + var ie = !!window.document.documentMode; + var legacyEdge = '-ms-ime-align' in document.documentElement.style; + + var div = document.createElement('div'); + div.contentEditable = true; + + // Check if the contentEditable attribute is supported + if (!('contentEditable' in document.documentElement) || + div.contentEditable !== 'true') { + return false; + } + + // I think blackberry supports contentEditable or will at least + // give a valid value for the contentEditable detection above + // so it isn't included in the below tests. + + // I hate having to do UA sniffing but some mobile browsers say they + // support contentediable when it isn't usable, i.e. you can't enter + // text. + // This is the only way I can think of to detect them which is also how + // every other editor I've seen deals with this issue. + + // Exclude Opera mobile and mini + isUnsupported = /Opera Mobi|Opera Mini/i.test(USER_AGENT); + + if (/Android/i.test(USER_AGENT)) { + isUnsupported = true; + + if (/Safari/.test(USER_AGENT)) { + // Android browser 534+ supports content editable + // This also matches Chrome which supports content editable too + match = /Safari\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + } + + // The current version of Amazon Silk supports it, older versions didn't + // As it uses webkit like Android, assume it's the same and started + // working at versions >= 534 + if (/ Silk\//i.test(USER_AGENT)) { + match = /AppleWebKit\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + + // iOS 5+ supports content editable + if (ios) { + // Block any version <= 4_x(_x) + isUnsupported = /OS [0-4](_\d)+ like Mac/i.test(USER_AGENT); + } + + // Firefox does support WYSIWYG on mobiles so override + // any previous value if using FF + if (/Firefox/i.test(USER_AGENT)) { + isUnsupported = false; + } + + if (/OneBrowser/i.test(USER_AGENT)) { + isUnsupported = false; + } + + // UCBrowser works but doesn't give a unique user agent + if (navigator.vendor === 'UCWEB') { + isUnsupported = false; + } + + // IE and legacy edge are not supported any more + if (ie || legacyEdge) { + isUnsupported = true; + } + + return !isUnsupported; + }()); + + /** + * Checks all emoticons are surrounded by whitespace and + * replaces any that aren't with with their emoticon code. + * + * @param {HTMLElement} node + * @param {rangeHelper} rangeHelper + * @return {void} + */ + function checkWhitespace(node, rangeHelper) { + var noneWsRegex = /[^\s\xA0\u2002\u2003\u2009]+/; + var emoticons = node && find(node, 'img[data-sceditor-emoticon]'); + + if (!node || !emoticons.length) { + return; + } + + for (var i = 0; i < emoticons.length; i++) { + var emoticon = emoticons[i]; + var parent = emoticon.parentNode; + var prev = emoticon.previousSibling; + var next = emoticon.nextSibling; + + if ((!prev || !noneWsRegex.test(prev.nodeValue.slice(-1))) && + (!next || !noneWsRegex.test((next.nodeValue || '')[0]))) { + continue; + } + + var range = rangeHelper.cloneSelected(); + var rangeStart = -1; + var rangeStartContainer = range.startContainer; + var previousText = prev.nodeValue || ''; + + previousText += data(emoticon, 'sceditor-emoticon'); + + // If the cursor is after the removed emoticon, add + // the length of the newly added text to it + if (rangeStartContainer === next) { + rangeStart = previousText.length + range.startOffset; + } + + // If the cursor is set before the next node, set it to + // the end of the new text node + if (rangeStartContainer === node && + node.childNodes[range.startOffset] === next) { + rangeStart = previousText.length; + } + + // If the cursor is set before the removed emoticon, + // just keep it at that position + if (rangeStartContainer === prev) { + rangeStart = range.startOffset; + } + + if (!next || next.nodeType !== TEXT_NODE) { + next = parent.insertBefore( + parent.ownerDocument.createTextNode(''), next + ); + } + + next.insertData(0, previousText); + remove(prev); + remove(emoticon); + + // Need to update the range starting position if it's been modified + if (rangeStart > -1) { + range.setStart(next, rangeStart); + range.collapse(true); + rangeHelper.selectRange(range); + } + } + } + /** + * Replaces any emoticons inside the root node with images. + * + * emoticons should be an object where the key is the emoticon + * code and the value is the HTML to replace it with. + * + * @param {HTMLElement} root + * @param {Object<string, string>} emoticons + * @param {boolean} emoticonsCompat + * @return {void} + */ + function replace(root, emoticons, emoticonsCompat) { + var doc = root.ownerDocument; + var space = '(^|\\s|\xA0|\u2002|\u2003|\u2009|$)'; + var emoticonCodes = []; + var emoticonRegex = {}; + + // TODO: Make this tag configurable. + if (parent(root, 'code')) { + return; + } + + each(emoticons, function (key) { + emoticonRegex[key] = new RegExp(space + regex(key) + space); + emoticonCodes.push(key); + }); + + // Sort keys longest to shortest so that longer keys + // take precedence (avoids bugs with shorter keys partially + // matching longer ones) + emoticonCodes.sort(function (a, b) { + return b.length - a.length; + }); + + (function convert(node) { + node = node.firstChild; + + while (node) { + // TODO: Make this tag configurable. + if (node.nodeType === ELEMENT_NODE && !is(node, 'code')) { + convert(node); + } + + if (node.nodeType === TEXT_NODE) { + for (var i = 0; i < emoticonCodes.length; i++) { + var text = node.nodeValue; + var key = emoticonCodes[i]; + var index = emoticonsCompat ? + text.search(emoticonRegex[key]) : + text.indexOf(key); + + if (index > -1) { + // When emoticonsCompat is enabled this will be the + // position after any white space + var startIndex = text.indexOf(key, index); + var fragment = parseHTML(emoticons[key], doc); + var after = text.substr(startIndex + key.length); + + fragment.appendChild(doc.createTextNode(after)); + + node.nodeValue = text.substr(0, startIndex); + node.parentNode + .insertBefore(fragment, node.nextSibling); + } + } + } + + node = node.nextSibling; + } + }(root)); + } + + /*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */ + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var hasOwnProperty = Object.hasOwnProperty, + setPrototypeOf = Object.setPrototypeOf, + isFrozen = Object.isFrozen, + getPrototypeOf = Object.getPrototypeOf, + getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var freeze = Object.freeze, + seal = Object.seal, + create = Object.create; // eslint-disable-line import/no-mutable-exports + + var _ref = typeof Reflect !== 'undefined' && Reflect, + apply = _ref.apply, + construct = _ref.construct; + + if (!apply) { + apply = function apply(fun, thisValue, args) { + return fun.apply(thisValue, args); + }; + } + + if (!freeze) { + freeze = function freeze(x) { + return x; + }; + } + + if (!seal) { + seal = function seal(x) { + return x; + }; + } + + if (!construct) { + construct = function construct(Func, args) { + return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); + }; + } + + var arrayForEach = unapply(Array.prototype.forEach); + var arrayPop = unapply(Array.prototype.pop); + var arrayPush = unapply(Array.prototype.push); + + var stringToLowerCase = unapply(String.prototype.toLowerCase); + var stringMatch = unapply(String.prototype.match); + var stringReplace = unapply(String.prototype.replace); + var stringIndexOf = unapply(String.prototype.indexOf); + var stringTrim = unapply(String.prototype.trim); + + var regExpTest = unapply(RegExp.prototype.test); + + var typeErrorCreate = unconstruct(TypeError); + + function unapply(func) { + return function (thisArg) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return apply(func, thisArg, args); + }; + } + + function unconstruct(func) { + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return construct(func, args); + }; + } + + /* Add properties to a lookup table */ + function addToSet(set, array) { + if (setPrototypeOf) { + // Make 'in' and truthy checks like Boolean(set.constructor) + // independent of any properties defined on Object.prototype. + // Prevent prototype setters from intercepting set as a this value. + setPrototypeOf(set, null); + } + + var l = array.length; + while (l--) { + var element = array[l]; + if (typeof element === 'string') { + var lcElement = stringToLowerCase(element); + if (lcElement !== element) { + // Config presets (e.g. tags.js, attrs.js) are immutable. + if (!isFrozen(array)) { + array[l] = lcElement; + } + + element = lcElement; + } + } + + set[element] = true; + } + + return set; + } + + /* Shallow clone an object */ + function clone(object) { + var newObject = create(null); + + var property = void 0; + for (property in object) { + if (apply(hasOwnProperty, object, [property])) { + newObject[property] = object[property]; + } + } + + return newObject; + } + + /* IE10 doesn't support __lookupGetter__ so lets' + * simulate it. It also automatically checks + * if the prop is function or getter and behaves + * accordingly. */ + function lookupGetter(object, prop) { + while (object !== null) { + var desc = getOwnPropertyDescriptor(object, prop); + if (desc) { + if (desc.get) { + return unapply(desc.get); + } + + if (typeof desc.value === 'function') { + return unapply(desc.value); + } + } + + object = getPrototypeOf(object); + } + + return null; + } + + var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); + + // SVG + var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); + + var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); + + // List of SVG elements that are disallowed by default. + // We still need to know them so that we can do namespace + // checks properly in case one wants to add them to + // allow-list. + var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); + + var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']); + + // Similarly to SVG, we want to know all MathML elements, + // even those that we disallow by default. + var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); + + var text = freeze(['#text']); + + var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns']); + + var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); + + var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); + + var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); + + // eslint-disable-next-line unicorn/better-regex + var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode + var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); + var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape + var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape + var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape + ); + var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); + var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex + ); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var getGlobal = function getGlobal() { + return typeof window === 'undefined' ? null : window; + }; + + /** + * Creates a no-op policy for internal use only. + * Don't export this function outside this module! + * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory. + * @param {Document} document The document object (to determine policy name suffix) + * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types + * are not supported). + */ + var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { + if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { + return null; + } + + // Allow the callers to control the unique policy name + // by adding a data-tt-policy-suffix to the script element with the DOMPurify. + // Policy creation with duplicate names throws in Trusted Types. + var suffix = null; + var ATTR_NAME = 'data-tt-policy-suffix'; + if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { + suffix = document.currentScript.getAttribute(ATTR_NAME); + } + + var policyName = 'dompurify' + (suffix ? '#' + suffix : ''); + + try { + return trustedTypes.createPolicy(policyName, { + createHTML: function createHTML(html$$1) { + return html$$1; + } + }); + } catch (_) { + // Policy creation failed (most likely another DOMPurify script has + // already run). Skip creating the policy, as this will only cause errors + // if TT are enforced. + console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); + return null; + } + }; + + function createDOMPurify() { + var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); + + var DOMPurify = function DOMPurify(root) { + return createDOMPurify(root); + }; + + /** + * Version label, exposed for easier checks + * if DOMPurify is up to date or not + */ + DOMPurify.version = '2.2.6'; + + /** + * Array of elements that DOMPurify removed during sanitation. + * Empty if nothing was removed. + */ + DOMPurify.removed = []; + + if (!window || !window.document || window.document.nodeType !== 9) { + // Not running in a browser, provide a factory function + // so that you can pass your own Window + DOMPurify.isSupported = false; + + return DOMPurify; + } + + var originalDocument = window.document; + + var document = window.document; + var DocumentFragment = window.DocumentFragment, + HTMLTemplateElement = window.HTMLTemplateElement, + Node = window.Node, + Element = window.Element, + NodeFilter = window.NodeFilter, + _window$NamedNodeMap = window.NamedNodeMap, + NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, + Text = window.Text, + Comment = window.Comment, + DOMParser = window.DOMParser, + trustedTypes = window.trustedTypes; + + + var ElementPrototype = Element.prototype; + + var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); + var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); + var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); + + // As per issue #47, the web-components registry is inherited by a + // new document created via createHTMLDocument. As per the spec + // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) + // a new empty registry is used when creating a template contents owner + // document, so we use that as our parent document to ensure nothing + // is inherited. + if (typeof HTMLTemplateElement === 'function') { + var template = document.createElement('template'); + if (template.content && template.content.ownerDocument) { + document = template.content.ownerDocument; + } + } + + var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); + var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : ''; + + var _document = document, + implementation = _document.implementation, + createNodeIterator = _document.createNodeIterator, + getElementsByTagName = _document.getElementsByTagName, + createDocumentFragment = _document.createDocumentFragment; + var importNode = originalDocument.importNode; + + + var documentMode = {}; + try { + documentMode = clone(document).documentMode ? document.documentMode : {}; + } catch (_) {} + + var hooks = {}; + + /** + * Expose whether this browser supports running the full DOMPurify. + */ + DOMPurify.isSupported = implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; + + var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, + ERB_EXPR$$1 = ERB_EXPR, + DATA_ATTR$$1 = DATA_ATTR, + ARIA_ATTR$$1 = ARIA_ATTR, + IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; + var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; + + /** + * We consider the elements and attributes below to be safe. Ideally + * don't add any new ones but feel free to remove unwanted ones. + */ + + /* allowed element names */ + + var ALLOWED_TAGS = null; + var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); + + /* Allowed attribute names */ + var ALLOWED_ATTR = null; + var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); + + /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ + var FORBID_TAGS = null; + + /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ + var FORBID_ATTR = null; + + /* Decide if ARIA attributes are okay */ + var ALLOW_ARIA_ATTR = true; + + /* Decide if custom data attributes are okay */ + var ALLOW_DATA_ATTR = true; + + /* Decide if unknown protocols are okay */ + var ALLOW_UNKNOWN_PROTOCOLS = false; + + /* Output should be safe for common template engines. + * This means, DOMPurify removes data attributes, mustaches and ERB + */ + var SAFE_FOR_TEMPLATES = false; + + /* Decide if document with <html>... should be returned */ + var WHOLE_DOCUMENT = false; + + /* Track whether config is already set on this instance of DOMPurify. */ + var SET_CONFIG = false; + + /* Decide if all elements (e.g. style, script) must be children of + * document.body. By default, browsers might move them to document.head */ + var FORCE_BODY = false; + + /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported). + * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead + */ + var RETURN_DOM = false; + + /* Decide if a DOM `DocumentFragment` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported) */ + var RETURN_DOM_FRAGMENT = false; + + /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM + * `Node` is imported into the current `Document`. If this flag is not enabled the + * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by + * DOMPurify. + * + * This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false` + * might cause XSS from attacks hidden in closed shadowroots in case the browser + * supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/ + */ + var RETURN_DOM_IMPORT = true; + + /* Try to return a Trusted Type object instead of a string, return a string in + * case Trusted Types are not supported */ + var RETURN_TRUSTED_TYPE = false; + + /* Output should be free from DOM clobbering attacks? */ + var SANITIZE_DOM = true; + + /* Keep element content when removing element? */ + var KEEP_CONTENT = true; + + /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead + * of importing it into a new Document and returning a sanitized copy */ + var IN_PLACE = false; + + /* Allow usage of profiles like html, svg and mathMl */ + var USE_PROFILES = {}; + + /* Tags to ignore content of when KEEP_CONTENT is true */ + var FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); + + /* Tags that are safe for data: URIs */ + var DATA_URI_TAGS = null; + var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); + + /* Attributes safe for values like "javascript:" */ + var URI_SAFE_ATTRIBUTES = null; + var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'summary', 'title', 'value', 'style', 'xmlns']); + + /* Keep a reference to config to pass to hooks */ + var CONFIG = null; + + /* Ideally, do not touch anything below this line */ + /* ______________________________________________ */ + + var formElement = document.createElement('form'); + + /** + * _parseConfig + * + * @param {Object} cfg optional config literal + */ + // eslint-disable-next-line complexity + var _parseConfig = function _parseConfig(cfg) { + if (CONFIG && CONFIG === cfg) { + return; + } + + /* Shield configuration object from tampering */ + if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { + cfg = {}; + } + + /* Shield configuration object from prototype pollution */ + cfg = clone(cfg); + + /* Set configuration parameters */ + ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; + ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; + URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES; + DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS; + FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {}; + FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {}; + USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false; + ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true + ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true + ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false + SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false + WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false + RETURN_DOM = cfg.RETURN_DOM || false; // Default false + RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false + RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true + RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false + FORCE_BODY = cfg.FORCE_BODY || false; // Default false + SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true + KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true + IN_PLACE = cfg.IN_PLACE || false; // Default false + IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; + if (SAFE_FOR_TEMPLATES) { + ALLOW_DATA_ATTR = false; + } + + if (RETURN_DOM_FRAGMENT) { + RETURN_DOM = true; + } + + /* Parse profile info */ + if (USE_PROFILES) { + ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); + ALLOWED_ATTR = []; + if (USE_PROFILES.html === true) { + addToSet(ALLOWED_TAGS, html); + addToSet(ALLOWED_ATTR, html$1); + } + + if (USE_PROFILES.svg === true) { + addToSet(ALLOWED_TAGS, svg); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.svgFilters === true) { + addToSet(ALLOWED_TAGS, svgFilters); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.mathMl === true) { + addToSet(ALLOWED_TAGS, mathMl); + addToSet(ALLOWED_ATTR, mathMl$1); + addToSet(ALLOWED_ATTR, xml); + } + } + + /* Merge configuration parameters */ + if (cfg.ADD_TAGS) { + if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { + ALLOWED_TAGS = clone(ALLOWED_TAGS); + } + + addToSet(ALLOWED_TAGS, cfg.ADD_TAGS); + } + + if (cfg.ADD_ATTR) { + if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { + ALLOWED_ATTR = clone(ALLOWED_ATTR); + } + + addToSet(ALLOWED_ATTR, cfg.ADD_ATTR); + } + + if (cfg.ADD_URI_SAFE_ATTR) { + addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR); + } + + /* Add #text in case KEEP_CONTENT is set to true */ + if (KEEP_CONTENT) { + ALLOWED_TAGS['#text'] = true; + } + + /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ + if (WHOLE_DOCUMENT) { + addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); + } + + /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ + if (ALLOWED_TAGS.table) { + addToSet(ALLOWED_TAGS, ['tbody']); + delete FORBID_TAGS.tbody; + } + + // Prevent further manipulation of configuration. + // Not available in IE8, Safari 5, etc. + if (freeze) { + freeze(cfg); + } + + CONFIG = cfg; + }; + + var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); + + var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); + + /* Keep track of all possible SVG and MathML tags + * so that we can perform the namespace checks + * correctly. */ + var ALL_SVG_TAGS = addToSet({}, svg); + addToSet(ALL_SVG_TAGS, svgFilters); + addToSet(ALL_SVG_TAGS, svgDisallowed); + + var ALL_MATHML_TAGS = addToSet({}, mathMl); + addToSet(ALL_MATHML_TAGS, mathMlDisallowed); + + var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + + /** + * + * + * @param {Element} element a DOM element whose namespace is being checked + * @returns {boolean} Return false if the element has a + * namespace that a spec-compliant parser would never + * return. Return true otherwise. + */ + var _checkValidNamespace = function _checkValidNamespace(element) { + var parent = getParentNode(element); + + // In JSDOM, if we're inside shadow DOM, then parentNode + // can be null. We just simulate parent in this case. + if (!parent || !parent.tagName) { + parent = { + namespaceURI: HTML_NAMESPACE, + tagName: 'template' + }; + } + + var tagName = stringToLowerCase(element.tagName); + var parentTagName = stringToLowerCase(parent.tagName); + + if (element.namespaceURI === SVG_NAMESPACE) { + // The only way to switch from HTML namespace to SVG + // is via <svg>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'svg'; + } + + // The only way to switch from MathML to SVG is via + // svg if parent is either <annotation-xml> or MathML + // text integration points. + if (parent.namespaceURI === MATHML_NAMESPACE) { + return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); + } + + // We only allow elements that are defined in SVG + // spec. All others are disallowed in SVG namespace. + return Boolean(ALL_SVG_TAGS[tagName]); + } + + if (element.namespaceURI === MATHML_NAMESPACE) { + // The only way to switch from HTML namespace to MathML + // is via <math>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'math'; + } + + // The only way to switch from SVG to MathML is via + // <math> and HTML integration points + if (parent.namespaceURI === SVG_NAMESPACE) { + return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; + } + + // We only allow elements that are defined in MathML + // spec. All others are disallowed in MathML namespace. + return Boolean(ALL_MATHML_TAGS[tagName]); + } + + if (element.namespaceURI === HTML_NAMESPACE) { + // The only way to switch from SVG to HTML is via + // HTML integration points, and from MathML to HTML + // is via MathML text integration points + if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + // Certain elements are allowed in both SVG and HTML + // namespace. We need to specify them explicitly + // so that they don't get erronously deleted from + // HTML namespace. + var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); + + // We disallow tags that are specific for MathML + // or SVG and should never appear in HTML namespace + return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); + } + + // The code should never reach this place (this means + // that the element somehow got namespace that is not + // HTML, SVG or MathML). Return false just in case. + return false; + }; + + /** + * _forceRemove + * + * @param {Node} node a DOM node + */ + var _forceRemove = function _forceRemove(node) { + arrayPush(DOMPurify.removed, { element: node }); + try { + node.parentNode.removeChild(node); + } catch (_) { + try { + node.outerHTML = emptyHTML; + } catch (_) { + node.remove(); + } + } + }; + + /** + * _removeAttribute + * + * @param {String} name an Attribute name + * @param {Node} node a DOM node + */ + var _removeAttribute = function _removeAttribute(name, node) { + try { + arrayPush(DOMPurify.removed, { + attribute: node.getAttributeNode(name), + from: node + }); + } catch (_) { + arrayPush(DOMPurify.removed, { + attribute: null, + from: node + }); + } + + node.removeAttribute(name); + }; + + /** + * _initDocument + * + * @param {String} dirty a string of dirty markup + * @return {Document} a DOM, filled with the dirty markup + */ + var _initDocument = function _initDocument(dirty) { + /* Create a HTML document */ + var doc = void 0; + var leadingWhitespace = void 0; + + if (FORCE_BODY) { + dirty = '<remove></remove>' + dirty; + } else { + /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ + var matches = stringMatch(dirty, /^[\r\n\t ]+/); + leadingWhitespace = matches && matches[0]; + } + + var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; + /* Use the DOMParser API by default, fallback later if needs be */ + try { + doc = new DOMParser().parseFromString(dirtyPayload, 'text/html'); + } catch (_) {} + + /* Use createHTMLDocument in case DOMParser is not available */ + if (!doc || !doc.documentElement) { + doc = implementation.createHTMLDocument(''); + var _doc = doc, + body = _doc.body; + + body.parentNode.removeChild(body.parentNode.firstElementChild); + body.outerHTML = dirtyPayload; + } + + if (dirty && leadingWhitespace) { + doc.body.insertBefore(document.createTextNode(leadingWhitespace), doc.body.childNodes[0] || null); + } + + /* Work on whole document or just its body */ + return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; + }; + + /** + * _createIterator + * + * @param {Document} root document/fragment to create iterator for + * @return {Iterator} iterator instance + */ + var _createIterator = function _createIterator(root) { + return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, function () { + return NodeFilter.FILTER_ACCEPT; + }, false); + }; + + /** + * _isClobbered + * + * @param {Node} elm element to check for clobbering attacks + * @return {Boolean} true if clobbered, false if safe + */ + var _isClobbered = function _isClobbered(elm) { + if (elm instanceof Text || elm instanceof Comment) { + return false; + } + + if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') { + return true; + } + + return false; + }; + + /** + * _isNode + * + * @param {Node} obj object to check whether it's a DOM node + * @return {Boolean} true is object is a DOM node + */ + var _isNode = function _isNode(object) { + return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; + }; + + /** + * _executeHook + * Execute user configurable hooks + * + * @param {String} entryPoint Name of the hook's entry point + * @param {Node} currentNode node to work on with the hook + * @param {Object} data additional hook parameters + */ + var _executeHook = function _executeHook(entryPoint, currentNode, data) { + if (!hooks[entryPoint]) { + return; + } + + arrayForEach(hooks[entryPoint], function (hook) { + hook.call(DOMPurify, currentNode, data, CONFIG); + }); + }; + + /** + * _sanitizeElements + * + * @protect nodeName + * @protect textContent + * @protect removeChild + * + * @param {Node} currentNode to check for permission to exist + * @return {Boolean} true if node was killed, false if left alive + */ + var _sanitizeElements = function _sanitizeElements(currentNode) { + var content = void 0; + + /* Execute a hook if present */ + _executeHook('beforeSanitizeElements', currentNode, null); + + /* Check if element is clobbered or can clobber */ + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Check if tagname contains Unicode */ + if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { + _forceRemove(currentNode); + return true; + } + + /* Now let's check the element's type and name */ + var tagName = stringToLowerCase(currentNode.nodeName); + + /* Execute a hook if present */ + _executeHook('uponSanitizeElement', currentNode, { + tagName: tagName, + allowedTags: ALLOWED_TAGS + }); + + /* Detect mXSS attempts abusing namespace confusion */ + if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { + _forceRemove(currentNode); + return true; + } + + /* Remove element if anything forbids its presence */ + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + /* Keep content except for bad-listed elements */ + if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { + var parentNode = getParentNode(currentNode); + var childNodes = getChildNodes(currentNode); + var childCount = childNodes.length; + for (var i = childCount - 1; i >= 0; --i) { + parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode)); + } + } + + _forceRemove(currentNode); + return true; + } + + /* Check whether element has a valid namespace */ + if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { + _forceRemove(currentNode); + return true; + } + + if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) { + _forceRemove(currentNode); + return true; + } + + /* Sanitize element content to be template-safe */ + if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { + /* Get the element's text content */ + content = currentNode.textContent; + content = stringReplace(content, MUSTACHE_EXPR$$1, ' '); + content = stringReplace(content, ERB_EXPR$$1, ' '); + if (currentNode.textContent !== content) { + arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); + currentNode.textContent = content; + } + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeElements', currentNode, null); + + return false; + }; + + /** + * _isValidAttribute + * + * @param {string} lcTag Lowercase tag name of containing element. + * @param {string} lcName Lowercase attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid, otherwise false. + */ + // eslint-disable-next-line complexity + var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { + /* Make sure attribute cannot clobber */ + if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { + return false; + } + + /* Allow valid data-* attributes: At least one character after "-" + (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) + XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) + We don't need to check the value; it's always URI safe. */ + if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { + return false; + + /* Check value is safe. First, is attr inert? If so, is safe */ + } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else { + return false; + } + + return true; + }; + + /** + * _sanitizeAttributes + * + * @protect attributes + * @protect nodeName + * @protect removeAttribute + * @protect setAttribute + * + * @param {Node} currentNode to sanitize + */ + var _sanitizeAttributes = function _sanitizeAttributes(currentNode) { + var attr = void 0; + var value = void 0; + var lcName = void 0; + var l = void 0; + /* Execute a hook if present */ + _executeHook('beforeSanitizeAttributes', currentNode, null); + + var attributes = currentNode.attributes; + + /* Check if we have attributes; if not we might have a text node */ + + if (!attributes) { + return; + } + + var hookEvent = { + attrName: '', + attrValue: '', + keepAttr: true, + allowedAttributes: ALLOWED_ATTR + }; + l = attributes.length; + + /* Go backwards over all attributes; safely remove bad ones */ + while (l--) { + attr = attributes[l]; + var _attr = attr, + name = _attr.name, + namespaceURI = _attr.namespaceURI; + + value = stringTrim(attr.value); + lcName = stringToLowerCase(name); + + /* Execute a hook if present */ + hookEvent.attrName = lcName; + hookEvent.attrValue = value; + hookEvent.keepAttr = true; + hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set + _executeHook('uponSanitizeAttribute', currentNode, hookEvent); + value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ + if (hookEvent.forceKeepAttr) { + continue; + } + + /* Remove attribute */ + _removeAttribute(name, currentNode); + + /* Did the hooks approve of the attribute? */ + if (!hookEvent.keepAttr) { + continue; + } + + /* Work around a security issue in jQuery 3.0 */ + if (regExpTest(/\/>/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Sanitize attribute content to be template-safe */ + if (SAFE_FOR_TEMPLATES) { + value = stringReplace(value, MUSTACHE_EXPR$$1, ' '); + value = stringReplace(value, ERB_EXPR$$1, ' '); + } + + /* Is `value` valid for this attribute? */ + var lcTag = currentNode.nodeName.toLowerCase(); + if (!_isValidAttribute(lcTag, lcName, value)) { + continue; + } + + /* Handle invalid data-* attribute set by try-catching it */ + try { + if (namespaceURI) { + currentNode.setAttributeNS(namespaceURI, name, value); + } else { + /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ + currentNode.setAttribute(name, value); + } + + arrayPop(DOMPurify.removed); + } catch (_) {} + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeAttributes', currentNode, null); + }; + + /** + * _sanitizeShadowDOM + * + * @param {DocumentFragment} fragment to iterate over recursively + */ + var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { + var shadowNode = void 0; + var shadowIterator = _createIterator(fragment); + + /* Execute a hook if present */ + _executeHook('beforeSanitizeShadowDOM', fragment, null); + + while (shadowNode = shadowIterator.nextNode()) { + /* Execute a hook if present */ + _executeHook('uponSanitizeShadowNode', shadowNode, null); + + /* Sanitize tags and elements */ + if (_sanitizeElements(shadowNode)) { + continue; + } + + /* Deep shadow DOM detected */ + if (shadowNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(shadowNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(shadowNode); + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeShadowDOM', fragment, null); + }; + + /** + * Sanitize + * Public method providing core sanitation functionality + * + * @param {String|Node} dirty string or DOM node + * @param {Object} configuration object + */ + // eslint-disable-next-line complexity + DOMPurify.sanitize = function (dirty, cfg) { + var body = void 0; + var importedNode = void 0; + var currentNode = void 0; + var oldNode = void 0; + var returnNode = void 0; + /* Make sure we have a string to sanitize. + DO NOT return early, as this will return the wrong type if + the user has requested a DOM object rather than a string */ + if (!dirty) { + dirty = '<!-->'; + } + + /* Stringify, in case dirty is an object */ + if (typeof dirty !== 'string' && !_isNode(dirty)) { + // eslint-disable-next-line no-negated-condition + if (typeof dirty.toString !== 'function') { + throw typeErrorCreate('toString is not a function'); + } else { + dirty = dirty.toString(); + if (typeof dirty !== 'string') { + throw typeErrorCreate('dirty is not a string, aborting'); + } + } + } + + /* Check we can run. Otherwise fall back or ignore */ + if (!DOMPurify.isSupported) { + if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') { + if (typeof dirty === 'string') { + return window.toStaticHTML(dirty); + } + + if (_isNode(dirty)) { + return window.toStaticHTML(dirty.outerHTML); + } + } + + return dirty; + } + + /* Assign config vars */ + if (!SET_CONFIG) { + _parseConfig(cfg); + } + + /* Clean up removed elements */ + DOMPurify.removed = []; + + /* Check if dirty is correctly typed for IN_PLACE */ + if (typeof dirty === 'string') { + IN_PLACE = false; + } + + if (IN_PLACE) ; else if (dirty instanceof Node) { + /* If dirty is a DOM element, append to an empty document to avoid + elements being stripped by the parser */ + body = _initDocument('<!---->'); + importedNode = body.ownerDocument.importNode(dirty, true); + if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') { + /* Node is already a body, use as is */ + body = importedNode; + } else if (importedNode.nodeName === 'HTML') { + body = importedNode; + } else { + // eslint-disable-next-line unicorn/prefer-node-append + body.appendChild(importedNode); + } + } else { + /* Exit directly if we have nothing to do */ + if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && + // eslint-disable-next-line unicorn/prefer-includes + dirty.indexOf('<') === -1) { + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; + } + + /* Initialize the document to work on */ + body = _initDocument(dirty); + + /* Check we have a DOM node from the data */ + if (!body) { + return RETURN_DOM ? null : emptyHTML; + } + } + + /* Remove first element node (ours) if FORCE_BODY is set */ + if (body && FORCE_BODY) { + _forceRemove(body.firstChild); + } + + /* Get node iterator */ + var nodeIterator = _createIterator(IN_PLACE ? dirty : body); + + /* Now start iterating over the created document */ + while (currentNode = nodeIterator.nextNode()) { + /* Fix IE's strange behavior with manipulated textNodes #89 */ + if (currentNode.nodeType === 3 && currentNode === oldNode) { + continue; + } + + /* Sanitize tags and elements */ + if (_sanitizeElements(currentNode)) { + continue; + } + + /* Shadow DOM detected, sanitize it */ + if (currentNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(currentNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(currentNode); + + oldNode = currentNode; + } + + oldNode = null; + + /* If we sanitized `dirty` in-place, return it. */ + if (IN_PLACE) { + return dirty; + } + + /* Return sanitized string or DOM */ + if (RETURN_DOM) { + if (RETURN_DOM_FRAGMENT) { + returnNode = createDocumentFragment.call(body.ownerDocument); + + while (body.firstChild) { + // eslint-disable-next-line unicorn/prefer-node-append + returnNode.appendChild(body.firstChild); + } + } else { + returnNode = body; + } + + if (RETURN_DOM_IMPORT) { + /* + AdoptNode() is not used because internal state is not reset + (e.g. the past names map of a HTMLFormElement), this is safe + in theory but we would rather not risk another attack vector. + The state that is cloned by importNode() is explicitly defined + by the specs. + */ + returnNode = importNode.call(originalDocument, returnNode, true); + } + + return returnNode; + } + + var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; + + /* Sanitize final string template-safe */ + if (SAFE_FOR_TEMPLATES) { + serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' '); + serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' '); + } + + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; + }; + + /** + * Public method to set the configuration once + * setConfig + * + * @param {Object} cfg configuration object + */ + DOMPurify.setConfig = function (cfg) { + _parseConfig(cfg); + SET_CONFIG = true; + }; + + /** + * Public method to remove the configuration + * clearConfig + * + */ + DOMPurify.clearConfig = function () { + CONFIG = null; + SET_CONFIG = false; + }; + + /** + * Public method to check if an attribute value is valid. + * Uses last set config, if any. Otherwise, uses config defaults. + * isValidAttribute + * + * @param {string} tag Tag name of containing element. + * @param {string} attr Attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false. + */ + DOMPurify.isValidAttribute = function (tag, attr, value) { + /* Initialize shared config vars if necessary. */ + if (!CONFIG) { + _parseConfig({}); + } + + var lcTag = stringToLowerCase(tag); + var lcName = stringToLowerCase(attr); + return _isValidAttribute(lcTag, lcName, value); + }; + + /** + * AddHook + * Public method to add DOMPurify hooks + * + * @param {String} entryPoint entry point for the hook to add + * @param {Function} hookFunction function to execute + */ + DOMPurify.addHook = function (entryPoint, hookFunction) { + if (typeof hookFunction !== 'function') { + return; + } + + hooks[entryPoint] = hooks[entryPoint] || []; + arrayPush(hooks[entryPoint], hookFunction); + }; + + /** + * RemoveHook + * Public method to remove a DOMPurify hook at a given entryPoint + * (pops it from the stack of hooks if more are present) + * + * @param {String} entryPoint entry point for the hook to remove + */ + DOMPurify.removeHook = function (entryPoint) { + if (hooks[entryPoint]) { + arrayPop(hooks[entryPoint]); + } + }; + + /** + * RemoveHooks + * Public method to remove all DOMPurify hooks at a given entryPoint + * + * @param {String} entryPoint entry point for the hooks to remove + */ + DOMPurify.removeHooks = function (entryPoint) { + if (hooks[entryPoint]) { + hooks[entryPoint] = []; + } + }; + + /** + * RemoveAllHooks + * Public method to remove all DOMPurify hooks + * + */ + DOMPurify.removeAllHooks = function () { + hooks = {}; + }; + + return DOMPurify; + } + + var purify = createDOMPurify(); + + var globalWin = window; + var globalDoc = document; + + var IMAGE_MIME_REGEX = /^image\/(p?jpe?g|gif|png|bmp)$/i; + + /** + * Wrap inlines that are in the root in paragraphs. + * + * @param {HTMLBodyElement} body + * @param {Document} doc + * @private + */ + function wrapInlines(body, doc) { + var wrapper; + + traverse(body, function (node) { + if (isInline(node, true)) { + // Ignore text nodes unless they contain non-whitespace chars as + // whitespace will be collapsed. + // Ignore sceditor-ignore elements unless wrapping siblings + // Should still wrap both if wrapping siblings. + if (wrapper || node.nodeType === TEXT_NODE ? + /\S/.test(node.nodeValue) : !is(node, '.sceditor-ignore')) { + if (!wrapper) { + wrapper = createElement('p', {}, doc); + insertBefore(wrapper, node); + } + + appendChild(wrapper, node); + } + } else { + wrapper = null; + } + }, false, true); + } + /** + * SCEditor - A lightweight WYSIWYG editor + * + * @param {HTMLTextAreaElement} original The textarea to be converted + * @param {Object} userOptions + * @class SCEditor + * @name SCEditor + */ + function SCEditor(original, userOptions) { + /** + * Alias of this + * + * @private + */ + var base = this; + + /** + * Editor format like BBCode or HTML + */ + var format; + + /** + * The div which contains the editor and toolbar + * + * @type {HTMLDivElement} + * @private + */ + var editorContainer; + + /** + * Map of events handlers bound to this instance. + * + * @type {Object} + * @private + */ + var eventHandlers = {}; + + /** + * The editors toolbar + * + * @type {HTMLDivElement} + * @private + */ + var toolbar; + + /** + * The editors iframe which should be in design mode + * + * @type {HTMLIFrameElement} + * @private + */ + var wysiwygEditor; + + /** + * The editors window + * + * @type {Window} + * @private + */ + var wysiwygWindow; + + /** + * The WYSIWYG editors body element + * + * @type {HTMLBodyElement} + * @private + */ + var wysiwygBody; + + /** + * The WYSIWYG editors document + * + * @type {Document} + * @private + */ + var wysiwygDocument; + + /** + * The editors textarea for viewing source + * + * @type {HTMLTextAreaElement} + * @private + */ + var sourceEditor; + + /** + * The current dropdown + * + * @type {HTMLDivElement} + * @private + */ + var dropdown; + + /** + * If the user is currently composing text via IME + * @type {boolean} + */ + var isComposing; + + /** + * Timer for valueChanged key handler + * @type {number} + */ + var valueChangedKeyUpTimer; + + /** + * The editors locale + * + * @private + */ + var locale; + + /** + * Stores a cache of preloaded images + * + * @private + * @type {Array.<HTMLImageElement>} + */ + var preLoadCache = []; + + /** + * The editors rangeHelper instance + * + * @type {RangeHelper} + * @private + */ + var rangeHelper; + + /** + * An array of button state handlers + * + * @type {Array.<Object>} + * @private + */ + var btnStateHandlers = []; + + /** + * Plugin manager instance + * + * @type {PluginManager} + * @private + */ + var pluginManager; + + /** + * The current node containing the selection/caret + * + * @type {Node} + * @private + */ + var currentNode; + + /** + * The first block level parent of the current node + * + * @type {node} + * @private + */ + var currentBlockNode; + + /** + * The current node selection/caret + * + * @type {Object} + * @private + */ + var currentSelection; + + /** + * Used to make sure only 1 selection changed + * check is called every 100ms. + * + * Helps improve performance as it is checked a lot. + * + * @type {boolean} + * @private + */ + var isSelectionCheckPending; + + /** + * If content is required (equivalent to the HTML5 required attribute) + * + * @type {boolean} + * @private + */ + var isRequired; + + /** + * The inline CSS style element. Will be undefined + * until css() is called for the first time. + * + * @type {HTMLStyleElement} + * @private + */ + var inlineCss; + + /** + * Object containing a list of shortcut handlers + * + * @type {Object} + * @private + */ + var shortcutHandlers = {}; + + /** + * The min and max heights that autoExpand should stay within + * + * @type {Object} + * @private + */ + var autoExpandBounds; + + /** + * Timeout for the autoExpand function to throttle calls + * + * @private + */ + var autoExpandThrottle; + + /** + * Cache of the current toolbar buttons + * + * @type {Object} + * @private + */ + var toolbarButtons = {}; + + /** + * Last scroll position before maximizing so + * it can be restored when finished. + * + * @type {number} + * @private + */ + var maximizeScrollPosition; + + /** + * Stores the contents while a paste is taking place. + * + * Needed to support browsers that lack clipboard API support. + * + * @type {?DocumentFragment} + * @private + */ + var pasteContentFragment; + + /** + * All the emoticons from dropdown, more and hidden combined + * and with the emoticons root set + * + * @type {!Object<string, string>} + * @private + */ + var allEmoticons = {}; + + /** + * Current icon set if any + * + * @type {?Object} + * @private + */ + var icons; + + /** + * Private functions + * @private + */ + var init, + replaceEmoticons, + handleCommand, + initEditor, + initLocale, + initToolBar, + initOptions, + initEvents, + initResize, + initEmoticons, + handlePasteEvt, + handleCutCopyEvt, + handlePasteData, + handleKeyDown, + handleBackSpace, + handleKeyPress, + handleFormReset, + handleMouseDown, + handleComposition, + handleEvent, + handleDocumentClick, + updateToolBar, + updateActiveButtons, + sourceEditorSelectedText, + appendNewLine, + checkSelectionChanged, + checkNodeChanged, + autofocus, + emoticonsKeyPress, + emoticonsCheckWhitespace, + currentStyledBlockNode, + triggerValueChanged, + valueChangedBlur, + valueChangedKeyUp, + autoUpdate, + autoExpand; + + /** + * All the commands supported by the editor + * @name commands + * @memberOf SCEditor.prototype + */ + base.commands = extend(true, {}, (userOptions.commands || defaultCmds)); + + /** + * Options for this editor instance + * @name opts + * @memberOf SCEditor.prototype + */ + var options = base.opts = extend( + true, {}, defaultOptions, userOptions + ); + + // Don't deep extend emoticons (fixes #565) + base.opts.emoticons = userOptions.emoticons || defaultOptions.emoticons; + + if (!Array.isArray(options.allowedIframeUrls)) { + options.allowedIframeUrls = []; + } + options.allowedIframeUrls.push('https://www.youtube-nocookie.com/embed/'); + + // Create new instance of DOMPurify for each editor instance so can + // have different allowed iframe URLs + // eslint-disable-next-line new-cap + var domPurify = purify(); + + // Allow iframes for things like YouTube, see: + // https://github.com/cure53/DOMPurify/issues/340#issuecomment-670758980 + domPurify.addHook('uponSanitizeElement', function (node, data) { + var allowedUrls = options.allowedIframeUrls; + + if (data.tagName === 'iframe') { + var src = attr(node, 'src') || ''; + + for (var i = 0; i < allowedUrls.length; i++) { + var url = allowedUrls[i]; + + if (isString(url) && src.substr(0, url.length) === url) { + return; + } + + // Handle regex + if (url.test && url.test(src)) { + return; + } + } + + // No match so remove + remove(node); + } + }); + + // Convert target attribute into data-sce-target attributes so XHTML format + // can allow them + domPurify.addHook('afterSanitizeAttributes', function (node) { + if ('target' in node) { + attr(node, 'data-sce-target', attr(node, 'target')); + } + + removeAttr(node, 'target'); + }); + + /** + * Sanitize HTML to avoid XSS + * + * @param {string} html + * @return {string} html + * @private + */ + function sanitize(html) { + return domPurify.sanitize(html, { + ADD_TAGS: ['iframe'], + ADD_ATTR: ['allowfullscreen', 'frameborder', 'target'] + }); + } + /** + * Creates the editor iframe and textarea + * @private + */ + init = function () { + original._sceditor = base; + + // Load locale + if (options.locale && options.locale !== 'en') { + initLocale(); + } + + editorContainer = createElement('div', { + className: 'sceditor-container' + }); + + insertBefore(editorContainer, original); + css(editorContainer, 'z-index', options.zIndex); + + isRequired = original.required; + original.required = false; + + var FormatCtor = SCEditor.formats[options.format]; + format = FormatCtor ? new FormatCtor() : {}; + /* + * Plugins should be initialized before the formatters since + * they may wish to add or change formatting handlers and + * since the bbcode format caches its handlers, + * such changes must be done first. + */ + pluginManager = new PluginManager(base); + (options.plugins || '').split(',').forEach(function (plugin) { + pluginManager.register(plugin.trim()); + }); + if ('init' in format) { + format.init.call(base); + } + + // create the editor + initEmoticons(); + initToolBar(); + initEditor(); + initOptions(); + initEvents(); + + // force into source mode if is a browser that can't handle + // full editing + if (!isWysiwygSupported) { + base.toggleSourceMode(); + } + + updateActiveButtons(); + + var loaded = function () { + off(globalWin, 'load', loaded); + + if (options.autofocus) { + autofocus(!!options.autofocusEnd); + } + + autoExpand(); + appendNewLine(); + // TODO: use editor doc and window? + pluginManager.call('ready'); + if ('onReady' in format) { + format.onReady.call(base); + } + }; + on(globalWin, 'load', loaded); + if (globalDoc.readyState === 'complete') { + loaded(); + } + }; + + /** + * Init the locale variable with the specified locale if possible + * @private + * @return void + */ + initLocale = function () { + var lang; + + locale = SCEditor.locale[options.locale]; + + if (!locale) { + lang = options.locale.split('-'); + locale = SCEditor.locale[lang[0]]; + } + + // Locale DateTime format overrides any specified in the options + if (locale && locale.dateFormat) { + options.dateFormat = locale.dateFormat; + } + }; + + /** + * Creates the editor iframe and textarea + * @private + */ + initEditor = function () { + sourceEditor = createElement('textarea'); + wysiwygEditor = createElement('iframe', { + frameborder: 0, + allowfullscreen: true + }); + + /* + * This needs to be done right after they are created because, + * for any reason, the user may not want the value to be tinkered + * by any filters. + */ + if (options.startInSourceMode) { + addClass(editorContainer, 'sourceMode'); + hide(wysiwygEditor); + } else { + addClass(editorContainer, 'wysiwygMode'); + hide(sourceEditor); + } + + if (!options.spellcheck) { + attr(editorContainer, 'spellcheck', 'false'); + } + + if (globalWin.location.protocol === 'https:') { + attr(wysiwygEditor, 'src', 'about:blank'); + } + + // Add the editor to the container + appendChild(editorContainer, wysiwygEditor); + appendChild(editorContainer, sourceEditor); + + // TODO: make this optional somehow + base.dimensions( + options.width || width(original), + options.height || height(original) + ); + + // Add ios to HTML so can apply CSS fix to only it + var className = ios ? ' ios' : ''; + + wysiwygDocument = wysiwygEditor.contentDocument; + wysiwygDocument.open(); + wysiwygDocument.write(_tmpl('html', { + attrs: ' class="' + className + '"', + spellcheck: options.spellcheck ? '' : 'spellcheck="false"', + charset: options.charset, + style: options.style + })); + wysiwygDocument.close(); + + wysiwygBody = wysiwygDocument.body; + wysiwygWindow = wysiwygEditor.contentWindow; + + base.readOnly(!!options.readOnly); + + // iframe overflow fix for iOS + if (ios) { + height(wysiwygBody, '100%'); + on(wysiwygBody, 'touchend', base.focus); + } + + var tabIndex = attr(original, 'tabindex'); + attr(sourceEditor, 'tabindex', tabIndex); + attr(wysiwygEditor, 'tabindex', tabIndex); + + rangeHelper = new RangeHelper(wysiwygWindow, null, sanitize); + + // load any textarea value into the editor + hide(original); + base.val(original.value); + + var placeholder = options.placeholder || + attr(original, 'placeholder'); + + if (placeholder) { + sourceEditor.placeholder = placeholder; + attr(wysiwygBody, 'placeholder', placeholder); + } + }; + + /** + * Initialises options + * @private + */ + initOptions = function () { + // auto-update original textbox on blur if option set to true + if (options.autoUpdate) { + on(wysiwygBody, 'blur', autoUpdate); + on(sourceEditor, 'blur', autoUpdate); + } + + if (options.rtl === null) { + options.rtl = css(sourceEditor, 'direction') === 'rtl'; + } + + base.rtl(!!options.rtl); + + if (options.autoExpand) { + // Need to update when images (or anything else) loads + on(wysiwygBody, 'load', autoExpand, EVENT_CAPTURE); + on(wysiwygBody, 'input keyup', autoExpand); + } + + if (options.resizeEnabled) { + initResize(); + } + + attr(editorContainer, 'id', options.id); + base.emoticons(options.emoticonsEnabled); + }; + + /** + * Initialises events + * @private + */ + initEvents = function () { + var form = original.form; + var compositionEvents = 'compositionstart compositionend'; + var eventsToForward = + 'keydown keyup keypress focus blur contextmenu input'; + var checkSelectionEvents = 'onselectionchange' in wysiwygDocument ? + 'selectionchange' : + 'keyup focus blur contextmenu mouseup touchend click'; + + on(globalDoc, 'click', handleDocumentClick); + + if (form) { + on(form, 'reset', handleFormReset); + on(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + on(window, 'pagehide', base.updateOriginal); + on(window, 'pageshow', handleFormReset); + on(wysiwygBody, 'keypress', handleKeyPress); + on(wysiwygBody, 'keydown', handleKeyDown); + on(wysiwygBody, 'keydown', handleBackSpace); + on(wysiwygBody, 'keyup', appendNewLine); + on(wysiwygBody, 'blur', valueChangedBlur); + on(wysiwygBody, 'keyup', valueChangedKeyUp); + on(wysiwygBody, 'paste', handlePasteEvt); + on(wysiwygBody, 'cut copy', handleCutCopyEvt); + on(wysiwygBody, compositionEvents, handleComposition); + on(wysiwygBody, checkSelectionEvents, checkSelectionChanged); + on(wysiwygBody, eventsToForward, handleEvent); + + if (options.emoticonsCompat && globalWin.getSelection) { + on(wysiwygBody, 'keyup', emoticonsCheckWhitespace); + } + + on(wysiwygBody, 'blur', function () { + if (!base.val()) { + addClass(wysiwygBody, 'placeholder'); + } + }); + + on(wysiwygBody, 'focus', function () { + removeClass(wysiwygBody, 'placeholder'); + }); + + on(sourceEditor, 'blur', valueChangedBlur); + on(sourceEditor, 'keyup', valueChangedKeyUp); + on(sourceEditor, 'keydown', handleKeyDown); + on(sourceEditor, compositionEvents, handleComposition); + on(sourceEditor, eventsToForward, handleEvent); + + on(wysiwygDocument, 'mousedown', handleMouseDown); + on(wysiwygDocument, checkSelectionEvents, checkSelectionChanged); + on(wysiwygDocument, 'keyup', appendNewLine); + + on(editorContainer, 'selectionchanged', checkNodeChanged); + on(editorContainer, 'selectionchanged', updateActiveButtons); + // Custom events to forward + on( + editorContainer, + 'selectionchanged valuechanged nodechanged pasteraw paste', + handleEvent + ); + }; + + /** + * Creates the toolbar and appends it to the container + * @private + */ + initToolBar = function () { + var group, + commands = base.commands, + exclude = (options.toolbarExclude || '').split(','), + groups = options.toolbar.split('|'); + + toolbar = createElement('div', { + className: 'sceditor-toolbar', + unselectable: 'on' + }); + + if (options.icons in SCEditor.icons) { + icons = new SCEditor.icons[options.icons](); + } + + each(groups, function (_, menuItems) { + group = createElement('div', { + className: 'sceditor-group' + }); + + each(menuItems.split(','), function (_, commandName) { + var button, shortcut, + command = commands[commandName]; + + // The commandName must be a valid command and not excluded + if (!command || exclude.indexOf(commandName) > -1) { + return; + } + + shortcut = command.shortcut; + button = _tmpl('toolbarButton', { + name: commandName, + dispName: base._(command.name || + command.tooltip || commandName) + }, true).firstChild; + + if (icons && icons.create) { + var icon = icons.create(commandName); + if (icon) { + insertBefore(icons.create(commandName), + button.firstChild); + addClass(button, 'has-icon'); + } + } + + button._sceTxtMode = !!command.txtExec; + button._sceWysiwygMode = !!command.exec; + toggleClass(button, 'disabled', !command.exec); + on(button, 'click', function (e) { + if (!hasClass(button, 'disabled')) { + handleCommand(button, command); + } + + updateActiveButtons(); + e.preventDefault(); + }); + // Prevent editor losing focus when button clicked + on(button, 'mousedown', function (e) { + base.closeDropDown(); + e.preventDefault(); + }); + + if (command.tooltip) { + attr(button, 'title', + base._(command.tooltip) + + (shortcut ? ' (' + shortcut + ')' : '') + ); + } + + if (shortcut) { + base.addShortcut(shortcut, commandName); + } + + if (command.state) { + btnStateHandlers.push({ + name: commandName, + state: command.state + }); + // exec string commands can be passed to queryCommandState + } else if (isString(command.exec)) { + btnStateHandlers.push({ + name: commandName, + state: command.exec + }); + } + + appendChild(group, button); + toolbarButtons[commandName] = button; + }); + + // Exclude empty groups + if (group.firstChild) { + appendChild(toolbar, group); + } + }); + + // Append the toolbar to the toolbarContainer option if given + appendChild(options.toolbarContainer || editorContainer, toolbar); + }; + + /** + * Creates the resizer. + * @private + */ + initResize = function () { + var minHeight, maxHeight, minWidth, maxWidth, + mouseMoveFunc, mouseUpFunc, + grip = createElement('div', { + className: 'sceditor-grip' + }), + // Cover is used to cover the editor iframe so document + // still gets mouse move events + cover = createElement('div', { + className: 'sceditor-resize-cover' + }), + moveEvents = 'touchmove mousemove', + endEvents = 'touchcancel touchend mouseup', + startX = 0, + startY = 0, + newX = 0, + newY = 0, + startWidth = 0, + startHeight = 0, + origWidth = width(editorContainer), + origHeight = height(editorContainer), + isDragging = false, + rtl = base.rtl(); + + minHeight = options.resizeMinHeight || origHeight / 1.5; + maxHeight = options.resizeMaxHeight || origHeight * 2.5; + minWidth = options.resizeMinWidth || origWidth / 1.25; + maxWidth = options.resizeMaxWidth || origWidth * 1.25; + + mouseMoveFunc = function (e) { + // iOS uses window.event + if (e.type === 'touchmove') { + e = globalWin.event; + newX = e.changedTouches[0].pageX; + newY = e.changedTouches[0].pageY; + } else { + newX = e.pageX; + newY = e.pageY; + } + + var newHeight = startHeight + (newY - startY), + newWidth = rtl ? + startWidth - (newX - startX) : + startWidth + (newX - startX); + + if (maxWidth > 0 && newWidth > maxWidth) { + newWidth = maxWidth; + } + if (minWidth > 0 && newWidth < minWidth) { + newWidth = minWidth; + } + if (!options.resizeWidth) { + newWidth = false; + } + + if (maxHeight > 0 && newHeight > maxHeight) { + newHeight = maxHeight; + } + if (minHeight > 0 && newHeight < minHeight) { + newHeight = minHeight; + } + if (!options.resizeHeight) { + newHeight = false; + } + + if (newWidth || newHeight) { + base.dimensions(newWidth, newHeight); + } + + e.preventDefault(); + }; + + mouseUpFunc = function (e) { + if (!isDragging) { + return; + } + + isDragging = false; + + hide(cover); + removeClass(editorContainer, 'resizing'); + off(globalDoc, moveEvents, mouseMoveFunc); + off(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }; + + if (icons && icons.create) { + var icon = icons.create('grip'); + if (icon) { + appendChild(grip, icon); + addClass(grip, 'has-icon'); + } + } + + appendChild(editorContainer, grip); + appendChild(editorContainer, cover); + hide(cover); + + on(grip, 'touchstart mousedown', function (e) { + // iOS uses window.event + if (e.type === 'touchstart') { + e = globalWin.event; + startX = e.touches[0].pageX; + startY = e.touches[0].pageY; + } else { + startX = e.pageX; + startY = e.pageY; + } + + startWidth = width(editorContainer); + startHeight = height(editorContainer); + isDragging = true; + + addClass(editorContainer, 'resizing'); + show(cover); + on(globalDoc, moveEvents, mouseMoveFunc); + on(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }); + }; + + /** + * Prefixes and preloads the emoticon images + * @private + */ + initEmoticons = function () { + var emoticons = options.emoticons; + var root = options.emoticonsRoot || ''; + + if (emoticons) { + allEmoticons = extend( + {}, emoticons.more, emoticons.dropdown, emoticons.hidden + ); + } + + each(allEmoticons, function (key, url) { + allEmoticons[key] = _tmpl('emoticon', { + key: key, + // Prefix emoticon root to emoticon urls + url: root + (url.url || url), + tooltip: url.tooltip || key + }); + + // Preload the emoticon + if (options.emoticonsEnabled) { + preLoadCache.push(createElement('img', { + src: root + (url.url || url) + })); + } + }); + }; + + /** + * Autofocus the editor + * @private + */ + autofocus = function (focusEnd) { + var range, txtPos, + node = wysiwygBody.firstChild; + + // Can't focus invisible elements + if (!isVisible(editorContainer)) { + return; + } + + if (base.sourceMode()) { + txtPos = focusEnd ? sourceEditor.value.length : 0; + + sourceEditor.setSelectionRange(txtPos, txtPos); + + return; + } + + removeWhiteSpace(wysiwygBody); + + if (focusEnd) { + if (!(node = wysiwygBody.lastChild)) { + node = createElement('p', {}, wysiwygDocument); + appendChild(wysiwygBody, node); + } + + while (node.lastChild) { + node = node.lastChild; + + // Should place the cursor before the last <br> + if (is(node, 'br') && node.previousSibling) { + node = node.previousSibling; + } + } + } + + range = wysiwygDocument.createRange(); + + if (!canHaveChildren(node)) { + range.setStartBefore(node); + + if (focusEnd) { + range.setStartAfter(node); + } + } else { + range.selectNodeContents(node); + } + + range.collapse(!focusEnd); + rangeHelper.selectRange(range); + currentSelection = range; + + if (focusEnd) { + wysiwygBody.scrollTop = wysiwygBody.scrollHeight; + } + + base.focus(); + }; + + /** + * Gets if the editor is read only + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly + * @return {boolean} + */ + /** + * Sets if the editor is read only + * + * @param {boolean} readOnly + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly^2 + * @return {this} + */ + base.readOnly = function (readOnly) { + if (typeof readOnly !== 'boolean') { + return !sourceEditor.readonly; + } + + wysiwygBody.contentEditable = !readOnly; + sourceEditor.readonly = !readOnly; + + updateToolBar(readOnly); + + return base; + }; + + /** + * Gets if the editor is in RTL mode + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl + * @return {boolean} + */ + /** + * Sets if the editor is in RTL mode + * + * @param {boolean} rtl + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl^2 + * @return {this} + */ + base.rtl = function (rtl) { + var dir = rtl ? 'rtl' : 'ltr'; + + if (typeof rtl !== 'boolean') { + return attr(sourceEditor, 'dir') === 'rtl'; + } + + attr(wysiwygBody, 'dir', dir); + attr(sourceEditor, 'dir', dir); + + removeClass(editorContainer, 'rtl'); + removeClass(editorContainer, 'ltr'); + addClass(editorContainer, dir); + + if (icons && icons.rtl) { + icons.rtl(rtl); + } + + return base; + }; + + /** + * Updates the toolbar to disable/enable the appropriate buttons + * @private + */ + updateToolBar = function (disable) { + var mode = base.inSourceMode() ? '_sceTxtMode' : '_sceWysiwygMode'; + + each(toolbarButtons, function (_, button) { + toggleClass(button, 'disabled', disable || !button[mode]); + }); + }; + + /** + * Gets the width of the editor in pixels + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width + * @return {number} + */ + /** + * Sets the width of the editor + * + * @param {number} width Width in pixels + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width^2 + * @return {this} + */ + /** + * Sets the width of the editor + * + * The saveWidth specifies if to save the width. The stored width can be + * used for things like restoring from maximized state. + * + * @param {number} width Width in pixels + * @param {boolean} [saveWidth=true] If to store the width + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name width^3 + * @return {this} + */ + base.width = function (width$1, saveWidth) { + if (!width$1 && width$1 !== 0) { + return width(editorContainer); + } + + base.dimensions(width$1, null, saveWidth); + + return base; + }; + + /** + * Returns an object with the properties width and height + * which are the width and height of the editor in px. + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions + * @return {object} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^2 + * @return {this} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * <p>The save argument specifies if to save the new sizes. + * The saved sizes can be used for things like restoring from + * maximized state. This should normally be left as true.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @param {boolean} [save=true] If to store the new sizes + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^3 + * @return {this} + */ + base.dimensions = function (width$1, height$1, save) { + // set undefined width/height to boolean false + width$1 = (!width$1 && width$1 !== 0) ? false : width$1; + height$1 = (!height$1 && height$1 !== 0) ? false : height$1; + + if (width$1 === false && height$1 === false) { + return { width: base.width(), height: base.height() }; + } + + if (width$1 !== false) { + if (save !== false) { + options.width = width$1; + } + + width(editorContainer, width$1); + } + + if (height$1 !== false) { + if (save !== false) { + options.height = height$1; + } + + height(editorContainer, height$1); + } + + return base; + }; + + /** + * Gets the height of the editor in px + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height + * @return {number} + */ + /** + * Sets the height of the editor + * + * @param {number} height Height in px + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height^2 + * @return {this} + */ + /** + * Sets the height of the editor + * + * The saveHeight specifies if to save the height. + * + * The stored height can be used for things like + * restoring from maximized state. + * + * @param {number} height Height in px + * @param {boolean} [saveHeight=true] If to store the height + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name height^3 + * @return {this} + */ + base.height = function (height$1, saveHeight) { + if (!height$1 && height$1 !== 0) { + return height(editorContainer); + } + + base.dimensions(null, height$1, saveHeight); + + return base; + }; + + /** + * Gets if the editor is maximised or not + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize + * @return {boolean} + */ + /** + * Sets if the editor is maximised or not + * + * @param {boolean} maximize If to maximise the editor + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize^2 + * @return {this} + */ + base.maximize = function (maximize) { + var maximizeSize = 'sceditor-maximize'; + + if (isUndefined(maximize)) { + return hasClass(editorContainer, maximizeSize); + } + + maximize = !!maximize; + + if (maximize) { + maximizeScrollPosition = globalWin.pageYOffset; + } + + toggleClass(globalDoc.documentElement, maximizeSize, maximize); + toggleClass(globalDoc.body, maximizeSize, maximize); + toggleClass(editorContainer, maximizeSize, maximize); + base.width(maximize ? '100%' : options.width, false); + base.height(maximize ? '100%' : options.height, false); + + if (!maximize) { + globalWin.scrollTo(0, maximizeScrollPosition); + } + + autoExpand(); + + return base; + }; + + autoExpand = function () { + if (options.autoExpand && !autoExpandThrottle) { + autoExpandThrottle = setTimeout(base.expandToContent, 200); + } + }; + + /** + * Expands or shrinks the editors height to the height of it's content + * + * Unless ignoreMaxHeight is set to true it will not expand + * higher than the maxHeight option. + * + * @since 1.3.5 + * @param {boolean} [ignoreMaxHeight=false] + * @function + * @name expandToContent + * @memberOf SCEditor.prototype + * @see #resizeToContent + */ + base.expandToContent = function (ignoreMaxHeight) { + if (base.maximize()) { + return; + } + + clearTimeout(autoExpandThrottle); + autoExpandThrottle = false; + + if (!autoExpandBounds) { + var height$1 = options.resizeMinHeight || options.height || + height(original); + + autoExpandBounds = { + min: height$1, + max: options.resizeMaxHeight || (height$1 * 2) + }; + } + + var range = globalDoc.createRange(); + range.selectNodeContents(wysiwygBody); + + var rect = range.getBoundingClientRect(); + var current = wysiwygDocument.documentElement.clientHeight - 1; + var spaceNeeded = rect.bottom - rect.top; + var newHeight = base.height() + 1 + (spaceNeeded - current); + + if (!ignoreMaxHeight && autoExpandBounds.max !== -1) { + newHeight = Math.min(newHeight, autoExpandBounds.max); + } + + base.height(Math.ceil(Math.max(newHeight, autoExpandBounds.min))); + }; + + /** + * Destroys the editor, removing all elements and + * event handlers. + * + * Leaves only the original textarea. + * + * @function + * @name destroy + * @memberOf SCEditor.prototype + */ + base.destroy = function () { + // Don't destroy if the editor has already been destroyed + if (!pluginManager) { + return; + } + + pluginManager.destroy(); + + rangeHelper = null; + pluginManager = null; + + if (dropdown) { + remove(dropdown); + } + + off(globalDoc, 'click', handleDocumentClick); + + var form = original.form; + if (form) { + off(form, 'reset', handleFormReset); + off(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + off(window, 'pagehide', base.updateOriginal); + off(window, 'pageshow', handleFormReset); + remove(sourceEditor); + remove(toolbar); + remove(editorContainer); + + delete original._sceditor; + show(original); + + original.required = isRequired; + }; + + + /** + * Creates a menu item drop down + * + * @param {HTMLElement} menuItem The button to align the dropdown with + * @param {string} name Used for styling the dropdown, will be + * a class sceditor-name + * @param {HTMLElement} content The HTML content of the dropdown + * @function + * @name createDropDown + * @memberOf SCEditor.prototype + */ + base.createDropDown = function (menuItem, name, content) { + // first click for create second click for close + var dropDownCss, + dropDownClass = 'sceditor-' + name; + + base.closeDropDown(); + + // Only close the dropdown if it was already open + if (dropdown && hasClass(dropdown, dropDownClass)) { + return; + } + + dropDownCss = extend({ + top: menuItem.offsetTop, + left: menuItem.offsetLeft, + marginTop: menuItem.clientHeight + }, options.dropDownCss); + + dropdown = createElement('div', { + className: 'sceditor-dropdown ' + dropDownClass + }); + + css(dropdown, dropDownCss); + appendChild(dropdown, content); + appendChild(editorContainer, dropdown); + on(dropdown, 'click focusin', function (e) { + // stop clicks within the dropdown from being handled + e.stopPropagation(); + }); + + if (dropdown) { + var first = find(dropdown, 'input,textarea')[0]; + if (first) { + first.focus(); + } + } + }; + + /** + * Handles any document click and closes the dropdown if open + * @private + */ + handleDocumentClick = function (e) { + // ignore right clicks + if (e.which !== 3 && dropdown && !e.defaultPrevented) { + autoUpdate(); + + base.closeDropDown(); + } + }; + + /** + * Handles the WYSIWYG editors cut & copy events + * + * By default browsers also copy inherited styling from the stylesheet and + * browser default styling which is unnecessary. + * + * This will ignore inherited styles and only copy inline styling. + * @private + */ + handleCutCopyEvt = function (e) { + var range = rangeHelper.selectedRange(); + if (range) { + var container = createElement('div', {}, wysiwygDocument); + var firstParent; + + // Copy all inline parent nodes up to the first block parent so can + // copy inline styles + var parent = range.commonAncestorContainer; + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + if (container.firstChild) { + appendChild(clone, container.firstChild); + } + + appendChild(container, clone); + firstParent = firstParent || clone; + } + parent = parent.parentNode; + } + + appendChild(firstParent || container, range.cloneContents()); + removeWhiteSpace(container); + + e.clipboardData.setData('text/html', container.innerHTML); + + // TODO: Refactor into private shared module with plaintext plugin + // innerText adds two newlines after <p> tags so convert them to + // <div> tags + each(find(container, 'p'), function (_, elm) { + convertElement(elm, 'div'); + }); + // Remove collapsed <br> tags as innerText converts them to newlines + each(find(container, 'br'), function (_, elm) { + if (!elm.nextSibling || !isInline(elm.nextSibling, true)) { + remove(elm); + } + }); + + // range.toString() doesn't include newlines so can't use that. + // selection.toString() seems to use the same method as innerText + // but needs to be normalised first so using container.innerText + appendChild(wysiwygBody, container); + e.clipboardData.setData('text/plain', container.innerText); + remove(container); + + if (e.type === 'cut') { + range.deleteContents(); + } + + e.preventDefault(); + } + }; + + /** + * Handles the WYSIWYG editors paste event + * @private + */ + handlePasteEvt = function (e) { + var editable = wysiwygBody; + var clipboard = e.clipboardData; + var loadImage = function (file) { + var reader = new FileReader(); + reader.onload = function (e) { + handlePasteData({ + html: '<img src="' + e.target.result + '" />' + }); + }; + reader.readAsDataURL(file); + }; + + // Modern browsers with clipboard API - everything other than _very_ + // old android web views and UC browser which doesn't support the + // paste event at all. + if (clipboard) { + var data = {}; + var types = clipboard.types; + var items = clipboard.items; + + e.preventDefault(); + + for (var i = 0; i < types.length; i++) { + // Word sometimes adds copied text as an image so if HTML + // exists prefer that over images + if (types.indexOf('text/html') < 0) { + // Normalise image pasting to paste as a data-uri + if (globalWin.FileReader && items && + IMAGE_MIME_REGEX.test(items[i].type)) { + return loadImage(clipboard.items[i].getAsFile()); + } + } + + data[types[i]] = clipboard.getData(types[i]); + } + // Call plugins here with file? + data.text = data['text/plain']; + data.html = sanitize(data['text/html']); + + handlePasteData(data); + // If contentsFragment exists then we are already waiting for a + // previous paste so let the handler for that handle this one too + } else if (!pasteContentFragment) { + // Save the scroll position so can be restored + // when contents is restored + var scrollTop = editable.scrollTop; + + rangeHelper.saveRange(); + + pasteContentFragment = globalDoc.createDocumentFragment(); + while (editable.firstChild) { + appendChild(pasteContentFragment, editable.firstChild); + } + + setTimeout(function () { + var html = editable.innerHTML; + + editable.innerHTML = ''; + appendChild(editable, pasteContentFragment); + editable.scrollTop = scrollTop; + pasteContentFragment = false; + + rangeHelper.restoreRange(); + + handlePasteData({ html: sanitize(html) }); + }, 0); + } + }; + + /** + * Gets the pasted data, filters it and then inserts it. + * @param {Object} data + * @private + */ + handlePasteData = function (data) { + var pasteArea = createElement('div', {}, wysiwygDocument); + + pluginManager.call('pasteRaw', data); + trigger(editorContainer, 'pasteraw', data); + + if (data.html) { + // Sanitize again in case plugins modified the HTML + pasteArea.innerHTML = sanitize(data.html); + + // fix any invalid nesting + fixNesting(pasteArea); + } else { + pasteArea.innerHTML = entities(data.text || ''); + } + + var paste = { + val: pasteArea.innerHTML + }; + + if ('fragmentToSource' in format) { + paste.val = format + .fragmentToSource(paste.val, wysiwygDocument, currentNode); + } + + pluginManager.call('paste', paste); + trigger(editorContainer, 'paste', paste); + + if ('fragmentToHtml' in format) { + paste.val = format + .fragmentToHtml(paste.val, currentNode); + } + + pluginManager.call('pasteHtml', paste); + + var parent = rangeHelper.getFirstBlockParent(); + base.wysiwygEditorInsertHtml(paste.val, null, true); + merge(parent); + }; + + /** + * Closes any currently open drop down + * + * @param {boolean} [focus=false] If to focus the editor + * after closing the drop down + * @function + * @name closeDropDown + * @memberOf SCEditor.prototype + */ + base.closeDropDown = function (focus) { + if (dropdown) { + remove(dropdown); + dropdown = null; + } + + if (focus === true) { + base.focus(); + } + }; + + + /** + * Inserts HTML into WYSIWYG editor. + * + * If endHtml is specified, any selected text will be placed + * between html and endHtml. If there is no selected text html + * and endHtml will just be concatenate together. + * + * @param {string} html + * @param {string} [endHtml=null] + * @param {boolean} [overrideCodeBlocking=false] If to insert the html + * into code tags, by + * default code tags only + * support text. + * @function + * @name wysiwygEditorInsertHtml + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertHtml = function ( + html, endHtml, overrideCodeBlocking + ) { + var marker, scrollTop, scrollTo, + editorHeight = height(wysiwygEditor); + + base.focus(); + + // TODO: This code tag should be configurable and + // should maybe convert the HTML into text instead + // Don't apply to code elements + if (!overrideCodeBlocking && closest(currentBlockNode, 'code')) { + return; + } + + // Insert the HTML and save the range so the editor can be scrolled + // to the end of the selection. Also allows emoticons to be replaced + // without affecting the cursor position + rangeHelper.insertHTML(html, endHtml); + rangeHelper.saveRange(); + replaceEmoticons(); + + // Fix any invalid nesting, e.g. if a quote or other block is inserted + // into a paragraph + fixNesting(wysiwygBody); + + // Scroll the editor after the end of the selection + marker = find(wysiwygBody, '#sceditor-end-marker')[0]; + show(marker); + scrollTop = wysiwygBody.scrollTop; + scrollTo = (getOffset(marker).top + + (marker.offsetHeight * 1.5)) - editorHeight; + hide(marker); + + // Only scroll if marker isn't already visible + if (scrollTo > scrollTop || scrollTo + editorHeight < scrollTop) { + wysiwygBody.scrollTop = scrollTo; + } + + triggerValueChanged(false); + rangeHelper.restoreRange(); + + // Add a new line after the last block element + // so can always add text after it + appendNewLine(); + }; + + /** + * Like wysiwygEditorInsertHtml except it will convert any HTML + * into text before inserting it. + * + * @param {string} text + * @param {string} [endText=null] + * @function + * @name wysiwygEditorInsertText + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertText = function (text, endText) { + base.wysiwygEditorInsertHtml( + entities(text), entities(endText) + ); + }; + + /** + * Inserts text into the WYSIWYG or source editor depending on which + * mode the editor is in. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.3.5 + * @function + * @name insertText + * @memberOf SCEditor.prototype + */ + base.insertText = function (text, endText) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(text, endText); + } else { + base.wysiwygEditorInsertText(text, endText); + } + + return base; + }; + + /** + * Like wysiwygEditorInsertHtml but inserts text into the + * source mode editor instead. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * The cursor will be placed after the text param. If endText is + * specified the cursor will be placed before endText, so passing:<br /> + * + * '[b]', '[/b]' + * + * Would cause the cursor to be placed:<br /> + * + * [b]Selected text|[/b] + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.4.0 + * @function + * @name sourceEditorInsertText + * @memberOf SCEditor.prototype + */ + base.sourceEditorInsertText = function (text, endText) { + var scrollTop, currentValue, + startPos = sourceEditor.selectionStart, + endPos = sourceEditor.selectionEnd; + + scrollTop = sourceEditor.scrollTop; + sourceEditor.focus(); + currentValue = sourceEditor.value; + + if (endText) { + text += currentValue.substring(startPos, endPos) + endText; + } + + sourceEditor.value = currentValue.substring(0, startPos) + + text + + currentValue.substring(endPos, currentValue.length); + + sourceEditor.selectionStart = (startPos + text.length) - + (endText ? endText.length : 0); + sourceEditor.selectionEnd = sourceEditor.selectionStart; + + sourceEditor.scrollTop = scrollTop; + sourceEditor.focus(); + + triggerValueChanged(); + }; + + /** + * Gets the current instance of the rangeHelper class + * for the editor. + * + * @return {RangeHelper} + * @function + * @name getRangeHelper + * @memberOf SCEditor.prototype + */ + base.getRangeHelper = function () { + return rangeHelper; + }; + + /** + * Gets or sets the source editor caret position. + * + * @param {Object} [position] + * @return {this} + * @function + * @since 1.4.5 + * @name sourceEditorCaret + * @memberOf SCEditor.prototype + */ + base.sourceEditorCaret = function (position) { + sourceEditor.focus(); + + if (position) { + sourceEditor.selectionStart = position.start; + sourceEditor.selectionEnd = position.end; + + return this; + } + + return { + start: sourceEditor.selectionStart, + end: sourceEditor.selectionEnd + }; + }; + + /** + * Gets the value of the editor. + * + * If the editor is in WYSIWYG mode it will return the filtered + * HTML from it (converted to BBCode if using the BBCode plugin). + * It it's in Source Mode it will return the unfiltered contents + * of the source editor (if using the BBCode plugin this will be + * BBCode again). + * + * @since 1.3.5 + * @return {string} + * @function + * @name val + * @memberOf SCEditor.prototype + */ + /** + * Sets the value of the editor. + * + * If filter set true the val will be passed through the filter + * function. If using the BBCode plugin it will pass the val to + * the BBCode filter to convert any BBCode into HTML. + * + * @param {string} val + * @param {boolean} [filter=true] + * @return {this} + * @since 1.3.5 + * @function + * @name val^2 + * @memberOf SCEditor.prototype + */ + base.val = function (val, filter) { + if (!isString(val)) { + return base.inSourceMode() ? + base.getSourceEditorValue(false) : + base.getWysiwygEditorValue(filter); + } + + if (!base.inSourceMode()) { + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + base.setWysiwygEditorValue(val); + } else { + base.setSourceEditorValue(val); + } + + return base; + }; + + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @return {this} + * @since 1.3.5 + * @function + * @name insert + * @memberOf SCEditor.prototype + */ + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * If the allowMixed param is set to true, HTML any will not be + * escaped + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @param {boolean} [allowMixed=false] + * @return {this} + * @since 1.4.3 + * @function + * @name insert^2 + * @memberOf SCEditor.prototype + */ + // eslint-disable-next-line max-params + base.insert = function ( + start, end, filter, convertEmoticons, allowMixed + ) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(start, end); + return base; + } + + // Add the selection between start and end + if (end) { + var html = rangeHelper.selectedHtml(); + + if (filter !== false && 'fragmentToSource' in format) { + html = format + .fragmentToSource(html, wysiwygDocument, currentNode); + } + + start += html + end; + } + // TODO: This filter should allow empty tags as it's inserting. + if (filter !== false && 'fragmentToHtml' in format) { + start = format.fragmentToHtml(start, currentNode); + } + + // Convert any escaped HTML back into HTML if mixed is allowed + if (filter !== false && allowMixed === true) { + start = start.replace(/</g, '<') + .replace(/>/g, '>') + .replace(/&/g, '&'); + } + + base.wysiwygEditorInsertHtml(start); + + return base; + }; + + /** + * Gets the WYSIWYG editors HTML value. + * + * If using a plugin that filters the Ht Ml like the BBCode plugin + * it will return the result of the filtering (BBCode) unless the + * filter param is set to false. + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @name getWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.getWysiwygEditorValue = function (filter) { + var html; + // Create a tmp node to store contents so it can be modified + // without affecting anything else. + var tmp = createElement('div', {}, wysiwygDocument); + var childNodes = wysiwygBody.childNodes; + + for (var i = 0; i < childNodes.length; i++) { + appendChild(tmp, childNodes[i].cloneNode(true)); + } + + appendChild(wysiwygBody, tmp); + fixNesting(tmp); + remove(tmp); + + html = tmp.innerHTML; + + // filter the HTML and DOM through any plugins + if (filter !== false && format.hasOwnProperty('toSource')) { + html = format.toSource(html, wysiwygDocument); + } + + return html; + }; + + /** + * Gets the WYSIWYG editor's iFrame Body. + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getBody + * @memberOf SCEditor.prototype + */ + base.getBody = function () { + return wysiwygBody; + }; + + /** + * Gets the WYSIWYG editors container area (whole iFrame). + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getContentAreaContainer + * @memberOf SCEditor.prototype + */ + base.getContentAreaContainer = function () { + return wysiwygEditor; + }; + + /** + * Gets the text editor value + * + * If using a plugin that filters the text like the BBCode plugin + * it will return the result of the filtering which is BBCode to + * HTML so it will return HTML. If filter is set to false it will + * just return the contents of the source editor (BBCode). + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @since 1.4.0 + * @name getSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.getSourceEditorValue = function (filter) { + var val = sourceEditor.value; + + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + return val; + }; + + /** + * Sets the WYSIWYG HTML editor value. Should only be the HTML + * contained within the body tags + * + * @param {string} value + * @function + * @name setWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.setWysiwygEditorValue = function (value) { + if (!value) { + value = '<p><br /></p>'; + } + + wysiwygBody.innerHTML = sanitize(value); + replaceEmoticons(); + + appendNewLine(); + triggerValueChanged(); + autoExpand(); + }; + + /** + * Sets the text editor value + * + * @param {string} value + * @function + * @name setSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.setSourceEditorValue = function (value) { + sourceEditor.value = value; + + triggerValueChanged(); + }; + + /** + * Updates the textarea that the editor is replacing + * with the value currently inside the editor. + * + * @function + * @name updateOriginal + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.updateOriginal = function () { + original.value = base.val(); + }; + + /** + * Replaces any emoticon codes in the passed HTML + * with their emoticon images + * @private + */ + replaceEmoticons = function () { + if (options.emoticonsEnabled) { + replace(wysiwygBody, allEmoticons, options.emoticonsCompat); + } + }; + + /** + * If the editor is in source code mode + * + * @return {boolean} + * @function + * @name inSourceMode + * @memberOf SCEditor.prototype + */ + base.inSourceMode = function () { + return hasClass(editorContainer, 'sourceMode'); + }; + + /** + * Gets if the editor is in sourceMode + * + * @return boolean + * @function + * @name sourceMode + * @memberOf SCEditor.prototype + */ + /** + * Sets if the editor is in sourceMode + * + * @param {boolean} enable + * @return {this} + * @function + * @name sourceMode^2 + * @memberOf SCEditor.prototype + */ + base.sourceMode = function (enable) { + var inSourceMode = base.inSourceMode(); + + if (typeof enable !== 'boolean') { + return inSourceMode; + } + + if ((inSourceMode && !enable) || (!inSourceMode && enable)) { + base.toggleSourceMode(); + } + + return base; + }; + + /** + * Switches between the WYSIWYG and source modes + * + * @function + * @name toggleSourceMode + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.toggleSourceMode = function () { + var isInSourceMode = base.inSourceMode(); + + // don't allow switching to WYSIWYG if doesn't support it + if (!isWysiwygSupported && isInSourceMode) { + return; + } + + if (!isInSourceMode) { + rangeHelper.saveRange(); + rangeHelper.clear(); + } + + currentSelection = null; + base.blur(); + + if (isInSourceMode) { + base.setWysiwygEditorValue(base.getSourceEditorValue()); + } else { + base.setSourceEditorValue(base.getWysiwygEditorValue()); + } + + toggle(sourceEditor); + toggle(wysiwygEditor); + + toggleClass(editorContainer, 'wysiwygMode', isInSourceMode); + toggleClass(editorContainer, 'sourceMode', !isInSourceMode); + + updateToolBar(); + updateActiveButtons(); + }; + + /** + * Gets the selected text of the source editor + * @return {string} + * @private + */ + sourceEditorSelectedText = function () { + sourceEditor.focus(); + + return sourceEditor.value.substring( + sourceEditor.selectionStart, + sourceEditor.selectionEnd + ); + }; + + /** + * Handles the passed command + * @private + */ + handleCommand = function (caller, cmd) { + // check if in text mode and handle text commands + if (base.inSourceMode()) { + if (cmd.txtExec) { + if (Array.isArray(cmd.txtExec)) { + base.sourceEditorInsertText.apply(base, cmd.txtExec); + } else { + cmd.txtExec.call(base, caller, sourceEditorSelectedText()); + } + } + } else if (cmd.exec) { + if (isFunction(cmd.exec)) { + cmd.exec.call(base, caller); + } else { + base.execCommand( + cmd.exec, + cmd.hasOwnProperty('execParam') ? cmd.execParam : null + ); + } + } + + }; + + /** + * Executes a command on the WYSIWYG editor + * + * @param {string} command + * @param {String|Boolean} [param] + * @function + * @name execCommand + * @memberOf SCEditor.prototype + */ + base.execCommand = function (command, param) { + var executed = false, + commandObj = base.commands[command]; + + base.focus(); + + // TODO: make configurable + // don't apply any commands to code elements + if (closest(rangeHelper.parentNode(), 'code')) { + return; + } + + try { + executed = wysiwygDocument.execCommand(command, false, param); + } catch (ex) { } + + // show error if execution failed and an error message exists + if (!executed && commandObj && commandObj.errorMessage) { + /*global alert:false*/ + alert(base._(commandObj.errorMessage)); + } + + updateActiveButtons(); + }; + + /** + * Checks if the current selection has changed and triggers + * the selectionchanged event if it has. + * + * In browsers other that don't support selectionchange event it will check + * at most once every 100ms. + * @private + */ + checkSelectionChanged = function () { + function check() { + // Don't create new selection if there isn't one (like after + // blur event in iOS) + if (wysiwygWindow.getSelection() && + wysiwygWindow.getSelection().rangeCount <= 0) { + currentSelection = null; + // rangeHelper could be null if editor was destroyed + // before the timeout had finished + } else if (rangeHelper && !rangeHelper.compare(currentSelection)) { + currentSelection = rangeHelper.cloneSelected(); + + // If the selection is in an inline wrap it in a block. + // Fixes #331 + if (currentSelection && currentSelection.collapsed) { + var parent = currentSelection.startContainer; + var offset = currentSelection.startOffset; + + // Handle if selection is placed before/after an element + if (offset && parent.nodeType !== TEXT_NODE) { + parent = parent.childNodes[offset]; + } + + while (parent && parent.parentNode !== wysiwygBody) { + parent = parent.parentNode; + } + + if (parent && isInline(parent, true)) { + rangeHelper.saveRange(); + wrapInlines(wysiwygBody, wysiwygDocument); + rangeHelper.restoreRange(); + } + } + + trigger(editorContainer, 'selectionchanged'); + } + + isSelectionCheckPending = false; + } + + if (isSelectionCheckPending) { + return; + } + + isSelectionCheckPending = true; + + // Don't need to limit checking if browser supports the Selection API + if ('onselectionchange' in wysiwygDocument) { + check(); + } else { + setTimeout(check, 100); + } + }; + + /** + * Checks if the current node has changed and triggers + * the nodechanged event if it has + * @private + */ + checkNodeChanged = function () { + // check if node has changed + var oldNode, + node = rangeHelper.parentNode(); + + if (currentNode !== node) { + oldNode = currentNode; + currentNode = node; + currentBlockNode = rangeHelper.getFirstBlockParent(node); + + trigger(editorContainer, 'nodechanged', { + oldNode: oldNode, + newNode: currentNode + }); + } + }; + + /** + * Gets the current node that contains the selection/caret in + * WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentNode + * @memberOf SCEditor.prototype + */ + base.currentNode = function () { + return currentNode; + }; + + /** + * Gets the first block level node that contains the + * selection/caret in WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentBlockNode + * @memberOf SCEditor.prototype + * @since 1.4.4 + */ + base.currentBlockNode = function () { + return currentBlockNode; + }; + + /** + * Updates if buttons are active or not + * @private + */ + updateActiveButtons = function () { + var firstBlock, parent; + var activeClass = 'active'; + var doc = wysiwygDocument; + var isSource = base.sourceMode(); + + if (base.readOnly()) { + each(find(toolbar, activeClass), function (_, menuItem) { + removeClass(menuItem, activeClass); + }); + return; + } + + if (!isSource) { + parent = rangeHelper.parentNode(); + firstBlock = rangeHelper.getFirstBlockParent(parent); + } + + for (var j = 0; j < btnStateHandlers.length; j++) { + var state = 0; + var btn = toolbarButtons[btnStateHandlers[j].name]; + var stateFn = btnStateHandlers[j].state; + var isDisabled = (isSource && !btn._sceTxtMode) || + (!isSource && !btn._sceWysiwygMode); + + if (isString(stateFn)) { + if (!isSource) { + try { + state = doc.queryCommandEnabled(stateFn) ? 0 : -1; + + // eslint-disable-next-line max-depth + if (state > -1) { + state = doc.queryCommandState(stateFn) ? 1 : 0; + } + } catch (ex) {} + } + } else if (!isDisabled) { + state = stateFn.call(base, parent, firstBlock); + } + + toggleClass(btn, 'disabled', isDisabled || state < 0); + toggleClass(btn, activeClass, state > 0); + } + + if (icons && icons.update) { + icons.update(isSource, parent, firstBlock); + } + }; + + /** + * Handles any key press in the WYSIWYG editor + * + * @private + */ + handleKeyPress = function (e) { + // FF bug: https://bugzilla.mozilla.org/show_bug.cgi?id=501496 + if (e.defaultPrevented) { + return; + } + + base.closeDropDown(); + + // 13 = enter key + if (e.which === 13) { + var LIST_TAGS = 'li,ul,ol'; + + // "Fix" (cludge) for blocklevel elements being duplicated in some + // browsers when enter is pressed instead of inserting a newline + if (!is(currentBlockNode, LIST_TAGS) && + hasStyling(currentBlockNode)) { + + var br = createElement('br', {}, wysiwygDocument); + rangeHelper.insertNode(br); + + // Last <br> of a block will be collapsed so need to make sure + // the <br> that was inserted isn't the last node of a block. + var parent = br.parentNode; + var lastChild = parent.lastChild; + + // Sometimes an empty next node is created after the <br> + if (lastChild && lastChild.nodeType === TEXT_NODE && + lastChild.nodeValue === '') { + remove(lastChild); + lastChild = parent.lastChild; + } + + // If this is the last BR of a block and the previous + // sibling is inline then will need an extra BR. This + // is needed because the last BR of a block will be + // collapsed. Fixes issue #248 + if (!isInline(parent, true) && lastChild === br && + isInline(br.previousSibling)) { + rangeHelper.insertHTML('<br>'); + } + + e.preventDefault(); + } + } + }; + + /** + * Makes sure that if there is a code or quote tag at the + * end of the editor, that there is a new line after it. + * + * If there wasn't a new line at the end you wouldn't be able + * to enter any text after a code/quote tag + * @return {void} + * @private + */ + appendNewLine = function () { + // Check all nodes in reverse until either add a new line + // or reach a non-empty textnode or BR at which point can + // stop checking. + rTraverse(wysiwygBody, function (node) { + // Last block, add new line after if has styling + if (node.nodeType === ELEMENT_NODE && + !/inline/.test(css(node, 'display'))) { + + // Add line break after if has styling + if (!is(node, '.sceditor-nlf') && hasStyling(node)) { + var paragraph = createElement('p', {}, wysiwygDocument); + paragraph.className = 'sceditor-nlf'; + paragraph.innerHTML = '<br />'; + appendChild(wysiwygBody, paragraph); + return false; + } + } + + // Last non-empty text node or line break. + // No need to add line-break after them + if ((node.nodeType === 3 && !/^\s*$/.test(node.nodeValue)) || + is(node, 'br')) { + return false; + } + }); + }; + + /** + * Handles form reset event + * @private + */ + handleFormReset = function () { + base.val(original.value); + }; + + /** + * Handles any mousedown press in the WYSIWYG editor + * @private + */ + handleMouseDown = function () { + base.closeDropDown(); + }; + + /** + * Translates the string into the locale language. + * + * Replaces any {0}, {1}, {2}, ect. with the params provided. + * + * @param {string} str + * @param {...String} args + * @return {string} + * @function + * @name _ + * @memberOf SCEditor.prototype + */ + base._ = function () { + var undef, + args = arguments; + + if (locale && locale[args[0]]) { + args[0] = locale[args[0]]; + } + + return args[0].replace(/\{(\d+)\}/g, function (str, p1) { + return args[p1 - 0 + 1] !== undef ? + args[p1 - 0 + 1] : + '{' + p1 + '}'; + }); + }; + + /** + * Passes events on to any handlers + * @private + * @return void + */ + handleEvent = function (e) { + if (pluginManager) { + // Send event to all plugins + pluginManager.call(e.type + 'Event', e, base); + } + + // convert the event into a custom event to send + var name = (e.target === sourceEditor ? 'scesrc' : 'scewys') + e.type; + + if (eventHandlers[name]) { + eventHandlers[name].forEach(function (fn) { + fn.call(base, e); + }); + } + }; + + /** + * Binds a handler to the specified events + * + * This function only binds to a limited list of + * supported events. + * + * The supported events are: + * + * * keyup + * * keydown + * * Keypress + * * blur + * * focus + * * input + * * nodechanged - When the current node containing + * the selection changes in WYSIWYG mode + * * contextmenu + * * selectionchanged + * * valuechanged + * + * + * The events param should be a string containing the event(s) + * to bind this handler to. If multiple, they should be separated + * by spaces. + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name bind + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.bind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + var wysEvent = 'scewys' + events[i]; + var srcEvent = 'scesrc' + events[i]; + // Use custom events to allow passing the instance as the + // 2nd argument. + // Also allows unbinding without unbinding the editors own + // event handlers. + if (!excludeWysiwyg) { + eventHandlers[wysEvent] = eventHandlers[wysEvent] || []; + eventHandlers[wysEvent].push(handler); + } + + if (!excludeSource) { + eventHandlers[srcEvent] = eventHandlers[srcEvent] || []; + eventHandlers[srcEvent].push(handler); + } + + // Start sending value changed events + if (events[i] === 'valuechanged') { + triggerValueChanged.hasHandler = true; + } + } + } + + return base; + }; + + /** + * Unbinds an event that was bound using bind(). + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude unbinding this + * handler from the WYSIWYG editor + * @param {boolean} excludeSource if to exclude unbinding this + * handler from the source editor + * @return {this} + * @function + * @name unbind + * @memberOf SCEditor.prototype + * @since 1.4.1 + * @see bind + */ + base.unbind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + if (!excludeWysiwyg) { + arrayRemove( + eventHandlers['scewys' + events[i]] || [], handler); + } + + if (!excludeSource) { + arrayRemove( + eventHandlers['scesrc' + events[i]] || [], handler); + } + } + } + + return base; + }; + + /** + * Blurs the editors input area + * + * @return {this} + * @function + * @name blur + * @memberOf SCEditor.prototype + * @since 1.3.6 + */ + /** + * Adds a handler to the editors blur event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name blur^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.blur = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('blur', handler, excludeWysiwyg, excludeSource); + } else if (!base.sourceMode()) { + wysiwygBody.blur(); + } else { + sourceEditor.blur(); + } + + return base; + }; + + /** + * Focuses the editors input area + * + * @return {this} + * @function + * @name focus + * @memberOf SCEditor.prototype + */ + /** + * Adds an event handler to the focus event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name focus^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.focus = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('focus', handler, excludeWysiwyg, excludeSource); + } else if (!base.inSourceMode()) { + // Already has focus so do nothing + if (find(wysiwygDocument, ':focus').length) { + return; + } + + var container; + var rng = rangeHelper.selectedRange(); + + // Fix FF bug where it shows the cursor in the wrong place + // if the editor hasn't had focus before. See issue #393 + if (!currentSelection) { + autofocus(true); + } + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (rng && rng.endOffset === 1 && rng.collapsed) { + container = rng.endContainer; + + if (container && container.childNodes.length === 1 && + is(container.firstChild, 'br')) { + rng.setStartBefore(container.firstChild); + rng.collapse(true); + rangeHelper.selectRange(rng); + } + } + + wysiwygWindow.focus(); + wysiwygBody.focus(); + } else { + sourceEditor.focus(); + } + + updateActiveButtons(); + + return base; + }; + + /** + * Adds a handler to the key down event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyDown + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyDown = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keydown', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key press event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyPress + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyPress = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('keypress', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key up event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyUp + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyUp = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keyup', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the node changed event. + * + * Happens whenever the node containing the selection/caret + * changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name nodeChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.nodeChanged = function (handler) { + return base.bind('nodechanged', handler, false, true); + }; + + /** + * Adds a handler to the selection changed event + * + * Happens whenever the selection changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name selectionChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.selectionChanged = function (handler) { + return base.bind('selectionchanged', handler, false, true); + }; + + /** + * Adds a handler to the value changed event + * + * Happens whenever the current editor value changes. + * + * Whenever anything is inserted, the value changed or + * 1.5 secs after text is typed. If a space is typed it will + * cause the event to be triggered immediately instead of + * after 1.5 seconds + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name valueChanged + * @memberOf SCEditor.prototype + * @since 1.4.5 + */ + base.valueChanged = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('valuechanged', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Emoticons keypress handler + * @private + */ + emoticonsKeyPress = function (e) { + var replacedEmoticon, + cachePos = 0, + emoticonsCache = base.emoticonsCache, + curChar = String.fromCharCode(e.which); + + // TODO: Make configurable + if (closest(currentBlockNode, 'code')) { + return; + } + + if (!emoticonsCache) { + emoticonsCache = []; + + each(allEmoticons, function (key, html) { + emoticonsCache[cachePos++] = [key, html]; + }); + + emoticonsCache.sort(function (a, b) { + return a[0].length - b[0].length; + }); + + base.emoticonsCache = emoticonsCache; + base.longestEmoticonCode = + emoticonsCache[emoticonsCache.length - 1][0].length; + } + + replacedEmoticon = rangeHelper.replaceKeyword( + base.emoticonsCache, + true, + true, + base.longestEmoticonCode, + options.emoticonsCompat, + curChar + ); + + if (replacedEmoticon) { + if (!options.emoticonsCompat || !/^\s$/.test(curChar)) { + e.preventDefault(); + } + } + }; + + /** + * Makes sure emoticons are surrounded by whitespace + * @private + */ + emoticonsCheckWhitespace = function () { + checkWhitespace(currentBlockNode, rangeHelper); + }; + + /** + * Gets if emoticons are currently enabled + * @return {boolean} + * @function + * @name emoticons + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + /** + * Enables/disables emoticons + * + * @param {boolean} enable + * @return {this} + * @function + * @name emoticons^2 + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + base.emoticons = function (enable) { + if (!enable && enable !== false) { + return options.emoticonsEnabled; + } + + options.emoticonsEnabled = enable; + + if (enable) { + on(wysiwygBody, 'keypress', emoticonsKeyPress); + + if (!base.sourceMode()) { + rangeHelper.saveRange(); + + replaceEmoticons(); + triggerValueChanged(false); + + rangeHelper.restoreRange(); + } + } else { + var emoticons = + find(wysiwygBody, 'img[data-sceditor-emoticon]'); + + each(emoticons, function (_, img) { + var text = data(img, 'sceditor-emoticon'); + var textNode = wysiwygDocument.createTextNode(text); + img.parentNode.replaceChild(textNode, img); + }); + + off(wysiwygBody, 'keypress', emoticonsKeyPress); + + triggerValueChanged(); + } + + return base; + }; + + /** + * Gets the current WYSIWYG editors inline CSS + * + * @return {string} + * @function + * @name css + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + /** + * Sets inline CSS for the WYSIWYG editor + * + * @param {string} css + * @return {this} + * @function + * @name css^2 + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + base.css = function (css) { + if (!inlineCss) { + inlineCss = createElement('style', { + id: 'inline' + }, wysiwygDocument); + + appendChild(wysiwygDocument.head, inlineCss); + } + + if (!isString(css)) { + return inlineCss.styleSheet ? + inlineCss.styleSheet.cssText : inlineCss.innerHTML; + } + + if (inlineCss.styleSheet) { + inlineCss.styleSheet.cssText = css; + } else { + inlineCss.innerHTML = css; + } + + return base; + }; + + /** + * Handles the keydown event, used for shortcuts + * @private + */ + handleKeyDown = function (e) { + var shortcut = [], + SHIFT_KEYS = { + '`': '~', + '1': '!', + '2': '@', + '3': '#', + '4': '$', + '5': '%', + '6': '^', + '7': '&', + '8': '*', + '9': '(', + '0': ')', + '-': '_', + '=': '+', + ';': ': ', + '\'': '"', + ',': '<', + '.': '>', + '/': '?', + '\\': '|', + '[': '{', + ']': '}' + }, + SPECIAL_KEYS = { + 8: 'backspace', + 9: 'tab', + 13: 'enter', + 19: 'pause', + 20: 'capslock', + 27: 'esc', + 32: 'space', + 33: 'pageup', + 34: 'pagedown', + 35: 'end', + 36: 'home', + 37: 'left', + 38: 'up', + 39: 'right', + 40: 'down', + 45: 'insert', + 46: 'del', + 91: 'win', + 92: 'win', + 93: 'select', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9', + 106: '*', + 107: '+', + 109: '-', + 110: '.', + 111: '/', + 112: 'f1', + 113: 'f2', + 114: 'f3', + 115: 'f4', + 116: 'f5', + 117: 'f6', + 118: 'f7', + 119: 'f8', + 120: 'f9', + 121: 'f10', + 122: 'f11', + 123: 'f12', + 144: 'numlock', + 145: 'scrolllock', + 186: ';', + 187: '=', + 188: ',', + 189: '-', + 190: '.', + 191: '/', + 192: '`', + 219: '[', + 220: '\\', + 221: ']', + 222: '\'' + }, + NUMPAD_SHIFT_KEYS = { + 109: '-', + 110: 'del', + 111: '/', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9' + }, + which = e.which, + character = SPECIAL_KEYS[which] || + String.fromCharCode(which).toLowerCase(); + + if (e.ctrlKey || e.metaKey) { + shortcut.push('ctrl'); + } + + if (e.altKey) { + shortcut.push('alt'); + } + + if (e.shiftKey) { + shortcut.push('shift'); + + if (NUMPAD_SHIFT_KEYS[which]) { + character = NUMPAD_SHIFT_KEYS[which]; + } else if (SHIFT_KEYS[character]) { + character = SHIFT_KEYS[character]; + } + } + + // Shift is 16, ctrl is 17 and alt is 18 + if (character && (which < 16 || which > 18)) { + shortcut.push(character); + } + + shortcut = shortcut.join('+'); + if (shortcutHandlers[shortcut] && + shortcutHandlers[shortcut].call(base) === false) { + + e.stopPropagation(); + e.preventDefault(); + } + }; + + /** + * Adds a shortcut handler to the editor + * @param {string} shortcut + * @param {String|Function} cmd + * @return {sceditor} + */ + base.addShortcut = function (shortcut, cmd) { + shortcut = shortcut.toLowerCase(); + + if (isString(cmd)) { + shortcutHandlers[shortcut] = function () { + handleCommand(toolbarButtons[cmd], base.commands[cmd]); + + return false; + }; + } else { + shortcutHandlers[shortcut] = cmd; + } + + return base; + }; + + /** + * Removes a shortcut handler + * @param {string} shortcut + * @return {sceditor} + */ + base.removeShortcut = function (shortcut) { + delete shortcutHandlers[shortcut.toLowerCase()]; + + return base; + }; + + /** + * Handles the backspace key press + * + * Will remove block styling like quotes/code ect if at the start. + * @private + */ + handleBackSpace = function (e) { + var node, offset, range, parent; + + // 8 is the backspace key + if (options.disableBlockRemove || e.which !== 8 || + !(range = rangeHelper.selectedRange())) { + return; + } + + node = range.startContainer; + offset = range.startOffset; + + if (offset !== 0 || !(parent = currentStyledBlockNode()) || + is(parent, 'body')) { + return; + } + + while (node !== parent) { + while (node.previousSibling) { + node = node.previousSibling; + + // Everything but empty text nodes before the cursor + // should prevent the style from being removed + if (node.nodeType !== TEXT_NODE || node.nodeValue) { + return; + } + } + + if (!(node = node.parentNode)) { + return; + } + } + + // The backspace was pressed at the start of + // the container so clear the style + base.clearBlockFormatting(parent); + e.preventDefault(); + }; + + /** + * Gets the first styled block node that contains the cursor + * @return {HTMLElement} + */ + currentStyledBlockNode = function () { + var block = currentBlockNode; + + while (!hasStyling(block) || isInline(block, true)) { + if (!(block = block.parentNode) || is(block, 'body')) { + return; + } + } + + return block; + }; + + /** + * Clears the formatting of the passed block element. + * + * If block is false, if will clear the styling of the first + * block level element that contains the cursor. + * @param {HTMLElement} block + * @since 1.4.4 + */ + base.clearBlockFormatting = function (block) { + block = block || currentStyledBlockNode(); + + if (!block || is(block, 'body')) { + return base; + } + + rangeHelper.saveRange(); + + block.className = ''; + + attr(block, 'style', ''); + + if (!is(block, 'p,div,td')) { + convertElement(block, 'p'); + } + + rangeHelper.restoreRange(); + return base; + }; + + /** + * Triggers the valueChanged signal if there is + * a plugin that handles it. + * + * If rangeHelper.saveRange() has already been + * called, then saveRange should be set to false + * to prevent the range being saved twice. + * + * @since 1.4.5 + * @param {boolean} saveRange If to call rangeHelper.saveRange(). + * @private + */ + triggerValueChanged = function (saveRange) { + if (!pluginManager || + (!pluginManager.hasHandler('valuechangedEvent') && + !triggerValueChanged.hasHandler)) { + return; + } + + var currentHtml, + sourceMode = base.sourceMode(), + hasSelection = !sourceMode && rangeHelper.hasSelection(); + + // Composition end isn't guaranteed to fire but must have + // ended when triggerValueChanged() is called so reset it + isComposing = false; + + // Don't need to save the range if sceditor-start-marker + // is present as the range is already saved + saveRange = saveRange !== false && + !wysiwygDocument.getElementById('sceditor-start-marker'); + + // Clear any current timeout as it's now been triggered + if (valueChangedKeyUpTimer) { + clearTimeout(valueChangedKeyUpTimer); + valueChangedKeyUpTimer = false; + } + + if (hasSelection && saveRange) { + rangeHelper.saveRange(); + } + + currentHtml = sourceMode ? sourceEditor.value : wysiwygBody.innerHTML; + + // Only trigger if something has actually changed. + if (currentHtml !== triggerValueChanged.lastVal) { + triggerValueChanged.lastVal = currentHtml; + + trigger(editorContainer, 'valuechanged', { + rawValue: sourceMode ? base.val() : currentHtml + }); + } + + if (hasSelection && saveRange) { + rangeHelper.removeMarkers(); + } + }; + + /** + * Should be called whenever there is a blur event + * @private + */ + valueChangedBlur = function () { + if (valueChangedKeyUpTimer) { + triggerValueChanged(); + } + }; + + /** + * Should be called whenever there is a keypress event + * @param {Event} e The keypress event + * @private + */ + valueChangedKeyUp = function (e) { + var which = e.which, + lastChar = valueChangedKeyUp.lastChar, + lastWasSpace = (lastChar === 13 || lastChar === 32), + lastWasDelete = (lastChar === 8 || lastChar === 46); + + valueChangedKeyUp.lastChar = which; + + if (isComposing) { + return; + } + + // 13 = return & 32 = space + if (which === 13 || which === 32) { + if (!lastWasSpace) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + // 8 = backspace & 46 = del + } else if (which === 8 || which === 46) { + if (!lastWasDelete) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + } else if (valueChangedKeyUp.triggerNext) { + triggerValueChanged(); + valueChangedKeyUp.triggerNext = false; + } + + // Clear the previous timeout and set a new one. + clearTimeout(valueChangedKeyUpTimer); + + // Trigger the event 1.5s after the last keypress if space + // isn't pressed. This might need to be lowered, will need + // to look into what the slowest average Chars Per Min is. + valueChangedKeyUpTimer = setTimeout(function () { + if (!isComposing) { + triggerValueChanged(); + } + }, 1500); + }; + + handleComposition = function (e) { + isComposing = /start/i.test(e.type); + + if (!isComposing) { + triggerValueChanged(); + } + }; + + autoUpdate = function () { + base.updateOriginal(); + }; + + // run the initializer + init(); + } + + /** + * Map containing the loaded SCEditor locales + * @type {Object} + * @name locale + * @memberOf sceditor + */ + SCEditor.locale = {}; + + SCEditor.formats = {}; + SCEditor.icons = {}; + + + /** + * Static command helper class + * @class command + * @name sceditor.command + */ + SCEditor.command = + /** @lends sceditor.command */ + { + /** + * Gets a command + * + * @param {string} name + * @return {Object|null} + * @since v1.3.5 + */ + get: function (name) { + return defaultCmds[name] || null; + }, + + /** + * <p>Adds a command to the editor or updates an existing + * command if a command with the specified name already exists.</p> + * + * <p>Once a command is add it can be included in the toolbar by + * adding it's name to the toolbar option in the constructor. It + * can also be executed manually by calling + * {@link sceditor.execCommand}</p> + * + * @example + * SCEditor.command.set("hello", + * { + * exec: function () { + * alert("Hello World!"); + * } + * }); + * + * @param {string} name + * @param {Object} cmd + * @return {this|false} Returns false if name or cmd is false + * @since v1.3.5 + */ + set: function (name, cmd) { + if (!name || !cmd) { + return false; + } + + // merge any existing command properties + cmd = extend(defaultCmds[name] || {}, cmd); + + cmd.remove = function () { + SCEditor.command.remove(name); + }; + + defaultCmds[name] = cmd; + return this; + }, + + /** + * Removes a command + * + * @param {string} name + * @return {this} + * @since v1.3.5 + */ + remove: function (name) { + if (defaultCmds[name]) { + delete defaultCmds[name]; + } + + return this; + } + }; + + /** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor - A lightweight WYSIWYG BBCode and HTML editor + * @author Sam Clarke + */ + + + window.sceditor = { + command: SCEditor.command, + commands: defaultCmds, + defaultOptions: defaultOptions, + + ios: ios, + isWysiwygSupported: isWysiwygSupported, + + regexEscape: regex, + escapeEntities: entities, + escapeUriScheme: uriScheme, + + dom: { + css: css, + attr: attr, + removeAttr: removeAttr, + is: is, + closest: closest, + width: width, + height: height, + traverse: traverse, + rTraverse: rTraverse, + parseHTML: parseHTML, + hasStyling: hasStyling, + convertElement: convertElement, + blockLevelList: blockLevelList, + canHaveChildren: canHaveChildren, + isInline: isInline, + copyCSS: copyCSS, + fixNesting: fixNesting, + findCommonAncestor: findCommonAncestor, + getSibling: getSibling, + removeWhiteSpace: removeWhiteSpace, + extractContents: extractContents, + getOffset: getOffset, + getStyle: getStyle, + hasStyle: hasStyle + }, + locale: SCEditor.locale, + icons: SCEditor.icons, + utils: { + each: each, + isEmptyObject: isEmptyObject, + extend: extend + }, + plugins: PluginManager.plugins, + formats: SCEditor.formats, + create: function (textarea, options) { + options = options || {}; + + // Don't allow the editor to be initialised + // on it's own source editor + if (parent(textarea, '.sceditor-container')) { + return; + } + + if (options.runWithoutWysiwygSupport || isWysiwygSupported) { + /*eslint no-new: off*/ + (new SCEditor(textarea, options)); + } + }, + instance: function (textarea) { + return textarea._sceditor; + } + }; + + /** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor - A lightweight WYSIWYG BBCode and HTML editor + * @author Sam Clarke + * @requires jQuery + */ + + + // For backwards compatibility + $__default['default'].sceditor = window.sceditor; + + /** + * Creates an instance of sceditor on all textareas + * matched by the jQuery selector. + * + * If options is set to "state" it will return bool value + * indicating if the editor has been initialised on the + * matched textarea(s). If there is only one textarea + * it will return the bool value for that textarea. + * If more than one textarea is matched it will + * return an array of bool values for each textarea. + * + * If options is set to "instance" it will return the + * current editor instance for the textarea(s). Like the + * state option, if only one textarea is matched this will + * return just the instance for that textarea. If more than + * one textarea is matched it will return an array of + * instances each textarea. + * + * @param {Object|string} [options] Should either be an Object of options or + * the strings "state" or "instance" + * @return {this|Array<SCEditor>|Array<boolean>|SCEditor|boolean} + */ + $__default['default'].fn.sceditor = function (options) { + var instance; + var ret = []; + + this.each(function () { + instance = this._sceditor; + + // Add state of instance to ret if that is what options is set to + if (options === 'state') { + ret.push(!!instance); + } else if (options === 'instance') { + ret.push(instance); + } else if (!instance) { + $__default['default'].sceditor.create(this, options); + } + }); + + // If nothing in the ret array then must be init so return this + if (!ret.length) { + return this; + } + + return ret.length === 1 ? ret[0] : ret; + }; + +}(jQuery));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/jquery.sceditor.xhtml.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,10427 @@ +(function ($) { + 'use strict'; + + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var $__default = /*#__PURE__*/_interopDefaultLegacy($); + + /** + * Check if the passed argument is the + * the passed type. + * + * @param {string} type + * @param {*} arg + * @returns {boolean} + */ + function isTypeof(type, arg) { + return typeof arg === type; + } + + /** + * @type {function(*): boolean} + */ + var isString = isTypeof.bind(null, 'string'); + + /** + * @type {function(*): boolean} + */ + var isUndefined = isTypeof.bind(null, 'undefined'); + + /** + * @type {function(*): boolean} + */ + var isFunction = isTypeof.bind(null, 'function'); + + /** + * @type {function(*): boolean} + */ + var isNumber = isTypeof.bind(null, 'number'); + + + /** + * Returns true if an object has no keys + * + * @param {!Object} obj + * @returns {boolean} + */ + function isEmptyObject(obj) { + return !Object.keys(obj).length; + } + + /** + * Extends the first object with any extra objects passed + * + * If the first argument is boolean and set to true + * it will extend child arrays and objects recursively. + * + * @param {!Object|boolean} targetArg + * @param {...Object} source + * @return {Object} + */ + function extend(targetArg, sourceArg) { + var isTargetBoolean = targetArg === !!targetArg; + var i = isTargetBoolean ? 2 : 1; + var target = isTargetBoolean ? sourceArg : targetArg; + var isDeep = isTargetBoolean ? targetArg : false; + + function isObject(value) { + return value !== null && typeof value === 'object' && + Object.getPrototypeOf(value) === Object.prototype; + } + + for (; i < arguments.length; i++) { + var source = arguments[i]; + + // Copy all properties for jQuery compatibility + /* eslint guard-for-in: off */ + for (var key in source) { + var targetValue = target[key]; + var value = source[key]; + + // Skip undefined values to match jQuery + if (isUndefined(value)) { + continue; + } + + // Skip special keys to prevent prototype pollution + if (key === '__proto__' || key === 'constructor') { + continue; + } + + var isValueObject = isObject(value); + var isValueArray = Array.isArray(value); + + if (isDeep && (isValueObject || isValueArray)) { + // Can only merge if target type matches otherwise create + // new target to merge into + var isSameType = isObject(targetValue) === isValueObject && + Array.isArray(targetValue) === isValueArray; + + target[key] = extend( + true, + isSameType ? targetValue : (isValueArray ? [] : {}), + value + ); + } else { + target[key] = value; + } + } + } + + return target; + } + + /** + * Removes an item from the passed array + * + * @param {!Array} arr + * @param {*} item + */ + function arrayRemove(arr, item) { + var i = arr.indexOf(item); + + if (i > -1) { + arr.splice(i, 1); + } + } + + /** + * Iterates over an array or object + * + * @param {!Object|Array} obj + * @param {function(*, *)} fn + */ + function each(obj, fn) { + if (Array.isArray(obj) || 'length' in obj && isNumber(obj.length)) { + for (var i = 0; i < obj.length; i++) { + fn(i, obj[i]); + } + } else { + Object.keys(obj).forEach(function (key) { + fn(key, obj[key]); + }); + } + } + + /** + * Cache of camelCase CSS property names + * @type {Object<string, string>} + */ + var cssPropertyNameCache = {}; + + /** + * Node type constant for element nodes + * + * @type {number} + */ + var ELEMENT_NODE = 1; + + /** + * Node type constant for text nodes + * + * @type {number} + */ + var TEXT_NODE = 3; + + /** + * Node type constant for comment nodes + * + * @type {number} + */ + var COMMENT_NODE = 8; + + function toFloat(value) { + value = parseFloat(value); + + return isFinite(value) ? value : 0; + } + + /** + * Creates an element with the specified attributes + * + * Will create it in the current document unless context + * is specified. + * + * @param {!string} tag + * @param {!Object<string, string>} [attributes] + * @param {!Document} [context] + * @returns {!HTMLElement} + */ + function createElement(tag, attributes, context) { + var node = (context || document).createElement(tag); + + each(attributes || {}, function (key, value) { + if (key === 'style') { + node.style.cssText = value; + } else if (key in node) { + node[key] = value; + } else { + node.setAttribute(key, value); + } + }); + + return node; + } + + /** + * Gets the first parent node that matches the selector + * + * @param {!HTMLElement} node + * @param {!string} [selector] + * @returns {HTMLElement|undefined} + */ + function parent(node, selector) { + var parent = node || {}; + + while ((parent = parent.parentNode) && !/(9|11)/.test(parent.nodeType)) { + if (!selector || is(parent, selector)) { + return parent; + } + } + } + + /** + * Checks the passed node and all parents and + * returns the first matching node if any. + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {HTMLElement|undefined} + */ + function closest(node, selector) { + return is(node, selector) ? node : parent(node, selector); + } + + /** + * Removes the node from the DOM + * + * @param {!HTMLElement} node + */ + function remove(node) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + } + + /** + * Appends child to parent node + * + * @param {!HTMLElement} node + * @param {!HTMLElement} child + */ + function appendChild(node, child) { + node.appendChild(child); + } + + /** + * Finds any child nodes that match the selector + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {NodeList} + */ + function find(node, selector) { + return node.querySelectorAll(selector); + } + + /** + * For on() and off() if to add/remove the event + * to the capture phase + * + * @type {boolean} + */ + var EVENT_CAPTURE = true; + + /** + * Adds an event listener for the specified events. + * + * Events should be a space separated list of events. + * + * If selector is specified the handler will only be + * called when the event target matches the selector. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see off() + */ + // eslint-disable-next-line max-params + function on(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector] || function (e) { + var target = e.target; + while (target && target !== node) { + if (is(target, selector)) { + fn.call(target, e); + return; + } + + target = target.parentNode; + } + }; + + fn['_sce-event-' + event + selector] = handler; + } else { + handler = selector; + capture = fn; + } + + node.addEventListener(event, handler, capture || false); + }); + } + + /** + * Removes an event listener for the specified events. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see on() + */ + // eslint-disable-next-line max-params + function off(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector]; + } else { + handler = selector; + capture = fn; + } + + node.removeEventListener(event, handler, capture || false); + }); + } + + /** + * If only attr param is specified it will get + * the value of the attr param. + * + * If value is specified but null the attribute + * will be removed otherwise the attr value will + * be set to the passed value. + * + * @param {!HTMLElement} node + * @param {!string} attr + * @param {?string} [value] + */ + function attr(node, attr, value) { + if (arguments.length < 3) { + return node.getAttribute(attr); + } + + // eslint-disable-next-line eqeqeq, no-eq-null + if (value == null) { + removeAttr(node, attr); + } else { + node.setAttribute(attr, value); + } + } + + /** + * Removes the specified attribute + * + * @param {!HTMLElement} node + * @param {!string} attr + */ + function removeAttr(node, attr) { + node.removeAttribute(attr); + } + + /** + * Sets the passed elements display to none + * + * @param {!HTMLElement} node + */ + function hide(node) { + css(node, 'display', 'none'); + } + + /** + * Sets the passed elements display to default + * + * @param {!HTMLElement} node + */ + function show(node) { + css(node, 'display', ''); + } + + /** + * Toggles an elements visibility + * + * @param {!HTMLElement} node + */ + function toggle(node) { + if (isVisible(node)) { + hide(node); + } else { + show(node); + } + } + + /** + * Gets a computed CSS values or sets an inline CSS value + * + * Rules should be in camelCase format and not + * hyphenated like CSS properties. + * + * @param {!HTMLElement} node + * @param {!Object|string} rule + * @param {string|number} [value] + * @return {string|number|undefined} + */ + function css(node, rule, value) { + if (arguments.length < 3) { + if (isString(rule)) { + return node.nodeType === 1 ? getComputedStyle(node)[rule] : null; + } + + each(rule, function (key, value) { + css(node, key, value); + }); + } else { + // isNaN returns false for null, false and empty strings + // so need to check it's truthy or 0 + var isNumeric = (value || value === 0) && !isNaN(value); + node.style[rule] = isNumeric ? value + 'px' : value; + } + } + + + /** + * Gets or sets the data attributes on a node + * + * Unlike the jQuery version this only stores data + * in the DOM attributes which means only strings + * can be stored. + * + * @param {Node} node + * @param {string} [key] + * @param {string} [value] + * @return {Object|undefined} + */ + function data(node, key, value) { + var argsLength = arguments.length; + var data = {}; + + if (node.nodeType === ELEMENT_NODE) { + if (argsLength === 1) { + each(node.attributes, function (_, attr) { + if (/^data\-/i.test(attr.name)) { + data[attr.name.substr(5)] = attr.value; + } + }); + + return data; + } + + if (argsLength === 2) { + return attr(node, 'data-' + key); + } + + attr(node, 'data-' + key, String(value)); + } + } + + /** + * Checks if node matches the given selector. + * + * @param {?HTMLElement} node + * @param {string} selector + * @returns {boolean} + */ + function is(node, selector) { + var result = false; + + if (node && node.nodeType === ELEMENT_NODE) { + result = (node.matches || node.msMatchesSelector || + node.webkitMatchesSelector).call(node, selector); + } + + return result; + } + + + /** + * Returns true if node contains child otherwise false. + * + * This differs from the DOM contains() method in that + * if node and child are equal this will return false. + * + * @param {!Node} node + * @param {HTMLElement} child + * @returns {boolean} + */ + function contains(node, child) { + return node !== child && node.contains && node.contains(child); + } + + /** + * @param {Node} node + * @param {string} [selector] + * @returns {?HTMLElement} + */ + function previousElementSibling(node, selector) { + var prev = node.previousElementSibling; + + if (selector && prev) { + return is(prev, selector) ? prev : null; + } + + return prev; + } + + /** + * @param {!Node} node + * @param {!Node} refNode + * @returns {Node} + */ + function insertBefore(node, refNode) { + return refNode.parentNode.insertBefore(node, refNode); + } + + /** + * @param {?HTMLElement} node + * @returns {!Array.<string>} + */ + function classes(node) { + return node.className.trim().split(/\s+/); + } + + /** + * @param {?HTMLElement} node + * @param {string} className + * @returns {boolean} + */ + function hasClass(node, className) { + return is(node, '.' + className); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function addClass(node, className) { + var classList = classes(node); + + if (classList.indexOf(className) < 0) { + classList.push(className); + } + + node.className = classList.join(' '); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function removeClass(node, className) { + var classList = classes(node); + + arrayRemove(classList, className); + + node.className = classList.join(' '); + } + + /** + * Toggles a class on node. + * + * If state is specified and is truthy it will add + * the class. + * + * If state is specified and is falsey it will remove + * the class. + * + * @param {HTMLElement} node + * @param {string} className + * @param {boolean} [state] + */ + function toggleClass(node, className, state) { + state = isUndefined(state) ? !hasClass(node, className) : state; + + if (state) { + addClass(node, className); + } else { + removeClass(node, className); + } + } + + /** + * Gets or sets the width of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function width(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingLeft) + toFloat(cs.paddingRight); + var border = toFloat(cs.borderLeftWidth) + toFloat(cs.borderRightWidth); + + return node.offsetWidth - padding - border; + } + + css(node, 'width', value); + } + + /** + * Gets or sets the height of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function height(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingTop) + toFloat(cs.paddingBottom); + var border = toFloat(cs.borderTopWidth) + toFloat(cs.borderBottomWidth); + + return node.offsetHeight - padding - border; + } + + css(node, 'height', value); + } + + /** + * Triggers a custom event with the specified name and + * sets the detail property to the data object passed. + * + * @param {HTMLElement} node + * @param {string} eventName + * @param {Object} [data] + */ + function trigger(node, eventName, data) { + var event; + + if (isFunction(window.CustomEvent)) { + event = new CustomEvent(eventName, { + bubbles: true, + cancelable: true, + detail: data + }); + } else { + event = node.ownerDocument.createEvent('CustomEvent'); + event.initCustomEvent(eventName, true, true, data); + } + + node.dispatchEvent(event); + } + + /** + * Returns if a node is visible. + * + * @param {HTMLElement} + * @returns {boolean} + */ + function isVisible(node) { + return !!node.getClientRects().length; + } + + /** + * Convert CSS property names into camel case + * + * @param {string} string + * @returns {string} + */ + function camelCase(string) { + return string + .replace(/^-ms-/, 'ms-') + .replace(/-(\w)/g, function (match, char) { + return char.toUpperCase(); + }); + } + + + /** + * Loop all child nodes of the passed node + * + * The function should accept 1 parameter being the node. + * If the function returns false the loop will be exited. + * + * @param {HTMLElement} node + * @param {function} func Callback which is called with every + * child node as the first argument. + * @param {boolean} innermostFirst If the innermost node should be passed + * to the function before it's parents. + * @param {boolean} siblingsOnly If to only traverse the nodes siblings + * @param {boolean} [reverse=false] If to traverse the nodes in reverse + */ + // eslint-disable-next-line max-params + function traverse(node, func, innermostFirst, siblingsOnly, reverse) { + node = reverse ? node.lastChild : node.firstChild; + + while (node) { + var next = reverse ? node.previousSibling : node.nextSibling; + + if ( + (!innermostFirst && func(node) === false) || + (!siblingsOnly && traverse( + node, func, innermostFirst, siblingsOnly, reverse + ) === false) || + (innermostFirst && func(node) === false) + ) { + return false; + } + + node = next; + } + } + + /** + * Like traverse but loops in reverse + * @see traverse + */ + function rTraverse(node, func, innermostFirst, siblingsOnly) { + traverse(node, func, innermostFirst, siblingsOnly, true); + } + + /** + * Parses HTML into a document fragment + * + * @param {string} html + * @param {Document} [context] + * @since 1.4.4 + * @return {DocumentFragment} + */ + function parseHTML(html, context) { + context = context || document; + + var ret = context.createDocumentFragment(); + var tmp = createElement('div', {}, context); + + tmp.innerHTML = html; + + while (tmp.firstChild) { + appendChild(ret, tmp.firstChild); + } + + return ret; + } + + /** + * Checks if an element has any styling. + * + * It has styling if it is not a plain <div> or <p> or + * if it has a class, style attribute or data. + * + * @param {HTMLElement} elm + * @return {boolean} + * @since 1.4.4 + */ + function hasStyling(node) { + return node && (!is(node, 'p,div') || node.className || + attr(node, 'style') || !isEmptyObject(data(node))); + } + + /** + * Converts an element from one type to another. + * + * For example it can convert the element <b> to <strong> + * + * @param {HTMLElement} element + * @param {string} toTagName + * @return {HTMLElement} + * @since 1.4.4 + */ + function convertElement(element, toTagName) { + var newElement = createElement(toTagName, {}, element.ownerDocument); + + each(element.attributes, function (_, attribute) { + // Some browsers parse invalid attributes names like + // 'size"2' which throw an exception when set, just + // ignore these. + try { + attr(newElement, attribute.name, attribute.value); + } catch (ex) {} + }); + + while (element.firstChild) { + appendChild(newElement, element.firstChild); + } + + element.parentNode.replaceChild(newElement, element); + + return newElement; + } + + /** + * List of block level elements separated by bars (|) + * + * @type {string} + */ + var blockLevelList = '|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|' + + 'form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|' + + 'details|section|article|aside|nav|main|header|hgroup|footer|fieldset|' + + 'dl|dt|dd|figure|figcaption|'; + + /** + * List of elements that do not allow children separated by bars (|) + * + * @param {Node} node + * @return {boolean} + * @since 1.4.5 + */ + function canHaveChildren(node) { + // 1 = Element + // 9 = Document + // 11 = Document Fragment + if (!/11?|9/.test(node.nodeType)) { + return false; + } + + // List of empty HTML tags separated by bar (|) character. + // Source: http://www.w3.org/TR/html4/index/elements.html + // Source: http://www.w3.org/TR/html5/syntax.html#void-elements + return ('|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr' + + '|isindex|link|meta|param|command|embed|keygen|source|track|' + + 'object|').indexOf('|' + node.nodeName.toLowerCase() + '|') < 0; + } + + /** + * Checks if an element is inline + * + * @param {HTMLElement} elm + * @param {boolean} [includeCodeAsBlock=false] + * @return {boolean} + */ + function isInline(elm, includeCodeAsBlock) { + var tagName, + nodeType = (elm || {}).nodeType || TEXT_NODE; + + if (nodeType !== ELEMENT_NODE) { + return nodeType === TEXT_NODE; + } + + tagName = elm.tagName.toLowerCase(); + + if (tagName === 'code') { + return !includeCodeAsBlock; + } + + return blockLevelList.indexOf('|' + tagName + '|') < 0; + } + + /** + * Copy the CSS from 1 node to another. + * + * Only copies CSS defined on the element e.g. style attr. + * + * @param {HTMLElement} from + * @param {HTMLElement} to + * @deprecated since v3.1.0 + */ + function copyCSS(from, to) { + if (to.style && from.style) { + to.style.cssText = from.style.cssText + to.style.cssText; + } + } + + /** + * Checks if a DOM node is empty + * + * @param {Node} node + * @returns {boolean} + */ + function isEmpty(node) { + if (node.lastChild && isEmpty(node.lastChild)) { + remove(node.lastChild); + } + + return node.nodeType === 3 ? !node.nodeValue : + (canHaveChildren(node) && !node.childNodes.length); + } + + /** + * Fixes block level elements inside in inline elements. + * + * Also fixes invalid list nesting by placing nested lists + * inside the previous li tag or wrapping them in an li tag. + * + * @param {HTMLElement} node + */ + function fixNesting(node) { + traverse(node, function (node) { + var list = 'ul,ol', + isBlock = !isInline(node, true) && node.nodeType !== COMMENT_NODE, + parent = node.parentNode; + + // Any blocklevel element inside an inline element needs fixing. + // Also <p> tags that contain blocks should be fixed + if (isBlock && (isInline(parent, true) || parent.tagName === 'P')) { + // Find the last inline parent node + var lastInlineParent = node; + while (isInline(lastInlineParent.parentNode, true) || + lastInlineParent.parentNode.tagName === 'P') { + lastInlineParent = lastInlineParent.parentNode; + } + + var before = extractContents(lastInlineParent, node); + var middle = node; + + // Clone inline styling and apply it to the blocks children + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + while (middle.firstChild) { + appendChild(clone, middle.firstChild); + } + + appendChild(middle, clone); + } + parent = parent.parentNode; + } + + insertBefore(middle, lastInlineParent); + if (!isEmpty(before)) { + insertBefore(before, middle); + } + if (isEmpty(lastInlineParent)) { + remove(lastInlineParent); + } + } + + // Fix invalid nested lists which should be wrapped in an li tag + if (isBlock && is(node, list) && is(node.parentNode, list)) { + var li = previousElementSibling(node, 'li'); + + if (!li) { + li = createElement('li'); + insertBefore(li, node); + } + + appendChild(li, node); + } + }); + } + + /** + * Finds the common parent of two nodes + * + * @param {!HTMLElement} node1 + * @param {!HTMLElement} node2 + * @return {?HTMLElement} + */ + function findCommonAncestor(node1, node2) { + while ((node1 = node1.parentNode)) { + if (contains(node1, node2)) { + return node1; + } + } + } + + /** + * @param {?Node} + * @param {boolean} [previous=false] + * @returns {?Node} + */ + function getSibling(node, previous) { + if (!node) { + return null; + } + + return (previous ? node.previousSibling : node.nextSibling) || + getSibling(node.parentNode, previous); + } + + /** + * Removes unused whitespace from the root and all it's children. + * + * @param {!HTMLElement} root + * @since 1.4.3 + */ + function removeWhiteSpace(root) { + var nodeValue, nodeType, next, previous, previousSibling, + nextNode, trimStart, + cssWhiteSpace = css(root, 'whiteSpace'), + // Preserve newlines if is pre-line + preserveNewLines = /line$/i.test(cssWhiteSpace), + node = root.firstChild; + + // Skip pre & pre-wrap with any vendor prefix + if (/pre(\-wrap)?$/i.test(cssWhiteSpace)) { + return; + } + + while (node) { + nextNode = node.nextSibling; + nodeValue = node.nodeValue; + nodeType = node.nodeType; + + if (nodeType === ELEMENT_NODE && node.firstChild) { + removeWhiteSpace(node); + } + + if (nodeType === TEXT_NODE) { + next = getSibling(node); + previous = getSibling(node, true); + trimStart = false; + + while (hasClass(previous, 'sceditor-ignore')) { + previous = getSibling(previous, true); + } + + // If previous sibling isn't inline or is a textnode that + // ends in whitespace, time the start whitespace + if (isInline(node) && previous) { + previousSibling = previous; + + while (previousSibling.lastChild) { + previousSibling = previousSibling.lastChild; + + // eslint-disable-next-line max-depth + while (hasClass(previousSibling, 'sceditor-ignore')) { + previousSibling = getSibling(previousSibling, true); + } + } + + trimStart = previousSibling.nodeType === TEXT_NODE ? + /[\t\n\r ]$/.test(previousSibling.nodeValue) : + !isInline(previousSibling); + } + + // Clear zero width spaces + nodeValue = nodeValue.replace(/\u200B/g, ''); + + // Strip leading whitespace + if (!previous || !isInline(previous) || trimStart) { + nodeValue = nodeValue.replace( + preserveNewLines ? /^[\t ]+/ : /^[\t\n\r ]+/, + '' + ); + } + + // Strip trailing whitespace + if (!next || !isInline(next)) { + nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+$/ : /[\t\n\r ]+$/, + '' + ); + } + + // Remove empty text nodes + if (!nodeValue.length) { + remove(node); + } else { + node.nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+/g : /[\t\n\r ]+/g, + ' ' + ); + } + } + + node = nextNode; + } + } + + /** + * Extracts all the nodes between the start and end nodes + * + * @param {HTMLElement} startNode The node to start extracting at + * @param {HTMLElement} endNode The node to stop extracting at + * @return {DocumentFragment} + */ + function extractContents(startNode, endNode) { + var range = startNode.ownerDocument.createRange(); + + range.setStartBefore(startNode); + range.setEndAfter(endNode); + + return range.extractContents(); + } + + /** + * Gets the offset position of an element + * + * @param {HTMLElement} node + * @return {Object} An object with left and top properties + */ + function getOffset(node) { + var left = 0, + top = 0; + + while (node) { + left += node.offsetLeft; + top += node.offsetTop; + node = node.offsetParent; + } + + return { + left: left, + top: top + }; + } + + /** + * Gets the value of a CSS property from the elements style attribute + * + * @param {HTMLElement} elm + * @param {string} property + * @return {string} + */ + function getStyle(elm, property) { + var styleValue, + elmStyle = elm.style; + + if (!cssPropertyNameCache[property]) { + cssPropertyNameCache[property] = camelCase(property); + } + + property = cssPropertyNameCache[property]; + styleValue = elmStyle[property]; + + // Add an exception for text-align + if ('textAlign' === property) { + styleValue = styleValue || css(elm, property); + + if (css(elm.parentNode, property) === styleValue || + css(elm, 'display') !== 'block' || is(elm, 'hr,th')) { + return ''; + } + } + + return styleValue; + } + + /** + * Tests if an element has a style. + * + * If values are specified it will check that the styles value + * matches one of the values + * + * @param {HTMLElement} elm + * @param {string} property + * @param {string|array} [values] + * @return {boolean} + */ + function hasStyle(elm, property, values) { + var styleValue = getStyle(elm, property); + + if (!styleValue) { + return false; + } + + return !values || styleValue === values || + (Array.isArray(values) && values.indexOf(styleValue) > -1); + } + + /** + * Returns true if both nodes have the same number of inline styles and all the + * inline styles have matching values + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function stylesMatch(nodeA, nodeB) { + var i = nodeA.style.length; + if (i !== nodeB.style.length) { + return false; + } + + while (i--) { + var prop = nodeA.style[i]; + if (nodeA.style[prop] !== nodeB.style[prop]) { + return false; + } + } + + return true; + } + + /** + * Returns true if both nodes have the same number of attributes and all the + * attribute values match + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function attributesMatch(nodeA, nodeB) { + var i = nodeA.attributes.length; + if (i !== nodeB.attributes.length) { + return false; + } + + while (i--) { + var prop = nodeA.attributes[i]; + var notMatches = prop.name === 'style' ? + !stylesMatch(nodeA, nodeB) : + prop.value !== attr(nodeB, prop.name); + + if (notMatches) { + return false; + } + } + + return true; + } + + /** + * Removes an element placing its children in its place + * + * @param {HTMLElement} node + */ + function removeKeepChildren(node) { + while (node.firstChild) { + insertBefore(node.firstChild, node); + } + + remove(node); + } + + /** + * Merges inline styles and tags with parents where possible + * + * @param {Node} node + * @since 3.1.0 + */ + function merge(node) { + if (node.nodeType !== ELEMENT_NODE) { + return; + } + + var parent = node.parentNode; + var tagName = node.tagName; + var mergeTags = /B|STRONG|EM|SPAN|FONT/; + + // Merge children (in reverse as children can be removed) + var i = node.childNodes.length; + while (i--) { + merge(node.childNodes[i]); + } + + // Should only merge inline tags + if (!isInline(node)) { + return; + } + + // Remove any inline styles that match the parent style + i = node.style.length; + while (i--) { + var prop = node.style[i]; + if (css(parent, prop) === css(node, prop)) { + node.style.removeProperty(prop); + } + } + + // Can only remove / merge tags if no inline styling left. + // If there is any inline style left then it means it at least partially + // doesn't match the parent style so must stay + if (!node.style.length) { + removeAttr(node, 'style'); + + // Remove font attributes if match parent + if (tagName === 'FONT') { + if (css(node, 'fontFamily').toLowerCase() === + css(parent, 'fontFamily').toLowerCase()) { + removeAttr(node, 'face'); + } + + if (css(node, 'color') === css(parent, 'color')) { + removeAttr(node, 'color'); + } + + if (css(node, 'fontSize') === css(parent, 'fontSize')) { + removeAttr(node, 'size'); + } + } + + // Spans and font tags with no attributes can be safely removed + if (!node.attributes.length && /SPAN|FONT/.test(tagName)) { + removeKeepChildren(node); + } else if (mergeTags.test(tagName)) { + var isBold = /B|STRONG/.test(tagName); + var isItalic = tagName === 'EM'; + + while (parent && isInline(parent) && + (!isBold || /bold|700/i.test(css(parent, 'fontWeight'))) && + (!isItalic || css(parent, 'fontStyle') === 'italic')) { + + // Remove if parent match + if ((parent.tagName === tagName || + (isBold && /B|STRONG/.test(parent.tagName))) && + attributesMatch(parent, node)) { + removeKeepChildren(node); + break; + } + + parent = parent.parentNode; + } + } + } + + // Merge siblings if attributes, including inline styles, match + var next = node.nextSibling; + if (next && next.tagName === tagName && attributesMatch(next, node)) { + appendChild(node, next); + removeKeepChildren(next); + } + } + + /** + * Default options for SCEditor + * @type {Object} + */ + var defaultOptions = { + /** @lends jQuery.sceditor.defaultOptions */ + /** + * Toolbar buttons order and groups. Should be comma separated and + * have a bar | to separate groups + * + * @type {string} + */ + toolbar: 'bold,italic,underline,strike,subscript,superscript|' + + 'left,center,right,justify|font,size,color,removeformat|' + + 'cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|' + + 'table|code,quote|horizontalrule,image,email,link,unlink|' + + 'emoticon,youtube,date,time|ltr,rtl|print,maximize,source', + + /** + * Comma separated list of commands to excludes from the toolbar + * + * @type {string} + */ + toolbarExclude: null, + + /** + * Stylesheet to include in the WYSIWYG editor. This is what will style + * the WYSIWYG elements + * + * @type {string} + */ + style: 'jquery.sceditor.default.css', + + /** + * Comma separated list of fonts for the font selector + * + * @type {string} + */ + fonts: 'Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,' + + 'Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana', + + /** + * Colors should be comma separated and have a bar | to signal a new + * column. + * + * If null the colors will be auto generated. + * + * @type {string} + */ + colors: '#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|' + + '#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|' + + '#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|' + + '#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|' + + '#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|' + + '#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|' + + '#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|' + + '#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef', + + /** + * The locale to use. + * @type {string} + */ + locale: attr(document.documentElement, 'lang') || 'en', + + /** + * The Charset to use + * @type {string} + */ + charset: 'utf-8', + + /** + * Compatibility mode for emoticons. + * + * Helps if you have emoticons such as :/ which would put an emoticon + * inside http:// + * + * This mode requires emoticons to be surrounded by whitespace or end of + * line chars. This mode has limited As You Type emoticon conversion + * support. It will not replace AYT for end of line chars, only + * emoticons surrounded by whitespace. They will still be replaced + * correctly when loaded just not AYT. + * + * @type {boolean} + */ + emoticonsCompat: false, + + /** + * If to enable emoticons. Can be changes at runtime using the + * emoticons() method. + * + * @type {boolean} + * @since 1.4.2 + */ + emoticonsEnabled: true, + + /** + * Emoticon root URL + * + * @type {string} + */ + emoticonsRoot: '', + emoticons: { + dropdown: { + ':)': 'emoticons/smile.png', + ':angel:': 'emoticons/angel.png', + ':angry:': 'emoticons/angry.png', + '8-)': 'emoticons/cool.png', + ':\'(': 'emoticons/cwy.png', + ':ermm:': 'emoticons/ermm.png', + ':D': 'emoticons/grin.png', + '<3': 'emoticons/heart.png', + ':(': 'emoticons/sad.png', + ':O': 'emoticons/shocked.png', + ':P': 'emoticons/tongue.png', + ';)': 'emoticons/wink.png' + }, + more: { + ':alien:': 'emoticons/alien.png', + ':blink:': 'emoticons/blink.png', + ':blush:': 'emoticons/blush.png', + ':cheerful:': 'emoticons/cheerful.png', + ':devil:': 'emoticons/devil.png', + ':dizzy:': 'emoticons/dizzy.png', + ':getlost:': 'emoticons/getlost.png', + ':happy:': 'emoticons/happy.png', + ':kissing:': 'emoticons/kissing.png', + ':ninja:': 'emoticons/ninja.png', + ':pinch:': 'emoticons/pinch.png', + ':pouty:': 'emoticons/pouty.png', + ':sick:': 'emoticons/sick.png', + ':sideways:': 'emoticons/sideways.png', + ':silly:': 'emoticons/silly.png', + ':sleeping:': 'emoticons/sleeping.png', + ':unsure:': 'emoticons/unsure.png', + ':woot:': 'emoticons/w00t.png', + ':wassat:': 'emoticons/wassat.png' + }, + hidden: { + ':whistling:': 'emoticons/whistling.png', + ':love:': 'emoticons/wub.png' + } + }, + + /** + * Width of the editor. Set to null for automatic with + * + * @type {?number} + */ + width: null, + + /** + * Height of the editor including toolbar. Set to null for automatic + * height + * + * @type {?number} + */ + height: null, + + /** + * If to allow the editor to be resized + * + * @type {boolean} + */ + resizeEnabled: true, + + /** + * Min resize to width, set to null for half textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinWidth: null, + /** + * Min resize to height, set to null for half textarea height or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinHeight: null, + /** + * Max resize to height, set to null for double textarea height or -1 + * for unlimited + * + * @type {?number} + */ + resizeMaxHeight: null, + /** + * Max resize to width, set to null for double textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMaxWidth: null, + /** + * If resizing by height is enabled + * + * @type {boolean} + */ + resizeHeight: true, + /** + * If resizing by width is enabled + * + * @type {boolean} + */ + resizeWidth: true, + + /** + * Date format, will be overridden if locale specifies one. + * + * The words year, month and day will be replaced with the users current + * year, month and day. + * + * @type {string} + */ + dateFormat: 'year-month-day', + + /** + * Element to inset the toolbar into. + * + * @type {HTMLElement} + */ + toolbarContainer: null, + + /** + * If to enable paste filtering. This is currently experimental, please + * report any issues. + * + * @type {boolean} + */ + enablePasteFiltering: false, + + /** + * If to completely disable pasting into the editor + * + * @type {boolean} + */ + disablePasting: false, + + /** + * If the editor is read only. + * + * @type {boolean} + */ + readOnly: false, + + /** + * If to set the editor to right-to-left mode. + * + * If set to null the direction will be automatically detected. + * + * @type {boolean} + */ + rtl: false, + + /** + * If to auto focus the editor on page load + * + * @type {boolean} + */ + autofocus: false, + + /** + * If to auto focus the editor to the end of the content + * + * @type {boolean} + */ + autofocusEnd: true, + + /** + * If to auto expand the editor to fix the content + * + * @type {boolean} + */ + autoExpand: false, + + /** + * If to auto update original textbox on blur + * + * @type {boolean} + */ + autoUpdate: false, + + /** + * If to enable the browsers built in spell checker + * + * @type {boolean} + */ + spellcheck: true, + + /** + * If to run the source editor when there is no WYSIWYG support. Only + * really applies to mobile OS's. + * + * @type {boolean} + */ + runWithoutWysiwygSupport: false, + + /** + * If to load the editor in source mode and still allow switching + * between WYSIWYG and source mode + * + * @type {boolean} + */ + startInSourceMode: false, + + /** + * Optional ID to give the editor. + * + * @type {string} + */ + id: null, + + /** + * Comma separated list of plugins + * + * @type {string} + */ + plugins: '', + + /** + * z-index to set the editor container to. Needed for jQuery UI dialog. + * + * @type {?number} + */ + zIndex: null, + + /** + * If to trim the BBCode. Removes any spaces at the start and end of the + * BBCode string. + * + * @type {boolean} + */ + bbcodeTrim: false, + + /** + * If to disable removing block level elements by pressing backspace at + * the start of them + * + * @type {boolean} + */ + disableBlockRemove: false, + + /** + * Array of allowed URL (should be either strings or regex) for iframes. + * + * If it's a string then iframes where the start of the src matches the + * specified string will be allowed. + * + * If it's a regex then iframes where the src matches the regex will be + * allowed. + * + * @type {Array} + */ + allowedIframeUrls: [], + + /** + * BBCode parser options, only applies if using the editor in BBCode + * mode. + * + * See SCEditor.BBCodeParser.defaults for list of valid options + * + * @type {Object} + */ + parserOptions: { }, + + /** + * CSS that will be added to the to dropdown menu (eg. z-index) + * + * @type {Object} + */ + dropDownCss: { } + }; + + // Must start with a valid scheme + // ^ + // Schemes that are considered safe + // (https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):| + // Relative schemes (//:) are considered safe + // (\\/\\/)| + // Image data URI's are considered safe + // data:image\\/(png|bmp|gif|p?jpe?g); + var VALID_SCHEME_REGEX = + /^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i; + + /** + * Escapes a string so it's safe to use in regex + * + * @param {string} str + * @return {string} + */ + function regex(str) { + return str.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'); + } + /** + * Escapes all HTML entities in a string + * + * If noQuotes is set to false, all single and double + * quotes will also be escaped + * + * @param {string} str + * @param {boolean} [noQuotes=true] + * @return {string} + * @since 1.4.1 + */ + function entities(str, noQuotes) { + if (!str) { + return str; + } + + var replacements = { + '&': '&', + '<': '<', + '>': '>', + ' ': ' ', + '\r\n': '<br />', + '\r': '<br />', + '\n': '<br />' + }; + + if (noQuotes !== false) { + replacements['"'] = '"'; + replacements['\''] = '''; + replacements['`'] = '`'; + } + + str = str.replace(/ {2}|\r\n|[&<>\r\n'"`]/g, function (match) { + return replacements[match] || match; + }); + + return str; + } + /** + * Escape URI scheme. + * + * Appends the current URL to a url if it has a scheme that is not: + * + * http + * https + * sftp + * ftp + * mailto + * spotify + * skype + * ssh + * teamspeak + * tel + * // + * data:image/(png|jpeg|jpg|pjpeg|bmp|gif); + * + * **IMPORTANT**: This does not escape any HTML in a url, for + * that use the escape.entities() method. + * + * @param {string} url + * @return {string} + * @since 1.4.5 + */ + function uriScheme(url) { + var path, + // If there is a : before a / then it has a scheme + hasScheme = /^[^\/]*:/i, + location = window.location; + + // Has no scheme or a valid scheme + if ((!url || !hasScheme.test(url)) || VALID_SCHEME_REGEX.test(url)) { + return url; + } + + path = location.pathname.split('/'); + path.pop(); + + return location.protocol + '//' + + location.host + + path.join('/') + '/' + + url; + } + + /** + * HTML templates used by the editor and default commands + * @type {Object} + * @private + */ + var _templates = { + html: + '<!DOCTYPE html>' + + '<html{attrs}>' + + '<head>' + + '<meta http-equiv="Content-Type" ' + + 'content="text/html;charset={charset}" />' + + '<link rel="stylesheet" type="text/css" href="{style}" />' + + '</head>' + + '<body contenteditable="true" {spellcheck}><p></p></body>' + + '</html>', + + toolbarButton: '<a class="sceditor-button sceditor-button-{name}" ' + + 'data-sceditor-command="{name}" unselectable="on">' + + '<div unselectable="on">{dispName}</div></a>', + + emoticon: '<img src="{url}" data-sceditor-emoticon="{key}" ' + + 'alt="{key}" title="{tooltip}" />', + + fontOpt: '<a class="sceditor-font-option" href="#" ' + + 'data-font="{font}"><font face="{font}">{font}</font></a>', + + sizeOpt: '<a class="sceditor-fontsize-option" data-size="{size}" ' + + 'href="#"><font size="{size}">{size}</font></a>', + + pastetext: + '<div><label for="txt">{label}</label> ' + + '<textarea cols="20" rows="7" id="txt"></textarea></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + table: + '<div><label for="rows">{rows}</label><input type="text" ' + + 'id="rows" value="2" /></div>' + + '<div><label for="cols">{cols}</label><input type="text" ' + + 'id="cols" value="2" /></div>' + + '<div><input type="button" class="button" value="{insert}"' + + ' /></div>', + + image: + '<div><label for="image">{url}</label> ' + + '<input type="text" id="image" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="width">{width}</label> ' + + '<input type="text" id="width" size="2" dir="ltr" /></div>' + + '<div><label for="height">{height}</label> ' + + '<input type="text" id="height" size="2" dir="ltr" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + email: + '<div><label for="email">{label}</label> ' + + '<input type="text" id="email" dir="ltr" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + link: + '<div><label for="link">{url}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{ins}" /></div>', + + youtubeMenu: + '<div><label for="link">{label}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + youtube: + '<iframe width="560" height="315" frameborder="0" allowfullscreen ' + + 'src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" ' + + 'data-youtube-id="{id}"></iframe>' + }; + + /** + * Replaces any params in a template with the passed params. + * + * If createHtml is passed it will return a DocumentFragment + * containing the parsed template. + * + * @param {string} name + * @param {Object} [params] + * @param {boolean} [createHtml] + * @returns {string|DocumentFragment} + * @private + */ + function _tmpl (name, params, createHtml) { + var template = _templates[name]; + + Object.keys(params).forEach(function (name) { + template = template.replace( + new RegExp(regex('{' + name + '}'), 'g'), params[name] + ); + }); + + if (createHtml) { + template = parseHTML(template); + } + + return template; + } + + /** + * Fixes a bug in FF where it sometimes wraps + * new lines in their own list item. + * See issue #359 + */ + function fixFirefoxListBug(editor) { + // Only apply to Firefox as will break other browsers. + if ('mozHidden' in document) { + var node = editor.getBody(); + var next; + + while (node) { + next = node; + + if (next.firstChild) { + next = next.firstChild; + } else { + + while (next && !next.nextSibling) { + next = next.parentNode; + } + + if (next) { + next = next.nextSibling; + } + } + + if (node.nodeType === 3 && /[\n\r\t]+/.test(node.nodeValue)) { + // Only remove if newlines are collapsed + if (!/^pre/.test(css(node.parentNode, 'whiteSpace'))) { + remove(node); + } + } + + node = next; + } + } + } + + + /** + * Map of all the commands for SCEditor + * @type {Object} + * @name commands + * @memberOf jQuery.sceditor + */ + var defaultCmds = { + // START_COMMAND: Bold + bold: { + exec: 'bold', + tooltip: 'Bold', + shortcut: 'Ctrl+B' + }, + // END_COMMAND + // START_COMMAND: Italic + italic: { + exec: 'italic', + tooltip: 'Italic', + shortcut: 'Ctrl+I' + }, + // END_COMMAND + // START_COMMAND: Underline + underline: { + exec: 'underline', + tooltip: 'Underline', + shortcut: 'Ctrl+U' + }, + // END_COMMAND + // START_COMMAND: Strikethrough + strike: { + exec: 'strikethrough', + tooltip: 'Strikethrough' + }, + // END_COMMAND + // START_COMMAND: Subscript + subscript: { + exec: 'subscript', + tooltip: 'Subscript' + }, + // END_COMMAND + // START_COMMAND: Superscript + superscript: { + exec: 'superscript', + tooltip: 'Superscript' + }, + // END_COMMAND + + // START_COMMAND: Left + left: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-left + return /left/.test(align) || + align === (isLtr ? 'start' : 'end'); + } + }, + exec: 'justifyleft', + tooltip: 'Align left' + }, + // END_COMMAND + // START_COMMAND: Centre + center: { + exec: 'justifycenter', + tooltip: 'Center' + }, + // END_COMMAND + // START_COMMAND: Right + right: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-right + return /right/.test(align) || + align === (isLtr ? 'end' : 'start'); + } + }, + exec: 'justifyright', + tooltip: 'Align right' + }, + // END_COMMAND + // START_COMMAND: Justify + justify: { + exec: 'justifyfull', + tooltip: 'Justify' + }, + // END_COMMAND + + // START_COMMAND: Font + font: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'font')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.opts.fonts.split(',').forEach(function (font) { + appendChild(content, _tmpl('fontOpt', { + font: font + }, true)); + }); + + editor.createDropDown(caller, 'font-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.font._dropDown(editor, caller, function (fontName) { + editor.execCommand('fontname', fontName); + }); + }, + tooltip: 'Font Name' + }, + // END_COMMAND + // START_COMMAND: Size + size: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'size')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + for (var i = 1; i <= 7; i++) { + appendChild(content, _tmpl('sizeOpt', { + size: i + }, true)); + } + + editor.createDropDown(caller, 'fontsize-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.size._dropDown(editor, caller, function (fontSize) { + editor.execCommand('fontsize', fontSize); + }); + }, + tooltip: 'Font Size' + }, + // END_COMMAND + // START_COMMAND: Colour + color: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'), + html = '', + cmd = defaultCmds.color; + + if (!cmd._htmlCache) { + editor.opts.colors.split('|').forEach(function (column) { + html += '<div class="sceditor-color-column">'; + + column.split(',').forEach(function (color) { + html += + '<a href="#" class="sceditor-color-option"' + + ' style="background-color: ' + color + '"' + + ' data-color="' + color + '"></a>'; + }); + + html += '</div>'; + }); + + cmd._htmlCache = html; + } + + appendChild(content, parseHTML(cmd._htmlCache)); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'color')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'color-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.color._dropDown(editor, caller, function (color) { + editor.execCommand('forecolor', color); + }); + }, + tooltip: 'Font Color' + }, + // END_COMMAND + // START_COMMAND: Remove Format + removeformat: { + exec: 'removeformat', + tooltip: 'Remove Formatting' + }, + // END_COMMAND + + // START_COMMAND: Cut + cut: { + exec: 'cut', + tooltip: 'Cut', + errorMessage: 'Your browser does not allow the cut command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-X' + }, + // END_COMMAND + // START_COMMAND: Copy + copy: { + exec: 'copy', + tooltip: 'Copy', + errorMessage: 'Your browser does not allow the copy command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-C' + }, + // END_COMMAND + // START_COMMAND: Paste + paste: { + exec: 'paste', + tooltip: 'Paste', + errorMessage: 'Your browser does not allow the paste command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-V' + }, + // END_COMMAND + // START_COMMAND: Paste Text + pastetext: { + exec: function (caller) { + var val, + content = createElement('div'), + editor = this; + + appendChild(content, _tmpl('pastetext', { + label: editor._( + 'Paste your text inside the following box:' + ), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + val = find(content, '#txt')[0].value; + + if (val) { + editor.wysiwygEditorInsertText(val); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'pastetext', content); + }, + tooltip: 'Paste Text' + }, + // END_COMMAND + // START_COMMAND: Bullet List + bulletlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertunorderedlist'); + }, + tooltip: 'Bullet list' + }, + // END_COMMAND + // START_COMMAND: Ordered List + orderedlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertorderedlist'); + }, + tooltip: 'Numbered list' + }, + // END_COMMAND + // START_COMMAND: Indent + indent: { + state: function (parent, firstBlock) { + // Only works with lists, for now + var range, startParent, endParent; + + if (is(firstBlock, 'li')) { + return 0; + } + + if (is(firstBlock, 'ul,ol,menu')) { + // if the whole list is selected, then this must be + // invalidated because the browser will place a + // <blockquote> there + range = this.getRangeHelper().selectedRange(); + + startParent = range.startContainer.parentNode; + endParent = range.endContainer.parentNode; + + // TODO: could use nodeType for this? + // Maybe just check the firstBlock contains both the start + //and end containers + + // Select the tag, not the textNode + // (that's why the parentNode) + if (startParent !== + startParent.parentNode.firstElementChild || + // work around a bug in FF + (is(endParent, 'li') && endParent !== + endParent.parentNode.lastElementChild)) { + return 0; + } + } + + return -1; + }, + exec: function () { + var editor = this, + block = editor.getRangeHelper().getFirstBlockParent(); + + editor.focus(); + + // An indent system is quite complicated as there are loads + // of complications and issues around how to indent text + // As default, let's just stay with indenting the lists, + // at least, for now. + if (closest(block, 'ul,ol,menu')) { + editor.execCommand('indent'); + } + }, + tooltip: 'Add indent' + }, + // END_COMMAND + // START_COMMAND: Outdent + outdent: { + state: function (parents, firstBlock) { + return closest(firstBlock, 'ul,ol,menu') ? 0 : -1; + }, + exec: function () { + var block = this.getRangeHelper().getFirstBlockParent(); + if (closest(block, 'ul,ol,menu')) { + this.execCommand('outdent'); + } + }, + tooltip: 'Remove one indent' + }, + // END_COMMAND + + // START_COMMAND: Table + table: { + exec: function (caller) { + var editor = this, + content = createElement('div'); + + appendChild(content, _tmpl('table', { + rows: editor._('Rows:'), + cols: editor._('Cols:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var rows = Number(find(content, '#rows')[0].value), + cols = Number(find(content, '#cols')[0].value), + html = '<table>'; + + if (rows > 0 && cols > 0) { + html += Array(rows + 1).join( + '<tr>' + + Array(cols + 1).join( + '<td><br /></td>' + ) + + '</tr>' + ); + + html += '</table>'; + + editor.wysiwygEditorInsertHtml(html); + editor.closeDropDown(true); + e.preventDefault(); + } + }); + + editor.createDropDown(caller, 'inserttable', content); + }, + tooltip: 'Insert a table' + }, + // END_COMMAND + + // START_COMMAND: Horizontal Rule + horizontalrule: { + exec: 'inserthorizontalrule', + tooltip: 'Insert a horizontal rule' + }, + // END_COMMAND + + // START_COMMAND: Code + code: { + exec: function () { + this.wysiwygEditorInsertHtml( + '<code>', + '<br /></code>' + ); + }, + tooltip: 'Code' + }, + // END_COMMAND + + // START_COMMAND: Image + image: { + _dropDown: function (editor, caller, selected, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('image', { + url: editor._('URL:'), + width: editor._('Width (optional):'), + height: editor._('Height (optional):'), + insert: editor._('Insert') + }, true)); + + + var urlInput = find(content, '#image')[0]; + + urlInput.value = selected; + + on(content, 'click', '.button', function (e) { + if (urlInput.value) { + cb( + urlInput.value, + find(content, '#width')[0].value, + find(content, '#height')[0].value + ); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertimage', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.image._dropDown( + editor, + caller, + '', + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width="' + parseInt(width, 10) + '"'; + } + + if (height) { + attrs += ' height="' + parseInt(height, 10) + '"'; + } + + attrs += ' src="' + entities(url) + '"'; + + editor.wysiwygEditorInsertHtml( + '<img' + attrs + ' />' + ); + } + ); + }, + tooltip: 'Insert an image' + }, + // END_COMMAND + + // START_COMMAND: E-mail + email: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('email', { + label: editor._('E-mail:'), + desc: editor._('Description (optional):'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var email = find(content, '#email')[0].value; + + if (email) { + cb(email, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertemail', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.email._dropDown( + editor, + caller, + function (email, text) { + if (!editor.getRangeHelper().selectedHtml() || text) { + editor.wysiwygEditorInsertHtml( + '<a href="' + + 'mailto:' + entities(email) + '">' + + entities((text || email)) + + '</a>' + ); + } else { + editor.execCommand('createlink', 'mailto:' + email); + } + } + ); + }, + tooltip: 'Insert an email' + }, + // END_COMMAND + + // START_COMMAND: Link + link: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('link', { + url: editor._('URL:'), + desc: editor._('Description (optional):'), + ins: editor._('Insert') + }, true)); + + var linkInput = find(content, '#link')[0]; + + function insertUrl(e) { + if (linkInput.value) { + cb(linkInput.value, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + } + + on(content, 'click', '.button', insertUrl); + on(content, 'keypress', function (e) { + // 13 = enter key + if (e.which === 13 && linkInput.value) { + insertUrl(e); + } + }, EVENT_CAPTURE); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.link._dropDown(editor, caller, function (url, text) { + if (text || !editor.getRangeHelper().selectedHtml()) { + editor.wysiwygEditorInsertHtml( + '<a href="' + entities(url) + '">' + + entities(text || url) + + '</a>' + ); + } else { + editor.execCommand('createlink', url); + } + }); + }, + tooltip: 'Insert a link' + }, + // END_COMMAND + + // START_COMMAND: Unlink + unlink: { + state: function () { + return closest(this.currentNode(), 'a') ? 0 : -1; + }, + exec: function () { + var anchor = closest(this.currentNode(), 'a'); + + if (anchor) { + while (anchor.firstChild) { + insertBefore(anchor.firstChild, anchor); + } + + remove(anchor); + } + }, + tooltip: 'Unlink' + }, + // END_COMMAND + + + // START_COMMAND: Quote + quote: { + exec: function (caller, html, author) { + var before = '<blockquote>', + end = '</blockquote>'; + + // if there is HTML passed set end to null so any selected + // text is replaced + if (html) { + author = (author ? '<cite>' + + entities(author) + + '</cite>' : ''); + before = before + author + html + end; + end = null; + // if not add a newline to the end of the inserted quote + } else if (this.getRangeHelper().selectedHtml() === '') { + end = '<br />' + end; + } + + this.wysiwygEditorInsertHtml(before, end); + }, + tooltip: 'Insert a Quote' + }, + // END_COMMAND + + // START_COMMAND: Emoticons + emoticon: { + exec: function (caller) { + var editor = this; + + var createContent = function (includeMore) { + var moreLink, + opts = editor.opts, + emoticonsRoot = opts.emoticonsRoot || '', + emoticonsCompat = opts.emoticonsCompat, + rangeHelper = editor.getRangeHelper(), + startSpace = emoticonsCompat && + rangeHelper.getOuterText(true, 1) !== ' ' ? ' ' : '', + endSpace = emoticonsCompat && + rangeHelper.getOuterText(false, 1) !== ' ' ? ' ' : '', + content = createElement('div'), + line = createElement('div'), + perLine = 0, + emoticons = extend( + {}, + opts.emoticons.dropdown, + includeMore ? opts.emoticons.more : {} + ); + + appendChild(content, line); + + perLine = Math.sqrt(Object.keys(emoticons).length); + + on(content, 'click', 'img', function (e) { + editor.insert(startSpace + attr(this, 'alt') + endSpace, + null, false).closeDropDown(true); + + e.preventDefault(); + }); + + each(emoticons, function (code, emoticon) { + appendChild(line, createElement('img', { + src: emoticonsRoot + (emoticon.url || emoticon), + alt: code, + title: emoticon.tooltip || code + })); + + if (line.children.length >= perLine) { + line = createElement('div'); + appendChild(content, line); + } + }); + + if (!includeMore && opts.emoticons.more) { + moreLink = createElement('a', { + className: 'sceditor-more' + }); + + appendChild(moreLink, + document.createTextNode(editor._('More'))); + + on(moreLink, 'click', function (e) { + editor.createDropDown( + caller, 'more-emoticons', createContent(true) + ); + + e.preventDefault(); + }); + + appendChild(content, moreLink); + } + + return content; + }; + + editor.createDropDown(caller, 'emoticons', createContent(false)); + }, + txtExec: function (caller) { + defaultCmds.emoticon.exec.call(this, caller); + }, + tooltip: 'Insert an emoticon' + }, + // END_COMMAND + + // START_COMMAND: YouTube + youtube: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + appendChild(content, _tmpl('youtubeMenu', { + label: editor._('Video URL:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var val = find(content, '#link')[0].value; + var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/); + var timeMatch = val.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/); + var time = 0; + + if (timeMatch) { + each(timeMatch[1].split(/[hms]/), function (i, val) { + if (val !== '') { + time = (time * 60) + Number(val); + } + }); + } + + if (idMatch && /^[a-zA-Z0-9_\-]{11}$/.test(idMatch[1])) { + callback(idMatch[1], time); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (btn) { + var editor = this; + + defaultCmds.youtube._dropDown(editor, btn, function (id, time) { + editor.wysiwygEditorInsertHtml(_tmpl('youtube', { + id: id, + time: time + })); + }); + }, + tooltip: 'Insert a YouTube video' + }, + // END_COMMAND + + // START_COMMAND: Date + date: { + _date: function (editor) { + var now = new Date(), + year = now.getYear(), + month = now.getMonth() + 1, + day = now.getDate(); + + if (year < 2000) { + year = 1900 + year; + } + + if (month < 10) { + month = '0' + month; + } + + if (day < 10) { + day = '0' + day; + } + + return editor.opts.dateFormat + .replace(/year/i, year) + .replace(/month/i, month) + .replace(/day/i, day); + }, + exec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + txtExec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + tooltip: 'Insert current date' + }, + // END_COMMAND + + // START_COMMAND: Time + time: { + _time: function () { + var now = new Date(), + hours = now.getHours(), + mins = now.getMinutes(), + secs = now.getSeconds(); + + if (hours < 10) { + hours = '0' + hours; + } + + if (mins < 10) { + mins = '0' + mins; + } + + if (secs < 10) { + secs = '0' + secs; + } + + return hours + ':' + mins + ':' + secs; + }, + exec: function () { + this.insertText(defaultCmds.time._time()); + }, + txtExec: function () { + this.insertText(defaultCmds.time._time()); + }, + tooltip: 'Insert current time' + }, + // END_COMMAND + + + // START_COMMAND: Ltr + ltr: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'ltr'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'ltr' ? '' : 'ltr'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Left-to-Right' + }, + // END_COMMAND + + // START_COMMAND: Rtl + rtl: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'rtl'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'rtl' ? '' : 'rtl'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Right-to-Left' + }, + // END_COMMAND + + + // START_COMMAND: Print + print: { + exec: 'print', + tooltip: 'Print' + }, + // END_COMMAND + + // START_COMMAND: Maximize + maximize: { + state: function () { + return this.maximize(); + }, + exec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + txtExec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + tooltip: 'Maximize', + shortcut: 'Ctrl+Shift+M' + }, + // END_COMMAND + + // START_COMMAND: Source + source: { + state: function () { + return this.sourceMode(); + }, + exec: function () { + this.toggleSourceMode(); + this.focus(); + }, + txtExec: function () { + this.toggleSourceMode(); + this.focus(); + }, + tooltip: 'View source', + shortcut: 'Ctrl+Shift+S' + }, + // END_COMMAND + + // this is here so that commands above can be removed + // without having to remove the , after the last one. + // Needed for IE. + ignore: {} + }; + + var plugins = {}; + + /** + * Plugin Manager class + * @class PluginManager + * @name PluginManager + */ + function PluginManager(thisObj) { + /** + * Alias of this + * + * @private + * @type {Object} + */ + var base = this; + + /** + * Array of all currently registered plugins + * + * @type {Array} + * @private + */ + var registeredPlugins = []; + + + /** + * Changes a signals name from "name" into "signalName". + * + * @param {string} signal + * @return {string} + * @private + */ + var formatSignalName = function (signal) { + return 'signal' + signal.charAt(0).toUpperCase() + signal.slice(1); + }; + + /** + * Calls handlers for a signal + * + * @see call() + * @see callOnlyFirst() + * @param {Array} args + * @param {boolean} returnAtFirst + * @return {*} + * @private + */ + var callHandlers = function (args, returnAtFirst) { + args = [].slice.call(args); + + var idx, ret, + signal = formatSignalName(args.shift()); + + for (idx = 0; idx < registeredPlugins.length; idx++) { + if (signal in registeredPlugins[idx]) { + ret = registeredPlugins[idx][signal].apply(thisObj, args); + + if (returnAtFirst) { + return ret; + } + } + } + }; + + /** + * Calls all handlers for the passed signal + * + * @param {string} signal + * @param {...string} args + * @function + * @name call + * @memberOf PluginManager.prototype + */ + base.call = function () { + callHandlers(arguments, false); + }; + + /** + * Calls the first handler for a signal, and returns the + * + * @param {string} signal + * @param {...string} args + * @return {*} The result of calling the handler + * @function + * @name callOnlyFirst + * @memberOf PluginManager.prototype + */ + base.callOnlyFirst = function () { + return callHandlers(arguments, true); + }; + + /** + * Checks if a signal has a handler + * + * @param {string} signal + * @return {boolean} + * @function + * @name hasHandler + * @memberOf PluginManager.prototype + */ + base.hasHandler = function (signal) { + var i = registeredPlugins.length; + signal = formatSignalName(signal); + + while (i--) { + if (signal in registeredPlugins[i]) { + return true; + } + } + + return false; + }; + + /** + * Checks if the plugin exists in plugins + * + * @param {string} plugin + * @return {boolean} + * @function + * @name exists + * @memberOf PluginManager.prototype + */ + base.exists = function (plugin) { + if (plugin in plugins) { + plugin = plugins[plugin]; + + return typeof plugin === 'function' && + typeof plugin.prototype === 'object'; + } + + return false; + }; + + /** + * Checks if the passed plugin is currently registered. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name isRegistered + * @memberOf PluginManager.prototype + */ + base.isRegistered = function (plugin) { + if (base.exists(plugin)) { + var idx = registeredPlugins.length; + + while (idx--) { + if (registeredPlugins[idx] instanceof plugins[plugin]) { + return true; + } + } + } + + return false; + }; + + /** + * Registers a plugin to receive signals + * + * @param {string} plugin + * @return {boolean} + * @function + * @name register + * @memberOf PluginManager.prototype + */ + base.register = function (plugin) { + if (!base.exists(plugin) || base.isRegistered(plugin)) { + return false; + } + + plugin = new plugins[plugin](); + registeredPlugins.push(plugin); + + if ('init' in plugin) { + plugin.init.call(thisObj); + } + + return true; + }; + + /** + * Deregisters a plugin. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name deregister + * @memberOf PluginManager.prototype + */ + base.deregister = function (plugin) { + var removedPlugin, + pluginIdx = registeredPlugins.length, + removed = false; + + if (!base.isRegistered(plugin)) { + return removed; + } + + while (pluginIdx--) { + if (registeredPlugins[pluginIdx] instanceof plugins[plugin]) { + removedPlugin = registeredPlugins.splice(pluginIdx, 1)[0]; + removed = true; + + if ('destroy' in removedPlugin) { + removedPlugin.destroy.call(thisObj); + } + } + } + + return removed; + }; + + /** + * Clears all plugins and removes the owner reference. + * + * Calling any functions on this object after calling + * destroy will cause a JS error. + * + * @name destroy + * @memberOf PluginManager.prototype + */ + base.destroy = function () { + var i = registeredPlugins.length; + + while (i--) { + if ('destroy' in registeredPlugins[i]) { + registeredPlugins[i].destroy.call(thisObj); + } + } + + registeredPlugins = []; + thisObj = null; + }; + } + PluginManager.plugins = plugins; + + /** + * Gets the text, start/end node and offset for + * length chars left or right of the passed node + * at the specified offset. + * + * @param {Node} node + * @param {number} offset + * @param {boolean} isLeft + * @param {number} length + * @return {Object} + * @private + */ + var outerText = function (range, isLeft, length) { + var nodeValue, remaining, start, end, node, + text = '', + next = range.startContainer, + offset = range.startOffset; + + // Handle cases where node is a paragraph and offset + // refers to the index of a text node. + // 3 = text node + if (next && next.nodeType !== 3) { + next = next.childNodes[offset]; + offset = 0; + } + + start = end = offset; + + while (length > text.length && next && next.nodeType === 3) { + nodeValue = next.nodeValue; + remaining = length - text.length; + + // If not the first node, start and end should be at their + // max values as will be updated when getting the text + if (node) { + end = nodeValue.length; + start = 0; + } + + node = next; + + if (isLeft) { + start = Math.max(end - remaining, 0); + offset = start; + + text = nodeValue.substr(start, end - start) + text; + next = node.previousSibling; + } else { + end = Math.min(remaining, nodeValue.length); + offset = start + end; + + text += nodeValue.substr(start, end); + next = node.nextSibling; + } + } + + return { + node: node || next, + offset: offset, + text: text + }; + }; + + /** + * Range helper + * + * @class RangeHelper + * @name RangeHelper + */ + function RangeHelper(win, d, sanitize) { + var _createMarker, _prepareInput, + doc = d || win.contentDocument || win.document, + startMarker = 'sceditor-start-marker', + endMarker = 'sceditor-end-marker', + base = this; + + /** + * Inserts HTML into the current range replacing any selected + * text. + * + * If endHTML is specified the selected contents will be put between + * html and endHTML. If there is nothing selected html and endHTML are + * just concatenate together. + * + * @param {string} html + * @param {string} [endHTML] + * @return False on fail + * @function + * @name insertHTML + * @memberOf RangeHelper.prototype + */ + base.insertHTML = function (html, endHTML) { + var node, div, + range = base.selectedRange(); + + if (!range) { + return false; + } + + if (endHTML) { + html += base.selectedHtml() + endHTML; + } + + div = createElement('p', {}, doc); + node = doc.createDocumentFragment(); + div.innerHTML = sanitize(html); + + while (div.firstChild) { + appendChild(node, div.firstChild); + } + + base.insertNode(node); + }; + + /** + * Prepares HTML to be inserted by adding a zero width space + * if the last child is empty and adding the range start/end + * markers to the last child. + * + * @param {Node|string} node + * @param {Node|string} [endNode] + * @param {boolean} [returnHtml] + * @return {Node|string} + * @private + */ + _prepareInput = function (node, endNode, returnHtml) { + var lastChild, + frag = doc.createDocumentFragment(); + + if (typeof node === 'string') { + if (endNode) { + node += base.selectedHtml() + endNode; + } + + frag = parseHTML(node); + } else { + appendChild(frag, node); + + if (endNode) { + appendChild(frag, base.selectedRange().extractContents()); + appendChild(frag, endNode); + } + } + + if (!(lastChild = frag.lastChild)) { + return; + } + + while (!isInline(lastChild.lastChild, true)) { + lastChild = lastChild.lastChild; + } + + if (canHaveChildren(lastChild)) { + // Webkit won't allow the cursor to be placed inside an + // empty tag, so add a zero width space to it. + if (!lastChild.lastChild) { + appendChild(lastChild, document.createTextNode('\u200B')); + } + } else { + lastChild = frag; + } + + base.removeMarkers(); + + // Append marks to last child so when restored cursor will be in + // the right place + appendChild(lastChild, _createMarker(startMarker)); + appendChild(lastChild, _createMarker(endMarker)); + + if (returnHtml) { + var div = createElement('div'); + appendChild(div, frag); + + return div.innerHTML; + } + + return frag; + }; + + /** + * The same as insertHTML except with DOM nodes instead + * + * <strong>Warning:</strong> the nodes must belong to the + * document they are being inserted into. Some browsers + * will throw exceptions if they don't. + * + * Returns boolean false on fail + * + * @param {Node} node + * @param {Node} endNode + * @return {false|undefined} + * @function + * @name insertNode + * @memberOf RangeHelper.prototype + */ + base.insertNode = function (node, endNode) { + var first, last, + input = _prepareInput(node, endNode), + range = base.selectedRange(), + parent = range.commonAncestorContainer, + emptyNodes = []; + + if (!input) { + return false; + } + + function removeIfEmpty(node) { + // Only remove empty node if it wasn't already empty + if (node && isEmpty(node) && emptyNodes.indexOf(node) < 0) { + remove(node); + } + } + + if (range.startContainer !== range.endContainer) { + each(parent.childNodes, function (_, node) { + if (isEmpty(node)) { + emptyNodes.push(node); + } + }); + + first = input.firstChild; + last = input.lastChild; + } + + range.deleteContents(); + + // FF allows <br /> to be selected but inserting a node + // into <br /> will cause it not to be displayed so must + // insert before the <br /> in FF. + // 3 = TextNode + if (parent && parent.nodeType !== 3 && !canHaveChildren(parent)) { + insertBefore(input, parent); + } else { + range.insertNode(input); + + // If a node was split or its contents deleted, remove any resulting + // empty tags. For example: + // <p>|test</p><div>test|</div> + // When deleteContents could become: + // <p></p>|<div></div> + // So remove the empty ones + removeIfEmpty(first && first.previousSibling); + removeIfEmpty(last && last.nextSibling); + } + + base.restoreRange(); + }; + + /** + * Clones the selected Range + * + * @return {Range} + * @function + * @name cloneSelected + * @memberOf RangeHelper.prototype + */ + base.cloneSelected = function () { + var range = base.selectedRange(); + + if (range) { + return range.cloneRange(); + } + }; + + /** + * Gets the selected Range + * + * @return {Range} + * @function + * @name selectedRange + * @memberOf RangeHelper.prototype + */ + base.selectedRange = function () { + var range, firstChild, + sel = win.getSelection(); + + if (!sel) { + return; + } + + // When creating a new range, set the start to the first child + // element of the body element to avoid errors in FF. + if (sel.rangeCount <= 0) { + firstChild = doc.body; + while (firstChild.firstChild) { + firstChild = firstChild.firstChild; + } + + range = doc.createRange(); + // Must be setStartBefore otherwise it can cause infinite + // loops with lists in WebKit. See issue 442 + range.setStartBefore(firstChild); + + sel.addRange(range); + } + + if (sel.rangeCount > 0) { + range = sel.getRangeAt(0); + } + + return range; + }; + + /** + * Gets if there is currently a selection + * + * @return {boolean} + * @function + * @name hasSelection + * @since 1.4.4 + * @memberOf RangeHelper.prototype + */ + base.hasSelection = function () { + var sel = win.getSelection(); + + return sel && sel.rangeCount > 0; + }; + + /** + * Gets the currently selected HTML + * + * @return {string} + * @function + * @name selectedHtml + * @memberOf RangeHelper.prototype + */ + base.selectedHtml = function () { + var div, + range = base.selectedRange(); + + if (range) { + div = createElement('p', {}, doc); + appendChild(div, range.cloneContents()); + + return div.innerHTML; + } + + return ''; + }; + + /** + * Gets the parent node of the selected contents in the range + * + * @return {HTMLElement} + * @function + * @name parentNode + * @memberOf RangeHelper.prototype + */ + base.parentNode = function () { + var range = base.selectedRange(); + + if (range) { + return range.commonAncestorContainer; + } + }; + + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @return {HTMLElement} + * @function + * @name getFirstBlockParent + * @memberOf RangeHelper.prototype + */ + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @param {Node} [n] The element to get the first block level parent from + * @return {HTMLElement} + * @function + * @name getFirstBlockParent^2 + * @since 1.4.1 + * @memberOf RangeHelper.prototype + */ + base.getFirstBlockParent = function (node) { + var func = function (elm) { + if (!isInline(elm, true)) { + return elm; + } + + elm = elm ? elm.parentNode : null; + + return elm ? func(elm) : elm; + }; + + return func(node || base.parentNode()); + }; + + /** + * Inserts a node at either the start or end of the current selection + * + * @param {Bool} start + * @param {Node} node + * @function + * @name insertNodeAt + * @memberOf RangeHelper.prototype + */ + base.insertNodeAt = function (start, node) { + var currentRange = base.selectedRange(), + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(start); + range.insertNode(node); + + // Reselect the current range. + // Fixes issue with Chrome losing the selection. Issue#82 + base.selectRange(currentRange); + }; + + /** + * Creates a marker node + * + * @param {string} id + * @return {HTMLSpanElement} + * @private + */ + _createMarker = function (id) { + base.removeMarker(id); + + var marker = createElement('span', { + id: id, + className: 'sceditor-selection sceditor-ignore', + style: 'display:none;line-height:0' + }, doc); + + marker.innerHTML = ' '; + + return marker; + }; + + /** + * Inserts start/end markers for the current selection + * which can be used by restoreRange to re-select the + * range. + * + * @memberOf RangeHelper.prototype + * @function + * @name insertMarkers + */ + base.insertMarkers = function () { + var currentRange = base.selectedRange(); + var startNode = _createMarker(startMarker); + + base.removeMarkers(); + base.insertNodeAt(true, startNode); + + // Fixes issue with end marker sometimes being placed before + // the start marker when the range is collapsed. + if (currentRange && currentRange.collapsed) { + startNode.parentNode.insertBefore( + _createMarker(endMarker), startNode.nextSibling); + } else { + base.insertNodeAt(false, _createMarker(endMarker)); + } + }; + + /** + * Gets the marker with the specified ID + * + * @param {string} id + * @return {Node} + * @function + * @name getMarker + * @memberOf RangeHelper.prototype + */ + base.getMarker = function (id) { + return doc.getElementById(id); + }; + + /** + * Removes the marker with the specified ID + * + * @param {string} id + * @function + * @name removeMarker + * @memberOf RangeHelper.prototype + */ + base.removeMarker = function (id) { + var marker = base.getMarker(id); + + if (marker) { + remove(marker); + } + }; + + /** + * Removes the start/end markers + * + * @function + * @name removeMarkers + * @memberOf RangeHelper.prototype + */ + base.removeMarkers = function () { + base.removeMarker(startMarker); + base.removeMarker(endMarker); + }; + + /** + * Saves the current range location. Alias of insertMarkers() + * + * @function + * @name saveRage + * @memberOf RangeHelper.prototype + */ + base.saveRange = function () { + base.insertMarkers(); + }; + + /** + * Select the specified range + * + * @param {Range} range + * @function + * @name selectRange + * @memberOf RangeHelper.prototype + */ + base.selectRange = function (range) { + var lastChild; + var sel = win.getSelection(); + var container = range.endContainer; + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (range.collapsed && container && + !isInline(container, true)) { + + lastChild = container.lastChild; + while (lastChild && is(lastChild, '.sceditor-ignore')) { + lastChild = lastChild.previousSibling; + } + + if (is(lastChild, 'br')) { + var rng = doc.createRange(); + rng.setEndAfter(lastChild); + rng.collapse(false); + + if (base.compare(range, rng)) { + range.setStartBefore(lastChild); + range.collapse(true); + } + } + } + + if (sel) { + base.clear(); + sel.addRange(range); + } + }; + + /** + * Restores the last range saved by saveRange() or insertMarkers() + * + * @function + * @name restoreRange + * @memberOf RangeHelper.prototype + */ + base.restoreRange = function () { + var isCollapsed, + range = base.selectedRange(), + start = base.getMarker(startMarker), + end = base.getMarker(endMarker); + + if (!start || !end || !range) { + return false; + } + + isCollapsed = start.nextSibling === end; + + range = doc.createRange(); + range.setStartBefore(start); + range.setEndAfter(end); + + if (isCollapsed) { + range.collapse(true); + } + + base.selectRange(range); + base.removeMarkers(); + }; + + /** + * Selects the text left and right of the current selection + * + * @param {number} left + * @param {number} right + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.selectOuterText = function (left, right) { + var start, end, + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(false); + + start = outerText(range, true, left); + end = outerText(range, false, right); + + range.setStart(start.node, start.offset); + range.setEnd(end.node, end.offset); + + base.selectRange(range); + }; + + /** + * Gets the text left or right of the current selection + * + * @param {boolean} before + * @param {number} length + * @return {string} + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.getOuterText = function (before, length) { + var range = base.cloneSelected(); + + if (!range) { + return ''; + } + + range.collapse(!before); + + return outerText(range, before, length).text; + }; + + /** + * Replaces keywords with values based on the current caret position + * + * @param {Array} keywords + * @param {boolean} includeAfter If to include the text after the + * current caret position or just + * text before + * @param {boolean} keywordsSorted If the keywords array is pre + * sorted shortest to longest + * @param {number} longestKeyword Length of the longest keyword + * @param {boolean} requireWhitespace If the key must be surrounded + * by whitespace + * @param {string} keypressChar If this is being called from + * a keypress event, this should be + * set to the pressed character + * @return {boolean} + * @function + * @name replaceKeyword + * @memberOf RangeHelper.prototype + */ + // eslint-disable-next-line max-params + base.replaceKeyword = function ( + keywords, + includeAfter, + keywordsSorted, + longestKeyword, + requireWhitespace, + keypressChar + ) { + if (!keywordsSorted) { + keywords.sort(function (a, b) { + return a[0].length - b[0].length; + }); + } + + var outerText, match, matchPos, startIndex, + leftLen, charsLeft, keyword, keywordLen, + whitespaceRegex = '(^|[\\s\xA0\u2002\u2003\u2009])', + keywordIdx = keywords.length, + whitespaceLen = requireWhitespace ? 1 : 0, + maxKeyLen = longestKeyword || + keywords[keywordIdx - 1][0].length; + + if (requireWhitespace) { + maxKeyLen++; + } + + keypressChar = keypressChar || ''; + outerText = base.getOuterText(true, maxKeyLen); + leftLen = outerText.length; + outerText += keypressChar; + + if (includeAfter) { + outerText += base.getOuterText(false, maxKeyLen); + } + + while (keywordIdx--) { + keyword = keywords[keywordIdx][0]; + keywordLen = keyword.length; + startIndex = Math.max(0, leftLen - keywordLen - whitespaceLen); + matchPos = -1; + + if (requireWhitespace) { + match = outerText + .substr(startIndex) + .match(new RegExp(whitespaceRegex + + regex(keyword) + whitespaceRegex)); + + if (match) { + // Add the length of the text that was removed by + // substr() and also add 1 for the whitespace + matchPos = match.index + startIndex + match[1].length; + } + } else { + matchPos = outerText.indexOf(keyword, startIndex); + } + + if (matchPos > -1) { + // Make sure the match is between before and + // after, not just entirely in one side or the other + if (matchPos <= leftLen && + matchPos + keywordLen + whitespaceLen >= leftLen) { + charsLeft = leftLen - matchPos; + + // If the keypress char is white space then it should + // not be replaced, only chars that are part of the + // key should be replaced. + base.selectOuterText( + charsLeft, + keywordLen - charsLeft - + (/^\S/.test(keypressChar) ? 1 : 0) + ); + + base.insertHTML(keywords[keywordIdx][1]); + return true; + } + } + } + + return false; + }; + + /** + * Compares two ranges. + * + * If rangeB is undefined it will be set to + * the current selected range + * + * @param {Range} rngA + * @param {Range} [rngB] + * @return {boolean} + * @function + * @name compare + * @memberOf RangeHelper.prototype + */ + base.compare = function (rngA, rngB) { + if (!rngB) { + rngB = base.selectedRange(); + } + + if (!rngA || !rngB) { + return !rngA && !rngB; + } + + return rngA.compareBoundaryPoints(Range.END_TO_END, rngB) === 0 && + rngA.compareBoundaryPoints(Range.START_TO_START, rngB) === 0; + }; + + /** + * Removes any current selection + * + * @since 1.4.6 + * @function + * @name clear + * @memberOf RangeHelper.prototype + */ + base.clear = function () { + var sel = win.getSelection(); + + if (sel) { + if (sel.removeAllRanges) { + sel.removeAllRanges(); + } else if (sel.empty) { + sel.empty(); + } + } + }; + } + + var USER_AGENT = navigator.userAgent; + + /** + * Detects if the browser is iOS + * + * Needed to fix iOS specific bugs + * + * @function + * @name ios + * @memberOf jQuery.sceditor + * @type {boolean} + */ + var ios = /iPhone|iPod|iPad| wosbrowser\//i.test(USER_AGENT); + + /** + * If the browser supports WYSIWYG editing (e.g. older mobile browsers). + * + * @function + * @name isWysiwygSupported + * @return {boolean} + */ + var isWysiwygSupported = (function () { + var match, isUnsupported; + + // IE is the only browser to support documentMode + var ie = !!window.document.documentMode; + var legacyEdge = '-ms-ime-align' in document.documentElement.style; + + var div = document.createElement('div'); + div.contentEditable = true; + + // Check if the contentEditable attribute is supported + if (!('contentEditable' in document.documentElement) || + div.contentEditable !== 'true') { + return false; + } + + // I think blackberry supports contentEditable or will at least + // give a valid value for the contentEditable detection above + // so it isn't included in the below tests. + + // I hate having to do UA sniffing but some mobile browsers say they + // support contentediable when it isn't usable, i.e. you can't enter + // text. + // This is the only way I can think of to detect them which is also how + // every other editor I've seen deals with this issue. + + // Exclude Opera mobile and mini + isUnsupported = /Opera Mobi|Opera Mini/i.test(USER_AGENT); + + if (/Android/i.test(USER_AGENT)) { + isUnsupported = true; + + if (/Safari/.test(USER_AGENT)) { + // Android browser 534+ supports content editable + // This also matches Chrome which supports content editable too + match = /Safari\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + } + + // The current version of Amazon Silk supports it, older versions didn't + // As it uses webkit like Android, assume it's the same and started + // working at versions >= 534 + if (/ Silk\//i.test(USER_AGENT)) { + match = /AppleWebKit\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + + // iOS 5+ supports content editable + if (ios) { + // Block any version <= 4_x(_x) + isUnsupported = /OS [0-4](_\d)+ like Mac/i.test(USER_AGENT); + } + + // Firefox does support WYSIWYG on mobiles so override + // any previous value if using FF + if (/Firefox/i.test(USER_AGENT)) { + isUnsupported = false; + } + + if (/OneBrowser/i.test(USER_AGENT)) { + isUnsupported = false; + } + + // UCBrowser works but doesn't give a unique user agent + if (navigator.vendor === 'UCWEB') { + isUnsupported = false; + } + + // IE and legacy edge are not supported any more + if (ie || legacyEdge) { + isUnsupported = true; + } + + return !isUnsupported; + }()); + + /** + * Checks all emoticons are surrounded by whitespace and + * replaces any that aren't with with their emoticon code. + * + * @param {HTMLElement} node + * @param {rangeHelper} rangeHelper + * @return {void} + */ + function checkWhitespace(node, rangeHelper) { + var noneWsRegex = /[^\s\xA0\u2002\u2003\u2009]+/; + var emoticons = node && find(node, 'img[data-sceditor-emoticon]'); + + if (!node || !emoticons.length) { + return; + } + + for (var i = 0; i < emoticons.length; i++) { + var emoticon = emoticons[i]; + var parent = emoticon.parentNode; + var prev = emoticon.previousSibling; + var next = emoticon.nextSibling; + + if ((!prev || !noneWsRegex.test(prev.nodeValue.slice(-1))) && + (!next || !noneWsRegex.test((next.nodeValue || '')[0]))) { + continue; + } + + var range = rangeHelper.cloneSelected(); + var rangeStart = -1; + var rangeStartContainer = range.startContainer; + var previousText = prev.nodeValue || ''; + + previousText += data(emoticon, 'sceditor-emoticon'); + + // If the cursor is after the removed emoticon, add + // the length of the newly added text to it + if (rangeStartContainer === next) { + rangeStart = previousText.length + range.startOffset; + } + + // If the cursor is set before the next node, set it to + // the end of the new text node + if (rangeStartContainer === node && + node.childNodes[range.startOffset] === next) { + rangeStart = previousText.length; + } + + // If the cursor is set before the removed emoticon, + // just keep it at that position + if (rangeStartContainer === prev) { + rangeStart = range.startOffset; + } + + if (!next || next.nodeType !== TEXT_NODE) { + next = parent.insertBefore( + parent.ownerDocument.createTextNode(''), next + ); + } + + next.insertData(0, previousText); + remove(prev); + remove(emoticon); + + // Need to update the range starting position if it's been modified + if (rangeStart > -1) { + range.setStart(next, rangeStart); + range.collapse(true); + rangeHelper.selectRange(range); + } + } + } + /** + * Replaces any emoticons inside the root node with images. + * + * emoticons should be an object where the key is the emoticon + * code and the value is the HTML to replace it with. + * + * @param {HTMLElement} root + * @param {Object<string, string>} emoticons + * @param {boolean} emoticonsCompat + * @return {void} + */ + function replace(root, emoticons, emoticonsCompat) { + var doc = root.ownerDocument; + var space = '(^|\\s|\xA0|\u2002|\u2003|\u2009|$)'; + var emoticonCodes = []; + var emoticonRegex = {}; + + // TODO: Make this tag configurable. + if (parent(root, 'code')) { + return; + } + + each(emoticons, function (key) { + emoticonRegex[key] = new RegExp(space + regex(key) + space); + emoticonCodes.push(key); + }); + + // Sort keys longest to shortest so that longer keys + // take precedence (avoids bugs with shorter keys partially + // matching longer ones) + emoticonCodes.sort(function (a, b) { + return b.length - a.length; + }); + + (function convert(node) { + node = node.firstChild; + + while (node) { + // TODO: Make this tag configurable. + if (node.nodeType === ELEMENT_NODE && !is(node, 'code')) { + convert(node); + } + + if (node.nodeType === TEXT_NODE) { + for (var i = 0; i < emoticonCodes.length; i++) { + var text = node.nodeValue; + var key = emoticonCodes[i]; + var index = emoticonsCompat ? + text.search(emoticonRegex[key]) : + text.indexOf(key); + + if (index > -1) { + // When emoticonsCompat is enabled this will be the + // position after any white space + var startIndex = text.indexOf(key, index); + var fragment = parseHTML(emoticons[key], doc); + var after = text.substr(startIndex + key.length); + + fragment.appendChild(doc.createTextNode(after)); + + node.nodeValue = text.substr(0, startIndex); + node.parentNode + .insertBefore(fragment, node.nextSibling); + } + } + } + + node = node.nextSibling; + } + }(root)); + } + + /*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */ + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var hasOwnProperty = Object.hasOwnProperty, + setPrototypeOf = Object.setPrototypeOf, + isFrozen = Object.isFrozen, + getPrototypeOf = Object.getPrototypeOf, + getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var freeze = Object.freeze, + seal = Object.seal, + create = Object.create; // eslint-disable-line import/no-mutable-exports + + var _ref = typeof Reflect !== 'undefined' && Reflect, + apply = _ref.apply, + construct = _ref.construct; + + if (!apply) { + apply = function apply(fun, thisValue, args) { + return fun.apply(thisValue, args); + }; + } + + if (!freeze) { + freeze = function freeze(x) { + return x; + }; + } + + if (!seal) { + seal = function seal(x) { + return x; + }; + } + + if (!construct) { + construct = function construct(Func, args) { + return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); + }; + } + + var arrayForEach = unapply(Array.prototype.forEach); + var arrayPop = unapply(Array.prototype.pop); + var arrayPush = unapply(Array.prototype.push); + + var stringToLowerCase = unapply(String.prototype.toLowerCase); + var stringMatch = unapply(String.prototype.match); + var stringReplace = unapply(String.prototype.replace); + var stringIndexOf = unapply(String.prototype.indexOf); + var stringTrim = unapply(String.prototype.trim); + + var regExpTest = unapply(RegExp.prototype.test); + + var typeErrorCreate = unconstruct(TypeError); + + function unapply(func) { + return function (thisArg) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return apply(func, thisArg, args); + }; + } + + function unconstruct(func) { + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return construct(func, args); + }; + } + + /* Add properties to a lookup table */ + function addToSet(set, array) { + if (setPrototypeOf) { + // Make 'in' and truthy checks like Boolean(set.constructor) + // independent of any properties defined on Object.prototype. + // Prevent prototype setters from intercepting set as a this value. + setPrototypeOf(set, null); + } + + var l = array.length; + while (l--) { + var element = array[l]; + if (typeof element === 'string') { + var lcElement = stringToLowerCase(element); + if (lcElement !== element) { + // Config presets (e.g. tags.js, attrs.js) are immutable. + if (!isFrozen(array)) { + array[l] = lcElement; + } + + element = lcElement; + } + } + + set[element] = true; + } + + return set; + } + + /* Shallow clone an object */ + function clone(object) { + var newObject = create(null); + + var property = void 0; + for (property in object) { + if (apply(hasOwnProperty, object, [property])) { + newObject[property] = object[property]; + } + } + + return newObject; + } + + /* IE10 doesn't support __lookupGetter__ so lets' + * simulate it. It also automatically checks + * if the prop is function or getter and behaves + * accordingly. */ + function lookupGetter(object, prop) { + while (object !== null) { + var desc = getOwnPropertyDescriptor(object, prop); + if (desc) { + if (desc.get) { + return unapply(desc.get); + } + + if (typeof desc.value === 'function') { + return unapply(desc.value); + } + } + + object = getPrototypeOf(object); + } + + return null; + } + + var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); + + // SVG + var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); + + var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); + + // List of SVG elements that are disallowed by default. + // We still need to know them so that we can do namespace + // checks properly in case one wants to add them to + // allow-list. + var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); + + var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']); + + // Similarly to SVG, we want to know all MathML elements, + // even those that we disallow by default. + var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); + + var text = freeze(['#text']); + + var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns']); + + var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); + + var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); + + var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); + + // eslint-disable-next-line unicorn/better-regex + var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode + var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); + var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape + var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape + var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape + ); + var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); + var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex + ); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var getGlobal = function getGlobal() { + return typeof window === 'undefined' ? null : window; + }; + + /** + * Creates a no-op policy for internal use only. + * Don't export this function outside this module! + * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory. + * @param {Document} document The document object (to determine policy name suffix) + * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types + * are not supported). + */ + var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { + if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { + return null; + } + + // Allow the callers to control the unique policy name + // by adding a data-tt-policy-suffix to the script element with the DOMPurify. + // Policy creation with duplicate names throws in Trusted Types. + var suffix = null; + var ATTR_NAME = 'data-tt-policy-suffix'; + if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { + suffix = document.currentScript.getAttribute(ATTR_NAME); + } + + var policyName = 'dompurify' + (suffix ? '#' + suffix : ''); + + try { + return trustedTypes.createPolicy(policyName, { + createHTML: function createHTML(html$$1) { + return html$$1; + } + }); + } catch (_) { + // Policy creation failed (most likely another DOMPurify script has + // already run). Skip creating the policy, as this will only cause errors + // if TT are enforced. + console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); + return null; + } + }; + + function createDOMPurify() { + var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); + + var DOMPurify = function DOMPurify(root) { + return createDOMPurify(root); + }; + + /** + * Version label, exposed for easier checks + * if DOMPurify is up to date or not + */ + DOMPurify.version = '2.2.6'; + + /** + * Array of elements that DOMPurify removed during sanitation. + * Empty if nothing was removed. + */ + DOMPurify.removed = []; + + if (!window || !window.document || window.document.nodeType !== 9) { + // Not running in a browser, provide a factory function + // so that you can pass your own Window + DOMPurify.isSupported = false; + + return DOMPurify; + } + + var originalDocument = window.document; + + var document = window.document; + var DocumentFragment = window.DocumentFragment, + HTMLTemplateElement = window.HTMLTemplateElement, + Node = window.Node, + Element = window.Element, + NodeFilter = window.NodeFilter, + _window$NamedNodeMap = window.NamedNodeMap, + NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, + Text = window.Text, + Comment = window.Comment, + DOMParser = window.DOMParser, + trustedTypes = window.trustedTypes; + + + var ElementPrototype = Element.prototype; + + var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); + var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); + var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); + + // As per issue #47, the web-components registry is inherited by a + // new document created via createHTMLDocument. As per the spec + // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) + // a new empty registry is used when creating a template contents owner + // document, so we use that as our parent document to ensure nothing + // is inherited. + if (typeof HTMLTemplateElement === 'function') { + var template = document.createElement('template'); + if (template.content && template.content.ownerDocument) { + document = template.content.ownerDocument; + } + } + + var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); + var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : ''; + + var _document = document, + implementation = _document.implementation, + createNodeIterator = _document.createNodeIterator, + getElementsByTagName = _document.getElementsByTagName, + createDocumentFragment = _document.createDocumentFragment; + var importNode = originalDocument.importNode; + + + var documentMode = {}; + try { + documentMode = clone(document).documentMode ? document.documentMode : {}; + } catch (_) {} + + var hooks = {}; + + /** + * Expose whether this browser supports running the full DOMPurify. + */ + DOMPurify.isSupported = implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; + + var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, + ERB_EXPR$$1 = ERB_EXPR, + DATA_ATTR$$1 = DATA_ATTR, + ARIA_ATTR$$1 = ARIA_ATTR, + IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; + var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; + + /** + * We consider the elements and attributes below to be safe. Ideally + * don't add any new ones but feel free to remove unwanted ones. + */ + + /* allowed element names */ + + var ALLOWED_TAGS = null; + var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); + + /* Allowed attribute names */ + var ALLOWED_ATTR = null; + var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); + + /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ + var FORBID_TAGS = null; + + /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ + var FORBID_ATTR = null; + + /* Decide if ARIA attributes are okay */ + var ALLOW_ARIA_ATTR = true; + + /* Decide if custom data attributes are okay */ + var ALLOW_DATA_ATTR = true; + + /* Decide if unknown protocols are okay */ + var ALLOW_UNKNOWN_PROTOCOLS = false; + + /* Output should be safe for common template engines. + * This means, DOMPurify removes data attributes, mustaches and ERB + */ + var SAFE_FOR_TEMPLATES = false; + + /* Decide if document with <html>... should be returned */ + var WHOLE_DOCUMENT = false; + + /* Track whether config is already set on this instance of DOMPurify. */ + var SET_CONFIG = false; + + /* Decide if all elements (e.g. style, script) must be children of + * document.body. By default, browsers might move them to document.head */ + var FORCE_BODY = false; + + /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported). + * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead + */ + var RETURN_DOM = false; + + /* Decide if a DOM `DocumentFragment` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported) */ + var RETURN_DOM_FRAGMENT = false; + + /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM + * `Node` is imported into the current `Document`. If this flag is not enabled the + * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by + * DOMPurify. + * + * This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false` + * might cause XSS from attacks hidden in closed shadowroots in case the browser + * supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/ + */ + var RETURN_DOM_IMPORT = true; + + /* Try to return a Trusted Type object instead of a string, return a string in + * case Trusted Types are not supported */ + var RETURN_TRUSTED_TYPE = false; + + /* Output should be free from DOM clobbering attacks? */ + var SANITIZE_DOM = true; + + /* Keep element content when removing element? */ + var KEEP_CONTENT = true; + + /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead + * of importing it into a new Document and returning a sanitized copy */ + var IN_PLACE = false; + + /* Allow usage of profiles like html, svg and mathMl */ + var USE_PROFILES = {}; + + /* Tags to ignore content of when KEEP_CONTENT is true */ + var FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); + + /* Tags that are safe for data: URIs */ + var DATA_URI_TAGS = null; + var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); + + /* Attributes safe for values like "javascript:" */ + var URI_SAFE_ATTRIBUTES = null; + var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'summary', 'title', 'value', 'style', 'xmlns']); + + /* Keep a reference to config to pass to hooks */ + var CONFIG = null; + + /* Ideally, do not touch anything below this line */ + /* ______________________________________________ */ + + var formElement = document.createElement('form'); + + /** + * _parseConfig + * + * @param {Object} cfg optional config literal + */ + // eslint-disable-next-line complexity + var _parseConfig = function _parseConfig(cfg) { + if (CONFIG && CONFIG === cfg) { + return; + } + + /* Shield configuration object from tampering */ + if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { + cfg = {}; + } + + /* Shield configuration object from prototype pollution */ + cfg = clone(cfg); + + /* Set configuration parameters */ + ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; + ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; + URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES; + DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS; + FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {}; + FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {}; + USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false; + ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true + ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true + ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false + SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false + WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false + RETURN_DOM = cfg.RETURN_DOM || false; // Default false + RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false + RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true + RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false + FORCE_BODY = cfg.FORCE_BODY || false; // Default false + SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true + KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true + IN_PLACE = cfg.IN_PLACE || false; // Default false + IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; + if (SAFE_FOR_TEMPLATES) { + ALLOW_DATA_ATTR = false; + } + + if (RETURN_DOM_FRAGMENT) { + RETURN_DOM = true; + } + + /* Parse profile info */ + if (USE_PROFILES) { + ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); + ALLOWED_ATTR = []; + if (USE_PROFILES.html === true) { + addToSet(ALLOWED_TAGS, html); + addToSet(ALLOWED_ATTR, html$1); + } + + if (USE_PROFILES.svg === true) { + addToSet(ALLOWED_TAGS, svg); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.svgFilters === true) { + addToSet(ALLOWED_TAGS, svgFilters); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.mathMl === true) { + addToSet(ALLOWED_TAGS, mathMl); + addToSet(ALLOWED_ATTR, mathMl$1); + addToSet(ALLOWED_ATTR, xml); + } + } + + /* Merge configuration parameters */ + if (cfg.ADD_TAGS) { + if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { + ALLOWED_TAGS = clone(ALLOWED_TAGS); + } + + addToSet(ALLOWED_TAGS, cfg.ADD_TAGS); + } + + if (cfg.ADD_ATTR) { + if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { + ALLOWED_ATTR = clone(ALLOWED_ATTR); + } + + addToSet(ALLOWED_ATTR, cfg.ADD_ATTR); + } + + if (cfg.ADD_URI_SAFE_ATTR) { + addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR); + } + + /* Add #text in case KEEP_CONTENT is set to true */ + if (KEEP_CONTENT) { + ALLOWED_TAGS['#text'] = true; + } + + /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ + if (WHOLE_DOCUMENT) { + addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); + } + + /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ + if (ALLOWED_TAGS.table) { + addToSet(ALLOWED_TAGS, ['tbody']); + delete FORBID_TAGS.tbody; + } + + // Prevent further manipulation of configuration. + // Not available in IE8, Safari 5, etc. + if (freeze) { + freeze(cfg); + } + + CONFIG = cfg; + }; + + var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); + + var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); + + /* Keep track of all possible SVG and MathML tags + * so that we can perform the namespace checks + * correctly. */ + var ALL_SVG_TAGS = addToSet({}, svg); + addToSet(ALL_SVG_TAGS, svgFilters); + addToSet(ALL_SVG_TAGS, svgDisallowed); + + var ALL_MATHML_TAGS = addToSet({}, mathMl); + addToSet(ALL_MATHML_TAGS, mathMlDisallowed); + + var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + + /** + * + * + * @param {Element} element a DOM element whose namespace is being checked + * @returns {boolean} Return false if the element has a + * namespace that a spec-compliant parser would never + * return. Return true otherwise. + */ + var _checkValidNamespace = function _checkValidNamespace(element) { + var parent = getParentNode(element); + + // In JSDOM, if we're inside shadow DOM, then parentNode + // can be null. We just simulate parent in this case. + if (!parent || !parent.tagName) { + parent = { + namespaceURI: HTML_NAMESPACE, + tagName: 'template' + }; + } + + var tagName = stringToLowerCase(element.tagName); + var parentTagName = stringToLowerCase(parent.tagName); + + if (element.namespaceURI === SVG_NAMESPACE) { + // The only way to switch from HTML namespace to SVG + // is via <svg>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'svg'; + } + + // The only way to switch from MathML to SVG is via + // svg if parent is either <annotation-xml> or MathML + // text integration points. + if (parent.namespaceURI === MATHML_NAMESPACE) { + return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); + } + + // We only allow elements that are defined in SVG + // spec. All others are disallowed in SVG namespace. + return Boolean(ALL_SVG_TAGS[tagName]); + } + + if (element.namespaceURI === MATHML_NAMESPACE) { + // The only way to switch from HTML namespace to MathML + // is via <math>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'math'; + } + + // The only way to switch from SVG to MathML is via + // <math> and HTML integration points + if (parent.namespaceURI === SVG_NAMESPACE) { + return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; + } + + // We only allow elements that are defined in MathML + // spec. All others are disallowed in MathML namespace. + return Boolean(ALL_MATHML_TAGS[tagName]); + } + + if (element.namespaceURI === HTML_NAMESPACE) { + // The only way to switch from SVG to HTML is via + // HTML integration points, and from MathML to HTML + // is via MathML text integration points + if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + // Certain elements are allowed in both SVG and HTML + // namespace. We need to specify them explicitly + // so that they don't get erronously deleted from + // HTML namespace. + var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); + + // We disallow tags that are specific for MathML + // or SVG and should never appear in HTML namespace + return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); + } + + // The code should never reach this place (this means + // that the element somehow got namespace that is not + // HTML, SVG or MathML). Return false just in case. + return false; + }; + + /** + * _forceRemove + * + * @param {Node} node a DOM node + */ + var _forceRemove = function _forceRemove(node) { + arrayPush(DOMPurify.removed, { element: node }); + try { + node.parentNode.removeChild(node); + } catch (_) { + try { + node.outerHTML = emptyHTML; + } catch (_) { + node.remove(); + } + } + }; + + /** + * _removeAttribute + * + * @param {String} name an Attribute name + * @param {Node} node a DOM node + */ + var _removeAttribute = function _removeAttribute(name, node) { + try { + arrayPush(DOMPurify.removed, { + attribute: node.getAttributeNode(name), + from: node + }); + } catch (_) { + arrayPush(DOMPurify.removed, { + attribute: null, + from: node + }); + } + + node.removeAttribute(name); + }; + + /** + * _initDocument + * + * @param {String} dirty a string of dirty markup + * @return {Document} a DOM, filled with the dirty markup + */ + var _initDocument = function _initDocument(dirty) { + /* Create a HTML document */ + var doc = void 0; + var leadingWhitespace = void 0; + + if (FORCE_BODY) { + dirty = '<remove></remove>' + dirty; + } else { + /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ + var matches = stringMatch(dirty, /^[\r\n\t ]+/); + leadingWhitespace = matches && matches[0]; + } + + var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; + /* Use the DOMParser API by default, fallback later if needs be */ + try { + doc = new DOMParser().parseFromString(dirtyPayload, 'text/html'); + } catch (_) {} + + /* Use createHTMLDocument in case DOMParser is not available */ + if (!doc || !doc.documentElement) { + doc = implementation.createHTMLDocument(''); + var _doc = doc, + body = _doc.body; + + body.parentNode.removeChild(body.parentNode.firstElementChild); + body.outerHTML = dirtyPayload; + } + + if (dirty && leadingWhitespace) { + doc.body.insertBefore(document.createTextNode(leadingWhitespace), doc.body.childNodes[0] || null); + } + + /* Work on whole document or just its body */ + return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; + }; + + /** + * _createIterator + * + * @param {Document} root document/fragment to create iterator for + * @return {Iterator} iterator instance + */ + var _createIterator = function _createIterator(root) { + return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, function () { + return NodeFilter.FILTER_ACCEPT; + }, false); + }; + + /** + * _isClobbered + * + * @param {Node} elm element to check for clobbering attacks + * @return {Boolean} true if clobbered, false if safe + */ + var _isClobbered = function _isClobbered(elm) { + if (elm instanceof Text || elm instanceof Comment) { + return false; + } + + if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') { + return true; + } + + return false; + }; + + /** + * _isNode + * + * @param {Node} obj object to check whether it's a DOM node + * @return {Boolean} true is object is a DOM node + */ + var _isNode = function _isNode(object) { + return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; + }; + + /** + * _executeHook + * Execute user configurable hooks + * + * @param {String} entryPoint Name of the hook's entry point + * @param {Node} currentNode node to work on with the hook + * @param {Object} data additional hook parameters + */ + var _executeHook = function _executeHook(entryPoint, currentNode, data) { + if (!hooks[entryPoint]) { + return; + } + + arrayForEach(hooks[entryPoint], function (hook) { + hook.call(DOMPurify, currentNode, data, CONFIG); + }); + }; + + /** + * _sanitizeElements + * + * @protect nodeName + * @protect textContent + * @protect removeChild + * + * @param {Node} currentNode to check for permission to exist + * @return {Boolean} true if node was killed, false if left alive + */ + var _sanitizeElements = function _sanitizeElements(currentNode) { + var content = void 0; + + /* Execute a hook if present */ + _executeHook('beforeSanitizeElements', currentNode, null); + + /* Check if element is clobbered or can clobber */ + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Check if tagname contains Unicode */ + if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { + _forceRemove(currentNode); + return true; + } + + /* Now let's check the element's type and name */ + var tagName = stringToLowerCase(currentNode.nodeName); + + /* Execute a hook if present */ + _executeHook('uponSanitizeElement', currentNode, { + tagName: tagName, + allowedTags: ALLOWED_TAGS + }); + + /* Detect mXSS attempts abusing namespace confusion */ + if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { + _forceRemove(currentNode); + return true; + } + + /* Remove element if anything forbids its presence */ + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + /* Keep content except for bad-listed elements */ + if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { + var parentNode = getParentNode(currentNode); + var childNodes = getChildNodes(currentNode); + var childCount = childNodes.length; + for (var i = childCount - 1; i >= 0; --i) { + parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode)); + } + } + + _forceRemove(currentNode); + return true; + } + + /* Check whether element has a valid namespace */ + if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { + _forceRemove(currentNode); + return true; + } + + if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) { + _forceRemove(currentNode); + return true; + } + + /* Sanitize element content to be template-safe */ + if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { + /* Get the element's text content */ + content = currentNode.textContent; + content = stringReplace(content, MUSTACHE_EXPR$$1, ' '); + content = stringReplace(content, ERB_EXPR$$1, ' '); + if (currentNode.textContent !== content) { + arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); + currentNode.textContent = content; + } + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeElements', currentNode, null); + + return false; + }; + + /** + * _isValidAttribute + * + * @param {string} lcTag Lowercase tag name of containing element. + * @param {string} lcName Lowercase attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid, otherwise false. + */ + // eslint-disable-next-line complexity + var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { + /* Make sure attribute cannot clobber */ + if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { + return false; + } + + /* Allow valid data-* attributes: At least one character after "-" + (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) + XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) + We don't need to check the value; it's always URI safe. */ + if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { + return false; + + /* Check value is safe. First, is attr inert? If so, is safe */ + } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else { + return false; + } + + return true; + }; + + /** + * _sanitizeAttributes + * + * @protect attributes + * @protect nodeName + * @protect removeAttribute + * @protect setAttribute + * + * @param {Node} currentNode to sanitize + */ + var _sanitizeAttributes = function _sanitizeAttributes(currentNode) { + var attr = void 0; + var value = void 0; + var lcName = void 0; + var l = void 0; + /* Execute a hook if present */ + _executeHook('beforeSanitizeAttributes', currentNode, null); + + var attributes = currentNode.attributes; + + /* Check if we have attributes; if not we might have a text node */ + + if (!attributes) { + return; + } + + var hookEvent = { + attrName: '', + attrValue: '', + keepAttr: true, + allowedAttributes: ALLOWED_ATTR + }; + l = attributes.length; + + /* Go backwards over all attributes; safely remove bad ones */ + while (l--) { + attr = attributes[l]; + var _attr = attr, + name = _attr.name, + namespaceURI = _attr.namespaceURI; + + value = stringTrim(attr.value); + lcName = stringToLowerCase(name); + + /* Execute a hook if present */ + hookEvent.attrName = lcName; + hookEvent.attrValue = value; + hookEvent.keepAttr = true; + hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set + _executeHook('uponSanitizeAttribute', currentNode, hookEvent); + value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ + if (hookEvent.forceKeepAttr) { + continue; + } + + /* Remove attribute */ + _removeAttribute(name, currentNode); + + /* Did the hooks approve of the attribute? */ + if (!hookEvent.keepAttr) { + continue; + } + + /* Work around a security issue in jQuery 3.0 */ + if (regExpTest(/\/>/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Sanitize attribute content to be template-safe */ + if (SAFE_FOR_TEMPLATES) { + value = stringReplace(value, MUSTACHE_EXPR$$1, ' '); + value = stringReplace(value, ERB_EXPR$$1, ' '); + } + + /* Is `value` valid for this attribute? */ + var lcTag = currentNode.nodeName.toLowerCase(); + if (!_isValidAttribute(lcTag, lcName, value)) { + continue; + } + + /* Handle invalid data-* attribute set by try-catching it */ + try { + if (namespaceURI) { + currentNode.setAttributeNS(namespaceURI, name, value); + } else { + /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ + currentNode.setAttribute(name, value); + } + + arrayPop(DOMPurify.removed); + } catch (_) {} + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeAttributes', currentNode, null); + }; + + /** + * _sanitizeShadowDOM + * + * @param {DocumentFragment} fragment to iterate over recursively + */ + var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { + var shadowNode = void 0; + var shadowIterator = _createIterator(fragment); + + /* Execute a hook if present */ + _executeHook('beforeSanitizeShadowDOM', fragment, null); + + while (shadowNode = shadowIterator.nextNode()) { + /* Execute a hook if present */ + _executeHook('uponSanitizeShadowNode', shadowNode, null); + + /* Sanitize tags and elements */ + if (_sanitizeElements(shadowNode)) { + continue; + } + + /* Deep shadow DOM detected */ + if (shadowNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(shadowNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(shadowNode); + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeShadowDOM', fragment, null); + }; + + /** + * Sanitize + * Public method providing core sanitation functionality + * + * @param {String|Node} dirty string or DOM node + * @param {Object} configuration object + */ + // eslint-disable-next-line complexity + DOMPurify.sanitize = function (dirty, cfg) { + var body = void 0; + var importedNode = void 0; + var currentNode = void 0; + var oldNode = void 0; + var returnNode = void 0; + /* Make sure we have a string to sanitize. + DO NOT return early, as this will return the wrong type if + the user has requested a DOM object rather than a string */ + if (!dirty) { + dirty = '<!-->'; + } + + /* Stringify, in case dirty is an object */ + if (typeof dirty !== 'string' && !_isNode(dirty)) { + // eslint-disable-next-line no-negated-condition + if (typeof dirty.toString !== 'function') { + throw typeErrorCreate('toString is not a function'); + } else { + dirty = dirty.toString(); + if (typeof dirty !== 'string') { + throw typeErrorCreate('dirty is not a string, aborting'); + } + } + } + + /* Check we can run. Otherwise fall back or ignore */ + if (!DOMPurify.isSupported) { + if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') { + if (typeof dirty === 'string') { + return window.toStaticHTML(dirty); + } + + if (_isNode(dirty)) { + return window.toStaticHTML(dirty.outerHTML); + } + } + + return dirty; + } + + /* Assign config vars */ + if (!SET_CONFIG) { + _parseConfig(cfg); + } + + /* Clean up removed elements */ + DOMPurify.removed = []; + + /* Check if dirty is correctly typed for IN_PLACE */ + if (typeof dirty === 'string') { + IN_PLACE = false; + } + + if (IN_PLACE) ; else if (dirty instanceof Node) { + /* If dirty is a DOM element, append to an empty document to avoid + elements being stripped by the parser */ + body = _initDocument('<!---->'); + importedNode = body.ownerDocument.importNode(dirty, true); + if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') { + /* Node is already a body, use as is */ + body = importedNode; + } else if (importedNode.nodeName === 'HTML') { + body = importedNode; + } else { + // eslint-disable-next-line unicorn/prefer-node-append + body.appendChild(importedNode); + } + } else { + /* Exit directly if we have nothing to do */ + if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && + // eslint-disable-next-line unicorn/prefer-includes + dirty.indexOf('<') === -1) { + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; + } + + /* Initialize the document to work on */ + body = _initDocument(dirty); + + /* Check we have a DOM node from the data */ + if (!body) { + return RETURN_DOM ? null : emptyHTML; + } + } + + /* Remove first element node (ours) if FORCE_BODY is set */ + if (body && FORCE_BODY) { + _forceRemove(body.firstChild); + } + + /* Get node iterator */ + var nodeIterator = _createIterator(IN_PLACE ? dirty : body); + + /* Now start iterating over the created document */ + while (currentNode = nodeIterator.nextNode()) { + /* Fix IE's strange behavior with manipulated textNodes #89 */ + if (currentNode.nodeType === 3 && currentNode === oldNode) { + continue; + } + + /* Sanitize tags and elements */ + if (_sanitizeElements(currentNode)) { + continue; + } + + /* Shadow DOM detected, sanitize it */ + if (currentNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(currentNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(currentNode); + + oldNode = currentNode; + } + + oldNode = null; + + /* If we sanitized `dirty` in-place, return it. */ + if (IN_PLACE) { + return dirty; + } + + /* Return sanitized string or DOM */ + if (RETURN_DOM) { + if (RETURN_DOM_FRAGMENT) { + returnNode = createDocumentFragment.call(body.ownerDocument); + + while (body.firstChild) { + // eslint-disable-next-line unicorn/prefer-node-append + returnNode.appendChild(body.firstChild); + } + } else { + returnNode = body; + } + + if (RETURN_DOM_IMPORT) { + /* + AdoptNode() is not used because internal state is not reset + (e.g. the past names map of a HTMLFormElement), this is safe + in theory but we would rather not risk another attack vector. + The state that is cloned by importNode() is explicitly defined + by the specs. + */ + returnNode = importNode.call(originalDocument, returnNode, true); + } + + return returnNode; + } + + var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; + + /* Sanitize final string template-safe */ + if (SAFE_FOR_TEMPLATES) { + serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' '); + serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' '); + } + + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; + }; + + /** + * Public method to set the configuration once + * setConfig + * + * @param {Object} cfg configuration object + */ + DOMPurify.setConfig = function (cfg) { + _parseConfig(cfg); + SET_CONFIG = true; + }; + + /** + * Public method to remove the configuration + * clearConfig + * + */ + DOMPurify.clearConfig = function () { + CONFIG = null; + SET_CONFIG = false; + }; + + /** + * Public method to check if an attribute value is valid. + * Uses last set config, if any. Otherwise, uses config defaults. + * isValidAttribute + * + * @param {string} tag Tag name of containing element. + * @param {string} attr Attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false. + */ + DOMPurify.isValidAttribute = function (tag, attr, value) { + /* Initialize shared config vars if necessary. */ + if (!CONFIG) { + _parseConfig({}); + } + + var lcTag = stringToLowerCase(tag); + var lcName = stringToLowerCase(attr); + return _isValidAttribute(lcTag, lcName, value); + }; + + /** + * AddHook + * Public method to add DOMPurify hooks + * + * @param {String} entryPoint entry point for the hook to add + * @param {Function} hookFunction function to execute + */ + DOMPurify.addHook = function (entryPoint, hookFunction) { + if (typeof hookFunction !== 'function') { + return; + } + + hooks[entryPoint] = hooks[entryPoint] || []; + arrayPush(hooks[entryPoint], hookFunction); + }; + + /** + * RemoveHook + * Public method to remove a DOMPurify hook at a given entryPoint + * (pops it from the stack of hooks if more are present) + * + * @param {String} entryPoint entry point for the hook to remove + */ + DOMPurify.removeHook = function (entryPoint) { + if (hooks[entryPoint]) { + arrayPop(hooks[entryPoint]); + } + }; + + /** + * RemoveHooks + * Public method to remove all DOMPurify hooks at a given entryPoint + * + * @param {String} entryPoint entry point for the hooks to remove + */ + DOMPurify.removeHooks = function (entryPoint) { + if (hooks[entryPoint]) { + hooks[entryPoint] = []; + } + }; + + /** + * RemoveAllHooks + * Public method to remove all DOMPurify hooks + * + */ + DOMPurify.removeAllHooks = function () { + hooks = {}; + }; + + return DOMPurify; + } + + var purify = createDOMPurify(); + + var globalWin = window; + var globalDoc = document; + + var IMAGE_MIME_REGEX = /^image\/(p?jpe?g|gif|png|bmp)$/i; + + /** + * Wrap inlines that are in the root in paragraphs. + * + * @param {HTMLBodyElement} body + * @param {Document} doc + * @private + */ + function wrapInlines(body, doc) { + var wrapper; + + traverse(body, function (node) { + if (isInline(node, true)) { + // Ignore text nodes unless they contain non-whitespace chars as + // whitespace will be collapsed. + // Ignore sceditor-ignore elements unless wrapping siblings + // Should still wrap both if wrapping siblings. + if (wrapper || node.nodeType === TEXT_NODE ? + /\S/.test(node.nodeValue) : !is(node, '.sceditor-ignore')) { + if (!wrapper) { + wrapper = createElement('p', {}, doc); + insertBefore(wrapper, node); + } + + appendChild(wrapper, node); + } + } else { + wrapper = null; + } + }, false, true); + } + /** + * SCEditor - A lightweight WYSIWYG editor + * + * @param {HTMLTextAreaElement} original The textarea to be converted + * @param {Object} userOptions + * @class SCEditor + * @name SCEditor + */ + function SCEditor(original, userOptions) { + /** + * Alias of this + * + * @private + */ + var base = this; + + /** + * Editor format like BBCode or HTML + */ + var format; + + /** + * The div which contains the editor and toolbar + * + * @type {HTMLDivElement} + * @private + */ + var editorContainer; + + /** + * Map of events handlers bound to this instance. + * + * @type {Object} + * @private + */ + var eventHandlers = {}; + + /** + * The editors toolbar + * + * @type {HTMLDivElement} + * @private + */ + var toolbar; + + /** + * The editors iframe which should be in design mode + * + * @type {HTMLIFrameElement} + * @private + */ + var wysiwygEditor; + + /** + * The editors window + * + * @type {Window} + * @private + */ + var wysiwygWindow; + + /** + * The WYSIWYG editors body element + * + * @type {HTMLBodyElement} + * @private + */ + var wysiwygBody; + + /** + * The WYSIWYG editors document + * + * @type {Document} + * @private + */ + var wysiwygDocument; + + /** + * The editors textarea for viewing source + * + * @type {HTMLTextAreaElement} + * @private + */ + var sourceEditor; + + /** + * The current dropdown + * + * @type {HTMLDivElement} + * @private + */ + var dropdown; + + /** + * If the user is currently composing text via IME + * @type {boolean} + */ + var isComposing; + + /** + * Timer for valueChanged key handler + * @type {number} + */ + var valueChangedKeyUpTimer; + + /** + * The editors locale + * + * @private + */ + var locale; + + /** + * Stores a cache of preloaded images + * + * @private + * @type {Array.<HTMLImageElement>} + */ + var preLoadCache = []; + + /** + * The editors rangeHelper instance + * + * @type {RangeHelper} + * @private + */ + var rangeHelper; + + /** + * An array of button state handlers + * + * @type {Array.<Object>} + * @private + */ + var btnStateHandlers = []; + + /** + * Plugin manager instance + * + * @type {PluginManager} + * @private + */ + var pluginManager; + + /** + * The current node containing the selection/caret + * + * @type {Node} + * @private + */ + var currentNode; + + /** + * The first block level parent of the current node + * + * @type {node} + * @private + */ + var currentBlockNode; + + /** + * The current node selection/caret + * + * @type {Object} + * @private + */ + var currentSelection; + + /** + * Used to make sure only 1 selection changed + * check is called every 100ms. + * + * Helps improve performance as it is checked a lot. + * + * @type {boolean} + * @private + */ + var isSelectionCheckPending; + + /** + * If content is required (equivalent to the HTML5 required attribute) + * + * @type {boolean} + * @private + */ + var isRequired; + + /** + * The inline CSS style element. Will be undefined + * until css() is called for the first time. + * + * @type {HTMLStyleElement} + * @private + */ + var inlineCss; + + /** + * Object containing a list of shortcut handlers + * + * @type {Object} + * @private + */ + var shortcutHandlers = {}; + + /** + * The min and max heights that autoExpand should stay within + * + * @type {Object} + * @private + */ + var autoExpandBounds; + + /** + * Timeout for the autoExpand function to throttle calls + * + * @private + */ + var autoExpandThrottle; + + /** + * Cache of the current toolbar buttons + * + * @type {Object} + * @private + */ + var toolbarButtons = {}; + + /** + * Last scroll position before maximizing so + * it can be restored when finished. + * + * @type {number} + * @private + */ + var maximizeScrollPosition; + + /** + * Stores the contents while a paste is taking place. + * + * Needed to support browsers that lack clipboard API support. + * + * @type {?DocumentFragment} + * @private + */ + var pasteContentFragment; + + /** + * All the emoticons from dropdown, more and hidden combined + * and with the emoticons root set + * + * @type {!Object<string, string>} + * @private + */ + var allEmoticons = {}; + + /** + * Current icon set if any + * + * @type {?Object} + * @private + */ + var icons; + + /** + * Private functions + * @private + */ + var init, + replaceEmoticons, + handleCommand, + initEditor, + initLocale, + initToolBar, + initOptions, + initEvents, + initResize, + initEmoticons, + handlePasteEvt, + handleCutCopyEvt, + handlePasteData, + handleKeyDown, + handleBackSpace, + handleKeyPress, + handleFormReset, + handleMouseDown, + handleComposition, + handleEvent, + handleDocumentClick, + updateToolBar, + updateActiveButtons, + sourceEditorSelectedText, + appendNewLine, + checkSelectionChanged, + checkNodeChanged, + autofocus, + emoticonsKeyPress, + emoticonsCheckWhitespace, + currentStyledBlockNode, + triggerValueChanged, + valueChangedBlur, + valueChangedKeyUp, + autoUpdate, + autoExpand; + + /** + * All the commands supported by the editor + * @name commands + * @memberOf SCEditor.prototype + */ + base.commands = extend(true, {}, (userOptions.commands || defaultCmds)); + + /** + * Options for this editor instance + * @name opts + * @memberOf SCEditor.prototype + */ + var options = base.opts = extend( + true, {}, defaultOptions, userOptions + ); + + // Don't deep extend emoticons (fixes #565) + base.opts.emoticons = userOptions.emoticons || defaultOptions.emoticons; + + if (!Array.isArray(options.allowedIframeUrls)) { + options.allowedIframeUrls = []; + } + options.allowedIframeUrls.push('https://www.youtube-nocookie.com/embed/'); + + // Create new instance of DOMPurify for each editor instance so can + // have different allowed iframe URLs + // eslint-disable-next-line new-cap + var domPurify = purify(); + + // Allow iframes for things like YouTube, see: + // https://github.com/cure53/DOMPurify/issues/340#issuecomment-670758980 + domPurify.addHook('uponSanitizeElement', function (node, data) { + var allowedUrls = options.allowedIframeUrls; + + if (data.tagName === 'iframe') { + var src = attr(node, 'src') || ''; + + for (var i = 0; i < allowedUrls.length; i++) { + var url = allowedUrls[i]; + + if (isString(url) && src.substr(0, url.length) === url) { + return; + } + + // Handle regex + if (url.test && url.test(src)) { + return; + } + } + + // No match so remove + remove(node); + } + }); + + // Convert target attribute into data-sce-target attributes so XHTML format + // can allow them + domPurify.addHook('afterSanitizeAttributes', function (node) { + if ('target' in node) { + attr(node, 'data-sce-target', attr(node, 'target')); + } + + removeAttr(node, 'target'); + }); + + /** + * Sanitize HTML to avoid XSS + * + * @param {string} html + * @return {string} html + * @private + */ + function sanitize(html) { + return domPurify.sanitize(html, { + ADD_TAGS: ['iframe'], + ADD_ATTR: ['allowfullscreen', 'frameborder', 'target'] + }); + } + /** + * Creates the editor iframe and textarea + * @private + */ + init = function () { + original._sceditor = base; + + // Load locale + if (options.locale && options.locale !== 'en') { + initLocale(); + } + + editorContainer = createElement('div', { + className: 'sceditor-container' + }); + + insertBefore(editorContainer, original); + css(editorContainer, 'z-index', options.zIndex); + + isRequired = original.required; + original.required = false; + + var FormatCtor = SCEditor.formats[options.format]; + format = FormatCtor ? new FormatCtor() : {}; + /* + * Plugins should be initialized before the formatters since + * they may wish to add or change formatting handlers and + * since the bbcode format caches its handlers, + * such changes must be done first. + */ + pluginManager = new PluginManager(base); + (options.plugins || '').split(',').forEach(function (plugin) { + pluginManager.register(plugin.trim()); + }); + if ('init' in format) { + format.init.call(base); + } + + // create the editor + initEmoticons(); + initToolBar(); + initEditor(); + initOptions(); + initEvents(); + + // force into source mode if is a browser that can't handle + // full editing + if (!isWysiwygSupported) { + base.toggleSourceMode(); + } + + updateActiveButtons(); + + var loaded = function () { + off(globalWin, 'load', loaded); + + if (options.autofocus) { + autofocus(!!options.autofocusEnd); + } + + autoExpand(); + appendNewLine(); + // TODO: use editor doc and window? + pluginManager.call('ready'); + if ('onReady' in format) { + format.onReady.call(base); + } + }; + on(globalWin, 'load', loaded); + if (globalDoc.readyState === 'complete') { + loaded(); + } + }; + + /** + * Init the locale variable with the specified locale if possible + * @private + * @return void + */ + initLocale = function () { + var lang; + + locale = SCEditor.locale[options.locale]; + + if (!locale) { + lang = options.locale.split('-'); + locale = SCEditor.locale[lang[0]]; + } + + // Locale DateTime format overrides any specified in the options + if (locale && locale.dateFormat) { + options.dateFormat = locale.dateFormat; + } + }; + + /** + * Creates the editor iframe and textarea + * @private + */ + initEditor = function () { + sourceEditor = createElement('textarea'); + wysiwygEditor = createElement('iframe', { + frameborder: 0, + allowfullscreen: true + }); + + /* + * This needs to be done right after they are created because, + * for any reason, the user may not want the value to be tinkered + * by any filters. + */ + if (options.startInSourceMode) { + addClass(editorContainer, 'sourceMode'); + hide(wysiwygEditor); + } else { + addClass(editorContainer, 'wysiwygMode'); + hide(sourceEditor); + } + + if (!options.spellcheck) { + attr(editorContainer, 'spellcheck', 'false'); + } + + if (globalWin.location.protocol === 'https:') { + attr(wysiwygEditor, 'src', 'about:blank'); + } + + // Add the editor to the container + appendChild(editorContainer, wysiwygEditor); + appendChild(editorContainer, sourceEditor); + + // TODO: make this optional somehow + base.dimensions( + options.width || width(original), + options.height || height(original) + ); + + // Add ios to HTML so can apply CSS fix to only it + var className = ios ? ' ios' : ''; + + wysiwygDocument = wysiwygEditor.contentDocument; + wysiwygDocument.open(); + wysiwygDocument.write(_tmpl('html', { + attrs: ' class="' + className + '"', + spellcheck: options.spellcheck ? '' : 'spellcheck="false"', + charset: options.charset, + style: options.style + })); + wysiwygDocument.close(); + + wysiwygBody = wysiwygDocument.body; + wysiwygWindow = wysiwygEditor.contentWindow; + + base.readOnly(!!options.readOnly); + + // iframe overflow fix for iOS + if (ios) { + height(wysiwygBody, '100%'); + on(wysiwygBody, 'touchend', base.focus); + } + + var tabIndex = attr(original, 'tabindex'); + attr(sourceEditor, 'tabindex', tabIndex); + attr(wysiwygEditor, 'tabindex', tabIndex); + + rangeHelper = new RangeHelper(wysiwygWindow, null, sanitize); + + // load any textarea value into the editor + hide(original); + base.val(original.value); + + var placeholder = options.placeholder || + attr(original, 'placeholder'); + + if (placeholder) { + sourceEditor.placeholder = placeholder; + attr(wysiwygBody, 'placeholder', placeholder); + } + }; + + /** + * Initialises options + * @private + */ + initOptions = function () { + // auto-update original textbox on blur if option set to true + if (options.autoUpdate) { + on(wysiwygBody, 'blur', autoUpdate); + on(sourceEditor, 'blur', autoUpdate); + } + + if (options.rtl === null) { + options.rtl = css(sourceEditor, 'direction') === 'rtl'; + } + + base.rtl(!!options.rtl); + + if (options.autoExpand) { + // Need to update when images (or anything else) loads + on(wysiwygBody, 'load', autoExpand, EVENT_CAPTURE); + on(wysiwygBody, 'input keyup', autoExpand); + } + + if (options.resizeEnabled) { + initResize(); + } + + attr(editorContainer, 'id', options.id); + base.emoticons(options.emoticonsEnabled); + }; + + /** + * Initialises events + * @private + */ + initEvents = function () { + var form = original.form; + var compositionEvents = 'compositionstart compositionend'; + var eventsToForward = + 'keydown keyup keypress focus blur contextmenu input'; + var checkSelectionEvents = 'onselectionchange' in wysiwygDocument ? + 'selectionchange' : + 'keyup focus blur contextmenu mouseup touchend click'; + + on(globalDoc, 'click', handleDocumentClick); + + if (form) { + on(form, 'reset', handleFormReset); + on(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + on(window, 'pagehide', base.updateOriginal); + on(window, 'pageshow', handleFormReset); + on(wysiwygBody, 'keypress', handleKeyPress); + on(wysiwygBody, 'keydown', handleKeyDown); + on(wysiwygBody, 'keydown', handleBackSpace); + on(wysiwygBody, 'keyup', appendNewLine); + on(wysiwygBody, 'blur', valueChangedBlur); + on(wysiwygBody, 'keyup', valueChangedKeyUp); + on(wysiwygBody, 'paste', handlePasteEvt); + on(wysiwygBody, 'cut copy', handleCutCopyEvt); + on(wysiwygBody, compositionEvents, handleComposition); + on(wysiwygBody, checkSelectionEvents, checkSelectionChanged); + on(wysiwygBody, eventsToForward, handleEvent); + + if (options.emoticonsCompat && globalWin.getSelection) { + on(wysiwygBody, 'keyup', emoticonsCheckWhitespace); + } + + on(wysiwygBody, 'blur', function () { + if (!base.val()) { + addClass(wysiwygBody, 'placeholder'); + } + }); + + on(wysiwygBody, 'focus', function () { + removeClass(wysiwygBody, 'placeholder'); + }); + + on(sourceEditor, 'blur', valueChangedBlur); + on(sourceEditor, 'keyup', valueChangedKeyUp); + on(sourceEditor, 'keydown', handleKeyDown); + on(sourceEditor, compositionEvents, handleComposition); + on(sourceEditor, eventsToForward, handleEvent); + + on(wysiwygDocument, 'mousedown', handleMouseDown); + on(wysiwygDocument, checkSelectionEvents, checkSelectionChanged); + on(wysiwygDocument, 'keyup', appendNewLine); + + on(editorContainer, 'selectionchanged', checkNodeChanged); + on(editorContainer, 'selectionchanged', updateActiveButtons); + // Custom events to forward + on( + editorContainer, + 'selectionchanged valuechanged nodechanged pasteraw paste', + handleEvent + ); + }; + + /** + * Creates the toolbar and appends it to the container + * @private + */ + initToolBar = function () { + var group, + commands = base.commands, + exclude = (options.toolbarExclude || '').split(','), + groups = options.toolbar.split('|'); + + toolbar = createElement('div', { + className: 'sceditor-toolbar', + unselectable: 'on' + }); + + if (options.icons in SCEditor.icons) { + icons = new SCEditor.icons[options.icons](); + } + + each(groups, function (_, menuItems) { + group = createElement('div', { + className: 'sceditor-group' + }); + + each(menuItems.split(','), function (_, commandName) { + var button, shortcut, + command = commands[commandName]; + + // The commandName must be a valid command and not excluded + if (!command || exclude.indexOf(commandName) > -1) { + return; + } + + shortcut = command.shortcut; + button = _tmpl('toolbarButton', { + name: commandName, + dispName: base._(command.name || + command.tooltip || commandName) + }, true).firstChild; + + if (icons && icons.create) { + var icon = icons.create(commandName); + if (icon) { + insertBefore(icons.create(commandName), + button.firstChild); + addClass(button, 'has-icon'); + } + } + + button._sceTxtMode = !!command.txtExec; + button._sceWysiwygMode = !!command.exec; + toggleClass(button, 'disabled', !command.exec); + on(button, 'click', function (e) { + if (!hasClass(button, 'disabled')) { + handleCommand(button, command); + } + + updateActiveButtons(); + e.preventDefault(); + }); + // Prevent editor losing focus when button clicked + on(button, 'mousedown', function (e) { + base.closeDropDown(); + e.preventDefault(); + }); + + if (command.tooltip) { + attr(button, 'title', + base._(command.tooltip) + + (shortcut ? ' (' + shortcut + ')' : '') + ); + } + + if (shortcut) { + base.addShortcut(shortcut, commandName); + } + + if (command.state) { + btnStateHandlers.push({ + name: commandName, + state: command.state + }); + // exec string commands can be passed to queryCommandState + } else if (isString(command.exec)) { + btnStateHandlers.push({ + name: commandName, + state: command.exec + }); + } + + appendChild(group, button); + toolbarButtons[commandName] = button; + }); + + // Exclude empty groups + if (group.firstChild) { + appendChild(toolbar, group); + } + }); + + // Append the toolbar to the toolbarContainer option if given + appendChild(options.toolbarContainer || editorContainer, toolbar); + }; + + /** + * Creates the resizer. + * @private + */ + initResize = function () { + var minHeight, maxHeight, minWidth, maxWidth, + mouseMoveFunc, mouseUpFunc, + grip = createElement('div', { + className: 'sceditor-grip' + }), + // Cover is used to cover the editor iframe so document + // still gets mouse move events + cover = createElement('div', { + className: 'sceditor-resize-cover' + }), + moveEvents = 'touchmove mousemove', + endEvents = 'touchcancel touchend mouseup', + startX = 0, + startY = 0, + newX = 0, + newY = 0, + startWidth = 0, + startHeight = 0, + origWidth = width(editorContainer), + origHeight = height(editorContainer), + isDragging = false, + rtl = base.rtl(); + + minHeight = options.resizeMinHeight || origHeight / 1.5; + maxHeight = options.resizeMaxHeight || origHeight * 2.5; + minWidth = options.resizeMinWidth || origWidth / 1.25; + maxWidth = options.resizeMaxWidth || origWidth * 1.25; + + mouseMoveFunc = function (e) { + // iOS uses window.event + if (e.type === 'touchmove') { + e = globalWin.event; + newX = e.changedTouches[0].pageX; + newY = e.changedTouches[0].pageY; + } else { + newX = e.pageX; + newY = e.pageY; + } + + var newHeight = startHeight + (newY - startY), + newWidth = rtl ? + startWidth - (newX - startX) : + startWidth + (newX - startX); + + if (maxWidth > 0 && newWidth > maxWidth) { + newWidth = maxWidth; + } + if (minWidth > 0 && newWidth < minWidth) { + newWidth = minWidth; + } + if (!options.resizeWidth) { + newWidth = false; + } + + if (maxHeight > 0 && newHeight > maxHeight) { + newHeight = maxHeight; + } + if (minHeight > 0 && newHeight < minHeight) { + newHeight = minHeight; + } + if (!options.resizeHeight) { + newHeight = false; + } + + if (newWidth || newHeight) { + base.dimensions(newWidth, newHeight); + } + + e.preventDefault(); + }; + + mouseUpFunc = function (e) { + if (!isDragging) { + return; + } + + isDragging = false; + + hide(cover); + removeClass(editorContainer, 'resizing'); + off(globalDoc, moveEvents, mouseMoveFunc); + off(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }; + + if (icons && icons.create) { + var icon = icons.create('grip'); + if (icon) { + appendChild(grip, icon); + addClass(grip, 'has-icon'); + } + } + + appendChild(editorContainer, grip); + appendChild(editorContainer, cover); + hide(cover); + + on(grip, 'touchstart mousedown', function (e) { + // iOS uses window.event + if (e.type === 'touchstart') { + e = globalWin.event; + startX = e.touches[0].pageX; + startY = e.touches[0].pageY; + } else { + startX = e.pageX; + startY = e.pageY; + } + + startWidth = width(editorContainer); + startHeight = height(editorContainer); + isDragging = true; + + addClass(editorContainer, 'resizing'); + show(cover); + on(globalDoc, moveEvents, mouseMoveFunc); + on(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }); + }; + + /** + * Prefixes and preloads the emoticon images + * @private + */ + initEmoticons = function () { + var emoticons = options.emoticons; + var root = options.emoticonsRoot || ''; + + if (emoticons) { + allEmoticons = extend( + {}, emoticons.more, emoticons.dropdown, emoticons.hidden + ); + } + + each(allEmoticons, function (key, url) { + allEmoticons[key] = _tmpl('emoticon', { + key: key, + // Prefix emoticon root to emoticon urls + url: root + (url.url || url), + tooltip: url.tooltip || key + }); + + // Preload the emoticon + if (options.emoticonsEnabled) { + preLoadCache.push(createElement('img', { + src: root + (url.url || url) + })); + } + }); + }; + + /** + * Autofocus the editor + * @private + */ + autofocus = function (focusEnd) { + var range, txtPos, + node = wysiwygBody.firstChild; + + // Can't focus invisible elements + if (!isVisible(editorContainer)) { + return; + } + + if (base.sourceMode()) { + txtPos = focusEnd ? sourceEditor.value.length : 0; + + sourceEditor.setSelectionRange(txtPos, txtPos); + + return; + } + + removeWhiteSpace(wysiwygBody); + + if (focusEnd) { + if (!(node = wysiwygBody.lastChild)) { + node = createElement('p', {}, wysiwygDocument); + appendChild(wysiwygBody, node); + } + + while (node.lastChild) { + node = node.lastChild; + + // Should place the cursor before the last <br> + if (is(node, 'br') && node.previousSibling) { + node = node.previousSibling; + } + } + } + + range = wysiwygDocument.createRange(); + + if (!canHaveChildren(node)) { + range.setStartBefore(node); + + if (focusEnd) { + range.setStartAfter(node); + } + } else { + range.selectNodeContents(node); + } + + range.collapse(!focusEnd); + rangeHelper.selectRange(range); + currentSelection = range; + + if (focusEnd) { + wysiwygBody.scrollTop = wysiwygBody.scrollHeight; + } + + base.focus(); + }; + + /** + * Gets if the editor is read only + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly + * @return {boolean} + */ + /** + * Sets if the editor is read only + * + * @param {boolean} readOnly + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly^2 + * @return {this} + */ + base.readOnly = function (readOnly) { + if (typeof readOnly !== 'boolean') { + return !sourceEditor.readonly; + } + + wysiwygBody.contentEditable = !readOnly; + sourceEditor.readonly = !readOnly; + + updateToolBar(readOnly); + + return base; + }; + + /** + * Gets if the editor is in RTL mode + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl + * @return {boolean} + */ + /** + * Sets if the editor is in RTL mode + * + * @param {boolean} rtl + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl^2 + * @return {this} + */ + base.rtl = function (rtl) { + var dir = rtl ? 'rtl' : 'ltr'; + + if (typeof rtl !== 'boolean') { + return attr(sourceEditor, 'dir') === 'rtl'; + } + + attr(wysiwygBody, 'dir', dir); + attr(sourceEditor, 'dir', dir); + + removeClass(editorContainer, 'rtl'); + removeClass(editorContainer, 'ltr'); + addClass(editorContainer, dir); + + if (icons && icons.rtl) { + icons.rtl(rtl); + } + + return base; + }; + + /** + * Updates the toolbar to disable/enable the appropriate buttons + * @private + */ + updateToolBar = function (disable) { + var mode = base.inSourceMode() ? '_sceTxtMode' : '_sceWysiwygMode'; + + each(toolbarButtons, function (_, button) { + toggleClass(button, 'disabled', disable || !button[mode]); + }); + }; + + /** + * Gets the width of the editor in pixels + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width + * @return {number} + */ + /** + * Sets the width of the editor + * + * @param {number} width Width in pixels + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width^2 + * @return {this} + */ + /** + * Sets the width of the editor + * + * The saveWidth specifies if to save the width. The stored width can be + * used for things like restoring from maximized state. + * + * @param {number} width Width in pixels + * @param {boolean} [saveWidth=true] If to store the width + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name width^3 + * @return {this} + */ + base.width = function (width$1, saveWidth) { + if (!width$1 && width$1 !== 0) { + return width(editorContainer); + } + + base.dimensions(width$1, null, saveWidth); + + return base; + }; + + /** + * Returns an object with the properties width and height + * which are the width and height of the editor in px. + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions + * @return {object} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^2 + * @return {this} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * <p>The save argument specifies if to save the new sizes. + * The saved sizes can be used for things like restoring from + * maximized state. This should normally be left as true.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @param {boolean} [save=true] If to store the new sizes + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^3 + * @return {this} + */ + base.dimensions = function (width$1, height$1, save) { + // set undefined width/height to boolean false + width$1 = (!width$1 && width$1 !== 0) ? false : width$1; + height$1 = (!height$1 && height$1 !== 0) ? false : height$1; + + if (width$1 === false && height$1 === false) { + return { width: base.width(), height: base.height() }; + } + + if (width$1 !== false) { + if (save !== false) { + options.width = width$1; + } + + width(editorContainer, width$1); + } + + if (height$1 !== false) { + if (save !== false) { + options.height = height$1; + } + + height(editorContainer, height$1); + } + + return base; + }; + + /** + * Gets the height of the editor in px + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height + * @return {number} + */ + /** + * Sets the height of the editor + * + * @param {number} height Height in px + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height^2 + * @return {this} + */ + /** + * Sets the height of the editor + * + * The saveHeight specifies if to save the height. + * + * The stored height can be used for things like + * restoring from maximized state. + * + * @param {number} height Height in px + * @param {boolean} [saveHeight=true] If to store the height + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name height^3 + * @return {this} + */ + base.height = function (height$1, saveHeight) { + if (!height$1 && height$1 !== 0) { + return height(editorContainer); + } + + base.dimensions(null, height$1, saveHeight); + + return base; + }; + + /** + * Gets if the editor is maximised or not + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize + * @return {boolean} + */ + /** + * Sets if the editor is maximised or not + * + * @param {boolean} maximize If to maximise the editor + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize^2 + * @return {this} + */ + base.maximize = function (maximize) { + var maximizeSize = 'sceditor-maximize'; + + if (isUndefined(maximize)) { + return hasClass(editorContainer, maximizeSize); + } + + maximize = !!maximize; + + if (maximize) { + maximizeScrollPosition = globalWin.pageYOffset; + } + + toggleClass(globalDoc.documentElement, maximizeSize, maximize); + toggleClass(globalDoc.body, maximizeSize, maximize); + toggleClass(editorContainer, maximizeSize, maximize); + base.width(maximize ? '100%' : options.width, false); + base.height(maximize ? '100%' : options.height, false); + + if (!maximize) { + globalWin.scrollTo(0, maximizeScrollPosition); + } + + autoExpand(); + + return base; + }; + + autoExpand = function () { + if (options.autoExpand && !autoExpandThrottle) { + autoExpandThrottle = setTimeout(base.expandToContent, 200); + } + }; + + /** + * Expands or shrinks the editors height to the height of it's content + * + * Unless ignoreMaxHeight is set to true it will not expand + * higher than the maxHeight option. + * + * @since 1.3.5 + * @param {boolean} [ignoreMaxHeight=false] + * @function + * @name expandToContent + * @memberOf SCEditor.prototype + * @see #resizeToContent + */ + base.expandToContent = function (ignoreMaxHeight) { + if (base.maximize()) { + return; + } + + clearTimeout(autoExpandThrottle); + autoExpandThrottle = false; + + if (!autoExpandBounds) { + var height$1 = options.resizeMinHeight || options.height || + height(original); + + autoExpandBounds = { + min: height$1, + max: options.resizeMaxHeight || (height$1 * 2) + }; + } + + var range = globalDoc.createRange(); + range.selectNodeContents(wysiwygBody); + + var rect = range.getBoundingClientRect(); + var current = wysiwygDocument.documentElement.clientHeight - 1; + var spaceNeeded = rect.bottom - rect.top; + var newHeight = base.height() + 1 + (spaceNeeded - current); + + if (!ignoreMaxHeight && autoExpandBounds.max !== -1) { + newHeight = Math.min(newHeight, autoExpandBounds.max); + } + + base.height(Math.ceil(Math.max(newHeight, autoExpandBounds.min))); + }; + + /** + * Destroys the editor, removing all elements and + * event handlers. + * + * Leaves only the original textarea. + * + * @function + * @name destroy + * @memberOf SCEditor.prototype + */ + base.destroy = function () { + // Don't destroy if the editor has already been destroyed + if (!pluginManager) { + return; + } + + pluginManager.destroy(); + + rangeHelper = null; + pluginManager = null; + + if (dropdown) { + remove(dropdown); + } + + off(globalDoc, 'click', handleDocumentClick); + + var form = original.form; + if (form) { + off(form, 'reset', handleFormReset); + off(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + off(window, 'pagehide', base.updateOriginal); + off(window, 'pageshow', handleFormReset); + remove(sourceEditor); + remove(toolbar); + remove(editorContainer); + + delete original._sceditor; + show(original); + + original.required = isRequired; + }; + + + /** + * Creates a menu item drop down + * + * @param {HTMLElement} menuItem The button to align the dropdown with + * @param {string} name Used for styling the dropdown, will be + * a class sceditor-name + * @param {HTMLElement} content The HTML content of the dropdown + * @function + * @name createDropDown + * @memberOf SCEditor.prototype + */ + base.createDropDown = function (menuItem, name, content) { + // first click for create second click for close + var dropDownCss, + dropDownClass = 'sceditor-' + name; + + base.closeDropDown(); + + // Only close the dropdown if it was already open + if (dropdown && hasClass(dropdown, dropDownClass)) { + return; + } + + dropDownCss = extend({ + top: menuItem.offsetTop, + left: menuItem.offsetLeft, + marginTop: menuItem.clientHeight + }, options.dropDownCss); + + dropdown = createElement('div', { + className: 'sceditor-dropdown ' + dropDownClass + }); + + css(dropdown, dropDownCss); + appendChild(dropdown, content); + appendChild(editorContainer, dropdown); + on(dropdown, 'click focusin', function (e) { + // stop clicks within the dropdown from being handled + e.stopPropagation(); + }); + + if (dropdown) { + var first = find(dropdown, 'input,textarea')[0]; + if (first) { + first.focus(); + } + } + }; + + /** + * Handles any document click and closes the dropdown if open + * @private + */ + handleDocumentClick = function (e) { + // ignore right clicks + if (e.which !== 3 && dropdown && !e.defaultPrevented) { + autoUpdate(); + + base.closeDropDown(); + } + }; + + /** + * Handles the WYSIWYG editors cut & copy events + * + * By default browsers also copy inherited styling from the stylesheet and + * browser default styling which is unnecessary. + * + * This will ignore inherited styles and only copy inline styling. + * @private + */ + handleCutCopyEvt = function (e) { + var range = rangeHelper.selectedRange(); + if (range) { + var container = createElement('div', {}, wysiwygDocument); + var firstParent; + + // Copy all inline parent nodes up to the first block parent so can + // copy inline styles + var parent = range.commonAncestorContainer; + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + if (container.firstChild) { + appendChild(clone, container.firstChild); + } + + appendChild(container, clone); + firstParent = firstParent || clone; + } + parent = parent.parentNode; + } + + appendChild(firstParent || container, range.cloneContents()); + removeWhiteSpace(container); + + e.clipboardData.setData('text/html', container.innerHTML); + + // TODO: Refactor into private shared module with plaintext plugin + // innerText adds two newlines after <p> tags so convert them to + // <div> tags + each(find(container, 'p'), function (_, elm) { + convertElement(elm, 'div'); + }); + // Remove collapsed <br> tags as innerText converts them to newlines + each(find(container, 'br'), function (_, elm) { + if (!elm.nextSibling || !isInline(elm.nextSibling, true)) { + remove(elm); + } + }); + + // range.toString() doesn't include newlines so can't use that. + // selection.toString() seems to use the same method as innerText + // but needs to be normalised first so using container.innerText + appendChild(wysiwygBody, container); + e.clipboardData.setData('text/plain', container.innerText); + remove(container); + + if (e.type === 'cut') { + range.deleteContents(); + } + + e.preventDefault(); + } + }; + + /** + * Handles the WYSIWYG editors paste event + * @private + */ + handlePasteEvt = function (e) { + var editable = wysiwygBody; + var clipboard = e.clipboardData; + var loadImage = function (file) { + var reader = new FileReader(); + reader.onload = function (e) { + handlePasteData({ + html: '<img src="' + e.target.result + '" />' + }); + }; + reader.readAsDataURL(file); + }; + + // Modern browsers with clipboard API - everything other than _very_ + // old android web views and UC browser which doesn't support the + // paste event at all. + if (clipboard) { + var data = {}; + var types = clipboard.types; + var items = clipboard.items; + + e.preventDefault(); + + for (var i = 0; i < types.length; i++) { + // Word sometimes adds copied text as an image so if HTML + // exists prefer that over images + if (types.indexOf('text/html') < 0) { + // Normalise image pasting to paste as a data-uri + if (globalWin.FileReader && items && + IMAGE_MIME_REGEX.test(items[i].type)) { + return loadImage(clipboard.items[i].getAsFile()); + } + } + + data[types[i]] = clipboard.getData(types[i]); + } + // Call plugins here with file? + data.text = data['text/plain']; + data.html = sanitize(data['text/html']); + + handlePasteData(data); + // If contentsFragment exists then we are already waiting for a + // previous paste so let the handler for that handle this one too + } else if (!pasteContentFragment) { + // Save the scroll position so can be restored + // when contents is restored + var scrollTop = editable.scrollTop; + + rangeHelper.saveRange(); + + pasteContentFragment = globalDoc.createDocumentFragment(); + while (editable.firstChild) { + appendChild(pasteContentFragment, editable.firstChild); + } + + setTimeout(function () { + var html = editable.innerHTML; + + editable.innerHTML = ''; + appendChild(editable, pasteContentFragment); + editable.scrollTop = scrollTop; + pasteContentFragment = false; + + rangeHelper.restoreRange(); + + handlePasteData({ html: sanitize(html) }); + }, 0); + } + }; + + /** + * Gets the pasted data, filters it and then inserts it. + * @param {Object} data + * @private + */ + handlePasteData = function (data) { + var pasteArea = createElement('div', {}, wysiwygDocument); + + pluginManager.call('pasteRaw', data); + trigger(editorContainer, 'pasteraw', data); + + if (data.html) { + // Sanitize again in case plugins modified the HTML + pasteArea.innerHTML = sanitize(data.html); + + // fix any invalid nesting + fixNesting(pasteArea); + } else { + pasteArea.innerHTML = entities(data.text || ''); + } + + var paste = { + val: pasteArea.innerHTML + }; + + if ('fragmentToSource' in format) { + paste.val = format + .fragmentToSource(paste.val, wysiwygDocument, currentNode); + } + + pluginManager.call('paste', paste); + trigger(editorContainer, 'paste', paste); + + if ('fragmentToHtml' in format) { + paste.val = format + .fragmentToHtml(paste.val, currentNode); + } + + pluginManager.call('pasteHtml', paste); + + var parent = rangeHelper.getFirstBlockParent(); + base.wysiwygEditorInsertHtml(paste.val, null, true); + merge(parent); + }; + + /** + * Closes any currently open drop down + * + * @param {boolean} [focus=false] If to focus the editor + * after closing the drop down + * @function + * @name closeDropDown + * @memberOf SCEditor.prototype + */ + base.closeDropDown = function (focus) { + if (dropdown) { + remove(dropdown); + dropdown = null; + } + + if (focus === true) { + base.focus(); + } + }; + + + /** + * Inserts HTML into WYSIWYG editor. + * + * If endHtml is specified, any selected text will be placed + * between html and endHtml. If there is no selected text html + * and endHtml will just be concatenate together. + * + * @param {string} html + * @param {string} [endHtml=null] + * @param {boolean} [overrideCodeBlocking=false] If to insert the html + * into code tags, by + * default code tags only + * support text. + * @function + * @name wysiwygEditorInsertHtml + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertHtml = function ( + html, endHtml, overrideCodeBlocking + ) { + var marker, scrollTop, scrollTo, + editorHeight = height(wysiwygEditor); + + base.focus(); + + // TODO: This code tag should be configurable and + // should maybe convert the HTML into text instead + // Don't apply to code elements + if (!overrideCodeBlocking && closest(currentBlockNode, 'code')) { + return; + } + + // Insert the HTML and save the range so the editor can be scrolled + // to the end of the selection. Also allows emoticons to be replaced + // without affecting the cursor position + rangeHelper.insertHTML(html, endHtml); + rangeHelper.saveRange(); + replaceEmoticons(); + + // Fix any invalid nesting, e.g. if a quote or other block is inserted + // into a paragraph + fixNesting(wysiwygBody); + + // Scroll the editor after the end of the selection + marker = find(wysiwygBody, '#sceditor-end-marker')[0]; + show(marker); + scrollTop = wysiwygBody.scrollTop; + scrollTo = (getOffset(marker).top + + (marker.offsetHeight * 1.5)) - editorHeight; + hide(marker); + + // Only scroll if marker isn't already visible + if (scrollTo > scrollTop || scrollTo + editorHeight < scrollTop) { + wysiwygBody.scrollTop = scrollTo; + } + + triggerValueChanged(false); + rangeHelper.restoreRange(); + + // Add a new line after the last block element + // so can always add text after it + appendNewLine(); + }; + + /** + * Like wysiwygEditorInsertHtml except it will convert any HTML + * into text before inserting it. + * + * @param {string} text + * @param {string} [endText=null] + * @function + * @name wysiwygEditorInsertText + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertText = function (text, endText) { + base.wysiwygEditorInsertHtml( + entities(text), entities(endText) + ); + }; + + /** + * Inserts text into the WYSIWYG or source editor depending on which + * mode the editor is in. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.3.5 + * @function + * @name insertText + * @memberOf SCEditor.prototype + */ + base.insertText = function (text, endText) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(text, endText); + } else { + base.wysiwygEditorInsertText(text, endText); + } + + return base; + }; + + /** + * Like wysiwygEditorInsertHtml but inserts text into the + * source mode editor instead. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * The cursor will be placed after the text param. If endText is + * specified the cursor will be placed before endText, so passing:<br /> + * + * '[b]', '[/b]' + * + * Would cause the cursor to be placed:<br /> + * + * [b]Selected text|[/b] + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.4.0 + * @function + * @name sourceEditorInsertText + * @memberOf SCEditor.prototype + */ + base.sourceEditorInsertText = function (text, endText) { + var scrollTop, currentValue, + startPos = sourceEditor.selectionStart, + endPos = sourceEditor.selectionEnd; + + scrollTop = sourceEditor.scrollTop; + sourceEditor.focus(); + currentValue = sourceEditor.value; + + if (endText) { + text += currentValue.substring(startPos, endPos) + endText; + } + + sourceEditor.value = currentValue.substring(0, startPos) + + text + + currentValue.substring(endPos, currentValue.length); + + sourceEditor.selectionStart = (startPos + text.length) - + (endText ? endText.length : 0); + sourceEditor.selectionEnd = sourceEditor.selectionStart; + + sourceEditor.scrollTop = scrollTop; + sourceEditor.focus(); + + triggerValueChanged(); + }; + + /** + * Gets the current instance of the rangeHelper class + * for the editor. + * + * @return {RangeHelper} + * @function + * @name getRangeHelper + * @memberOf SCEditor.prototype + */ + base.getRangeHelper = function () { + return rangeHelper; + }; + + /** + * Gets or sets the source editor caret position. + * + * @param {Object} [position] + * @return {this} + * @function + * @since 1.4.5 + * @name sourceEditorCaret + * @memberOf SCEditor.prototype + */ + base.sourceEditorCaret = function (position) { + sourceEditor.focus(); + + if (position) { + sourceEditor.selectionStart = position.start; + sourceEditor.selectionEnd = position.end; + + return this; + } + + return { + start: sourceEditor.selectionStart, + end: sourceEditor.selectionEnd + }; + }; + + /** + * Gets the value of the editor. + * + * If the editor is in WYSIWYG mode it will return the filtered + * HTML from it (converted to BBCode if using the BBCode plugin). + * It it's in Source Mode it will return the unfiltered contents + * of the source editor (if using the BBCode plugin this will be + * BBCode again). + * + * @since 1.3.5 + * @return {string} + * @function + * @name val + * @memberOf SCEditor.prototype + */ + /** + * Sets the value of the editor. + * + * If filter set true the val will be passed through the filter + * function. If using the BBCode plugin it will pass the val to + * the BBCode filter to convert any BBCode into HTML. + * + * @param {string} val + * @param {boolean} [filter=true] + * @return {this} + * @since 1.3.5 + * @function + * @name val^2 + * @memberOf SCEditor.prototype + */ + base.val = function (val, filter) { + if (!isString(val)) { + return base.inSourceMode() ? + base.getSourceEditorValue(false) : + base.getWysiwygEditorValue(filter); + } + + if (!base.inSourceMode()) { + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + base.setWysiwygEditorValue(val); + } else { + base.setSourceEditorValue(val); + } + + return base; + }; + + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @return {this} + * @since 1.3.5 + * @function + * @name insert + * @memberOf SCEditor.prototype + */ + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * If the allowMixed param is set to true, HTML any will not be + * escaped + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @param {boolean} [allowMixed=false] + * @return {this} + * @since 1.4.3 + * @function + * @name insert^2 + * @memberOf SCEditor.prototype + */ + // eslint-disable-next-line max-params + base.insert = function ( + start, end, filter, convertEmoticons, allowMixed + ) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(start, end); + return base; + } + + // Add the selection between start and end + if (end) { + var html = rangeHelper.selectedHtml(); + + if (filter !== false && 'fragmentToSource' in format) { + html = format + .fragmentToSource(html, wysiwygDocument, currentNode); + } + + start += html + end; + } + // TODO: This filter should allow empty tags as it's inserting. + if (filter !== false && 'fragmentToHtml' in format) { + start = format.fragmentToHtml(start, currentNode); + } + + // Convert any escaped HTML back into HTML if mixed is allowed + if (filter !== false && allowMixed === true) { + start = start.replace(/</g, '<') + .replace(/>/g, '>') + .replace(/&/g, '&'); + } + + base.wysiwygEditorInsertHtml(start); + + return base; + }; + + /** + * Gets the WYSIWYG editors HTML value. + * + * If using a plugin that filters the Ht Ml like the BBCode plugin + * it will return the result of the filtering (BBCode) unless the + * filter param is set to false. + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @name getWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.getWysiwygEditorValue = function (filter) { + var html; + // Create a tmp node to store contents so it can be modified + // without affecting anything else. + var tmp = createElement('div', {}, wysiwygDocument); + var childNodes = wysiwygBody.childNodes; + + for (var i = 0; i < childNodes.length; i++) { + appendChild(tmp, childNodes[i].cloneNode(true)); + } + + appendChild(wysiwygBody, tmp); + fixNesting(tmp); + remove(tmp); + + html = tmp.innerHTML; + + // filter the HTML and DOM through any plugins + if (filter !== false && format.hasOwnProperty('toSource')) { + html = format.toSource(html, wysiwygDocument); + } + + return html; + }; + + /** + * Gets the WYSIWYG editor's iFrame Body. + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getBody + * @memberOf SCEditor.prototype + */ + base.getBody = function () { + return wysiwygBody; + }; + + /** + * Gets the WYSIWYG editors container area (whole iFrame). + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getContentAreaContainer + * @memberOf SCEditor.prototype + */ + base.getContentAreaContainer = function () { + return wysiwygEditor; + }; + + /** + * Gets the text editor value + * + * If using a plugin that filters the text like the BBCode plugin + * it will return the result of the filtering which is BBCode to + * HTML so it will return HTML. If filter is set to false it will + * just return the contents of the source editor (BBCode). + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @since 1.4.0 + * @name getSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.getSourceEditorValue = function (filter) { + var val = sourceEditor.value; + + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + return val; + }; + + /** + * Sets the WYSIWYG HTML editor value. Should only be the HTML + * contained within the body tags + * + * @param {string} value + * @function + * @name setWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.setWysiwygEditorValue = function (value) { + if (!value) { + value = '<p><br /></p>'; + } + + wysiwygBody.innerHTML = sanitize(value); + replaceEmoticons(); + + appendNewLine(); + triggerValueChanged(); + autoExpand(); + }; + + /** + * Sets the text editor value + * + * @param {string} value + * @function + * @name setSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.setSourceEditorValue = function (value) { + sourceEditor.value = value; + + triggerValueChanged(); + }; + + /** + * Updates the textarea that the editor is replacing + * with the value currently inside the editor. + * + * @function + * @name updateOriginal + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.updateOriginal = function () { + original.value = base.val(); + }; + + /** + * Replaces any emoticon codes in the passed HTML + * with their emoticon images + * @private + */ + replaceEmoticons = function () { + if (options.emoticonsEnabled) { + replace(wysiwygBody, allEmoticons, options.emoticonsCompat); + } + }; + + /** + * If the editor is in source code mode + * + * @return {boolean} + * @function + * @name inSourceMode + * @memberOf SCEditor.prototype + */ + base.inSourceMode = function () { + return hasClass(editorContainer, 'sourceMode'); + }; + + /** + * Gets if the editor is in sourceMode + * + * @return boolean + * @function + * @name sourceMode + * @memberOf SCEditor.prototype + */ + /** + * Sets if the editor is in sourceMode + * + * @param {boolean} enable + * @return {this} + * @function + * @name sourceMode^2 + * @memberOf SCEditor.prototype + */ + base.sourceMode = function (enable) { + var inSourceMode = base.inSourceMode(); + + if (typeof enable !== 'boolean') { + return inSourceMode; + } + + if ((inSourceMode && !enable) || (!inSourceMode && enable)) { + base.toggleSourceMode(); + } + + return base; + }; + + /** + * Switches between the WYSIWYG and source modes + * + * @function + * @name toggleSourceMode + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.toggleSourceMode = function () { + var isInSourceMode = base.inSourceMode(); + + // don't allow switching to WYSIWYG if doesn't support it + if (!isWysiwygSupported && isInSourceMode) { + return; + } + + if (!isInSourceMode) { + rangeHelper.saveRange(); + rangeHelper.clear(); + } + + currentSelection = null; + base.blur(); + + if (isInSourceMode) { + base.setWysiwygEditorValue(base.getSourceEditorValue()); + } else { + base.setSourceEditorValue(base.getWysiwygEditorValue()); + } + + toggle(sourceEditor); + toggle(wysiwygEditor); + + toggleClass(editorContainer, 'wysiwygMode', isInSourceMode); + toggleClass(editorContainer, 'sourceMode', !isInSourceMode); + + updateToolBar(); + updateActiveButtons(); + }; + + /** + * Gets the selected text of the source editor + * @return {string} + * @private + */ + sourceEditorSelectedText = function () { + sourceEditor.focus(); + + return sourceEditor.value.substring( + sourceEditor.selectionStart, + sourceEditor.selectionEnd + ); + }; + + /** + * Handles the passed command + * @private + */ + handleCommand = function (caller, cmd) { + // check if in text mode and handle text commands + if (base.inSourceMode()) { + if (cmd.txtExec) { + if (Array.isArray(cmd.txtExec)) { + base.sourceEditorInsertText.apply(base, cmd.txtExec); + } else { + cmd.txtExec.call(base, caller, sourceEditorSelectedText()); + } + } + } else if (cmd.exec) { + if (isFunction(cmd.exec)) { + cmd.exec.call(base, caller); + } else { + base.execCommand( + cmd.exec, + cmd.hasOwnProperty('execParam') ? cmd.execParam : null + ); + } + } + + }; + + /** + * Executes a command on the WYSIWYG editor + * + * @param {string} command + * @param {String|Boolean} [param] + * @function + * @name execCommand + * @memberOf SCEditor.prototype + */ + base.execCommand = function (command, param) { + var executed = false, + commandObj = base.commands[command]; + + base.focus(); + + // TODO: make configurable + // don't apply any commands to code elements + if (closest(rangeHelper.parentNode(), 'code')) { + return; + } + + try { + executed = wysiwygDocument.execCommand(command, false, param); + } catch (ex) { } + + // show error if execution failed and an error message exists + if (!executed && commandObj && commandObj.errorMessage) { + /*global alert:false*/ + alert(base._(commandObj.errorMessage)); + } + + updateActiveButtons(); + }; + + /** + * Checks if the current selection has changed and triggers + * the selectionchanged event if it has. + * + * In browsers other that don't support selectionchange event it will check + * at most once every 100ms. + * @private + */ + checkSelectionChanged = function () { + function check() { + // Don't create new selection if there isn't one (like after + // blur event in iOS) + if (wysiwygWindow.getSelection() && + wysiwygWindow.getSelection().rangeCount <= 0) { + currentSelection = null; + // rangeHelper could be null if editor was destroyed + // before the timeout had finished + } else if (rangeHelper && !rangeHelper.compare(currentSelection)) { + currentSelection = rangeHelper.cloneSelected(); + + // If the selection is in an inline wrap it in a block. + // Fixes #331 + if (currentSelection && currentSelection.collapsed) { + var parent = currentSelection.startContainer; + var offset = currentSelection.startOffset; + + // Handle if selection is placed before/after an element + if (offset && parent.nodeType !== TEXT_NODE) { + parent = parent.childNodes[offset]; + } + + while (parent && parent.parentNode !== wysiwygBody) { + parent = parent.parentNode; + } + + if (parent && isInline(parent, true)) { + rangeHelper.saveRange(); + wrapInlines(wysiwygBody, wysiwygDocument); + rangeHelper.restoreRange(); + } + } + + trigger(editorContainer, 'selectionchanged'); + } + + isSelectionCheckPending = false; + } + + if (isSelectionCheckPending) { + return; + } + + isSelectionCheckPending = true; + + // Don't need to limit checking if browser supports the Selection API + if ('onselectionchange' in wysiwygDocument) { + check(); + } else { + setTimeout(check, 100); + } + }; + + /** + * Checks if the current node has changed and triggers + * the nodechanged event if it has + * @private + */ + checkNodeChanged = function () { + // check if node has changed + var oldNode, + node = rangeHelper.parentNode(); + + if (currentNode !== node) { + oldNode = currentNode; + currentNode = node; + currentBlockNode = rangeHelper.getFirstBlockParent(node); + + trigger(editorContainer, 'nodechanged', { + oldNode: oldNode, + newNode: currentNode + }); + } + }; + + /** + * Gets the current node that contains the selection/caret in + * WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentNode + * @memberOf SCEditor.prototype + */ + base.currentNode = function () { + return currentNode; + }; + + /** + * Gets the first block level node that contains the + * selection/caret in WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentBlockNode + * @memberOf SCEditor.prototype + * @since 1.4.4 + */ + base.currentBlockNode = function () { + return currentBlockNode; + }; + + /** + * Updates if buttons are active or not + * @private + */ + updateActiveButtons = function () { + var firstBlock, parent; + var activeClass = 'active'; + var doc = wysiwygDocument; + var isSource = base.sourceMode(); + + if (base.readOnly()) { + each(find(toolbar, activeClass), function (_, menuItem) { + removeClass(menuItem, activeClass); + }); + return; + } + + if (!isSource) { + parent = rangeHelper.parentNode(); + firstBlock = rangeHelper.getFirstBlockParent(parent); + } + + for (var j = 0; j < btnStateHandlers.length; j++) { + var state = 0; + var btn = toolbarButtons[btnStateHandlers[j].name]; + var stateFn = btnStateHandlers[j].state; + var isDisabled = (isSource && !btn._sceTxtMode) || + (!isSource && !btn._sceWysiwygMode); + + if (isString(stateFn)) { + if (!isSource) { + try { + state = doc.queryCommandEnabled(stateFn) ? 0 : -1; + + // eslint-disable-next-line max-depth + if (state > -1) { + state = doc.queryCommandState(stateFn) ? 1 : 0; + } + } catch (ex) {} + } + } else if (!isDisabled) { + state = stateFn.call(base, parent, firstBlock); + } + + toggleClass(btn, 'disabled', isDisabled || state < 0); + toggleClass(btn, activeClass, state > 0); + } + + if (icons && icons.update) { + icons.update(isSource, parent, firstBlock); + } + }; + + /** + * Handles any key press in the WYSIWYG editor + * + * @private + */ + handleKeyPress = function (e) { + // FF bug: https://bugzilla.mozilla.org/show_bug.cgi?id=501496 + if (e.defaultPrevented) { + return; + } + + base.closeDropDown(); + + // 13 = enter key + if (e.which === 13) { + var LIST_TAGS = 'li,ul,ol'; + + // "Fix" (cludge) for blocklevel elements being duplicated in some + // browsers when enter is pressed instead of inserting a newline + if (!is(currentBlockNode, LIST_TAGS) && + hasStyling(currentBlockNode)) { + + var br = createElement('br', {}, wysiwygDocument); + rangeHelper.insertNode(br); + + // Last <br> of a block will be collapsed so need to make sure + // the <br> that was inserted isn't the last node of a block. + var parent = br.parentNode; + var lastChild = parent.lastChild; + + // Sometimes an empty next node is created after the <br> + if (lastChild && lastChild.nodeType === TEXT_NODE && + lastChild.nodeValue === '') { + remove(lastChild); + lastChild = parent.lastChild; + } + + // If this is the last BR of a block and the previous + // sibling is inline then will need an extra BR. This + // is needed because the last BR of a block will be + // collapsed. Fixes issue #248 + if (!isInline(parent, true) && lastChild === br && + isInline(br.previousSibling)) { + rangeHelper.insertHTML('<br>'); + } + + e.preventDefault(); + } + } + }; + + /** + * Makes sure that if there is a code or quote tag at the + * end of the editor, that there is a new line after it. + * + * If there wasn't a new line at the end you wouldn't be able + * to enter any text after a code/quote tag + * @return {void} + * @private + */ + appendNewLine = function () { + // Check all nodes in reverse until either add a new line + // or reach a non-empty textnode or BR at which point can + // stop checking. + rTraverse(wysiwygBody, function (node) { + // Last block, add new line after if has styling + if (node.nodeType === ELEMENT_NODE && + !/inline/.test(css(node, 'display'))) { + + // Add line break after if has styling + if (!is(node, '.sceditor-nlf') && hasStyling(node)) { + var paragraph = createElement('p', {}, wysiwygDocument); + paragraph.className = 'sceditor-nlf'; + paragraph.innerHTML = '<br />'; + appendChild(wysiwygBody, paragraph); + return false; + } + } + + // Last non-empty text node or line break. + // No need to add line-break after them + if ((node.nodeType === 3 && !/^\s*$/.test(node.nodeValue)) || + is(node, 'br')) { + return false; + } + }); + }; + + /** + * Handles form reset event + * @private + */ + handleFormReset = function () { + base.val(original.value); + }; + + /** + * Handles any mousedown press in the WYSIWYG editor + * @private + */ + handleMouseDown = function () { + base.closeDropDown(); + }; + + /** + * Translates the string into the locale language. + * + * Replaces any {0}, {1}, {2}, ect. with the params provided. + * + * @param {string} str + * @param {...String} args + * @return {string} + * @function + * @name _ + * @memberOf SCEditor.prototype + */ + base._ = function () { + var undef, + args = arguments; + + if (locale && locale[args[0]]) { + args[0] = locale[args[0]]; + } + + return args[0].replace(/\{(\d+)\}/g, function (str, p1) { + return args[p1 - 0 + 1] !== undef ? + args[p1 - 0 + 1] : + '{' + p1 + '}'; + }); + }; + + /** + * Passes events on to any handlers + * @private + * @return void + */ + handleEvent = function (e) { + if (pluginManager) { + // Send event to all plugins + pluginManager.call(e.type + 'Event', e, base); + } + + // convert the event into a custom event to send + var name = (e.target === sourceEditor ? 'scesrc' : 'scewys') + e.type; + + if (eventHandlers[name]) { + eventHandlers[name].forEach(function (fn) { + fn.call(base, e); + }); + } + }; + + /** + * Binds a handler to the specified events + * + * This function only binds to a limited list of + * supported events. + * + * The supported events are: + * + * * keyup + * * keydown + * * Keypress + * * blur + * * focus + * * input + * * nodechanged - When the current node containing + * the selection changes in WYSIWYG mode + * * contextmenu + * * selectionchanged + * * valuechanged + * + * + * The events param should be a string containing the event(s) + * to bind this handler to. If multiple, they should be separated + * by spaces. + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name bind + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.bind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + var wysEvent = 'scewys' + events[i]; + var srcEvent = 'scesrc' + events[i]; + // Use custom events to allow passing the instance as the + // 2nd argument. + // Also allows unbinding without unbinding the editors own + // event handlers. + if (!excludeWysiwyg) { + eventHandlers[wysEvent] = eventHandlers[wysEvent] || []; + eventHandlers[wysEvent].push(handler); + } + + if (!excludeSource) { + eventHandlers[srcEvent] = eventHandlers[srcEvent] || []; + eventHandlers[srcEvent].push(handler); + } + + // Start sending value changed events + if (events[i] === 'valuechanged') { + triggerValueChanged.hasHandler = true; + } + } + } + + return base; + }; + + /** + * Unbinds an event that was bound using bind(). + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude unbinding this + * handler from the WYSIWYG editor + * @param {boolean} excludeSource if to exclude unbinding this + * handler from the source editor + * @return {this} + * @function + * @name unbind + * @memberOf SCEditor.prototype + * @since 1.4.1 + * @see bind + */ + base.unbind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + if (!excludeWysiwyg) { + arrayRemove( + eventHandlers['scewys' + events[i]] || [], handler); + } + + if (!excludeSource) { + arrayRemove( + eventHandlers['scesrc' + events[i]] || [], handler); + } + } + } + + return base; + }; + + /** + * Blurs the editors input area + * + * @return {this} + * @function + * @name blur + * @memberOf SCEditor.prototype + * @since 1.3.6 + */ + /** + * Adds a handler to the editors blur event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name blur^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.blur = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('blur', handler, excludeWysiwyg, excludeSource); + } else if (!base.sourceMode()) { + wysiwygBody.blur(); + } else { + sourceEditor.blur(); + } + + return base; + }; + + /** + * Focuses the editors input area + * + * @return {this} + * @function + * @name focus + * @memberOf SCEditor.prototype + */ + /** + * Adds an event handler to the focus event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name focus^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.focus = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('focus', handler, excludeWysiwyg, excludeSource); + } else if (!base.inSourceMode()) { + // Already has focus so do nothing + if (find(wysiwygDocument, ':focus').length) { + return; + } + + var container; + var rng = rangeHelper.selectedRange(); + + // Fix FF bug where it shows the cursor in the wrong place + // if the editor hasn't had focus before. See issue #393 + if (!currentSelection) { + autofocus(true); + } + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (rng && rng.endOffset === 1 && rng.collapsed) { + container = rng.endContainer; + + if (container && container.childNodes.length === 1 && + is(container.firstChild, 'br')) { + rng.setStartBefore(container.firstChild); + rng.collapse(true); + rangeHelper.selectRange(rng); + } + } + + wysiwygWindow.focus(); + wysiwygBody.focus(); + } else { + sourceEditor.focus(); + } + + updateActiveButtons(); + + return base; + }; + + /** + * Adds a handler to the key down event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyDown + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyDown = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keydown', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key press event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyPress + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyPress = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('keypress', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key up event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyUp + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyUp = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keyup', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the node changed event. + * + * Happens whenever the node containing the selection/caret + * changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name nodeChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.nodeChanged = function (handler) { + return base.bind('nodechanged', handler, false, true); + }; + + /** + * Adds a handler to the selection changed event + * + * Happens whenever the selection changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name selectionChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.selectionChanged = function (handler) { + return base.bind('selectionchanged', handler, false, true); + }; + + /** + * Adds a handler to the value changed event + * + * Happens whenever the current editor value changes. + * + * Whenever anything is inserted, the value changed or + * 1.5 secs after text is typed. If a space is typed it will + * cause the event to be triggered immediately instead of + * after 1.5 seconds + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name valueChanged + * @memberOf SCEditor.prototype + * @since 1.4.5 + */ + base.valueChanged = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('valuechanged', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Emoticons keypress handler + * @private + */ + emoticonsKeyPress = function (e) { + var replacedEmoticon, + cachePos = 0, + emoticonsCache = base.emoticonsCache, + curChar = String.fromCharCode(e.which); + + // TODO: Make configurable + if (closest(currentBlockNode, 'code')) { + return; + } + + if (!emoticonsCache) { + emoticonsCache = []; + + each(allEmoticons, function (key, html) { + emoticonsCache[cachePos++] = [key, html]; + }); + + emoticonsCache.sort(function (a, b) { + return a[0].length - b[0].length; + }); + + base.emoticonsCache = emoticonsCache; + base.longestEmoticonCode = + emoticonsCache[emoticonsCache.length - 1][0].length; + } + + replacedEmoticon = rangeHelper.replaceKeyword( + base.emoticonsCache, + true, + true, + base.longestEmoticonCode, + options.emoticonsCompat, + curChar + ); + + if (replacedEmoticon) { + if (!options.emoticonsCompat || !/^\s$/.test(curChar)) { + e.preventDefault(); + } + } + }; + + /** + * Makes sure emoticons are surrounded by whitespace + * @private + */ + emoticonsCheckWhitespace = function () { + checkWhitespace(currentBlockNode, rangeHelper); + }; + + /** + * Gets if emoticons are currently enabled + * @return {boolean} + * @function + * @name emoticons + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + /** + * Enables/disables emoticons + * + * @param {boolean} enable + * @return {this} + * @function + * @name emoticons^2 + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + base.emoticons = function (enable) { + if (!enable && enable !== false) { + return options.emoticonsEnabled; + } + + options.emoticonsEnabled = enable; + + if (enable) { + on(wysiwygBody, 'keypress', emoticonsKeyPress); + + if (!base.sourceMode()) { + rangeHelper.saveRange(); + + replaceEmoticons(); + triggerValueChanged(false); + + rangeHelper.restoreRange(); + } + } else { + var emoticons = + find(wysiwygBody, 'img[data-sceditor-emoticon]'); + + each(emoticons, function (_, img) { + var text = data(img, 'sceditor-emoticon'); + var textNode = wysiwygDocument.createTextNode(text); + img.parentNode.replaceChild(textNode, img); + }); + + off(wysiwygBody, 'keypress', emoticonsKeyPress); + + triggerValueChanged(); + } + + return base; + }; + + /** + * Gets the current WYSIWYG editors inline CSS + * + * @return {string} + * @function + * @name css + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + /** + * Sets inline CSS for the WYSIWYG editor + * + * @param {string} css + * @return {this} + * @function + * @name css^2 + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + base.css = function (css) { + if (!inlineCss) { + inlineCss = createElement('style', { + id: 'inline' + }, wysiwygDocument); + + appendChild(wysiwygDocument.head, inlineCss); + } + + if (!isString(css)) { + return inlineCss.styleSheet ? + inlineCss.styleSheet.cssText : inlineCss.innerHTML; + } + + if (inlineCss.styleSheet) { + inlineCss.styleSheet.cssText = css; + } else { + inlineCss.innerHTML = css; + } + + return base; + }; + + /** + * Handles the keydown event, used for shortcuts + * @private + */ + handleKeyDown = function (e) { + var shortcut = [], + SHIFT_KEYS = { + '`': '~', + '1': '!', + '2': '@', + '3': '#', + '4': '$', + '5': '%', + '6': '^', + '7': '&', + '8': '*', + '9': '(', + '0': ')', + '-': '_', + '=': '+', + ';': ': ', + '\'': '"', + ',': '<', + '.': '>', + '/': '?', + '\\': '|', + '[': '{', + ']': '}' + }, + SPECIAL_KEYS = { + 8: 'backspace', + 9: 'tab', + 13: 'enter', + 19: 'pause', + 20: 'capslock', + 27: 'esc', + 32: 'space', + 33: 'pageup', + 34: 'pagedown', + 35: 'end', + 36: 'home', + 37: 'left', + 38: 'up', + 39: 'right', + 40: 'down', + 45: 'insert', + 46: 'del', + 91: 'win', + 92: 'win', + 93: 'select', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9', + 106: '*', + 107: '+', + 109: '-', + 110: '.', + 111: '/', + 112: 'f1', + 113: 'f2', + 114: 'f3', + 115: 'f4', + 116: 'f5', + 117: 'f6', + 118: 'f7', + 119: 'f8', + 120: 'f9', + 121: 'f10', + 122: 'f11', + 123: 'f12', + 144: 'numlock', + 145: 'scrolllock', + 186: ';', + 187: '=', + 188: ',', + 189: '-', + 190: '.', + 191: '/', + 192: '`', + 219: '[', + 220: '\\', + 221: ']', + 222: '\'' + }, + NUMPAD_SHIFT_KEYS = { + 109: '-', + 110: 'del', + 111: '/', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9' + }, + which = e.which, + character = SPECIAL_KEYS[which] || + String.fromCharCode(which).toLowerCase(); + + if (e.ctrlKey || e.metaKey) { + shortcut.push('ctrl'); + } + + if (e.altKey) { + shortcut.push('alt'); + } + + if (e.shiftKey) { + shortcut.push('shift'); + + if (NUMPAD_SHIFT_KEYS[which]) { + character = NUMPAD_SHIFT_KEYS[which]; + } else if (SHIFT_KEYS[character]) { + character = SHIFT_KEYS[character]; + } + } + + // Shift is 16, ctrl is 17 and alt is 18 + if (character && (which < 16 || which > 18)) { + shortcut.push(character); + } + + shortcut = shortcut.join('+'); + if (shortcutHandlers[shortcut] && + shortcutHandlers[shortcut].call(base) === false) { + + e.stopPropagation(); + e.preventDefault(); + } + }; + + /** + * Adds a shortcut handler to the editor + * @param {string} shortcut + * @param {String|Function} cmd + * @return {sceditor} + */ + base.addShortcut = function (shortcut, cmd) { + shortcut = shortcut.toLowerCase(); + + if (isString(cmd)) { + shortcutHandlers[shortcut] = function () { + handleCommand(toolbarButtons[cmd], base.commands[cmd]); + + return false; + }; + } else { + shortcutHandlers[shortcut] = cmd; + } + + return base; + }; + + /** + * Removes a shortcut handler + * @param {string} shortcut + * @return {sceditor} + */ + base.removeShortcut = function (shortcut) { + delete shortcutHandlers[shortcut.toLowerCase()]; + + return base; + }; + + /** + * Handles the backspace key press + * + * Will remove block styling like quotes/code ect if at the start. + * @private + */ + handleBackSpace = function (e) { + var node, offset, range, parent; + + // 8 is the backspace key + if (options.disableBlockRemove || e.which !== 8 || + !(range = rangeHelper.selectedRange())) { + return; + } + + node = range.startContainer; + offset = range.startOffset; + + if (offset !== 0 || !(parent = currentStyledBlockNode()) || + is(parent, 'body')) { + return; + } + + while (node !== parent) { + while (node.previousSibling) { + node = node.previousSibling; + + // Everything but empty text nodes before the cursor + // should prevent the style from being removed + if (node.nodeType !== TEXT_NODE || node.nodeValue) { + return; + } + } + + if (!(node = node.parentNode)) { + return; + } + } + + // The backspace was pressed at the start of + // the container so clear the style + base.clearBlockFormatting(parent); + e.preventDefault(); + }; + + /** + * Gets the first styled block node that contains the cursor + * @return {HTMLElement} + */ + currentStyledBlockNode = function () { + var block = currentBlockNode; + + while (!hasStyling(block) || isInline(block, true)) { + if (!(block = block.parentNode) || is(block, 'body')) { + return; + } + } + + return block; + }; + + /** + * Clears the formatting of the passed block element. + * + * If block is false, if will clear the styling of the first + * block level element that contains the cursor. + * @param {HTMLElement} block + * @since 1.4.4 + */ + base.clearBlockFormatting = function (block) { + block = block || currentStyledBlockNode(); + + if (!block || is(block, 'body')) { + return base; + } + + rangeHelper.saveRange(); + + block.className = ''; + + attr(block, 'style', ''); + + if (!is(block, 'p,div,td')) { + convertElement(block, 'p'); + } + + rangeHelper.restoreRange(); + return base; + }; + + /** + * Triggers the valueChanged signal if there is + * a plugin that handles it. + * + * If rangeHelper.saveRange() has already been + * called, then saveRange should be set to false + * to prevent the range being saved twice. + * + * @since 1.4.5 + * @param {boolean} saveRange If to call rangeHelper.saveRange(). + * @private + */ + triggerValueChanged = function (saveRange) { + if (!pluginManager || + (!pluginManager.hasHandler('valuechangedEvent') && + !triggerValueChanged.hasHandler)) { + return; + } + + var currentHtml, + sourceMode = base.sourceMode(), + hasSelection = !sourceMode && rangeHelper.hasSelection(); + + // Composition end isn't guaranteed to fire but must have + // ended when triggerValueChanged() is called so reset it + isComposing = false; + + // Don't need to save the range if sceditor-start-marker + // is present as the range is already saved + saveRange = saveRange !== false && + !wysiwygDocument.getElementById('sceditor-start-marker'); + + // Clear any current timeout as it's now been triggered + if (valueChangedKeyUpTimer) { + clearTimeout(valueChangedKeyUpTimer); + valueChangedKeyUpTimer = false; + } + + if (hasSelection && saveRange) { + rangeHelper.saveRange(); + } + + currentHtml = sourceMode ? sourceEditor.value : wysiwygBody.innerHTML; + + // Only trigger if something has actually changed. + if (currentHtml !== triggerValueChanged.lastVal) { + triggerValueChanged.lastVal = currentHtml; + + trigger(editorContainer, 'valuechanged', { + rawValue: sourceMode ? base.val() : currentHtml + }); + } + + if (hasSelection && saveRange) { + rangeHelper.removeMarkers(); + } + }; + + /** + * Should be called whenever there is a blur event + * @private + */ + valueChangedBlur = function () { + if (valueChangedKeyUpTimer) { + triggerValueChanged(); + } + }; + + /** + * Should be called whenever there is a keypress event + * @param {Event} e The keypress event + * @private + */ + valueChangedKeyUp = function (e) { + var which = e.which, + lastChar = valueChangedKeyUp.lastChar, + lastWasSpace = (lastChar === 13 || lastChar === 32), + lastWasDelete = (lastChar === 8 || lastChar === 46); + + valueChangedKeyUp.lastChar = which; + + if (isComposing) { + return; + } + + // 13 = return & 32 = space + if (which === 13 || which === 32) { + if (!lastWasSpace) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + // 8 = backspace & 46 = del + } else if (which === 8 || which === 46) { + if (!lastWasDelete) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + } else if (valueChangedKeyUp.triggerNext) { + triggerValueChanged(); + valueChangedKeyUp.triggerNext = false; + } + + // Clear the previous timeout and set a new one. + clearTimeout(valueChangedKeyUpTimer); + + // Trigger the event 1.5s after the last keypress if space + // isn't pressed. This might need to be lowered, will need + // to look into what the slowest average Chars Per Min is. + valueChangedKeyUpTimer = setTimeout(function () { + if (!isComposing) { + triggerValueChanged(); + } + }, 1500); + }; + + handleComposition = function (e) { + isComposing = /start/i.test(e.type); + + if (!isComposing) { + triggerValueChanged(); + } + }; + + autoUpdate = function () { + base.updateOriginal(); + }; + + // run the initializer + init(); + } + + /** + * Map containing the loaded SCEditor locales + * @type {Object} + * @name locale + * @memberOf sceditor + */ + SCEditor.locale = {}; + + SCEditor.formats = {}; + SCEditor.icons = {}; + + + /** + * Static command helper class + * @class command + * @name sceditor.command + */ + SCEditor.command = + /** @lends sceditor.command */ + { + /** + * Gets a command + * + * @param {string} name + * @return {Object|null} + * @since v1.3.5 + */ + get: function (name) { + return defaultCmds[name] || null; + }, + + /** + * <p>Adds a command to the editor or updates an existing + * command if a command with the specified name already exists.</p> + * + * <p>Once a command is add it can be included in the toolbar by + * adding it's name to the toolbar option in the constructor. It + * can also be executed manually by calling + * {@link sceditor.execCommand}</p> + * + * @example + * SCEditor.command.set("hello", + * { + * exec: function () { + * alert("Hello World!"); + * } + * }); + * + * @param {string} name + * @param {Object} cmd + * @return {this|false} Returns false if name or cmd is false + * @since v1.3.5 + */ + set: function (name, cmd) { + if (!name || !cmd) { + return false; + } + + // merge any existing command properties + cmd = extend(defaultCmds[name] || {}, cmd); + + cmd.remove = function () { + SCEditor.command.remove(name); + }; + + defaultCmds[name] = cmd; + return this; + }, + + /** + * Removes a command + * + * @param {string} name + * @return {this} + * @since v1.3.5 + */ + remove: function (name) { + if (defaultCmds[name]) { + delete defaultCmds[name]; + } + + return this; + } + }; + + /** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor - A lightweight WYSIWYG BBCode and HTML editor + * @author Sam Clarke + */ + + + window.sceditor = { + command: SCEditor.command, + commands: defaultCmds, + defaultOptions: defaultOptions, + + ios: ios, + isWysiwygSupported: isWysiwygSupported, + + regexEscape: regex, + escapeEntities: entities, + escapeUriScheme: uriScheme, + + dom: { + css: css, + attr: attr, + removeAttr: removeAttr, + is: is, + closest: closest, + width: width, + height: height, + traverse: traverse, + rTraverse: rTraverse, + parseHTML: parseHTML, + hasStyling: hasStyling, + convertElement: convertElement, + blockLevelList: blockLevelList, + canHaveChildren: canHaveChildren, + isInline: isInline, + copyCSS: copyCSS, + fixNesting: fixNesting, + findCommonAncestor: findCommonAncestor, + getSibling: getSibling, + removeWhiteSpace: removeWhiteSpace, + extractContents: extractContents, + getOffset: getOffset, + getStyle: getStyle, + hasStyle: hasStyle + }, + locale: SCEditor.locale, + icons: SCEditor.icons, + utils: { + each: each, + isEmptyObject: isEmptyObject, + extend: extend + }, + plugins: PluginManager.plugins, + formats: SCEditor.formats, + create: function (textarea, options) { + options = options || {}; + + // Don't allow the editor to be initialised + // on it's own source editor + if (parent(textarea, '.sceditor-container')) { + return; + } + + if (options.runWithoutWysiwygSupport || isWysiwygSupported) { + /*eslint no-new: off*/ + (new SCEditor(textarea, options)); + } + }, + instance: function (textarea) { + return textarea._sceditor; + } + }; + + /** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor - A lightweight WYSIWYG BBCode and HTML editor + * @author Sam Clarke + * @requires jQuery + */ + + + // For backwards compatibility + $__default['default'].sceditor = window.sceditor; + + /** + * Creates an instance of sceditor on all textareas + * matched by the jQuery selector. + * + * If options is set to "state" it will return bool value + * indicating if the editor has been initialised on the + * matched textarea(s). If there is only one textarea + * it will return the bool value for that textarea. + * If more than one textarea is matched it will + * return an array of bool values for each textarea. + * + * If options is set to "instance" it will return the + * current editor instance for the textarea(s). Like the + * state option, if only one textarea is matched this will + * return just the instance for that textarea. If more than + * one textarea is matched it will return an array of + * instances each textarea. + * + * @param {Object|string} [options] Should either be an Object of options or + * the strings "state" or "instance" + * @return {this|Array<SCEditor>|Array<boolean>|SCEditor|boolean} + */ + $__default['default'].fn.sceditor = function (options) { + var instance; + var ret = []; + + this.each(function () { + instance = this._sceditor; + + // Add state of instance to ret if that is what options is set to + if (options === 'state') { + ret.push(!!instance); + } else if (options === 'instance') { + ret.push(instance); + } else if (!instance) { + $__default['default'].sceditor.create(this, options); + } + }); + + // If nothing in the ret array then must be init so return this + if (!ret.length) { + return this; + } + + return ret.length === 1 ? ret[0] : ret; + }; + +}(jQuery)); +;/** + * SCEditor XHTML Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (sceditor) { + 'use strict'; + + var dom = sceditor.dom; + var utils = sceditor.utils; + + var css = dom.css; + var attr = dom.attr; + var is = dom.is; + var removeAttr = dom.removeAttr; + var convertElement = dom.convertElement; + var extend = utils.extend; + var each = utils.each; + var isEmptyObject = utils.isEmptyObject; + + var getEditorCommand = sceditor.command.get; + + var defaultCommandsOverrides = { + bold: { + txtExec: ['<strong>', '</strong>'] + }, + italic: { + txtExec: ['<em>', '</em>'] + }, + underline: { + txtExec: ['<span style="text-decoration:underline;">', '</span>'] + }, + strike: { + txtExec: ['<span style="text-decoration:line-through;">', '</span>'] + }, + subscript: { + txtExec: ['<sub>', '</sub>'] + }, + superscript: { + txtExec: ['<sup>', '</sup>'] + }, + left: { + txtExec: ['<div style="text-align:left;">', '</div>'] + }, + center: { + txtExec: ['<div style="text-align:center;">', '</div>'] + }, + right: { + txtExec: ['<div style="text-align:right;">', '</div>'] + }, + justify: { + txtExec: ['<div style="text-align:justify;">', '</div>'] + }, + font: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('font')._dropDown( + editor, + caller, + function (font) { + editor.insertText('<span style="font-family:' + + font + ';">', '</span>'); + } + ); + } + }, + size: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('size')._dropDown( + editor, + caller, + function (size) { + editor.insertText('<span style="font-size:' + + size + ';">', '</span>'); + } + ); + } + }, + color: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('color')._dropDown( + editor, + caller, + function (color) { + editor.insertText('<span style="color:' + + color + ';">', '</span>'); + } + ); + } + }, + bulletlist: { + txtExec: ['<ul><li>', '</li></ul>'] + }, + orderedlist: { + txtExec: ['<ol><li>', '</li></ol>'] + }, + table: { + txtExec: ['<table><tr><td>', '</td></tr></table>'] + }, + horizontalrule: { + txtExec: ['<hr />'] + }, + code: { + txtExec: ['<code>', '</code>'] + }, + image: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('image')._dropDown( + editor, + caller, + selected, + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width="' + width + '"'; + } + + if (height) { + attrs += ' height="' + height + '"'; + } + + editor.insertText( + '<img' + attrs + ' src="' + url + '" />' + ); + } + ); + } + }, + email: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('email')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '<a href="mailto:' + url + '">' + + (text || selected || url) + + '</a>' + ); + } + ); + } + }, + link: { + txtExec: function (caller, selected) { + var editor = this; + + getEditorCommand('link')._dropDown( + editor, + caller, + function (url, text) { + editor.insertText( + '<a href="' + url + '">' + + (text || selected || url) + + '</a>' + ); + } + ); + } + }, + quote: { + txtExec: ['<blockquote>', '</blockquote>'] + }, + youtube: { + txtExec: function (caller) { + var editor = this; + + getEditorCommand('youtube')._dropDown( + editor, + caller, + function (id, time) { + editor.insertText( + '<iframe width="560" height="315" ' + + 'src="https://www.youtube.com/embed/{id}?' + + 'wmode=opaque&start=' + time + '" ' + + 'data-youtube-id="' + id + '" ' + + 'frameborder="0" allowfullscreen></iframe>' + ); + } + ); + } + }, + rtl: { + txtExec: ['<div stlye="direction:rtl;">', '</div>'] + }, + ltr: { + txtExec: ['<div stlye="direction:ltr;">', '</div>'] + } + }; + + /** + * XHTMLSerializer part of the XHTML plugin. + * + * @class XHTMLSerializer + * @name jQuery.sceditor.XHTMLSerializer + * @since v1.4.1 + */ + sceditor.XHTMLSerializer = function () { + var base = this; + + var opts = { + indentStr: '\t' + }; + + /** + * Array containing the output, used as it's faster + * than string concatenation in slow browsers. + * @type {Array} + * @private + */ + var outputStringBuilder = []; + + /** + * Current indention level + * @type {number} + * @private + */ + var currentIndent = 0; + + // TODO: use escape.entities + /** + * Escapes XHTML entities + * + * @param {string} str + * @return {string} + * @private + */ + function escapeEntities(str) { + var entities = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\xa0': ' ' + }; + + return !str ? '' : str.replace(/[&<>"\xa0]/g, function (entity) { + return entities[entity] || entity; + }); + }; + + /** + * Replace spaces including newlines with a single + * space except for non-breaking spaces + * + * @param {string} str + * @return {string} + * @private + */ + function trim(str) { + return str.replace(/[^\S\u00A0]+/g, ' '); + }; + + /** + * Serializes a node to XHTML + * + * @param {Node} node Node to serialize + * @param {boolean} onlyChildren If to only serialize the nodes + * children and not the node + * itself + * @return {string} The serialized node + * @name serialize + * @memberOf jQuery.sceditor.XHTMLSerializer.prototype + * @since v1.4.1 + */ + base.serialize = function (node, onlyChildren) { + outputStringBuilder = []; + + if (onlyChildren) { + node = node.firstChild; + + while (node) { + serializeNode(node); + node = node.nextSibling; + } + } else { + serializeNode(node); + } + + return outputStringBuilder.join(''); + }; + + /** + * Serializes a node to the outputStringBuilder + * + * @param {Node} node + * @return {void} + * @private + */ + function serializeNode(node, parentIsPre) { + switch (node.nodeType) { + case 1: // element + handleElement(node, parentIsPre); + break; + + case 3: // text + handleText(node, parentIsPre); + break; + + case 4: // cdata section + handleCdata(node); + break; + + case 8: // comment + handleComment(node); + break; + + case 9: // document + case 11: // document fragment + handleDoc(node); + break; + + // Ignored types + case 2: // attribute + case 5: // entity ref + case 6: // entity + case 7: // processing instruction + case 10: // document type + case 12: // notation + break; + } + }; + + /** + * Handles doc node + * @param {Node} node + * @return {void} + * @private + */ + function handleDoc(node) { + var child = node.firstChild; + + while (child) { + serializeNode(child); + child = child.nextSibling; + } + }; + + /** + * Handles element nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleElement(node, parentIsPre) { + var child, attr, attrValue, + tagName = node.nodeName.toLowerCase(), + isIframe = tagName === 'iframe', + attrIdx = node.attributes.length, + firstChild = node.firstChild, + // pre || pre-wrap with any vendor prefix + isPre = parentIsPre || + /pre(?:\-wrap)?$/i.test(css(node, 'whiteSpace')), + selfClosing = !node.firstChild && !dom.canHaveChildren(node) && + !isIframe; + + if (is(node, '.sceditor-ignore')) { + return; + } + + output('<' + tagName, !parentIsPre && canIndent(node)); + while (attrIdx--) { + attr = node.attributes[attrIdx]; + + attrValue = attr.value; + + output(' ' + attr.name.toLowerCase() + '="' + + escapeEntities(attrValue) + '"', false); + } + output(selfClosing ? ' />' : '>', false); + + if (!isIframe) { + child = firstChild; + } + + while (child) { + currentIndent++; + + serializeNode(child, isPre); + child = child.nextSibling; + + currentIndent--; + } + + if (!selfClosing) { + output( + '</' + tagName + '>', + !isPre && !isIframe && canIndent(node) && + firstChild && canIndent(firstChild) + ); + } + }; + + /** + * Handles CDATA nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleCdata(node) { + output('<![CDATA[' + escapeEntities(node.nodeValue) + ']]>'); + }; + + /** + * Handles comment nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleComment(node) { + output('<!-- ' + escapeEntities(node.nodeValue) + ' -->'); + }; + + /** + * Handles text nodes + * @param {Node} node + * @return {void} + * @private + */ + function handleText(node, parentIsPre) { + var text = node.nodeValue; + + if (!parentIsPre) { + text = trim(text); + } + + if (text) { + output(escapeEntities(text), !parentIsPre && canIndent(node)); + } + }; + + /** + * Adds a string to the outputStringBuilder. + * + * The string will be indented unless indent is set to boolean false. + * @param {string} str + * @param {boolean} indent + * @return {void} + * @private + */ + function output(str, indent) { + var i = currentIndent; + + if (indent !== false) { + // Don't add a new line if it's the first element + if (outputStringBuilder.length) { + outputStringBuilder.push('\n'); + } + + while (i--) { + outputStringBuilder.push(opts.indentStr); + } + } + + outputStringBuilder.push(str); + }; + + /** + * Checks if should indent the node or not + * @param {Node} node + * @return {boolean} + * @private + */ + function canIndent(node) { + var prev = node.previousSibling; + + if (node.nodeType !== 1 && prev) { + return !dom.isInline(prev); + } + + // first child of a block element + if (!prev && !dom.isInline(node.parentNode)) { + return true; + } + + return !dom.isInline(node); + }; + }; + + /** + * SCEditor XHTML plugin + * @class xhtml + * @name jQuery.sceditor.plugins.xhtml + * @since v1.4.1 + */ + function xhtmlFormat() { + var base = this; + + /** + * Tag converters cache + * @type {Object} + * @private + */ + var tagConvertersCache = {}; + + /** + * Attributes filter cache + * @type {Object} + * @private + */ + var attrsCache = {}; + + /** + * Init + * @return {void} + */ + base.init = function () { + if (!isEmptyObject(xhtmlFormat.converters || {})) { + each( + xhtmlFormat.converters, + function (idx, converter) { + each(converter.tags, function (tagname) { + if (!tagConvertersCache[tagname]) { + tagConvertersCache[tagname] = []; + } + + tagConvertersCache[tagname].push(converter); + }); + } + ); + } + + this.commands = extend(true, + {}, defaultCommandsOverrides, this.commands); + }; + + /** + * Converts the WYSIWYG content to XHTML + * + * @param {boolean} isFragment + * @param {string} html + * @param {Document} context + * @param {HTMLElement} [parent] + * @return {string} + * @memberOf jQuery.sceditor.plugins.xhtml.prototype + */ + function toSource(isFragment, html, context) { + var xhtml, + container = context.createElement('div'); + container.innerHTML = html; + + css(container, 'visibility', 'hidden'); + context.body.appendChild(container); + + convertTags(container); + removeTags(container); + removeAttribs(container); + + if (!isFragment) { + wrapInlines(container); + } + + xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true); + + context.body.removeChild(container); + + return xhtml; + }; + + base.toSource = toSource.bind(null, false); + + base.fragmentToSource = toSource.bind(null, true);; + + /** + * Runs all converters for the specified tagName + * against the DOM node. + * @param {string} tagName + * @return {Node} node + * @private + */ + function convertNode(tagName, node) { + if (!tagConvertersCache[tagName]) { + return; + } + + tagConvertersCache[tagName].forEach(function (converter) { + if (converter.tags[tagName]) { + each(converter.tags[tagName], function (attr, values) { + if (!node.getAttributeNode) { + return; + } + + attr = node.getAttributeNode(attr); + + if (!attr || values && values.indexOf(attr.value) < 0) { + return; + } + + converter.conv.call(base, node); + }); + } else if (converter.conv) { + converter.conv.call(base, node); + } + }); + }; + + /** + * Converts any tags/attributes to their XHTML equivalents + * @param {Node} node + * @return {void} + * @private + */ + function convertTags(node) { + dom.traverse(node, function (node) { + var tagName = node.nodeName.toLowerCase(); + + convertNode('*', node); + convertNode(tagName, node); + }, true); + }; + + /** + * Tests if a node is empty and can be removed. + * + * @param {Node} node + * @return {boolean} + * @private + */ + function isEmpty(node, excludeBr) { + var rect, + childNodes = node.childNodes, + tagName = node.nodeName.toLowerCase(), + nodeValue = node.nodeValue, + childrenLength = childNodes.length, + allowedEmpty = xhtmlFormat.allowedEmptyTags || []; + + if (excludeBr && tagName === 'br') { + return true; + } + + if (is(node, '.sceditor-ignore')) { + return true; + } + + if (allowedEmpty.indexOf(tagName) > -1 || tagName === 'td' || + !dom.canHaveChildren(node)) { + + return false; + } + + // \S|\u00A0 = any non space char + if (nodeValue && /\S|\u00A0/.test(nodeValue)) { + return false; + } + + while (childrenLength--) { + if (!isEmpty(childNodes[childrenLength], + excludeBr && !node.previousSibling && !node.nextSibling)) { + return false; + } + } + + // Treat tags with a width and height from CSS as not empty + if (node.getBoundingClientRect && + (node.className || node.hasAttributes('style'))) { + rect = node.getBoundingClientRect(); + return !rect.width || !rect.height; + } + + return true; + }; + + /** + * Removes any tags that are not white listed or if no + * tags are white listed it will remove any tags that + * are black listed. + * + * @param {Node} rootNode + * @return {void} + * @private + */ + function removeTags(rootNode) { + dom.traverse(rootNode, function (node) { + var remove, + tagName = node.nodeName.toLowerCase(), + parentNode = node.parentNode, + nodeType = node.nodeType, + isBlock = !dom.isInline(node), + previousSibling = node.previousSibling, + nextSibling = node.nextSibling, + isTopLevel = parentNode === rootNode, + noSiblings = !previousSibling && !nextSibling, + empty = tagName !== 'iframe' && isEmpty(node, + isTopLevel && noSiblings && tagName !== 'br'), + document = node.ownerDocument, + allowedTags = xhtmlFormat.allowedTags, + firstChild = node.firstChild, + disallowedTags = xhtmlFormat.disallowedTags; + + // 3 = text node + if (nodeType === 3) { + return; + } + + if (nodeType === 4) { + tagName = '!cdata'; + } else if (tagName === '!' || nodeType === 8) { + tagName = '!comment'; + } + + if (nodeType === 1) { + // skip empty nlf elements (new lines automatically + // added after block level elements like quotes) + if (is(node, '.sceditor-nlf')) { + if (!firstChild || (node.childNodes.length === 1 && + /br/i.test(firstChild.nodeName))) { + // Mark as empty,it will be removed by the next code + empty = true; + } else { + node.classList.remove('sceditor-nlf'); + + if (!node.className) { + removeAttr(node, 'class'); + } + } + } + } + + if (empty) { + remove = true; + // 3 is text node which do not get filtered + } else if (allowedTags && allowedTags.length) { + remove = (allowedTags.indexOf(tagName) < 0); + } else if (disallowedTags && disallowedTags.length) { + remove = (disallowedTags.indexOf(tagName) > -1); + } + + if (remove) { + if (!empty) { + if (isBlock && previousSibling && + dom.isInline(previousSibling)) { + parentNode.insertBefore( + document.createTextNode(' '), node); + } + + // Insert all the childen after node + while (node.firstChild) { + parentNode.insertBefore(node.firstChild, + nextSibling); + } + + if (isBlock && nextSibling && + dom.isInline(nextSibling)) { + parentNode.insertBefore( + document.createTextNode(' '), nextSibling); + } + } + + parentNode.removeChild(node); + } + }, true); + }; + + /** + * Merges two sets of attribute filters into one + * + * @param {Object} filtersA + * @param {Object} filtersB + * @return {Object} + * @private + */ + function mergeAttribsFilters(filtersA, filtersB) { + var ret = {}; + + if (filtersA) { + ret = extend({}, ret, filtersA); + } + + if (!filtersB) { + return ret; + } + + each(filtersB, function (attrName, values) { + if (Array.isArray(values)) { + ret[attrName] = (ret[attrName] || []).concat(values); + } else if (!ret[attrName]) { + ret[attrName] = null; + } + }); + + return ret; + }; + + /** + * Wraps adjacent inline child nodes of root + * in paragraphs. + * + * @param {Node} root + * @private + */ + function wrapInlines(root) { + // Strip empty text nodes so they don't get wrapped. + dom.removeWhiteSpace(root); + + var wrapper; + var node = root.firstChild; + var next; + while (node) { + next = node.nextSibling; + + if (dom.isInline(node) && !is(node, '.sceditor-ignore')) { + if (!wrapper) { + wrapper = root.ownerDocument.createElement('p'); + node.parentNode.insertBefore(wrapper, node); + } + + wrapper.appendChild(node); + } else { + wrapper = null; + } + + node = next; + } + }; + + /** + * Removes any attributes that are not white listed or + * if no attributes are white listed it will remove + * any attributes that are black listed. + * @param {Node} node + * @return {void} + * @private + */ + function removeAttribs(node) { + var tagName, attr, attrName, attrsLength, validValues, remove, + allowedAttribs = xhtmlFormat.allowedAttribs, + isAllowed = allowedAttribs && + !isEmptyObject(allowedAttribs), + disallowedAttribs = xhtmlFormat.disallowedAttribs, + isDisallowed = disallowedAttribs && + !isEmptyObject(disallowedAttribs); + + attrsCache = {}; + + dom.traverse(node, function (node) { + if (!node.attributes) { + return; + } + + tagName = node.nodeName.toLowerCase(); + attrsLength = node.attributes.length; + + if (attrsLength) { + if (!attrsCache[tagName]) { + if (isAllowed) { + attrsCache[tagName] = mergeAttribsFilters( + allowedAttribs['*'], + allowedAttribs[tagName] + ); + } else { + attrsCache[tagName] = mergeAttribsFilters( + disallowedAttribs['*'], + disallowedAttribs[tagName] + ); + } + } + + while (attrsLength--) { + attr = node.attributes[attrsLength]; + attrName = attr.name; + validValues = attrsCache[tagName][attrName]; + remove = false; + + if (isAllowed) { + remove = validValues !== null && + (!Array.isArray(validValues) || + validValues.indexOf(attr.value) < 0); + } else if (isDisallowed) { + remove = validValues === null || + (Array.isArray(validValues) && + validValues.indexOf(attr.value) > -1); + } + + if (remove) { + node.removeAttribute(attrName); + } + } + } + }); + }; + }; + + /** + * Tag conveters, a converter is applied to all + * tags that match the criteria. + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.converters + * @since v1.4.1 + */ + xhtmlFormat.converters = [ + { + tags: { + '*': { + width: null + } + }, + conv: function (node) { + css(node, 'width', attr(node, 'width')); + removeAttr(node, 'width'); + } + }, + { + tags: { + '*': { + height: null + } + }, + conv: function (node) { + css(node, 'height', attr(node, 'height')); + removeAttr(node, 'height'); + } + }, + { + tags: { + 'li': { + value: null + } + }, + conv: function (node) { + removeAttr(node, 'value'); + } + }, + { + tags: { + '*': { + text: null + } + }, + conv: function (node) { + css(node, 'color', attr(node, 'text')); + removeAttr(node, 'text'); + } + }, + { + tags: { + '*': { + color: null + } + }, + conv: function (node) { + css(node, 'color', attr(node, 'color')); + removeAttr(node, 'color'); + } + }, + { + tags: { + '*': { + face: null + } + }, + conv: function (node) { + css(node, 'fontFamily', attr(node, 'face')); + removeAttr(node, 'face'); + } + }, + { + tags: { + '*': { + align: null + } + }, + conv: function (node) { + css(node, 'textAlign', attr(node, 'align')); + removeAttr(node, 'align'); + } + }, + { + tags: { + '*': { + border: null + } + }, + conv: function (node) { + css(node, 'borderWidth', attr(node, 'border')); + removeAttr(node, 'border'); + } + }, + { + tags: { + applet: { + name: null + }, + img: { + name: null + }, + layer: { + name: null + }, + map: { + name: null + }, + object: { + name: null + }, + param: { + name: null + } + }, + conv: function (node) { + if (!attr(node, 'id')) { + attr(node, 'id', attr(node, 'name')); + } + + removeAttr(node, 'name'); + } + }, + { + tags: { + '*': { + vspace: null + } + }, + conv: function (node) { + css(node, 'marginTop', attr(node, 'vspace') - 0); + css(node, 'marginBottom', attr(node, 'vspace') - 0); + removeAttr(node, 'vspace'); + } + }, + { + tags: { + '*': { + hspace: null + } + }, + conv: function (node) { + css(node, 'marginLeft', attr(node, 'hspace') - 0); + css(node, 'marginRight', attr(node, 'hspace') - 0); + removeAttr(node, 'hspace'); + } + }, + { + tags: { + 'hr': { + noshade: null + } + }, + conv: function (node) { + css(node, 'borderStyle', 'solid'); + removeAttr(node, 'noshade'); + } + }, + { + tags: { + '*': { + nowrap: null + } + }, + conv: function (node) { + css(node, 'whiteSpace', 'nowrap'); + removeAttr(node, 'nowrap'); + } + }, + { + tags: { + big: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'fontSize', 'larger'); + } + }, + { + tags: { + small: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'fontSize', 'smaller'); + } + }, + { + tags: { + b: null + }, + conv: function (node) { + convertElement(node, 'strong'); + } + }, + { + tags: { + u: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'textDecoration', + 'underline'); + } + }, + { + tags: { + s: null, + strike: null + }, + conv: function (node) { + css(convertElement(node, 'span'), 'textDecoration', + 'line-through'); + } + }, + { + tags: { + dir: null + }, + conv: function (node) { + convertElement(node, 'ul'); + } + }, + { + tags: { + center: null + }, + conv: function (node) { + css(convertElement(node, 'div'), 'textAlign', 'center'); + } + }, + { + tags: { + font: { + size: null + } + }, + conv: function (node) { + css(node, 'fontSize', css(node, 'fontSize')); + removeAttr(node, 'size'); + } + }, + { + tags: { + font: null + }, + conv: function (node) { + // All it's attributes will be converted + // by the attribute converters + convertElement(node, 'span'); + } + }, + { + tags: { + '*': { + type: ['_moz'] + } + }, + conv: function (node) { + removeAttr(node, 'type'); + } + }, + { + tags: { + '*': { + '_moz_dirty': null + } + }, + conv: function (node) { + removeAttr(node, '_moz_dirty'); + } + }, + { + tags: { + '*': { + '_moz_editor_bogus_node': null + } + }, + conv: function (node) { + node.parentNode.removeChild(node); + } + }, + { + tags: { + '*': { + 'data-sce-target': null + } + }, + conv: function (node) { + var rel = attr(node, 'rel') || ''; + var target = attr(node, 'data-sce-target'); + + // Only allow the value _blank and only on links + if (target === '_blank' && is(node, 'a')) { + if (!/(^|\s)noopener(\s|$)/.test(rel)) { + attr(node, 'rel', 'noopener' + (rel ? ' ' + rel : '')); + } + + attr(node, 'target', target); + } + + + removeAttr(node, 'data-sce-target'); + } + }, + { + tags: { + code: null + }, + conv: function (node) { + var node, nodes = node.getElementsByTagName('div'); + while ((node = nodes[0])) { + node.style.display = 'block'; + convertElement(node, 'span'); + } + } + } + ]; + + /** + * Allowed attributes map. + * + * To allow an attribute for all tags use * as the tag name. + * + * Leave empty or null to allow all attributes. (the disallow + * list will be used to filter them instead) + * @type {Object} + * @name jQuery.sceditor.plugins.xhtml.allowedAttribs + * @since v1.4.1 + */ + xhtmlFormat.allowedAttribs = {}; + + /** + * Attributes that are not allowed. + * + * Only used if allowed attributes is null or empty. + * @type {Object} + * @name jQuery.sceditor.plugins.xhtml.disallowedAttribs + * @since v1.4.1 + */ + xhtmlFormat.disallowedAttribs = {}; + + /** + * Array containing all the allowed tags. + * + * If null or empty all tags will be allowed. + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.allowedTags + * @since v1.4.1 + */ + xhtmlFormat.allowedTags = []; + + /** + * Array containing all the disallowed tags. + * + * Only used if allowed tags is null or empty. + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.disallowedTags + * @since v1.4.1 + */ + xhtmlFormat.disallowedTags = []; + + /** + * Array containing tags which should not be removed when empty. + * + * @type {Array} + * @name jQuery.sceditor.plugins.xhtml.allowedEmptyTags + * @since v2.0.0 + */ + xhtmlFormat.allowedEmptyTags = []; + + sceditor.formats.xhtml = xhtmlFormat; +}(sceditor));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/alternative-lists.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,157 @@ +/** + * SCEditor Inline-Code Plugin for BBCode format + * http://www.sceditor.com/ + * + * Copyright (C) 2011-2013, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor alternative lists plugin + * This plugin implements phpBB style of the lists: + * [list] + * [*]item + * [*]item + * [/list] + * @author Alex Betis + */ + +(function (sceditor) { + 'use strict'; + + var utils = sceditor.utils; + + function isFunction(fn) { + return typeof fn === 'function'; + } + + sceditor.plugins['alternative-lists'] = function () { + var base = this; + + /** + * Private functions + * @private + */ + var bulletHandler; + var orderedHandler; + var insertListTag; + + base.init = function () { + var opts = this.opts; + + // Enable for BBCode only + if (opts.format && opts.format !== 'bbcode') { + return; + } + + // Override only txtExec implementation + sceditor.command.get('orderedlist').txtExec = orderedHandler; + sceditor.command.get('bulletlist').txtExec = bulletHandler; + + // Override current implementation + sceditor.formats.bbcode.set('list', { + breakStart: true, + isInline: false, + skipLastLineBreak: true, + html: function (token, attrs, content) { + var listType = 'disc'; + var toHtml = null; + + if (attrs.defaultattr) { + listType = attrs.defaultattr; + } + + if (listType === '1') { + // This listType belongs to orderedList (OL) + toHtml = sceditor.formats.bbcode.get('ol').html; + } else { + // unknown listType, use default bullet list behavior + toHtml = sceditor.formats.bbcode.get('ul').html; + } + + if (isFunction(toHtml)) { + return toHtml.call(this, token, attrs, content); + } else { + token.attrs['0'] = content; + return sceditor.formats.bbcode.formatBBCodeString( + toHtml, token.attrs); + } + } + }); + + sceditor.formats.bbcode.set('ul', { + tags: { + ul: null + }, + breakStart: true, + isInline: false, + skipLastLineBreak: true, + format: '[list]{0}[/list]', + html: '<ul>{0}</ul>' + }); + + sceditor.formats.bbcode.set('ol', { + tags: { + ol: null + }, + breakStart: true, + isInline: false, + skipLastLineBreak: true, + format: '[list=1]{0}[/list]', + html: '<ol>{0}</ol>' + }); + + sceditor.formats.bbcode.set('li', { + tags: { + li: null + }, + isInline: false, + closedBy: ['/ul', '/ol', '/list', '*', 'li'], + format: '[*]{0}', + html: '<li>{0}</li>' + }); + + sceditor.formats.bbcode.set('*', { + isInline: false, + excludeClosing: true, + closedBy: ['/ul', '/ol', '/list', '*', 'li'], + html: '<li>{0}</li>' + }); + }; + + insertListTag = function (editor, listType, selected) { + var content = ''; + + utils.each(selected.split(/\r?\n/), function (item) { + content += (content ? '\n' : '') + + '[*]' + item; + }); + + if (listType === '') { + editor.insertText('[list]\n' + content + '\n[/list]'); + } else { + editor.insertText('[list=' + listType + ']\n' + content + + '\n[/list]'); + } + }; + + /** + * Function for the txtExec and exec properties + * + * @param {node} caller + * @private + */ + orderedHandler = function (caller, selected) { + var editor = this; + + insertListTag(editor, '1', selected); + }; + + bulletHandler = function (caller, selected) { + var editor = this; + + insertListTag(editor, '', selected); + }; + + }; +})(sceditor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/autosave.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,110 @@ +/** + * SCEditor AutoSave Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (sceditor) { + 'use strict'; + + var defaultKey = 'sce-autodraft-' + location.pathname + location.search; + + function clear(key) { + localStorage.removeItem(key || defaultKey); + } + + sceditor.plugins.autosave = function () { + var base = this; + var editor; + var isLoading = false; + var storageKey = defaultKey; + // 86400000 = 24 hrs (24 * 60 * 60 * 1000) + var expires = 86400000; + var saveHandler = function (value) { + localStorage.setItem(storageKey, JSON.stringify(value)); + }; + var loadHandler = function () { + return JSON.parse(localStorage.getItem(storageKey)); + }; + + function gc() { + for (var i = 0; i < localStorage.length; i++) { + var key = localStorage.key(i); + + if (/^sce\-autodraft\-/.test(key)) { + var item = JSON.parse(localStorage.getItem(storageKey)); + if (item && item.time < Date.now() - expires) { + clear(key); + } + } + } + } + + base.init = function () { + editor = this; + var opts = editor.opts && editor.opts.autosave || {}; + + saveHandler = opts.save || saveHandler; + loadHandler = opts.load || loadHandler; + storageKey = opts.storageKey || storageKey; + expires = opts.expires || expires; + + gc(); + }; + + base.signalReady = function () { + // Add submit event listener to clear autosave + var parent = editor.getContentAreaContainer(); + while (parent) { + if (/form/i.test(parent.nodeName)) { + parent.addEventListener( + 'submit', clear.bind(null, storageKey), true + ); + break; + } + + parent = parent.parentNode; + } + + var state = loadHandler(); + if (state) { + isLoading = true; + editor.sourceMode(state.sourceMode); + editor.val(state.value, false); + editor.focus(); + + if (state.sourceMode) { + editor.sourceEditorCaret(state.caret); + } else { + editor.getRangeHelper().restoreRange(); + } + isLoading = false; + } else { + saveHandler({ + caret: this.sourceEditorCaret(), + sourceMode: this.sourceMode(), + value: editor.val(null, false), + time: Date.now() + }); + } + }; + + base.signalValuechangedEvent = function (e) { + if (!isLoading) { + saveHandler({ + caret: this.sourceEditorCaret(), + sourceMode: this.sourceMode(), + value: e.detail.rawValue, + time: Date.now() + }); + } + }; + }; + + sceditor.plugins.autosave.clear = clear; +}(sceditor));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/autoyoutube.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,106 @@ +/** + * SCEditor Auto Youtube Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2016, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (document, sceditor) { + 'use strict'; + + var dom = sceditor.dom; + + /* + (^|\s) Start of line or space + (?:https?:\/\/)? Optional scheme like http:// + (?:www\.)? Optional www. prefix + (?: + youtu\.be\/ Ends with .be/ so whatever comes next is the ID + | + youtube\.com\/watch\?v= Matches the .com version + ) + ([^"&?\/ ]{11}) The actual YT ID + (?:\&[\&_\?0-9a-z\#]+)? Any extra URL params + (\s|$) End of line or space + */ + var ytUrlRegex = /(^|\s)(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/watch\?v=)([^"&?\/ ]{11})(?:\&[\&_\?0-9a-z\#]+)?(\s|$)/i; + + function youtubeEmbedCode(id) { + return '<iframe width="560" height="315" frameborder="0" ' + + 'src="https://www.youtube-nocookie.com/embed/' + id + '" ' + + 'data-youtube-id="' + id + '" allowfullscreen></iframe>'; + } + + function convertYoutubeLinks(parent, isRoot) { + var node = parent.firstChild; + var wholeContent = (parent.textContent || ''); + + // Don't care about whitespace if is the root node + if (isRoot) { + wholeContent = wholeContent.trim(); + } + + var match = wholeContent.match(ytUrlRegex); + // Whole content match so only return URL embed + if (wholeContent === wholeContent.trim() && match && + match[0].length === wholeContent.length) { + dom.removeAttr(parent, 'style'); + dom.removeAttr(parent, 'class'); + parent.innerHTML = youtubeEmbedCode(match[2]); + return; + } + + while (node) { + // 3 is TextNodes + if (node.nodeType === 3) { + var text = node.nodeValue; + var nodeParent = node.parentNode; + + if ((match = text.match(ytUrlRegex))) { + nodeParent.insertBefore(document.createTextNode( + text.substr(0, match.index) + match[1] + ), node); + + nodeParent.insertBefore( + dom.parseHTML(youtubeEmbedCode(match[2])), node + ); + + node.nodeValue = match[3] + + text.substr(match.index + match[0].length); + } + } else { + // TODO: Make this tag configurable. + if (!dom.is(node, 'code')) { + convertYoutubeLinks(node); + } + } + + node = node.nextSibling; + } + }; + + sceditor.plugins.autoyoutube = function () { + this.signalPasteRaw = function (data) { + // TODO: Make this tag configurable. + // Skip code tags + if (dom.closest(this.currentNode(), 'code')) { + return; + } + + if (data.html || data.text) { + var node = document.createElement('div'); + + node.innerHTML = data.html || + sceditor.escapeEntities(data.text); + + convertYoutubeLinks(node, true); + + data.html = node.innerHTML; + } + }; + }; +})(document, sceditor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/dragdrop.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,222 @@ +/** + * SCEditor Drag and Drop Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (sceditor) { + 'use strict'; + + /** + * Place holder GIF shown while image is loading. + * @type {string} + * @private + */ + var loadingGif = 'data:image/gif;base64,R0lGODlhlgBkAPABAH19ffb29iH5BAAK' + + 'AAAAIf4aQ3JlYXRlZCB3aXRoIGFqYXhsb2FkLmluZm8AIf8LTkVUU0NBUEUyLjADAQA' + + 'AACwAAAAAlgBkAAAC1YyPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s' + + '73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2Py+f0u' + + 'v2OvwD2fP6iD/gH6Pc2GIhg2JeQSNjGuLf4GMlYKIloefAIUEl52ZmJyaY5mUhqyFnq' + + 'mQr6KRoaMKp66hbLumpQ69oK+5qrOyg4a6qYV2x8jJysvMzc7PwMHS09TV1tfY2drb3' + + 'N3e39DR4uPk5ebn6Onq6+zt7u/g4fL99UAAAh+QQACgAAACwAAAAAlgBkAIEAAAB9fX' + + '329vYAAAAC3JSPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MC' + + 'ofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2Py+f0uv2OvwD2' + + 'fP4iABgY+CcoCNeHuJdQyLjIaOiWiOj4CEhZ+SbZd/nI2RipqYhQOThKGpAZCuBZyAr' + + 'ZprpqSupaCqtaazmLCRqai7rb2av5W5wqSShcm8fc7PwMHS09TV1tfY2drb3N3e39DR' + + '4uPk5ebn6Onq6+zt7u/g4fLz9PX29/j5/vVAAAIfkEAAoAAAAsAAAAAJYAZACBAAAAf' + + 'X199vb2AAAAAuCUj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4P' + + 'DAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9jr8' + + 'E9nz+AgAYGLjQVwhXiJgguAiYgGjo9tinyCjoKLn3hpmJUGmJsBmguUnpCXCJOZraaX' + + 'oKShoJe9DqehCqKlnqiZobuzrbyvuIO8xqKpxIPKlwrPCbBx0tPU1dbX2Nna29zd3t/' + + 'Q0eLj5OXm5+jp6uvs7e7v4OHy8/T19vf4+fr7/P379UAAAh+QQACgAAACwAAAAAlgBk' + + 'AIEAAAB9fX329vYAAAAC4JSPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3' + + 'n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2Py+' + + 'f0uv2OvwT2fP6iD7gAMEhICAeImIAYiFDoOPi22KcouZfw6BhZGUBZeYlp6LbJiTD6C' + + 'Qqg6Vm6eQqqKtkZ24iaKtrKunpQa9tmmju7Wwu7KFtMi3oYDMzompkHHS09TV1tfY2d' + + 'rb3N3e39DR4uPk5ebn6Onq6+zt7u/g4fLz9PX29/j5+vv8/f31QAADs='; + + /** + * Basic check for browser support + * @type {boolean} + * @private + */ + var isSupported = typeof window.FileReader !== 'undefined'; + var base64DataUri = /data:[^;]+;base64,/i; + + function base64DataUriToBlob(url) { + // 5 is length of "data:" prefix + var mime = url.substr(5, url.indexOf(';') - 5); + var data = atob(url.substr(url.indexOf(',') + 1)); + /* global Uint8Array */ + var binary = new Uint8Array(data.length); + + for (var i = 0; i < data.length; i++) { + binary[i] = data[i].charCodeAt(0); + } + + try { + return new Blob([binary], { type: mime }); + } catch (e) { + return null; + } + } + + sceditor.plugins.dragdrop = function () { + if (!isSupported) { + return; + } + + var base = this; + var opts; + var editor; + var handleFile; + var container; + var cover; + var placeholderId = 0; + + + function hideCover() { + cover.style.display = 'none'; + container.className = container.className.replace(/(^| )dnd( |$)/g, ''); + } + + function showCover() { + if (cover.style.display === 'none') { + cover.style.display = 'block'; + container.className += ' dnd'; + } + } + + function isAllowed(file) { + // FF sets type to application/x-moz-file until it has been dropped + if (file.type !== 'application/x-moz-file' && opts.allowedTypes && + opts.allowedTypes.indexOf(file.type) < 0) { + return false; + } + + return opts.isAllowed ? opts.isAllowed(file) : true; + }; + + function createHolder(toReplace) { + var placeholder = document.createElement('img'); + placeholder.src = loadingGif; + placeholder.className = 'sceditor-ignore'; + placeholder.id = 'sce-dragdrop-' + placeholderId++; + + function replace(html) { + var node = editor + .getBody() + .ownerDocument + .getElementById(placeholder.id); + + if (node) { + if (typeof html === 'string') { + node.insertAdjacentHTML('afterend', html); + } + + node.parentNode.removeChild(node); + } + } + + return function () { + if (toReplace) { + toReplace.parentNode.replaceChild(placeholder, toReplace); + } else { + editor.wysiwygEditorInsertHtml(placeholder.outerHTML); + } + + return { + insert: function (html) { + replace(html); + }, + cancel: replace + }; + }; + } + + function handleDragOver(e) { + var dt = e.dataTransfer; + var files = dt.files.length || !dt.items ? dt.files : dt.items; + + for (var i = 0; i < files.length; i++) { + // Dragging a string should be left to default + if (files[i].kind === 'string') { + return; + } + } + + showCover(); + e.preventDefault(); + } + + function handleDrop(e) { + var dt = e.dataTransfer; + var files = dt.files.length || !dt.items ? dt.files : dt.items; + + hideCover(); + + for (var i = 0; i < files.length; i++) { + // Dragging a string should be left to default + if (files[i].kind === 'string') { + return; + } + + if (isAllowed(files[i])) { + handleFile(files[i], createHolder()); + } + } + + e.preventDefault(); + } + + base.signalReady = function () { + editor = this; + opts = editor.opts.dragdrop || {}; + handleFile = opts.handleFile; + + container = editor.getContentAreaContainer().parentNode; + + cover = container.appendChild(sceditor.dom.parseHTML( + '<div class="sceditor-dnd-cover" style="display: none">' + + '<p>' + editor._('Drop files here') + '</p>' + + '</div>' + ).firstChild); + + container.addEventListener('dragover', handleDragOver); + container.addEventListener('dragleave', hideCover); + container.addEventListener('dragend', hideCover); + container.addEventListener('drop', handleDrop); + + editor.getBody().addEventListener('dragover', handleDragOver); + editor.getBody().addEventListener('drop', hideCover); + }; + + base.signalPasteHtml = function (paste) { + if (!('handlePaste' in opts) || opts.handlePaste) { + var div = document.createElement('div'); + div.innerHTML = paste.val; + + var images = div.querySelectorAll('img'); + for (var i = 0; i < images.length; i++) { + var image = images[i]; + + if (base64DataUri.test(image.src)) { + var file = base64DataUriToBlob(image.src); + if (file && isAllowed(file)) { + handleFile(file, createHolder(image)); + } else { + image.parentNode.removeChild(image); + } + } + } + + paste.val = div.innerHTML; + } + }; + }; +})(sceditor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/format.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,127 @@ +/** + * SCEditor Paragraph Formatting Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2011-2013, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor Paragraph Formatting Plugin + * @author Sam Clarke + */ +(function (sceditor) { + 'use strict'; + + sceditor.plugins.format = function () { + var base = this; + + /** + * Default tags + * @type {Object} + * @private + */ + var tags = { + p: 'Paragraph', + h1: 'Heading 1', + h2: 'Heading 2', + h3: 'Heading 3', + h4: 'Heading 4', + h5: 'Heading 5', + h6: 'Heading 6', + address: 'Address', + pre: 'Preformatted Text' + }; + + /** + * Private functions + * @private + */ + var insertTag, + formatCmd; + + + base.init = function () { + var opts = this.opts, + pOpts = opts.paragraphformat; + + // Don't enable if the BBCode plugin is enabled. + if (opts.format && opts.format === 'bbcode') { + return; + } + + if (pOpts) { + if (pOpts.tags) { + tags = pOpts.tags; + } + + if (pOpts.excludeTags) { + pOpts.excludeTags.forEach(function (val) { + delete tags[val]; + }); + } + } + + if (!this.commands.format) { + this.commands.format = { + exec: formatCmd, + txtExec: formatCmd, + tooltip: 'Format Paragraph' + }; + } + + if (opts.toolbar === sceditor.defaultOptions.toolbar) { + opts.toolbar = opts.toolbar.replace(',color,', + ',color,format,'); + } + }; + + /** + * Inserts the specified tag into the editor + * + * @param {sceditor} editor + * @param {string} tag + * @private + */ + insertTag = function (editor, tag) { + if (editor.sourceMode()) { + editor.insert('<' + tag + '>', '</' + tag + '>'); + } else { + editor.execCommand('formatblock', '<' + tag + '>'); + } + + }; + + /** + * Function for the exec and txtExec properties + * + * @param {node} caller + * @private + */ + formatCmd = function (caller) { + var editor = this, + content = document.createElement('div'); + + sceditor.utils.each(tags, function (tag, val) { + var link = document.createElement('a'); + link.className = 'sceditor-option'; + link.textContent = val.name || val; + link.addEventListener('click', function (e) { + editor.closeDropDown(true); + + if (val.exec) { + val.exec(editor); + } else { + insertTag(editor, tag); + } + + e.preventDefault(); + }); + + content.appendChild(link); + }); + + editor.createDropDown(caller, 'format', content); + }; + }; +})(sceditor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/plaintext.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,78 @@ +/** + * SCEditor Plain Text Plugin + * http://www.sceditor.com/ + * + * Copyright (C) 2016, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @author Sam Clarke + */ +(function (sceditor) { + 'use strict'; + + var utils = sceditor.utils; + var dom = sceditor.dom; + + /** + * Options: + * + * pastetext.addButton - If to replace the plaintext button with a toggle + * button that enables and disables plain text mode. + * + * pastetext.enabled - If the plain text button should be enabled at start + * up. Only applies if addButton is enabled. + */ + sceditor.plugins.plaintext = function () { + var plainTextEnabled = true; + + this.init = function () { + var commands = this.commands; + var opts = this.opts; + + if (opts && opts.plaintext && opts.plaintext.addButton) { + plainTextEnabled = opts.plaintext.enabled; + + commands.pastetext = utils.extend(commands.pastetext || {}, { + state: function () { + return plainTextEnabled ? 1 : 0; + }, + exec: function () { + plainTextEnabled = !plainTextEnabled; + } + }); + } + }; + + this.signalPasteRaw = function (data) { + if (plainTextEnabled) { + if (data.html && !data.text) { + var div = document.createElement('div'); + div.innerHTML = data.html; + + // TODO: Refactor into private shared module with editor + // innerText adds two newlines after <p> tags so convert + // them to <div> tags + utils.each(div.querySelectorAll('p'), function (_, elm) { + dom.convertElement(elm, 'div'); + }); + // Remove collapsed <br> tags as innerText converts them to + // newlines + utils.each(div.querySelectorAll('br'), function (_, elm) { + if (!elm.nextSibling || + !dom.isInline(elm.nextSibling, true)) { + elm.parentNode.removeChild(elm); + } + }); + + document.body.appendChild(div); + data.text = div.innerText; + document.body.removeChild(div); + } + + data.html = null; + } + }; + }; +}(sceditor));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/undo.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,362 @@ +(function (sceditor) { + 'use strict'; + + sceditor.plugins.undo = function () { + var base = this; + var sourceEditor; + var editor; + var body; + var lastInputType = ''; + var charChangedCount = 0; + var isInPatchedFn = false; + /** + * If currently restoring a state + * Should ignore events while it's happening + */ + var isApplying = false; + /** + * If current selection change event has already been stored + */ + var isSelectionChangeHandled = false; + + var undoLimit = 50; + var undoStates = []; + var redoPosition = 0; + var lastState; + + /** + * Sets the editor to the specified state. + * @param {Object} state + * @private + */ + function applyState(state) { + isApplying = true; + editor.sourceMode(state.sourceMode); + + if (state.sourceMode) { + editor.val(state.value, false); + editor.sourceEditorCaret(state.caret); + } else { + editor.getBody().innerHTML = state.value; + + var range = editor.getRangeHelper().selectedRange(); + setRangePositions(range, state.caret); + editor.getRangeHelper().selectRange(range); + } + + editor.focus(); + isApplying = false; + }; + + /** + * Patches a function on the object to call store() after invocation + * @param {Object} obj + * @param {string} fn + */ + function patch(obj, fn) { + var origFn = obj[fn]; + obj[fn] = function () { + // sourceMode calls other patched methods so need to ignore them + var ignore = isInPatchedFn; + + // Store caret position before any change is made + if (!ignore && !isApplying && lastState && + editor.getRangeHelper().hasSelection()) { + updateLastState(); + } + + isInPatchedFn = true; + origFn.apply(this, arguments); + + if (!ignore) { + isInPatchedFn = false; + + if (!isApplying) { + storeState(); + lastInputType = ''; + } + } + }; + } + + /** + * Stores the editors current state + */ + function storeState() { + if (redoPosition) { + undoStates.length -= redoPosition; + redoPosition = 0; + } + + if (undoLimit > 0 && undoStates.length > undoLimit) { + undoStates.shift(); + } + + lastState = {}; + updateLastState(); + undoStates.push(lastState); + } + + /** + * Updates the last saved state with the editors current state + */ + function updateLastState() { + var sourceMode = editor.sourceMode(); + lastState.caret = sourceMode ? editor.sourceEditorCaret() : + getRangePositions(editor.getRangeHelper().selectedRange()); + lastState.sourceMode = sourceMode; + lastState.value = sourceMode ? + editor.getSourceEditorValue(false) : + editor.getBody().innerHTML; + } + + base.init = function () { + // The this variable will be set to the instance of the editor + // calling it, hence why the plugins "this" is saved to the base + // variable. + editor = this; + + undoLimit = editor.undoLimit || undoLimit; + + editor.addShortcut('ctrl+z', base.undo); + editor.addShortcut('ctrl+shift+z', base.redo); + editor.addShortcut('ctrl+y', base.redo); + }; + + function documentSelectionChangeHandler() { + if (sourceEditor === document.activeElement) { + base.signalSelectionchangedEvent(); + } + } + + base.signalReady = function () { + sourceEditor = editor.getContentAreaContainer().nextSibling; + body = editor.getBody(); + + // Store initial state + storeState(); + + // Patch methods that allow inserting content into the editor + // programmatically + // TODO: remove this when there is a built in event to handle it + patch(editor, 'setWysiwygEditorValue'); + patch(editor, 'setSourceEditorValue'); + patch(editor, 'sourceEditorInsertText'); + patch(editor.getRangeHelper(), 'insertNode'); + patch(editor, 'toggleSourceMode'); + + /** + * Handles the before input event so can override built in + * undo / redo + * @param {InputEvent} e + */ + function beforeInputHandler(e) { + if (e.inputType === 'historyUndo') { + base.undo(); + e.preventDefault(); + } else if (e.inputType === 'historyRedo') { + base.redo(); + e.preventDefault(); + } + } + + body.addEventListener('beforeinput', beforeInputHandler); + sourceEditor.addEventListener('beforeinput', beforeInputHandler); + + /** + * Should always store state at the end of composing + */ + function compositionHandler() { + lastInputType = ''; + storeState(); + } + body.addEventListener('compositionend', compositionHandler); + sourceEditor.addEventListener('compositionend', compositionHandler); + + // Chrome doesn't trigger selectionchange on textarea so need to + // listen to global event + document.addEventListener('selectionchange', + documentSelectionChangeHandler); + }; + + base.destroy = function () { + document.removeEventListener('selectionchange', + documentSelectionChangeHandler); + }; + + base.undo = function () { + lastState = null; + + if (redoPosition < undoStates.length - 1) { + redoPosition++; + applyState(undoStates[undoStates.length - 1 - redoPosition]); + } + + return false; + }; + + base.redo = function () { + if (redoPosition > 0) { + redoPosition--; + applyState(undoStates[undoStates.length - 1 - redoPosition]); + } + + return false; + }; + + /** + * Handle the selectionchanged event so can store the last caret + * position before the input so undoing places it in the right place + */ + base.signalSelectionchangedEvent = function () { + if (isApplying || isSelectionChangeHandled) { + isSelectionChangeHandled = false; + return; + } + if (lastState) { + updateLastState(); + } + lastInputType = ''; + }; + + /** + * Handles the input event + * @param {InputEvent} e + */ + base.signalInputEvent = function (e) { + // InputType is one of + // https://rawgit.com/w3c/input-events/v1/index.html#interface-InputEvent-Attributes + // Most should cause a full undo item to be added so only need to + // handle a few of them + var inputType = e.inputType; + + // Should ignore selection changes that occur because of input + // events as already handling them + isSelectionChangeHandled = true; + + // inputType should be supported by all supported browsers + // except IE 11 in runWithoutWysiwygSupport. Shouldn't be an issue + // as native handling will mostly work there. + // Ignore if composing as will handle composition end instead + if (!inputType || e.isComposing) { + return; + } + + switch (e.inputType) { + case 'deleteContentBackward': + if (lastState && lastInputType === inputType && + charChangedCount < 20) { + updateLastState(); + } else { + storeState(); + charChangedCount = 0; + } + + lastInputType = inputType; + break; + + case 'insertText': + charChangedCount += e.data ? e.data.length : 1; + + if (lastState && lastInputType === inputType && + charChangedCount < 20 && !/\s$/.test(e.data)) { + updateLastState(); + } else { + storeState(); + charChangedCount = 0; + } + + lastInputType = inputType; + break; + default: + lastInputType = 'sce-misc'; + charChangedCount = 0; + storeState(); + break; + } + }; + + /** + * Creates a positions object form passed range + * @param {Range} range + * @return {Object<string, Array<number>} + */ + function getRangePositions(range) { + // Merge any adjacent text nodes as it will be done by innerHTML + // which would cause positions to be off if not done + body.normalize(); + + return { + startPositions: + nodeToPositions(range.startContainer, range.startOffset), + endPositions: + nodeToPositions(range.endContainer, range.endOffset) + }; + } + + /** + * Sets the range start/end based on the positions object + * @param {Range} range + * @param {Object<string, Array<number>>} positions + */ + function setRangePositions(range, positions) { + try { + var startPositions = positions.startPositions; + var endPositions = positions.endPositions; + + range.setStart(positionsToNode(body, startPositions), + startPositions[0]); + range.setEnd(positionsToNode(body, endPositions), + endPositions[0]); + } catch (e) { + if (console && console.warn) { + console.warn('[SCEditor] Undo plugin lost caret', e); + } + } + } + + /** + * Converts the passed container and offset into positions array + * @param {Node} container + * @param {number} offset + * @returns {Array<number>} + */ + function nodeToPositions(container, offset) { + var positions = [offset]; + var node = container; + + while (node && node.tagName !== 'BODY') { + positions.push(nodeIndex(node)); + node = node.parentNode; + } + + return positions; + } + + /** + * Returns index of passed node + * @param {Node} node + * @returns {number} + */ + function nodeIndex(node) { + var i = 0; + while ((node = node.previousSibling)) { + i++; + } + return i; + } + + /** + * Gets the container node from the positions array + * @param {Node} node + * @param {Array<number>} positions + * @returns {Node} + */ + function positionsToNode(node, positions) { + for (var i = positions.length - 1; node && i > 0; i--) { + node = node.childNodes[positions[i]]; + } + return node; + } + }; +}(sceditor));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/plugins/v1compat.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,97 @@ +/** + * Version 1 compatibility plugin + * + * Patches commands and BBCodes set with + * command.set and bbcode.set to wrap DOM + * node arguments in jQuery objects. + * + * Should only be used to ease migrating. + */ +(function (sceditor, $) { + 'use strict'; + + var plugins = sceditor.plugins; + + /** + * Patches a method to wrap and DOM nodes in a jQuery object + * @private + */ + function patchMethodArguments(fn) { + if (fn._scePatched) { + return fn; + } + + var patch = function () { + var args = []; + + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + + if (arg && arg.nodeType) { + args.push($(arg)); + } else { + args.push(arg); + } + } + + return fn.apply(this, args); + }; + + patch._scePatched = true; + return patch; + } + + /** + * Patches a method to wrap any return value in a jQuery object + * @private + */ + function patchMethodReturn(fn) { + if (fn._scePatched) { + return fn; + } + + var patch = function () { + return $(fn.apply(this, arguments)); + }; + + patch._scePatched = true; + return patch; + } + + var oldSet = sceditor.command.set; + sceditor.command.set = function (name, cmd) { + if (cmd && typeof cmd.exec === 'function') { + cmd.exec = patchMethodArguments(cmd.exec); + } + + if (cmd && typeof cmd.txtExec === 'function') { + cmd.txtExec = patchMethodArguments(cmd.txtExec); + } + + return oldSet.call(this, name, cmd); + }; + + if (plugins.bbcode) { + var oldBBCodeSet = plugins.bbcode.bbcode.set; + plugins.bbcode.bbcode.set = function (name, bbcode) { + if (bbcode && typeof bbcode.format === 'function') { + bbcode.format = patchMethodArguments(bbcode.format); + } + + return oldBBCodeSet.call(this, name, bbcode); + }; + }; + + var oldCreate = sceditor.create; + sceditor.create = function (textarea, options) { + oldCreate.call(this, textarea, options); + + if (textarea && textarea._sceditor) { + var editor = textarea._sceditor; + + editor.getBody = patchMethodReturn(editor.getBody); + editor.getContentAreaContainer = + patchMethodReturn(editor.getContentAreaContainer); + } + }; +}(sceditor, jQuery));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/sceditor.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,9089 @@ +(function () { + 'use strict'; + + /** + * Check if the passed argument is the + * the passed type. + * + * @param {string} type + * @param {*} arg + * @returns {boolean} + */ + function isTypeof(type, arg) { + return typeof arg === type; + } + + /** + * @type {function(*): boolean} + */ + var isString = isTypeof.bind(null, 'string'); + + /** + * @type {function(*): boolean} + */ + var isUndefined = isTypeof.bind(null, 'undefined'); + + /** + * @type {function(*): boolean} + */ + var isFunction = isTypeof.bind(null, 'function'); + + /** + * @type {function(*): boolean} + */ + var isNumber = isTypeof.bind(null, 'number'); + + + /** + * Returns true if an object has no keys + * + * @param {!Object} obj + * @returns {boolean} + */ + function isEmptyObject(obj) { + return !Object.keys(obj).length; + } + + /** + * Extends the first object with any extra objects passed + * + * If the first argument is boolean and set to true + * it will extend child arrays and objects recursively. + * + * @param {!Object|boolean} targetArg + * @param {...Object} source + * @return {Object} + */ + function extend(targetArg, sourceArg) { + var isTargetBoolean = targetArg === !!targetArg; + var i = isTargetBoolean ? 2 : 1; + var target = isTargetBoolean ? sourceArg : targetArg; + var isDeep = isTargetBoolean ? targetArg : false; + + function isObject(value) { + return value !== null && typeof value === 'object' && + Object.getPrototypeOf(value) === Object.prototype; + } + + for (; i < arguments.length; i++) { + var source = arguments[i]; + + // Copy all properties for jQuery compatibility + /* eslint guard-for-in: off */ + for (var key in source) { + var targetValue = target[key]; + var value = source[key]; + + // Skip undefined values to match jQuery + if (isUndefined(value)) { + continue; + } + + // Skip special keys to prevent prototype pollution + if (key === '__proto__' || key === 'constructor') { + continue; + } + + var isValueObject = isObject(value); + var isValueArray = Array.isArray(value); + + if (isDeep && (isValueObject || isValueArray)) { + // Can only merge if target type matches otherwise create + // new target to merge into + var isSameType = isObject(targetValue) === isValueObject && + Array.isArray(targetValue) === isValueArray; + + target[key] = extend( + true, + isSameType ? targetValue : (isValueArray ? [] : {}), + value + ); + } else { + target[key] = value; + } + } + } + + return target; + } + + /** + * Removes an item from the passed array + * + * @param {!Array} arr + * @param {*} item + */ + function arrayRemove(arr, item) { + var i = arr.indexOf(item); + + if (i > -1) { + arr.splice(i, 1); + } + } + + /** + * Iterates over an array or object + * + * @param {!Object|Array} obj + * @param {function(*, *)} fn + */ + function each(obj, fn) { + if (Array.isArray(obj) || 'length' in obj && isNumber(obj.length)) { + for (var i = 0; i < obj.length; i++) { + fn(i, obj[i]); + } + } else { + Object.keys(obj).forEach(function (key) { + fn(key, obj[key]); + }); + } + } + + /** + * Cache of camelCase CSS property names + * @type {Object<string, string>} + */ + var cssPropertyNameCache = {}; + + /** + * Node type constant for element nodes + * + * @type {number} + */ + var ELEMENT_NODE = 1; + + /** + * Node type constant for text nodes + * + * @type {number} + */ + var TEXT_NODE = 3; + + /** + * Node type constant for comment nodes + * + * @type {number} + */ + var COMMENT_NODE = 8; + + function toFloat(value) { + value = parseFloat(value); + + return isFinite(value) ? value : 0; + } + + /** + * Creates an element with the specified attributes + * + * Will create it in the current document unless context + * is specified. + * + * @param {!string} tag + * @param {!Object<string, string>} [attributes] + * @param {!Document} [context] + * @returns {!HTMLElement} + */ + function createElement(tag, attributes, context) { + var node = (context || document).createElement(tag); + + each(attributes || {}, function (key, value) { + if (key === 'style') { + node.style.cssText = value; + } else if (key in node) { + node[key] = value; + } else { + node.setAttribute(key, value); + } + }); + + return node; + } + + /** + * Gets the first parent node that matches the selector + * + * @param {!HTMLElement} node + * @param {!string} [selector] + * @returns {HTMLElement|undefined} + */ + function parent(node, selector) { + var parent = node || {}; + + while ((parent = parent.parentNode) && !/(9|11)/.test(parent.nodeType)) { + if (!selector || is(parent, selector)) { + return parent; + } + } + } + + /** + * Checks the passed node and all parents and + * returns the first matching node if any. + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {HTMLElement|undefined} + */ + function closest(node, selector) { + return is(node, selector) ? node : parent(node, selector); + } + + /** + * Removes the node from the DOM + * + * @param {!HTMLElement} node + */ + function remove(node) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + } + + /** + * Appends child to parent node + * + * @param {!HTMLElement} node + * @param {!HTMLElement} child + */ + function appendChild(node, child) { + node.appendChild(child); + } + + /** + * Finds any child nodes that match the selector + * + * @param {!HTMLElement} node + * @param {!string} selector + * @returns {NodeList} + */ + function find(node, selector) { + return node.querySelectorAll(selector); + } + + /** + * For on() and off() if to add/remove the event + * to the capture phase + * + * @type {boolean} + */ + var EVENT_CAPTURE = true; + + /** + * Adds an event listener for the specified events. + * + * Events should be a space separated list of events. + * + * If selector is specified the handler will only be + * called when the event target matches the selector. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see off() + */ + // eslint-disable-next-line max-params + function on(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector] || function (e) { + var target = e.target; + while (target && target !== node) { + if (is(target, selector)) { + fn.call(target, e); + return; + } + + target = target.parentNode; + } + }; + + fn['_sce-event-' + event + selector] = handler; + } else { + handler = selector; + capture = fn; + } + + node.addEventListener(event, handler, capture || false); + }); + } + + /** + * Removes an event listener for the specified events. + * + * @param {!Node} node + * @param {string} events + * @param {string} [selector] + * @param {function(Object)} fn + * @param {boolean} [capture=false] + * @see on() + */ + // eslint-disable-next-line max-params + function off(node, events, selector, fn, capture) { + events.split(' ').forEach(function (event) { + var handler; + + if (isString(selector)) { + handler = fn['_sce-event-' + event + selector]; + } else { + handler = selector; + capture = fn; + } + + node.removeEventListener(event, handler, capture || false); + }); + } + + /** + * If only attr param is specified it will get + * the value of the attr param. + * + * If value is specified but null the attribute + * will be removed otherwise the attr value will + * be set to the passed value. + * + * @param {!HTMLElement} node + * @param {!string} attr + * @param {?string} [value] + */ + function attr(node, attr, value) { + if (arguments.length < 3) { + return node.getAttribute(attr); + } + + // eslint-disable-next-line eqeqeq, no-eq-null + if (value == null) { + removeAttr(node, attr); + } else { + node.setAttribute(attr, value); + } + } + + /** + * Removes the specified attribute + * + * @param {!HTMLElement} node + * @param {!string} attr + */ + function removeAttr(node, attr) { + node.removeAttribute(attr); + } + + /** + * Sets the passed elements display to none + * + * @param {!HTMLElement} node + */ + function hide(node) { + css(node, 'display', 'none'); + } + + /** + * Sets the passed elements display to default + * + * @param {!HTMLElement} node + */ + function show(node) { + css(node, 'display', ''); + } + + /** + * Toggles an elements visibility + * + * @param {!HTMLElement} node + */ + function toggle(node) { + if (isVisible(node)) { + hide(node); + } else { + show(node); + } + } + + /** + * Gets a computed CSS values or sets an inline CSS value + * + * Rules should be in camelCase format and not + * hyphenated like CSS properties. + * + * @param {!HTMLElement} node + * @param {!Object|string} rule + * @param {string|number} [value] + * @return {string|number|undefined} + */ + function css(node, rule, value) { + if (arguments.length < 3) { + if (isString(rule)) { + return node.nodeType === 1 ? getComputedStyle(node)[rule] : null; + } + + each(rule, function (key, value) { + css(node, key, value); + }); + } else { + // isNaN returns false for null, false and empty strings + // so need to check it's truthy or 0 + var isNumeric = (value || value === 0) && !isNaN(value); + node.style[rule] = isNumeric ? value + 'px' : value; + } + } + + + /** + * Gets or sets the data attributes on a node + * + * Unlike the jQuery version this only stores data + * in the DOM attributes which means only strings + * can be stored. + * + * @param {Node} node + * @param {string} [key] + * @param {string} [value] + * @return {Object|undefined} + */ + function data(node, key, value) { + var argsLength = arguments.length; + var data = {}; + + if (node.nodeType === ELEMENT_NODE) { + if (argsLength === 1) { + each(node.attributes, function (_, attr) { + if (/^data\-/i.test(attr.name)) { + data[attr.name.substr(5)] = attr.value; + } + }); + + return data; + } + + if (argsLength === 2) { + return attr(node, 'data-' + key); + } + + attr(node, 'data-' + key, String(value)); + } + } + + /** + * Checks if node matches the given selector. + * + * @param {?HTMLElement} node + * @param {string} selector + * @returns {boolean} + */ + function is(node, selector) { + var result = false; + + if (node && node.nodeType === ELEMENT_NODE) { + result = (node.matches || node.msMatchesSelector || + node.webkitMatchesSelector).call(node, selector); + } + + return result; + } + + + /** + * Returns true if node contains child otherwise false. + * + * This differs from the DOM contains() method in that + * if node and child are equal this will return false. + * + * @param {!Node} node + * @param {HTMLElement} child + * @returns {boolean} + */ + function contains(node, child) { + return node !== child && node.contains && node.contains(child); + } + + /** + * @param {Node} node + * @param {string} [selector] + * @returns {?HTMLElement} + */ + function previousElementSibling(node, selector) { + var prev = node.previousElementSibling; + + if (selector && prev) { + return is(prev, selector) ? prev : null; + } + + return prev; + } + + /** + * @param {!Node} node + * @param {!Node} refNode + * @returns {Node} + */ + function insertBefore(node, refNode) { + return refNode.parentNode.insertBefore(node, refNode); + } + + /** + * @param {?HTMLElement} node + * @returns {!Array.<string>} + */ + function classes(node) { + return node.className.trim().split(/\s+/); + } + + /** + * @param {?HTMLElement} node + * @param {string} className + * @returns {boolean} + */ + function hasClass(node, className) { + return is(node, '.' + className); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function addClass(node, className) { + var classList = classes(node); + + if (classList.indexOf(className) < 0) { + classList.push(className); + } + + node.className = classList.join(' '); + } + + /** + * @param {!HTMLElement} node + * @param {string} className + */ + function removeClass(node, className) { + var classList = classes(node); + + arrayRemove(classList, className); + + node.className = classList.join(' '); + } + + /** + * Toggles a class on node. + * + * If state is specified and is truthy it will add + * the class. + * + * If state is specified and is falsey it will remove + * the class. + * + * @param {HTMLElement} node + * @param {string} className + * @param {boolean} [state] + */ + function toggleClass(node, className, state) { + state = isUndefined(state) ? !hasClass(node, className) : state; + + if (state) { + addClass(node, className); + } else { + removeClass(node, className); + } + } + + /** + * Gets or sets the width of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function width(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingLeft) + toFloat(cs.paddingRight); + var border = toFloat(cs.borderLeftWidth) + toFloat(cs.borderRightWidth); + + return node.offsetWidth - padding - border; + } + + css(node, 'width', value); + } + + /** + * Gets or sets the height of the passed node. + * + * @param {HTMLElement} node + * @param {number|string} [value] + * @returns {number|undefined} + */ + function height(node, value) { + if (isUndefined(value)) { + var cs = getComputedStyle(node); + var padding = toFloat(cs.paddingTop) + toFloat(cs.paddingBottom); + var border = toFloat(cs.borderTopWidth) + toFloat(cs.borderBottomWidth); + + return node.offsetHeight - padding - border; + } + + css(node, 'height', value); + } + + /** + * Triggers a custom event with the specified name and + * sets the detail property to the data object passed. + * + * @param {HTMLElement} node + * @param {string} eventName + * @param {Object} [data] + */ + function trigger(node, eventName, data) { + var event; + + if (isFunction(window.CustomEvent)) { + event = new CustomEvent(eventName, { + bubbles: true, + cancelable: true, + detail: data + }); + } else { + event = node.ownerDocument.createEvent('CustomEvent'); + event.initCustomEvent(eventName, true, true, data); + } + + node.dispatchEvent(event); + } + + /** + * Returns if a node is visible. + * + * @param {HTMLElement} + * @returns {boolean} + */ + function isVisible(node) { + return !!node.getClientRects().length; + } + + /** + * Convert CSS property names into camel case + * + * @param {string} string + * @returns {string} + */ + function camelCase(string) { + return string + .replace(/^-ms-/, 'ms-') + .replace(/-(\w)/g, function (match, char) { + return char.toUpperCase(); + }); + } + + + /** + * Loop all child nodes of the passed node + * + * The function should accept 1 parameter being the node. + * If the function returns false the loop will be exited. + * + * @param {HTMLElement} node + * @param {function} func Callback which is called with every + * child node as the first argument. + * @param {boolean} innermostFirst If the innermost node should be passed + * to the function before it's parents. + * @param {boolean} siblingsOnly If to only traverse the nodes siblings + * @param {boolean} [reverse=false] If to traverse the nodes in reverse + */ + // eslint-disable-next-line max-params + function traverse(node, func, innermostFirst, siblingsOnly, reverse) { + node = reverse ? node.lastChild : node.firstChild; + + while (node) { + var next = reverse ? node.previousSibling : node.nextSibling; + + if ( + (!innermostFirst && func(node) === false) || + (!siblingsOnly && traverse( + node, func, innermostFirst, siblingsOnly, reverse + ) === false) || + (innermostFirst && func(node) === false) + ) { + return false; + } + + node = next; + } + } + + /** + * Like traverse but loops in reverse + * @see traverse + */ + function rTraverse(node, func, innermostFirst, siblingsOnly) { + traverse(node, func, innermostFirst, siblingsOnly, true); + } + + /** + * Parses HTML into a document fragment + * + * @param {string} html + * @param {Document} [context] + * @since 1.4.4 + * @return {DocumentFragment} + */ + function parseHTML(html, context) { + context = context || document; + + var ret = context.createDocumentFragment(); + var tmp = createElement('div', {}, context); + + tmp.innerHTML = html; + + while (tmp.firstChild) { + appendChild(ret, tmp.firstChild); + } + + return ret; + } + + /** + * Checks if an element has any styling. + * + * It has styling if it is not a plain <div> or <p> or + * if it has a class, style attribute or data. + * + * @param {HTMLElement} elm + * @return {boolean} + * @since 1.4.4 + */ + function hasStyling(node) { + return node && (!is(node, 'p,div') || node.className || + attr(node, 'style') || !isEmptyObject(data(node))); + } + + /** + * Converts an element from one type to another. + * + * For example it can convert the element <b> to <strong> + * + * @param {HTMLElement} element + * @param {string} toTagName + * @return {HTMLElement} + * @since 1.4.4 + */ + function convertElement(element, toTagName) { + var newElement = createElement(toTagName, {}, element.ownerDocument); + + each(element.attributes, function (_, attribute) { + // Some browsers parse invalid attributes names like + // 'size"2' which throw an exception when set, just + // ignore these. + try { + attr(newElement, attribute.name, attribute.value); + } catch (ex) {} + }); + + while (element.firstChild) { + appendChild(newElement, element.firstChild); + } + + element.parentNode.replaceChild(newElement, element); + + return newElement; + } + + /** + * List of block level elements separated by bars (|) + * + * @type {string} + */ + var blockLevelList = '|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|' + + 'form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|' + + 'details|section|article|aside|nav|main|header|hgroup|footer|fieldset|' + + 'dl|dt|dd|figure|figcaption|'; + + /** + * List of elements that do not allow children separated by bars (|) + * + * @param {Node} node + * @return {boolean} + * @since 1.4.5 + */ + function canHaveChildren(node) { + // 1 = Element + // 9 = Document + // 11 = Document Fragment + if (!/11?|9/.test(node.nodeType)) { + return false; + } + + // List of empty HTML tags separated by bar (|) character. + // Source: http://www.w3.org/TR/html4/index/elements.html + // Source: http://www.w3.org/TR/html5/syntax.html#void-elements + return ('|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr' + + '|isindex|link|meta|param|command|embed|keygen|source|track|' + + 'object|').indexOf('|' + node.nodeName.toLowerCase() + '|') < 0; + } + + /** + * Checks if an element is inline + * + * @param {HTMLElement} elm + * @param {boolean} [includeCodeAsBlock=false] + * @return {boolean} + */ + function isInline(elm, includeCodeAsBlock) { + var tagName, + nodeType = (elm || {}).nodeType || TEXT_NODE; + + if (nodeType !== ELEMENT_NODE) { + return nodeType === TEXT_NODE; + } + + tagName = elm.tagName.toLowerCase(); + + if (tagName === 'code') { + return !includeCodeAsBlock; + } + + return blockLevelList.indexOf('|' + tagName + '|') < 0; + } + + /** + * Copy the CSS from 1 node to another. + * + * Only copies CSS defined on the element e.g. style attr. + * + * @param {HTMLElement} from + * @param {HTMLElement} to + * @deprecated since v3.1.0 + */ + function copyCSS(from, to) { + if (to.style && from.style) { + to.style.cssText = from.style.cssText + to.style.cssText; + } + } + + /** + * Checks if a DOM node is empty + * + * @param {Node} node + * @returns {boolean} + */ + function isEmpty(node) { + if (node.lastChild && isEmpty(node.lastChild)) { + remove(node.lastChild); + } + + return node.nodeType === 3 ? !node.nodeValue : + (canHaveChildren(node) && !node.childNodes.length); + } + + /** + * Fixes block level elements inside in inline elements. + * + * Also fixes invalid list nesting by placing nested lists + * inside the previous li tag or wrapping them in an li tag. + * + * @param {HTMLElement} node + */ + function fixNesting(node) { + traverse(node, function (node) { + var list = 'ul,ol', + isBlock = !isInline(node, true) && node.nodeType !== COMMENT_NODE, + parent = node.parentNode; + + // Any blocklevel element inside an inline element needs fixing. + // Also <p> tags that contain blocks should be fixed + if (isBlock && (isInline(parent, true) || parent.tagName === 'P')) { + // Find the last inline parent node + var lastInlineParent = node; + while (isInline(lastInlineParent.parentNode, true) || + lastInlineParent.parentNode.tagName === 'P') { + lastInlineParent = lastInlineParent.parentNode; + } + + var before = extractContents(lastInlineParent, node); + var middle = node; + + // Clone inline styling and apply it to the blocks children + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + while (middle.firstChild) { + appendChild(clone, middle.firstChild); + } + + appendChild(middle, clone); + } + parent = parent.parentNode; + } + + insertBefore(middle, lastInlineParent); + if (!isEmpty(before)) { + insertBefore(before, middle); + } + if (isEmpty(lastInlineParent)) { + remove(lastInlineParent); + } + } + + // Fix invalid nested lists which should be wrapped in an li tag + if (isBlock && is(node, list) && is(node.parentNode, list)) { + var li = previousElementSibling(node, 'li'); + + if (!li) { + li = createElement('li'); + insertBefore(li, node); + } + + appendChild(li, node); + } + }); + } + + /** + * Finds the common parent of two nodes + * + * @param {!HTMLElement} node1 + * @param {!HTMLElement} node2 + * @return {?HTMLElement} + */ + function findCommonAncestor(node1, node2) { + while ((node1 = node1.parentNode)) { + if (contains(node1, node2)) { + return node1; + } + } + } + + /** + * @param {?Node} + * @param {boolean} [previous=false] + * @returns {?Node} + */ + function getSibling(node, previous) { + if (!node) { + return null; + } + + return (previous ? node.previousSibling : node.nextSibling) || + getSibling(node.parentNode, previous); + } + + /** + * Removes unused whitespace from the root and all it's children. + * + * @param {!HTMLElement} root + * @since 1.4.3 + */ + function removeWhiteSpace(root) { + var nodeValue, nodeType, next, previous, previousSibling, + nextNode, trimStart, + cssWhiteSpace = css(root, 'whiteSpace'), + // Preserve newlines if is pre-line + preserveNewLines = /line$/i.test(cssWhiteSpace), + node = root.firstChild; + + // Skip pre & pre-wrap with any vendor prefix + if (/pre(\-wrap)?$/i.test(cssWhiteSpace)) { + return; + } + + while (node) { + nextNode = node.nextSibling; + nodeValue = node.nodeValue; + nodeType = node.nodeType; + + if (nodeType === ELEMENT_NODE && node.firstChild) { + removeWhiteSpace(node); + } + + if (nodeType === TEXT_NODE) { + next = getSibling(node); + previous = getSibling(node, true); + trimStart = false; + + while (hasClass(previous, 'sceditor-ignore')) { + previous = getSibling(previous, true); + } + + // If previous sibling isn't inline or is a textnode that + // ends in whitespace, time the start whitespace + if (isInline(node) && previous) { + previousSibling = previous; + + while (previousSibling.lastChild) { + previousSibling = previousSibling.lastChild; + + // eslint-disable-next-line max-depth + while (hasClass(previousSibling, 'sceditor-ignore')) { + previousSibling = getSibling(previousSibling, true); + } + } + + trimStart = previousSibling.nodeType === TEXT_NODE ? + /[\t\n\r ]$/.test(previousSibling.nodeValue) : + !isInline(previousSibling); + } + + // Clear zero width spaces + nodeValue = nodeValue.replace(/\u200B/g, ''); + + // Strip leading whitespace + if (!previous || !isInline(previous) || trimStart) { + nodeValue = nodeValue.replace( + preserveNewLines ? /^[\t ]+/ : /^[\t\n\r ]+/, + '' + ); + } + + // Strip trailing whitespace + if (!next || !isInline(next)) { + nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+$/ : /[\t\n\r ]+$/, + '' + ); + } + + // Remove empty text nodes + if (!nodeValue.length) { + remove(node); + } else { + node.nodeValue = nodeValue.replace( + preserveNewLines ? /[\t ]+/g : /[\t\n\r ]+/g, + ' ' + ); + } + } + + node = nextNode; + } + } + + /** + * Extracts all the nodes between the start and end nodes + * + * @param {HTMLElement} startNode The node to start extracting at + * @param {HTMLElement} endNode The node to stop extracting at + * @return {DocumentFragment} + */ + function extractContents(startNode, endNode) { + var range = startNode.ownerDocument.createRange(); + + range.setStartBefore(startNode); + range.setEndAfter(endNode); + + return range.extractContents(); + } + + /** + * Gets the offset position of an element + * + * @param {HTMLElement} node + * @return {Object} An object with left and top properties + */ + function getOffset(node) { + var left = 0, + top = 0; + + while (node) { + left += node.offsetLeft; + top += node.offsetTop; + node = node.offsetParent; + } + + return { + left: left, + top: top + }; + } + + /** + * Gets the value of a CSS property from the elements style attribute + * + * @param {HTMLElement} elm + * @param {string} property + * @return {string} + */ + function getStyle(elm, property) { + var styleValue, + elmStyle = elm.style; + + if (!cssPropertyNameCache[property]) { + cssPropertyNameCache[property] = camelCase(property); + } + + property = cssPropertyNameCache[property]; + styleValue = elmStyle[property]; + + // Add an exception for text-align + if ('textAlign' === property) { + styleValue = styleValue || css(elm, property); + + if (css(elm.parentNode, property) === styleValue || + css(elm, 'display') !== 'block' || is(elm, 'hr,th')) { + return ''; + } + } + + return styleValue; + } + + /** + * Tests if an element has a style. + * + * If values are specified it will check that the styles value + * matches one of the values + * + * @param {HTMLElement} elm + * @param {string} property + * @param {string|array} [values] + * @return {boolean} + */ + function hasStyle(elm, property, values) { + var styleValue = getStyle(elm, property); + + if (!styleValue) { + return false; + } + + return !values || styleValue === values || + (Array.isArray(values) && values.indexOf(styleValue) > -1); + } + + /** + * Returns true if both nodes have the same number of inline styles and all the + * inline styles have matching values + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function stylesMatch(nodeA, nodeB) { + var i = nodeA.style.length; + if (i !== nodeB.style.length) { + return false; + } + + while (i--) { + var prop = nodeA.style[i]; + if (nodeA.style[prop] !== nodeB.style[prop]) { + return false; + } + } + + return true; + } + + /** + * Returns true if both nodes have the same number of attributes and all the + * attribute values match + * + * @param {HTMLElement} nodeA + * @param {HTMLElement} nodeB + * @returns {boolean} + */ + function attributesMatch(nodeA, nodeB) { + var i = nodeA.attributes.length; + if (i !== nodeB.attributes.length) { + return false; + } + + while (i--) { + var prop = nodeA.attributes[i]; + var notMatches = prop.name === 'style' ? + !stylesMatch(nodeA, nodeB) : + prop.value !== attr(nodeB, prop.name); + + if (notMatches) { + return false; + } + } + + return true; + } + + /** + * Removes an element placing its children in its place + * + * @param {HTMLElement} node + */ + function removeKeepChildren(node) { + while (node.firstChild) { + insertBefore(node.firstChild, node); + } + + remove(node); + } + + /** + * Merges inline styles and tags with parents where possible + * + * @param {Node} node + * @since 3.1.0 + */ + function merge(node) { + if (node.nodeType !== ELEMENT_NODE) { + return; + } + + var parent = node.parentNode; + var tagName = node.tagName; + var mergeTags = /B|STRONG|EM|SPAN|FONT/; + + // Merge children (in reverse as children can be removed) + var i = node.childNodes.length; + while (i--) { + merge(node.childNodes[i]); + } + + // Should only merge inline tags + if (!isInline(node)) { + return; + } + + // Remove any inline styles that match the parent style + i = node.style.length; + while (i--) { + var prop = node.style[i]; + if (css(parent, prop) === css(node, prop)) { + node.style.removeProperty(prop); + } + } + + // Can only remove / merge tags if no inline styling left. + // If there is any inline style left then it means it at least partially + // doesn't match the parent style so must stay + if (!node.style.length) { + removeAttr(node, 'style'); + + // Remove font attributes if match parent + if (tagName === 'FONT') { + if (css(node, 'fontFamily').toLowerCase() === + css(parent, 'fontFamily').toLowerCase()) { + removeAttr(node, 'face'); + } + + if (css(node, 'color') === css(parent, 'color')) { + removeAttr(node, 'color'); + } + + if (css(node, 'fontSize') === css(parent, 'fontSize')) { + removeAttr(node, 'size'); + } + } + + // Spans and font tags with no attributes can be safely removed + if (!node.attributes.length && /SPAN|FONT/.test(tagName)) { + removeKeepChildren(node); + } else if (mergeTags.test(tagName)) { + var isBold = /B|STRONG/.test(tagName); + var isItalic = tagName === 'EM'; + + while (parent && isInline(parent) && + (!isBold || /bold|700/i.test(css(parent, 'fontWeight'))) && + (!isItalic || css(parent, 'fontStyle') === 'italic')) { + + // Remove if parent match + if ((parent.tagName === tagName || + (isBold && /B|STRONG/.test(parent.tagName))) && + attributesMatch(parent, node)) { + removeKeepChildren(node); + break; + } + + parent = parent.parentNode; + } + } + } + + // Merge siblings if attributes, including inline styles, match + var next = node.nextSibling; + if (next && next.tagName === tagName && attributesMatch(next, node)) { + appendChild(node, next); + removeKeepChildren(next); + } + } + + /** + * Default options for SCEditor + * @type {Object} + */ + var defaultOptions = { + /** @lends jQuery.sceditor.defaultOptions */ + /** + * Toolbar buttons order and groups. Should be comma separated and + * have a bar | to separate groups + * + * @type {string} + */ + toolbar: 'bold,italic,underline,strike,subscript,superscript|' + + 'left,center,right,justify|font,size,color,removeformat|' + + 'cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|' + + 'table|code,quote|horizontalrule,image,email,link,unlink|' + + 'emoticon,youtube,date,time|ltr,rtl|print,maximize,source', + + /** + * Comma separated list of commands to excludes from the toolbar + * + * @type {string} + */ + toolbarExclude: null, + + /** + * Stylesheet to include in the WYSIWYG editor. This is what will style + * the WYSIWYG elements + * + * @type {string} + */ + style: 'jquery.sceditor.default.css', + + /** + * Comma separated list of fonts for the font selector + * + * @type {string} + */ + fonts: 'Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,' + + 'Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana', + + /** + * Colors should be comma separated and have a bar | to signal a new + * column. + * + * If null the colors will be auto generated. + * + * @type {string} + */ + colors: '#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|' + + '#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|' + + '#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|' + + '#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|' + + '#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|' + + '#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|' + + '#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|' + + '#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef', + + /** + * The locale to use. + * @type {string} + */ + locale: attr(document.documentElement, 'lang') || 'en', + + /** + * The Charset to use + * @type {string} + */ + charset: 'utf-8', + + /** + * Compatibility mode for emoticons. + * + * Helps if you have emoticons such as :/ which would put an emoticon + * inside http:// + * + * This mode requires emoticons to be surrounded by whitespace or end of + * line chars. This mode has limited As You Type emoticon conversion + * support. It will not replace AYT for end of line chars, only + * emoticons surrounded by whitespace. They will still be replaced + * correctly when loaded just not AYT. + * + * @type {boolean} + */ + emoticonsCompat: false, + + /** + * If to enable emoticons. Can be changes at runtime using the + * emoticons() method. + * + * @type {boolean} + * @since 1.4.2 + */ + emoticonsEnabled: true, + + /** + * Emoticon root URL + * + * @type {string} + */ + emoticonsRoot: '', + emoticons: { + dropdown: { + ':)': 'emoticons/smile.png', + ':angel:': 'emoticons/angel.png', + ':angry:': 'emoticons/angry.png', + '8-)': 'emoticons/cool.png', + ':\'(': 'emoticons/cwy.png', + ':ermm:': 'emoticons/ermm.png', + ':D': 'emoticons/grin.png', + '<3': 'emoticons/heart.png', + ':(': 'emoticons/sad.png', + ':O': 'emoticons/shocked.png', + ':P': 'emoticons/tongue.png', + ';)': 'emoticons/wink.png' + }, + more: { + ':alien:': 'emoticons/alien.png', + ':blink:': 'emoticons/blink.png', + ':blush:': 'emoticons/blush.png', + ':cheerful:': 'emoticons/cheerful.png', + ':devil:': 'emoticons/devil.png', + ':dizzy:': 'emoticons/dizzy.png', + ':getlost:': 'emoticons/getlost.png', + ':happy:': 'emoticons/happy.png', + ':kissing:': 'emoticons/kissing.png', + ':ninja:': 'emoticons/ninja.png', + ':pinch:': 'emoticons/pinch.png', + ':pouty:': 'emoticons/pouty.png', + ':sick:': 'emoticons/sick.png', + ':sideways:': 'emoticons/sideways.png', + ':silly:': 'emoticons/silly.png', + ':sleeping:': 'emoticons/sleeping.png', + ':unsure:': 'emoticons/unsure.png', + ':woot:': 'emoticons/w00t.png', + ':wassat:': 'emoticons/wassat.png' + }, + hidden: { + ':whistling:': 'emoticons/whistling.png', + ':love:': 'emoticons/wub.png' + } + }, + + /** + * Width of the editor. Set to null for automatic with + * + * @type {?number} + */ + width: null, + + /** + * Height of the editor including toolbar. Set to null for automatic + * height + * + * @type {?number} + */ + height: null, + + /** + * If to allow the editor to be resized + * + * @type {boolean} + */ + resizeEnabled: true, + + /** + * Min resize to width, set to null for half textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinWidth: null, + /** + * Min resize to height, set to null for half textarea height or -1 for + * unlimited + * + * @type {?number} + */ + resizeMinHeight: null, + /** + * Max resize to height, set to null for double textarea height or -1 + * for unlimited + * + * @type {?number} + */ + resizeMaxHeight: null, + /** + * Max resize to width, set to null for double textarea width or -1 for + * unlimited + * + * @type {?number} + */ + resizeMaxWidth: null, + /** + * If resizing by height is enabled + * + * @type {boolean} + */ + resizeHeight: true, + /** + * If resizing by width is enabled + * + * @type {boolean} + */ + resizeWidth: true, + + /** + * Date format, will be overridden if locale specifies one. + * + * The words year, month and day will be replaced with the users current + * year, month and day. + * + * @type {string} + */ + dateFormat: 'year-month-day', + + /** + * Element to inset the toolbar into. + * + * @type {HTMLElement} + */ + toolbarContainer: null, + + /** + * If to enable paste filtering. This is currently experimental, please + * report any issues. + * + * @type {boolean} + */ + enablePasteFiltering: false, + + /** + * If to completely disable pasting into the editor + * + * @type {boolean} + */ + disablePasting: false, + + /** + * If the editor is read only. + * + * @type {boolean} + */ + readOnly: false, + + /** + * If to set the editor to right-to-left mode. + * + * If set to null the direction will be automatically detected. + * + * @type {boolean} + */ + rtl: false, + + /** + * If to auto focus the editor on page load + * + * @type {boolean} + */ + autofocus: false, + + /** + * If to auto focus the editor to the end of the content + * + * @type {boolean} + */ + autofocusEnd: true, + + /** + * If to auto expand the editor to fix the content + * + * @type {boolean} + */ + autoExpand: false, + + /** + * If to auto update original textbox on blur + * + * @type {boolean} + */ + autoUpdate: false, + + /** + * If to enable the browsers built in spell checker + * + * @type {boolean} + */ + spellcheck: true, + + /** + * If to run the source editor when there is no WYSIWYG support. Only + * really applies to mobile OS's. + * + * @type {boolean} + */ + runWithoutWysiwygSupport: false, + + /** + * If to load the editor in source mode and still allow switching + * between WYSIWYG and source mode + * + * @type {boolean} + */ + startInSourceMode: false, + + /** + * Optional ID to give the editor. + * + * @type {string} + */ + id: null, + + /** + * Comma separated list of plugins + * + * @type {string} + */ + plugins: '', + + /** + * z-index to set the editor container to. Needed for jQuery UI dialog. + * + * @type {?number} + */ + zIndex: null, + + /** + * If to trim the BBCode. Removes any spaces at the start and end of the + * BBCode string. + * + * @type {boolean} + */ + bbcodeTrim: false, + + /** + * If to disable removing block level elements by pressing backspace at + * the start of them + * + * @type {boolean} + */ + disableBlockRemove: false, + + /** + * Array of allowed URL (should be either strings or regex) for iframes. + * + * If it's a string then iframes where the start of the src matches the + * specified string will be allowed. + * + * If it's a regex then iframes where the src matches the regex will be + * allowed. + * + * @type {Array} + */ + allowedIframeUrls: [], + + /** + * BBCode parser options, only applies if using the editor in BBCode + * mode. + * + * See SCEditor.BBCodeParser.defaults for list of valid options + * + * @type {Object} + */ + parserOptions: { }, + + /** + * CSS that will be added to the to dropdown menu (eg. z-index) + * + * @type {Object} + */ + dropDownCss: { } + }; + + // Must start with a valid scheme + // ^ + // Schemes that are considered safe + // (https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):| + // Relative schemes (//:) are considered safe + // (\\/\\/)| + // Image data URI's are considered safe + // data:image\\/(png|bmp|gif|p?jpe?g); + var VALID_SCHEME_REGEX = + /^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i; + + /** + * Escapes a string so it's safe to use in regex + * + * @param {string} str + * @return {string} + */ + function regex(str) { + return str.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'); + } + /** + * Escapes all HTML entities in a string + * + * If noQuotes is set to false, all single and double + * quotes will also be escaped + * + * @param {string} str + * @param {boolean} [noQuotes=true] + * @return {string} + * @since 1.4.1 + */ + function entities(str, noQuotes) { + if (!str) { + return str; + } + + var replacements = { + '&': '&', + '<': '<', + '>': '>', + ' ': ' ', + '\r\n': '<br />', + '\r': '<br />', + '\n': '<br />' + }; + + if (noQuotes !== false) { + replacements['"'] = '"'; + replacements['\''] = '''; + replacements['`'] = '`'; + } + + str = str.replace(/ {2}|\r\n|[&<>\r\n'"`]/g, function (match) { + return replacements[match] || match; + }); + + return str; + } + /** + * Escape URI scheme. + * + * Appends the current URL to a url if it has a scheme that is not: + * + * http + * https + * sftp + * ftp + * mailto + * spotify + * skype + * ssh + * teamspeak + * tel + * // + * data:image/(png|jpeg|jpg|pjpeg|bmp|gif); + * + * **IMPORTANT**: This does not escape any HTML in a url, for + * that use the escape.entities() method. + * + * @param {string} url + * @return {string} + * @since 1.4.5 + */ + function uriScheme(url) { + var path, + // If there is a : before a / then it has a scheme + hasScheme = /^[^\/]*:/i, + location = window.location; + + // Has no scheme or a valid scheme + if ((!url || !hasScheme.test(url)) || VALID_SCHEME_REGEX.test(url)) { + return url; + } + + path = location.pathname.split('/'); + path.pop(); + + return location.protocol + '//' + + location.host + + path.join('/') + '/' + + url; + } + + /** + * HTML templates used by the editor and default commands + * @type {Object} + * @private + */ + var _templates = { + html: + '<!DOCTYPE html>' + + '<html{attrs}>' + + '<head>' + + '<meta http-equiv="Content-Type" ' + + 'content="text/html;charset={charset}" />' + + '<link rel="stylesheet" type="text/css" href="{style}" />' + + '</head>' + + '<body contenteditable="true" {spellcheck}><p></p></body>' + + '</html>', + + toolbarButton: '<a class="sceditor-button sceditor-button-{name}" ' + + 'data-sceditor-command="{name}" unselectable="on">' + + '<div unselectable="on">{dispName}</div></a>', + + emoticon: '<img src="{url}" data-sceditor-emoticon="{key}" ' + + 'alt="{key}" title="{tooltip}" />', + + fontOpt: '<a class="sceditor-font-option" href="#" ' + + 'data-font="{font}"><font face="{font}">{font}</font></a>', + + sizeOpt: '<a class="sceditor-fontsize-option" data-size="{size}" ' + + 'href="#"><font size="{size}">{size}</font></a>', + + pastetext: + '<div><label for="txt">{label}</label> ' + + '<textarea cols="20" rows="7" id="txt"></textarea></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + table: + '<div><label for="rows">{rows}</label><input type="text" ' + + 'id="rows" value="2" /></div>' + + '<div><label for="cols">{cols}</label><input type="text" ' + + 'id="cols" value="2" /></div>' + + '<div><input type="button" class="button" value="{insert}"' + + ' /></div>', + + image: + '<div><label for="image">{url}</label> ' + + '<input type="text" id="image" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="width">{width}</label> ' + + '<input type="text" id="width" size="2" dir="ltr" /></div>' + + '<div><label for="height">{height}</label> ' + + '<input type="text" id="height" size="2" dir="ltr" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + email: + '<div><label for="email">{label}</label> ' + + '<input type="text" id="email" dir="ltr" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + link: + '<div><label for="link">{url}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><label for="des">{desc}</label> ' + + '<input type="text" id="des" /></div>' + + '<div><input type="button" class="button" value="{ins}" /></div>', + + youtubeMenu: + '<div><label for="link">{label}</label> ' + + '<input type="text" id="link" dir="ltr" placeholder="https://" /></div>' + + '<div><input type="button" class="button" value="{insert}" />' + + '</div>', + + youtube: + '<iframe width="560" height="315" frameborder="0" allowfullscreen ' + + 'src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" ' + + 'data-youtube-id="{id}"></iframe>' + }; + + /** + * Replaces any params in a template with the passed params. + * + * If createHtml is passed it will return a DocumentFragment + * containing the parsed template. + * + * @param {string} name + * @param {Object} [params] + * @param {boolean} [createHtml] + * @returns {string|DocumentFragment} + * @private + */ + function _tmpl (name, params, createHtml) { + var template = _templates[name]; + + Object.keys(params).forEach(function (name) { + template = template.replace( + new RegExp(regex('{' + name + '}'), 'g'), params[name] + ); + }); + + if (createHtml) { + template = parseHTML(template); + } + + return template; + } + + /** + * Fixes a bug in FF where it sometimes wraps + * new lines in their own list item. + * See issue #359 + */ + function fixFirefoxListBug(editor) { + // Only apply to Firefox as will break other browsers. + if ('mozHidden' in document) { + var node = editor.getBody(); + var next; + + while (node) { + next = node; + + if (next.firstChild) { + next = next.firstChild; + } else { + + while (next && !next.nextSibling) { + next = next.parentNode; + } + + if (next) { + next = next.nextSibling; + } + } + + if (node.nodeType === 3 && /[\n\r\t]+/.test(node.nodeValue)) { + // Only remove if newlines are collapsed + if (!/^pre/.test(css(node.parentNode, 'whiteSpace'))) { + remove(node); + } + } + + node = next; + } + } + } + + + /** + * Map of all the commands for SCEditor + * @type {Object} + * @name commands + * @memberOf jQuery.sceditor + */ + var defaultCmds = { + // START_COMMAND: Bold + bold: { + exec: 'bold', + tooltip: 'Bold', + shortcut: 'Ctrl+B' + }, + // END_COMMAND + // START_COMMAND: Italic + italic: { + exec: 'italic', + tooltip: 'Italic', + shortcut: 'Ctrl+I' + }, + // END_COMMAND + // START_COMMAND: Underline + underline: { + exec: 'underline', + tooltip: 'Underline', + shortcut: 'Ctrl+U' + }, + // END_COMMAND + // START_COMMAND: Strikethrough + strike: { + exec: 'strikethrough', + tooltip: 'Strikethrough' + }, + // END_COMMAND + // START_COMMAND: Subscript + subscript: { + exec: 'subscript', + tooltip: 'Subscript' + }, + // END_COMMAND + // START_COMMAND: Superscript + superscript: { + exec: 'superscript', + tooltip: 'Superscript' + }, + // END_COMMAND + + // START_COMMAND: Left + left: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-left + return /left/.test(align) || + align === (isLtr ? 'start' : 'end'); + } + }, + exec: 'justifyleft', + tooltip: 'Align left' + }, + // END_COMMAND + // START_COMMAND: Centre + center: { + exec: 'justifycenter', + tooltip: 'Center' + }, + // END_COMMAND + // START_COMMAND: Right + right: { + state: function (node) { + if (node && node.nodeType === 3) { + node = node.parentNode; + } + + if (node) { + var isLtr = css(node, 'direction') === 'ltr'; + var align = css(node, 'textAlign'); + + // Can be -moz-right + return /right/.test(align) || + align === (isLtr ? 'end' : 'start'); + } + }, + exec: 'justifyright', + tooltip: 'Align right' + }, + // END_COMMAND + // START_COMMAND: Justify + justify: { + exec: 'justifyfull', + tooltip: 'Justify' + }, + // END_COMMAND + + // START_COMMAND: Font + font: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'font')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.opts.fonts.split(',').forEach(function (font) { + appendChild(content, _tmpl('fontOpt', { + font: font + }, true)); + }); + + editor.createDropDown(caller, 'font-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.font._dropDown(editor, caller, function (fontName) { + editor.execCommand('fontname', fontName); + }); + }, + tooltip: 'Font Name' + }, + // END_COMMAND + // START_COMMAND: Size + size: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'size')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + for (var i = 1; i <= 7; i++) { + appendChild(content, _tmpl('sizeOpt', { + size: i + }, true)); + } + + editor.createDropDown(caller, 'fontsize-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.size._dropDown(editor, caller, function (fontSize) { + editor.execCommand('fontsize', fontSize); + }); + }, + tooltip: 'Font Size' + }, + // END_COMMAND + // START_COMMAND: Colour + color: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'), + html = '', + cmd = defaultCmds.color; + + if (!cmd._htmlCache) { + editor.opts.colors.split('|').forEach(function (column) { + html += '<div class="sceditor-color-column">'; + + column.split(',').forEach(function (color) { + html += + '<a href="#" class="sceditor-color-option"' + + ' style="background-color: ' + color + '"' + + ' data-color="' + color + '"></a>'; + }); + + html += '</div>'; + }); + + cmd._htmlCache = html; + } + + appendChild(content, parseHTML(cmd._htmlCache)); + + on(content, 'click', 'a', function (e) { + callback(data(this, 'color')); + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'color-picker', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.color._dropDown(editor, caller, function (color) { + editor.execCommand('forecolor', color); + }); + }, + tooltip: 'Font Color' + }, + // END_COMMAND + // START_COMMAND: Remove Format + removeformat: { + exec: 'removeformat', + tooltip: 'Remove Formatting' + }, + // END_COMMAND + + // START_COMMAND: Cut + cut: { + exec: 'cut', + tooltip: 'Cut', + errorMessage: 'Your browser does not allow the cut command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-X' + }, + // END_COMMAND + // START_COMMAND: Copy + copy: { + exec: 'copy', + tooltip: 'Copy', + errorMessage: 'Your browser does not allow the copy command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-C' + }, + // END_COMMAND + // START_COMMAND: Paste + paste: { + exec: 'paste', + tooltip: 'Paste', + errorMessage: 'Your browser does not allow the paste command. ' + + 'Please use the keyboard shortcut Ctrl/Cmd-V' + }, + // END_COMMAND + // START_COMMAND: Paste Text + pastetext: { + exec: function (caller) { + var val, + content = createElement('div'), + editor = this; + + appendChild(content, _tmpl('pastetext', { + label: editor._( + 'Paste your text inside the following box:' + ), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + val = find(content, '#txt')[0].value; + + if (val) { + editor.wysiwygEditorInsertText(val); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'pastetext', content); + }, + tooltip: 'Paste Text' + }, + // END_COMMAND + // START_COMMAND: Bullet List + bulletlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertunorderedlist'); + }, + tooltip: 'Bullet list' + }, + // END_COMMAND + // START_COMMAND: Ordered List + orderedlist: { + exec: function () { + fixFirefoxListBug(this); + this.execCommand('insertorderedlist'); + }, + tooltip: 'Numbered list' + }, + // END_COMMAND + // START_COMMAND: Indent + indent: { + state: function (parent, firstBlock) { + // Only works with lists, for now + var range, startParent, endParent; + + if (is(firstBlock, 'li')) { + return 0; + } + + if (is(firstBlock, 'ul,ol,menu')) { + // if the whole list is selected, then this must be + // invalidated because the browser will place a + // <blockquote> there + range = this.getRangeHelper().selectedRange(); + + startParent = range.startContainer.parentNode; + endParent = range.endContainer.parentNode; + + // TODO: could use nodeType for this? + // Maybe just check the firstBlock contains both the start + //and end containers + + // Select the tag, not the textNode + // (that's why the parentNode) + if (startParent !== + startParent.parentNode.firstElementChild || + // work around a bug in FF + (is(endParent, 'li') && endParent !== + endParent.parentNode.lastElementChild)) { + return 0; + } + } + + return -1; + }, + exec: function () { + var editor = this, + block = editor.getRangeHelper().getFirstBlockParent(); + + editor.focus(); + + // An indent system is quite complicated as there are loads + // of complications and issues around how to indent text + // As default, let's just stay with indenting the lists, + // at least, for now. + if (closest(block, 'ul,ol,menu')) { + editor.execCommand('indent'); + } + }, + tooltip: 'Add indent' + }, + // END_COMMAND + // START_COMMAND: Outdent + outdent: { + state: function (parents, firstBlock) { + return closest(firstBlock, 'ul,ol,menu') ? 0 : -1; + }, + exec: function () { + var block = this.getRangeHelper().getFirstBlockParent(); + if (closest(block, 'ul,ol,menu')) { + this.execCommand('outdent'); + } + }, + tooltip: 'Remove one indent' + }, + // END_COMMAND + + // START_COMMAND: Table + table: { + exec: function (caller) { + var editor = this, + content = createElement('div'); + + appendChild(content, _tmpl('table', { + rows: editor._('Rows:'), + cols: editor._('Cols:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var rows = Number(find(content, '#rows')[0].value), + cols = Number(find(content, '#cols')[0].value), + html = '<table>'; + + if (rows > 0 && cols > 0) { + html += Array(rows + 1).join( + '<tr>' + + Array(cols + 1).join( + '<td><br /></td>' + ) + + '</tr>' + ); + + html += '</table>'; + + editor.wysiwygEditorInsertHtml(html); + editor.closeDropDown(true); + e.preventDefault(); + } + }); + + editor.createDropDown(caller, 'inserttable', content); + }, + tooltip: 'Insert a table' + }, + // END_COMMAND + + // START_COMMAND: Horizontal Rule + horizontalrule: { + exec: 'inserthorizontalrule', + tooltip: 'Insert a horizontal rule' + }, + // END_COMMAND + + // START_COMMAND: Code + code: { + exec: function () { + this.wysiwygEditorInsertHtml( + '<code>', + '<br /></code>' + ); + }, + tooltip: 'Code' + }, + // END_COMMAND + + // START_COMMAND: Image + image: { + _dropDown: function (editor, caller, selected, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('image', { + url: editor._('URL:'), + width: editor._('Width (optional):'), + height: editor._('Height (optional):'), + insert: editor._('Insert') + }, true)); + + + var urlInput = find(content, '#image')[0]; + + urlInput.value = selected; + + on(content, 'click', '.button', function (e) { + if (urlInput.value) { + cb( + urlInput.value, + find(content, '#width')[0].value, + find(content, '#height')[0].value + ); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertimage', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.image._dropDown( + editor, + caller, + '', + function (url, width, height) { + var attrs = ''; + + if (width) { + attrs += ' width="' + parseInt(width, 10) + '"'; + } + + if (height) { + attrs += ' height="' + parseInt(height, 10) + '"'; + } + + attrs += ' src="' + entities(url) + '"'; + + editor.wysiwygEditorInsertHtml( + '<img' + attrs + ' />' + ); + } + ); + }, + tooltip: 'Insert an image' + }, + // END_COMMAND + + // START_COMMAND: E-mail + email: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('email', { + label: editor._('E-mail:'), + desc: editor._('Description (optional):'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var email = find(content, '#email')[0].value; + + if (email) { + cb(email, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertemail', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.email._dropDown( + editor, + caller, + function (email, text) { + if (!editor.getRangeHelper().selectedHtml() || text) { + editor.wysiwygEditorInsertHtml( + '<a href="' + + 'mailto:' + entities(email) + '">' + + entities((text || email)) + + '</a>' + ); + } else { + editor.execCommand('createlink', 'mailto:' + email); + } + } + ); + }, + tooltip: 'Insert an email' + }, + // END_COMMAND + + // START_COMMAND: Link + link: { + _dropDown: function (editor, caller, cb) { + var content = createElement('div'); + + appendChild(content, _tmpl('link', { + url: editor._('URL:'), + desc: editor._('Description (optional):'), + ins: editor._('Insert') + }, true)); + + var linkInput = find(content, '#link')[0]; + + function insertUrl(e) { + if (linkInput.value) { + cb(linkInput.value, find(content, '#des')[0].value); + } + + editor.closeDropDown(true); + e.preventDefault(); + } + + on(content, 'click', '.button', insertUrl); + on(content, 'keypress', function (e) { + // 13 = enter key + if (e.which === 13 && linkInput.value) { + insertUrl(e); + } + }, EVENT_CAPTURE); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (caller) { + var editor = this; + + defaultCmds.link._dropDown(editor, caller, function (url, text) { + if (text || !editor.getRangeHelper().selectedHtml()) { + editor.wysiwygEditorInsertHtml( + '<a href="' + entities(url) + '">' + + entities(text || url) + + '</a>' + ); + } else { + editor.execCommand('createlink', url); + } + }); + }, + tooltip: 'Insert a link' + }, + // END_COMMAND + + // START_COMMAND: Unlink + unlink: { + state: function () { + return closest(this.currentNode(), 'a') ? 0 : -1; + }, + exec: function () { + var anchor = closest(this.currentNode(), 'a'); + + if (anchor) { + while (anchor.firstChild) { + insertBefore(anchor.firstChild, anchor); + } + + remove(anchor); + } + }, + tooltip: 'Unlink' + }, + // END_COMMAND + + + // START_COMMAND: Quote + quote: { + exec: function (caller, html, author) { + var before = '<blockquote>', + end = '</blockquote>'; + + // if there is HTML passed set end to null so any selected + // text is replaced + if (html) { + author = (author ? '<cite>' + + entities(author) + + '</cite>' : ''); + before = before + author + html + end; + end = null; + // if not add a newline to the end of the inserted quote + } else if (this.getRangeHelper().selectedHtml() === '') { + end = '<br />' + end; + } + + this.wysiwygEditorInsertHtml(before, end); + }, + tooltip: 'Insert a Quote' + }, + // END_COMMAND + + // START_COMMAND: Emoticons + emoticon: { + exec: function (caller) { + var editor = this; + + var createContent = function (includeMore) { + var moreLink, + opts = editor.opts, + emoticonsRoot = opts.emoticonsRoot || '', + emoticonsCompat = opts.emoticonsCompat, + rangeHelper = editor.getRangeHelper(), + startSpace = emoticonsCompat && + rangeHelper.getOuterText(true, 1) !== ' ' ? ' ' : '', + endSpace = emoticonsCompat && + rangeHelper.getOuterText(false, 1) !== ' ' ? ' ' : '', + content = createElement('div'), + line = createElement('div'), + perLine = 0, + emoticons = extend( + {}, + opts.emoticons.dropdown, + includeMore ? opts.emoticons.more : {} + ); + + appendChild(content, line); + + perLine = Math.sqrt(Object.keys(emoticons).length); + + on(content, 'click', 'img', function (e) { + editor.insert(startSpace + attr(this, 'alt') + endSpace, + null, false).closeDropDown(true); + + e.preventDefault(); + }); + + each(emoticons, function (code, emoticon) { + appendChild(line, createElement('img', { + src: emoticonsRoot + (emoticon.url || emoticon), + alt: code, + title: emoticon.tooltip || code + })); + + if (line.children.length >= perLine) { + line = createElement('div'); + appendChild(content, line); + } + }); + + if (!includeMore && opts.emoticons.more) { + moreLink = createElement('a', { + className: 'sceditor-more' + }); + + appendChild(moreLink, + document.createTextNode(editor._('More'))); + + on(moreLink, 'click', function (e) { + editor.createDropDown( + caller, 'more-emoticons', createContent(true) + ); + + e.preventDefault(); + }); + + appendChild(content, moreLink); + } + + return content; + }; + + editor.createDropDown(caller, 'emoticons', createContent(false)); + }, + txtExec: function (caller) { + defaultCmds.emoticon.exec.call(this, caller); + }, + tooltip: 'Insert an emoticon' + }, + // END_COMMAND + + // START_COMMAND: YouTube + youtube: { + _dropDown: function (editor, caller, callback) { + var content = createElement('div'); + + appendChild(content, _tmpl('youtubeMenu', { + label: editor._('Video URL:'), + insert: editor._('Insert') + }, true)); + + on(content, 'click', '.button', function (e) { + var val = find(content, '#link')[0].value; + var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/); + var timeMatch = val.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/); + var time = 0; + + if (timeMatch) { + each(timeMatch[1].split(/[hms]/), function (i, val) { + if (val !== '') { + time = (time * 60) + Number(val); + } + }); + } + + if (idMatch && /^[a-zA-Z0-9_\-]{11}$/.test(idMatch[1])) { + callback(idMatch[1], time); + } + + editor.closeDropDown(true); + e.preventDefault(); + }); + + editor.createDropDown(caller, 'insertlink', content); + }, + exec: function (btn) { + var editor = this; + + defaultCmds.youtube._dropDown(editor, btn, function (id, time) { + editor.wysiwygEditorInsertHtml(_tmpl('youtube', { + id: id, + time: time + })); + }); + }, + tooltip: 'Insert a YouTube video' + }, + // END_COMMAND + + // START_COMMAND: Date + date: { + _date: function (editor) { + var now = new Date(), + year = now.getYear(), + month = now.getMonth() + 1, + day = now.getDate(); + + if (year < 2000) { + year = 1900 + year; + } + + if (month < 10) { + month = '0' + month; + } + + if (day < 10) { + day = '0' + day; + } + + return editor.opts.dateFormat + .replace(/year/i, year) + .replace(/month/i, month) + .replace(/day/i, day); + }, + exec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + txtExec: function () { + this.insertText(defaultCmds.date._date(this)); + }, + tooltip: 'Insert current date' + }, + // END_COMMAND + + // START_COMMAND: Time + time: { + _time: function () { + var now = new Date(), + hours = now.getHours(), + mins = now.getMinutes(), + secs = now.getSeconds(); + + if (hours < 10) { + hours = '0' + hours; + } + + if (mins < 10) { + mins = '0' + mins; + } + + if (secs < 10) { + secs = '0' + secs; + } + + return hours + ':' + mins + ':' + secs; + }, + exec: function () { + this.insertText(defaultCmds.time._time()); + }, + txtExec: function () { + this.insertText(defaultCmds.time._time()); + }, + tooltip: 'Insert current time' + }, + // END_COMMAND + + + // START_COMMAND: Ltr + ltr: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'ltr'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'ltr' ? '' : 'ltr'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Left-to-Right' + }, + // END_COMMAND + + // START_COMMAND: Rtl + rtl: { + state: function (parents, firstBlock) { + return firstBlock && firstBlock.style.direction === 'rtl'; + }, + exec: function () { + var editor = this, + rangeHelper = editor.getRangeHelper(), + node = rangeHelper.getFirstBlockParent(); + + editor.focus(); + + if (!node || is(node, 'body')) { + editor.execCommand('formatBlock', 'p'); + + node = rangeHelper.getFirstBlockParent(); + + if (!node || is(node, 'body')) { + return; + } + } + + var toggleValue = css(node, 'direction') === 'rtl' ? '' : 'rtl'; + css(node, 'direction', toggleValue); + }, + tooltip: 'Right-to-Left' + }, + // END_COMMAND + + + // START_COMMAND: Print + print: { + exec: 'print', + tooltip: 'Print' + }, + // END_COMMAND + + // START_COMMAND: Maximize + maximize: { + state: function () { + return this.maximize(); + }, + exec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + txtExec: function () { + this.maximize(!this.maximize()); + this.focus(); + }, + tooltip: 'Maximize', + shortcut: 'Ctrl+Shift+M' + }, + // END_COMMAND + + // START_COMMAND: Source + source: { + state: function () { + return this.sourceMode(); + }, + exec: function () { + this.toggleSourceMode(); + this.focus(); + }, + txtExec: function () { + this.toggleSourceMode(); + this.focus(); + }, + tooltip: 'View source', + shortcut: 'Ctrl+Shift+S' + }, + // END_COMMAND + + // this is here so that commands above can be removed + // without having to remove the , after the last one. + // Needed for IE. + ignore: {} + }; + + var plugins = {}; + + /** + * Plugin Manager class + * @class PluginManager + * @name PluginManager + */ + function PluginManager(thisObj) { + /** + * Alias of this + * + * @private + * @type {Object} + */ + var base = this; + + /** + * Array of all currently registered plugins + * + * @type {Array} + * @private + */ + var registeredPlugins = []; + + + /** + * Changes a signals name from "name" into "signalName". + * + * @param {string} signal + * @return {string} + * @private + */ + var formatSignalName = function (signal) { + return 'signal' + signal.charAt(0).toUpperCase() + signal.slice(1); + }; + + /** + * Calls handlers for a signal + * + * @see call() + * @see callOnlyFirst() + * @param {Array} args + * @param {boolean} returnAtFirst + * @return {*} + * @private + */ + var callHandlers = function (args, returnAtFirst) { + args = [].slice.call(args); + + var idx, ret, + signal = formatSignalName(args.shift()); + + for (idx = 0; idx < registeredPlugins.length; idx++) { + if (signal in registeredPlugins[idx]) { + ret = registeredPlugins[idx][signal].apply(thisObj, args); + + if (returnAtFirst) { + return ret; + } + } + } + }; + + /** + * Calls all handlers for the passed signal + * + * @param {string} signal + * @param {...string} args + * @function + * @name call + * @memberOf PluginManager.prototype + */ + base.call = function () { + callHandlers(arguments, false); + }; + + /** + * Calls the first handler for a signal, and returns the + * + * @param {string} signal + * @param {...string} args + * @return {*} The result of calling the handler + * @function + * @name callOnlyFirst + * @memberOf PluginManager.prototype + */ + base.callOnlyFirst = function () { + return callHandlers(arguments, true); + }; + + /** + * Checks if a signal has a handler + * + * @param {string} signal + * @return {boolean} + * @function + * @name hasHandler + * @memberOf PluginManager.prototype + */ + base.hasHandler = function (signal) { + var i = registeredPlugins.length; + signal = formatSignalName(signal); + + while (i--) { + if (signal in registeredPlugins[i]) { + return true; + } + } + + return false; + }; + + /** + * Checks if the plugin exists in plugins + * + * @param {string} plugin + * @return {boolean} + * @function + * @name exists + * @memberOf PluginManager.prototype + */ + base.exists = function (plugin) { + if (plugin in plugins) { + plugin = plugins[plugin]; + + return typeof plugin === 'function' && + typeof plugin.prototype === 'object'; + } + + return false; + }; + + /** + * Checks if the passed plugin is currently registered. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name isRegistered + * @memberOf PluginManager.prototype + */ + base.isRegistered = function (plugin) { + if (base.exists(plugin)) { + var idx = registeredPlugins.length; + + while (idx--) { + if (registeredPlugins[idx] instanceof plugins[plugin]) { + return true; + } + } + } + + return false; + }; + + /** + * Registers a plugin to receive signals + * + * @param {string} plugin + * @return {boolean} + * @function + * @name register + * @memberOf PluginManager.prototype + */ + base.register = function (plugin) { + if (!base.exists(plugin) || base.isRegistered(plugin)) { + return false; + } + + plugin = new plugins[plugin](); + registeredPlugins.push(plugin); + + if ('init' in plugin) { + plugin.init.call(thisObj); + } + + return true; + }; + + /** + * Deregisters a plugin. + * + * @param {string} plugin + * @return {boolean} + * @function + * @name deregister + * @memberOf PluginManager.prototype + */ + base.deregister = function (plugin) { + var removedPlugin, + pluginIdx = registeredPlugins.length, + removed = false; + + if (!base.isRegistered(plugin)) { + return removed; + } + + while (pluginIdx--) { + if (registeredPlugins[pluginIdx] instanceof plugins[plugin]) { + removedPlugin = registeredPlugins.splice(pluginIdx, 1)[0]; + removed = true; + + if ('destroy' in removedPlugin) { + removedPlugin.destroy.call(thisObj); + } + } + } + + return removed; + }; + + /** + * Clears all plugins and removes the owner reference. + * + * Calling any functions on this object after calling + * destroy will cause a JS error. + * + * @name destroy + * @memberOf PluginManager.prototype + */ + base.destroy = function () { + var i = registeredPlugins.length; + + while (i--) { + if ('destroy' in registeredPlugins[i]) { + registeredPlugins[i].destroy.call(thisObj); + } + } + + registeredPlugins = []; + thisObj = null; + }; + } + PluginManager.plugins = plugins; + + /** + * Gets the text, start/end node and offset for + * length chars left or right of the passed node + * at the specified offset. + * + * @param {Node} node + * @param {number} offset + * @param {boolean} isLeft + * @param {number} length + * @return {Object} + * @private + */ + var outerText = function (range, isLeft, length) { + var nodeValue, remaining, start, end, node, + text = '', + next = range.startContainer, + offset = range.startOffset; + + // Handle cases where node is a paragraph and offset + // refers to the index of a text node. + // 3 = text node + if (next && next.nodeType !== 3) { + next = next.childNodes[offset]; + offset = 0; + } + + start = end = offset; + + while (length > text.length && next && next.nodeType === 3) { + nodeValue = next.nodeValue; + remaining = length - text.length; + + // If not the first node, start and end should be at their + // max values as will be updated when getting the text + if (node) { + end = nodeValue.length; + start = 0; + } + + node = next; + + if (isLeft) { + start = Math.max(end - remaining, 0); + offset = start; + + text = nodeValue.substr(start, end - start) + text; + next = node.previousSibling; + } else { + end = Math.min(remaining, nodeValue.length); + offset = start + end; + + text += nodeValue.substr(start, end); + next = node.nextSibling; + } + } + + return { + node: node || next, + offset: offset, + text: text + }; + }; + + /** + * Range helper + * + * @class RangeHelper + * @name RangeHelper + */ + function RangeHelper(win, d, sanitize) { + var _createMarker, _prepareInput, + doc = d || win.contentDocument || win.document, + startMarker = 'sceditor-start-marker', + endMarker = 'sceditor-end-marker', + base = this; + + /** + * Inserts HTML into the current range replacing any selected + * text. + * + * If endHTML is specified the selected contents will be put between + * html and endHTML. If there is nothing selected html and endHTML are + * just concatenate together. + * + * @param {string} html + * @param {string} [endHTML] + * @return False on fail + * @function + * @name insertHTML + * @memberOf RangeHelper.prototype + */ + base.insertHTML = function (html, endHTML) { + var node, div, + range = base.selectedRange(); + + if (!range) { + return false; + } + + if (endHTML) { + html += base.selectedHtml() + endHTML; + } + + div = createElement('p', {}, doc); + node = doc.createDocumentFragment(); + div.innerHTML = sanitize(html); + + while (div.firstChild) { + appendChild(node, div.firstChild); + } + + base.insertNode(node); + }; + + /** + * Prepares HTML to be inserted by adding a zero width space + * if the last child is empty and adding the range start/end + * markers to the last child. + * + * @param {Node|string} node + * @param {Node|string} [endNode] + * @param {boolean} [returnHtml] + * @return {Node|string} + * @private + */ + _prepareInput = function (node, endNode, returnHtml) { + var lastChild, + frag = doc.createDocumentFragment(); + + if (typeof node === 'string') { + if (endNode) { + node += base.selectedHtml() + endNode; + } + + frag = parseHTML(node); + } else { + appendChild(frag, node); + + if (endNode) { + appendChild(frag, base.selectedRange().extractContents()); + appendChild(frag, endNode); + } + } + + if (!(lastChild = frag.lastChild)) { + return; + } + + while (!isInline(lastChild.lastChild, true)) { + lastChild = lastChild.lastChild; + } + + if (canHaveChildren(lastChild)) { + // Webkit won't allow the cursor to be placed inside an + // empty tag, so add a zero width space to it. + if (!lastChild.lastChild) { + appendChild(lastChild, document.createTextNode('\u200B')); + } + } else { + lastChild = frag; + } + + base.removeMarkers(); + + // Append marks to last child so when restored cursor will be in + // the right place + appendChild(lastChild, _createMarker(startMarker)); + appendChild(lastChild, _createMarker(endMarker)); + + if (returnHtml) { + var div = createElement('div'); + appendChild(div, frag); + + return div.innerHTML; + } + + return frag; + }; + + /** + * The same as insertHTML except with DOM nodes instead + * + * <strong>Warning:</strong> the nodes must belong to the + * document they are being inserted into. Some browsers + * will throw exceptions if they don't. + * + * Returns boolean false on fail + * + * @param {Node} node + * @param {Node} endNode + * @return {false|undefined} + * @function + * @name insertNode + * @memberOf RangeHelper.prototype + */ + base.insertNode = function (node, endNode) { + var first, last, + input = _prepareInput(node, endNode), + range = base.selectedRange(), + parent = range.commonAncestorContainer, + emptyNodes = []; + + if (!input) { + return false; + } + + function removeIfEmpty(node) { + // Only remove empty node if it wasn't already empty + if (node && isEmpty(node) && emptyNodes.indexOf(node) < 0) { + remove(node); + } + } + + if (range.startContainer !== range.endContainer) { + each(parent.childNodes, function (_, node) { + if (isEmpty(node)) { + emptyNodes.push(node); + } + }); + + first = input.firstChild; + last = input.lastChild; + } + + range.deleteContents(); + + // FF allows <br /> to be selected but inserting a node + // into <br /> will cause it not to be displayed so must + // insert before the <br /> in FF. + // 3 = TextNode + if (parent && parent.nodeType !== 3 && !canHaveChildren(parent)) { + insertBefore(input, parent); + } else { + range.insertNode(input); + + // If a node was split or its contents deleted, remove any resulting + // empty tags. For example: + // <p>|test</p><div>test|</div> + // When deleteContents could become: + // <p></p>|<div></div> + // So remove the empty ones + removeIfEmpty(first && first.previousSibling); + removeIfEmpty(last && last.nextSibling); + } + + base.restoreRange(); + }; + + /** + * Clones the selected Range + * + * @return {Range} + * @function + * @name cloneSelected + * @memberOf RangeHelper.prototype + */ + base.cloneSelected = function () { + var range = base.selectedRange(); + + if (range) { + return range.cloneRange(); + } + }; + + /** + * Gets the selected Range + * + * @return {Range} + * @function + * @name selectedRange + * @memberOf RangeHelper.prototype + */ + base.selectedRange = function () { + var range, firstChild, + sel = win.getSelection(); + + if (!sel) { + return; + } + + // When creating a new range, set the start to the first child + // element of the body element to avoid errors in FF. + if (sel.rangeCount <= 0) { + firstChild = doc.body; + while (firstChild.firstChild) { + firstChild = firstChild.firstChild; + } + + range = doc.createRange(); + // Must be setStartBefore otherwise it can cause infinite + // loops with lists in WebKit. See issue 442 + range.setStartBefore(firstChild); + + sel.addRange(range); + } + + if (sel.rangeCount > 0) { + range = sel.getRangeAt(0); + } + + return range; + }; + + /** + * Gets if there is currently a selection + * + * @return {boolean} + * @function + * @name hasSelection + * @since 1.4.4 + * @memberOf RangeHelper.prototype + */ + base.hasSelection = function () { + var sel = win.getSelection(); + + return sel && sel.rangeCount > 0; + }; + + /** + * Gets the currently selected HTML + * + * @return {string} + * @function + * @name selectedHtml + * @memberOf RangeHelper.prototype + */ + base.selectedHtml = function () { + var div, + range = base.selectedRange(); + + if (range) { + div = createElement('p', {}, doc); + appendChild(div, range.cloneContents()); + + return div.innerHTML; + } + + return ''; + }; + + /** + * Gets the parent node of the selected contents in the range + * + * @return {HTMLElement} + * @function + * @name parentNode + * @memberOf RangeHelper.prototype + */ + base.parentNode = function () { + var range = base.selectedRange(); + + if (range) { + return range.commonAncestorContainer; + } + }; + + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @return {HTMLElement} + * @function + * @name getFirstBlockParent + * @memberOf RangeHelper.prototype + */ + /** + * Gets the first block level parent of the selected + * contents of the range. + * + * @param {Node} [n] The element to get the first block level parent from + * @return {HTMLElement} + * @function + * @name getFirstBlockParent^2 + * @since 1.4.1 + * @memberOf RangeHelper.prototype + */ + base.getFirstBlockParent = function (node) { + var func = function (elm) { + if (!isInline(elm, true)) { + return elm; + } + + elm = elm ? elm.parentNode : null; + + return elm ? func(elm) : elm; + }; + + return func(node || base.parentNode()); + }; + + /** + * Inserts a node at either the start or end of the current selection + * + * @param {Bool} start + * @param {Node} node + * @function + * @name insertNodeAt + * @memberOf RangeHelper.prototype + */ + base.insertNodeAt = function (start, node) { + var currentRange = base.selectedRange(), + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(start); + range.insertNode(node); + + // Reselect the current range. + // Fixes issue with Chrome losing the selection. Issue#82 + base.selectRange(currentRange); + }; + + /** + * Creates a marker node + * + * @param {string} id + * @return {HTMLSpanElement} + * @private + */ + _createMarker = function (id) { + base.removeMarker(id); + + var marker = createElement('span', { + id: id, + className: 'sceditor-selection sceditor-ignore', + style: 'display:none;line-height:0' + }, doc); + + marker.innerHTML = ' '; + + return marker; + }; + + /** + * Inserts start/end markers for the current selection + * which can be used by restoreRange to re-select the + * range. + * + * @memberOf RangeHelper.prototype + * @function + * @name insertMarkers + */ + base.insertMarkers = function () { + var currentRange = base.selectedRange(); + var startNode = _createMarker(startMarker); + + base.removeMarkers(); + base.insertNodeAt(true, startNode); + + // Fixes issue with end marker sometimes being placed before + // the start marker when the range is collapsed. + if (currentRange && currentRange.collapsed) { + startNode.parentNode.insertBefore( + _createMarker(endMarker), startNode.nextSibling); + } else { + base.insertNodeAt(false, _createMarker(endMarker)); + } + }; + + /** + * Gets the marker with the specified ID + * + * @param {string} id + * @return {Node} + * @function + * @name getMarker + * @memberOf RangeHelper.prototype + */ + base.getMarker = function (id) { + return doc.getElementById(id); + }; + + /** + * Removes the marker with the specified ID + * + * @param {string} id + * @function + * @name removeMarker + * @memberOf RangeHelper.prototype + */ + base.removeMarker = function (id) { + var marker = base.getMarker(id); + + if (marker) { + remove(marker); + } + }; + + /** + * Removes the start/end markers + * + * @function + * @name removeMarkers + * @memberOf RangeHelper.prototype + */ + base.removeMarkers = function () { + base.removeMarker(startMarker); + base.removeMarker(endMarker); + }; + + /** + * Saves the current range location. Alias of insertMarkers() + * + * @function + * @name saveRage + * @memberOf RangeHelper.prototype + */ + base.saveRange = function () { + base.insertMarkers(); + }; + + /** + * Select the specified range + * + * @param {Range} range + * @function + * @name selectRange + * @memberOf RangeHelper.prototype + */ + base.selectRange = function (range) { + var lastChild; + var sel = win.getSelection(); + var container = range.endContainer; + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (range.collapsed && container && + !isInline(container, true)) { + + lastChild = container.lastChild; + while (lastChild && is(lastChild, '.sceditor-ignore')) { + lastChild = lastChild.previousSibling; + } + + if (is(lastChild, 'br')) { + var rng = doc.createRange(); + rng.setEndAfter(lastChild); + rng.collapse(false); + + if (base.compare(range, rng)) { + range.setStartBefore(lastChild); + range.collapse(true); + } + } + } + + if (sel) { + base.clear(); + sel.addRange(range); + } + }; + + /** + * Restores the last range saved by saveRange() or insertMarkers() + * + * @function + * @name restoreRange + * @memberOf RangeHelper.prototype + */ + base.restoreRange = function () { + var isCollapsed, + range = base.selectedRange(), + start = base.getMarker(startMarker), + end = base.getMarker(endMarker); + + if (!start || !end || !range) { + return false; + } + + isCollapsed = start.nextSibling === end; + + range = doc.createRange(); + range.setStartBefore(start); + range.setEndAfter(end); + + if (isCollapsed) { + range.collapse(true); + } + + base.selectRange(range); + base.removeMarkers(); + }; + + /** + * Selects the text left and right of the current selection + * + * @param {number} left + * @param {number} right + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.selectOuterText = function (left, right) { + var start, end, + range = base.cloneSelected(); + + if (!range) { + return false; + } + + range.collapse(false); + + start = outerText(range, true, left); + end = outerText(range, false, right); + + range.setStart(start.node, start.offset); + range.setEnd(end.node, end.offset); + + base.selectRange(range); + }; + + /** + * Gets the text left or right of the current selection + * + * @param {boolean} before + * @param {number} length + * @return {string} + * @since 1.4.3 + * @function + * @name selectOuterText + * @memberOf RangeHelper.prototype + */ + base.getOuterText = function (before, length) { + var range = base.cloneSelected(); + + if (!range) { + return ''; + } + + range.collapse(!before); + + return outerText(range, before, length).text; + }; + + /** + * Replaces keywords with values based on the current caret position + * + * @param {Array} keywords + * @param {boolean} includeAfter If to include the text after the + * current caret position or just + * text before + * @param {boolean} keywordsSorted If the keywords array is pre + * sorted shortest to longest + * @param {number} longestKeyword Length of the longest keyword + * @param {boolean} requireWhitespace If the key must be surrounded + * by whitespace + * @param {string} keypressChar If this is being called from + * a keypress event, this should be + * set to the pressed character + * @return {boolean} + * @function + * @name replaceKeyword + * @memberOf RangeHelper.prototype + */ + // eslint-disable-next-line max-params + base.replaceKeyword = function ( + keywords, + includeAfter, + keywordsSorted, + longestKeyword, + requireWhitespace, + keypressChar + ) { + if (!keywordsSorted) { + keywords.sort(function (a, b) { + return a[0].length - b[0].length; + }); + } + + var outerText, match, matchPos, startIndex, + leftLen, charsLeft, keyword, keywordLen, + whitespaceRegex = '(^|[\\s\xA0\u2002\u2003\u2009])', + keywordIdx = keywords.length, + whitespaceLen = requireWhitespace ? 1 : 0, + maxKeyLen = longestKeyword || + keywords[keywordIdx - 1][0].length; + + if (requireWhitespace) { + maxKeyLen++; + } + + keypressChar = keypressChar || ''; + outerText = base.getOuterText(true, maxKeyLen); + leftLen = outerText.length; + outerText += keypressChar; + + if (includeAfter) { + outerText += base.getOuterText(false, maxKeyLen); + } + + while (keywordIdx--) { + keyword = keywords[keywordIdx][0]; + keywordLen = keyword.length; + startIndex = Math.max(0, leftLen - keywordLen - whitespaceLen); + matchPos = -1; + + if (requireWhitespace) { + match = outerText + .substr(startIndex) + .match(new RegExp(whitespaceRegex + + regex(keyword) + whitespaceRegex)); + + if (match) { + // Add the length of the text that was removed by + // substr() and also add 1 for the whitespace + matchPos = match.index + startIndex + match[1].length; + } + } else { + matchPos = outerText.indexOf(keyword, startIndex); + } + + if (matchPos > -1) { + // Make sure the match is between before and + // after, not just entirely in one side or the other + if (matchPos <= leftLen && + matchPos + keywordLen + whitespaceLen >= leftLen) { + charsLeft = leftLen - matchPos; + + // If the keypress char is white space then it should + // not be replaced, only chars that are part of the + // key should be replaced. + base.selectOuterText( + charsLeft, + keywordLen - charsLeft - + (/^\S/.test(keypressChar) ? 1 : 0) + ); + + base.insertHTML(keywords[keywordIdx][1]); + return true; + } + } + } + + return false; + }; + + /** + * Compares two ranges. + * + * If rangeB is undefined it will be set to + * the current selected range + * + * @param {Range} rngA + * @param {Range} [rngB] + * @return {boolean} + * @function + * @name compare + * @memberOf RangeHelper.prototype + */ + base.compare = function (rngA, rngB) { + if (!rngB) { + rngB = base.selectedRange(); + } + + if (!rngA || !rngB) { + return !rngA && !rngB; + } + + return rngA.compareBoundaryPoints(Range.END_TO_END, rngB) === 0 && + rngA.compareBoundaryPoints(Range.START_TO_START, rngB) === 0; + }; + + /** + * Removes any current selection + * + * @since 1.4.6 + * @function + * @name clear + * @memberOf RangeHelper.prototype + */ + base.clear = function () { + var sel = win.getSelection(); + + if (sel) { + if (sel.removeAllRanges) { + sel.removeAllRanges(); + } else if (sel.empty) { + sel.empty(); + } + } + }; + } + + var USER_AGENT = navigator.userAgent; + + /** + * Detects if the browser is iOS + * + * Needed to fix iOS specific bugs + * + * @function + * @name ios + * @memberOf jQuery.sceditor + * @type {boolean} + */ + var ios = /iPhone|iPod|iPad| wosbrowser\//i.test(USER_AGENT); + + /** + * If the browser supports WYSIWYG editing (e.g. older mobile browsers). + * + * @function + * @name isWysiwygSupported + * @return {boolean} + */ + var isWysiwygSupported = (function () { + var match, isUnsupported; + + // IE is the only browser to support documentMode + var ie = !!window.document.documentMode; + var legacyEdge = '-ms-ime-align' in document.documentElement.style; + + var div = document.createElement('div'); + div.contentEditable = true; + + // Check if the contentEditable attribute is supported + if (!('contentEditable' in document.documentElement) || + div.contentEditable !== 'true') { + return false; + } + + // I think blackberry supports contentEditable or will at least + // give a valid value for the contentEditable detection above + // so it isn't included in the below tests. + + // I hate having to do UA sniffing but some mobile browsers say they + // support contentediable when it isn't usable, i.e. you can't enter + // text. + // This is the only way I can think of to detect them which is also how + // every other editor I've seen deals with this issue. + + // Exclude Opera mobile and mini + isUnsupported = /Opera Mobi|Opera Mini/i.test(USER_AGENT); + + if (/Android/i.test(USER_AGENT)) { + isUnsupported = true; + + if (/Safari/.test(USER_AGENT)) { + // Android browser 534+ supports content editable + // This also matches Chrome which supports content editable too + match = /Safari\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + } + + // The current version of Amazon Silk supports it, older versions didn't + // As it uses webkit like Android, assume it's the same and started + // working at versions >= 534 + if (/ Silk\//i.test(USER_AGENT)) { + match = /AppleWebKit\/(\d+)/.exec(USER_AGENT); + isUnsupported = (!match || !match[1] ? true : match[1] < 534); + } + + // iOS 5+ supports content editable + if (ios) { + // Block any version <= 4_x(_x) + isUnsupported = /OS [0-4](_\d)+ like Mac/i.test(USER_AGENT); + } + + // Firefox does support WYSIWYG on mobiles so override + // any previous value if using FF + if (/Firefox/i.test(USER_AGENT)) { + isUnsupported = false; + } + + if (/OneBrowser/i.test(USER_AGENT)) { + isUnsupported = false; + } + + // UCBrowser works but doesn't give a unique user agent + if (navigator.vendor === 'UCWEB') { + isUnsupported = false; + } + + // IE and legacy edge are not supported any more + if (ie || legacyEdge) { + isUnsupported = true; + } + + return !isUnsupported; + }()); + + /** + * Checks all emoticons are surrounded by whitespace and + * replaces any that aren't with with their emoticon code. + * + * @param {HTMLElement} node + * @param {rangeHelper} rangeHelper + * @return {void} + */ + function checkWhitespace(node, rangeHelper) { + var noneWsRegex = /[^\s\xA0\u2002\u2003\u2009]+/; + var emoticons = node && find(node, 'img[data-sceditor-emoticon]'); + + if (!node || !emoticons.length) { + return; + } + + for (var i = 0; i < emoticons.length; i++) { + var emoticon = emoticons[i]; + var parent = emoticon.parentNode; + var prev = emoticon.previousSibling; + var next = emoticon.nextSibling; + + if ((!prev || !noneWsRegex.test(prev.nodeValue.slice(-1))) && + (!next || !noneWsRegex.test((next.nodeValue || '')[0]))) { + continue; + } + + var range = rangeHelper.cloneSelected(); + var rangeStart = -1; + var rangeStartContainer = range.startContainer; + var previousText = prev.nodeValue || ''; + + previousText += data(emoticon, 'sceditor-emoticon'); + + // If the cursor is after the removed emoticon, add + // the length of the newly added text to it + if (rangeStartContainer === next) { + rangeStart = previousText.length + range.startOffset; + } + + // If the cursor is set before the next node, set it to + // the end of the new text node + if (rangeStartContainer === node && + node.childNodes[range.startOffset] === next) { + rangeStart = previousText.length; + } + + // If the cursor is set before the removed emoticon, + // just keep it at that position + if (rangeStartContainer === prev) { + rangeStart = range.startOffset; + } + + if (!next || next.nodeType !== TEXT_NODE) { + next = parent.insertBefore( + parent.ownerDocument.createTextNode(''), next + ); + } + + next.insertData(0, previousText); + remove(prev); + remove(emoticon); + + // Need to update the range starting position if it's been modified + if (rangeStart > -1) { + range.setStart(next, rangeStart); + range.collapse(true); + rangeHelper.selectRange(range); + } + } + } + /** + * Replaces any emoticons inside the root node with images. + * + * emoticons should be an object where the key is the emoticon + * code and the value is the HTML to replace it with. + * + * @param {HTMLElement} root + * @param {Object<string, string>} emoticons + * @param {boolean} emoticonsCompat + * @return {void} + */ + function replace(root, emoticons, emoticonsCompat) { + var doc = root.ownerDocument; + var space = '(^|\\s|\xA0|\u2002|\u2003|\u2009|$)'; + var emoticonCodes = []; + var emoticonRegex = {}; + + // TODO: Make this tag configurable. + if (parent(root, 'code')) { + return; + } + + each(emoticons, function (key) { + emoticonRegex[key] = new RegExp(space + regex(key) + space); + emoticonCodes.push(key); + }); + + // Sort keys longest to shortest so that longer keys + // take precedence (avoids bugs with shorter keys partially + // matching longer ones) + emoticonCodes.sort(function (a, b) { + return b.length - a.length; + }); + + (function convert(node) { + node = node.firstChild; + + while (node) { + // TODO: Make this tag configurable. + if (node.nodeType === ELEMENT_NODE && !is(node, 'code')) { + convert(node); + } + + if (node.nodeType === TEXT_NODE) { + for (var i = 0; i < emoticonCodes.length; i++) { + var text = node.nodeValue; + var key = emoticonCodes[i]; + var index = emoticonsCompat ? + text.search(emoticonRegex[key]) : + text.indexOf(key); + + if (index > -1) { + // When emoticonsCompat is enabled this will be the + // position after any white space + var startIndex = text.indexOf(key, index); + var fragment = parseHTML(emoticons[key], doc); + var after = text.substr(startIndex + key.length); + + fragment.appendChild(doc.createTextNode(after)); + + node.nodeValue = text.substr(0, startIndex); + node.parentNode + .insertBefore(fragment, node.nextSibling); + } + } + } + + node = node.nextSibling; + } + }(root)); + } + + /*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */ + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var hasOwnProperty = Object.hasOwnProperty, + setPrototypeOf = Object.setPrototypeOf, + isFrozen = Object.isFrozen, + getPrototypeOf = Object.getPrototypeOf, + getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var freeze = Object.freeze, + seal = Object.seal, + create = Object.create; // eslint-disable-line import/no-mutable-exports + + var _ref = typeof Reflect !== 'undefined' && Reflect, + apply = _ref.apply, + construct = _ref.construct; + + if (!apply) { + apply = function apply(fun, thisValue, args) { + return fun.apply(thisValue, args); + }; + } + + if (!freeze) { + freeze = function freeze(x) { + return x; + }; + } + + if (!seal) { + seal = function seal(x) { + return x; + }; + } + + if (!construct) { + construct = function construct(Func, args) { + return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))(); + }; + } + + var arrayForEach = unapply(Array.prototype.forEach); + var arrayPop = unapply(Array.prototype.pop); + var arrayPush = unapply(Array.prototype.push); + + var stringToLowerCase = unapply(String.prototype.toLowerCase); + var stringMatch = unapply(String.prototype.match); + var stringReplace = unapply(String.prototype.replace); + var stringIndexOf = unapply(String.prototype.indexOf); + var stringTrim = unapply(String.prototype.trim); + + var regExpTest = unapply(RegExp.prototype.test); + + var typeErrorCreate = unconstruct(TypeError); + + function unapply(func) { + return function (thisArg) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return apply(func, thisArg, args); + }; + } + + function unconstruct(func) { + return function () { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return construct(func, args); + }; + } + + /* Add properties to a lookup table */ + function addToSet(set, array) { + if (setPrototypeOf) { + // Make 'in' and truthy checks like Boolean(set.constructor) + // independent of any properties defined on Object.prototype. + // Prevent prototype setters from intercepting set as a this value. + setPrototypeOf(set, null); + } + + var l = array.length; + while (l--) { + var element = array[l]; + if (typeof element === 'string') { + var lcElement = stringToLowerCase(element); + if (lcElement !== element) { + // Config presets (e.g. tags.js, attrs.js) are immutable. + if (!isFrozen(array)) { + array[l] = lcElement; + } + + element = lcElement; + } + } + + set[element] = true; + } + + return set; + } + + /* Shallow clone an object */ + function clone(object) { + var newObject = create(null); + + var property = void 0; + for (property in object) { + if (apply(hasOwnProperty, object, [property])) { + newObject[property] = object[property]; + } + } + + return newObject; + } + + /* IE10 doesn't support __lookupGetter__ so lets' + * simulate it. It also automatically checks + * if the prop is function or getter and behaves + * accordingly. */ + function lookupGetter(object, prop) { + while (object !== null) { + var desc = getOwnPropertyDescriptor(object, prop); + if (desc) { + if (desc.get) { + return unapply(desc.get); + } + + if (typeof desc.value === 'function') { + return unapply(desc.value); + } + } + + object = getPrototypeOf(object); + } + + return null; + } + + var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); + + // SVG + var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); + + var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); + + // List of SVG elements that are disallowed by default. + // We still need to know them so that we can do namespace + // checks properly in case one wants to add them to + // allow-list. + var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); + + var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']); + + // Similarly to SVG, we want to know all MathML elements, + // even those that we disallow by default. + var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); + + var text = freeze(['#text']); + + var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns']); + + var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); + + var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); + + var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); + + // eslint-disable-next-line unicorn/better-regex + var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode + var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm); + var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape + var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape + var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape + ); + var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); + var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex + ); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var getGlobal = function getGlobal() { + return typeof window === 'undefined' ? null : window; + }; + + /** + * Creates a no-op policy for internal use only. + * Don't export this function outside this module! + * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory. + * @param {Document} document The document object (to determine policy name suffix) + * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types + * are not supported). + */ + var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) { + if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') { + return null; + } + + // Allow the callers to control the unique policy name + // by adding a data-tt-policy-suffix to the script element with the DOMPurify. + // Policy creation with duplicate names throws in Trusted Types. + var suffix = null; + var ATTR_NAME = 'data-tt-policy-suffix'; + if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) { + suffix = document.currentScript.getAttribute(ATTR_NAME); + } + + var policyName = 'dompurify' + (suffix ? '#' + suffix : ''); + + try { + return trustedTypes.createPolicy(policyName, { + createHTML: function createHTML(html$$1) { + return html$$1; + } + }); + } catch (_) { + // Policy creation failed (most likely another DOMPurify script has + // already run). Skip creating the policy, as this will only cause errors + // if TT are enforced. + console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); + return null; + } + }; + + function createDOMPurify() { + var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); + + var DOMPurify = function DOMPurify(root) { + return createDOMPurify(root); + }; + + /** + * Version label, exposed for easier checks + * if DOMPurify is up to date or not + */ + DOMPurify.version = '2.2.6'; + + /** + * Array of elements that DOMPurify removed during sanitation. + * Empty if nothing was removed. + */ + DOMPurify.removed = []; + + if (!window || !window.document || window.document.nodeType !== 9) { + // Not running in a browser, provide a factory function + // so that you can pass your own Window + DOMPurify.isSupported = false; + + return DOMPurify; + } + + var originalDocument = window.document; + + var document = window.document; + var DocumentFragment = window.DocumentFragment, + HTMLTemplateElement = window.HTMLTemplateElement, + Node = window.Node, + Element = window.Element, + NodeFilter = window.NodeFilter, + _window$NamedNodeMap = window.NamedNodeMap, + NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, + Text = window.Text, + Comment = window.Comment, + DOMParser = window.DOMParser, + trustedTypes = window.trustedTypes; + + + var ElementPrototype = Element.prototype; + + var cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); + var getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); + var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); + + // As per issue #47, the web-components registry is inherited by a + // new document created via createHTMLDocument. As per the spec + // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) + // a new empty registry is used when creating a template contents owner + // document, so we use that as our parent document to ensure nothing + // is inherited. + if (typeof HTMLTemplateElement === 'function') { + var template = document.createElement('template'); + if (template.content && template.content.ownerDocument) { + document = template.content.ownerDocument; + } + } + + var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); + var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : ''; + + var _document = document, + implementation = _document.implementation, + createNodeIterator = _document.createNodeIterator, + getElementsByTagName = _document.getElementsByTagName, + createDocumentFragment = _document.createDocumentFragment; + var importNode = originalDocument.importNode; + + + var documentMode = {}; + try { + documentMode = clone(document).documentMode ? document.documentMode : {}; + } catch (_) {} + + var hooks = {}; + + /** + * Expose whether this browser supports running the full DOMPurify. + */ + DOMPurify.isSupported = implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9; + + var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR, + ERB_EXPR$$1 = ERB_EXPR, + DATA_ATTR$$1 = DATA_ATTR, + ARIA_ATTR$$1 = ARIA_ATTR, + IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE$$1 = ATTR_WHITESPACE; + var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI; + + /** + * We consider the elements and attributes below to be safe. Ideally + * don't add any new ones but feel free to remove unwanted ones. + */ + + /* allowed element names */ + + var ALLOWED_TAGS = null; + var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text))); + + /* Allowed attribute names */ + var ALLOWED_ATTR = null; + var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml))); + + /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ + var FORBID_TAGS = null; + + /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ + var FORBID_ATTR = null; + + /* Decide if ARIA attributes are okay */ + var ALLOW_ARIA_ATTR = true; + + /* Decide if custom data attributes are okay */ + var ALLOW_DATA_ATTR = true; + + /* Decide if unknown protocols are okay */ + var ALLOW_UNKNOWN_PROTOCOLS = false; + + /* Output should be safe for common template engines. + * This means, DOMPurify removes data attributes, mustaches and ERB + */ + var SAFE_FOR_TEMPLATES = false; + + /* Decide if document with <html>... should be returned */ + var WHOLE_DOCUMENT = false; + + /* Track whether config is already set on this instance of DOMPurify. */ + var SET_CONFIG = false; + + /* Decide if all elements (e.g. style, script) must be children of + * document.body. By default, browsers might move them to document.head */ + var FORCE_BODY = false; + + /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported). + * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead + */ + var RETURN_DOM = false; + + /* Decide if a DOM `DocumentFragment` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported) */ + var RETURN_DOM_FRAGMENT = false; + + /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM + * `Node` is imported into the current `Document`. If this flag is not enabled the + * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by + * DOMPurify. + * + * This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false` + * might cause XSS from attacks hidden in closed shadowroots in case the browser + * supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/ + */ + var RETURN_DOM_IMPORT = true; + + /* Try to return a Trusted Type object instead of a string, return a string in + * case Trusted Types are not supported */ + var RETURN_TRUSTED_TYPE = false; + + /* Output should be free from DOM clobbering attacks? */ + var SANITIZE_DOM = true; + + /* Keep element content when removing element? */ + var KEEP_CONTENT = true; + + /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead + * of importing it into a new Document and returning a sanitized copy */ + var IN_PLACE = false; + + /* Allow usage of profiles like html, svg and mathMl */ + var USE_PROFILES = {}; + + /* Tags to ignore content of when KEEP_CONTENT is true */ + var FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); + + /* Tags that are safe for data: URIs */ + var DATA_URI_TAGS = null; + var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); + + /* Attributes safe for values like "javascript:" */ + var URI_SAFE_ATTRIBUTES = null; + var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'summary', 'title', 'value', 'style', 'xmlns']); + + /* Keep a reference to config to pass to hooks */ + var CONFIG = null; + + /* Ideally, do not touch anything below this line */ + /* ______________________________________________ */ + + var formElement = document.createElement('form'); + + /** + * _parseConfig + * + * @param {Object} cfg optional config literal + */ + // eslint-disable-next-line complexity + var _parseConfig = function _parseConfig(cfg) { + if (CONFIG && CONFIG === cfg) { + return; + } + + /* Shield configuration object from tampering */ + if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') { + cfg = {}; + } + + /* Shield configuration object from prototype pollution */ + cfg = clone(cfg); + + /* Set configuration parameters */ + ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS; + ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR; + URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES; + DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS; + FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {}; + FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {}; + USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false; + ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true + ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true + ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false + SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false + WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false + RETURN_DOM = cfg.RETURN_DOM || false; // Default false + RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false + RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true + RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false + FORCE_BODY = cfg.FORCE_BODY || false; // Default false + SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true + KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true + IN_PLACE = cfg.IN_PLACE || false; // Default false + IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1; + if (SAFE_FOR_TEMPLATES) { + ALLOW_DATA_ATTR = false; + } + + if (RETURN_DOM_FRAGMENT) { + RETURN_DOM = true; + } + + /* Parse profile info */ + if (USE_PROFILES) { + ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text))); + ALLOWED_ATTR = []; + if (USE_PROFILES.html === true) { + addToSet(ALLOWED_TAGS, html); + addToSet(ALLOWED_ATTR, html$1); + } + + if (USE_PROFILES.svg === true) { + addToSet(ALLOWED_TAGS, svg); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.svgFilters === true) { + addToSet(ALLOWED_TAGS, svgFilters); + addToSet(ALLOWED_ATTR, svg$1); + addToSet(ALLOWED_ATTR, xml); + } + + if (USE_PROFILES.mathMl === true) { + addToSet(ALLOWED_TAGS, mathMl); + addToSet(ALLOWED_ATTR, mathMl$1); + addToSet(ALLOWED_ATTR, xml); + } + } + + /* Merge configuration parameters */ + if (cfg.ADD_TAGS) { + if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { + ALLOWED_TAGS = clone(ALLOWED_TAGS); + } + + addToSet(ALLOWED_TAGS, cfg.ADD_TAGS); + } + + if (cfg.ADD_ATTR) { + if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { + ALLOWED_ATTR = clone(ALLOWED_ATTR); + } + + addToSet(ALLOWED_ATTR, cfg.ADD_ATTR); + } + + if (cfg.ADD_URI_SAFE_ATTR) { + addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR); + } + + /* Add #text in case KEEP_CONTENT is set to true */ + if (KEEP_CONTENT) { + ALLOWED_TAGS['#text'] = true; + } + + /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ + if (WHOLE_DOCUMENT) { + addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); + } + + /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ + if (ALLOWED_TAGS.table) { + addToSet(ALLOWED_TAGS, ['tbody']); + delete FORBID_TAGS.tbody; + } + + // Prevent further manipulation of configuration. + // Not available in IE8, Safari 5, etc. + if (freeze) { + freeze(cfg); + } + + CONFIG = cfg; + }; + + var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); + + var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); + + /* Keep track of all possible SVG and MathML tags + * so that we can perform the namespace checks + * correctly. */ + var ALL_SVG_TAGS = addToSet({}, svg); + addToSet(ALL_SVG_TAGS, svgFilters); + addToSet(ALL_SVG_TAGS, svgDisallowed); + + var ALL_MATHML_TAGS = addToSet({}, mathMl); + addToSet(ALL_MATHML_TAGS, mathMlDisallowed); + + var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + + /** + * + * + * @param {Element} element a DOM element whose namespace is being checked + * @returns {boolean} Return false if the element has a + * namespace that a spec-compliant parser would never + * return. Return true otherwise. + */ + var _checkValidNamespace = function _checkValidNamespace(element) { + var parent = getParentNode(element); + + // In JSDOM, if we're inside shadow DOM, then parentNode + // can be null. We just simulate parent in this case. + if (!parent || !parent.tagName) { + parent = { + namespaceURI: HTML_NAMESPACE, + tagName: 'template' + }; + } + + var tagName = stringToLowerCase(element.tagName); + var parentTagName = stringToLowerCase(parent.tagName); + + if (element.namespaceURI === SVG_NAMESPACE) { + // The only way to switch from HTML namespace to SVG + // is via <svg>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'svg'; + } + + // The only way to switch from MathML to SVG is via + // svg if parent is either <annotation-xml> or MathML + // text integration points. + if (parent.namespaceURI === MATHML_NAMESPACE) { + return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); + } + + // We only allow elements that are defined in SVG + // spec. All others are disallowed in SVG namespace. + return Boolean(ALL_SVG_TAGS[tagName]); + } + + if (element.namespaceURI === MATHML_NAMESPACE) { + // The only way to switch from HTML namespace to MathML + // is via <math>. If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'math'; + } + + // The only way to switch from SVG to MathML is via + // <math> and HTML integration points + if (parent.namespaceURI === SVG_NAMESPACE) { + return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; + } + + // We only allow elements that are defined in MathML + // spec. All others are disallowed in MathML namespace. + return Boolean(ALL_MATHML_TAGS[tagName]); + } + + if (element.namespaceURI === HTML_NAMESPACE) { + // The only way to switch from SVG to HTML is via + // HTML integration points, and from MathML to HTML + // is via MathML text integration points + if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + // Certain elements are allowed in both SVG and HTML + // namespace. We need to specify them explicitly + // so that they don't get erronously deleted from + // HTML namespace. + var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']); + + // We disallow tags that are specific for MathML + // or SVG and should never appear in HTML namespace + return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]); + } + + // The code should never reach this place (this means + // that the element somehow got namespace that is not + // HTML, SVG or MathML). Return false just in case. + return false; + }; + + /** + * _forceRemove + * + * @param {Node} node a DOM node + */ + var _forceRemove = function _forceRemove(node) { + arrayPush(DOMPurify.removed, { element: node }); + try { + node.parentNode.removeChild(node); + } catch (_) { + try { + node.outerHTML = emptyHTML; + } catch (_) { + node.remove(); + } + } + }; + + /** + * _removeAttribute + * + * @param {String} name an Attribute name + * @param {Node} node a DOM node + */ + var _removeAttribute = function _removeAttribute(name, node) { + try { + arrayPush(DOMPurify.removed, { + attribute: node.getAttributeNode(name), + from: node + }); + } catch (_) { + arrayPush(DOMPurify.removed, { + attribute: null, + from: node + }); + } + + node.removeAttribute(name); + }; + + /** + * _initDocument + * + * @param {String} dirty a string of dirty markup + * @return {Document} a DOM, filled with the dirty markup + */ + var _initDocument = function _initDocument(dirty) { + /* Create a HTML document */ + var doc = void 0; + var leadingWhitespace = void 0; + + if (FORCE_BODY) { + dirty = '<remove></remove>' + dirty; + } else { + /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ + var matches = stringMatch(dirty, /^[\r\n\t ]+/); + leadingWhitespace = matches && matches[0]; + } + + var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; + /* Use the DOMParser API by default, fallback later if needs be */ + try { + doc = new DOMParser().parseFromString(dirtyPayload, 'text/html'); + } catch (_) {} + + /* Use createHTMLDocument in case DOMParser is not available */ + if (!doc || !doc.documentElement) { + doc = implementation.createHTMLDocument(''); + var _doc = doc, + body = _doc.body; + + body.parentNode.removeChild(body.parentNode.firstElementChild); + body.outerHTML = dirtyPayload; + } + + if (dirty && leadingWhitespace) { + doc.body.insertBefore(document.createTextNode(leadingWhitespace), doc.body.childNodes[0] || null); + } + + /* Work on whole document or just its body */ + return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; + }; + + /** + * _createIterator + * + * @param {Document} root document/fragment to create iterator for + * @return {Iterator} iterator instance + */ + var _createIterator = function _createIterator(root) { + return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, function () { + return NodeFilter.FILTER_ACCEPT; + }, false); + }; + + /** + * _isClobbered + * + * @param {Node} elm element to check for clobbering attacks + * @return {Boolean} true if clobbered, false if safe + */ + var _isClobbered = function _isClobbered(elm) { + if (elm instanceof Text || elm instanceof Comment) { + return false; + } + + if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') { + return true; + } + + return false; + }; + + /** + * _isNode + * + * @param {Node} obj object to check whether it's a DOM node + * @return {Boolean} true is object is a DOM node + */ + var _isNode = function _isNode(object) { + return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'; + }; + + /** + * _executeHook + * Execute user configurable hooks + * + * @param {String} entryPoint Name of the hook's entry point + * @param {Node} currentNode node to work on with the hook + * @param {Object} data additional hook parameters + */ + var _executeHook = function _executeHook(entryPoint, currentNode, data) { + if (!hooks[entryPoint]) { + return; + } + + arrayForEach(hooks[entryPoint], function (hook) { + hook.call(DOMPurify, currentNode, data, CONFIG); + }); + }; + + /** + * _sanitizeElements + * + * @protect nodeName + * @protect textContent + * @protect removeChild + * + * @param {Node} currentNode to check for permission to exist + * @return {Boolean} true if node was killed, false if left alive + */ + var _sanitizeElements = function _sanitizeElements(currentNode) { + var content = void 0; + + /* Execute a hook if present */ + _executeHook('beforeSanitizeElements', currentNode, null); + + /* Check if element is clobbered or can clobber */ + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Check if tagname contains Unicode */ + if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) { + _forceRemove(currentNode); + return true; + } + + /* Now let's check the element's type and name */ + var tagName = stringToLowerCase(currentNode.nodeName); + + /* Execute a hook if present */ + _executeHook('uponSanitizeElement', currentNode, { + tagName: tagName, + allowedTags: ALLOWED_TAGS + }); + + /* Detect mXSS attempts abusing namespace confusion */ + if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { + _forceRemove(currentNode); + return true; + } + + /* Remove element if anything forbids its presence */ + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + /* Keep content except for bad-listed elements */ + if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { + var parentNode = getParentNode(currentNode); + var childNodes = getChildNodes(currentNode); + var childCount = childNodes.length; + for (var i = childCount - 1; i >= 0; --i) { + parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode)); + } + } + + _forceRemove(currentNode); + return true; + } + + /* Check whether element has a valid namespace */ + if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { + _forceRemove(currentNode); + return true; + } + + if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) { + _forceRemove(currentNode); + return true; + } + + /* Sanitize element content to be template-safe */ + if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { + /* Get the element's text content */ + content = currentNode.textContent; + content = stringReplace(content, MUSTACHE_EXPR$$1, ' '); + content = stringReplace(content, ERB_EXPR$$1, ' '); + if (currentNode.textContent !== content) { + arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); + currentNode.textContent = content; + } + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeElements', currentNode, null); + + return false; + }; + + /** + * _isValidAttribute + * + * @param {string} lcTag Lowercase tag name of containing element. + * @param {string} lcName Lowercase attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid, otherwise false. + */ + // eslint-disable-next-line complexity + var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { + /* Make sure attribute cannot clobber */ + if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { + return false; + } + + /* Allow valid data-* attributes: At least one character after "-" + (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) + XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) + We don't need to check the value; it's always URI safe. */ + if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { + return false; + + /* Check value is safe. First, is attr inert? If so, is safe */ + } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else { + return false; + } + + return true; + }; + + /** + * _sanitizeAttributes + * + * @protect attributes + * @protect nodeName + * @protect removeAttribute + * @protect setAttribute + * + * @param {Node} currentNode to sanitize + */ + var _sanitizeAttributes = function _sanitizeAttributes(currentNode) { + var attr = void 0; + var value = void 0; + var lcName = void 0; + var l = void 0; + /* Execute a hook if present */ + _executeHook('beforeSanitizeAttributes', currentNode, null); + + var attributes = currentNode.attributes; + + /* Check if we have attributes; if not we might have a text node */ + + if (!attributes) { + return; + } + + var hookEvent = { + attrName: '', + attrValue: '', + keepAttr: true, + allowedAttributes: ALLOWED_ATTR + }; + l = attributes.length; + + /* Go backwards over all attributes; safely remove bad ones */ + while (l--) { + attr = attributes[l]; + var _attr = attr, + name = _attr.name, + namespaceURI = _attr.namespaceURI; + + value = stringTrim(attr.value); + lcName = stringToLowerCase(name); + + /* Execute a hook if present */ + hookEvent.attrName = lcName; + hookEvent.attrValue = value; + hookEvent.keepAttr = true; + hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set + _executeHook('uponSanitizeAttribute', currentNode, hookEvent); + value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ + if (hookEvent.forceKeepAttr) { + continue; + } + + /* Remove attribute */ + _removeAttribute(name, currentNode); + + /* Did the hooks approve of the attribute? */ + if (!hookEvent.keepAttr) { + continue; + } + + /* Work around a security issue in jQuery 3.0 */ + if (regExpTest(/\/>/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Sanitize attribute content to be template-safe */ + if (SAFE_FOR_TEMPLATES) { + value = stringReplace(value, MUSTACHE_EXPR$$1, ' '); + value = stringReplace(value, ERB_EXPR$$1, ' '); + } + + /* Is `value` valid for this attribute? */ + var lcTag = currentNode.nodeName.toLowerCase(); + if (!_isValidAttribute(lcTag, lcName, value)) { + continue; + } + + /* Handle invalid data-* attribute set by try-catching it */ + try { + if (namespaceURI) { + currentNode.setAttributeNS(namespaceURI, name, value); + } else { + /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ + currentNode.setAttribute(name, value); + } + + arrayPop(DOMPurify.removed); + } catch (_) {} + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeAttributes', currentNode, null); + }; + + /** + * _sanitizeShadowDOM + * + * @param {DocumentFragment} fragment to iterate over recursively + */ + var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { + var shadowNode = void 0; + var shadowIterator = _createIterator(fragment); + + /* Execute a hook if present */ + _executeHook('beforeSanitizeShadowDOM', fragment, null); + + while (shadowNode = shadowIterator.nextNode()) { + /* Execute a hook if present */ + _executeHook('uponSanitizeShadowNode', shadowNode, null); + + /* Sanitize tags and elements */ + if (_sanitizeElements(shadowNode)) { + continue; + } + + /* Deep shadow DOM detected */ + if (shadowNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(shadowNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(shadowNode); + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeShadowDOM', fragment, null); + }; + + /** + * Sanitize + * Public method providing core sanitation functionality + * + * @param {String|Node} dirty string or DOM node + * @param {Object} configuration object + */ + // eslint-disable-next-line complexity + DOMPurify.sanitize = function (dirty, cfg) { + var body = void 0; + var importedNode = void 0; + var currentNode = void 0; + var oldNode = void 0; + var returnNode = void 0; + /* Make sure we have a string to sanitize. + DO NOT return early, as this will return the wrong type if + the user has requested a DOM object rather than a string */ + if (!dirty) { + dirty = '<!-->'; + } + + /* Stringify, in case dirty is an object */ + if (typeof dirty !== 'string' && !_isNode(dirty)) { + // eslint-disable-next-line no-negated-condition + if (typeof dirty.toString !== 'function') { + throw typeErrorCreate('toString is not a function'); + } else { + dirty = dirty.toString(); + if (typeof dirty !== 'string') { + throw typeErrorCreate('dirty is not a string, aborting'); + } + } + } + + /* Check we can run. Otherwise fall back or ignore */ + if (!DOMPurify.isSupported) { + if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') { + if (typeof dirty === 'string') { + return window.toStaticHTML(dirty); + } + + if (_isNode(dirty)) { + return window.toStaticHTML(dirty.outerHTML); + } + } + + return dirty; + } + + /* Assign config vars */ + if (!SET_CONFIG) { + _parseConfig(cfg); + } + + /* Clean up removed elements */ + DOMPurify.removed = []; + + /* Check if dirty is correctly typed for IN_PLACE */ + if (typeof dirty === 'string') { + IN_PLACE = false; + } + + if (IN_PLACE) ; else if (dirty instanceof Node) { + /* If dirty is a DOM element, append to an empty document to avoid + elements being stripped by the parser */ + body = _initDocument('<!---->'); + importedNode = body.ownerDocument.importNode(dirty, true); + if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') { + /* Node is already a body, use as is */ + body = importedNode; + } else if (importedNode.nodeName === 'HTML') { + body = importedNode; + } else { + // eslint-disable-next-line unicorn/prefer-node-append + body.appendChild(importedNode); + } + } else { + /* Exit directly if we have nothing to do */ + if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && + // eslint-disable-next-line unicorn/prefer-includes + dirty.indexOf('<') === -1) { + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; + } + + /* Initialize the document to work on */ + body = _initDocument(dirty); + + /* Check we have a DOM node from the data */ + if (!body) { + return RETURN_DOM ? null : emptyHTML; + } + } + + /* Remove first element node (ours) if FORCE_BODY is set */ + if (body && FORCE_BODY) { + _forceRemove(body.firstChild); + } + + /* Get node iterator */ + var nodeIterator = _createIterator(IN_PLACE ? dirty : body); + + /* Now start iterating over the created document */ + while (currentNode = nodeIterator.nextNode()) { + /* Fix IE's strange behavior with manipulated textNodes #89 */ + if (currentNode.nodeType === 3 && currentNode === oldNode) { + continue; + } + + /* Sanitize tags and elements */ + if (_sanitizeElements(currentNode)) { + continue; + } + + /* Shadow DOM detected, sanitize it */ + if (currentNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(currentNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(currentNode); + + oldNode = currentNode; + } + + oldNode = null; + + /* If we sanitized `dirty` in-place, return it. */ + if (IN_PLACE) { + return dirty; + } + + /* Return sanitized string or DOM */ + if (RETURN_DOM) { + if (RETURN_DOM_FRAGMENT) { + returnNode = createDocumentFragment.call(body.ownerDocument); + + while (body.firstChild) { + // eslint-disable-next-line unicorn/prefer-node-append + returnNode.appendChild(body.firstChild); + } + } else { + returnNode = body; + } + + if (RETURN_DOM_IMPORT) { + /* + AdoptNode() is not used because internal state is not reset + (e.g. the past names map of a HTMLFormElement), this is safe + in theory but we would rather not risk another attack vector. + The state that is cloned by importNode() is explicitly defined + by the specs. + */ + returnNode = importNode.call(originalDocument, returnNode, true); + } + + return returnNode; + } + + var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; + + /* Sanitize final string template-safe */ + if (SAFE_FOR_TEMPLATES) { + serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' '); + serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' '); + } + + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; + }; + + /** + * Public method to set the configuration once + * setConfig + * + * @param {Object} cfg configuration object + */ + DOMPurify.setConfig = function (cfg) { + _parseConfig(cfg); + SET_CONFIG = true; + }; + + /** + * Public method to remove the configuration + * clearConfig + * + */ + DOMPurify.clearConfig = function () { + CONFIG = null; + SET_CONFIG = false; + }; + + /** + * Public method to check if an attribute value is valid. + * Uses last set config, if any. Otherwise, uses config defaults. + * isValidAttribute + * + * @param {string} tag Tag name of containing element. + * @param {string} attr Attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false. + */ + DOMPurify.isValidAttribute = function (tag, attr, value) { + /* Initialize shared config vars if necessary. */ + if (!CONFIG) { + _parseConfig({}); + } + + var lcTag = stringToLowerCase(tag); + var lcName = stringToLowerCase(attr); + return _isValidAttribute(lcTag, lcName, value); + }; + + /** + * AddHook + * Public method to add DOMPurify hooks + * + * @param {String} entryPoint entry point for the hook to add + * @param {Function} hookFunction function to execute + */ + DOMPurify.addHook = function (entryPoint, hookFunction) { + if (typeof hookFunction !== 'function') { + return; + } + + hooks[entryPoint] = hooks[entryPoint] || []; + arrayPush(hooks[entryPoint], hookFunction); + }; + + /** + * RemoveHook + * Public method to remove a DOMPurify hook at a given entryPoint + * (pops it from the stack of hooks if more are present) + * + * @param {String} entryPoint entry point for the hook to remove + */ + DOMPurify.removeHook = function (entryPoint) { + if (hooks[entryPoint]) { + arrayPop(hooks[entryPoint]); + } + }; + + /** + * RemoveHooks + * Public method to remove all DOMPurify hooks at a given entryPoint + * + * @param {String} entryPoint entry point for the hooks to remove + */ + DOMPurify.removeHooks = function (entryPoint) { + if (hooks[entryPoint]) { + hooks[entryPoint] = []; + } + }; + + /** + * RemoveAllHooks + * Public method to remove all DOMPurify hooks + * + */ + DOMPurify.removeAllHooks = function () { + hooks = {}; + }; + + return DOMPurify; + } + + var purify = createDOMPurify(); + + var globalWin = window; + var globalDoc = document; + + var IMAGE_MIME_REGEX = /^image\/(p?jpe?g|gif|png|bmp)$/i; + + /** + * Wrap inlines that are in the root in paragraphs. + * + * @param {HTMLBodyElement} body + * @param {Document} doc + * @private + */ + function wrapInlines(body, doc) { + var wrapper; + + traverse(body, function (node) { + if (isInline(node, true)) { + // Ignore text nodes unless they contain non-whitespace chars as + // whitespace will be collapsed. + // Ignore sceditor-ignore elements unless wrapping siblings + // Should still wrap both if wrapping siblings. + if (wrapper || node.nodeType === TEXT_NODE ? + /\S/.test(node.nodeValue) : !is(node, '.sceditor-ignore')) { + if (!wrapper) { + wrapper = createElement('p', {}, doc); + insertBefore(wrapper, node); + } + + appendChild(wrapper, node); + } + } else { + wrapper = null; + } + }, false, true); + } + /** + * SCEditor - A lightweight WYSIWYG editor + * + * @param {HTMLTextAreaElement} original The textarea to be converted + * @param {Object} userOptions + * @class SCEditor + * @name SCEditor + */ + function SCEditor(original, userOptions) { + /** + * Alias of this + * + * @private + */ + var base = this; + + /** + * Editor format like BBCode or HTML + */ + var format; + + /** + * The div which contains the editor and toolbar + * + * @type {HTMLDivElement} + * @private + */ + var editorContainer; + + /** + * Map of events handlers bound to this instance. + * + * @type {Object} + * @private + */ + var eventHandlers = {}; + + /** + * The editors toolbar + * + * @type {HTMLDivElement} + * @private + */ + var toolbar; + + /** + * The editors iframe which should be in design mode + * + * @type {HTMLIFrameElement} + * @private + */ + var wysiwygEditor; + + /** + * The editors window + * + * @type {Window} + * @private + */ + var wysiwygWindow; + + /** + * The WYSIWYG editors body element + * + * @type {HTMLBodyElement} + * @private + */ + var wysiwygBody; + + /** + * The WYSIWYG editors document + * + * @type {Document} + * @private + */ + var wysiwygDocument; + + /** + * The editors textarea for viewing source + * + * @type {HTMLTextAreaElement} + * @private + */ + var sourceEditor; + + /** + * The current dropdown + * + * @type {HTMLDivElement} + * @private + */ + var dropdown; + + /** + * If the user is currently composing text via IME + * @type {boolean} + */ + var isComposing; + + /** + * Timer for valueChanged key handler + * @type {number} + */ + var valueChangedKeyUpTimer; + + /** + * The editors locale + * + * @private + */ + var locale; + + /** + * Stores a cache of preloaded images + * + * @private + * @type {Array.<HTMLImageElement>} + */ + var preLoadCache = []; + + /** + * The editors rangeHelper instance + * + * @type {RangeHelper} + * @private + */ + var rangeHelper; + + /** + * An array of button state handlers + * + * @type {Array.<Object>} + * @private + */ + var btnStateHandlers = []; + + /** + * Plugin manager instance + * + * @type {PluginManager} + * @private + */ + var pluginManager; + + /** + * The current node containing the selection/caret + * + * @type {Node} + * @private + */ + var currentNode; + + /** + * The first block level parent of the current node + * + * @type {node} + * @private + */ + var currentBlockNode; + + /** + * The current node selection/caret + * + * @type {Object} + * @private + */ + var currentSelection; + + /** + * Used to make sure only 1 selection changed + * check is called every 100ms. + * + * Helps improve performance as it is checked a lot. + * + * @type {boolean} + * @private + */ + var isSelectionCheckPending; + + /** + * If content is required (equivalent to the HTML5 required attribute) + * + * @type {boolean} + * @private + */ + var isRequired; + + /** + * The inline CSS style element. Will be undefined + * until css() is called for the first time. + * + * @type {HTMLStyleElement} + * @private + */ + var inlineCss; + + /** + * Object containing a list of shortcut handlers + * + * @type {Object} + * @private + */ + var shortcutHandlers = {}; + + /** + * The min and max heights that autoExpand should stay within + * + * @type {Object} + * @private + */ + var autoExpandBounds; + + /** + * Timeout for the autoExpand function to throttle calls + * + * @private + */ + var autoExpandThrottle; + + /** + * Cache of the current toolbar buttons + * + * @type {Object} + * @private + */ + var toolbarButtons = {}; + + /** + * Last scroll position before maximizing so + * it can be restored when finished. + * + * @type {number} + * @private + */ + var maximizeScrollPosition; + + /** + * Stores the contents while a paste is taking place. + * + * Needed to support browsers that lack clipboard API support. + * + * @type {?DocumentFragment} + * @private + */ + var pasteContentFragment; + + /** + * All the emoticons from dropdown, more and hidden combined + * and with the emoticons root set + * + * @type {!Object<string, string>} + * @private + */ + var allEmoticons = {}; + + /** + * Current icon set if any + * + * @type {?Object} + * @private + */ + var icons; + + /** + * Private functions + * @private + */ + var init, + replaceEmoticons, + handleCommand, + initEditor, + initLocale, + initToolBar, + initOptions, + initEvents, + initResize, + initEmoticons, + handlePasteEvt, + handleCutCopyEvt, + handlePasteData, + handleKeyDown, + handleBackSpace, + handleKeyPress, + handleFormReset, + handleMouseDown, + handleComposition, + handleEvent, + handleDocumentClick, + updateToolBar, + updateActiveButtons, + sourceEditorSelectedText, + appendNewLine, + checkSelectionChanged, + checkNodeChanged, + autofocus, + emoticonsKeyPress, + emoticonsCheckWhitespace, + currentStyledBlockNode, + triggerValueChanged, + valueChangedBlur, + valueChangedKeyUp, + autoUpdate, + autoExpand; + + /** + * All the commands supported by the editor + * @name commands + * @memberOf SCEditor.prototype + */ + base.commands = extend(true, {}, (userOptions.commands || defaultCmds)); + + /** + * Options for this editor instance + * @name opts + * @memberOf SCEditor.prototype + */ + var options = base.opts = extend( + true, {}, defaultOptions, userOptions + ); + + // Don't deep extend emoticons (fixes #565) + base.opts.emoticons = userOptions.emoticons || defaultOptions.emoticons; + + if (!Array.isArray(options.allowedIframeUrls)) { + options.allowedIframeUrls = []; + } + options.allowedIframeUrls.push('https://www.youtube-nocookie.com/embed/'); + + // Create new instance of DOMPurify for each editor instance so can + // have different allowed iframe URLs + // eslint-disable-next-line new-cap + var domPurify = purify(); + + // Allow iframes for things like YouTube, see: + // https://github.com/cure53/DOMPurify/issues/340#issuecomment-670758980 + domPurify.addHook('uponSanitizeElement', function (node, data) { + var allowedUrls = options.allowedIframeUrls; + + if (data.tagName === 'iframe') { + var src = attr(node, 'src') || ''; + + for (var i = 0; i < allowedUrls.length; i++) { + var url = allowedUrls[i]; + + if (isString(url) && src.substr(0, url.length) === url) { + return; + } + + // Handle regex + if (url.test && url.test(src)) { + return; + } + } + + // No match so remove + remove(node); + } + }); + + // Convert target attribute into data-sce-target attributes so XHTML format + // can allow them + domPurify.addHook('afterSanitizeAttributes', function (node) { + if ('target' in node) { + attr(node, 'data-sce-target', attr(node, 'target')); + } + + removeAttr(node, 'target'); + }); + + /** + * Sanitize HTML to avoid XSS + * + * @param {string} html + * @return {string} html + * @private + */ + function sanitize(html) { + return domPurify.sanitize(html, { + ADD_TAGS: ['iframe'], + ADD_ATTR: ['allowfullscreen', 'frameborder', 'target'] + }); + } + /** + * Creates the editor iframe and textarea + * @private + */ + init = function () { + original._sceditor = base; + + // Load locale + if (options.locale && options.locale !== 'en') { + initLocale(); + } + + editorContainer = createElement('div', { + className: 'sceditor-container' + }); + + insertBefore(editorContainer, original); + css(editorContainer, 'z-index', options.zIndex); + + isRequired = original.required; + original.required = false; + + var FormatCtor = SCEditor.formats[options.format]; + format = FormatCtor ? new FormatCtor() : {}; + /* + * Plugins should be initialized before the formatters since + * they may wish to add or change formatting handlers and + * since the bbcode format caches its handlers, + * such changes must be done first. + */ + pluginManager = new PluginManager(base); + (options.plugins || '').split(',').forEach(function (plugin) { + pluginManager.register(plugin.trim()); + }); + if ('init' in format) { + format.init.call(base); + } + + // create the editor + initEmoticons(); + initToolBar(); + initEditor(); + initOptions(); + initEvents(); + + // force into source mode if is a browser that can't handle + // full editing + if (!isWysiwygSupported) { + base.toggleSourceMode(); + } + + updateActiveButtons(); + + var loaded = function () { + off(globalWin, 'load', loaded); + + if (options.autofocus) { + autofocus(!!options.autofocusEnd); + } + + autoExpand(); + appendNewLine(); + // TODO: use editor doc and window? + pluginManager.call('ready'); + if ('onReady' in format) { + format.onReady.call(base); + } + }; + on(globalWin, 'load', loaded); + if (globalDoc.readyState === 'complete') { + loaded(); + } + }; + + /** + * Init the locale variable with the specified locale if possible + * @private + * @return void + */ + initLocale = function () { + var lang; + + locale = SCEditor.locale[options.locale]; + + if (!locale) { + lang = options.locale.split('-'); + locale = SCEditor.locale[lang[0]]; + } + + // Locale DateTime format overrides any specified in the options + if (locale && locale.dateFormat) { + options.dateFormat = locale.dateFormat; + } + }; + + /** + * Creates the editor iframe and textarea + * @private + */ + initEditor = function () { + sourceEditor = createElement('textarea'); + wysiwygEditor = createElement('iframe', { + frameborder: 0, + allowfullscreen: true + }); + + /* + * This needs to be done right after they are created because, + * for any reason, the user may not want the value to be tinkered + * by any filters. + */ + if (options.startInSourceMode) { + addClass(editorContainer, 'sourceMode'); + hide(wysiwygEditor); + } else { + addClass(editorContainer, 'wysiwygMode'); + hide(sourceEditor); + } + + if (!options.spellcheck) { + attr(editorContainer, 'spellcheck', 'false'); + } + + if (globalWin.location.protocol === 'https:') { + attr(wysiwygEditor, 'src', 'about:blank'); + } + + // Add the editor to the container + appendChild(editorContainer, wysiwygEditor); + appendChild(editorContainer, sourceEditor); + + // TODO: make this optional somehow + base.dimensions( + options.width || width(original), + options.height || height(original) + ); + + // Add ios to HTML so can apply CSS fix to only it + var className = ios ? ' ios' : ''; + + wysiwygDocument = wysiwygEditor.contentDocument; + wysiwygDocument.open(); + wysiwygDocument.write(_tmpl('html', { + attrs: ' class="' + className + '"', + spellcheck: options.spellcheck ? '' : 'spellcheck="false"', + charset: options.charset, + style: options.style + })); + wysiwygDocument.close(); + + wysiwygBody = wysiwygDocument.body; + wysiwygWindow = wysiwygEditor.contentWindow; + + base.readOnly(!!options.readOnly); + + // iframe overflow fix for iOS + if (ios) { + height(wysiwygBody, '100%'); + on(wysiwygBody, 'touchend', base.focus); + } + + var tabIndex = attr(original, 'tabindex'); + attr(sourceEditor, 'tabindex', tabIndex); + attr(wysiwygEditor, 'tabindex', tabIndex); + + rangeHelper = new RangeHelper(wysiwygWindow, null, sanitize); + + // load any textarea value into the editor + hide(original); + base.val(original.value); + + var placeholder = options.placeholder || + attr(original, 'placeholder'); + + if (placeholder) { + sourceEditor.placeholder = placeholder; + attr(wysiwygBody, 'placeholder', placeholder); + } + }; + + /** + * Initialises options + * @private + */ + initOptions = function () { + // auto-update original textbox on blur if option set to true + if (options.autoUpdate) { + on(wysiwygBody, 'blur', autoUpdate); + on(sourceEditor, 'blur', autoUpdate); + } + + if (options.rtl === null) { + options.rtl = css(sourceEditor, 'direction') === 'rtl'; + } + + base.rtl(!!options.rtl); + + if (options.autoExpand) { + // Need to update when images (or anything else) loads + on(wysiwygBody, 'load', autoExpand, EVENT_CAPTURE); + on(wysiwygBody, 'input keyup', autoExpand); + } + + if (options.resizeEnabled) { + initResize(); + } + + attr(editorContainer, 'id', options.id); + base.emoticons(options.emoticonsEnabled); + }; + + /** + * Initialises events + * @private + */ + initEvents = function () { + var form = original.form; + var compositionEvents = 'compositionstart compositionend'; + var eventsToForward = + 'keydown keyup keypress focus blur contextmenu input'; + var checkSelectionEvents = 'onselectionchange' in wysiwygDocument ? + 'selectionchange' : + 'keyup focus blur contextmenu mouseup touchend click'; + + on(globalDoc, 'click', handleDocumentClick); + + if (form) { + on(form, 'reset', handleFormReset); + on(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + on(window, 'pagehide', base.updateOriginal); + on(window, 'pageshow', handleFormReset); + on(wysiwygBody, 'keypress', handleKeyPress); + on(wysiwygBody, 'keydown', handleKeyDown); + on(wysiwygBody, 'keydown', handleBackSpace); + on(wysiwygBody, 'keyup', appendNewLine); + on(wysiwygBody, 'blur', valueChangedBlur); + on(wysiwygBody, 'keyup', valueChangedKeyUp); + on(wysiwygBody, 'paste', handlePasteEvt); + on(wysiwygBody, 'cut copy', handleCutCopyEvt); + on(wysiwygBody, compositionEvents, handleComposition); + on(wysiwygBody, checkSelectionEvents, checkSelectionChanged); + on(wysiwygBody, eventsToForward, handleEvent); + + if (options.emoticonsCompat && globalWin.getSelection) { + on(wysiwygBody, 'keyup', emoticonsCheckWhitespace); + } + + on(wysiwygBody, 'blur', function () { + if (!base.val()) { + addClass(wysiwygBody, 'placeholder'); + } + }); + + on(wysiwygBody, 'focus', function () { + removeClass(wysiwygBody, 'placeholder'); + }); + + on(sourceEditor, 'blur', valueChangedBlur); + on(sourceEditor, 'keyup', valueChangedKeyUp); + on(sourceEditor, 'keydown', handleKeyDown); + on(sourceEditor, compositionEvents, handleComposition); + on(sourceEditor, eventsToForward, handleEvent); + + on(wysiwygDocument, 'mousedown', handleMouseDown); + on(wysiwygDocument, checkSelectionEvents, checkSelectionChanged); + on(wysiwygDocument, 'keyup', appendNewLine); + + on(editorContainer, 'selectionchanged', checkNodeChanged); + on(editorContainer, 'selectionchanged', updateActiveButtons); + // Custom events to forward + on( + editorContainer, + 'selectionchanged valuechanged nodechanged pasteraw paste', + handleEvent + ); + }; + + /** + * Creates the toolbar and appends it to the container + * @private + */ + initToolBar = function () { + var group, + commands = base.commands, + exclude = (options.toolbarExclude || '').split(','), + groups = options.toolbar.split('|'); + + toolbar = createElement('div', { + className: 'sceditor-toolbar', + unselectable: 'on' + }); + + if (options.icons in SCEditor.icons) { + icons = new SCEditor.icons[options.icons](); + } + + each(groups, function (_, menuItems) { + group = createElement('div', { + className: 'sceditor-group' + }); + + each(menuItems.split(','), function (_, commandName) { + var button, shortcut, + command = commands[commandName]; + + // The commandName must be a valid command and not excluded + if (!command || exclude.indexOf(commandName) > -1) { + return; + } + + shortcut = command.shortcut; + button = _tmpl('toolbarButton', { + name: commandName, + dispName: base._(command.name || + command.tooltip || commandName) + }, true).firstChild; + + if (icons && icons.create) { + var icon = icons.create(commandName); + if (icon) { + insertBefore(icons.create(commandName), + button.firstChild); + addClass(button, 'has-icon'); + } + } + + button._sceTxtMode = !!command.txtExec; + button._sceWysiwygMode = !!command.exec; + toggleClass(button, 'disabled', !command.exec); + on(button, 'click', function (e) { + if (!hasClass(button, 'disabled')) { + handleCommand(button, command); + } + + updateActiveButtons(); + e.preventDefault(); + }); + // Prevent editor losing focus when button clicked + on(button, 'mousedown', function (e) { + base.closeDropDown(); + e.preventDefault(); + }); + + if (command.tooltip) { + attr(button, 'title', + base._(command.tooltip) + + (shortcut ? ' (' + shortcut + ')' : '') + ); + } + + if (shortcut) { + base.addShortcut(shortcut, commandName); + } + + if (command.state) { + btnStateHandlers.push({ + name: commandName, + state: command.state + }); + // exec string commands can be passed to queryCommandState + } else if (isString(command.exec)) { + btnStateHandlers.push({ + name: commandName, + state: command.exec + }); + } + + appendChild(group, button); + toolbarButtons[commandName] = button; + }); + + // Exclude empty groups + if (group.firstChild) { + appendChild(toolbar, group); + } + }); + + // Append the toolbar to the toolbarContainer option if given + appendChild(options.toolbarContainer || editorContainer, toolbar); + }; + + /** + * Creates the resizer. + * @private + */ + initResize = function () { + var minHeight, maxHeight, minWidth, maxWidth, + mouseMoveFunc, mouseUpFunc, + grip = createElement('div', { + className: 'sceditor-grip' + }), + // Cover is used to cover the editor iframe so document + // still gets mouse move events + cover = createElement('div', { + className: 'sceditor-resize-cover' + }), + moveEvents = 'touchmove mousemove', + endEvents = 'touchcancel touchend mouseup', + startX = 0, + startY = 0, + newX = 0, + newY = 0, + startWidth = 0, + startHeight = 0, + origWidth = width(editorContainer), + origHeight = height(editorContainer), + isDragging = false, + rtl = base.rtl(); + + minHeight = options.resizeMinHeight || origHeight / 1.5; + maxHeight = options.resizeMaxHeight || origHeight * 2.5; + minWidth = options.resizeMinWidth || origWidth / 1.25; + maxWidth = options.resizeMaxWidth || origWidth * 1.25; + + mouseMoveFunc = function (e) { + // iOS uses window.event + if (e.type === 'touchmove') { + e = globalWin.event; + newX = e.changedTouches[0].pageX; + newY = e.changedTouches[0].pageY; + } else { + newX = e.pageX; + newY = e.pageY; + } + + var newHeight = startHeight + (newY - startY), + newWidth = rtl ? + startWidth - (newX - startX) : + startWidth + (newX - startX); + + if (maxWidth > 0 && newWidth > maxWidth) { + newWidth = maxWidth; + } + if (minWidth > 0 && newWidth < minWidth) { + newWidth = minWidth; + } + if (!options.resizeWidth) { + newWidth = false; + } + + if (maxHeight > 0 && newHeight > maxHeight) { + newHeight = maxHeight; + } + if (minHeight > 0 && newHeight < minHeight) { + newHeight = minHeight; + } + if (!options.resizeHeight) { + newHeight = false; + } + + if (newWidth || newHeight) { + base.dimensions(newWidth, newHeight); + } + + e.preventDefault(); + }; + + mouseUpFunc = function (e) { + if (!isDragging) { + return; + } + + isDragging = false; + + hide(cover); + removeClass(editorContainer, 'resizing'); + off(globalDoc, moveEvents, mouseMoveFunc); + off(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }; + + if (icons && icons.create) { + var icon = icons.create('grip'); + if (icon) { + appendChild(grip, icon); + addClass(grip, 'has-icon'); + } + } + + appendChild(editorContainer, grip); + appendChild(editorContainer, cover); + hide(cover); + + on(grip, 'touchstart mousedown', function (e) { + // iOS uses window.event + if (e.type === 'touchstart') { + e = globalWin.event; + startX = e.touches[0].pageX; + startY = e.touches[0].pageY; + } else { + startX = e.pageX; + startY = e.pageY; + } + + startWidth = width(editorContainer); + startHeight = height(editorContainer); + isDragging = true; + + addClass(editorContainer, 'resizing'); + show(cover); + on(globalDoc, moveEvents, mouseMoveFunc); + on(globalDoc, endEvents, mouseUpFunc); + + e.preventDefault(); + }); + }; + + /** + * Prefixes and preloads the emoticon images + * @private + */ + initEmoticons = function () { + var emoticons = options.emoticons; + var root = options.emoticonsRoot || ''; + + if (emoticons) { + allEmoticons = extend( + {}, emoticons.more, emoticons.dropdown, emoticons.hidden + ); + } + + each(allEmoticons, function (key, url) { + allEmoticons[key] = _tmpl('emoticon', { + key: key, + // Prefix emoticon root to emoticon urls + url: root + (url.url || url), + tooltip: url.tooltip || key + }); + + // Preload the emoticon + if (options.emoticonsEnabled) { + preLoadCache.push(createElement('img', { + src: root + (url.url || url) + })); + } + }); + }; + + /** + * Autofocus the editor + * @private + */ + autofocus = function (focusEnd) { + var range, txtPos, + node = wysiwygBody.firstChild; + + // Can't focus invisible elements + if (!isVisible(editorContainer)) { + return; + } + + if (base.sourceMode()) { + txtPos = focusEnd ? sourceEditor.value.length : 0; + + sourceEditor.setSelectionRange(txtPos, txtPos); + + return; + } + + removeWhiteSpace(wysiwygBody); + + if (focusEnd) { + if (!(node = wysiwygBody.lastChild)) { + node = createElement('p', {}, wysiwygDocument); + appendChild(wysiwygBody, node); + } + + while (node.lastChild) { + node = node.lastChild; + + // Should place the cursor before the last <br> + if (is(node, 'br') && node.previousSibling) { + node = node.previousSibling; + } + } + } + + range = wysiwygDocument.createRange(); + + if (!canHaveChildren(node)) { + range.setStartBefore(node); + + if (focusEnd) { + range.setStartAfter(node); + } + } else { + range.selectNodeContents(node); + } + + range.collapse(!focusEnd); + rangeHelper.selectRange(range); + currentSelection = range; + + if (focusEnd) { + wysiwygBody.scrollTop = wysiwygBody.scrollHeight; + } + + base.focus(); + }; + + /** + * Gets if the editor is read only + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly + * @return {boolean} + */ + /** + * Sets if the editor is read only + * + * @param {boolean} readOnly + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name readOnly^2 + * @return {this} + */ + base.readOnly = function (readOnly) { + if (typeof readOnly !== 'boolean') { + return !sourceEditor.readonly; + } + + wysiwygBody.contentEditable = !readOnly; + sourceEditor.readonly = !readOnly; + + updateToolBar(readOnly); + + return base; + }; + + /** + * Gets if the editor is in RTL mode + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl + * @return {boolean} + */ + /** + * Sets if the editor is in RTL mode + * + * @param {boolean} rtl + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name rtl^2 + * @return {this} + */ + base.rtl = function (rtl) { + var dir = rtl ? 'rtl' : 'ltr'; + + if (typeof rtl !== 'boolean') { + return attr(sourceEditor, 'dir') === 'rtl'; + } + + attr(wysiwygBody, 'dir', dir); + attr(sourceEditor, 'dir', dir); + + removeClass(editorContainer, 'rtl'); + removeClass(editorContainer, 'ltr'); + addClass(editorContainer, dir); + + if (icons && icons.rtl) { + icons.rtl(rtl); + } + + return base; + }; + + /** + * Updates the toolbar to disable/enable the appropriate buttons + * @private + */ + updateToolBar = function (disable) { + var mode = base.inSourceMode() ? '_sceTxtMode' : '_sceWysiwygMode'; + + each(toolbarButtons, function (_, button) { + toggleClass(button, 'disabled', disable || !button[mode]); + }); + }; + + /** + * Gets the width of the editor in pixels + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width + * @return {number} + */ + /** + * Sets the width of the editor + * + * @param {number} width Width in pixels + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name width^2 + * @return {this} + */ + /** + * Sets the width of the editor + * + * The saveWidth specifies if to save the width. The stored width can be + * used for things like restoring from maximized state. + * + * @param {number} width Width in pixels + * @param {boolean} [saveWidth=true] If to store the width + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name width^3 + * @return {this} + */ + base.width = function (width$1, saveWidth) { + if (!width$1 && width$1 !== 0) { + return width(editorContainer); + } + + base.dimensions(width$1, null, saveWidth); + + return base; + }; + + /** + * Returns an object with the properties width and height + * which are the width and height of the editor in px. + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions + * @return {object} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^2 + * @return {this} + */ + /** + * <p>Sets the width and/or height of the editor.</p> + * + * <p>If width or height is not numeric it is ignored.</p> + * + * <p>The save argument specifies if to save the new sizes. + * The saved sizes can be used for things like restoring from + * maximized state. This should normally be left as true.</p> + * + * @param {number} width Width in px + * @param {number} height Height in px + * @param {boolean} [save=true] If to store the new sizes + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name dimensions^3 + * @return {this} + */ + base.dimensions = function (width$1, height$1, save) { + // set undefined width/height to boolean false + width$1 = (!width$1 && width$1 !== 0) ? false : width$1; + height$1 = (!height$1 && height$1 !== 0) ? false : height$1; + + if (width$1 === false && height$1 === false) { + return { width: base.width(), height: base.height() }; + } + + if (width$1 !== false) { + if (save !== false) { + options.width = width$1; + } + + width(editorContainer, width$1); + } + + if (height$1 !== false) { + if (save !== false) { + options.height = height$1; + } + + height(editorContainer, height$1); + } + + return base; + }; + + /** + * Gets the height of the editor in px + * + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height + * @return {number} + */ + /** + * Sets the height of the editor + * + * @param {number} height Height in px + * @since 1.3.5 + * @function + * @memberOf SCEditor.prototype + * @name height^2 + * @return {this} + */ + /** + * Sets the height of the editor + * + * The saveHeight specifies if to save the height. + * + * The stored height can be used for things like + * restoring from maximized state. + * + * @param {number} height Height in px + * @param {boolean} [saveHeight=true] If to store the height + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name height^3 + * @return {this} + */ + base.height = function (height$1, saveHeight) { + if (!height$1 && height$1 !== 0) { + return height(editorContainer); + } + + base.dimensions(null, height$1, saveHeight); + + return base; + }; + + /** + * Gets if the editor is maximised or not + * + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize + * @return {boolean} + */ + /** + * Sets if the editor is maximised or not + * + * @param {boolean} maximize If to maximise the editor + * @since 1.4.1 + * @function + * @memberOf SCEditor.prototype + * @name maximize^2 + * @return {this} + */ + base.maximize = function (maximize) { + var maximizeSize = 'sceditor-maximize'; + + if (isUndefined(maximize)) { + return hasClass(editorContainer, maximizeSize); + } + + maximize = !!maximize; + + if (maximize) { + maximizeScrollPosition = globalWin.pageYOffset; + } + + toggleClass(globalDoc.documentElement, maximizeSize, maximize); + toggleClass(globalDoc.body, maximizeSize, maximize); + toggleClass(editorContainer, maximizeSize, maximize); + base.width(maximize ? '100%' : options.width, false); + base.height(maximize ? '100%' : options.height, false); + + if (!maximize) { + globalWin.scrollTo(0, maximizeScrollPosition); + } + + autoExpand(); + + return base; + }; + + autoExpand = function () { + if (options.autoExpand && !autoExpandThrottle) { + autoExpandThrottle = setTimeout(base.expandToContent, 200); + } + }; + + /** + * Expands or shrinks the editors height to the height of it's content + * + * Unless ignoreMaxHeight is set to true it will not expand + * higher than the maxHeight option. + * + * @since 1.3.5 + * @param {boolean} [ignoreMaxHeight=false] + * @function + * @name expandToContent + * @memberOf SCEditor.prototype + * @see #resizeToContent + */ + base.expandToContent = function (ignoreMaxHeight) { + if (base.maximize()) { + return; + } + + clearTimeout(autoExpandThrottle); + autoExpandThrottle = false; + + if (!autoExpandBounds) { + var height$1 = options.resizeMinHeight || options.height || + height(original); + + autoExpandBounds = { + min: height$1, + max: options.resizeMaxHeight || (height$1 * 2) + }; + } + + var range = globalDoc.createRange(); + range.selectNodeContents(wysiwygBody); + + var rect = range.getBoundingClientRect(); + var current = wysiwygDocument.documentElement.clientHeight - 1; + var spaceNeeded = rect.bottom - rect.top; + var newHeight = base.height() + 1 + (spaceNeeded - current); + + if (!ignoreMaxHeight && autoExpandBounds.max !== -1) { + newHeight = Math.min(newHeight, autoExpandBounds.max); + } + + base.height(Math.ceil(Math.max(newHeight, autoExpandBounds.min))); + }; + + /** + * Destroys the editor, removing all elements and + * event handlers. + * + * Leaves only the original textarea. + * + * @function + * @name destroy + * @memberOf SCEditor.prototype + */ + base.destroy = function () { + // Don't destroy if the editor has already been destroyed + if (!pluginManager) { + return; + } + + pluginManager.destroy(); + + rangeHelper = null; + pluginManager = null; + + if (dropdown) { + remove(dropdown); + } + + off(globalDoc, 'click', handleDocumentClick); + + var form = original.form; + if (form) { + off(form, 'reset', handleFormReset); + off(form, 'submit', base.updateOriginal, EVENT_CAPTURE); + } + + off(window, 'pagehide', base.updateOriginal); + off(window, 'pageshow', handleFormReset); + remove(sourceEditor); + remove(toolbar); + remove(editorContainer); + + delete original._sceditor; + show(original); + + original.required = isRequired; + }; + + + /** + * Creates a menu item drop down + * + * @param {HTMLElement} menuItem The button to align the dropdown with + * @param {string} name Used for styling the dropdown, will be + * a class sceditor-name + * @param {HTMLElement} content The HTML content of the dropdown + * @function + * @name createDropDown + * @memberOf SCEditor.prototype + */ + base.createDropDown = function (menuItem, name, content) { + // first click for create second click for close + var dropDownCss, + dropDownClass = 'sceditor-' + name; + + base.closeDropDown(); + + // Only close the dropdown if it was already open + if (dropdown && hasClass(dropdown, dropDownClass)) { + return; + } + + dropDownCss = extend({ + top: menuItem.offsetTop, + left: menuItem.offsetLeft, + marginTop: menuItem.clientHeight + }, options.dropDownCss); + + dropdown = createElement('div', { + className: 'sceditor-dropdown ' + dropDownClass + }); + + css(dropdown, dropDownCss); + appendChild(dropdown, content); + appendChild(editorContainer, dropdown); + on(dropdown, 'click focusin', function (e) { + // stop clicks within the dropdown from being handled + e.stopPropagation(); + }); + + if (dropdown) { + var first = find(dropdown, 'input,textarea')[0]; + if (first) { + first.focus(); + } + } + }; + + /** + * Handles any document click and closes the dropdown if open + * @private + */ + handleDocumentClick = function (e) { + // ignore right clicks + if (e.which !== 3 && dropdown && !e.defaultPrevented) { + autoUpdate(); + + base.closeDropDown(); + } + }; + + /** + * Handles the WYSIWYG editors cut & copy events + * + * By default browsers also copy inherited styling from the stylesheet and + * browser default styling which is unnecessary. + * + * This will ignore inherited styles and only copy inline styling. + * @private + */ + handleCutCopyEvt = function (e) { + var range = rangeHelper.selectedRange(); + if (range) { + var container = createElement('div', {}, wysiwygDocument); + var firstParent; + + // Copy all inline parent nodes up to the first block parent so can + // copy inline styles + var parent = range.commonAncestorContainer; + while (parent && isInline(parent, true)) { + if (parent.nodeType === ELEMENT_NODE) { + var clone = parent.cloneNode(); + if (container.firstChild) { + appendChild(clone, container.firstChild); + } + + appendChild(container, clone); + firstParent = firstParent || clone; + } + parent = parent.parentNode; + } + + appendChild(firstParent || container, range.cloneContents()); + removeWhiteSpace(container); + + e.clipboardData.setData('text/html', container.innerHTML); + + // TODO: Refactor into private shared module with plaintext plugin + // innerText adds two newlines after <p> tags so convert them to + // <div> tags + each(find(container, 'p'), function (_, elm) { + convertElement(elm, 'div'); + }); + // Remove collapsed <br> tags as innerText converts them to newlines + each(find(container, 'br'), function (_, elm) { + if (!elm.nextSibling || !isInline(elm.nextSibling, true)) { + remove(elm); + } + }); + + // range.toString() doesn't include newlines so can't use that. + // selection.toString() seems to use the same method as innerText + // but needs to be normalised first so using container.innerText + appendChild(wysiwygBody, container); + e.clipboardData.setData('text/plain', container.innerText); + remove(container); + + if (e.type === 'cut') { + range.deleteContents(); + } + + e.preventDefault(); + } + }; + + /** + * Handles the WYSIWYG editors paste event + * @private + */ + handlePasteEvt = function (e) { + var editable = wysiwygBody; + var clipboard = e.clipboardData; + var loadImage = function (file) { + var reader = new FileReader(); + reader.onload = function (e) { + handlePasteData({ + html: '<img src="' + e.target.result + '" />' + }); + }; + reader.readAsDataURL(file); + }; + + // Modern browsers with clipboard API - everything other than _very_ + // old android web views and UC browser which doesn't support the + // paste event at all. + if (clipboard) { + var data = {}; + var types = clipboard.types; + var items = clipboard.items; + + e.preventDefault(); + + for (var i = 0; i < types.length; i++) { + // Word sometimes adds copied text as an image so if HTML + // exists prefer that over images + if (types.indexOf('text/html') < 0) { + // Normalise image pasting to paste as a data-uri + if (globalWin.FileReader && items && + IMAGE_MIME_REGEX.test(items[i].type)) { + return loadImage(clipboard.items[i].getAsFile()); + } + } + + data[types[i]] = clipboard.getData(types[i]); + } + // Call plugins here with file? + data.text = data['text/plain']; + data.html = sanitize(data['text/html']); + + handlePasteData(data); + // If contentsFragment exists then we are already waiting for a + // previous paste so let the handler for that handle this one too + } else if (!pasteContentFragment) { + // Save the scroll position so can be restored + // when contents is restored + var scrollTop = editable.scrollTop; + + rangeHelper.saveRange(); + + pasteContentFragment = globalDoc.createDocumentFragment(); + while (editable.firstChild) { + appendChild(pasteContentFragment, editable.firstChild); + } + + setTimeout(function () { + var html = editable.innerHTML; + + editable.innerHTML = ''; + appendChild(editable, pasteContentFragment); + editable.scrollTop = scrollTop; + pasteContentFragment = false; + + rangeHelper.restoreRange(); + + handlePasteData({ html: sanitize(html) }); + }, 0); + } + }; + + /** + * Gets the pasted data, filters it and then inserts it. + * @param {Object} data + * @private + */ + handlePasteData = function (data) { + var pasteArea = createElement('div', {}, wysiwygDocument); + + pluginManager.call('pasteRaw', data); + trigger(editorContainer, 'pasteraw', data); + + if (data.html) { + // Sanitize again in case plugins modified the HTML + pasteArea.innerHTML = sanitize(data.html); + + // fix any invalid nesting + fixNesting(pasteArea); + } else { + pasteArea.innerHTML = entities(data.text || ''); + } + + var paste = { + val: pasteArea.innerHTML + }; + + if ('fragmentToSource' in format) { + paste.val = format + .fragmentToSource(paste.val, wysiwygDocument, currentNode); + } + + pluginManager.call('paste', paste); + trigger(editorContainer, 'paste', paste); + + if ('fragmentToHtml' in format) { + paste.val = format + .fragmentToHtml(paste.val, currentNode); + } + + pluginManager.call('pasteHtml', paste); + + var parent = rangeHelper.getFirstBlockParent(); + base.wysiwygEditorInsertHtml(paste.val, null, true); + merge(parent); + }; + + /** + * Closes any currently open drop down + * + * @param {boolean} [focus=false] If to focus the editor + * after closing the drop down + * @function + * @name closeDropDown + * @memberOf SCEditor.prototype + */ + base.closeDropDown = function (focus) { + if (dropdown) { + remove(dropdown); + dropdown = null; + } + + if (focus === true) { + base.focus(); + } + }; + + + /** + * Inserts HTML into WYSIWYG editor. + * + * If endHtml is specified, any selected text will be placed + * between html and endHtml. If there is no selected text html + * and endHtml will just be concatenate together. + * + * @param {string} html + * @param {string} [endHtml=null] + * @param {boolean} [overrideCodeBlocking=false] If to insert the html + * into code tags, by + * default code tags only + * support text. + * @function + * @name wysiwygEditorInsertHtml + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertHtml = function ( + html, endHtml, overrideCodeBlocking + ) { + var marker, scrollTop, scrollTo, + editorHeight = height(wysiwygEditor); + + base.focus(); + + // TODO: This code tag should be configurable and + // should maybe convert the HTML into text instead + // Don't apply to code elements + if (!overrideCodeBlocking && closest(currentBlockNode, 'code')) { + return; + } + + // Insert the HTML and save the range so the editor can be scrolled + // to the end of the selection. Also allows emoticons to be replaced + // without affecting the cursor position + rangeHelper.insertHTML(html, endHtml); + rangeHelper.saveRange(); + replaceEmoticons(); + + // Fix any invalid nesting, e.g. if a quote or other block is inserted + // into a paragraph + fixNesting(wysiwygBody); + + // Scroll the editor after the end of the selection + marker = find(wysiwygBody, '#sceditor-end-marker')[0]; + show(marker); + scrollTop = wysiwygBody.scrollTop; + scrollTo = (getOffset(marker).top + + (marker.offsetHeight * 1.5)) - editorHeight; + hide(marker); + + // Only scroll if marker isn't already visible + if (scrollTo > scrollTop || scrollTo + editorHeight < scrollTop) { + wysiwygBody.scrollTop = scrollTo; + } + + triggerValueChanged(false); + rangeHelper.restoreRange(); + + // Add a new line after the last block element + // so can always add text after it + appendNewLine(); + }; + + /** + * Like wysiwygEditorInsertHtml except it will convert any HTML + * into text before inserting it. + * + * @param {string} text + * @param {string} [endText=null] + * @function + * @name wysiwygEditorInsertText + * @memberOf SCEditor.prototype + */ + base.wysiwygEditorInsertText = function (text, endText) { + base.wysiwygEditorInsertHtml( + entities(text), entities(endText) + ); + }; + + /** + * Inserts text into the WYSIWYG or source editor depending on which + * mode the editor is in. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.3.5 + * @function + * @name insertText + * @memberOf SCEditor.prototype + */ + base.insertText = function (text, endText) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(text, endText); + } else { + base.wysiwygEditorInsertText(text, endText); + } + + return base; + }; + + /** + * Like wysiwygEditorInsertHtml but inserts text into the + * source mode editor instead. + * + * If endText is specified any selected text will be placed between + * text and endText. If no text is selected text and endText will + * just be concatenate together. + * + * The cursor will be placed after the text param. If endText is + * specified the cursor will be placed before endText, so passing:<br /> + * + * '[b]', '[/b]' + * + * Would cause the cursor to be placed:<br /> + * + * [b]Selected text|[/b] + * + * @param {string} text + * @param {string} [endText=null] + * @since 1.4.0 + * @function + * @name sourceEditorInsertText + * @memberOf SCEditor.prototype + */ + base.sourceEditorInsertText = function (text, endText) { + var scrollTop, currentValue, + startPos = sourceEditor.selectionStart, + endPos = sourceEditor.selectionEnd; + + scrollTop = sourceEditor.scrollTop; + sourceEditor.focus(); + currentValue = sourceEditor.value; + + if (endText) { + text += currentValue.substring(startPos, endPos) + endText; + } + + sourceEditor.value = currentValue.substring(0, startPos) + + text + + currentValue.substring(endPos, currentValue.length); + + sourceEditor.selectionStart = (startPos + text.length) - + (endText ? endText.length : 0); + sourceEditor.selectionEnd = sourceEditor.selectionStart; + + sourceEditor.scrollTop = scrollTop; + sourceEditor.focus(); + + triggerValueChanged(); + }; + + /** + * Gets the current instance of the rangeHelper class + * for the editor. + * + * @return {RangeHelper} + * @function + * @name getRangeHelper + * @memberOf SCEditor.prototype + */ + base.getRangeHelper = function () { + return rangeHelper; + }; + + /** + * Gets or sets the source editor caret position. + * + * @param {Object} [position] + * @return {this} + * @function + * @since 1.4.5 + * @name sourceEditorCaret + * @memberOf SCEditor.prototype + */ + base.sourceEditorCaret = function (position) { + sourceEditor.focus(); + + if (position) { + sourceEditor.selectionStart = position.start; + sourceEditor.selectionEnd = position.end; + + return this; + } + + return { + start: sourceEditor.selectionStart, + end: sourceEditor.selectionEnd + }; + }; + + /** + * Gets the value of the editor. + * + * If the editor is in WYSIWYG mode it will return the filtered + * HTML from it (converted to BBCode if using the BBCode plugin). + * It it's in Source Mode it will return the unfiltered contents + * of the source editor (if using the BBCode plugin this will be + * BBCode again). + * + * @since 1.3.5 + * @return {string} + * @function + * @name val + * @memberOf SCEditor.prototype + */ + /** + * Sets the value of the editor. + * + * If filter set true the val will be passed through the filter + * function. If using the BBCode plugin it will pass the val to + * the BBCode filter to convert any BBCode into HTML. + * + * @param {string} val + * @param {boolean} [filter=true] + * @return {this} + * @since 1.3.5 + * @function + * @name val^2 + * @memberOf SCEditor.prototype + */ + base.val = function (val, filter) { + if (!isString(val)) { + return base.inSourceMode() ? + base.getSourceEditorValue(false) : + base.getWysiwygEditorValue(filter); + } + + if (!base.inSourceMode()) { + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + base.setWysiwygEditorValue(val); + } else { + base.setSourceEditorValue(val); + } + + return base; + }; + + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @return {this} + * @since 1.3.5 + * @function + * @name insert + * @memberOf SCEditor.prototype + */ + /** + * Inserts HTML/BBCode into the editor + * + * If end is supplied any selected text will be placed between + * start and end. If there is no selected text start and end + * will be concatenate together. + * + * If the filter param is set to true, the HTML/BBCode will be + * passed through any plugin filters. If using the BBCode plugin + * this will convert any BBCode into HTML. + * + * If the allowMixed param is set to true, HTML any will not be + * escaped + * + * @param {string} start + * @param {string} [end=null] + * @param {boolean} [filter=true] + * @param {boolean} [convertEmoticons=true] If to convert emoticons + * @param {boolean} [allowMixed=false] + * @return {this} + * @since 1.4.3 + * @function + * @name insert^2 + * @memberOf SCEditor.prototype + */ + // eslint-disable-next-line max-params + base.insert = function ( + start, end, filter, convertEmoticons, allowMixed + ) { + if (base.inSourceMode()) { + base.sourceEditorInsertText(start, end); + return base; + } + + // Add the selection between start and end + if (end) { + var html = rangeHelper.selectedHtml(); + + if (filter !== false && 'fragmentToSource' in format) { + html = format + .fragmentToSource(html, wysiwygDocument, currentNode); + } + + start += html + end; + } + // TODO: This filter should allow empty tags as it's inserting. + if (filter !== false && 'fragmentToHtml' in format) { + start = format.fragmentToHtml(start, currentNode); + } + + // Convert any escaped HTML back into HTML if mixed is allowed + if (filter !== false && allowMixed === true) { + start = start.replace(/</g, '<') + .replace(/>/g, '>') + .replace(/&/g, '&'); + } + + base.wysiwygEditorInsertHtml(start); + + return base; + }; + + /** + * Gets the WYSIWYG editors HTML value. + * + * If using a plugin that filters the Ht Ml like the BBCode plugin + * it will return the result of the filtering (BBCode) unless the + * filter param is set to false. + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @name getWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.getWysiwygEditorValue = function (filter) { + var html; + // Create a tmp node to store contents so it can be modified + // without affecting anything else. + var tmp = createElement('div', {}, wysiwygDocument); + var childNodes = wysiwygBody.childNodes; + + for (var i = 0; i < childNodes.length; i++) { + appendChild(tmp, childNodes[i].cloneNode(true)); + } + + appendChild(wysiwygBody, tmp); + fixNesting(tmp); + remove(tmp); + + html = tmp.innerHTML; + + // filter the HTML and DOM through any plugins + if (filter !== false && format.hasOwnProperty('toSource')) { + html = format.toSource(html, wysiwygDocument); + } + + return html; + }; + + /** + * Gets the WYSIWYG editor's iFrame Body. + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getBody + * @memberOf SCEditor.prototype + */ + base.getBody = function () { + return wysiwygBody; + }; + + /** + * Gets the WYSIWYG editors container area (whole iFrame). + * + * @return {HTMLElement} + * @function + * @since 1.4.3 + * @name getContentAreaContainer + * @memberOf SCEditor.prototype + */ + base.getContentAreaContainer = function () { + return wysiwygEditor; + }; + + /** + * Gets the text editor value + * + * If using a plugin that filters the text like the BBCode plugin + * it will return the result of the filtering which is BBCode to + * HTML so it will return HTML. If filter is set to false it will + * just return the contents of the source editor (BBCode). + * + * @param {boolean} [filter=true] + * @return {string} + * @function + * @since 1.4.0 + * @name getSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.getSourceEditorValue = function (filter) { + var val = sourceEditor.value; + + if (filter !== false && 'toHtml' in format) { + val = format.toHtml(val); + } + + return val; + }; + + /** + * Sets the WYSIWYG HTML editor value. Should only be the HTML + * contained within the body tags + * + * @param {string} value + * @function + * @name setWysiwygEditorValue + * @memberOf SCEditor.prototype + */ + base.setWysiwygEditorValue = function (value) { + if (!value) { + value = '<p><br /></p>'; + } + + wysiwygBody.innerHTML = sanitize(value); + replaceEmoticons(); + + appendNewLine(); + triggerValueChanged(); + autoExpand(); + }; + + /** + * Sets the text editor value + * + * @param {string} value + * @function + * @name setSourceEditorValue + * @memberOf SCEditor.prototype + */ + base.setSourceEditorValue = function (value) { + sourceEditor.value = value; + + triggerValueChanged(); + }; + + /** + * Updates the textarea that the editor is replacing + * with the value currently inside the editor. + * + * @function + * @name updateOriginal + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.updateOriginal = function () { + original.value = base.val(); + }; + + /** + * Replaces any emoticon codes in the passed HTML + * with their emoticon images + * @private + */ + replaceEmoticons = function () { + if (options.emoticonsEnabled) { + replace(wysiwygBody, allEmoticons, options.emoticonsCompat); + } + }; + + /** + * If the editor is in source code mode + * + * @return {boolean} + * @function + * @name inSourceMode + * @memberOf SCEditor.prototype + */ + base.inSourceMode = function () { + return hasClass(editorContainer, 'sourceMode'); + }; + + /** + * Gets if the editor is in sourceMode + * + * @return boolean + * @function + * @name sourceMode + * @memberOf SCEditor.prototype + */ + /** + * Sets if the editor is in sourceMode + * + * @param {boolean} enable + * @return {this} + * @function + * @name sourceMode^2 + * @memberOf SCEditor.prototype + */ + base.sourceMode = function (enable) { + var inSourceMode = base.inSourceMode(); + + if (typeof enable !== 'boolean') { + return inSourceMode; + } + + if ((inSourceMode && !enable) || (!inSourceMode && enable)) { + base.toggleSourceMode(); + } + + return base; + }; + + /** + * Switches between the WYSIWYG and source modes + * + * @function + * @name toggleSourceMode + * @since 1.4.0 + * @memberOf SCEditor.prototype + */ + base.toggleSourceMode = function () { + var isInSourceMode = base.inSourceMode(); + + // don't allow switching to WYSIWYG if doesn't support it + if (!isWysiwygSupported && isInSourceMode) { + return; + } + + if (!isInSourceMode) { + rangeHelper.saveRange(); + rangeHelper.clear(); + } + + currentSelection = null; + base.blur(); + + if (isInSourceMode) { + base.setWysiwygEditorValue(base.getSourceEditorValue()); + } else { + base.setSourceEditorValue(base.getWysiwygEditorValue()); + } + + toggle(sourceEditor); + toggle(wysiwygEditor); + + toggleClass(editorContainer, 'wysiwygMode', isInSourceMode); + toggleClass(editorContainer, 'sourceMode', !isInSourceMode); + + updateToolBar(); + updateActiveButtons(); + }; + + /** + * Gets the selected text of the source editor + * @return {string} + * @private + */ + sourceEditorSelectedText = function () { + sourceEditor.focus(); + + return sourceEditor.value.substring( + sourceEditor.selectionStart, + sourceEditor.selectionEnd + ); + }; + + /** + * Handles the passed command + * @private + */ + handleCommand = function (caller, cmd) { + // check if in text mode and handle text commands + if (base.inSourceMode()) { + if (cmd.txtExec) { + if (Array.isArray(cmd.txtExec)) { + base.sourceEditorInsertText.apply(base, cmd.txtExec); + } else { + cmd.txtExec.call(base, caller, sourceEditorSelectedText()); + } + } + } else if (cmd.exec) { + if (isFunction(cmd.exec)) { + cmd.exec.call(base, caller); + } else { + base.execCommand( + cmd.exec, + cmd.hasOwnProperty('execParam') ? cmd.execParam : null + ); + } + } + + }; + + /** + * Executes a command on the WYSIWYG editor + * + * @param {string} command + * @param {String|Boolean} [param] + * @function + * @name execCommand + * @memberOf SCEditor.prototype + */ + base.execCommand = function (command, param) { + var executed = false, + commandObj = base.commands[command]; + + base.focus(); + + // TODO: make configurable + // don't apply any commands to code elements + if (closest(rangeHelper.parentNode(), 'code')) { + return; + } + + try { + executed = wysiwygDocument.execCommand(command, false, param); + } catch (ex) { } + + // show error if execution failed and an error message exists + if (!executed && commandObj && commandObj.errorMessage) { + /*global alert:false*/ + alert(base._(commandObj.errorMessage)); + } + + updateActiveButtons(); + }; + + /** + * Checks if the current selection has changed and triggers + * the selectionchanged event if it has. + * + * In browsers other that don't support selectionchange event it will check + * at most once every 100ms. + * @private + */ + checkSelectionChanged = function () { + function check() { + // Don't create new selection if there isn't one (like after + // blur event in iOS) + if (wysiwygWindow.getSelection() && + wysiwygWindow.getSelection().rangeCount <= 0) { + currentSelection = null; + // rangeHelper could be null if editor was destroyed + // before the timeout had finished + } else if (rangeHelper && !rangeHelper.compare(currentSelection)) { + currentSelection = rangeHelper.cloneSelected(); + + // If the selection is in an inline wrap it in a block. + // Fixes #331 + if (currentSelection && currentSelection.collapsed) { + var parent = currentSelection.startContainer; + var offset = currentSelection.startOffset; + + // Handle if selection is placed before/after an element + if (offset && parent.nodeType !== TEXT_NODE) { + parent = parent.childNodes[offset]; + } + + while (parent && parent.parentNode !== wysiwygBody) { + parent = parent.parentNode; + } + + if (parent && isInline(parent, true)) { + rangeHelper.saveRange(); + wrapInlines(wysiwygBody, wysiwygDocument); + rangeHelper.restoreRange(); + } + } + + trigger(editorContainer, 'selectionchanged'); + } + + isSelectionCheckPending = false; + } + + if (isSelectionCheckPending) { + return; + } + + isSelectionCheckPending = true; + + // Don't need to limit checking if browser supports the Selection API + if ('onselectionchange' in wysiwygDocument) { + check(); + } else { + setTimeout(check, 100); + } + }; + + /** + * Checks if the current node has changed and triggers + * the nodechanged event if it has + * @private + */ + checkNodeChanged = function () { + // check if node has changed + var oldNode, + node = rangeHelper.parentNode(); + + if (currentNode !== node) { + oldNode = currentNode; + currentNode = node; + currentBlockNode = rangeHelper.getFirstBlockParent(node); + + trigger(editorContainer, 'nodechanged', { + oldNode: oldNode, + newNode: currentNode + }); + } + }; + + /** + * Gets the current node that contains the selection/caret in + * WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentNode + * @memberOf SCEditor.prototype + */ + base.currentNode = function () { + return currentNode; + }; + + /** + * Gets the first block level node that contains the + * selection/caret in WYSIWYG mode. + * + * Will be null in sourceMode or if there is no selection. + * + * @return {?Node} + * @function + * @name currentBlockNode + * @memberOf SCEditor.prototype + * @since 1.4.4 + */ + base.currentBlockNode = function () { + return currentBlockNode; + }; + + /** + * Updates if buttons are active or not + * @private + */ + updateActiveButtons = function () { + var firstBlock, parent; + var activeClass = 'active'; + var doc = wysiwygDocument; + var isSource = base.sourceMode(); + + if (base.readOnly()) { + each(find(toolbar, activeClass), function (_, menuItem) { + removeClass(menuItem, activeClass); + }); + return; + } + + if (!isSource) { + parent = rangeHelper.parentNode(); + firstBlock = rangeHelper.getFirstBlockParent(parent); + } + + for (var j = 0; j < btnStateHandlers.length; j++) { + var state = 0; + var btn = toolbarButtons[btnStateHandlers[j].name]; + var stateFn = btnStateHandlers[j].state; + var isDisabled = (isSource && !btn._sceTxtMode) || + (!isSource && !btn._sceWysiwygMode); + + if (isString(stateFn)) { + if (!isSource) { + try { + state = doc.queryCommandEnabled(stateFn) ? 0 : -1; + + // eslint-disable-next-line max-depth + if (state > -1) { + state = doc.queryCommandState(stateFn) ? 1 : 0; + } + } catch (ex) {} + } + } else if (!isDisabled) { + state = stateFn.call(base, parent, firstBlock); + } + + toggleClass(btn, 'disabled', isDisabled || state < 0); + toggleClass(btn, activeClass, state > 0); + } + + if (icons && icons.update) { + icons.update(isSource, parent, firstBlock); + } + }; + + /** + * Handles any key press in the WYSIWYG editor + * + * @private + */ + handleKeyPress = function (e) { + // FF bug: https://bugzilla.mozilla.org/show_bug.cgi?id=501496 + if (e.defaultPrevented) { + return; + } + + base.closeDropDown(); + + // 13 = enter key + if (e.which === 13) { + var LIST_TAGS = 'li,ul,ol'; + + // "Fix" (cludge) for blocklevel elements being duplicated in some + // browsers when enter is pressed instead of inserting a newline + if (!is(currentBlockNode, LIST_TAGS) && + hasStyling(currentBlockNode)) { + + var br = createElement('br', {}, wysiwygDocument); + rangeHelper.insertNode(br); + + // Last <br> of a block will be collapsed so need to make sure + // the <br> that was inserted isn't the last node of a block. + var parent = br.parentNode; + var lastChild = parent.lastChild; + + // Sometimes an empty next node is created after the <br> + if (lastChild && lastChild.nodeType === TEXT_NODE && + lastChild.nodeValue === '') { + remove(lastChild); + lastChild = parent.lastChild; + } + + // If this is the last BR of a block and the previous + // sibling is inline then will need an extra BR. This + // is needed because the last BR of a block will be + // collapsed. Fixes issue #248 + if (!isInline(parent, true) && lastChild === br && + isInline(br.previousSibling)) { + rangeHelper.insertHTML('<br>'); + } + + e.preventDefault(); + } + } + }; + + /** + * Makes sure that if there is a code or quote tag at the + * end of the editor, that there is a new line after it. + * + * If there wasn't a new line at the end you wouldn't be able + * to enter any text after a code/quote tag + * @return {void} + * @private + */ + appendNewLine = function () { + // Check all nodes in reverse until either add a new line + // or reach a non-empty textnode or BR at which point can + // stop checking. + rTraverse(wysiwygBody, function (node) { + // Last block, add new line after if has styling + if (node.nodeType === ELEMENT_NODE && + !/inline/.test(css(node, 'display'))) { + + // Add line break after if has styling + if (!is(node, '.sceditor-nlf') && hasStyling(node)) { + var paragraph = createElement('p', {}, wysiwygDocument); + paragraph.className = 'sceditor-nlf'; + paragraph.innerHTML = '<br />'; + appendChild(wysiwygBody, paragraph); + return false; + } + } + + // Last non-empty text node or line break. + // No need to add line-break after them + if ((node.nodeType === 3 && !/^\s*$/.test(node.nodeValue)) || + is(node, 'br')) { + return false; + } + }); + }; + + /** + * Handles form reset event + * @private + */ + handleFormReset = function () { + base.val(original.value); + }; + + /** + * Handles any mousedown press in the WYSIWYG editor + * @private + */ + handleMouseDown = function () { + base.closeDropDown(); + }; + + /** + * Translates the string into the locale language. + * + * Replaces any {0}, {1}, {2}, ect. with the params provided. + * + * @param {string} str + * @param {...String} args + * @return {string} + * @function + * @name _ + * @memberOf SCEditor.prototype + */ + base._ = function () { + var undef, + args = arguments; + + if (locale && locale[args[0]]) { + args[0] = locale[args[0]]; + } + + return args[0].replace(/\{(\d+)\}/g, function (str, p1) { + return args[p1 - 0 + 1] !== undef ? + args[p1 - 0 + 1] : + '{' + p1 + '}'; + }); + }; + + /** + * Passes events on to any handlers + * @private + * @return void + */ + handleEvent = function (e) { + if (pluginManager) { + // Send event to all plugins + pluginManager.call(e.type + 'Event', e, base); + } + + // convert the event into a custom event to send + var name = (e.target === sourceEditor ? 'scesrc' : 'scewys') + e.type; + + if (eventHandlers[name]) { + eventHandlers[name].forEach(function (fn) { + fn.call(base, e); + }); + } + }; + + /** + * Binds a handler to the specified events + * + * This function only binds to a limited list of + * supported events. + * + * The supported events are: + * + * * keyup + * * keydown + * * Keypress + * * blur + * * focus + * * input + * * nodechanged - When the current node containing + * the selection changes in WYSIWYG mode + * * contextmenu + * * selectionchanged + * * valuechanged + * + * + * The events param should be a string containing the event(s) + * to bind this handler to. If multiple, they should be separated + * by spaces. + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name bind + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.bind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + var wysEvent = 'scewys' + events[i]; + var srcEvent = 'scesrc' + events[i]; + // Use custom events to allow passing the instance as the + // 2nd argument. + // Also allows unbinding without unbinding the editors own + // event handlers. + if (!excludeWysiwyg) { + eventHandlers[wysEvent] = eventHandlers[wysEvent] || []; + eventHandlers[wysEvent].push(handler); + } + + if (!excludeSource) { + eventHandlers[srcEvent] = eventHandlers[srcEvent] || []; + eventHandlers[srcEvent].push(handler); + } + + // Start sending value changed events + if (events[i] === 'valuechanged') { + triggerValueChanged.hasHandler = true; + } + } + } + + return base; + }; + + /** + * Unbinds an event that was bound using bind(). + * + * @param {string} events + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude unbinding this + * handler from the WYSIWYG editor + * @param {boolean} excludeSource if to exclude unbinding this + * handler from the source editor + * @return {this} + * @function + * @name unbind + * @memberOf SCEditor.prototype + * @since 1.4.1 + * @see bind + */ + base.unbind = function (events, handler, excludeWysiwyg, excludeSource) { + events = events.split(' '); + + var i = events.length; + while (i--) { + if (isFunction(handler)) { + if (!excludeWysiwyg) { + arrayRemove( + eventHandlers['scewys' + events[i]] || [], handler); + } + + if (!excludeSource) { + arrayRemove( + eventHandlers['scesrc' + events[i]] || [], handler); + } + } + } + + return base; + }; + + /** + * Blurs the editors input area + * + * @return {this} + * @function + * @name blur + * @memberOf SCEditor.prototype + * @since 1.3.6 + */ + /** + * Adds a handler to the editors blur event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name blur^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.blur = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('blur', handler, excludeWysiwyg, excludeSource); + } else if (!base.sourceMode()) { + wysiwygBody.blur(); + } else { + sourceEditor.blur(); + } + + return base; + }; + + /** + * Focuses the editors input area + * + * @return {this} + * @function + * @name focus + * @memberOf SCEditor.prototype + */ + /** + * Adds an event handler to the focus event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource if to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name focus^2 + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.focus = function (handler, excludeWysiwyg, excludeSource) { + if (isFunction(handler)) { + base.bind('focus', handler, excludeWysiwyg, excludeSource); + } else if (!base.inSourceMode()) { + // Already has focus so do nothing + if (find(wysiwygDocument, ':focus').length) { + return; + } + + var container; + var rng = rangeHelper.selectedRange(); + + // Fix FF bug where it shows the cursor in the wrong place + // if the editor hasn't had focus before. See issue #393 + if (!currentSelection) { + autofocus(true); + } + + // Check if cursor is set after a BR when the BR is the only + // child of the parent. In Firefox this causes a line break + // to occur when something is typed. See issue #321 + if (rng && rng.endOffset === 1 && rng.collapsed) { + container = rng.endContainer; + + if (container && container.childNodes.length === 1 && + is(container.firstChild, 'br')) { + rng.setStartBefore(container.firstChild); + rng.collapse(true); + rangeHelper.selectRange(rng); + } + } + + wysiwygWindow.focus(); + wysiwygBody.focus(); + } else { + sourceEditor.focus(); + } + + updateActiveButtons(); + + return base; + }; + + /** + * Adds a handler to the key down event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyDown + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyDown = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keydown', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key press event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyPress + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyPress = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('keypress', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the key up event + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name keyUp + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.keyUp = function (handler, excludeWysiwyg, excludeSource) { + return base.bind('keyup', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Adds a handler to the node changed event. + * + * Happens whenever the node containing the selection/caret + * changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name nodeChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.nodeChanged = function (handler) { + return base.bind('nodechanged', handler, false, true); + }; + + /** + * Adds a handler to the selection changed event + * + * Happens whenever the selection changes in WYSIWYG mode. + * + * @param {Function} handler + * @return {this} + * @function + * @name selectionChanged + * @memberOf SCEditor.prototype + * @since 1.4.1 + */ + base.selectionChanged = function (handler) { + return base.bind('selectionchanged', handler, false, true); + }; + + /** + * Adds a handler to the value changed event + * + * Happens whenever the current editor value changes. + * + * Whenever anything is inserted, the value changed or + * 1.5 secs after text is typed. If a space is typed it will + * cause the event to be triggered immediately instead of + * after 1.5 seconds + * + * @param {Function} handler + * @param {boolean} excludeWysiwyg If to exclude adding this handler + * to the WYSIWYG editor + * @param {boolean} excludeSource If to exclude adding this handler + * to the source editor + * @return {this} + * @function + * @name valueChanged + * @memberOf SCEditor.prototype + * @since 1.4.5 + */ + base.valueChanged = function (handler, excludeWysiwyg, excludeSource) { + return base + .bind('valuechanged', handler, excludeWysiwyg, excludeSource); + }; + + /** + * Emoticons keypress handler + * @private + */ + emoticonsKeyPress = function (e) { + var replacedEmoticon, + cachePos = 0, + emoticonsCache = base.emoticonsCache, + curChar = String.fromCharCode(e.which); + + // TODO: Make configurable + if (closest(currentBlockNode, 'code')) { + return; + } + + if (!emoticonsCache) { + emoticonsCache = []; + + each(allEmoticons, function (key, html) { + emoticonsCache[cachePos++] = [key, html]; + }); + + emoticonsCache.sort(function (a, b) { + return a[0].length - b[0].length; + }); + + base.emoticonsCache = emoticonsCache; + base.longestEmoticonCode = + emoticonsCache[emoticonsCache.length - 1][0].length; + } + + replacedEmoticon = rangeHelper.replaceKeyword( + base.emoticonsCache, + true, + true, + base.longestEmoticonCode, + options.emoticonsCompat, + curChar + ); + + if (replacedEmoticon) { + if (!options.emoticonsCompat || !/^\s$/.test(curChar)) { + e.preventDefault(); + } + } + }; + + /** + * Makes sure emoticons are surrounded by whitespace + * @private + */ + emoticonsCheckWhitespace = function () { + checkWhitespace(currentBlockNode, rangeHelper); + }; + + /** + * Gets if emoticons are currently enabled + * @return {boolean} + * @function + * @name emoticons + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + /** + * Enables/disables emoticons + * + * @param {boolean} enable + * @return {this} + * @function + * @name emoticons^2 + * @memberOf SCEditor.prototype + * @since 1.4.2 + */ + base.emoticons = function (enable) { + if (!enable && enable !== false) { + return options.emoticonsEnabled; + } + + options.emoticonsEnabled = enable; + + if (enable) { + on(wysiwygBody, 'keypress', emoticonsKeyPress); + + if (!base.sourceMode()) { + rangeHelper.saveRange(); + + replaceEmoticons(); + triggerValueChanged(false); + + rangeHelper.restoreRange(); + } + } else { + var emoticons = + find(wysiwygBody, 'img[data-sceditor-emoticon]'); + + each(emoticons, function (_, img) { + var text = data(img, 'sceditor-emoticon'); + var textNode = wysiwygDocument.createTextNode(text); + img.parentNode.replaceChild(textNode, img); + }); + + off(wysiwygBody, 'keypress', emoticonsKeyPress); + + triggerValueChanged(); + } + + return base; + }; + + /** + * Gets the current WYSIWYG editors inline CSS + * + * @return {string} + * @function + * @name css + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + /** + * Sets inline CSS for the WYSIWYG editor + * + * @param {string} css + * @return {this} + * @function + * @name css^2 + * @memberOf SCEditor.prototype + * @since 1.4.3 + */ + base.css = function (css) { + if (!inlineCss) { + inlineCss = createElement('style', { + id: 'inline' + }, wysiwygDocument); + + appendChild(wysiwygDocument.head, inlineCss); + } + + if (!isString(css)) { + return inlineCss.styleSheet ? + inlineCss.styleSheet.cssText : inlineCss.innerHTML; + } + + if (inlineCss.styleSheet) { + inlineCss.styleSheet.cssText = css; + } else { + inlineCss.innerHTML = css; + } + + return base; + }; + + /** + * Handles the keydown event, used for shortcuts + * @private + */ + handleKeyDown = function (e) { + var shortcut = [], + SHIFT_KEYS = { + '`': '~', + '1': '!', + '2': '@', + '3': '#', + '4': '$', + '5': '%', + '6': '^', + '7': '&', + '8': '*', + '9': '(', + '0': ')', + '-': '_', + '=': '+', + ';': ': ', + '\'': '"', + ',': '<', + '.': '>', + '/': '?', + '\\': '|', + '[': '{', + ']': '}' + }, + SPECIAL_KEYS = { + 8: 'backspace', + 9: 'tab', + 13: 'enter', + 19: 'pause', + 20: 'capslock', + 27: 'esc', + 32: 'space', + 33: 'pageup', + 34: 'pagedown', + 35: 'end', + 36: 'home', + 37: 'left', + 38: 'up', + 39: 'right', + 40: 'down', + 45: 'insert', + 46: 'del', + 91: 'win', + 92: 'win', + 93: 'select', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9', + 106: '*', + 107: '+', + 109: '-', + 110: '.', + 111: '/', + 112: 'f1', + 113: 'f2', + 114: 'f3', + 115: 'f4', + 116: 'f5', + 117: 'f6', + 118: 'f7', + 119: 'f8', + 120: 'f9', + 121: 'f10', + 122: 'f11', + 123: 'f12', + 144: 'numlock', + 145: 'scrolllock', + 186: ';', + 187: '=', + 188: ',', + 189: '-', + 190: '.', + 191: '/', + 192: '`', + 219: '[', + 220: '\\', + 221: ']', + 222: '\'' + }, + NUMPAD_SHIFT_KEYS = { + 109: '-', + 110: 'del', + 111: '/', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9' + }, + which = e.which, + character = SPECIAL_KEYS[which] || + String.fromCharCode(which).toLowerCase(); + + if (e.ctrlKey || e.metaKey) { + shortcut.push('ctrl'); + } + + if (e.altKey) { + shortcut.push('alt'); + } + + if (e.shiftKey) { + shortcut.push('shift'); + + if (NUMPAD_SHIFT_KEYS[which]) { + character = NUMPAD_SHIFT_KEYS[which]; + } else if (SHIFT_KEYS[character]) { + character = SHIFT_KEYS[character]; + } + } + + // Shift is 16, ctrl is 17 and alt is 18 + if (character && (which < 16 || which > 18)) { + shortcut.push(character); + } + + shortcut = shortcut.join('+'); + if (shortcutHandlers[shortcut] && + shortcutHandlers[shortcut].call(base) === false) { + + e.stopPropagation(); + e.preventDefault(); + } + }; + + /** + * Adds a shortcut handler to the editor + * @param {string} shortcut + * @param {String|Function} cmd + * @return {sceditor} + */ + base.addShortcut = function (shortcut, cmd) { + shortcut = shortcut.toLowerCase(); + + if (isString(cmd)) { + shortcutHandlers[shortcut] = function () { + handleCommand(toolbarButtons[cmd], base.commands[cmd]); + + return false; + }; + } else { + shortcutHandlers[shortcut] = cmd; + } + + return base; + }; + + /** + * Removes a shortcut handler + * @param {string} shortcut + * @return {sceditor} + */ + base.removeShortcut = function (shortcut) { + delete shortcutHandlers[shortcut.toLowerCase()]; + + return base; + }; + + /** + * Handles the backspace key press + * + * Will remove block styling like quotes/code ect if at the start. + * @private + */ + handleBackSpace = function (e) { + var node, offset, range, parent; + + // 8 is the backspace key + if (options.disableBlockRemove || e.which !== 8 || + !(range = rangeHelper.selectedRange())) { + return; + } + + node = range.startContainer; + offset = range.startOffset; + + if (offset !== 0 || !(parent = currentStyledBlockNode()) || + is(parent, 'body')) { + return; + } + + while (node !== parent) { + while (node.previousSibling) { + node = node.previousSibling; + + // Everything but empty text nodes before the cursor + // should prevent the style from being removed + if (node.nodeType !== TEXT_NODE || node.nodeValue) { + return; + } + } + + if (!(node = node.parentNode)) { + return; + } + } + + // The backspace was pressed at the start of + // the container so clear the style + base.clearBlockFormatting(parent); + e.preventDefault(); + }; + + /** + * Gets the first styled block node that contains the cursor + * @return {HTMLElement} + */ + currentStyledBlockNode = function () { + var block = currentBlockNode; + + while (!hasStyling(block) || isInline(block, true)) { + if (!(block = block.parentNode) || is(block, 'body')) { + return; + } + } + + return block; + }; + + /** + * Clears the formatting of the passed block element. + * + * If block is false, if will clear the styling of the first + * block level element that contains the cursor. + * @param {HTMLElement} block + * @since 1.4.4 + */ + base.clearBlockFormatting = function (block) { + block = block || currentStyledBlockNode(); + + if (!block || is(block, 'body')) { + return base; + } + + rangeHelper.saveRange(); + + block.className = ''; + + attr(block, 'style', ''); + + if (!is(block, 'p,div,td')) { + convertElement(block, 'p'); + } + + rangeHelper.restoreRange(); + return base; + }; + + /** + * Triggers the valueChanged signal if there is + * a plugin that handles it. + * + * If rangeHelper.saveRange() has already been + * called, then saveRange should be set to false + * to prevent the range being saved twice. + * + * @since 1.4.5 + * @param {boolean} saveRange If to call rangeHelper.saveRange(). + * @private + */ + triggerValueChanged = function (saveRange) { + if (!pluginManager || + (!pluginManager.hasHandler('valuechangedEvent') && + !triggerValueChanged.hasHandler)) { + return; + } + + var currentHtml, + sourceMode = base.sourceMode(), + hasSelection = !sourceMode && rangeHelper.hasSelection(); + + // Composition end isn't guaranteed to fire but must have + // ended when triggerValueChanged() is called so reset it + isComposing = false; + + // Don't need to save the range if sceditor-start-marker + // is present as the range is already saved + saveRange = saveRange !== false && + !wysiwygDocument.getElementById('sceditor-start-marker'); + + // Clear any current timeout as it's now been triggered + if (valueChangedKeyUpTimer) { + clearTimeout(valueChangedKeyUpTimer); + valueChangedKeyUpTimer = false; + } + + if (hasSelection && saveRange) { + rangeHelper.saveRange(); + } + + currentHtml = sourceMode ? sourceEditor.value : wysiwygBody.innerHTML; + + // Only trigger if something has actually changed. + if (currentHtml !== triggerValueChanged.lastVal) { + triggerValueChanged.lastVal = currentHtml; + + trigger(editorContainer, 'valuechanged', { + rawValue: sourceMode ? base.val() : currentHtml + }); + } + + if (hasSelection && saveRange) { + rangeHelper.removeMarkers(); + } + }; + + /** + * Should be called whenever there is a blur event + * @private + */ + valueChangedBlur = function () { + if (valueChangedKeyUpTimer) { + triggerValueChanged(); + } + }; + + /** + * Should be called whenever there is a keypress event + * @param {Event} e The keypress event + * @private + */ + valueChangedKeyUp = function (e) { + var which = e.which, + lastChar = valueChangedKeyUp.lastChar, + lastWasSpace = (lastChar === 13 || lastChar === 32), + lastWasDelete = (lastChar === 8 || lastChar === 46); + + valueChangedKeyUp.lastChar = which; + + if (isComposing) { + return; + } + + // 13 = return & 32 = space + if (which === 13 || which === 32) { + if (!lastWasSpace) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + // 8 = backspace & 46 = del + } else if (which === 8 || which === 46) { + if (!lastWasDelete) { + triggerValueChanged(); + } else { + valueChangedKeyUp.triggerNext = true; + } + } else if (valueChangedKeyUp.triggerNext) { + triggerValueChanged(); + valueChangedKeyUp.triggerNext = false; + } + + // Clear the previous timeout and set a new one. + clearTimeout(valueChangedKeyUpTimer); + + // Trigger the event 1.5s after the last keypress if space + // isn't pressed. This might need to be lowered, will need + // to look into what the slowest average Chars Per Min is. + valueChangedKeyUpTimer = setTimeout(function () { + if (!isComposing) { + triggerValueChanged(); + } + }, 1500); + }; + + handleComposition = function (e) { + isComposing = /start/i.test(e.type); + + if (!isComposing) { + triggerValueChanged(); + } + }; + + autoUpdate = function () { + base.updateOriginal(); + }; + + // run the initializer + init(); + } + + /** + * Map containing the loaded SCEditor locales + * @type {Object} + * @name locale + * @memberOf sceditor + */ + SCEditor.locale = {}; + + SCEditor.formats = {}; + SCEditor.icons = {}; + + + /** + * Static command helper class + * @class command + * @name sceditor.command + */ + SCEditor.command = + /** @lends sceditor.command */ + { + /** + * Gets a command + * + * @param {string} name + * @return {Object|null} + * @since v1.3.5 + */ + get: function (name) { + return defaultCmds[name] || null; + }, + + /** + * <p>Adds a command to the editor or updates an existing + * command if a command with the specified name already exists.</p> + * + * <p>Once a command is add it can be included in the toolbar by + * adding it's name to the toolbar option in the constructor. It + * can also be executed manually by calling + * {@link sceditor.execCommand}</p> + * + * @example + * SCEditor.command.set("hello", + * { + * exec: function () { + * alert("Hello World!"); + * } + * }); + * + * @param {string} name + * @param {Object} cmd + * @return {this|false} Returns false if name or cmd is false + * @since v1.3.5 + */ + set: function (name, cmd) { + if (!name || !cmd) { + return false; + } + + // merge any existing command properties + cmd = extend(defaultCmds[name] || {}, cmd); + + cmd.remove = function () { + SCEditor.command.remove(name); + }; + + defaultCmds[name] = cmd; + return this; + }, + + /** + * Removes a command + * + * @param {string} name + * @return {this} + * @since v1.3.5 + */ + remove: function (name) { + if (defaultCmds[name]) { + delete defaultCmds[name]; + } + + return this; + } + }; + + /** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * @fileoverview SCEditor - A lightweight WYSIWYG BBCode and HTML editor + * @author Sam Clarke + */ + + + window.sceditor = { + command: SCEditor.command, + commands: defaultCmds, + defaultOptions: defaultOptions, + + ios: ios, + isWysiwygSupported: isWysiwygSupported, + + regexEscape: regex, + escapeEntities: entities, + escapeUriScheme: uriScheme, + + dom: { + css: css, + attr: attr, + removeAttr: removeAttr, + is: is, + closest: closest, + width: width, + height: height, + traverse: traverse, + rTraverse: rTraverse, + parseHTML: parseHTML, + hasStyling: hasStyling, + convertElement: convertElement, + blockLevelList: blockLevelList, + canHaveChildren: canHaveChildren, + isInline: isInline, + copyCSS: copyCSS, + fixNesting: fixNesting, + findCommonAncestor: findCommonAncestor, + getSibling: getSibling, + removeWhiteSpace: removeWhiteSpace, + extractContents: extractContents, + getOffset: getOffset, + getStyle: getStyle, + hasStyle: hasStyle + }, + locale: SCEditor.locale, + icons: SCEditor.icons, + utils: { + each: each, + isEmptyObject: isEmptyObject, + extend: extend + }, + plugins: PluginManager.plugins, + formats: SCEditor.formats, + create: function (textarea, options) { + options = options || {}; + + // Don't allow the editor to be initialised + // on it's own source editor + if (parent(textarea, '.sceditor-container')) { + return; + } + + if (options.runWithoutWysiwygSupport || isWysiwygSupported) { + /*eslint no-new: off*/ + (new SCEditor(textarea, options)); + } + }, + instance: function (textarea) { + return textarea._sceditor; + } + }; + +}());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/themes/content/default.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,85 @@ +/*! SCEditor | (C) 2011-2013, Sam Clarke | sceditor.com/license */ +html, body, p, code:before, table { + margin: 0; + padding: 0; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #111; + line-height: 1.25; + overflow: visible; +} +html { + height: 100%; +} +.ios { + /* Needed for iOS scrolling bug fix */ + overflow: auto; + -webkit-overflow-scrolling: touch; +} +.ios body { + /* Needed for iOS scrolling bug fix */ + position: relative; + overflow: auto; +} +body { + /* Needed to make sure body covers the whole editor and that + long lines don't cause horizontal scrolling */ + min-height: 100%; + word-wrap: break-word; +} + +body.placeholder::before { + content: attr(placeholder); + color: #555; + font-style: italic; +} + +ul, ol { + margin-top: 0; + margin-bottom: 0; + padding-top: 0; + padding-bottom: 0; +} + +table, td { + border: 1px dotted #000; + empty-cells: show; +} + +table td { + min-width: 5px; +} + +code { + display: block; + background: #f1f1f1; + white-space: pre; + padding: 1em; + text-align: left; + margin: .25em 0; + direction: ltr; +} + +blockquote { + background: #fff7d9; + margin: .25em 0; + border-left: .3em solid #f4e59f; + padding: .5em .5em .5em .75em; +} +blockquote cite { + font-weight: bold; + display: block; + font-size: 1em; + margin: 0 -.5em .25em -.75em; + padding: 0 .5em .15em .75em; + border-bottom: 1px solid #f4e59f; +} + +h1, h2, h3, h4, h5, h6 { + padding: 0; margin: 0; +} + +/* Prevent empty paragraphs from collapsing */ +div, p { + min-height: 1.25em; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/themes/default.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,530 @@ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */ +/** + * Default SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2011-16, Sam Clarke + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +div.sceditor-grip, +.sceditor-button div { + background-image: url("famfamfam.png"); + background-repeat: no-repeat; + width: 16px; + height: 16px; +} +.sceditor-button-youtube div { + background-position: 0px 0px; +} +.sceditor-button-link div { + background-position: 0px -16px; +} +.sceditor-button-unlink div { + background-position: 0px -32px; +} +.sceditor-button-underline div { + background-position: 0px -48px; +} +.sceditor-button-time div { + background-position: 0px -64px; +} +.sceditor-button-table div { + background-position: 0px -80px; +} +.sceditor-button-superscript div { + background-position: 0px -96px; +} +.sceditor-button-subscript div { + background-position: 0px -112px; +} +.sceditor-button-strike div { + background-position: 0px -128px; +} +.sceditor-button-source div { + background-position: 0px -144px; +} +.sceditor-button-size div { + background-position: 0px -160px; +} +.sceditor-button-rtl div { + background-position: 0px -176px; +} +.sceditor-button-right div { + background-position: 0px -192px; +} +.sceditor-button-removeformat div { + background-position: 0px -208px; +} +.sceditor-button-quote div { + background-position: 0px -224px; +} +.sceditor-button-print div { + background-position: 0px -240px; +} +.sceditor-button-pastetext div { + background-position: 0px -256px; +} +.sceditor-button-paste div { + background-position: 0px -272px; +} +.sceditor-button-outdent div { + background-position: 0px -288px; +} +.sceditor-button-orderedlist div { + background-position: 0px -304px; +} +.sceditor-button-maximize div { + background-position: 0px -320px; +} +.sceditor-button-ltr div { + background-position: 0px -336px; +} +.sceditor-button-left div { + background-position: 0px -352px; +} +.sceditor-button-justify div { + background-position: 0px -368px; +} +.sceditor-button-italic div { + background-position: 0px -384px; +} +.sceditor-button-indent div { + background-position: 0px -400px; +} +.sceditor-button-image div { + background-position: 0px -416px; +} +.sceditor-button-horizontalrule div { + background-position: 0px -432px; +} +.sceditor-button-format div { + background-position: 0px -448px; +} +.sceditor-button-font div { + background-position: 0px -464px; +} +.sceditor-button-emoticon div { + background-position: 0px -480px; +} +.sceditor-button-email div { + background-position: 0px -496px; +} +.sceditor-button-date div { + background-position: 0px -512px; +} +.sceditor-button-cut div { + background-position: 0px -528px; +} +.sceditor-button-copy div { + background-position: 0px -544px; +} +.sceditor-button-color div { + background-position: 0px -560px; +} +.sceditor-button-code div { + background-position: 0px -576px; +} +.sceditor-button-center div { + background-position: 0px -592px; +} +.sceditor-button-bulletlist div { + background-position: 0px -608px; +} +.sceditor-button-bold div { + background-position: 0px -624px; +} +div.sceditor-grip { + background-position: 0px -640px; + width: 10px; + height: 10px; +} +.rtl div.sceditor-grip { + background-position: 0px -650px; +} +/** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +/*--------------------------------------------------- + LESS Elements 0.7 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +.sceditor-container { + display: -ms-flexbox; + display: flex; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + background: #fff; + border: 1px solid #d9d9d9; + font-size: 13px; + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + color: #333; + line-height: 1; + font-weight: bold; + height: 250px; + border-radius: 4px; + background-clip: padding-box; +} +.sceditor-container *, +.sceditor-container *:before, +.sceditor-container *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.sceditor-container, +.sceditor-container div, +div.sceditor-dropdown, +div.sceditor-dropdown div { + padding: 0; + margin: 0; + z-index: 3; +} +.sceditor-container iframe, +.sceditor-container textarea { + display: block; + -ms-flex: 1 1 0%; + flex: 1 1 0%; + line-height: 1.25; + border: 0; + outline: none; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #111; + padding: 0; + margin: 5px; + resize: none; + background: #fff; + height: auto !important; + width: auto !important; + width: calc(100% - 10px) !important; + min-height: 1px; +} +.sceditor-container textarea { + margin: 7px 5px; +} +div.sceditor-dnd-cover { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: rgba(255, 255, 255, 0.2); + border: 5px dashed #aaa; + z-index: 200; + font-size: 2em; + text-align: center; + color: #aaa; +} +div.sceditor-dnd-cover p { + position: relative; + top: 45%; + pointer-events: none; +} +div.sceditor-resize-cover { + position: absolute; + top: 0; + left: 0; + background: #000; + width: 100%; + height: 100%; + z-index: 10; + opacity: 0.3; +} +div.sceditor-grip { + overflow: hidden; + width: 10px; + height: 10px; + cursor: pointer; + position: absolute; + bottom: 0; + right: 0; + z-index: 3; + line-height: 0; +} +div.sceditor-grip.has-icon { + background-image: none; +} +.sceditor-maximize { + position: fixed; + top: 0; + left: 0; + height: 100% !important; + width: 100% !important; + border-radius: 0; + background-clip: padding-box; + z-index: 2000; +} +html.sceditor-maximize, +body.sceditor-maximize { + height: 100%; + width: 100%; + padding: 0; + margin: 0; + overflow: hidden; +} +.sceditor-maximize div.sceditor-grip { + display: none; +} +.sceditor-maximize div.sceditor-toolbar { + border-radius: 0; + background-clip: padding-box; +} +/** + * Dropdown styleing + */ +div.sceditor-dropdown { + position: absolute; + border: 1px solid #ccc; + background: #fff; + z-index: 4000; + padding: 10px; + font-weight: normal; + font-size: 15px; + border-radius: 2px; + background-clip: padding-box; + box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2); +} +div.sceditor-dropdown *, +div.sceditor-dropdown *:before, +div.sceditor-dropdown *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +div.sceditor-dropdown a, +div.sceditor-dropdown a:link { + color: #333; +} +div.sceditor-dropdown form { + margin: 0; +} +div.sceditor-dropdown label { + display: block; + font-weight: bold; + color: #3c3c3c; + padding: 4px 0; +} +div.sceditor-dropdown input, +div.sceditor-dropdown textarea { + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + outline: 0; + padding: 4px; + border: 1px solid #ccc; + border-top-color: #888; + margin: 0 0 0.75em; + border-radius: 1px; + background-clip: padding-box; +} +div.sceditor-dropdown textarea { + padding: 6px; +} +div.sceditor-dropdown input:focus, +div.sceditor-dropdown textarea:focus { + border-color: #aaa; + border-top-color: #666; + box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1); +} +div.sceditor-dropdown .button { + font-weight: bold; + color: #444; + padding: 6px 12px; + background: #ececec; + border: solid 1px #ccc; + border-radius: 2px; + background-clip: padding-box; + cursor: pointer; + margin: 0.3em 0 0; +} +div.sceditor-dropdown .button:hover { + background: #f3f3f3; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); +} +div.sceditor-font-picker, +div.sceditor-fontsize-picker, +div.sceditor-format { + padding: 6px 0; +} +div.sceditor-color-picker { + padding: 4px; +} +div.sceditor-emoticons, +div.sceditor-more-emoticons { + padding: 0; +} +.sceditor-pastetext textarea { + border: 1px solid #bbb; + width: 20em; +} +.sceditor-emoticons img, +.sceditor-more-emoticons img { + padding: 0; + cursor: pointer; + margin: 2px; +} +.sceditor-more { + border-top: 1px solid #bbb; + display: block; + text-align: center; + cursor: pointer; + font-weight: bold; + padding: 6px 0; +} +.sceditor-dropdown a:hover { + background: #eee; +} +.sceditor-fontsize-option, +.sceditor-font-option, +.sceditor-format a { + display: block; + padding: 7px 10px; + cursor: pointer; + text-decoration: none; + color: #222; +} +.sceditor-fontsize-option { + padding: 7px 13px; +} +.sceditor-color-column { + float: left; +} +.sceditor-color-option { + display: block; + border: 2px solid #fff; + height: 18px; + width: 18px; + overflow: hidden; +} +.sceditor-color-option:hover { + border: 1px solid #aaa; +} +/** + * Toolbar styleing + */ +div.sceditor-toolbar { + flex-shrink: 0; + overflow: hidden; + padding: 3px 5px 2px; + background: #f7f7f7; + border-bottom: 1px solid #c0c0c0; + line-height: 0; + text-align: left; + user-select: none; + border-radius: 3px 3px 0 0; + background-clip: padding-box; +} +div.sceditor-group { + display: inline-block; + background: #ddd; + margin: 1px 5px 1px 0; + padding: 1px; + border-bottom: 1px solid #aaa; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button { + float: left; + cursor: pointer; + padding: 3px 5px; + width: 16px; + height: 20px; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2); +} +.sceditor-button:active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2), inset 0 0 8px rgba(0,0,0,0.3); +} +.sceditor-button.disabled:hover { + background: inherit; + cursor: default; + box-shadow: none; +} +.sceditor-button, +.sceditor-button div { + display: block; +} +.sceditor-button svg { + display: inline-block; + height: 16px; + width: 16px; + margin: 2px 0; + fill: #111; + text-decoration: none; + pointer-events: none; + line-height: 1; +} +.sceditor-button.disabled svg { + fill: #888; +} +.sceditor-button div { + display: inline-block; + margin: 2px 0; + padding: 0; + overflow: hidden; + line-height: 0; + font-size: 0; + color: transparent; +} +.sceditor-button.has-icon div { + display: none; +} +.sceditor-button.disabled div { + opacity: 0.3; +} +.text .sceditor-button, +.text .sceditor-button div, +.sceditor-button.text, +.sceditor-button.text div, +.text-icon .sceditor-button, +.text-icon .sceditor-button div, +.sceditor-button.text-icon, +.sceditor-button.text-icon div { + display: inline-block; + width: auto; + line-height: 16px; + font-size: 1em; + color: inherit; + text-indent: 0; +} +.text-icon .sceditor-button.has-icon div, +.sceditor-button.has-icon div, +.text .sceditor-button div, +.sceditor-button.text div { + padding: 0 2px; + background: none; +} +.text .sceditor-button svg, +.sceditor-button.text svg { + display: none; +} +.text-icon .sceditor-button div, +.sceditor-button.text-icon div { + padding: 0 2px 0 20px; +} +.rtl div.sceditor-toolbar { + text-align: right; +} +.rtl .sceditor-button { + float: right; +} +.rtl div.sceditor-grip { + right: auto; + left: 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/themes/defaultdark.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,548 @@ +/*! SCEditor | (C) 2017, Sam Clarke | sceditor.com/license */ +/** + * Default SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +div.sceditor-grip, +.sceditor-button div { + background-image: url("famfamfam.png"); + background-repeat: no-repeat; + width: 16px; + height: 16px; +} +.sceditor-button-youtube div { + background-position: 0px 0px; +} +.sceditor-button-link div { + background-position: 0px -16px; +} +.sceditor-button-unlink div { + background-position: 0px -32px; +} +.sceditor-button-underline div { + background-position: 0px -48px; +} +.sceditor-button-time div { + background-position: 0px -64px; +} +.sceditor-button-table div { + background-position: 0px -80px; +} +.sceditor-button-superscript div { + background-position: 0px -96px; +} +.sceditor-button-subscript div { + background-position: 0px -112px; +} +.sceditor-button-strike div { + background-position: 0px -128px; +} +.sceditor-button-source div { + background-position: 0px -144px; +} +.sceditor-button-size div { + background-position: 0px -160px; +} +.sceditor-button-rtl div { + background-position: 0px -176px; +} +.sceditor-button-right div { + background-position: 0px -192px; +} +.sceditor-button-removeformat div { + background-position: 0px -208px; +} +.sceditor-button-quote div { + background-position: 0px -224px; +} +.sceditor-button-print div { + background-position: 0px -240px; +} +.sceditor-button-pastetext div { + background-position: 0px -256px; +} +.sceditor-button-paste div { + background-position: 0px -272px; +} +.sceditor-button-outdent div { + background-position: 0px -288px; +} +.sceditor-button-orderedlist div { + background-position: 0px -304px; +} +.sceditor-button-maximize div { + background-position: 0px -320px; +} +.sceditor-button-ltr div { + background-position: 0px -336px; +} +.sceditor-button-left div { + background-position: 0px -352px; +} +.sceditor-button-justify div { + background-position: 0px -368px; +} +.sceditor-button-italic div { + background-position: 0px -384px; +} +.sceditor-button-indent div { + background-position: 0px -400px; +} +.sceditor-button-image div { + background-position: 0px -416px; +} +.sceditor-button-horizontalrule div { + background-position: 0px -432px; +} +.sceditor-button-format div { + background-position: 0px -448px; +} +.sceditor-button-font div { + background-position: 0px -464px; +} +.sceditor-button-emoticon div { + background-position: 0px -480px; +} +.sceditor-button-email div { + background-position: 0px -496px; +} +.sceditor-button-date div { + background-position: 0px -512px; +} +.sceditor-button-cut div { + background-position: 0px -528px; +} +.sceditor-button-copy div { + background-position: 0px -544px; +} +.sceditor-button-color div { + background-position: 0px -560px; +} +.sceditor-button-code div { + background-position: 0px -576px; +} +.sceditor-button-center div { + background-position: 0px -592px; +} +.sceditor-button-bulletlist div { + background-position: 0px -608px; +} +.sceditor-button-bold div { + background-position: 0px -624px; +} +div.sceditor-grip { + background-position: 0px -640px; + width: 10px; + height: 10px; +} +.rtl div.sceditor-grip { + background-position: 0px -650px; +} +/** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +/*--------------------------------------------------- + LESS Elements 0.7 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +.sceditor-container { + display: -ms-flexbox; + display: flex; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + background: #fff; + border: 1px solid #d9d9d9; + font-size: 13px; + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + color: #333; + line-height: 1; + font-weight: bold; + height: 250px; + border-radius: 4px; + background-clip: padding-box; +} +.sceditor-container *, +.sceditor-container *:before, +.sceditor-container *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.sceditor-container, +.sceditor-container div, +div.sceditor-dropdown, +div.sceditor-dropdown div { + padding: 0; + margin: 0; + z-index: 3; +} +.sceditor-container iframe, +.sceditor-container textarea { + display: block; + -ms-flex: 1 1 0%; + flex: 1 1 0%; + line-height: 1.25; + border: 0; + outline: none; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #111; + padding: 0; + margin: 5px; + resize: none; + background: #fff; + height: auto !important; + width: auto !important; + width: calc(100% - 10px) !important; + min-height: 1px; +} +.sceditor-container textarea { + margin: 7px 5px; +} +div.sceditor-dnd-cover { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: rgba(255, 255, 255, 0.2); + border: 5px dashed #aaa; + z-index: 200; + font-size: 2em; + text-align: center; + color: #aaa; +} +div.sceditor-dnd-cover p { + position: relative; + top: 45%; + pointer-events: none; +} +div.sceditor-resize-cover { + position: absolute; + top: 0; + left: 0; + background: #000; + width: 100%; + height: 100%; + z-index: 10; + opacity: 0.3; +} +div.sceditor-grip { + overflow: hidden; + width: 10px; + height: 10px; + cursor: pointer; + position: absolute; + bottom: 0; + right: 0; + z-index: 3; + line-height: 0; +} +div.sceditor-grip.has-icon { + background-image: none; +} +.sceditor-maximize { + position: fixed; + top: 0; + left: 0; + height: 100% !important; + width: 100% !important; + border-radius: 0; + background-clip: padding-box; + z-index: 2000; +} +html.sceditor-maximize, +body.sceditor-maximize { + height: 100%; + width: 100%; + padding: 0; + margin: 0; + overflow: hidden; +} +.sceditor-maximize div.sceditor-grip { + display: none; +} +.sceditor-maximize div.sceditor-toolbar { + border-radius: 0; + background-clip: padding-box; +} +/** + * Dropdown styleing + */ +div.sceditor-dropdown { + position: absolute; + border: 1px solid #ccc; + background: #fff; + z-index: 4000; + padding: 10px; + font-weight: normal; + font-size: 15px; + border-radius: 2px; + background-clip: padding-box; + box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2); +} +div.sceditor-dropdown *, +div.sceditor-dropdown *:before, +div.sceditor-dropdown *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +div.sceditor-dropdown a, +div.sceditor-dropdown a:link { + color: #333; +} +div.sceditor-dropdown form { + margin: 0; +} +div.sceditor-dropdown label { + display: block; + font-weight: bold; + color: #3c3c3c; + padding: 4px 0; +} +div.sceditor-dropdown input, +div.sceditor-dropdown textarea { + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + outline: 0; + padding: 4px; + border: 1px solid #ccc; + border-top-color: #888; + margin: 0 0 0.75em; + border-radius: 1px; + background-clip: padding-box; +} +div.sceditor-dropdown textarea { + padding: 6px; +} +div.sceditor-dropdown input:focus, +div.sceditor-dropdown textarea:focus { + border-color: #aaa; + border-top-color: #666; + box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1); +} +div.sceditor-dropdown .button { + font-weight: bold; + color: #444; + padding: 6px 12px; + background: #ececec; + border: solid 1px #ccc; + border-radius: 2px; + background-clip: padding-box; + cursor: pointer; + margin: 0.3em 0 0; +} +div.sceditor-dropdown .button:hover { + background: #f3f3f3; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); +} +div.sceditor-font-picker, +div.sceditor-fontsize-picker, +div.sceditor-format { + padding: 6px 0; +} +div.sceditor-color-picker { + padding: 4px; +} +div.sceditor-emoticons, +div.sceditor-more-emoticons { + padding: 0; +} +.sceditor-pastetext textarea { + border: 1px solid #bbb; + width: 20em; +} +.sceditor-emoticons img, +.sceditor-more-emoticons img { + padding: 0; + cursor: pointer; + margin: 2px; +} +.sceditor-more { + border-top: 1px solid #bbb; + display: block; + text-align: center; + cursor: pointer; + font-weight: bold; + padding: 6px 0; +} +.sceditor-dropdown a:hover { + background: #eee; +} +.sceditor-fontsize-option, +.sceditor-font-option, +.sceditor-format a { + display: block; + padding: 7px 10px; + cursor: pointer; + text-decoration: none; + color: #222; +} +.sceditor-fontsize-option { + padding: 7px 13px; +} +.sceditor-color-column { + float: left; +} +.sceditor-color-option { + display: block; + border: 2px solid #fff; + height: 18px; + width: 18px; + overflow: hidden; +} +.sceditor-color-option:hover { + border: 1px solid #aaa; +} +/** + * Toolbar styleing + */ +div.sceditor-toolbar { + flex-shrink: 0; + overflow: hidden; + padding: 3px 5px 2px; + background: #f7f7f7; + border-bottom: 1px solid #c0c0c0; + line-height: 0; + text-align: left; + user-select: none; + border-radius: 3px 3px 0 0; + background-clip: padding-box; +} +div.sceditor-group { + display: inline-block; + background: #ddd; + margin: 1px 5px 1px 0; + padding: 1px; + border-bottom: 1px solid #aaa; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button { + float: left; + cursor: pointer; + padding: 3px 5px; + width: 16px; + height: 20px; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2); +} +.sceditor-button:active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2), inset 0 0 8px rgba(0,0,0,0.3); +} +.sceditor-button.disabled:hover { + background: inherit; + cursor: default; + box-shadow: none; +} +.sceditor-button, +.sceditor-button div { + display: block; +} +.sceditor-button svg { + display: inline-block; + height: 16px; + width: 16px; + margin: 2px 0; + fill: #111; + text-decoration: none; + pointer-events: none; + line-height: 1; +} +.sceditor-button.disabled svg { + fill: #888; +} +.sceditor-button div { + display: inline-block; + margin: 2px 0; + padding: 0; + overflow: hidden; + line-height: 0; + font-size: 0; + color: transparent; +} +.sceditor-button.has-icon div { + display: none; +} +.sceditor-button.disabled div { + opacity: 0.3; +} +.text .sceditor-button, +.text .sceditor-button div, +.sceditor-button.text, +.sceditor-button.text div, +.text-icon .sceditor-button, +.text-icon .sceditor-button div, +.sceditor-button.text-icon, +.sceditor-button.text-icon div { + display: inline-block; + width: auto; + line-height: 16px; + font-size: 1em; + color: inherit; + text-indent: 0; +} +.text-icon .sceditor-button.has-icon div, +.sceditor-button.has-icon div, +.text .sceditor-button div, +.sceditor-button.text div { + padding: 0 2px; + background: none; +} +.text .sceditor-button svg, +.sceditor-button.text svg { + display: none; +} +.text-icon .sceditor-button div, +.sceditor-button.text-icon div { + padding: 0 2px 0 20px; +} +.rtl div.sceditor-toolbar { + text-align: right; +} +.rtl .sceditor-button { + float: right; +} +.rtl div.sceditor-grip { + right: auto; + left: 0; +} +div.sceditor-toolbar { + background: #5d5d5d; +} +div.sceditor-group { + background: #303030; + border-bottom: 1px solid #000; +} +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active { + background: #6b6b6b; +} +.sceditor-button svg { + fill: #fff; +} +.sceditor-button.disabled svg { + fill: #777; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/themes/modern.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,604 @@ +/** + * Modern theme + * + * Copyright (C) 2012, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Icons by Mark James (http://www.famfamfam.com/lab/icons/silk/) + * Licensed under the Creative Commons CC-BY license (http://creativecommons.org/licenses/by/3.0/) + */ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */ +/** + * Default SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2011-16, Sam Clarke + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +div.sceditor-grip, +.sceditor-button div { + background-image: url("famfamfam.png"); + background-repeat: no-repeat; + width: 16px; + height: 16px; +} +.sceditor-button-youtube div { + background-position: 0px 0px; +} +.sceditor-button-link div { + background-position: 0px -16px; +} +.sceditor-button-unlink div { + background-position: 0px -32px; +} +.sceditor-button-underline div { + background-position: 0px -48px; +} +.sceditor-button-time div { + background-position: 0px -64px; +} +.sceditor-button-table div { + background-position: 0px -80px; +} +.sceditor-button-superscript div { + background-position: 0px -96px; +} +.sceditor-button-subscript div { + background-position: 0px -112px; +} +.sceditor-button-strike div { + background-position: 0px -128px; +} +.sceditor-button-source div { + background-position: 0px -144px; +} +.sceditor-button-size div { + background-position: 0px -160px; +} +.sceditor-button-rtl div { + background-position: 0px -176px; +} +.sceditor-button-right div { + background-position: 0px -192px; +} +.sceditor-button-removeformat div { + background-position: 0px -208px; +} +.sceditor-button-quote div { + background-position: 0px -224px; +} +.sceditor-button-print div { + background-position: 0px -240px; +} +.sceditor-button-pastetext div { + background-position: 0px -256px; +} +.sceditor-button-paste div { + background-position: 0px -272px; +} +.sceditor-button-outdent div { + background-position: 0px -288px; +} +.sceditor-button-orderedlist div { + background-position: 0px -304px; +} +.sceditor-button-maximize div { + background-position: 0px -320px; +} +.sceditor-button-ltr div { + background-position: 0px -336px; +} +.sceditor-button-left div { + background-position: 0px -352px; +} +.sceditor-button-justify div { + background-position: 0px -368px; +} +.sceditor-button-italic div { + background-position: 0px -384px; +} +.sceditor-button-indent div { + background-position: 0px -400px; +} +.sceditor-button-image div { + background-position: 0px -416px; +} +.sceditor-button-horizontalrule div { + background-position: 0px -432px; +} +.sceditor-button-format div { + background-position: 0px -448px; +} +.sceditor-button-font div { + background-position: 0px -464px; +} +.sceditor-button-emoticon div { + background-position: 0px -480px; +} +.sceditor-button-email div { + background-position: 0px -496px; +} +.sceditor-button-date div { + background-position: 0px -512px; +} +.sceditor-button-cut div { + background-position: 0px -528px; +} +.sceditor-button-copy div { + background-position: 0px -544px; +} +.sceditor-button-color div { + background-position: 0px -560px; +} +.sceditor-button-code div { + background-position: 0px -576px; +} +.sceditor-button-center div { + background-position: 0px -592px; +} +.sceditor-button-bulletlist div { + background-position: 0px -608px; +} +.sceditor-button-bold div { + background-position: 0px -624px; +} +div.sceditor-grip { + background-position: 0px -640px; + width: 10px; + height: 10px; +} +.rtl div.sceditor-grip { + background-position: 0px -650px; +} +/** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +/*--------------------------------------------------- + LESS Elements 0.7 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +.sceditor-container { + display: -ms-flexbox; + display: flex; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + background: #fff; + border: 1px solid #d9d9d9; + font-size: 13px; + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + color: #333; + line-height: 1; + font-weight: bold; + height: 250px; + border-radius: 4px; + background-clip: padding-box; +} +.sceditor-container *, +.sceditor-container *:before, +.sceditor-container *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.sceditor-container, +.sceditor-container div, +div.sceditor-dropdown, +div.sceditor-dropdown div { + padding: 0; + margin: 0; + z-index: 3; +} +.sceditor-container iframe, +.sceditor-container textarea { + display: block; + -ms-flex: 1 1 0%; + flex: 1 1 0%; + line-height: 1.25; + border: 0; + outline: none; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #111; + padding: 0; + margin: 5px; + resize: none; + background: #fff; + height: auto !important; + width: auto !important; + width: calc(100% - 10px) !important; + min-height: 1px; +} +.sceditor-container textarea { + margin: 7px 5px; +} +div.sceditor-dnd-cover { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: rgba(255, 255, 255, 0.2); + border: 5px dashed #aaa; + z-index: 200; + font-size: 2em; + text-align: center; + color: #aaa; +} +div.sceditor-dnd-cover p { + position: relative; + top: 45%; + pointer-events: none; +} +div.sceditor-resize-cover { + position: absolute; + top: 0; + left: 0; + background: #000; + width: 100%; + height: 100%; + z-index: 10; + opacity: 0.3; +} +div.sceditor-grip { + overflow: hidden; + width: 10px; + height: 10px; + cursor: pointer; + position: absolute; + bottom: 0; + right: 0; + z-index: 3; + line-height: 0; +} +div.sceditor-grip.has-icon { + background-image: none; +} +.sceditor-maximize { + position: fixed; + top: 0; + left: 0; + height: 100% !important; + width: 100% !important; + border-radius: 0; + background-clip: padding-box; + z-index: 2000; +} +html.sceditor-maximize, +body.sceditor-maximize { + height: 100%; + width: 100%; + padding: 0; + margin: 0; + overflow: hidden; +} +.sceditor-maximize div.sceditor-grip { + display: none; +} +.sceditor-maximize div.sceditor-toolbar { + border-radius: 0; + background-clip: padding-box; +} +/** + * Dropdown styleing + */ +div.sceditor-dropdown { + position: absolute; + border: 1px solid #ccc; + background: #fff; + z-index: 4000; + padding: 10px; + font-weight: normal; + font-size: 15px; + border-radius: 2px; + background-clip: padding-box; + box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2); +} +div.sceditor-dropdown *, +div.sceditor-dropdown *:before, +div.sceditor-dropdown *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +div.sceditor-dropdown a, +div.sceditor-dropdown a:link { + color: #333; +} +div.sceditor-dropdown form { + margin: 0; +} +div.sceditor-dropdown label { + display: block; + font-weight: bold; + color: #3c3c3c; + padding: 4px 0; +} +div.sceditor-dropdown input, +div.sceditor-dropdown textarea { + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + outline: 0; + padding: 4px; + border: 1px solid #ccc; + border-top-color: #888; + margin: 0 0 0.75em; + border-radius: 1px; + background-clip: padding-box; +} +div.sceditor-dropdown textarea { + padding: 6px; +} +div.sceditor-dropdown input:focus, +div.sceditor-dropdown textarea:focus { + border-color: #aaa; + border-top-color: #666; + box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1); +} +div.sceditor-dropdown .button { + font-weight: bold; + color: #444; + padding: 6px 12px; + background: #ececec; + border: solid 1px #ccc; + border-radius: 2px; + background-clip: padding-box; + cursor: pointer; + margin: 0.3em 0 0; +} +div.sceditor-dropdown .button:hover { + background: #f3f3f3; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); +} +div.sceditor-font-picker, +div.sceditor-fontsize-picker, +div.sceditor-format { + padding: 6px 0; +} +div.sceditor-color-picker { + padding: 4px; +} +div.sceditor-emoticons, +div.sceditor-more-emoticons { + padding: 0; +} +.sceditor-pastetext textarea { + border: 1px solid #bbb; + width: 20em; +} +.sceditor-emoticons img, +.sceditor-more-emoticons img { + padding: 0; + cursor: pointer; + margin: 2px; +} +.sceditor-more { + border-top: 1px solid #bbb; + display: block; + text-align: center; + cursor: pointer; + font-weight: bold; + padding: 6px 0; +} +.sceditor-dropdown a:hover { + background: #eee; +} +.sceditor-fontsize-option, +.sceditor-font-option, +.sceditor-format a { + display: block; + padding: 7px 10px; + cursor: pointer; + text-decoration: none; + color: #222; +} +.sceditor-fontsize-option { + padding: 7px 13px; +} +.sceditor-color-column { + float: left; +} +.sceditor-color-option { + display: block; + border: 2px solid #fff; + height: 18px; + width: 18px; + overflow: hidden; +} +.sceditor-color-option:hover { + border: 1px solid #aaa; +} +/** + * Toolbar styleing + */ +div.sceditor-toolbar { + flex-shrink: 0; + overflow: hidden; + padding: 3px 5px 2px; + background: #f7f7f7; + border-bottom: 1px solid #c0c0c0; + line-height: 0; + text-align: left; + user-select: none; + border-radius: 3px 3px 0 0; + background-clip: padding-box; +} +div.sceditor-group { + display: inline-block; + background: #ddd; + margin: 1px 5px 1px 0; + padding: 1px; + border-bottom: 1px solid #aaa; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button { + float: left; + cursor: pointer; + padding: 3px 5px; + width: 16px; + height: 20px; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2); +} +.sceditor-button:active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2), inset 0 0 8px rgba(0,0,0,0.3); +} +.sceditor-button.disabled:hover { + background: inherit; + cursor: default; + box-shadow: none; +} +.sceditor-button, +.sceditor-button div { + display: block; +} +.sceditor-button svg { + display: inline-block; + height: 16px; + width: 16px; + margin: 2px 0; + fill: #111; + text-decoration: none; + pointer-events: none; + line-height: 1; +} +.sceditor-button.disabled svg { + fill: #888; +} +.sceditor-button div { + display: inline-block; + margin: 2px 0; + padding: 0; + overflow: hidden; + line-height: 0; + font-size: 0; + color: transparent; +} +.sceditor-button.has-icon div { + display: none; +} +.sceditor-button.disabled div { + opacity: 0.3; +} +.text .sceditor-button, +.text .sceditor-button div, +.sceditor-button.text, +.sceditor-button.text div, +.text-icon .sceditor-button, +.text-icon .sceditor-button div, +.sceditor-button.text-icon, +.sceditor-button.text-icon div { + display: inline-block; + width: auto; + line-height: 16px; + font-size: 1em; + color: inherit; + text-indent: 0; +} +.text-icon .sceditor-button.has-icon div, +.sceditor-button.has-icon div, +.text .sceditor-button div, +.sceditor-button.text div { + padding: 0 2px; + background: none; +} +.text .sceditor-button svg, +.sceditor-button.text svg { + display: none; +} +.text-icon .sceditor-button div, +.sceditor-button.text-icon div { + padding: 0 2px 0 20px; +} +.rtl div.sceditor-toolbar { + text-align: right; +} +.rtl .sceditor-button { + float: right; +} +.rtl div.sceditor-grip { + right: auto; + left: 0; +} +.sceditor-container { + border: 1px solid #999; +} +.sceditor-container textarea { + font-family: Consolas, "Bitstream Vera Sans Mono", "Andale Mono", Monaco, "DejaVu Sans Mono", "Lucida Console", monospace; + background: #2e3436; + color: #fff; + margin: 0; + padding: 5px; +} +div.sceditor-toolbar { + background: #ccc; + background: linear-gradient(to bottom, #cccccc 0%, #b2b2b2 100%); +} +div.sceditor-group { + display: inline; + background: transparent; + margin: 0; + padding: 0; + border: 0; +} +.sceditor-button { + padding: 4px; + margin: 2px 1px 2px 3px; + height: 16px; + border-radius: 12px; + background-clip: padding-box; +} +.sceditor-button:hover, +.sceditor-button.active, +.sceditor-button.active:hover { + box-shadow: none; +} +.sceditor-button:hover { + background: #fff; + background: rgba(255, 255, 255, 0.75); + margin: 1px 0 1px 2px; + border: 1px solid #eee; +} +.sceditor-button.disabled:hover { + margin: 2px 1px 2px 3px; + border: 0; +} +.sceditor-button.active { + background: #b1b1b1; + background: rgba(0, 0, 0, 0.1); + margin: 1px 0 1px 2px; + border: 1px solid #999; +} +.sceditor-button.active:hover { + background: #fff; + background: rgba(255, 255, 255, 0.25); +} +.sceditor-button:active, +.sceditor-button.active:active { + margin: 1px 0 1px 2px; + border: 1px solid #999; + box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5); +} +.sceditor-button div, +.sceditor-button svg { + margin: 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/themes/office-toolbar.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,596 @@ +/** + * Copyright (C) 2012, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Icons by Mark James (http://www.famfamfam.com/lab/icons/silk/) + * Licensed under the Creative Commons CC-BY license (http://creativecommons.org/licenses/by/3.0/) + */ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */ +/** + * Default SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2011-16, Sam Clarke + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +div.sceditor-grip, +.sceditor-button div { + background-image: url("famfamfam.png"); + background-repeat: no-repeat; + width: 16px; + height: 16px; +} +.sceditor-button-youtube div { + background-position: 0px 0px; +} +.sceditor-button-link div { + background-position: 0px -16px; +} +.sceditor-button-unlink div { + background-position: 0px -32px; +} +.sceditor-button-underline div { + background-position: 0px -48px; +} +.sceditor-button-time div { + background-position: 0px -64px; +} +.sceditor-button-table div { + background-position: 0px -80px; +} +.sceditor-button-superscript div { + background-position: 0px -96px; +} +.sceditor-button-subscript div { + background-position: 0px -112px; +} +.sceditor-button-strike div { + background-position: 0px -128px; +} +.sceditor-button-source div { + background-position: 0px -144px; +} +.sceditor-button-size div { + background-position: 0px -160px; +} +.sceditor-button-rtl div { + background-position: 0px -176px; +} +.sceditor-button-right div { + background-position: 0px -192px; +} +.sceditor-button-removeformat div { + background-position: 0px -208px; +} +.sceditor-button-quote div { + background-position: 0px -224px; +} +.sceditor-button-print div { + background-position: 0px -240px; +} +.sceditor-button-pastetext div { + background-position: 0px -256px; +} +.sceditor-button-paste div { + background-position: 0px -272px; +} +.sceditor-button-outdent div { + background-position: 0px -288px; +} +.sceditor-button-orderedlist div { + background-position: 0px -304px; +} +.sceditor-button-maximize div { + background-position: 0px -320px; +} +.sceditor-button-ltr div { + background-position: 0px -336px; +} +.sceditor-button-left div { + background-position: 0px -352px; +} +.sceditor-button-justify div { + background-position: 0px -368px; +} +.sceditor-button-italic div { + background-position: 0px -384px; +} +.sceditor-button-indent div { + background-position: 0px -400px; +} +.sceditor-button-image div { + background-position: 0px -416px; +} +.sceditor-button-horizontalrule div { + background-position: 0px -432px; +} +.sceditor-button-format div { + background-position: 0px -448px; +} +.sceditor-button-font div { + background-position: 0px -464px; +} +.sceditor-button-emoticon div { + background-position: 0px -480px; +} +.sceditor-button-email div { + background-position: 0px -496px; +} +.sceditor-button-date div { + background-position: 0px -512px; +} +.sceditor-button-cut div { + background-position: 0px -528px; +} +.sceditor-button-copy div { + background-position: 0px -544px; +} +.sceditor-button-color div { + background-position: 0px -560px; +} +.sceditor-button-code div { + background-position: 0px -576px; +} +.sceditor-button-center div { + background-position: 0px -592px; +} +.sceditor-button-bulletlist div { + background-position: 0px -608px; +} +.sceditor-button-bold div { + background-position: 0px -624px; +} +div.sceditor-grip { + background-position: 0px -640px; + width: 10px; + height: 10px; +} +.rtl div.sceditor-grip { + background-position: 0px -650px; +} +/** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +/*--------------------------------------------------- + LESS Elements 0.7 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +.sceditor-container { + display: -ms-flexbox; + display: flex; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + background: #fff; + border: 1px solid #d9d9d9; + font-size: 13px; + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + color: #333; + line-height: 1; + font-weight: bold; + height: 250px; + border-radius: 4px; + background-clip: padding-box; +} +.sceditor-container *, +.sceditor-container *:before, +.sceditor-container *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.sceditor-container, +.sceditor-container div, +div.sceditor-dropdown, +div.sceditor-dropdown div { + padding: 0; + margin: 0; + z-index: 3; +} +.sceditor-container iframe, +.sceditor-container textarea { + display: block; + -ms-flex: 1 1 0%; + flex: 1 1 0%; + line-height: 1.25; + border: 0; + outline: none; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #111; + padding: 0; + margin: 5px; + resize: none; + background: #fff; + height: auto !important; + width: auto !important; + width: calc(100% - 10px) !important; + min-height: 1px; +} +.sceditor-container textarea { + margin: 7px 5px; +} +div.sceditor-dnd-cover { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: rgba(255, 255, 255, 0.2); + border: 5px dashed #aaa; + z-index: 200; + font-size: 2em; + text-align: center; + color: #aaa; +} +div.sceditor-dnd-cover p { + position: relative; + top: 45%; + pointer-events: none; +} +div.sceditor-resize-cover { + position: absolute; + top: 0; + left: 0; + background: #000; + width: 100%; + height: 100%; + z-index: 10; + opacity: 0.3; +} +div.sceditor-grip { + overflow: hidden; + width: 10px; + height: 10px; + cursor: pointer; + position: absolute; + bottom: 0; + right: 0; + z-index: 3; + line-height: 0; +} +div.sceditor-grip.has-icon { + background-image: none; +} +.sceditor-maximize { + position: fixed; + top: 0; + left: 0; + height: 100% !important; + width: 100% !important; + border-radius: 0; + background-clip: padding-box; + z-index: 2000; +} +html.sceditor-maximize, +body.sceditor-maximize { + height: 100%; + width: 100%; + padding: 0; + margin: 0; + overflow: hidden; +} +.sceditor-maximize div.sceditor-grip { + display: none; +} +.sceditor-maximize div.sceditor-toolbar { + border-radius: 0; + background-clip: padding-box; +} +/** + * Dropdown styleing + */ +div.sceditor-dropdown { + position: absolute; + border: 1px solid #ccc; + background: #fff; + z-index: 4000; + padding: 10px; + font-weight: normal; + font-size: 15px; + border-radius: 2px; + background-clip: padding-box; + box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2); +} +div.sceditor-dropdown *, +div.sceditor-dropdown *:before, +div.sceditor-dropdown *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +div.sceditor-dropdown a, +div.sceditor-dropdown a:link { + color: #333; +} +div.sceditor-dropdown form { + margin: 0; +} +div.sceditor-dropdown label { + display: block; + font-weight: bold; + color: #3c3c3c; + padding: 4px 0; +} +div.sceditor-dropdown input, +div.sceditor-dropdown textarea { + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + outline: 0; + padding: 4px; + border: 1px solid #ccc; + border-top-color: #888; + margin: 0 0 0.75em; + border-radius: 1px; + background-clip: padding-box; +} +div.sceditor-dropdown textarea { + padding: 6px; +} +div.sceditor-dropdown input:focus, +div.sceditor-dropdown textarea:focus { + border-color: #aaa; + border-top-color: #666; + box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1); +} +div.sceditor-dropdown .button { + font-weight: bold; + color: #444; + padding: 6px 12px; + background: #ececec; + border: solid 1px #ccc; + border-radius: 2px; + background-clip: padding-box; + cursor: pointer; + margin: 0.3em 0 0; +} +div.sceditor-dropdown .button:hover { + background: #f3f3f3; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); +} +div.sceditor-font-picker, +div.sceditor-fontsize-picker, +div.sceditor-format { + padding: 6px 0; +} +div.sceditor-color-picker { + padding: 4px; +} +div.sceditor-emoticons, +div.sceditor-more-emoticons { + padding: 0; +} +.sceditor-pastetext textarea { + border: 1px solid #bbb; + width: 20em; +} +.sceditor-emoticons img, +.sceditor-more-emoticons img { + padding: 0; + cursor: pointer; + margin: 2px; +} +.sceditor-more { + border-top: 1px solid #bbb; + display: block; + text-align: center; + cursor: pointer; + font-weight: bold; + padding: 6px 0; +} +.sceditor-dropdown a:hover { + background: #eee; +} +.sceditor-fontsize-option, +.sceditor-font-option, +.sceditor-format a { + display: block; + padding: 7px 10px; + cursor: pointer; + text-decoration: none; + color: #222; +} +.sceditor-fontsize-option { + padding: 7px 13px; +} +.sceditor-color-column { + float: left; +} +.sceditor-color-option { + display: block; + border: 2px solid #fff; + height: 18px; + width: 18px; + overflow: hidden; +} +.sceditor-color-option:hover { + border: 1px solid #aaa; +} +/** + * Toolbar styleing + */ +div.sceditor-toolbar { + flex-shrink: 0; + overflow: hidden; + padding: 3px 5px 2px; + background: #f7f7f7; + border-bottom: 1px solid #c0c0c0; + line-height: 0; + text-align: left; + user-select: none; + border-radius: 3px 3px 0 0; + background-clip: padding-box; +} +div.sceditor-group { + display: inline-block; + background: #ddd; + margin: 1px 5px 1px 0; + padding: 1px; + border-bottom: 1px solid #aaa; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button { + float: left; + cursor: pointer; + padding: 3px 5px; + width: 16px; + height: 20px; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2); +} +.sceditor-button:active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2), inset 0 0 8px rgba(0,0,0,0.3); +} +.sceditor-button.disabled:hover { + background: inherit; + cursor: default; + box-shadow: none; +} +.sceditor-button, +.sceditor-button div { + display: block; +} +.sceditor-button svg { + display: inline-block; + height: 16px; + width: 16px; + margin: 2px 0; + fill: #111; + text-decoration: none; + pointer-events: none; + line-height: 1; +} +.sceditor-button.disabled svg { + fill: #888; +} +.sceditor-button div { + display: inline-block; + margin: 2px 0; + padding: 0; + overflow: hidden; + line-height: 0; + font-size: 0; + color: transparent; +} +.sceditor-button.has-icon div { + display: none; +} +.sceditor-button.disabled div { + opacity: 0.3; +} +.text .sceditor-button, +.text .sceditor-button div, +.sceditor-button.text, +.sceditor-button.text div, +.text-icon .sceditor-button, +.text-icon .sceditor-button div, +.sceditor-button.text-icon, +.sceditor-button.text-icon div { + display: inline-block; + width: auto; + line-height: 16px; + font-size: 1em; + color: inherit; + text-indent: 0; +} +.text-icon .sceditor-button.has-icon div, +.sceditor-button.has-icon div, +.text .sceditor-button div, +.sceditor-button.text div { + padding: 0 2px; + background: none; +} +.text .sceditor-button svg, +.sceditor-button.text svg { + display: none; +} +.text-icon .sceditor-button div, +.sceditor-button.text-icon div { + padding: 0 2px 0 20px; +} +.rtl div.sceditor-toolbar { + text-align: right; +} +.rtl .sceditor-button { + float: right; +} +.rtl div.sceditor-grip { + right: auto; + left: 0; +} +.sceditor-container { + border: 1px solid #8db2e3; +} +.sceditor-container textarea { + font-family: Consolas, "Bitstream Vera Sans Mono", "Andale Mono", Monaco, "DejaVu Sans Mono", "Lucida Console", monospace; +} +div.sceditor-toolbar { + border-bottom: 1px solid #95a9c3; + background: #dee8f5; + background: linear-gradient(to bottom, #dee8f5 0%, #c7d8ed 29%, #ccdcee 61%, #c0d8ef 100%); +} +div.sceditor-group { + border: 1px solid #7596bf; + background: transparent; + padding: 0; + background: #cadcf0; + background: linear-gradient(to bottom, #cadcf0 24%, #bcd0e9 38%, #d0e1f7 99%); +} +.sceditor-button { + height: 16px; + padding: 3px 4px; + border-radius: 0; + background-clip: padding-box; + box-shadow: inset 0 1px #d5e3f1, inset 0 -1px #e3edfb, inset 1px 0 #cddcef, inset -1px 0 #b8ceea; +} +.sceditor-button:first-child { + border-radius: 4px 0 0 4px; + background-clip: padding-box; +} +.sceditor-button:last-child { + border-radius: 0 4px 4px 0; + background-clip: padding-box; +} +.sceditor-button div, +.sceditor-button svg { + margin: 0; +} +.sceditor-button.active { + background: #fbdbb5; + background: linear-gradient(to bottom, #fbdbb5 11%, #feb456 29%, #fdeb9f 99%); + box-shadow: inset 0 1px #ebd1b4, inset 0 -1px #ffe47f, inset -1px 0 #b8ceea; +} +.sceditor-button:hover { + background: #fef7d5; + background: linear-gradient(to bottom, #fef7d5 0%, #fae5a9 42%, #ffd048 42%, #ffe59f 100%); + box-shadow: inset 0 1px #fffbe8, inset -1px 0 #ffefc4, inset 0 -1px #fff9cc; +} +.sceditor-button:active { + background: #e7a66d; + background: linear-gradient(to bottom, #e7a66d 0%, #fcb16d 1%, #ff8d05 42%, #ffc450 100%); + box-shadow: inset 0 1px 1px #7b6645, inset 0 -1px #d19c33; +} +.sceditor-button.active:hover { + background: #dba368; + background: linear-gradient(to bottom, #dba368 0%, #ffbd79 4%, #fea335 34%, #ffc64c 66%, #fee069 100%); + box-shadow: inset 0 1px 1px #9e8255, inset 0 -1px #fcce6b; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/themes/office.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,618 @@ +/** + * Copyright (C) 2012, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Icons by Mark James (http://www.famfamfam.com/lab/icons/silk/) + * Licensed under the Creative Commons CC-BY license (http://creativecommons.org/licenses/by/3.0/) + */ +/** + * Copyright (C) 2012, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Icons by Mark James (http://www.famfamfam.com/lab/icons/silk/) + * Licensed under the Creative Commons CC-BY license (http://creativecommons.org/licenses/by/3.0/) + */ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */ +/** + * Default SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2011-16, Sam Clarke + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +div.sceditor-grip, +.sceditor-button div { + background-image: url("famfamfam.png"); + background-repeat: no-repeat; + width: 16px; + height: 16px; +} +.sceditor-button-youtube div { + background-position: 0px 0px; +} +.sceditor-button-link div { + background-position: 0px -16px; +} +.sceditor-button-unlink div { + background-position: 0px -32px; +} +.sceditor-button-underline div { + background-position: 0px -48px; +} +.sceditor-button-time div { + background-position: 0px -64px; +} +.sceditor-button-table div { + background-position: 0px -80px; +} +.sceditor-button-superscript div { + background-position: 0px -96px; +} +.sceditor-button-subscript div { + background-position: 0px -112px; +} +.sceditor-button-strike div { + background-position: 0px -128px; +} +.sceditor-button-source div { + background-position: 0px -144px; +} +.sceditor-button-size div { + background-position: 0px -160px; +} +.sceditor-button-rtl div { + background-position: 0px -176px; +} +.sceditor-button-right div { + background-position: 0px -192px; +} +.sceditor-button-removeformat div { + background-position: 0px -208px; +} +.sceditor-button-quote div { + background-position: 0px -224px; +} +.sceditor-button-print div { + background-position: 0px -240px; +} +.sceditor-button-pastetext div { + background-position: 0px -256px; +} +.sceditor-button-paste div { + background-position: 0px -272px; +} +.sceditor-button-outdent div { + background-position: 0px -288px; +} +.sceditor-button-orderedlist div { + background-position: 0px -304px; +} +.sceditor-button-maximize div { + background-position: 0px -320px; +} +.sceditor-button-ltr div { + background-position: 0px -336px; +} +.sceditor-button-left div { + background-position: 0px -352px; +} +.sceditor-button-justify div { + background-position: 0px -368px; +} +.sceditor-button-italic div { + background-position: 0px -384px; +} +.sceditor-button-indent div { + background-position: 0px -400px; +} +.sceditor-button-image div { + background-position: 0px -416px; +} +.sceditor-button-horizontalrule div { + background-position: 0px -432px; +} +.sceditor-button-format div { + background-position: 0px -448px; +} +.sceditor-button-font div { + background-position: 0px -464px; +} +.sceditor-button-emoticon div { + background-position: 0px -480px; +} +.sceditor-button-email div { + background-position: 0px -496px; +} +.sceditor-button-date div { + background-position: 0px -512px; +} +.sceditor-button-cut div { + background-position: 0px -528px; +} +.sceditor-button-copy div { + background-position: 0px -544px; +} +.sceditor-button-color div { + background-position: 0px -560px; +} +.sceditor-button-code div { + background-position: 0px -576px; +} +.sceditor-button-center div { + background-position: 0px -592px; +} +.sceditor-button-bulletlist div { + background-position: 0px -608px; +} +.sceditor-button-bold div { + background-position: 0px -624px; +} +div.sceditor-grip { + background-position: 0px -640px; + width: 10px; + height: 10px; +} +.rtl div.sceditor-grip { + background-position: 0px -650px; +} +/** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +/*--------------------------------------------------- + LESS Elements 0.7 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +.sceditor-container { + display: -ms-flexbox; + display: flex; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + background: #fff; + border: 1px solid #d9d9d9; + font-size: 13px; + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + color: #333; + line-height: 1; + font-weight: bold; + height: 250px; + border-radius: 4px; + background-clip: padding-box; +} +.sceditor-container *, +.sceditor-container *:before, +.sceditor-container *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.sceditor-container, +.sceditor-container div, +div.sceditor-dropdown, +div.sceditor-dropdown div { + padding: 0; + margin: 0; + z-index: 3; +} +.sceditor-container iframe, +.sceditor-container textarea { + display: block; + -ms-flex: 1 1 0%; + flex: 1 1 0%; + line-height: 1.25; + border: 0; + outline: none; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #111; + padding: 0; + margin: 5px; + resize: none; + background: #fff; + height: auto !important; + width: auto !important; + width: calc(100% - 10px) !important; + min-height: 1px; +} +.sceditor-container textarea { + margin: 7px 5px; +} +div.sceditor-dnd-cover { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: rgba(255, 255, 255, 0.2); + border: 5px dashed #aaa; + z-index: 200; + font-size: 2em; + text-align: center; + color: #aaa; +} +div.sceditor-dnd-cover p { + position: relative; + top: 45%; + pointer-events: none; +} +div.sceditor-resize-cover { + position: absolute; + top: 0; + left: 0; + background: #000; + width: 100%; + height: 100%; + z-index: 10; + opacity: 0.3; +} +div.sceditor-grip { + overflow: hidden; + width: 10px; + height: 10px; + cursor: pointer; + position: absolute; + bottom: 0; + right: 0; + z-index: 3; + line-height: 0; +} +div.sceditor-grip.has-icon { + background-image: none; +} +.sceditor-maximize { + position: fixed; + top: 0; + left: 0; + height: 100% !important; + width: 100% !important; + border-radius: 0; + background-clip: padding-box; + z-index: 2000; +} +html.sceditor-maximize, +body.sceditor-maximize { + height: 100%; + width: 100%; + padding: 0; + margin: 0; + overflow: hidden; +} +.sceditor-maximize div.sceditor-grip { + display: none; +} +.sceditor-maximize div.sceditor-toolbar { + border-radius: 0; + background-clip: padding-box; +} +/** + * Dropdown styleing + */ +div.sceditor-dropdown { + position: absolute; + border: 1px solid #ccc; + background: #fff; + z-index: 4000; + padding: 10px; + font-weight: normal; + font-size: 15px; + border-radius: 2px; + background-clip: padding-box; + box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2); +} +div.sceditor-dropdown *, +div.sceditor-dropdown *:before, +div.sceditor-dropdown *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +div.sceditor-dropdown a, +div.sceditor-dropdown a:link { + color: #333; +} +div.sceditor-dropdown form { + margin: 0; +} +div.sceditor-dropdown label { + display: block; + font-weight: bold; + color: #3c3c3c; + padding: 4px 0; +} +div.sceditor-dropdown input, +div.sceditor-dropdown textarea { + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + outline: 0; + padding: 4px; + border: 1px solid #ccc; + border-top-color: #888; + margin: 0 0 0.75em; + border-radius: 1px; + background-clip: padding-box; +} +div.sceditor-dropdown textarea { + padding: 6px; +} +div.sceditor-dropdown input:focus, +div.sceditor-dropdown textarea:focus { + border-color: #aaa; + border-top-color: #666; + box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1); +} +div.sceditor-dropdown .button { + font-weight: bold; + color: #444; + padding: 6px 12px; + background: #ececec; + border: solid 1px #ccc; + border-radius: 2px; + background-clip: padding-box; + cursor: pointer; + margin: 0.3em 0 0; +} +div.sceditor-dropdown .button:hover { + background: #f3f3f3; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); +} +div.sceditor-font-picker, +div.sceditor-fontsize-picker, +div.sceditor-format { + padding: 6px 0; +} +div.sceditor-color-picker { + padding: 4px; +} +div.sceditor-emoticons, +div.sceditor-more-emoticons { + padding: 0; +} +.sceditor-pastetext textarea { + border: 1px solid #bbb; + width: 20em; +} +.sceditor-emoticons img, +.sceditor-more-emoticons img { + padding: 0; + cursor: pointer; + margin: 2px; +} +.sceditor-more { + border-top: 1px solid #bbb; + display: block; + text-align: center; + cursor: pointer; + font-weight: bold; + padding: 6px 0; +} +.sceditor-dropdown a:hover { + background: #eee; +} +.sceditor-fontsize-option, +.sceditor-font-option, +.sceditor-format a { + display: block; + padding: 7px 10px; + cursor: pointer; + text-decoration: none; + color: #222; +} +.sceditor-fontsize-option { + padding: 7px 13px; +} +.sceditor-color-column { + float: left; +} +.sceditor-color-option { + display: block; + border: 2px solid #fff; + height: 18px; + width: 18px; + overflow: hidden; +} +.sceditor-color-option:hover { + border: 1px solid #aaa; +} +/** + * Toolbar styleing + */ +div.sceditor-toolbar { + flex-shrink: 0; + overflow: hidden; + padding: 3px 5px 2px; + background: #f7f7f7; + border-bottom: 1px solid #c0c0c0; + line-height: 0; + text-align: left; + user-select: none; + border-radius: 3px 3px 0 0; + background-clip: padding-box; +} +div.sceditor-group { + display: inline-block; + background: #ddd; + margin: 1px 5px 1px 0; + padding: 1px; + border-bottom: 1px solid #aaa; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button { + float: left; + cursor: pointer; + padding: 3px 5px; + width: 16px; + height: 20px; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2); +} +.sceditor-button:active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2), inset 0 0 8px rgba(0,0,0,0.3); +} +.sceditor-button.disabled:hover { + background: inherit; + cursor: default; + box-shadow: none; +} +.sceditor-button, +.sceditor-button div { + display: block; +} +.sceditor-button svg { + display: inline-block; + height: 16px; + width: 16px; + margin: 2px 0; + fill: #111; + text-decoration: none; + pointer-events: none; + line-height: 1; +} +.sceditor-button.disabled svg { + fill: #888; +} +.sceditor-button div { + display: inline-block; + margin: 2px 0; + padding: 0; + overflow: hidden; + line-height: 0; + font-size: 0; + color: transparent; +} +.sceditor-button.has-icon div { + display: none; +} +.sceditor-button.disabled div { + opacity: 0.3; +} +.text .sceditor-button, +.text .sceditor-button div, +.sceditor-button.text, +.sceditor-button.text div, +.text-icon .sceditor-button, +.text-icon .sceditor-button div, +.sceditor-button.text-icon, +.sceditor-button.text-icon div { + display: inline-block; + width: auto; + line-height: 16px; + font-size: 1em; + color: inherit; + text-indent: 0; +} +.text-icon .sceditor-button.has-icon div, +.sceditor-button.has-icon div, +.text .sceditor-button div, +.sceditor-button.text div { + padding: 0 2px; + background: none; +} +.text .sceditor-button svg, +.sceditor-button.text svg { + display: none; +} +.text-icon .sceditor-button div, +.sceditor-button.text-icon div { + padding: 0 2px 0 20px; +} +.rtl div.sceditor-toolbar { + text-align: right; +} +.rtl .sceditor-button { + float: right; +} +.rtl div.sceditor-grip { + right: auto; + left: 0; +} +.sceditor-container { + border: 1px solid #8db2e3; +} +.sceditor-container textarea { + font-family: Consolas, "Bitstream Vera Sans Mono", "Andale Mono", Monaco, "DejaVu Sans Mono", "Lucida Console", monospace; +} +div.sceditor-toolbar { + border-bottom: 1px solid #95a9c3; + background: #dee8f5; + background: linear-gradient(to bottom, #dee8f5 0%, #c7d8ed 29%, #ccdcee 61%, #c0d8ef 100%); +} +div.sceditor-group { + border: 1px solid #7596bf; + background: transparent; + padding: 0; + background: #cadcf0; + background: linear-gradient(to bottom, #cadcf0 24%, #bcd0e9 38%, #d0e1f7 99%); +} +.sceditor-button { + height: 16px; + padding: 3px 4px; + border-radius: 0; + background-clip: padding-box; + box-shadow: inset 0 1px #d5e3f1, inset 0 -1px #e3edfb, inset 1px 0 #cddcef, inset -1px 0 #b8ceea; +} +.sceditor-button:first-child { + border-radius: 4px 0 0 4px; + background-clip: padding-box; +} +.sceditor-button:last-child { + border-radius: 0 4px 4px 0; + background-clip: padding-box; +} +.sceditor-button div, +.sceditor-button svg { + margin: 0; +} +.sceditor-button.active { + background: #fbdbb5; + background: linear-gradient(to bottom, #fbdbb5 11%, #feb456 29%, #fdeb9f 99%); + box-shadow: inset 0 1px #ebd1b4, inset 0 -1px #ffe47f, inset -1px 0 #b8ceea; +} +.sceditor-button:hover { + background: #fef7d5; + background: linear-gradient(to bottom, #fef7d5 0%, #fae5a9 42%, #ffd048 42%, #ffe59f 100%); + box-shadow: inset 0 1px #fffbe8, inset -1px 0 #ffefc4, inset 0 -1px #fff9cc; +} +.sceditor-button:active { + background: #e7a66d; + background: linear-gradient(to bottom, #e7a66d 0%, #fcb16d 1%, #ff8d05 42%, #ffc450 100%); + box-shadow: inset 0 1px 1px #7b6645, inset 0 -1px #d19c33; +} +.sceditor-button.active:hover { + background: #dba368; + background: linear-gradient(to bottom, #dba368 0%, #ffbd79 4%, #fea335 34%, #ffc64c 66%, #fee069 100%); + box-shadow: inset 0 1px 1px #9e8255, inset 0 -1px #fcce6b; +} +.sceditor-container { + background: #a3c2ea; + background: linear-gradient(to bottom, #a3c2ea 0%, #6d92c1 39%, #577fb3 64%, #6591cc 100%); +} +.sceditor-container iframe, +.sceditor-container textarea { + border: 1px solid #646464; + background: #fff; + margin: 7px 40px; + padding: 20px; + width: calc(100% - 120px) !important; + box-shadow: 1px 1px 5px #293a52; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/development/themes/square.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,619 @@ +/** + * Square theme + * + * This theme is best suited to short toolbars that + * don't span multiple lines. + * + * Copyright (C) 2012, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Icons by Mark James (http://www.famfamfam.com/lab/icons/silk/) + * Licensed under the Creative Commons CC-BY license (http://creativecommons.org/licenses/by/3.0/) + */ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */ +/** + * Default SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2011-16, Sam Clarke + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +div.sceditor-grip, +.sceditor-button div { + background-image: url("famfamfam.png"); + background-repeat: no-repeat; + width: 16px; + height: 16px; +} +.sceditor-button-youtube div { + background-position: 0px 0px; +} +.sceditor-button-link div { + background-position: 0px -16px; +} +.sceditor-button-unlink div { + background-position: 0px -32px; +} +.sceditor-button-underline div { + background-position: 0px -48px; +} +.sceditor-button-time div { + background-position: 0px -64px; +} +.sceditor-button-table div { + background-position: 0px -80px; +} +.sceditor-button-superscript div { + background-position: 0px -96px; +} +.sceditor-button-subscript div { + background-position: 0px -112px; +} +.sceditor-button-strike div { + background-position: 0px -128px; +} +.sceditor-button-source div { + background-position: 0px -144px; +} +.sceditor-button-size div { + background-position: 0px -160px; +} +.sceditor-button-rtl div { + background-position: 0px -176px; +} +.sceditor-button-right div { + background-position: 0px -192px; +} +.sceditor-button-removeformat div { + background-position: 0px -208px; +} +.sceditor-button-quote div { + background-position: 0px -224px; +} +.sceditor-button-print div { + background-position: 0px -240px; +} +.sceditor-button-pastetext div { + background-position: 0px -256px; +} +.sceditor-button-paste div { + background-position: 0px -272px; +} +.sceditor-button-outdent div { + background-position: 0px -288px; +} +.sceditor-button-orderedlist div { + background-position: 0px -304px; +} +.sceditor-button-maximize div { + background-position: 0px -320px; +} +.sceditor-button-ltr div { + background-position: 0px -336px; +} +.sceditor-button-left div { + background-position: 0px -352px; +} +.sceditor-button-justify div { + background-position: 0px -368px; +} +.sceditor-button-italic div { + background-position: 0px -384px; +} +.sceditor-button-indent div { + background-position: 0px -400px; +} +.sceditor-button-image div { + background-position: 0px -416px; +} +.sceditor-button-horizontalrule div { + background-position: 0px -432px; +} +.sceditor-button-format div { + background-position: 0px -448px; +} +.sceditor-button-font div { + background-position: 0px -464px; +} +.sceditor-button-emoticon div { + background-position: 0px -480px; +} +.sceditor-button-email div { + background-position: 0px -496px; +} +.sceditor-button-date div { + background-position: 0px -512px; +} +.sceditor-button-cut div { + background-position: 0px -528px; +} +.sceditor-button-copy div { + background-position: 0px -544px; +} +.sceditor-button-color div { + background-position: 0px -560px; +} +.sceditor-button-code div { + background-position: 0px -576px; +} +.sceditor-button-center div { + background-position: 0px -592px; +} +.sceditor-button-bulletlist div { + background-position: 0px -608px; +} +.sceditor-button-bold div { + background-position: 0px -624px; +} +div.sceditor-grip { + background-position: 0px -640px; + width: 10px; + height: 10px; +} +.rtl div.sceditor-grip { + background-position: 0px -650px; +} +/** + * SCEditor + * http://www.sceditor.com/ + * + * Copyright (C) 2017, Sam Clarke (samclarke.com) + * + * SCEditor is licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + */ +/*--------------------------------------------------- + LESS Elements 0.7 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +.sceditor-container { + display: -ms-flexbox; + display: flex; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + background: #fff; + border: 1px solid #d9d9d9; + font-size: 13px; + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + color: #333; + line-height: 1; + font-weight: bold; + height: 250px; + border-radius: 4px; + background-clip: padding-box; +} +.sceditor-container *, +.sceditor-container *:before, +.sceditor-container *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} +.sceditor-container, +.sceditor-container div, +div.sceditor-dropdown, +div.sceditor-dropdown div { + padding: 0; + margin: 0; + z-index: 3; +} +.sceditor-container iframe, +.sceditor-container textarea { + display: block; + -ms-flex: 1 1 0%; + flex: 1 1 0%; + line-height: 1.25; + border: 0; + outline: none; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #111; + padding: 0; + margin: 5px; + resize: none; + background: #fff; + height: auto !important; + width: auto !important; + width: calc(100% - 10px) !important; + min-height: 1px; +} +.sceditor-container textarea { + margin: 7px 5px; +} +div.sceditor-dnd-cover { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: rgba(255, 255, 255, 0.2); + border: 5px dashed #aaa; + z-index: 200; + font-size: 2em; + text-align: center; + color: #aaa; +} +div.sceditor-dnd-cover p { + position: relative; + top: 45%; + pointer-events: none; +} +div.sceditor-resize-cover { + position: absolute; + top: 0; + left: 0; + background: #000; + width: 100%; + height: 100%; + z-index: 10; + opacity: 0.3; +} +div.sceditor-grip { + overflow: hidden; + width: 10px; + height: 10px; + cursor: pointer; + position: absolute; + bottom: 0; + right: 0; + z-index: 3; + line-height: 0; +} +div.sceditor-grip.has-icon { + background-image: none; +} +.sceditor-maximize { + position: fixed; + top: 0; + left: 0; + height: 100% !important; + width: 100% !important; + border-radius: 0; + background-clip: padding-box; + z-index: 2000; +} +html.sceditor-maximize, +body.sceditor-maximize { + height: 100%; + width: 100%; + padding: 0; + margin: 0; + overflow: hidden; +} +.sceditor-maximize div.sceditor-grip { + display: none; +} +.sceditor-maximize div.sceditor-toolbar { + border-radius: 0; + background-clip: padding-box; +} +/** + * Dropdown styleing + */ +div.sceditor-dropdown { + position: absolute; + border: 1px solid #ccc; + background: #fff; + z-index: 4000; + padding: 10px; + font-weight: normal; + font-size: 15px; + border-radius: 2px; + background-clip: padding-box; + box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2); +} +div.sceditor-dropdown *, +div.sceditor-dropdown *:before, +div.sceditor-dropdown *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +div.sceditor-dropdown a, +div.sceditor-dropdown a:link { + color: #333; +} +div.sceditor-dropdown form { + margin: 0; +} +div.sceditor-dropdown label { + display: block; + font-weight: bold; + color: #3c3c3c; + padding: 4px 0; +} +div.sceditor-dropdown input, +div.sceditor-dropdown textarea { + font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; + outline: 0; + padding: 4px; + border: 1px solid #ccc; + border-top-color: #888; + margin: 0 0 0.75em; + border-radius: 1px; + background-clip: padding-box; +} +div.sceditor-dropdown textarea { + padding: 6px; +} +div.sceditor-dropdown input:focus, +div.sceditor-dropdown textarea:focus { + border-color: #aaa; + border-top-color: #666; + box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1); +} +div.sceditor-dropdown .button { + font-weight: bold; + color: #444; + padding: 6px 12px; + background: #ececec; + border: solid 1px #ccc; + border-radius: 2px; + background-clip: padding-box; + cursor: pointer; + margin: 0.3em 0 0; +} +div.sceditor-dropdown .button:hover { + background: #f3f3f3; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15); +} +div.sceditor-font-picker, +div.sceditor-fontsize-picker, +div.sceditor-format { + padding: 6px 0; +} +div.sceditor-color-picker { + padding: 4px; +} +div.sceditor-emoticons, +div.sceditor-more-emoticons { + padding: 0; +} +.sceditor-pastetext textarea { + border: 1px solid #bbb; + width: 20em; +} +.sceditor-emoticons img, +.sceditor-more-emoticons img { + padding: 0; + cursor: pointer; + margin: 2px; +} +.sceditor-more { + border-top: 1px solid #bbb; + display: block; + text-align: center; + cursor: pointer; + font-weight: bold; + padding: 6px 0; +} +.sceditor-dropdown a:hover { + background: #eee; +} +.sceditor-fontsize-option, +.sceditor-font-option, +.sceditor-format a { + display: block; + padding: 7px 10px; + cursor: pointer; + text-decoration: none; + color: #222; +} +.sceditor-fontsize-option { + padding: 7px 13px; +} +.sceditor-color-column { + float: left; +} +.sceditor-color-option { + display: block; + border: 2px solid #fff; + height: 18px; + width: 18px; + overflow: hidden; +} +.sceditor-color-option:hover { + border: 1px solid #aaa; +} +/** + * Toolbar styleing + */ +div.sceditor-toolbar { + flex-shrink: 0; + overflow: hidden; + padding: 3px 5px 2px; + background: #f7f7f7; + border-bottom: 1px solid #c0c0c0; + line-height: 0; + text-align: left; + user-select: none; + border-radius: 3px 3px 0 0; + background-clip: padding-box; +} +div.sceditor-group { + display: inline-block; + background: #ddd; + margin: 1px 5px 1px 0; + padding: 1px; + border-bottom: 1px solid #aaa; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button { + float: left; + cursor: pointer; + padding: 3px 5px; + width: 16px; + height: 20px; + border-radius: 3px; + background-clip: padding-box; +} +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2); +} +.sceditor-button:active { + background: #fff; + box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3), inset -1px 0 rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.2), inset 0 0 8px rgba(0,0,0,0.3); +} +.sceditor-button.disabled:hover { + background: inherit; + cursor: default; + box-shadow: none; +} +.sceditor-button, +.sceditor-button div { + display: block; +} +.sceditor-button svg { + display: inline-block; + height: 16px; + width: 16px; + margin: 2px 0; + fill: #111; + text-decoration: none; + pointer-events: none; + line-height: 1; +} +.sceditor-button.disabled svg { + fill: #888; +} +.sceditor-button div { + display: inline-block; + margin: 2px 0; + padding: 0; + overflow: hidden; + line-height: 0; + font-size: 0; + color: transparent; +} +.sceditor-button.has-icon div { + display: none; +} +.sceditor-button.disabled div { + opacity: 0.3; +} +.text .sceditor-button, +.text .sceditor-button div, +.sceditor-button.text, +.sceditor-button.text div, +.text-icon .sceditor-button, +.text-icon .sceditor-button div, +.sceditor-button.text-icon, +.sceditor-button.text-icon div { + display: inline-block; + width: auto; + line-height: 16px; + font-size: 1em; + color: inherit; + text-indent: 0; +} +.text-icon .sceditor-button.has-icon div, +.sceditor-button.has-icon div, +.text .sceditor-button div, +.sceditor-button.text div { + padding: 0 2px; + background: none; +} +.text .sceditor-button svg, +.sceditor-button.text svg { + display: none; +} +.text-icon .sceditor-button div, +.sceditor-button.text-icon div { + padding: 0 2px 0 20px; +} +.rtl div.sceditor-toolbar { + text-align: right; +} +.rtl .sceditor-button { + float: right; +} +.rtl div.sceditor-grip { + right: auto; + left: 0; +} +.sceditor-container { + border: 1px solid #d6d6d6; + border-radius: 0; + background-clip: padding-box; +} +.sceditor-container textarea { + font-family: Consolas, "Bitstream Vera Sans Mono", "Andale Mono", Monaco, "DejaVu Sans Mono", "Lucida Console", monospace; + background: #2e3436; + color: #fff; + margin: 0; + padding: 5px; +} +div.sceditor-toolbar, +div.sceditor-group { + background: #f2f2f2; + background: linear-gradient(to bottom, #f2f2f2 0%, #dddddd 89%); +} +div.sceditor-toolbar { + padding: 0; + border-bottom: 1px solid #bbb; + background-size: 100% 32px; +} +div.sceditor-group { + margin: 0; + padding: 2px 4px; + border: 0; + border-right: 1px solid #ccc; + border-left: 1px solid #eaeaea; + border-radius: 0; + background-clip: padding-box; +} +div.sceditor-group:last-child { + border-right: 0; +} +div.sceditor-group:first-child { + border-left: 0; +} +.sceditor-button { + height: 16px; + padding: 5px; + margin: 1px; + border-radius: 0; + background-clip: padding-box; +} +.sceditor-button div, +.sceditor-button svg { + margin: 0; +} +.sceditor-button.active, +.sceditor-button:hover, +.sceditor-button:active, +.sceditor-button.active:hover { + margin: 0; + box-shadow: none; +} +.sceditor-button.active { + background: #f4f4f4; + border: 1px solid #ccc; +} +.sceditor-button:hover { + background: #fefefe; + border: 1px solid #ddd; +} +.sceditor-button.disabled:hover { + margin: 1px; + border: 0; +} +.sceditor-button:active { + background: #eee; + border: 1px solid #ccc; +} +.sceditor-button.active:hover { + background: #f8f8f8; + border: 1px solid #ddd; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/emoticons/credits.txt Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,9 @@ +Presenting, Nomicons: The Full Monty :o + +Credits: +Oscar Gruno, aka Nominell v. 2.0 -> oscargruno@mac.com +Andy Fedosjeenko, aka Nightwolf -> bobo@animevanguard.com + +Copyright (C) 2001-Infinity, Oscar Gruno & Andy Fedosjeenko + +You can redistribute these files as much as you like, as long as you keep this file with them and give us the proper credit. You may even rape them if you please, just give us credit for our work. \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/example.html Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,91 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> + + <title>SCEditor Demo</title> + + <link rel="stylesheet" href="minified/themes/default.min.css" id="theme-style" /> + + <script src="minified/sceditor.min.js"></script> + <script src="minified/icons/monocons.js"></script> + <script src="minified/formats/bbcode.js"></script> + + <style> + html { + font-family: Arial, Helvetica, sans-serif; + font-size: 13px; + } + form div { + padding: .5em; + } + code:before { + position: absolute; + content: 'Code:'; + top: -1.35em; + left: 0; + } + code { + margin-top: 1.5em; + position: relative; + background: #eee; + border: 1px solid #aaa; + white-space: pre; + padding: .25em; + min-height: 1.25em; + } + code:before, code { + display: block; + text-align: left; + } + </style> + </head> + <body> + <form action="" method="post"> + <div> + <textarea id="example" style="height:300px;width:600px;">[center][size=3][b]BBCode SCEditor[/b][/size][/center] + +Give it a try! :) + +[color=#ff00]Red text! [/color][color=#3399ff]Blue?[/color] + +[ul][li]A simple list[/li][li]list item 2[/li][/ul] + +Just type [b]:[/b]) and it should be converted into :) as you type.</textarea> + + </div> + + <div> + <label for="theme">Theme:</label> + <select id="theme"> + <option value="default">Default</option> + <option value="defaultdark">Default dark</option> + <option value="modern">Modern</option> + <option value="office-toolbar">Office Toolbar</option> + <option value="office">Office</option> + <option value="square">Square</option> + </select> + </div> + </form> + + + <script> + var textarea = document.getElementById('example'); + sceditor.create(textarea, { + format: 'bbcode', + icons: 'monocons', + style: 'minified/themes/content/default.min.css' + }); + + + var themeInput = document.getElementById('theme'); + themeInput.onchange = function() { + var theme = 'minified/themes/' + themeInput.value + '.min.css'; + + document.getElementById('theme-style').href = theme; + }; + </script> + + <p>SCEditor is licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></p> + </body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/ar.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author Atramez_Zeton http://onyx-sy.net + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['ar'] = { + 'Bold': 'عريض', + 'Italic': 'مائل', + 'Underline': 'خط من الأسفل', + 'Strikethrough': 'خط في المنتصف', + 'Subscript': 'حرف منخفض', + 'Superscript': 'حرف مرتفع', + 'Align left': 'انحياز إلى اليسار', + 'Center': 'توسط', + 'Align right': 'انحياز إالى اليمين', + 'Justify': 'ملأ السطر', + 'Font Name': 'نوع الخط', + 'Font Size': 'حجم الخط', + 'Font Color': 'لون الخط', + 'Remove Formatting': 'ازالة التعديلات', + 'Cut': 'قص', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Ctrl/Cmd-X متصفحك لا يدعم اوامر القص الرجاء استخدام اختصارات لوحة التحكم', + 'Copy': 'نسخ', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Ctrl/Cmd-C متصفحك لا يدعم اوامر النسخ الرجاء استخدام اختصارات لوحة التحكم', + 'Paste': 'لصق', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Ctrl/Cmd-V متصفحك لا يدعم اوامر اللصق الرجاء استخدام اختصارات لوحة التحكم', + 'Paste your text inside the following box:': 'قم بلصق نصّك في المربع', + 'Paste Text': 'الصق النص', + 'Bullet list': 'قائمة نقطية', + 'Numbered list': 'قائمة مرقمة', + 'Undo': 'تراجع', + 'Redo': 'تقدم', + 'Rows:': 'اسطر', + 'Cols:': 'اعمدة', + 'Insert a table': 'ادرج جدول', + 'Insert a horizontal rule': 'ادرج مسطرة افقية', + 'Code': 'كود', + 'Width (optional):': 'عرض (اختياري)', + 'Height (optional):': 'ارتفاع (اختياري)', + 'Insert an image': 'ادرج صورة', + 'E-mail:': 'بريد الكتروني', + 'Insert an email': 'ادرج بريدا الكترونيا', + 'URL:': 'وصلة موقع', + 'Insert a link': 'ادرج وصلة لموقع', + 'Unlink': 'ازالة الوصلة', + 'More': 'المزيد', + 'Insert an emoticon': 'ادرج وجها', + 'Video URL:': 'وصلة فيديو', + 'Insert': 'ادرج', + 'Insert a YouTube video': 'ادرج وصلة فيديو يوتيوب', + 'Insert current date': 'ادرج التاريخ الحالي', + 'Insert current time': 'ادرج الوقت الحالي', + 'Print': 'اطبع', + 'View source': 'اظهر المصدر', + 'Description (optional):': 'الوصف (اختياري)', + 'Enter the image URL:': 'ضع وصلة الصورة', + 'Enter the e-mail address:': 'ضع عنوان البريد الإلكتروني', + 'Enter the displayed text:': 'ضع النص الذي تريد اظهاره', + 'Enter URL:': 'ضع وصلة موقع', + 'Enter the YouTube video URL or ID:': 'ضع وصلة فيديو يوتيوب او رقم الفيديو', + 'Insert a Quote': 'ادرج اقتباسا', + 'Invalid YouTube video': 'هذا الفيديو غير صالح', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/ca.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author Fran Sobrino + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['ca'] = { + 'Bold': 'Negrita', + 'Italic': 'Cursiva', + 'Underline': 'Subratlla', + 'Strikethrough': 'Ratllar', + 'Subscript': 'Sub\u00edndice', + 'Superscript': 'Super\u00edndice', + 'Align left': 'Alinear a l\'Esquerra', + 'Center': 'Centrar', + 'Align right': 'Alinear a la dreta', + 'Justify': 'Justificar', + 'Font Name': 'Tipus de Lletra', + 'Font Size': 'Mida de Lletra', + 'Font Color': 'Color de Font', + 'Remove Formatting': 'Treure Formats', + 'Cut': 'Tallar', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'O seu navegador non acepta o comando cortar. Por favor, empregue a combinaci\u00f3n Ctrl/Cmd-X', + 'Copy': 'Copiar', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'O seu navegador non acepta o comando cortar. Por favor, empregue a combinaci\u00f3n Ctrl/Cmd-C', + 'Paste': 'Pegar', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'O seu navegador non acepta o comando cortar. Por favor, empregue a combinaci\u00f3n Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Pega o texto dentro do seguinte recadro', + 'Paste Text': 'Pegar Texto', + 'Bullet list': 'Llista d\'Vinyetes', + 'Numbered list': 'Llista numerada', + 'Undo': 'Desfer', + 'Redo': 'Refer', + 'Rows:': 'Files', + 'Cols:': 'Columnes', + 'Insert a table': 'Inserir una taula', + 'Insert a horizontal rule': 'Insereix una Regla horitzontal', + 'Code': 'C\u00f3digo', + 'Width (optional):': 'Ample (Opcional)', + 'Height (optional):': 'Alçada (Opcional)', + 'Insert an image': 'Insereix una imatge', + 'E-mail:': 'Correu electrònic', + 'Insert an email': 'Insereix un Email', + 'URL:': 'URL', + 'Insert a link': 'Inserir un enllaç', + 'Unlink': 'Treure un enllaç', + 'More': 'Més', + 'Insert an emoticon': 'Inserir un emoticon', + 'Video URL:': 'URL del V\u00eddeo', + 'Insert': 'Insereix', + 'Insert a YouTube video': 'Insereix un v\u00eddeo de YouTube', + 'Insert current date': 'Insereix data actual', + 'Insert current time': 'Insereix hora actual', + 'Print': 'Imprimir', + 'View source': 'Veure C\u00f3digo', + 'Description (optional):': 'Descripci\u00f3 (Opcional):', + 'Enter the image URL:': 'Ingressar la URL de la imatge:', + 'Enter the e-mail address:': 'Ingressar el correu electr\u00f3nico:', + 'Enter the displayed text:': 'Ingressar el texto mostrat:', + 'Enter URL:': 'Entrada URL:', + 'Enter the YouTube video URL or ID:': 'Entrada URL ou ID de YouTube', + 'Insert a Quote': 'v Insereix', + 'Invalid YouTube video': 'V\u00eddeo de YouTube Inv\u00e1lido', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/cn.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author <Your Name> <Your e-mail/Website if you would like> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['cn'] = { + 'Bold': '粗体', + 'Italic': '斜体', + 'Underline': '下划线', + 'Strikethrough': '删除线', + 'Subscript': '下标', + 'Superscript': '上标', + 'Align left': '靠左对齐', + 'Center': '置中', + 'Align right': '靠右对齐', + 'Justify': '两端对齐', + 'Font Name': '字体', + 'Font Size': '字号', + 'Font Color': '字色', + 'Remove Formatting': '格式清除', + 'Cut': '剪切', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': '您的浏览器不支持剪切命令,请使用快捷键 Ctrl/Cmd-X', + 'Copy': '拷贝', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': '您的浏览器不支持拷贝命令,请使用快捷键 Ctrl/Cmd-C', + 'Paste': '粘贴', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': '您的浏览器不支持粘贴命令,请使用快捷键 Ctrl/Cmd-V', + 'Paste your text inside the following box:': '请在下面贴入您的文本', + 'Paste Text': '粘贴纯文本', + 'Bullet list': '符号列表', + 'Numbered list': '编号列表', + 'Undo': '恢复', + 'Redo': '撤消', + 'Rows:': '行数', + 'Cols:': '列数', + 'Insert a table': '插入表格', + 'Insert a horizontal rule': '插入分隔符', + 'Code': '代码', + 'Width (optional):': '宽度(选填)', + 'Height (optional):': '高度(选填)', + 'Insert an image': '插入图片', + 'E-mail:': 'Email地址', + 'Insert an email': '插入Email地址', + 'URL:': '网址', + 'Insert a link': '插入链接', + 'Unlink': '取消链接', + 'More': '更多', + 'Insert an emoticon': '插入表情符号', + 'Video URL:': '视频地址', + 'Insert': '插入', + 'Insert a YouTube video': '插入YouTube视频', + 'Insert current date': '插入当前日期', + 'Insert current time': '插入当前时间', + 'Print': '打印', + 'View source': '查看代码', + 'Description (optional):': '描述(选填)', + 'Enter the image URL:': '输入图片地址', + 'Enter the e-mail address:': '输入email地址', + 'Enter the displayed text:': '输入显示文字', + 'Enter URL:': '输入网址', + 'Enter the YouTube video URL or ID:': '输入YouTube地址或编号', + 'Insert a Quote': '插入引用', + 'Invalid YouTube video': '无效的YouTube视频', + + dateFormat: 'year-month-day' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/cs.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,71 @@ +/** + * @author Daniel Vítek danielvitek1@gmail.com danvitek.cz + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['cs'] = { + 'Bold': 'Tučné', + 'Italic': 'Kurzíva', + 'Underline': 'Podtržené', + 'Strikethrough': 'Přeškrtnuté', + 'Subscript': 'Dolní index', + 'Superscript': 'Horní index', + 'Align left': 'Zarovnat vlevo', + 'Center': 'Zarovnat na střed', + 'Align right': 'Zarovnat vpravo', + 'Justify': 'Zarovnat do bloku', + 'Font Name': 'Výběr písma', + 'Font Size': 'Velikost písma', + 'Font Color': 'Barva písma', + 'Remove Formatting': 'Vymazat formátování', + 'Cut': 'Vyjmout', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Váš prohlížeč nepodporuje tento příkaz, použijte CTRL+X', + 'Copy': 'Kopírovat', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Váš prohlížeč nepodporuje tento příkaz, použijte CTRL+C', + 'Paste': 'Vložit', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Váš prohlížeč nepodporuje tento příkaz, použijte CTRL+V', + 'Paste your text inside the following box:': 'Vložte Váš text do následujícího pole', + 'Paste Text': 'Vložit text', + 'Bullet list': 'Seznam', + 'Numbered list': 'Číslovaný seznam', + 'Undo': 'Zpět', + 'Redo': 'Vpřed', + 'Rows:': 'Řádků', + 'Cols:': 'Buněk', + 'Insert a table': 'Vložit tabulku', + 'Insert a horizontal rule': 'Vložit vodorovnou čáru', + 'Code': 'Vložit kód', + 'Width (optional):': 'Šířka (volitelné)', + 'Height (optional):': 'Výška (volitelné)', + 'Insert an image': 'Vložit obrázek', + 'E-mail:': 'E-mailová adresa', + 'Insert an email': 'Vložit e-mail', + 'URL:': 'Adresa', + 'Insert a link': 'Vložit odkaz', + 'Unlink': 'Zrušit odkaz', + 'More': 'Více', + 'Insert an emoticon': 'Vložit smajlíka', + 'Video URL:': 'Adresa videa', + 'Insert': 'Vložit', + 'Insert a YouTube video': 'Vložte video z YouTube', + 'Insert current date': 'Vložte aktuální datum', + 'Insert current time': 'Vložte aktuální čas', + 'Print': 'Vytisknout', + 'View source': 'Zobrazit zdroj', + 'Description (optional):': 'Popis (volitelné)', + 'Enter the image URL:': 'Vložte adresu obrázku', + 'Enter the e-mail address:': 'Vložte e-mailovou adresu', + 'Enter the displayed text:': 'Vložte zobrazovaný text', + 'Enter URL:': 'Vložte adresu', + 'Enter the YouTube video URL or ID:': 'Vložte adresu YouTube videa nebo ID videa', + 'Insert a Quote': 'Vložit citát', + 'Invalid YouTube video': 'Neplatné YouTube video', + 'Add indent': 'Posunout na další úroveň', + 'Remove one indent': 'Posunout na předchozí úroveň', + 'Maximize': 'Zobrazit přes celou obrazovku', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/de.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,59 @@ +(function () { + 'use strict'; + + sceditor.locale['de'] = { + 'Bold': 'Fett', + 'Italic': 'Kursiv', + 'Underline': 'Unterstrichen', + 'Strikethrough': 'Durchgestrichen', + 'Subscript': 'Tiefgestellt', + 'Superscript': 'Hochgestellt', + 'Align left': 'Linksbündig ausrichten', + 'Center': 'Zentrieren', + 'Align right': 'Rechtsbündig ausrichten', + 'Justify': 'Blocksatz', + 'Font Name': 'Schriftname', + 'Font Size': 'Schriftgröße', + 'Font Color': 'Schriftfarbe', + 'Remove Formatting': 'Formatierung entfernen', + 'Cut': 'Ausschneiden', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Ihr Browser erlaubt das Ausschneiden von Text nicht, bitte Nutzen Sie das Tastenkürzel Strg / Cmd-X', + 'Copy': 'Kopieren', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Ihr Browser erlaubt das Kopieren von Text nicht, bitte Nutzen Sie das Tastenkürzel Strg / Cmd-C', + 'Paste': 'Einfügen', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Ihr Browser erlaubt das Einfügen von Text nicht, bitte Nutzen Sie das Tastenkürzel Strg / Cmd-V', + 'Paste your text inside the following box:': 'Fügen Sie Ihren Text in die folgende Box ein', + 'Paste Text': 'Text einfügen', + 'Bullet list': 'Aufzählungsliste', + 'Numbered list': 'Nummerierte Liste', + 'Undo': 'Rückgängig machen', + 'Redo': 'Wiederherstellen', + 'Rows:': 'Zeilen', + 'Cols:': 'Spalten', + 'Insert a table': 'Tabelle einfügen', + 'Insert a horizontal rule': 'Horizontale Linie einfügen', + 'Code': 'Code', + 'Insert a Quote': 'Zitat einfügen', + 'Width (optional):': 'Breite (Optional)', + 'Height (optional):': 'Höhe (Optional)', + 'Insert an image': 'Ein Bild einfügen', + 'E-mail:': 'E-Mail', + 'Insert an email': 'E-Mail einfügen', + 'URL:': 'URL', + 'Insert a link': 'Link einfügen', + 'Unlink': 'Link entfernen', + 'More': 'Mehr', + 'Left-to-Right': 'Links nach rechts', + 'Right-to-Left': 'Rechts nach links', + 'Insert an emoticon': 'Emoticon einfügen', + 'Video URL:': 'Video URL', + 'Insert': 'Einfügen', + 'Insert a YouTube video': 'YouTube Video einfügen', + 'Insert current date': 'Aktuelles Datum einfügen', + 'Insert current time': 'Aktuelle Uhrzeit einfügen', + 'Print': 'Drucken', + 'Maximize': 'Maximieren', + 'View source': 'Quelltext ansehen', + dateFormat: 'day.month.year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/el.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author Nikos Aggelis nikosaggelis@hotmail.gr + */ +(function () { + 'use strict'; + + sceditor.locale['el'] = { + 'Bold': 'Έντονα', + 'Italic': 'Πλάγια', + 'Underline': 'Υπογραμμισμένα', + 'Strikethrough': 'Διαγραμμισμένα', + 'Subscript': 'Δείκτης', + 'Superscript': 'Εκθέτης', + 'Align left': 'Αριστερή στοίχιση', + 'Center': 'Κεντραρισμένα', + 'Align right': 'Δεξιά στοίχιση', + 'Justify': 'Πλήρης στοίχιση', + 'Font Name': 'Γραμματοσειρά', + 'Font Size': 'Μέγεθος', + 'Font Color': 'Χρώμα', + 'Remove Formatting': 'Αφαίρεση μορφοποίησης', + 'Cut': 'Αποκοπή', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Ο περιηγητής σας δεν επιτρέπει την εντολή αποκοπής. Παρακαλούμε χρησιμοποιήστε τη συντόμευση πληκτρολογίου Ctrl/Cmd-X', + 'Copy': 'Αντιγραφή', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Ο περιηγητής σας δεν επιτρέπει την εντολή αντιγραφής. Παρακαλούμε χρησιμοποιήστε τη συντόμευση πληκτρολογίου Ctrl/Cmd-C', + 'Paste': 'Επικόλληση', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Ο περιηγητής σας δεν επιτρέπει την εντολή επικόλλησης. Παρακαλούμε χρησιμοποιήστε τη συντόμευση πληκτρολογίου Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Επικολλήστε το κείμενό σας μέσα στο ακόλουθο πλαίσιο:', + 'Paste Text': 'Επικόλληση κειμένου', + 'Bullet list': 'Λίστα με κουκίδες', + 'Numbered list': 'Λίστα με αρίθμηση', + 'Undo': 'Αναίρεση', + 'Redo': 'Επανάληψη', + 'Rows:': 'Γραμμές', + 'Cols:': 'Στήλες', + 'Insert a table': 'Εισαγωγή πίνακα', + 'Insert a horizontal rule': 'Εισαγωγή οριζόντιας γραμμής', + 'Code': 'Κώδικας', + 'Width (optional):': 'Πλάτος (Προαιρετικό)', + 'Height (optional):': 'Ύψος (Προαιρετικό)', + 'Insert an image': 'Εισαγωγή εικόνας', + 'E-mail:': 'Ηλεκτρονικό ταχυδρομείο', + 'Insert an email': 'Εισαγωγή email', + 'URL:': 'Ηλεκτρονική διεύθυνση', + 'Insert a link': 'Εισαγωγή συνδέσμου', + 'Unlink': 'Κατάργηση σύνδεσης', + 'More': 'Περισσότερα', + 'Insert an emoticon': 'Εισαγωγή φατσούλας', + 'Video URL:': 'Διεύθυνση βίντεο', + 'Insert': 'Εισαγωγή', + 'Insert a YouTube video': 'Εισαγωγή βίντεο YouTube', + 'Insert current date': 'Εισαγωγή τρέχουσας ημερομηνίας', + 'Insert current time': 'Εισαγωγή τρέχουσας ώρας', + 'Print': 'Εκτύπωση', + 'Maximize': 'Μεγιστοποίηση', + 'View source': 'Προβολή πηγαίου κώδικα', + 'Description (optional):': 'Περιγραφή (προαιρετικό)', + 'Enter the image URL:': 'Εισάγετε τη διεύθυνση εικόνας', + 'Enter the e-mail address:': 'Εισάγετε τη διεύθυνση e-mail', + 'Enter the displayed text:': 'Εισάγετε το εμφανιζόμενο κείμενο', + 'Enter URL:': 'Εισάγετε διεύθυνση', + 'Enter the YouTube video URL or ID:': 'Εισάγετε τη διεύθυνση του βίντεο YouTube ή το ID', + 'Insert a Quote': 'Εισαγωγή παράθεσης', + 'Invalid YouTube video': 'Μη έγκυρο βίντεο YouTube', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/en-US.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,7 @@ +(function () { + 'use strict'; + + sceditor.locale['en-US'] = { + dateFormat: 'month/day/year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/en.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,12 @@ +(function () { + 'use strict'; + + sceditor.locale['en-GB'] = { + 'Font Color': 'Font Colour', + 'Center': 'Centre', + dateFormat: 'day/month/year' + }; + + // set this as the default English locale + sceditor.locale['en'] = sceditor.locale['en-GB']; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/es.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author <Maxpower> <maxpowerid@gmail.com/www.identi.li> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['es'] = { + 'Bold': 'Negrita', + 'Italic': 'Cursiva', + 'Underline': 'Subrayar', + 'Strikethrough': 'Tachar', + 'Subscript': 'Sub\u00edndice', + 'Superscript': 'Super\u00edndice', + 'Align left': 'Alinear a la Izquierda', + 'Center': 'Centrar', + 'Align right': 'Alinear a la Derecha', + 'Justify': 'Justificar', + 'Font Name': 'Tipo de Letra', + 'Font Size': 'Tama\u00f1o de Letra', + 'Font Color': 'Color de Fuente', + 'Remove Formatting': 'Quitar Formatos', + 'Cut': 'Cortar', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Su navegador no acepta el comando cortar. Por favor, use la combinaci\u00f3n Ctrl/Cmd-X', + 'Copy': 'Copiar', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Su navegador no acepta el comando copiar. Por favor, use la combinaci\u00f3n Ctrl/Cmd-C', + 'Paste': 'Pegar', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Su navegador no acepta el comando pegar. Por favor, use la combinaci\u00f3n Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Pega el texto dentro del siguiente recuadro', + 'Paste Text': 'Pegar Texto', + 'Bullet list': 'Lista de Vi\u00f1etas', + 'Numbered list': 'Lista Numerada', + 'Undo': 'Deshacer', + 'Redo': 'Rehacer', + 'Rows:': 'Filas', + 'Cols:': 'Columnas', + 'Insert a table': 'Insertar una Tabla', + 'Insert a horizontal rule': 'Insertar una Regla Horizontal', + 'Code': 'C\u00f3digo', + 'Width (optional):': 'Ancho (Opcional)', + 'Height (optional):': 'Altura (Opcional)', + 'Insert an image': 'Insertar una Imagen', + 'E-mail:': 'E-mail', + 'Insert an email': 'Insertar un Email', + 'URL:': 'URL', + 'Insert a link': 'Insertar un V\u00ednculo', + 'Unlink': 'Quitar V\u00ednculo', + 'More': 'M\u00e1s', + 'Insert an emoticon': 'Insertar un emoticon', + 'Video URL:': 'URL del V\u00eddeo', + 'Insert': 'Insertar', + 'Insert a YouTube video': 'Insertar un v\u00eddeo de YouTube', + 'Insert current date': 'Insertar fecha actual', + 'Insert current time': 'Insertar hora actual', + 'Print': 'Imprimir', + 'View source': 'Ver C\u00f3digo', + 'Description (optional):': 'Descripci\u00f3n (Opcional):', + 'Enter the image URL:': 'Ingresar la URL de la imagen:', + 'Enter the e-mail address:': 'Ingresar el correo electr\u00f3nico:', + 'Enter the displayed text:': 'Ingresar el texto mostrado:', + 'Enter URL:': 'Ingresar URL:', + 'Enter the YouTube video URL or ID:': 'Ingresar URL o ID de YouTube', + 'Insert a Quote': 'Insertar Cita', + 'Invalid YouTube video': 'Video de YouTube Inv\u00e1lido', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/et.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,57 @@ +(function () { + 'use strict'; + + sceditor.locale['et'] = { + 'Bold': 'Rasvane', + 'Italic': 'Kaldkiri', + 'Underline': 'Allajoonitud', + 'Strikethrough': 'Läbijoonitud', + 'Subscript': 'Allindeks', + 'Superscript': 'Ülaindeks', + 'Align left': 'Joonad vasakule', + 'Center': 'Joonda keskele', + 'Align right': 'Joonda paremale', + 'Justify': 'Joondus mõlemale poole', + 'Font Name': 'Fondi nimi', + 'Font Size': 'Fondi suurus', + 'Font Color': 'Fondi värv', + 'Remove Formatting': 'Eemalda vormindus', + 'Cut': 'Lõika', + 'Sinu veebilehitseja ei luba lõikamise käsu kasutamist. Palun kasuta kiirklahvi Ctrl/Cmd-X': '... Ctrl / Cmd-X', + 'Copy': 'Kopeeri', + 'Sinu veebilehitseja ei luba kopeerimise käsu kasutamist. Palun kasuta kiirklahvi Ctrl/Cmd-C': '... Ctrl / Cmd-C', + 'Paste': 'Aseta', + 'Sinu veebilehitseja ei luba asetamise käsu kasutamist. Palun kasuta kiirklahvi Ctrl/Cmd-V': '... Ctrl / Cmd-V', + 'Paste your text inside the following box:': 'Aseta oma tekst järgneva tekstikasti sisse', + 'Paste Text': 'Aseta tekstina', + 'Bullet list': 'Nimekiri', + 'Numbered list': 'Nummerdatud nimekiri', + 'Undo': 'Samm tagasi', + 'Redo': 'Samm edasi', + 'Rows:': 'Read', + 'Cols:': 'Veerud', + 'Insert a table': 'Sisesta tabel', + 'Insert a horizontal rule': 'Sisesta horisontaalne joon', + 'Code': 'Kood', + 'Insert a Quote': 'Sisesta tsitaat', + 'Width (optional):': 'Laius (Valikuline)', + 'Height (optional):': 'Kõrgus (Valikuline)', + 'Insert an image': 'Sisesta pilt', + 'E-mail:': 'E-post', + 'Insert an email': 'Sisesta e-posti aadress', + 'URL:': 'Link', + 'Insert a link': 'Sisesta link', + 'Unlink': 'Eemalda link', + 'More': 'Veel', + 'Insert an emoticon': 'Sisesta emotikon', + 'Video URL:': 'Video link', + 'Insert': 'Sisesta', + 'Insert a YouTube video': 'Sisesta YouTube video', + 'Insert current date': 'Sisesta praegune kuupäev', + 'Insert current time': 'Sisesta praegune kellaaeg', + 'Print': 'Prindi', + 'View source': 'Vaata lähtekoodi', + + dateFormat: 'day.month.year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/fa.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,69 @@ +// add locale:'fa', to your config options. +// Translated By Ebad Ghafoory [info@ghafoory.com] +// 2013/05/01 +(function () { + 'use strict'; + + sceditor.locale['fa'] = { + 'Bold': 'تیره', + 'Italic': 'مورب', + 'Underline': 'زیرخط', + 'Strikethrough': 'خط خورده', + 'Subscript': 'زیرنویس', + 'Superscript': 'بالانویس', + 'Align left': 'چپ چین', + 'Center': 'وسط چین', + 'Align right': 'راست چین', + 'Justify': 'همخط', + 'Font Name': 'نام قلم', + 'Font Size': 'اندازه\u200cی نوشته', + 'Font Color': 'رنگ نوشته', + 'Remove Formatting': 'پاکسازی فرمت نوشته', + 'Cut': 'برش', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'مرورگر شما اجازه برش توسط نرم\u200cافزار را نمی\u200cدهد. لطفا از دکمه\u200cهای ترکیبی Ctrl / Cmd-X استفاده کنید', + 'Copy': 'کپی', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'مرورگر شما اجازه کپی کردن توسط نرم\u200cافزار را نمی\u200cدهد. لطفا از دکمه\u200cهای ترکیبی Ctrl / Cmd-C استفاده کنید', + 'Paste': 'چسباندن', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'مرورگر شما اجازه چسباندن توسط نرم\u200cافزار را نمی\u200cدهد. لطفا از دکمه\u200cهای ترکیبی Ctrl / Cmd-V استفاده کنید', + 'Paste your text inside the following box:': 'متن خود را در داخل کادر زیر بچسبانید', + 'Paste Text': 'چسباندن متن', + 'Bullet list': 'لیست', + 'Numbered list': 'لیست عددی', + 'Undo': 'حرکت قبل', + 'Redo': 'حرکت بعد', + 'Rows:': 'تعداد ردیف', + 'Cols:': 'تعداد ستون', + 'Insert a table': 'افزودن جدول', + 'Insert a horizontal rule': 'افزودن خط افقی', + 'Code': 'کد', + 'Insert a Quote': 'افزودن نقل قول', + 'Width (optional):': 'پهنا (دلخواه):', + 'Height (optional):': 'ارتفاع (دلخواه):', + 'Insert an image': 'افزودن عکس', + 'E-mail:': 'ایمیل', + 'Insert an email': 'افزودن ایمیل', + 'URL:': 'آدرس اینترنتی', + 'Insert a link': 'افزودن لینک', + 'Unlink': 'حذف لینک', + 'More': 'بیشتر', + 'Insert an emoticon': 'افزودن شکلک', + 'Video URL:': 'آدرس اینترنتی ویدیو', + 'Insert': 'افزودن', + 'Insert a YouTube video': 'افزودن فیلم از یوتوب', + 'Insert current date': 'افزودن تاریخ اکنون', + 'Insert current time': 'افزودن زمان اکنون', + 'Print': 'چاپ', + 'View source': 'مشاهده سورس', + 'Description (optional):': 'توضیحات (دلخواه):', + 'Enter the image URL:': 'آدرس اینترنتی عکس را وارد کنید:', + 'Enter the e-mail address:': 'آدرس ایمیل را وارد کنید:', + 'Enter the displayed text:': 'متن نمایش\u200cدهنده را وارد کنید:', + 'Enter URL:': 'آدرس اینترنتی را وارد کنید:', + 'Enter the YouTube video URL or ID:': 'آدرس اینترنتی فیلم یوتوب یا شناسه ویدیو را وارد کنید:', + 'Invalid YouTube video': 'فیلم یوتوب غیر معتبر است', + 'Right-to-Left': 'راست به چپ', + 'Left-to-Right': 'چپ به راست', + + dateFormat: 'year.month.day' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/fr.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,70 @@ + +// add locale:'fr', to your config options. + +(function () { + 'use strict'; + + sceditor.locale['fr-FR'] = { + 'Bold': 'Gras', + 'Italic': 'Italique', + 'Underline': 'Souligné', + 'Strikethrough': 'Barré', + 'Subscript': 'Indice', + 'Superscript': 'Exposant', + 'Align left': 'Aligner à gauche', + 'Center': 'Centrer', + 'Align right': 'Aligner à droite', + 'Justify': 'Justifier', + 'Font Name': 'Police', + 'Font Size': 'Taille de police', + 'Font Color': 'Couleur de police', + 'Remove Formatting': 'Enlever le formatage', + 'Cut': 'Couper', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Votre navigateur n\'autorise pas la commande \'Couper\'. Merci d\'utiliser le raccourcis clavier Ctrl/Cmd+X', + 'Copy': 'Copier', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Votre navigateur n\'autorise pas la commande \'Copier\'. Merci d\'utiliser le raccourcis clavier Ctrl/Cmd+C', + 'Paste': 'Coller', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Votre navigateur n\'autorise pas la commande \'Coller\'. Merci d\'utiliser le raccourcis clavier Ctrl/Cmd+V', + 'Paste your text inside the following box:': 'Collez votre texte à l\'intérieur de ce bloc', + 'Paste Text': 'Texte collé', + 'Bullet list': 'Liste à puce', + 'Numbered list': 'Liste numérotée', + 'Undo': 'Annuler', + 'Redo': 'Rétablir', + 'Rows:': 'Lignes', + 'Cols:': 'Colonnes', + 'Insert a table': 'Insérer un tableau', + 'Insert a horizontal rule': 'Insérer une ligne horizontale', + 'Code': 'Code', + 'Insert a Quote': 'Insérer une citation', + 'Width (optional):': 'Largeur (Optionnelle)', + 'Height (optional):': 'Hauteur (Optionnelle)', + 'Insert an image': 'Insérer une image', + 'E-mail:': 'Courriel', + 'Insert an email': 'Insérer un courriel', + 'URL:': 'URL', + 'Insert a link': 'Insérer un lien', + 'Unlink': 'Supprimer un lien', + 'More': 'Plus', + 'Insert an emoticon': 'Insérer une émoticône', + 'Video URL:': 'URL Vidéo', + 'Insert': 'Insérer', + 'Insert a YouTube video': 'Insérer une vidéo YouTube', + 'Insert current date': 'Insérer la date actuelle', + 'Insert current time': 'Insérer l\'heure actuelle', + 'Print': 'Imprimer', + 'View source': 'Afficher le texte brut', + 'Description (optional):': 'Description (Optionnelle)', + 'Enter the image URL:': 'Entrez l\'URL de l\'image:', + 'Enter the e-mail address:': 'Entrez le courriel:', + 'Enter the displayed text:': 'Entrez le texte affiché:', + 'Enter URL:': 'Entrez une URL:', + 'Enter the YouTube video URL or ID:': 'Entrez l\'URL ou l\'ID de la vidéo YouTube:', + 'Invalid YouTube video': 'Vidéo YouTube invalide', + 'Right-to-Left': 'De droite à gauche', + 'Left-to-Right': 'De gauche à droite', + + dateFormat: 'day/month/year' + }; + sceditor.locale['fr'] = sceditor.locale['fr-FR']; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/gl.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author Fran Sobrino + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['gl'] = { + 'Bold': 'Negrita', + 'Italic': 'Cursiva', + 'Underline': 'Subrayar', + 'Strikethrough': 'Riscar', + 'Subscript': 'Sub\u00edndice', + 'Superscript': 'Super\u00edndice', + 'Align left': 'Alinear á Esquerda', + 'Center': 'Centrar', + 'Align right': 'Alinear á Dereita', + 'Justify': 'Xustificar', + 'Font Name': 'Tipo de Letra', + 'Font Size': 'Tama\u00f1o de Letra', + 'Font Color': 'Cor de Fonte', + 'Remove Formatting': 'Quitar Formatos', + 'Cut': 'Cortar', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'O seu navegador non acepta o comando cortar. Por favor, empregue a combinaci\u00f3n Ctrl/Cmd-X', + 'Copy': 'Copiar', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'O seu navegador non acepta o comando cortar. Por favor, empregue a combinaci\u00f3n Ctrl/Cmd-C', + 'Paste': 'Pegar', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'O seu navegador non acepta o comando cortar. Por favor, empregue a combinaci\u00f3n Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Pega o texto dentro do seguinte recadro', + 'Paste Text': 'Pegar Texto', + 'Bullet list': 'Lista de Vi\u00f1etas', + 'Numbered list': 'Lista Numerada', + 'Undo': 'Desfacer', + 'Redo': 'Refacer', + 'Rows:': 'Ringleiras', + 'Cols:': 'Columnas', + 'Insert a table': 'Engadir unha Tabla', + 'Insert a horizontal rule': 'Engadir unha Regla Horizontal', + 'Code': 'C\u00f3digo', + 'Width (optional):': 'Ancho (Opcional)', + 'Height (optional):': 'Altura (Opcional)', + 'Insert an image': 'Engadir unha Imaxen', + 'E-mail:': 'E-mail', + 'Insert an email': 'Engadir un Email', + 'URL:': 'URL', + 'Insert a link': 'Engadir un V\u00ednculo', + 'Unlink': 'Quitar V\u00ednculo', + 'More': 'M\u00e1is', + 'Insert an emoticon': 'Engadir un emoticon', + 'Video URL:': 'URL do V\u00eddeo', + 'Insert': 'Engadir', + 'Insert a YouTube video': 'Engadir un v\u00eddeo de YouTube', + 'Insert current date': 'Engadir data actual', + 'Insert current time': 'Engadir hora actual', + 'Print': 'Imprimir', + 'View source': 'Ver C\u00f3digo', + 'Description (optional):': 'Descripci\u00f3n (Opcional):', + 'Enter the image URL:': 'Ingresar a URL da imaxen:', + 'Enter the e-mail address:': 'Ingresar o correo electr\u00f3nico:', + 'Enter the displayed text:': 'Ingresar o texto mostrado:', + 'Enter URL:': 'Ingresar URL:', + 'Enter the YouTube video URL or ID:': 'Ingresar URL ou ID de YouTube', + 'Insert a Quote': 'Engadir Cita', + 'Invalid YouTube video': 'V\u00eddeo de YouTube Inv\u00e1lido', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/hu.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,69 @@ +/** + * @author Ángyán László <lacavale55@gmail.com> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + * @date 2013-08-11 + */ +(function () { + 'use strict'; + + sceditor.locale['hu'] = { + 'Bold': 'Félkövér', + 'Italic': 'Dőlt', + 'Underline': 'Aláhúzva', + 'Strikethrough': 'Áthúzva', + 'Subscript': 'Alsó index', + 'Superscript': 'Felső index', + 'Align left': 'Balra zárt', + 'Center': 'Középre zárt', + 'Align right': 'Jobbra zárt', + 'Justify': 'Sorkizárt', + 'Font Name': 'Betűtípus', + 'Font Size': 'Betű méret', + 'Font Color': 'Betű szín', + 'Remove Formatting': 'Formázás törlése', + 'Cut': 'Kivágás', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'A böngésző biztonsági beállításai nem engedik a kivágást. Használd a Ctrl/Cmd+X billetyűket.', + 'Copy': 'Másolás', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'A böngésző biztonsági beállításai nem engedik a másolást. Használd a Ctrl/Cmd+C billetyűket.', + 'Paste': 'Beillesztés', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'A böngésző biztonsági beállításai nem engedik a beillesztést. Használd a Ctrl/Cmd+V billetyűket.', + 'Paste your text inside the following box:': 'Illeszd be a szöveget a dobozba:', + 'Paste Text': 'Szöveg beszúrása', + 'Bullet list': 'Felsorolás', + 'Numbered list': 'Sorszámozott felsorolás', + 'Undo': 'Vissza', + 'Redo': 'Mégis', + 'Rows:': 'Sorok', + 'Cols:': 'Oszlopok', + 'Insert a table': 'Táblázat beszúrása', + 'Insert a horizontal rule': 'Vízszintes vonal beszúrása', + 'Code': 'Kód', + 'Width (optional):': 'Szélesség (nem kötelező):', + 'Height (optional):': 'Magasság (nem kötelező):', + 'Insert an image': 'Illessz be egy képet', + 'E-mail:': 'Email:', + 'Insert an email': 'Illessz be egy email címet.', + 'URL:': 'Honlap', + 'Insert a link': 'Hivatkozás létrehozása', + 'Unlink': 'Hivatkozás megszüntetése', + 'More': 'Több', + 'Insert an emoticon': 'Smiley beszúrása', + 'Video URL:': 'Video link:', + 'Insert': 'Beszúrás', + 'Insert a YouTube video': 'Youtube video beszúrása', + 'Insert current date': 'Szúrd be az aktuális dátumot', + 'Insert current time': 'Szúrd be a jelenlegi időt', + 'Print': 'Nyomtatás', + 'View source': 'Forrás', + 'Description (optional):': 'Hivatkozás szövege (nem kötelező)', + 'Enter the image URL:': 'Kép URL beillesztése:', + 'Enter the e-mail address:': 'Írd be az email címet:', + 'Enter the displayed text:': 'Írd be a megjelenítendő szöveget:', + 'Enter URL:': 'Írd be a linket:', + 'Enter the YouTube video URL or ID:': 'Írd be a Youtube video URL-jét vagy azonosítóját', + 'Insert a Quote': 'Idézet beszúrása', + 'Invalid YouTube video': 'Érvénytelen Youtube link', + + dateFormat: 'year.month.day.' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/id.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author Sandy Irawan (sndbkct@gmail.com) + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['id'] = { + 'Bold': 'Tebal', + 'Italic': 'Miring', + 'Underline': 'Garis Bawah', + 'Strikethrough': 'Coret', + 'Subscript': 'Tulisan dibawah garis', + 'Superscript': 'Tulisan diatas garis', + 'Align left': 'Rata Kiri', + 'Center': 'Rata Tengah', + 'Align right': 'Rata Kanan', + 'Justify': 'Rata Kanan-Kiri', + 'Font Name': 'Nama Fon', + 'Font Size': 'Ukuran Fon', + 'Font Color': 'Warna Fon', + 'Remove Formatting': 'Hapus Format', + 'Cut': 'Potong', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Browser Anda tidak memungkinkan perintah cut. Silakan gunakan shortcut keyboard Ctrl / Cmd-X ', + 'Copy': 'Salin', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Browser Anda tidak memungkinkan perintah copy. Silakan gunakan shortcut keyboard Ctrl / Cmd-C ', + 'Paste': 'Rekatkan', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Browser Anda tidak memungkinkan perintah paste. Silakan gunakan shortcut keyboard Ctrl / Cmd-V ', + 'Paste your text inside the following box:': 'Rekatkan teks Anda dalam kotak berikut:', + 'Paste Text': 'Rekatkan Teks', + 'Bullet list': 'Daftar Bullet', + 'Numbered list': 'Daftar Nomor', + 'Undo': 'Kembalikan', + 'Redo': 'Ulangi', + 'Rows:': 'Baris', + 'Cols:': 'Kolom', + 'Insert a table': 'Sisipkan sebuah tabel', + 'Insert a horizontal rule': 'Sisipkan aturan horisontal', + 'Code': 'Kode', + 'Width (optional):': 'Lebar (opsional)', + 'Height (optional):': 'Tinggi (opsional)', + 'Insert an image': 'Sisipkan Gambar', + 'E-mail:': 'Surel', + 'Insert an email': 'Sisipkan surel', + 'URL:': 'URL', + 'Insert a link': 'Sisipkan link', + 'Unlink': 'Buang Link', + 'More': 'Lainnya', + 'Insert an emoticon': 'Sisipkan emotikon', + 'Video URL:': 'URL Video', + 'Insert': 'Sisipkan', + 'Insert a YouTube video': 'Sisipkan video Youtube', + 'Insert current date': 'Sisipkan tanggal sekarang', + 'Insert current time': 'Sisipkan waktu sekarang', + 'Print': 'Print', + 'View source': 'Lihat sumber', + 'Description (optional):': 'Deskripsi (opsional)', + 'Enter the image URL:': 'Masukkan URL gambar', + 'Enter the e-mail address:': 'Masukkan alamat surel', + 'Enter the displayed text:': 'Masukkan teks yang ditampilkan', + 'Enter URL:': 'Masukkan URL', + 'Enter the YouTube video URL or ID:': 'Masukkan URL video YouTube atau ID', + 'Insert a Quote': 'Sisipkan kutipan', + 'Invalid YouTube video': 'Video YouTube yang tidak valid', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/it.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,72 @@ +/** + * @author <Tropico> <www.mangiaconsapevole.com> + * @author Gianluca Guazzo + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['it-IT'] = { + 'Bold': 'Grassetto', + 'Italic': 'Corsivo', + 'Underline': 'Sottolineato', + 'Strikethrough': 'Barrato', + 'Subscript': 'Pedice', + 'Superscript': 'Apice', + 'Align left': 'Allinea a sinistra', + 'Center': 'Centrato', + 'Align right': 'Allinea a destra', + 'Justify': 'Giustificato', + 'Font Name': 'Nome carattere', + 'Font Size': 'Dimensione carattere', + 'Font Color': 'Colore carattere', + 'Remove Formatting': 'Rimuovi formattazione', + 'Cut': 'Taglia', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Il tuo browser non permette il comando Taglia. Usa per favore la scorciatoia da tastiera Ctrl/Cmd-X', + 'Copy': 'Copia', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Il tuo browser non permette il comando Copia. Usa per favore la scorciatoia da tastiera Ctrl/Cmd-C', + 'Paste': 'Incolla', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Il tuo browser non permette il comando Incolla. Usa per favore la scorciatoia da tastiera Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Incolla il tuo testo dentro il seguente riquadro', + 'Paste Text': 'Incolla Testo', + 'Bullet list': 'Elenco puntato', + 'Numbered list': 'Elenco numerato', + 'Undo': 'Annulla', + 'Redo': 'Ripeti', + 'Rows:': 'Righe:', + 'Cols:': 'Colonne:', + 'Insert a table': 'Inserisci una tabella', + 'Insert a horizontal rule': 'Inserisci riga orizzontale', + 'Code': 'Codice', + 'Width (optional):': 'Larghezza(opzionale):', + 'Height (optional):': 'Altezza(opzionale):', + 'Insert an image': 'Inserisci un\'immagine', + 'E-mail:': 'E-mail:', + 'Insert an email': 'Inserisci una email', + 'URL:': 'URL:', + 'Insert a link': 'Inserisci collegamento(link):', + 'Unlink': 'Togli collegamento(link):', + 'More': 'Di più', + 'Insert an emoticon': 'Inserisci una emoticon', + 'Video URL:': 'URL del video', + 'Insert': 'Inserisci', + 'Insert a YouTube video': 'Inserisci un video YouTube', + 'Insert current date': 'Inserisci data corrente', + 'Insert current time': 'Inserisci ora corrente', + 'Print': 'Stampa', + 'View source': 'Vedi codice sorgente', + 'Description (optional):': 'Descrizione (opzionale):', + 'Enter the image URL:': 'Inserisci URL dell\'immagine', + 'Enter the e-mail address:': 'Inserisci indirizzo email', + 'Enter the displayed text:': 'Inserisci testo visualizzato', + 'Enter URL:': 'Inserisci URL', + 'Enter the YouTube video URL or ID:': 'Inserisci URL o ID video di YouTube', + 'Insert a Quote': 'Inserisci una citazione', + 'Invalid YouTube video': 'Video YouTube invalido', + + dateFormat: 'day-month-year' + }; + + // Set as the default Italian locale + sceditor.locale['it'] = sceditor.locale['it-IT']; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/ja.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,71 @@ +/** + * @author <Yoshihiro Misawa> <myoshi321go@gmail.com> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['ja'] = { + 'Bold': '太字', + 'Italic': '斜字', + 'Underline': '下線', + 'Strikethrough': '取り消し線', + 'Subscript': '下付き文字', + 'Superscript': '上付き文字', + 'Align left': '左揃え', + 'Center': '中央揃え', + 'Align right': '右揃え', + 'Justify': '均等揃え', + 'Font Name': 'フォント名', + 'Font Size': 'フォントサイズ', + 'Font Color': 'フォントの色', + 'Remove Formatting': '書式解除', + 'Cut': '切り取り', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'お使いのブラウザではカットコマンドを許可されていません。 キーボードショートカットの Ctrl/Cmd-X をお使いください。', + 'Copy': 'コピー', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'お使いのブラウザではコピーコマンドを許可されていません。 キーボードショートカットの Ctrl/Cmd-C をお使いください。', + 'Paste': '貼り付け', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'お使いのブラウザでは貼り付けコマンドを許可されていません。 キーボードショートカットの Ctrl/Cmd-V をお使いください。', + 'Paste your text inside the following box:': '以下にテキストを貼り付けてください。', + 'Paste Text': 'テキストを貼り付け', + 'Bullet list': '箇条書き', + 'Numbered list': '段落番号', + 'Undo': '元に戻す', + 'Redo': 'やり直す', + 'Rows:': '行数', + 'Cols:': '列数', + 'Insert a table': '表を挿入', + 'Insert a horizontal rule': '水平線を挿入', + 'Code': 'コード', + 'Width (optional):': '幅 (オプション)', + 'Height (optional):': '高さ (オプション)', + 'Insert an image': '画像を挿入', + 'E-mail:': 'メールアドレス', + 'Insert an email': 'メールアドレスを挿入', + //'URL:': ', + 'Insert a link': 'リンクを挿入', + 'Unlink': 'リンクを解除', + //'More': ', + 'Insert an emoticon': '顔文字を挿入', + 'Video URL:': '動画URL', + 'Insert': '挿入', + 'Insert a YouTube video': 'Youtubeを挿入', + 'Insert current date': '現在の日付を挿入', + 'Insert current time': '現在の時間を挿入', + 'Print': '印刷', + 'View source': 'ソースを表示', + 'Description (optional):': '説明 (オプション)', + 'Enter the image URL:': '画像URLを入力してください。', + 'Enter the e-mail address:': 'メールアドレスを入力してください。', + 'Enter the displayed text:': '表示テキストを入力してください。', + 'Enter URL:': 'URLを入力してください。', + 'Enter the YouTube video URL or ID:': 'Youtubeの動画URLまたはIDを入力してください。', + 'Insert a Quote': '引用を挿入', + 'Invalid YouTube video': '不正なYoutube動画', + 'Left-to-Right': '左から右へ', + 'Right-to-Left': '右から左へ', + 'Maximize': '最大化', + + dateFormat: 'year-month-day' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/lt.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author Team from www.klaustukai.lt + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['lt'] = { + 'Bold': 'Paryškintas', + 'Italic': 'Pasvirasis', + 'Underline': 'Pabraukti', + 'Strikethrough': 'Perbraukti', + 'Subscript': 'Parašyti sumažintas raides po žodžio', + 'Superscript': 'Parašyti sumažintas raides virš žodžio', + 'Align left': 'Kairysis lygiavimas', + 'Center': 'Centrinis lygiavimas', + 'Align right': 'Dešinysis lygiavimas', + 'Justify': 'Išlygintas tekstas', + 'Font Name': 'Šrifto pavadinimas', + 'Font Size': 'Šrifto dydis', + 'Font Color': 'Šrifto spalva', + 'Remove Formatting': 'Panaikinti teksto formatavimą', + 'Cut': 'Iškirpti', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Jūsų paieškos sistema neleidžia atlikti šios funkcijos. Norėdami iškirpti spauskite Ctrl/Cmd-x', + 'Copy': 'Kopijuoti', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Jūsų paieškos sistema neleidžia atlikti šios komandos. Norėdami nukopijuoti spauskite Ctrl/Cmd - C', + 'Paste': 'Įklijuoti', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Jūsų paieškos sistema neleidžia atlikti šios komandos. Norėdami įklijuoti spauskite Ctrl/Cmd - V', + 'Paste your text inside the following box:': 'Įklijuokite tekstą nurodytoje vietoje', + 'Paste Text': 'Įklijuoti tekstą', + 'Bullet list': 'Sugrupuotas sąrašas', + 'Numbered list': 'Sunumeruotas sąrašas', + 'Undo': 'panaikinti', + 'Redo': 'atitaisyti', + 'Rows:': 'Eilutės', + 'Cols:': 'Stulpeliai', + 'Insert a table': 'Įterpti lentelę', + 'Insert a horizontal rule': 'Įterpti horizontalią liniją', + 'Code': 'Šalies kodas', + 'Width (optional):': 'plotis (laisvai pasirenkamas)', + 'Height (optional):': 'aukštis (laisvai pasirenkamas)', + 'Insert an image': 'Įterpti nuotrauką', + 'E-mail:': 'Elektroninis paštas', + 'Insert an email': 'Įterpti elktroninio pašto nuorodą', + 'URL:': 'Internetinės svetainės adresas:', + 'Insert a link': 'Įterpti nuorodą', + 'Unlink': 'Atjungti', + 'More': 'Daugiau', + 'Insert an emoticon': 'Įterpti šypsenėlę', + 'Video URL:': 'Vaizdo klipo nuoroda', + 'Insert': 'Įterpti', + 'Insert a YouTube video': 'Įterpti Youtube vaizdo klipą', + 'Insert current date': 'Įterpti esamą datą (diena-mėnuo-metai)', + 'Insert current time': 'Įterpti esamą laiką', + 'Print': 'Atspausdinti', + 'View source': 'Peržiūrėti šaltinį', + 'Description (optional):': 'Aprašymas (laisvai pasirenkamas)', + 'Enter the image URL:': 'Įterpti nuotraukos adresą', + 'Enter the e-mail address:': 'Įterpti elektroninio pašto adresą', + 'Enter the displayed text:': 'Įvesti pavaizduotą tekstą', + 'Enter URL:': 'Įvesti internetinį adresą', + 'Enter the YouTube video URL or ID:': 'Įrašykite Youtube vaizdo klipo nuorodą ar ID', + 'Insert a Quote': 'Įterpti citatą', + 'Invalid YouTube video': 'YouTube vaizdo įrašas neveikia', + + dateFormat: 'year-month-day' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/nb.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,70 @@ +/** + * @author Katrine + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['nb-NO'] = { + 'Bold': 'Fet', + 'Italic': 'Kursiv', + 'Underline': 'Understrek', + 'Strikethrough': 'Gjennomstrek', + 'Subscript': 'Senket', + 'Superscript': 'Hevet', + 'Align left': 'Sidestill til venstre', + 'Center': 'Midstill', + 'Align right': 'Sidestill til høyre', + 'Justify': 'Normalt oppstilt', + 'Font Name': 'Skriftype', + 'Font Size': 'Skriftstørrelse', + 'Font Color': 'skriftfarge', + 'Remove Formatting': 'Fjern formatering', + 'Cut': 'Klipp', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Nettleseren din kan ikke utføre klippe kommandoen. Vennligst bruk hurtigtasten Ctrl / Cmd-X', + 'Copy': 'Kopier', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Nettleseren din kan ikke utføre kopier kommandoen. Vennligst bruk hurtigtasten Ctrl / Cmd-C', + 'Paste': 'Lim', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Nettleseren din kan ikke utføre lime kommandoen. Vennligst bruk hurtigtasten Ctrl / Cmd-V', + 'Paste your text inside the following box:': 'Lim inn teksten i den følgende boksen:', + 'Paste Text': 'Lim inn tekst', + 'Bullet list': 'Bullet liste', + 'Numbered list': 'Nummerert liste', + 'Undo': 'Angre', + 'Redo': 'Gjør på nytt', + 'Rows:': 'Rader', + 'Cols:': 'Kolonner', + 'Insert a table': 'Sett inn en tabell', + 'Insert a horizontal rule': 'Sett en horisontal regel', + 'Code': 'Kode', + 'Width (optional):': 'Bredde (valgfritt):', + 'Height (optional):': 'Høyde (valgfritt):', + 'Insert an image': 'Sett inn et bilde', + 'E-mail:': 'E-post', + 'Insert an email': 'Sett inn en e-post', + 'URL:': 'URL:', + 'Insert a link': 'Sett inn en lenke', + 'Unlink': 'Oppheve tilknytningen', + 'More': 'Mer', + 'Insert an emoticon': 'Sett inn et uttrykksikon', + 'Video URL:': 'Video URL', + 'Insert': 'Sett inn', + 'Insert a YouTube video': 'Sett inn en YouTube-video', + 'Insert current date': 'Sett inn gjeldende dato', + 'Insert current time': 'Sett inn gjeldende klokkeslett', + 'Print': 'Skriv ut', + 'View source': 'Vis kildekode', + 'Description (optional):': 'Beskrivelse (valgfritt):', + 'Enter the image URL:': 'Skriv inn bildet\'s URL:', + 'Enter the e-mail address:': 'Skriv inn e-postadresse:', + 'Enter the displayed text:': 'Skriv inn teksten som vises:', + 'Enter URL:': 'Skriv inn URL adresse:', + 'Enter the YouTube video URL or ID:': 'Angi YouTube video link eller ID:', + 'Insert a Quote': 'Sett inn sitat', + 'Invalid YouTube video': 'Ugyldig Youtube video', + + dateFormat: 'day.month.year' + }; + + sceditor.locale['nb'] = sceditor.locale['nb-NO']; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/nl.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,57 @@ +(function () { + 'use strict'; + + sceditor.locale['nl'] = { + 'Bold': 'Vet', + 'Italic': 'Schuingedrukt', + 'Underline': 'Onderstreept', + 'Strikethrough': 'Doorhalen', + 'Subscript': 'Subscript', + 'Superscript': 'Superscript', + 'Align left': 'Links uitlijnen', + 'Center': 'Centreren', + 'Align right': 'Rechts uitlijnen', + 'Justify': 'Uitvullen', + 'Font Name': 'Fontnaam', + 'Font Size': 'Fontgrootte', + 'Font Color': 'Fontkleur', + 'Remove Formatting': 'Verwijder opmaak', + 'Cut': 'Knippen', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Je browser staat het knippen commando niet toe. Gebruik de toetsenbord sneltoets Ctrl / Cmd-X', + 'Copy': 'Kopiëren', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Je browser staat het kopieer commando niet toe. Gebruik de toetsenbord sneltoets Ctrl / Cmd-C', + 'Paste': 'Plakken', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Je browser staat het plakken commando niet toe. Gebruik de toetsenbord sneltoets Ctrl / Cmd-V', + 'Paste your text inside the following box:': 'Plak je tekst in de volgende locatie:', + 'Paste Text': 'Tekst plakken', + 'Bullet list': 'Opsomming', + 'Numbered list': 'Genummerde lijst', + 'Undo': 'Ongedaan maken', + 'Redo': 'Opnieuw uitvoeren', + 'Rows:': 'Rijen', + 'Cols:': 'Kolommen', + 'Insert a table': 'Tabel', + 'Insert a horizontal rule': 'Horizontale regel', + 'Code': 'Code', + 'Insert a Quote': 'Citeren', + 'Width (optional):': 'Breedte (optioneel):', + 'Height (optional):': 'Hoogte (optioneel):', + 'Insert an image': 'Afbeelding', + 'E-mail:': 'E-mail', + 'Insert an email': 'E-mail', + 'URL:': 'URL:', + 'Insert a link': 'Link', + 'Unlink': 'Link verwijderen', + 'More': 'Meer', + 'Insert an emoticon': 'Emoticon', + 'Video URL:': 'Video URL', + 'Insert': 'Invoegen', + 'Insert a YouTube video': 'YouTube-video', + 'Insert current date': 'Huidige datum', + 'Insert current time': 'Huidige tijd', + 'Print': 'Print', + 'View source': 'Bron bekijken', + + dateFormat: 'day.month.year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/pl.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author <Mirosław Dróżdż> <miroslaw.drozdz@vert.pl/www.vert.info.pl> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['pl'] = { + 'Bold': 'Pogrubienie', + 'Italic': 'Kursywa', + 'Underline': 'Podkreślenie', + 'Strikethrough': 'Przekreślenie', + 'Subscript': 'Indeks dolny', + 'Superscript': 'Indeks górny', + 'Align left': 'Do lewej', + 'Center': 'Do środka', + 'Align right': 'Do prawej', + 'Justify': 'Wyjustowanie', + 'Font Name': 'Krój czcionki', + 'Font Size': 'Rozmiar czcionki', + 'Font Color': 'Kolor czcionki', + 'Remove Formatting': 'Usuń formatowanie', + 'Cut': 'Wytnij', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Twoja przeglądarka nie obsługuje opcji wycinania. Użyj skrótu klawiszowego Cmd/Ctrl + X', + 'Copy': 'Skopiuj', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Twoja przeglądarka nie obsługuje opcji kopiowania. Użyj skrótu klawiszowego Cmd/Ctrl + C', + 'Paste': 'Wklej', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Twoja przeglądarka nie obsługuje opcji wklejania. Użyj skrótu klawiszowego Cmd/Ctrl + V', + 'Paste your text inside the following box:': 'Wklej swój tekst do tego pola:', + 'Paste Text': 'Wklej tekst', + 'Bullet list': 'Wypunktowanie', + 'Numbered list': 'Lista numerowana', + 'Undo': 'Cofnij', + 'Redo': 'Powtórz', + 'Rows:': 'Wiersze:', + 'Cols:': 'Kolumny:', + 'Insert a table': 'Wstaw tabelę', + 'Insert a horizontal rule': 'Wstaw linię poziomą', + 'Code': 'Kod', + 'Width (optional):': 'Szerokość (opcjonalnie)', + 'Height (optional):': 'Wysokość (opcjonalnie)', + 'Insert an image': 'Wstaw obrazek', + 'E-mail:': 'E-mail', + 'Insert an email': 'Wstaw e-mail', + 'URL:': 'URL', + 'Insert a link': 'Wstaw odnośnik', + 'Unlink': 'Usuń odnośnik', + 'More': 'Więcej', + 'Insert an emoticon': 'Wstaw emotikonę', + 'Video URL:': 'URL do filmu', + 'Insert': 'Wstaw', + 'Insert a YouTube video': 'Wstaw film YouTube', + 'Insert current date': 'Wstaw aktualną datę', + 'Insert current time': 'Wstaw aktualny czas', + 'Print': 'Drukuj', + 'View source': 'Pokaż źródło', + 'Description (optional):': 'Opis (opcjonalny)', + 'Enter the image URL:': 'Wstaw URL do obrazka', + 'Enter the e-mail address:': 'Wpisz adres e-mail', + 'Enter the displayed text:': 'Wpisz wyświetlony tekst', + 'Enter URL:': 'Wpisz adres URL', + 'Enter the YouTube video URL or ID:': 'Wpisz adres URL lub ID filmu na YouTube', + 'Insert a Quote': 'Wstaw cytat', + 'Invalid YouTube video': 'Nieprawidłowy film YouTube', + + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/pt-BR.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,67 @@ +/** +* @author martec +* @license [MIT](http://www.opensource.org/licenses/mit-license.php) +*/ +(function () { + 'use strict'; + + sceditor.locale['pt-BR'] = { + 'Bold': 'Negrito', + 'Italic': 'Itálico', + 'Underline': 'Sublinhado', + 'Strikethrough': 'Rasurado', + 'Subscript': 'Subscrito', + 'Superscript': 'Sobrescrito ', + 'Align left': 'Alinhar à esquerda', + 'Center': 'Centralizar', + 'Align right': 'Alinhar à direita', + 'Justify': 'Justificar', + 'Font Name': 'Nome da fonte', + 'Font Size': 'Tamanho da fonte', + 'Font Color': 'Cor da fonte', + 'Remove Formatting': 'Remover a formatação', + 'Cut': 'Recortar', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Seu navegador não permite o comando recortar. Favor use o atalho Ctrl/Cmd-X', + 'Copy': 'Copiar', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Seu navegador não permite o comando copiar. Favor use o atalho Ctrl/Cmd-C', + 'Paste': 'Colar', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Seu navegador não permite o comando colar. Favor use o atalho Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Cole o seu texto dentro da caixa de texto a seguir:', + 'Paste Text': 'Colar o texto', + 'Bullet list': 'Lista com marcadores', + 'Numbered list': 'Lista numérica', + 'Undo': 'Desfazer', + 'Redo': 'Refazer', + 'Rows:': 'Linhas:', + 'Cols:': 'Colunas:', + 'Insert a table': 'Inserir uma tabela', + 'Insert a horizontal rule': 'Inserir uma linha horizontal', + 'Code': 'Código', + 'Width (optional):': 'Largura (opcional):', + 'Height (optional):': 'Altura (opcional):', + 'Insert an image': 'Inserir uma imagem', + 'E-mail:': 'E-mail:', + 'Insert an email': 'Inserir um e-mail', + 'URL:': 'URL:', + 'Insert a link': 'Inserir um hiperlink', + 'Unlink': 'Remover o hiperlink', + 'More': 'Mais', + 'Insert an emoticon': 'Inserir um emoticon', + 'Video URL:': 'Video URL:', + 'Insert': 'Inserir', + 'Insert a YouTube video': 'Inserir YouTube video', + 'Insert current date': 'Inserir a data atual', + 'Insert current time': 'Inserir a hora atual', + 'Print': 'Imprimir', + 'View source': 'Fonte', + 'Description (optional):': 'Descrição (opcional):', + 'Enter the image URL:': 'Informe o endereço URL da imagem:', + 'Enter the e-mail address:': 'Informe o endereço de e-mail:', + 'Enter the displayed text:': 'Digite o texto exibido:', + 'Enter URL:': 'Informe o endereço URL:', + 'Enter the YouTube video URL or ID:': 'Informe o endereço URL ou ID do YouTube:', + 'Insert a Quote': 'Inserir uma citação', + 'Invalid YouTube video': 'Vídeo do YouTube inválido', + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/pt.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,69 @@ +/** +* @author brunoais +* @license [MIT](http://www.opensource.org/licenses/mit-license.php) +*/ +(function () { + 'use strict'; + + sceditor.locale['pt-PT'] = { + 'Bold': 'Negrito', + 'Italic': 'Itálico', + 'Underline': 'Sublinhado', + 'Strikethrough': 'Rasurado', + 'Subscript': 'Subscrito', + 'Superscript': 'Sobrescrito ', + 'Align left': 'Alinhar à esquerda', + 'Center': 'Centrar', + 'Align right': 'Alinhar à direita', + 'Justify': 'Justificar', + 'Font Name': 'Nome da fonte', + 'Font Size': 'Tamanho da fonte', + 'Font Color': 'Cor da fonte', + 'Remove Formatting': 'Remover a formatação', + 'Cut': 'Cortar', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Seu navegador não permite o comando cortar. Por favor use o atalho Ctrl/Cmd-X', + 'Copy': 'Copiar', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Seu navegador não permite o comando copiar. Por favor use o atalho Ctrl/Cmd-C', + 'Paste': 'Colar', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Seu navegador não permite o comando colar. Por favor use o atalho Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Cole o seu texto dentro da caixa de texto a seguir:', + 'Paste Text': 'Colar o texto', + 'Bullet list': 'Lista com marcadores', + 'Numbered list': 'Lista numérica', + 'Undo': 'Desfazer', + 'Redo': 'Refazer', + 'Rows:': 'Linhas:', + 'Cols:': 'Colunas:', + 'Insert a table': 'Inserir uma tabela', + 'Insert a horizontal rule': 'Inserir uma linha horizontal', + 'Code': 'Código', + 'Width (optional):': 'Largura (opcional):', + 'Height (optional):': 'Altura (opcional):', + 'Insert an image': 'Inserir uma imagem', + 'E-mail:': 'E-mail:', + 'Insert an email': 'Inserir um e-mail', + 'URL:': 'URL:', + 'Insert a link': 'Inserir um hiperlink', + 'Unlink': 'Remover o hiperlink', + 'More': 'Mais', + 'Insert an emoticon': 'Inserir um emoticon', + 'Video URL:': 'Video URL:', + 'Insert': 'Inserir', + 'Insert a YouTube video': 'Inserir YouTube video', + 'Insert current date': 'Inserir a data atual', + 'Insert current time': 'Inserir a hora atual', + 'Print': 'Imprimir', + 'View source': 'Código fonte', + 'Description (optional):': 'Descrição (opcional):', + 'Enter the image URL:': 'Introduza o endereço URL da imagem:', + 'Enter the e-mail address:': 'Introduza o endereço de e-mail:', + 'Enter the displayed text:': 'Indique o texto exibido:', + 'Enter URL:': 'Introduza o endereço URL:', + 'Enter the YouTube video URL or ID:': 'Introduza o endereço URL ou o ID do video do YouTube:', + 'Insert a Quote': 'Inserir uma citação', + dateFormat: 'day/month/year' + }; + + // Set as the default Portuguese locale + sceditor.locale['pt'] = sceditor.locale['pt-PT']; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/ru.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,57 @@ +(function () { + 'use strict'; + + sceditor.locale['ru'] = { + 'Bold': 'Жирный', + 'Italic': 'Курсив', + 'Underline': 'Подчёркнутый', + 'Strikethrough': 'Зачёркнутый', + 'Subscript': 'Нижний индекс', + 'Superscript': 'Верхний индекс', + 'Align left': 'Выравнивание по левому краю', + 'Center': 'Выравнивание по центру', + 'Align right': 'Выравнивание по правому краю', + 'Justify': 'Выравнивание по обоим краям', + 'Font Name': 'Шрифт', + 'Font Size': 'Размер шрифта', + 'Font Color': 'Цвет шрифта', + 'Remove Formatting': 'Удалить форматирование', + 'Cut': 'Вырезать', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Ваш браузер не позволяет выполнять эту команду. Пожалуйста, используйте сочетание клавиш Ctrl / Cmd-X', + 'Copy': 'Копировать', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Ваш браузер не позволяет выполнять эту команду. Пожалуйста, используйте сочетание клавиш Ctrl / Cmd-C', + 'Paste': 'Выставить', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Ваш браузер не позволяет выполнять эту команду. Пожалуйста, используйте сочетание клавиш Ctrl / Cmd-V', + 'Paste your text inside the following box:': 'Вставьте текст в следующее окно:', + 'Paste Text': 'Вставить текст', + 'Bullet list': 'Маркированный список', + 'Numbered list': 'Нумерованный список', + 'Undo': 'Отменить', + 'Redo': 'Повторить', + 'Rows:': 'Строки', + 'Cols:': 'Столбцы', + 'Insert a table': 'Таблица', + 'Insert a horizontal rule': 'Горизонтальная линия', + 'Code': 'Код', + 'Insert a Quote': 'Цитата', + 'Width (optional):': 'Ширина (необязательно):', + 'Height (optional):': 'Высота (необязательно):', + 'Insert an image': 'Изображение', + 'E-mail:': 'E-mail', + 'Insert an email': 'E-mail', + 'URL:': 'URL:', + 'Insert a link': 'Ссылка', + 'Unlink': 'Удалить ссылку', + 'More': 'Больше', + 'Insert an emoticon': 'Смайлы', + 'Video URL:': 'Видео URL', + 'Insert': 'Вставить', + 'Insert a YouTube video': 'YouTube-видео', + 'Insert current date': 'Текущая дата', + 'Insert current time': 'Текущее время', + 'Print': 'Распечатать', + 'View source': 'Показать код', + 'Maximize': 'Развернуть', + dateFormat: 'day.month.year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/sk.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,70 @@ +/** + * @author Kevo <me@kevo.link> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + sceditor.locale['sk'] = { + 'Bold': 'Tučné', + 'Italic': 'Kurzíva', + 'Underline': 'Podčiarknuté', + 'Strikethrough': 'Prečiarknuté', + 'Subscript': 'Dolný index', + 'Superscript': 'Horný index', + 'Align left': 'Zarovnať vľavo', + 'Center': 'Zarovnať na stred', + 'Align right': 'Zarovnať vpravo', + 'Justify': 'Zarovnať do bloku', + 'Font Name': 'Typ písma', + 'Font Size': 'Veľkosť písma', + 'Font Color': 'Farba písma', + 'Remove Formatting': 'Odstrániť formátovanie', + 'Cut': 'Vystrihnúť', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Váš prehliadač nepodporuje príkaz pre vystrihnutie. Prosím, použite klávesovú skratku Ctrl/Cmd-X', + 'Copy': '', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Váš prehliadač nepodporuje príkaz pre skopírovanie. Prosím, použite klávesovú skratku Ctrl/Cmd-C', + 'Paste': '', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Váš prehliadač nepodporuje príkaz pre vloženie. Prosím, použite klávesovú skratku Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Vložte Váš text do nasledujúceho poľa', + 'Paste Text': 'Vložiť text', + 'Bullet list': 'Zoznam', + 'Numbered list': 'Číslovaný zoznam', + 'Undo': 'Krok späť', + 'Redo': 'Krok vpred', + 'Rows:': 'Riadkov:', + 'Cols:': 'Stĺpcov:', + 'Insert a table': 'Vložiť tabuľku', + 'Insert a horizontal rule': 'Vložiť vodorovnú čiaru', + 'Code': 'Vložiť kód', + 'Width (optional):': 'Šírka (voliteľné):', + 'Height (optional):': 'Výška (voliteľné):', + 'Insert an image': 'Vložiť obrázok', + 'E-mail:': 'E-mail:', + 'Insert an email': 'Vložiť E-mail', + 'URL:': 'URL adresa:', + 'Insert a link': 'Vložiť odkaz', + 'Unlink': 'Zrušiť odkaz', + 'More': 'Viac', + 'Insert an emoticon': 'Vložiť smajlíka', + 'Video URL:': 'URL adresa videa:', + 'Insert': 'Vložiť', + 'Insert a YouTube video': 'Vložiť YouTube video', + 'Insert current date': 'Vložiť dnešný dátum', + 'Insert current time': 'Vložiť aktuálny čas', + 'Print': 'Vytlačiť', + 'View source': 'Zobraziť zdrojový kód', + 'Description (optional):': 'Popis (voliteľné):', + 'Enter the image URL:': 'Vložte URL adresu obrázka:', + 'Enter the e-mail address:': 'Vložte E-mailovú adresu:', + 'Enter the displayed text:': 'Vložte zobrazovaný text:', + 'Enter URL:': 'Vložte URL adresu:', + 'Enter the YouTube video URL or ID:': 'Vložte URL adresu YouTube videa alebo jeho ID:', + 'Insert a Quote': 'Vložiť citát', + 'Invalid YouTube video': 'Neplatné YouTube video', + 'Left-to-Right': 'Zľava doprava', + 'Right-to-Left': 'Zprava doľava', + 'Drop files here': 'Presuňte súbory sem', + 'Maximize': 'Maximalizovať', + dateFormat: 'day. month. year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/sv.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,58 @@ +(function () { + 'use strict'; + + sceditor.locale['sv-SE'] = { + 'Bold': 'Fet', + 'Italic': 'Kursiv', + 'Underline': 'Understruken', + 'Strikethrough': 'Genomstruken', + 'Subscript': 'Nersänkt', + 'Superscript': 'Upphöjt', + 'Align left': 'Vänsterställ', + 'Center': 'Centrera', + 'Align right': 'Högerställ', + 'Justify': 'Normalt oppstilt', + 'Font Name': 'Teckensnitt', + 'Font Size': 'Teckenstorlek', + 'Font Color': 'Teckenfärg', + 'Remove Formatting': 'Ta bort formatering', + 'Cut': 'Klipp ut', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Din webbläsare kan inte utföra kommandot. Vänligen använd kortkommando Ctrl / Cmd-X', + 'Copy': 'Kopiera', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Din webbläsare kan inte utföra kommandot. Vänligen använd kortkommando Ctrl / Cmd-C', + 'Paste': 'Klista in', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Din webbläsare kan inte utföra kommandot. Vänligen använd kortkommando Ctrl / Cmd-V', + 'Paste your text inside the following box:': 'Klistra in din text i rutan:', + 'Paste Text': 'Klistra in text', + 'Bullet list': 'Lista', + 'Numbered list': 'Numrerad lista', + 'Undo': 'Ångra', + 'Redo': 'Gör om', + 'Rows:': 'Rader', + 'Cols:': 'Kolumner', + 'Insert a table': 'Infoga tabell', + 'Insert a horizontal rule': 'Infoga skiljestreck', + 'Code': 'Kod', + 'Width (optional):': 'Bredd (valfritt):', + 'Height (optional):': 'Höjd (valfritt):', + 'Insert an image': 'Infoga bild', + 'E-mail:': 'E-post', + 'Insert an email': 'Infoga e-post', + 'URL:': 'URL:', + 'Insert a link': 'Infoga länk', + 'Unlink': 'Ta bort länk', + 'More': 'Mer', + 'Insert an emoticon': 'Infoga smiley', + 'Video URL:': 'Video URL', + 'Insert': 'Infoga', + 'Insert a YouTube video': 'Infoga YouTube-video', + 'Insert current date': 'Infoga dagens datum', + 'Insert current time': 'Infoga nuvarande tid', + 'Print': 'Skriv ut', + 'View source': 'Visa källkod', + 'Description (optional):': 'Beskrivning (valfritt):', + dateFormat: 'year-month-day' + }; + + sceditor.locale['sv'] = sceditor.locale['sv-SE']; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/template.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,75 @@ +/** + * @author <Your Name> <Your e-mail/Website if you would like> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + // Replace <code> with the language code, e.g. no, fr, en, ect. + sceditor.locale['<code>'] = { + + // Original string is on the left, place the translation between + // the quotes on the right + 'Bold': '', + 'Italic': '', + 'Underline': '', + 'Strikethrough': '', + 'Subscript': '', + 'Superscript': '', + 'Align left': '', + 'Center': '', + 'Align right': '', + 'Justify': '', + 'Font Name': '', + 'Font Size': '', + 'Font Color': '', + 'Remove Formatting': '', + 'Cut': '', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': '', + 'Copy': '', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': '', + 'Paste': '', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': '', + 'Paste your text inside the following box:': '', + 'Paste Text': '', + 'Bullet list': '', + 'Numbered list': '', + 'Undo': '', + 'Redo': '', + 'Rows:': '', + 'Cols:': '', + 'Insert a table': '', + 'Insert a horizontal rule': '', + 'Code': '', + 'Width (optional):': '', + 'Height (optional):': '', + 'Insert an image': '', + 'E-mail:': '', + 'Insert an email': '', + 'URL:': '', + 'Insert a link': '', + 'Unlink': '', + 'More': '', + 'Insert an emoticon': '', + 'Video URL:': '', + 'Insert': '', + 'Insert a YouTube video': '', + 'Insert current date': '', + 'Insert current time': '', + 'Print': '', + 'View source': '', + 'Description (optional):': '', + 'Enter the image URL:': '', + 'Enter the e-mail address:': '', + 'Enter the displayed text:': '', + 'Enter URL:': '', + 'Enter the YouTube video URL or ID:': '', + 'Insert a Quote': '', + 'Invalid YouTube video': '', + 'Drop files here': '', + + // month format, replace - with the date format separator and order in the + // order used + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/tr.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,66 @@ +/** + * @author Mahmut Yaman - iletisim@/m-yaman.com + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + sceditor.locale['tr'] = { + 'Bold': 'Kalın', + 'Italic': 'İtalik', + 'Underline': 'Altı çizgili', + 'Strikethrough': 'Üstü çizgili', + 'Subscript': 'Simge', + 'Superscript': 'Üstsimge', + 'Align left': 'Sola yasla', + 'Center': 'Ortala', + 'Align right': 'Sağa yasla', + 'Justify': 'Satır uzunluğuna ayarla', + 'Font Name': 'Yazı tipi', + 'Font Size': 'Yazı boyutu', + 'Font Color': 'Yazı rengi', + 'Remove Formatting': 'Biçimlendirmeyi temizle', + 'Cut': 'Kes', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Tarayıcınız kesme komutuna izin vermiyor. Lütfen Ctrl/Cmd-X klavye kısayolunu kullanın.', + 'Copy': 'Kopyala', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Tarayıcınız kopyalama komutuna izin vermiyor. Lütfen Ctrl/Cmd-C klavye kısayolunu kullanın.', + 'Paste': 'Yapıştır', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Tarayıcınız yapıştırma komutuna izin vermiyor. Lütfen Ctrl/Cmd-V klavye kısayolunu kullanın.', + 'Paste your text inside the following box:': 'Yazınızı bu kutucuğa yapıştırın:', + 'Paste Text': 'Metin Yapıştır', + 'Bullet list': 'Madde işaretli liste', + 'Numbered list': 'Numaralı liste', + 'Undo': 'Geri al', + 'Redo': 'Yinele', + 'Rows:': 'Sütun:', + 'Cols:': 'Kolon:', + 'Insert a table': 'Tablo ekle', + 'Insert a horizontal rule': 'Yatay ayraç ekle', + 'Code': 'Kod', + 'Width (optional):': 'Genişlik (opsiyonel):', + 'Height (optional):': 'Yükseklik (opsiyonel):', + 'Insert an image': 'Resim ekle', + 'E-mail:': 'E-posta:', + 'Insert an email': 'E-posta ekle', + 'URL:': 'URL:', + 'Insert a link': 'Bağlantı ekle', + 'Unlink': 'Bağlantıyı kaldır', + 'More': 'Daha fazla', + 'Insert an emoticon': 'Yüz ifadesi ekle', + 'Video URL:': 'Video URL:', + 'Insert': 'Ekle', + 'Insert a YouTube video': 'YouTube videosu ekle', + 'Insert current date': 'Şuanki tarihi ekle', + 'Insert current time': 'Şuanki saati ekle', + 'Print': 'Yazdır', + 'View source': 'Kaynağı görüntüle', + 'Description (optional):': 'Açıklama (opsiyonel):', + 'Enter the image URL:': 'Resim URL\'sini girin:', + 'Enter the e-mail address:': 'E-posta adresini girin:', + 'Enter the displayed text:': 'Görünecek yazıyı girin:', + 'Enter URL:': 'URL\'yi girin:', + 'Enter the YouTube video URL or ID:': 'YouTube video URL\'sini yada ID\'sini girin:', + 'Insert a Quote': 'Alıntı ekle', + 'Invalid YouTube video': 'Geçersiz YouTube videosu', + dateFormat: 'day-month-year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/tw.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author <Your Name> <Your e-mail/Website if you would like> + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['tw'] = { + 'Bold': '粗體', + 'Italic': '斜體', + 'Underline': '底線', + 'Strikethrough': '删除線', + 'Subscript': '下標', + 'Superscript': '上標', + 'Align left': '靠左對齊', + 'Center': '置中', + 'Align right': '靠右對齊', + 'Justify': '兩端對齊', + 'Font Name': '字形', + 'Font Size': '字體大小', + 'Font Color': '文字顏色', + 'Remove Formatting': '清除格式', + 'Cut': '剪下', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': '您的瀏覽器不支持剪下命令,請使用快速键 Ctrl/Cmd-X', + 'Copy': '拷貝', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': '您的瀏覽器不支持拷貝命令,請使用快速键 Ctrl/Cmd-C', + 'Paste': '貼上', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': '您的瀏覽器不支持貼上命令,請使用快速键 Ctrl/Cmd-V', + 'Paste your text inside the following box:': '請在下面貼上您的文字', + 'Paste Text': '貼上纯文字', + 'Bullet list': '符號列表', + 'Numbered list': '编號列表', + 'Undo': '復原', + 'Redo': '重做', + 'Rows:': '行數', + 'Cols:': '列數', + 'Insert a table': '插入表格', + 'Insert a horizontal rule': '插入分隔線', + 'Code': '原始碼', + 'Width (optional):': '寬度(選填)', + 'Height (optional):': '高度(選填)', + 'Insert an image': '插入圖片', + 'E-mail:': 'Email', + 'Insert an email': '插入Email', + 'URL:': '網址', + 'Insert a link': '插入超鏈結', + 'Unlink': '取消超鏈結', + 'More': '更多', + 'Insert an emoticon': '插入表情符號', + 'Video URL:': '影片網址', + 'Insert': '插入', + 'Insert a YouTube video': '插入 YouTube 影片', + 'Insert current date': '插入目前日期', + 'Insert current time': '插入目前時間', + 'Print': '列印', + 'View source': '查看原始碼', + 'Description (optional):': '描述(選填)', + 'Enter the image URL:': '輸入圖片網址', + 'Enter the e-mail address:': '輸入 Email', + 'Enter the displayed text:': '輸入顯示文字', + 'Enter URL:': '輸入網址', + 'Enter the YouTube video URL or ID:': '輸入 YouTube 網址或影片编號', + 'Insert a Quote': '插入引用', + 'Invalid YouTube video': '無效的YouTube影片', + + dateFormat: 'year-month-day' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/uk.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,57 @@ +(function () { + 'use strict'; + + sceditor.locale['uk'] = { + 'Bold': 'Жирний', + 'Italic': 'Курсив', + 'Underline': 'Підкреслений', + 'Strikethrough': 'Закреслений', + 'Subscript': 'Нижній індекс', + 'Superscript': 'Верхній індекс', + 'Align left': 'Вирівняти по лівому краю', + 'Center': 'Вирівняти по центру', + 'Align right': 'Вирівняти по правому краю', + 'Justify': 'Вирівняти по ширині', + 'Font Name': 'Шрифт', + 'Font Size': 'Розмір шрифту', + 'Font Color': 'Колір шрифту', + 'Remove Formatting': 'Видалити форматування', + 'Cut': 'Вирізати', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Ваш браузер не дозволяє виконати цю команду. Будь ласка, використовуйте комбінацію клавіш Ctrl/Cmd-X', + 'Copy': 'Копіювати', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Ваш браузер не дозволяє виконати цю команду. Будь ласка, використовуйте комбінацію клавіш Ctrl/Cmd-C', + 'Paste': 'Вставити', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Ваш браузер не дозволяє виконати цю команду. Будь ласка, використовуйте комбінацію клавіш Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Вставте текст у наступне вікно:', + 'Paste Text': 'Вставити текст', + 'Bullet list': 'Маркований список', + 'Numbered list': 'Нумерований список', + 'Undo': 'Відмінити', + 'Redo': 'Повторити', + 'Rows:': 'Рядків:', + 'Cols:': 'Cтовпців:', + 'Insert a table': 'Додати таблицю', + 'Insert a horizontal rule': 'Додати горизонтальну лінію', + 'Code': 'Код', + 'Insert a Quote': 'Додати цитату', + 'Width (optional):': 'Ширина (необов\'язково):', + 'Height (optional):': 'Висота (необов\'язково):', + 'Insert an image': 'Додати зображення', + 'E-mail:': 'E-mail:', + 'Insert an email': 'Додати E-mail', + 'URL:': 'URL:', + 'Insert a link': 'Додати посилання', + 'Unlink': 'Видалити посилання', + 'More': 'Більше', + 'Insert an emoticon': 'Додати смайлик', + 'Video URL:': 'URL відео:', + 'Insert': 'Вставити', + 'Insert a YouTube video': 'Додати відео з YouTube', + 'Insert current date': 'Додати дату', + 'Insert current time': 'Додати час', + 'Print': 'Надрукувати', + 'View source': 'Показати код', + 'Maximize': 'Розгорнути редактор', + dateFormat: 'day.month.year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/languages/vi.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,68 @@ +/** + * @author Chien + * @license [MIT](http://www.opensource.org/licenses/mit-license.php) + */ +(function () { + 'use strict'; + + sceditor.locale['vi'] = { + 'Bold': 'Đậm', + 'Italic': 'Nghiêng', + 'Underline': 'Gạch chân', + 'Strikethrough': 'Gạch giữa', + 'Subscript': 'Hệ số', + 'Superscript': 'Mũ', + 'Align left': 'Căn trái', + 'Center': 'Căn giữa', + 'Align right': 'Căn phải', + 'Justify': 'Căn đều', + 'Font Name': 'Phông chữ', + 'Font Size': 'Cỡ chữ', + 'Font Color': 'Màu chữ', + 'Remove Formatting': 'Xóa định dạng', + 'Cut': 'Cắt', + 'Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X': 'Trình duyệt không cho phép sử dụng lệnh Cut. Vui lòng sử dụng phím tắt Ctrl/Cmd-X', + 'Copy': 'Sao chép', + 'Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C': 'Trình duyệt không cho phép sử dụng lệnh Copy. Vui lòng sử dụng phím tắt Ctrl/Cmd-C', + 'Paste': 'Chép vào', + 'Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V': 'Trình duyệt không cho phép sử dụng lệnh Paste. Vui lòng sử dụng phím tắt Ctrl/Cmd-V', + 'Paste your text inside the following box:': 'Chép nội dung text vào khung sau', + 'Paste Text': 'Chép nội dung text', + 'Bullet list': 'Danh sách kiểu nốt', + 'Numbered list': 'Danh sách kiểu số', + 'Undo': 'Hủy bỏ', + 'Redo': 'Trở lại bước trước', + 'Rows:': 'Số dòng', + 'Cols:': 'Số cột', + 'Insert a table': 'Thêm bảng', + 'Insert a horizontal rule': 'Thêm thước ngang', + 'Code': 'Mã code', + 'Width (optional):': 'Dài (không bắt buộc)', + 'Height (optional):': 'Rộng (không bắt buộc)', + 'Insert an image': 'Chèn hình ảnh', + 'E-mail:': 'E-mail', + 'Insert an email': 'Chèn email', + 'URL:': 'Liên kết', + 'Insert a link': 'Chèn liên kết', + 'Unlink': 'Bỏ liên kết', + 'More': 'Xem thêm', + 'Insert an emoticon': 'Chèn biểu tượng', + 'Video URL:': 'Đường dẫn của Video', + 'Insert': 'Thêm vào', + 'Insert a YouTube video': 'Chèn Youtube', + 'Insert current date': 'Chèn ngày hiện tại', + 'Insert current time': 'Chèn thời gian hiện tại', + 'Print': 'In ấn', + 'View source': 'Xem mã nguồn', + 'Description (optional):': 'Mô tả (không bắt buộc)', + 'Enter the image URL:': 'Nhập vào đường dẫn của hình ảnh', + 'Enter the e-mail address:': 'Nhập vào địa chỉ email', + 'Enter the displayed text:': 'Nhập vào nội dung hiển thị', + 'Enter URL:': 'Nhập vào liên kết', + 'Enter the YouTube video URL or ID:': 'Nhập vào liên kết của video hoặc ID trên Youtube', + 'Insert a Quote': 'Chèn trích dẫn', + 'Invalid YouTube video': 'Video Youtube không chính xác', + + dateFormat: 'day/month/year' + }; +})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/formats/bbcode.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(t){"use strict";var f=t.escapeEntities,o=t.escapeUriScheme,d=t.dom,e=t.utils,h=d.css,m=d.attr,p=d.is,n=e.extend,g=e.each,v="data-sceditor-emoticon",l=t.command.get,b={always:1,never:2,auto:3},r={bold:{txtExec:["[b]","[/b]"]},italic:{txtExec:["[i]","[/i]"]},underline:{txtExec:["[u]","[/u]"]},strike:{txtExec:["[s]","[/s]"]},subscript:{txtExec:["[sub]","[/sub]"]},superscript:{txtExec:["[sup]","[/sup]"]},left:{txtExec:["[left]","[/left]"]},center:{txtExec:["[center]","[/center]"]},right:{txtExec:["[right]","[/right]"]},justify:{txtExec:["[justify]","[/justify]"]},font:{txtExec:function(t){var e=this;l("font")._dropDown(e,t,function(t){e.insertText("[font="+t+"]","[/font]")})}},size:{txtExec:function(t){var e=this;l("size")._dropDown(e,t,function(t){e.insertText("[size="+t+"]","[/size]")})}},color:{txtExec:function(t){var e=this;l("color")._dropDown(e,t,function(t){e.insertText("[color="+t+"]","[/color]")})}},bulletlist:{txtExec:function(t,e){this.insertText("[ul]\n[li]"+e.split(/\r?\n/).join("[/li]\n[li]")+"[/li]\n[/ul]")}},orderedlist:{txtExec:function(t,e){this.insertText("[ol]\n[li]"+e.split(/\r?\n/).join("[/li]\n[li]")+"[/li]\n[/ol]")}},table:{txtExec:["[table][tr][td]","[/td][/tr][/table]"]},horizontalrule:{txtExec:["[hr]"]},code:{txtExec:["[code]","[/code]"]},image:{txtExec:function(t,e){var i=this;l("image")._dropDown(i,t,e,function(t,e,n){var r="";e&&(r+=" width="+e),n&&(r+=" height="+n),i.insertText("[img"+r+"]"+t+"[/img]")})}},email:{txtExec:function(t,n){var r=this;l("email")._dropDown(r,t,function(t,e){r.insertText("[email="+t+"]"+(e||n||t)+"[/email]")})}},link:{txtExec:function(t,n){var r=this;l("link")._dropDown(r,t,function(t,e){r.insertText("[url="+t+"]"+(e||n||t)+"[/url]")})}},quote:{txtExec:["[quote]","[/quote]"]},youtube:{txtExec:function(t){var e=this;l("youtube")._dropDown(e,t,function(t){e.insertText("[youtube]"+t+"[/youtube]")})}},rtl:{txtExec:["[rtl]","[/rtl]"]},ltr:{txtExec:["[ltr]","[/ltr]"]}},y={b:{tags:{b:null,strong:null},styles:{"font-weight":["bold","bolder","401","700","800","900"]},format:"[b]{0}[/b]",html:"<strong>{0}</strong>"},i:{tags:{i:null,em:null},styles:{"font-style":["italic","oblique"]},format:"[i]{0}[/i]",html:"<em>{0}</em>"},u:{tags:{u:null},styles:{"text-decoration":["underline"]},format:"[u]{0}[/u]",html:"<u>{0}</u>"},s:{tags:{s:null,strike:null},styles:{"text-decoration":["line-through"]},format:"[s]{0}[/s]",html:"<s>{0}</s>"},sub:{tags:{sub:null},format:"[sub]{0}[/sub]",html:"<sub>{0}</sub>"},sup:{tags:{sup:null},format:"[sup]{0}[/sup]",html:"<sup>{0}</sup>"},font:{tags:{font:{face:null}},styles:{"font-family":null},quoteType:b.never,format:function(t,e){var n;return"[font="+w(n=!p(t,"font")||!(n=m(t,"face"))?h(t,"font-family"):n)+"]"+e+"[/font]"},html:'<font face="{defaultattr}">{0}</font>'},size:{tags:{font:{size:null}},styles:{"font-size":null},format:function(t,e){var n=m(t,"size"),r=2;return-1<(n=n||h(t,"fontSize")).indexOf("px")?((n=+n.replace("px",""))<12&&(r=1),15<n&&(r=3),17<n&&(r=4),23<n&&(r=5),31<n&&(r=6),47<n&&(r=7)):r=n,"[size="+r+"]"+e+"[/size]"},html:'<font size="{defaultattr}">{!0}</font>'},color:{tags:{font:{color:null}},styles:{color:null},quoteType:b.never,format:function(t,e){var n;return"[color="+s(n=!p(t,"font")||!(n=m(t,"color"))?t.style.color||h(t,"color"):n)+"]"+e+"[/color]"},html:function(t,e,n){return'<font color="'+f(s(e.defaultattr),!0)+'">'+n+"</font>"}},ul:{tags:{ul:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ul]{0}[/ul]",html:"<ul>{0}</ul>"},list:{breakStart:!0,isInline:!1,skipLastLineBreak:!0,html:"<ul>{0}</ul>"},ol:{tags:{ol:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ol]{0}[/ol]",html:"<ol>{0}</ol>"},li:{tags:{li:null},isInline:!1,closedBy:["/ul","/ol","/list","*","li"],format:"[li]{0}[/li]",html:"<li>{0}</li>"},"*":{isInline:!1,closedBy:["/ul","/ol","/list","*","li"],html:"<li>{0}</li>"},table:{tags:{table:null},isInline:!1,isHtmlInline:!0,skipLastLineBreak:!0,format:"[table]{0}[/table]",html:"<table>{0}</table>"},tr:{tags:{tr:null},isInline:!1,skipLastLineBreak:!0,format:"[tr]{0}[/tr]",html:"<tr>{0}</tr>"},th:{tags:{th:null},allowsEmpty:!0,isInline:!1,format:"[th]{0}[/th]",html:"<th>{0}</th>"},td:{tags:{td:null},allowsEmpty:!0,isInline:!1,format:"[td]{0}[/td]",html:"<td>{0}</td>"},emoticon:{allowsEmpty:!0,tags:{img:{src:null,"data-sceditor-emoticon":null}},format:function(t,e){return m(t,v)+e},html:"{0}"},hr:{tags:{hr:null},allowsEmpty:!0,isSelfClosing:!0,isInline:!1,format:"[hr]{0}",html:"<hr />"},img:{allowsEmpty:!0,tags:{img:{src:null}},allowedChildren:["#"],quoteType:b.never,format:function(e,t){var n="",r=function(t){return e.style?e.style[t]:null};return m(e,v)?t:(t=m(e,"width")||r("width"),r=m(e,"height")||r("height"),"[img"+(n=e.complete&&(t||r)||t&&r?"="+d.width(e)+"x"+d.height(e):n)+"]"+m(e,"src")+"[/img]")},html:function(t,e,n){var r="",i=e.width,l=e.height;return e.defaultattr&&(i=(e=e.defaultattr.split(/x/i))[0],l=2===e.length?e[1]:e[0]),void 0!==i&&(r+=' width="'+f(i,!0)+'"'),void 0!==l&&(r+=' height="'+f(l,!0)+'"'),"<img"+r+' src="'+o(n)+'" />'}},url:{allowsEmpty:!0,tags:{a:{href:null}},quoteType:b.never,format:function(t,e){t=m(t,"href");return"mailto:"===t.substr(0,7)?'[email="'+t.substr(7)+'"]'+e+"[/email]":"[url="+t+"]"+e+"[/url]"},html:function(t,e,n){return e.defaultattr=f(e.defaultattr,!0)||n,'<a href="'+o(e.defaultattr)+'">'+n+"</a>"}},email:{quoteType:b.never,html:function(t,e,n){return'<a href="mailto:'+(f(e.defaultattr,!0)||n)+'">'+n+"</a>"}},quote:{tags:{blockquote:null},isInline:!1,quoteType:b.never,format:function(t,e){for(var n,r="data-author",i="",l=t.children,o=0;!n&&o<l.length;o++)p(l[o],"cite")&&(n=l[o]);return(n||m(t,r))&&(i=n&&n.textContent||m(t,r),m(t,r,i),n&&t.removeChild(n),e=this.elementToBbcode(t),i="="+i.replace(/(^\s+|\s+$)/g,""),n&&t.insertBefore(n,t.firstChild)),"[quote"+i+"]"+e+"[/quote]"},html:function(t,e,n){return"<blockquote>"+(n=e.defaultattr?"<cite>"+f(e.defaultattr)+"</cite>"+n:n)+"</blockquote>"}},code:{tags:{code:null},isInline:!1,allowedChildren:["#","#newline"],format:"[code]{0}[/code]",html:"<code>{0}</code>"},left:{styles:{"text-align":["left","-webkit-left","-moz-left","-khtml-left"]},isInline:!1,allowsEmpty:!0,format:"[left]{0}[/left]",html:'<div align="left">{0}</div>'},center:{styles:{"text-align":["center","-webkit-center","-moz-center","-khtml-center"]},isInline:!1,allowsEmpty:!0,format:"[center]{0}[/center]",html:'<div align="center">{0}</div>'},right:{styles:{"text-align":["right","-webkit-right","-moz-right","-khtml-right"]},isInline:!1,allowsEmpty:!0,format:"[right]{0}[/right]",html:'<div align="right">{0}</div>'},justify:{styles:{"text-align":["justify","-webkit-justify","-moz-justify","-khtml-justify"]},isInline:!1,allowsEmpty:!0,format:"[justify]{0}[/justify]",html:'<div align="justify">{0}</div>'},youtube:{allowsEmpty:!0,tags:{iframe:{"data-youtube-id":null}},format:function(t,e){return(t=m(t,"data-youtube-id"))?"[youtube]"+t+"[/youtube]":e},html:'<iframe width="560" height="315" frameborder="0" src="https://www.youtube-nocookie.com/embed/{0}?wmode=opaque" data-youtube-id="{0}" allowfullscreen></iframe>'},rtl:{styles:{direction:["rtl"]},isInline:!1,format:"[rtl]{0}[/rtl]",html:'<div style="direction: rtl">{0}</div>'},ltr:{styles:{direction:["ltr"]},isInline:!1,format:"[ltr]{0}[/ltr]",html:'<div style="direction: ltr">{0}</div>'},ignore:{}};function x(t,r){return t.replace(/\{([^}]+)\}/g,function(t,e){var n=!0;return"!"===e.charAt(0)&&(n=!1,e=e.substring(1)),"0"===e&&(n=!1),void 0===r[e]?t:n?f(r[e],!0):r[e]})}function k(t){return"function"==typeof t}function w(t){return t&&t.replace(/\\(.)/g,"$1").replace(/^(["'])(.*?)\1$/,"$2")}var E="open",B="content",C="newline",I="close";function a(t,e,n,r,i,l){var o=this;o.type=t,o.name=e,o.val=n,o.attrs=r||{},o.children=i||[],o.closing=l||null}function T(t){var m=this;function o(t,e){var n,r,i;return t===E&&(n=e.match(/\[([^\]\s=]+)(?:([^\]]+))?\]/))&&(i=l(n[1]),n[2]&&(n[2]=n[2].trim())&&(r=function(t){var e,n=/([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g,r={};if("="===t.charAt(0)&&t.indexOf("=",1)<0)r.defaultattr=w(t.substr(1));else for("="===t.charAt(0)&&(t="defaultattr"+t);e=n.exec(t);)r[l(e[1])]=w(e[3])||e[4];return r}(n[2]))),t===I&&(n=e.match(/\[\/([^\[\]]+)\]/))&&(i=l(n[1])),(i=t===C?"#newline":i)&&(t!==E&&t!==I||y[i])||(t=B,i="#"),new a(t,i,e,r)}function d(t,e,n){for(var r=n.length;r--;)if(n[r].type===e&&n[r].name===t)return 1}function h(t,e){t=(t?y[t.name]:{}).allowedChildren;return!m.opts.fixInvalidChildren||!t||-1<t.indexOf(e.name||"#")}function p(t,e,n){var r=/\s|=/.test(t);return k(e)?e(t,n):e===b.never||e===b.auto&&!r?t:'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function g(t){return t.length?t[t.length-1]:null}function l(t){return t.toLowerCase()}m.opts=n({},T.defaults,t),m.tokenize=function(t){var e,n,r,i=[],l=[{type:B,regex:/^([^\[\r\n]+|\[)/},{type:C,regex:/^(\r\n|\r|\n)/},{type:E,regex:/^\[[^\[\]]+\]/},{type:I,regex:/^\[\/[^\[\]]+\]/}];t:for(;t.length;){for(r=l.length;r--;)if(n=l[r].type,(e=t.match(l[r].regex))&&e[0]){i.push(o(n,e[0])),t=t.substr(e[0].length);continue t}t.length&&i.push(o(B,t)),t=""}return i},m.parse=function(t,e){var n=function(t){function e(){return g(f)}function n(t){(e()?e().children:c).push(t)}function r(t){return e()&&(l=y[e().name])&&l.closedBy&&-1<l.closedBy.indexOf(t)}var i,l,o,a,s,u=[],c=[],f=[];for(;i=t.shift();)switch(s=t[0],h(e(),i)||i.type===I&&e()&&i.name===e().name||(i.name="#",i.type=B),i.type){case E:r(i.name)&&f.pop(),n(i),(l=y[i.name])&&!l.isSelfClosing&&(l.closedBy||d(i.name,I,t))?f.push(i):l&&l.isSelfClosing||(i.type=B);break;case I:if(e()&&i.name!==e().name&&r("/"+i.name)&&f.pop(),e()&&i.name===e().name)e().closing=i,f.pop();else if(d(i.name,E,f)){for(;o=f.pop();){if(o.name===i.name){o.closing=i;break}o=o.clone(),u.length&&o.children.push(g(u)),u.push(o)}for(s&&s.type===C&&(l=y[i.name])&&!1===l.isInline&&(n(s),t.shift()),n(g(u)),a=u.length;a--;)f.push(u[a]);u.length=0}else i.type=B,n(i);break;case C:e()&&s&&r((s.type===I?"/":"")+s.name)&&(s.type===I&&s.name===e().name||((l=y[e().name])&&l.breakAfter||l&&!1===l.isInline&&m.opts.breakAfterBlock&&!1!==l.breakAfter)&&f.pop()),n(i);break;default:n(i)}return c}(m.tokenize(t)),t=m.opts;return t.fixInvalidNesting&&function t(e,n,r,i){var l,o,a,s;var u=function(t){var t=y[t.name];return!t||!1!==t.isInline};n=n||[];i=i||e;for(o=0;o<e.length;o++)if((l=e[o])&&l.type===E){var c;if(r&&!u(l))if(f=g(n),s=f.splitAt(l),a=1<n.length?n[n.length-2].children:i,h(l,f)&&((c=f.clone()).children=l.children,l.children=[c]),-1<(c=a.indexOf(f))){s.children.splice(0,1),a.splice(c+1,0,l,s);var f=s.children[0];return void(f&&f.type===C&&(u(l)||(s.children.splice(0,1),a.splice(c+2,0,f))))}n.push(l),t(l.children,n,r||u(l),i),n.pop()}}(n),function t(e,n,r){var i,l,o,a,s,u,c,f;var d=e.length;n&&(a=y[n.name]);var h=d;for(;h--;)(i=e[h])&&(i.type===C?(l=0<h?e[h-1]:null,o=h<d-1?e[h+1]:null,f=!1,!r&&a&&!0!==a.isSelfClosing&&(l?u||o||(!1===a.isInline&&m.opts.breakEndBlock&&!1!==a.breakEnd&&(f=!0),a.breakEnd&&(f=!0),u=f):(!1===a.isInline&&m.opts.breakStartBlock&&!1!==a.breakStart&&(f=!0),a.breakStart&&(f=!0))),l&&l.type===E&&(s=y[l.name])&&(r?!1===s.isInline&&(f=!0):(!1===s.isInline&&m.opts.breakAfterBlock&&!1!==s.breakAfter&&(f=!0),s.breakAfter&&(f=!0))),!r&&!c&&o&&o.type===E&&(s=y[o.name])&&(!1===s.isInline&&m.opts.breakBeforeBlock&&!1!==s.breakBefore&&(f=!0),s.breakBefore&&(f=!0),c=f)?e.splice(h,1):(f&&e.splice(h,1),c=!1)):i.type===E&&t(i.children,i,r))}(n,null,e),t.removeEmptyTags&&function t(e){var n,r;var i=function(t){for(var e=t.length;e--;){var n=t[e].type;if(n===E||n===I)return!1;if(n===B&&/\S|\u00A0/.test(t[e].val))return!1}return!0};var l=e.length;for(;l--;)(n=e[l])&&n.type===E&&(r=y[n.name],t(n.children),i(n.children)&&r&&!r.isSelfClosing&&!r.allowsEmpty&&e.splice.apply(e,[l,1].concat(n.children)))}(n),n},m.toHTML=function(t,e){return function t(e,n){var r,i,l,o,a,s,u,c="";s=function(t){return!1!==(!t||(void 0!==t.isHtmlInline?t.isHtmlInline:t.isInline))};for(;0<e.length;)if(r=e.shift()){if(r.type===E)u=r.children[r.children.length-1]||{},i=y[r.name],o=n&&s(i),l=t(r.children,!1),l=i&&i.html?(s(i)||!s(y[u.name])||i.isPreFormatted||i.skipLastLineBreak||(l+="<br />"),k(i.html)?i.html.call(m,r,r.attrs,l):(r.attrs[0]=l,x(i.html,r.attrs))):r.val+l+(r.closing?r.closing.val:"");else{if(r.type===C){if(!n){c+="<br />";continue}a||(c+="<div>"),c+="<br />",e.length||(c+="<br />"),c+="</div>\n",a=!1;continue}o=n,l=f(r.val,!0)}o&&!a?(c+="<div>",a=!0):!o&&a&&(c+="</div>\n",a=!1),c+=l}a&&(c+="</div>\n");return c}(m.parse(t,e),!0)},m.toBBCode=function(t,e){return function t(e){var n,r,i,l,o,a,s,u,c,f="";for(;0<e.length;)if(n=e.shift())if(i=y[n.name],c=!(!i||!1!==i.isInline),l=i&&i.isSelfClosing,a=c&&m.opts.breakBeforeBlock&&!1!==i.breakBefore||i&&i.breakBefore,s=c&&!l&&m.opts.breakStartBlock&&!1!==i.breakStart||i&&i.breakStart,u=c&&m.opts.breakEndBlock&&!1!==i.breakEnd||i&&i.breakEnd,c=c&&m.opts.breakAfterBlock&&!1!==i.breakAfter||i&&i.breakAfter,o=(i?i.quoteType:null)||m.opts.quoteType||b.auto,i||n.type!==E)if(n.type===E){if(a&&(f+="\n"),f+="["+n.name,n.attrs)for(r in n.attrs.defaultattr&&(f+="="+p(n.attrs.defaultattr,o,"defaultattr"),delete n.attrs.defaultattr),n.attrs)n.attrs.hasOwnProperty(r)&&(f+=" "+r+"="+p(n.attrs[r],o,r));f+="]",s&&(f+="\n"),n.children&&(f+=t(n.children)),l||i.excludeClosing||(u&&(f+="\n"),f+="[/"+n.name+"]"),c&&(f+="\n"),n.closing&&l&&(f+=n.closing.val)}else f+=n.val;else f+=n.val,n.children&&(f+=t(n.children)),n.closing&&(f+=n.closing.val);return f}(m.parse(t,e))}}function i(t){return t=parseInt(t,10),isNaN(t)?"00":(t=Math.max(0,Math.min(t,255)).toString(16)).length<2?"0"+t:t}function s(t){var e;return(e=(t=t||"#000").match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))?"#"+i(e[1])+i(e[2])+i(e[3]):(e=t.match(/#([0-f])([0-f])([0-f])\s*?$/i))?"#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:t}function u(){var s=this;s.stripQuotes=w;var a={},c={ul:["li","ol","ul"],ol:["li","ol","ul"],table:["tr"],tr:["td","th"],code:["br","p","div"]};function f(i,l,e){function o(t){var e=t[0],n=t[1],r=d.getStyle(i,e),t=i.parentNode;return!(!r||t&&d.hasStyle(t,e,r))&&(!n||n.includes(r))}function t(t){a[t]&&a[t][e]&&g(a[t][e],function(t,e){var n=y[t].strictMatch;if(void 0===n&&(n=s.opts.strictMatch),!e||e[n?"every":"some"]((r=n,function(t){var e=t[0],t=t[1];if("style"===e&&"CODE"===i.nodeName)return!1;if("style"===e&&t)return t[r?"every":"some"](o);e=m(i,e);return e&&(!t||t.includes(e))}))){var r,t=y[t].format;return l=k(t)?t.call(s,i,l):function(t){var n=arguments;return t.replace(/\{(\d+)\}/g,function(t,e){return void 0!==n[+e+1]?n[+e+1]:"{"+e+"}"})}(t,l),!1}})}return t("*"),t(i.nodeName.toLowerCase()),l}function u(t){var u=function(t,a){var s="";return d.traverse(t,function(t){var e="",n=t.nodeType,r=t.nodeName.toLowerCase(),i=c[r],l=t.firstChild,o=!0;"object"==typeof a&&(o=-1<a.indexOf(r),(o=p(t,"img")&&m(t,v)?!0:o)||(i=a)),3!==n&&1!==n||(1===n?p(t,".sceditor-nlf")&&!l||("iframe"!==r&&(e=u(t,i)),o?("code"!==r&&(e=f(t,e,!1)),e=f(t,e,!0),s+=function(t,e){var n=t.nodeName.toLowerCase(),r=d.isInline;if(!r(t,!0)||"br"===n){for(var i,l,o=t.previousSibling;o&&1===o.nodeType&&!p(o,"br")&&r(o,!0)&&!o.firstChild;)o=o.previousSibling;for(;i=((l=t.parentNode)&&l.lastChild)===t,t=l,l&&i&&r(l,!0););i&&"li"!==n||(e+="\n"),"br"!==n&&o&&!p(o,"br")&&r(o,!0)&&(e="\n"+e)}return e}(t,e)):s+=e):s+=t.nodeValue)},!1,!0),s};return u(t)}function t(t,e,n){var r,i,e=new T(s.opts.parserOptions).toHTML(s.opts.bbcodeTrim?e.trim():e);return t||n?(t=e,i=document.createElement("div"),n=function(t,e){if(!d.hasStyling(t)){if(1!==t.childNodes.length||!p(t.firstChild,"br"))for(;r=t.firstChild;)i.insertBefore(r,t);!e||t!==(e=i.lastChild)&&p(e,"div")&&t.nextSibling===e&&i.insertBefore(document.createElement("br"),t),i.removeChild(t)}},h(i,"display","none"),i.innerHTML=t.replace(/<\/div>\n/g,"</div>"),(t=i.firstChild)&&p(t,"div")&&n(t,!0),(t=i.lastChild)&&p(t,"div")&&n(t),i.innerHTML):e}function e(t,e,n,r){var i,l=(n=n||document).createElement("div"),o=n.createElement("div"),a=new T(s.opts.parserOptions);for(o.innerHTML=e,h(l,"visibility","hidden"),l.appendChild(o),n.body.appendChild(l),t&&(l.insertBefore(n.createTextNode("#"),l.firstChild),l.appendChild(n.createTextNode("#"))),r&&h(o,"whiteSpace",h(r,"whiteSpace")),i=o.getElementsByClassName("sceditor-ignore");i.length;)i[0].parentNode.removeChild(i[0]);return d.removeWhiteSpace(l),o=u(o),n.body.removeChild(l),o=a.toBBCode(o,!0),o=s.opts.bbcodeTrim?o.trim():o}s.init=function(){s.opts=this.opts,s.elementToBbcode=u,g(y,function(n,t){var r=!1===t.isInline,e=y[n].tags,t=y[n].styles;t&&(a["*"]=a["*"]||{},a["*"][r]=a["*"][r]||{},a["*"][r][n]=[["style",Object.entries(t)]]),e&&g(e,function(t,e){e&&e.style&&(e.style=Object.entries(e.style)),a[t]=a[t]||{},a[t][r]=a[t][r]||{},a[t][r][n]=e&&Object.entries(e)})}),this.commands=n(!0,{},r,this.commands),this.toBBCode=s.toSource,this.fromBBCode=s.toHtml},s.toHtml=t.bind(null,!1),s.fragmentToHtml=t.bind(null,!0),s.toSource=e.bind(null,!1),s.fragmentToSource=e.bind(null,!0)}a.prototype={clone:function(){var t=this;return new a(t.type,t.name,t.val,n({},t.attrs),[],t.closing?t.closing.clone():null)},splitAt:function(t){var e=this.clone(),n=this.children.indexOf(t);return-1<n&&(t=this.children.length-n,e.children=this.children.splice(n,t)),e}},T.QuoteType=b,T.defaults={breakBeforeBlock:!1,breakStartBlock:!1,breakEndBlock:!1,breakAfterBlock:!0,removeEmptyTags:!0,fixInvalidNesting:!0,fixInvalidChildren:!0,quoteType:b.auto,strictMatch:!1},u.get=function(t){return y[t]||null},u.set=function(t,e){return t&&e&&((e=n(y[t]||{},e)).remove=function(){delete y[t]},y[t]=e),this},u.rename=function(t,e){return t in y&&(y[e]=y[t],delete y[t]),this},u.remove=function(t){return t in y&&delete y[t],this},u.formatBBCodeString=x,t.formats.bbcode=u,t.BBCodeParser=T}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/formats/xhtml.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(m){"use strict";var b=m.dom,t=m.utils,w=b.css,i=b.attr,y=b.is,E=b.removeAttr,n=b.convertElement,r=t.extend,a=t.each,S=t.isEmptyObject,l=m.command.get,e={bold:{txtExec:["<strong>","</strong>"]},italic:{txtExec:["<em>","</em>"]},underline:{txtExec:['<span style="text-decoration:underline;">',"</span>"]},strike:{txtExec:['<span style="text-decoration:line-through;">',"</span>"]},subscript:{txtExec:["<sub>","</sub>"]},superscript:{txtExec:["<sup>","</sup>"]},left:{txtExec:['<div style="text-align:left;">',"</div>"]},center:{txtExec:['<div style="text-align:center;">',"</div>"]},right:{txtExec:['<div style="text-align:right;">',"</div>"]},justify:{txtExec:['<div style="text-align:justify;">',"</div>"]},font:{txtExec:function(t){var e=this;l("font")._dropDown(e,t,function(t){e.insertText('<span style="font-family:'+t+';">',"</span>")})}},size:{txtExec:function(t){var e=this;l("size")._dropDown(e,t,function(t){e.insertText('<span style="font-size:'+t+';">',"</span>")})}},color:{txtExec:function(t){var e=this;l("color")._dropDown(e,t,function(t){e.insertText('<span style="color:'+t+';">',"</span>")})}},bulletlist:{txtExec:["<ul><li>","</li></ul>"]},orderedlist:{txtExec:["<ol><li>","</li></ol>"]},table:{txtExec:["<table><tr><td>","</td></tr></table>"]},horizontalrule:{txtExec:["<hr />"]},code:{txtExec:["<code>","</code>"]},image:{txtExec:function(t,e){var o=this;l("image")._dropDown(o,t,e,function(t,e,n){var i="";e&&(i+=' width="'+e+'"'),n&&(i+=' height="'+n+'"'),o.insertText("<img"+i+' src="'+t+'" />')})}},email:{txtExec:function(t,n){var i=this;l("email")._dropDown(i,t,function(t,e){i.insertText('<a href="mailto:'+t+'">'+(e||n||t)+"</a>")})}},link:{txtExec:function(t,n){var i=this;l("link")._dropDown(i,t,function(t,e){i.insertText('<a href="'+t+'">'+(e||n||t)+"</a>")})}},quote:{txtExec:["<blockquote>","</blockquote>"]},youtube:{txtExec:function(t){var n=this;l("youtube")._dropDown(n,t,function(t,e){n.insertText('<iframe width="560" height="315" src="https://www.youtube.com/embed/{id}?wmode=opaque&start='+e+'" data-youtube-id="'+t+'" frameborder="0" allowfullscreen></iframe>')})}},rtl:{txtExec:['<div stlye="direction:rtl;">',"</div>"]},ltr:{txtExec:['<div stlye="direction:ltr;">',"</div>"]}};function T(){var o=this,n={},h={};function t(t,e,n){var g,i,o,r,a,l,s,c,u,d,f,v=n.createElement("div");return v.innerHTML=e,w(v,"visibility","hidden"),n.body.appendChild(v),e=v,b.traverse(e,function(t){var e=t.nodeName.toLowerCase();x("*",t),x(e,t)},!0),g=v,b.traverse(g,function(t){var e,n=t.nodeName.toLowerCase(),i=t.parentNode,o=t.nodeType,r=!b.isInline(t),a=t.previousSibling,l=t.nextSibling,s="iframe"!==n&&function t(e,n){var i=e.childNodes,o=e.nodeName.toLowerCase(),r=e.nodeValue,a=i.length,l=T.allowedEmptyTags||[];if(n&&"br"===o)return!0;if(y(e,".sceditor-ignore"))return!0;if(-1<l.indexOf(o)||"td"===o||!b.canHaveChildren(e))return!1;if(r&&/\S|\u00A0/.test(r))return!1;for(;a--;)if(!t(i[a],n&&!e.previousSibling&&!e.nextSibling))return!1;if(e.getBoundingClientRect&&(e.className||e.hasAttributes("style")))return!(r=e.getBoundingClientRect()).width||!r.height;return!0}(t,i===g&&(!a&&!l)&&"br"!==n),c=t.ownerDocument,u=T.allowedTags,d=t.firstChild,f=T.disallowedTags;if(3!==o&&(4===o?n="!cdata":"!"!==n&&8!==o||(n="!comment"),1===o&&y(t,".sceditor-nlf")&&(!d||1===t.childNodes.length&&/br/i.test(d.nodeName)?s=!0:(t.classList.remove("sceditor-nlf"),t.className||E(t,"class"))),s?e=!0:u&&u.length?e=u.indexOf(n)<0:f&&f.length&&(e=-1<f.indexOf(n)),e)){if(!s){for(r&&a&&b.isInline(a)&&i.insertBefore(c.createTextNode(" "),t);t.firstChild;)i.insertBefore(t.firstChild,l);r&&l&&b.isInline(l)&&i.insertBefore(c.createTextNode(" "),l)}i.removeChild(t)}},!0),e=v,u=(c=T.allowedAttribs)&&!S(c),f=(d=T.disallowedAttribs)&&!S(d),h={},b.traverse(e,function(t){if(t.attributes&&(i=t.nodeName.toLowerCase(),a=t.attributes.length))for(h[i]||(h[i]=u?p(c["*"],c[i]):p(d["*"],d[i]));a--;)o=t.attributes[a],r=o.name,l=h[i][r],s=!1,u?s=null!==l&&(!Array.isArray(l)||l.indexOf(o.value)<0):f&&(s=null===l||Array.isArray(l)&&-1<l.indexOf(o.value)),s&&t.removeAttribute(r)}),t||function(t){var e;b.removeWhiteSpace(t);for(var n,i=t.firstChild;i;)n=i.nextSibling,b.isInline(i)&&!y(i,".sceditor-ignore")?(e||(e=t.ownerDocument.createElement("p"),i.parentNode.insertBefore(e,i)),e.appendChild(i)):e=null,i=n}(v),t=(new m.XHTMLSerializer).serialize(v,!0),n.body.removeChild(v),t}function x(t,i){n[t]&&n[t].forEach(function(n){n.tags[t]?a(n.tags[t],function(t,e){i.getAttributeNode&&(!(t=i.getAttributeNode(t))||e&&e.indexOf(t.value)<0||n.conv.call(o,i))}):n.conv&&n.conv.call(o,i)})}function p(t,e){var n={};return t&&(n=r({},n,t)),e&&a(e,function(t,e){Array.isArray(e)?n[t]=(n[t]||[]).concat(e):n[t]||(n[t]=null)}),n}o.init=function(){S(T.converters||{})||a(T.converters,function(t,e){a(e.tags,function(t){n[t]||(n[t]=[]),n[t].push(e)})}),this.commands=r(!0,{},e,this.commands)},o.toSource=t.bind(null,!1),o.fragmentToSource=t.bind(null,!0)}m.XHTMLSerializer=function(){var i={indentStr:"\t"},o=[],d=0;function f(t){var e={"&":"&","<":"<",">":">",'"':"""," ":" "};return t?t.replace(/[&<>"\xa0]/g,function(t){return e[t]||t}):""}function g(e,t){switch(e.nodeType){case 1:!function(t,e){var n,i,o,r=t.nodeName.toLowerCase(),a="iframe"===r,l=t.attributes.length,s=t.firstChild,c=e||/pre(?:\-wrap)?$/i.test(w(t,"whiteSpace")),u=!t.firstChild&&!b.canHaveChildren(t)&&!a;if(!y(t,".sceditor-ignore")){for(v("<"+r,!e&&h(t));l--;)i=t.attributes[l],o=i.value,v(" "+i.name.toLowerCase()+'="'+f(o)+'"',!1);for(v(u?" />":">",!1),a||(n=s);n;)d++,g(n,c),n=n.nextSibling,d--;u||v("</"+r+">",!c&&!a&&h(t)&&s&&h(s))}}(e,t);break;case 3:i=t,o=(n=e).nodeValue,!void((o=!i?o.replace(/[^\S\u00A0]+/g," "):o)&&v(f(o),!i&&h(n)));break;case 4:v("<![CDATA["+f(e.nodeValue)+"]]>");break;case 8:v("\x3c!-- "+f(e.nodeValue)+" --\x3e");break;case 9:case 11:!function(){for(var t=e.firstChild;t;)g(t),t=t.nextSibling}()}var n,i,o}function v(t,e){var n=d;if(!1!==e)for(o.length&&o.push("\n");n--;)o.push(i.indentStr);o.push(t)}function h(t){var e=t.previousSibling;return 1!==t.nodeType&&e?!b.isInline(e):!e&&!b.isInline(t.parentNode)||!b.isInline(t)}this.serialize=function(t,e){if(o=[],e)for(t=t.firstChild;t;)g(t),t=t.nextSibling;else g(t);return o.join("")}},T.converters=[{tags:{"*":{width:null}},conv:function(t){w(t,"width",i(t,"width")),E(t,"width")}},{tags:{"*":{height:null}},conv:function(t){w(t,"height",i(t,"height")),E(t,"height")}},{tags:{li:{value:null}},conv:function(t){E(t,"value")}},{tags:{"*":{text:null}},conv:function(t){w(t,"color",i(t,"text")),E(t,"text")}},{tags:{"*":{color:null}},conv:function(t){w(t,"color",i(t,"color")),E(t,"color")}},{tags:{"*":{face:null}},conv:function(t){w(t,"fontFamily",i(t,"face")),E(t,"face")}},{tags:{"*":{align:null}},conv:function(t){w(t,"textAlign",i(t,"align")),E(t,"align")}},{tags:{"*":{border:null}},conv:function(t){w(t,"borderWidth",i(t,"border")),E(t,"border")}},{tags:{applet:{name:null},img:{name:null},layer:{name:null},map:{name:null},object:{name:null},param:{name:null}},conv:function(t){i(t,"id")||i(t,"id",i(t,"name")),E(t,"name")}},{tags:{"*":{vspace:null}},conv:function(t){w(t,"marginTop",+i(t,"vspace")),w(t,"marginBottom",+i(t,"vspace")),E(t,"vspace")}},{tags:{"*":{hspace:null}},conv:function(t){w(t,"marginLeft",+i(t,"hspace")),w(t,"marginRight",+i(t,"hspace")),E(t,"hspace")}},{tags:{hr:{noshade:null}},conv:function(t){w(t,"borderStyle","solid"),E(t,"noshade")}},{tags:{"*":{nowrap:null}},conv:function(t){w(t,"whiteSpace","nowrap"),E(t,"nowrap")}},{tags:{big:null},conv:function(t){w(n(t,"span"),"fontSize","larger")}},{tags:{small:null},conv:function(t){w(n(t,"span"),"fontSize","smaller")}},{tags:{b:null},conv:function(t){n(t,"strong")}},{tags:{u:null},conv:function(t){w(n(t,"span"),"textDecoration","underline")}},{tags:{s:null,strike:null},conv:function(t){w(n(t,"span"),"textDecoration","line-through")}},{tags:{dir:null},conv:function(t){n(t,"ul")}},{tags:{center:null},conv:function(t){w(n(t,"div"),"textAlign","center")}},{tags:{font:{size:null}},conv:function(t){w(t,"fontSize",w(t,"fontSize")),E(t,"size")}},{tags:{font:null},conv:function(t){n(t,"span")}},{tags:{"*":{type:["_moz"]}},conv:function(t){E(t,"type")}},{tags:{"*":{_moz_dirty:null}},conv:function(t){E(t,"_moz_dirty")}},{tags:{"*":{_moz_editor_bogus_node:null}},conv:function(t){t.parentNode.removeChild(t)}},{tags:{"*":{"data-sce-target":null}},conv:function(t){var e=i(t,"rel")||"",n=i(t,"data-sce-target");"_blank"===n&&y(t,"a")&&(/(^|\s)noopener(\s|$)/.test(e)||i(t,"rel","noopener"+(e?" "+e:"")),i(t,"target",n)),E(t,"data-sce-target")}},{tags:{code:null},conv:function(t){for(var e=t.getElementsByTagName("div");t=e[0];)t.style.display="block",n(t,"span")}}],T.allowedAttribs={},T.disallowedAttribs={},T.allowedTags=[],T.disallowedTags=[],T.allowedEmptyTags=[],m.formats.xhtml=T}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/icons/material.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(V){"use strict";var A=V.dom,t={bold:'<path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" />',bulletlist:'<path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" />',center:'<path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" />',code:'<path d="M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z" />',color:'<path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /><path class="sce-color" d="M0,24H24V20H0V24Z" />',copy:'<path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" />',cut:'<path d="M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z" />',date:'<path d="M7,10H12V15H7M19,19H5V8H19M19,3H18V1H16V3H8V1H6V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3Z" />',email:'<path d="M20,8L12,13L4,8V6L12,11L20,6M20,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V6C22,4.89 21.1,4 20,4Z" />',emoticon:'<path d="M12,17.5C14.33,17.5 16.3,16.04 17.11,14H6.89C7.69,16.04 9.67,17.5 12,17.5M8.5,11A1.5,1.5 0 0,0 10,9.5A1.5,1.5 0 0,0 8.5,8A1.5,1.5 0 0,0 7,9.5A1.5,1.5 0 0,0 8.5,11M15.5,11A1.5,1.5 0 0,0 17,9.5A1.5,1.5 0 0,0 15.5,8A1.5,1.5 0 0,0 14,9.5A1.5,1.5 0 0,0 15.5,11M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />',font:'<path d="M17,8H20V20H21V21H17V20H18V17H14L12.5,20H14V21H10V20H11L17,8M18,9L14.5,16H18V9M5,3H10C11.11,3 12,3.89 12,5V16H9V11H6V16H3V5C3,3.89 3.89,3 5,3M6,5V9H9V5H6Z" />',format:'<path d="M18,4V3A1,1 0 0,0 17,2H5A1,1 0 0,0 4,3V7A1,1 0 0,0 5,8H17A1,1 0 0,0 18,7V6H19V10H9V21A1,1 0 0,0 10,22H12A1,1 0 0,0 13,21V12H21V4H18Z" />',grip:'<path d="M22,22H20V20H22V22M22,18H20V16H22V18M18,22H16V20H18V22M18,18H16V16H18V18M14,22H12V20H14V22M22,14H20V12H22V14Z" />',horizontalrule:'<path d="M 3,3 21,3 21,5 3,5 3,3 M 3,7 15,7 15,9 3,9 3,7 m 0,4 18,0 0,4 -18,0 0,-4" />',image:'<path d="M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z" />',indent:'<path d="M11,13H21V11H11M11,9H21V7H11M3,3V5H21V3M11,17H21V15H11M3,8V16L7,12M3,21H21V19H3V21Z" />',italic:'<path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" />',justify:'<path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" />\t\t',left:'<path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" />\t\t',link:'<path d="M16,6H13V7.9H16C18.26,7.9 20.1,9.73 20.1,12A4.1,4.1 0 0,1 16,16.1H13V18H16A6,6 0 0,0 22,12C22,8.68 19.31,6 16,6M3.9,12C3.9,9.73 5.74,7.9 8,7.9H11V6H8A6,6 0 0,0 2,12A6,6 0 0,0 8,18H11V16.1H8C5.74,16.1 3.9,14.26 3.9,12M8,13H16V11H8V13Z" />',ltr:'<path d="M21,18L17,14V17H5V19H17V22M9,10V15H11V4H13V15H15V4H17V2H9A4,4 0 0,0 5,6A4,4 0 0,0 9,10Z" />',maximize:'<path d="M9.5,13.09L10.91,14.5L6.41,19H10V21H3V14H5V17.59L9.5,13.09M10.91,9.5L9.5,10.91L5,6.41V10H3V3H10V5H6.41L10.91,9.5M14.5,13.09L19,17.59V14H21V21H14V19H17.59L13.09,14.5L14.5,13.09M13.09,9.5L17.59,5H14V3H21V10H19V6.41L14.5,10.91L13.09,9.5Z" />',orderedlist:'<path d="M7,13H21V11H7M7,19H21V17H7M7,7H21V5H7M2,11H3.8L2,13.1V14H5V13H3.2L5,10.9V10H2M3,8H4V4H2V5H3M2,17H4V17.5H3V18.5H4V19H2V20H5V16H2V17Z" />',outdent:'<path d="M11,13H21V11H11M11,9H21V7H11M3,3V5H21V3M3,21H21V19H3M3,12L7,16V8M11,17H21V15H11V17Z" />',paste:'<path d="M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z" />',pastetext:'<path d="M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z" />',print:'<path d="M18,3H6V7H18M19,12A1,1 0 0,1 18,11A1,1 0 0,1 19,10A1,1 0 0,1 20,11A1,1 0 0,1 19,12M16,19H8V14H16M19,8H5A3,3 0 0,0 2,11V17H6V21H18V17H22V11A3,3 0 0,0 19,8Z" />',quote:'<path d="M14,17H17L19,13V7H13V13H16M6,17H9L11,13V7H5V13H8L6,17Z" />',redo:'<path d="M18.4,10.6C16.55,9 14.15,8 11.5,8C6.85,8 2.92,11.03 1.54,15.22L3.9,16C4.95,12.81 7.95,10.5 11.5,10.5C13.45,10.5 15.23,11.22 16.62,12.38L13,16H22V7L18.4,10.6Z" />',removeformat:'<path d="M6,5V5.18L8.82,8H11.22L10.5,9.68L12.6,11.78L14.21,8H20V5H6M3.27,5L2,6.27L8.97,13.24L6.5,19H9.5L11.07,15.34L16.73,21L18,19.73L3.55,5.27L3.27,5Z" />',right:'<path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" />',rtl:'<path d="M8,17V14L4,18L8,22V19H20V17M10,10V15H12V4H14V15H16V4H18V2H10A4,4 0 0,0 6,6A4,4 0 0,0 10,10Z" />',size:'<path d="M3,12H6V19H9V12H12V9H3M9,4V7H14V19H17V7H22V4H9Z" />',source:'<path d="M14.6,16.6L19.2,12L14.6,7.4L16,6L22,12L16,18L14.6,16.6M9.4,16.6L4.8,12L9.4,7.4L8,6L2,12L8,18L9.4,16.6Z" />',strike:'<path d="M3,14H21V12H3M5,4V7H10V10H14V7H19V4M10,19H14V16H10V19Z" />',subscript:'<path d="M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,21.03H16.97V20.03L17.86,19.23C18.62,18.58 19.18,18.04 19.56,17.6C19.93,17.16 20.12,16.75 20.13,16.36C20.14,16.08 20.05,15.85 19.86,15.66C19.68,15.5 19.39,15.38 19,15.38C18.69,15.38 18.42,15.44 18.16,15.56L17.5,15.94L17.05,14.77C17.32,14.56 17.64,14.38 18.03,14.24C18.42,14.1 18.85,14 19.32,14C20.1,14.04 20.7,14.25 21.1,14.66C21.5,15.07 21.72,15.59 21.72,16.23C21.71,16.79 21.53,17.31 21.18,17.78C20.84,18.25 20.42,18.7 19.91,19.14L19.27,19.66V19.68H21.85V21.03Z" />',superscript:'<path d="M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,9H16.97V8L17.86,7.18C18.62,6.54 19.18,6 19.56,5.55C19.93,5.11 20.12,4.7 20.13,4.32C20.14,4.04 20.05,3.8 19.86,3.62C19.68,3.43 19.39,3.34 19,3.33C18.69,3.34 18.42,3.4 18.16,3.5L17.5,3.89L17.05,2.72C17.32,2.5 17.64,2.33 18.03,2.19C18.42,2.05 18.85,2 19.32,2C20.1,2 20.7,2.2 21.1,2.61C21.5,3 21.72,3.54 21.72,4.18C21.71,4.74 21.53,5.26 21.18,5.73C20.84,6.21 20.42,6.66 19.91,7.09L19.27,7.61V7.63H21.85V9Z" />',table:'<path d="M5,4H19A2,2 0 0,1 21,6V18A2,2 0 0,1 19,20H5A2,2 0 0,1 3,18V6A2,2 0 0,1 5,4M5,8V12H11V8H5M13,8V12H19V8H13M5,14V18H11V14H5M13,14V18H19V14H13Z" />',time:'<path d="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z" />',underline:'<path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" />',undo:'<path d="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z" />',unlink:'<path d="M2,5.27L3.28,4L20,20.72L18.73,22L14.73,18H13V16.27L9.73,13H8V11.27L5.5,8.76C4.5,9.5 3.9,10.68 3.9,12C3.9,14.26 5.74,16.1 8,16.1H11V18H8A6,6 0 0,1 2,12C2,10.16 2.83,8.5 4.14,7.41L2,5.27M16,6A6,6 0 0,1 22,12C22,14.21 20.8,16.15 19,17.19L17.6,15.77C19.07,15.15 20.1,13.7 20.1,12C20.1,9.73 18.26,7.9 16,7.9H13V6H16M8,6H11V7.9H9.72L7.82,6H8M16,11V13H14.82L12.82,11H16Z" />',youtube:'<path d="M10,16.5V7.5L16,12M20,4.4C19.4,4.2 15.7,4 12,4C8.3,4 4.6,4.19 4,4.38C2.44,4.9 2,8.4 2,12C2,15.59 2.44,19.1 4,19.61C4.6,19.81 8.3,20 12,20C15.7,20 19.4,19.81 20,19.61C21.56,19.1 22,15.59 22,12C22,8.4 21.56,4.91 20,4.4Z" />'};V.icons.material=function(){var L,M={};return{create:function(H){return H in t&&(M[H]=V.dom.parseHTML('<svg xmlns="http://www.w3.org/2000/svg" viewbox="1 1 22 22" unselectable="on">'+t[H]+"</svg>").firstChild,"color"===H&&(L=M[H].querySelector(".sce-color"))),M[H]},update:function(H,V){var M;L&&(M="inherit",!H&&V&&(M=V.ownerDocument.queryCommandValue("forecolor")),A.css(L,"fill",M))},rtl:function(H){var V=M.grip;V&&(H=H?"scaleX(-1)":"",A.css(V,"transform",H),A.css(V,"msTransform",H),A.css(V,"webkitTransform",H))}}},V.icons.material.icons=t}((document,sceditor)); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/icons/monocons.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(a){"use strict";var t=a.dom,c={bold:'<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-size="15" font-weight="bold">B</text>',bulletlist:'<path d="M6 2h9v2H6zm0 5h9v2H6zm0 5h9v2H6z"/><circle cx="3" cy="3" r="1.75"/><circle cx="3" cy="8" r="1.75"/><circle cx="3" cy="13" r="1.75"/>',center:'<path d="M1 1h14v2H1zm2 4h10v2H3zM1 9h14v2H1zm2 4h10v2H3z"/>',code:'<path d="M7 6L4 9l3 3v-1.5L5.5 9 7 7.5zm2 0v1.5L10.5 9 9 10.5V12l3-3zM2.406 1A.517.517 0 0 0 2 1.5v13c0 .262.238.5.5.5h11a.52.52 0 0 0 .5-.5V4.375c.002-.102-.13-.193-.156-.219l-3-3A.506.506 0 0 0 10.5 1zM3 2h7v2.5c0 .262.238.5.5.5H13v9H3zm8 .688L12.313 4H11z"/>',color:'<text x="50%" y="8" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-size="13" font-weight="bold">A</text><path class="sce-color" d="M2 13h12v2H2z"/>',copy:'<path d="M6.404 5.002a.5.5 0 0 0-.406.5v10a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V8.596a.492.492 0 0 0 0-.094.662.662 0 0 0 0-.063v-.063l-.031-.063v-.031a.557.557 0 0 0-.094-.094l-.031-.031-2.875-2.844a.498.498 0 0 0-.125-.156.5.5 0 0 0-.344-.156h-5a.59.59 0 0 0-.094.001c-.239.046.031-.003 0 0zm.594 1h4v2.5a.5.5 0 0 0 .5.5h2.5v6h-7v-9zm5 .687l1.313 1.313h-1.313V6.689zM1.406.002a.517.517 0 0 0-.406.5v10c0 .262.238.5.5.5H7V6l3-.063V3.596a.492.492 0 0 0 0-.094.331.331 0 0 0 0-.063v-.063c-.009-.021-.02-.041-.031-.062v-.031a.597.597 0 0 0-.094-.094l-.031-.031L6.969.314a.484.484 0 0 0-.125-.156A.506.506 0 0 0 6.5.002h-5a.492.492 0 0 0-.094 0c-.229.044.032-.003 0 0zm.594 1h4v2.5c0 .262.238.5.5.5H9v1.029L7 5 6 6v4l-4 .002v-9zm5 .687l1.313 1.313H7V1.689z"/>',cut:'<path d="M3 .5c0 2.936 3.774 7.73 3.938 7.938l-1.813 2.844A2.46 2.46 0 0 0 4 11c-1.375 0-2.5 1.125-2.5 2.5S2.625 16 4 16s2.5-1.125 2.5-2.5c0-.444-.138-.856-.344-1.22L8 9.845l1.844 2.438A2.473 2.473 0 0 0 9.5 13.5c0 1.375 1.125 2.5 2.5 2.5s2.5-1.125 2.5-2.5S13.375 11 12 11a2.46 2.46 0 0 0-1.125.28L9.062 8.439C9.226 8.232 13 3.437 13 .5h-1L8 6.78 4 .5H3zM4 12c.834 0 1.5.666 1.5 1.5S4.834 15 4 15s-1.5-.666-1.5-1.5S3.166 12 4 12zm8 0c.834 0 1.5.666 1.5 1.5S12.834 15 12 15s-1.5-.666-1.5-1.5.666-1.5 1.5-1.5z"/>',date:'<path d="M8.1 7v1h2.7v1H8.094v3H11.7v-1H9v-1h2.7V7zM4.5 7v1h.8v3h-.8v1h2.7v-1h-.9V7zM.9 1v14h14.4V1h-1.8v2h-2.7V1H5.4v2H2.7V1zm.9 4h12.6v9H1.8z"/>',email:'<path d="M1 4.5v8c0 .262.238.5.5.5h13a.52.52 0 0 0 .5-.5V4.594C15 4 15 4 14.5 4H1.563C1 4 1 4 1 4.5zM2 5h12v7H2V5zm-.187-.906l-.625.812 6.5 5 .312.219.313-.219 6.5-5-.625-.813L8 8.844l-6.187-4.75z"/>',emoticon:'<path d="M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm0 1a6 6 0 1 1 0 12A6 6 0 0 1 8 2zM6 5c-.546 0-1 .454-1 1s.454 1 1 1 1-.454 1-1-.454-1-1-1zm4 0c-.547 0-1 .454-1 1s.453 1 1 1c.547 0 1-.454 1-1s-.453-1-1-1zM4.5 9.5s-.002.652.469 1.281C5.44 11.409 6.389 12 8 12c1.611 0 2.561-.591 3.031-1.219.47-.629.469-1.281.469-1.281h-1s-.002.314-.281.688c-.279.374-.83.813-2.219.813-1.389 0-1.94-.44-2.219-.813C5.502 9.814 5.5 9.5 5.5 9.5z"/>',font:'<path d="M7.953 9.75h-4.06l-.395 1.141c-.132.381-.254.752-.368 1.109H.7c.391-1.119.762-2.154 1.113-3.105a104.642 104.642 0 0 1 2.024-5.079 52.23 52.23 0 0 1 1.016-2.212h2.218a80.63 80.63 0 0 1 2.011 4.605c.337.84.105.338.458 1.288s-1.455 2.63-1.587 2.253zM5.912 3.959c-.052.151-.129.357-.229.616-.1.26-.215.56-.343.901-.129.341-.273.716-.431 1.125-.159.409-.32.839-.484 1.288h2.972c-.159-.45-.312-.882-.461-1.292a46.81 46.81 0 0 0-.425-1.127c-.135-.34-.252-.641-.354-.9-.1-.26-.182-.463-.245-.611zm6.949 10.042a36.325 36.325 0 0 0-.35-1.037l-.371-1.063H8.352l-.368 1.064A41.69 41.69 0 0 0 7.64 14H5.373c.365-1.045.711-2.01 1.039-2.896.328-.886.648-1.723.962-2.506.313-.786.623-1.53.927-2.235.305-.705.62-1.393.948-2.065h2.069c.318.672.634 1.36.941 2.065.311.705.621 1.449.936 2.235.314.783.636 1.619.964 2.506.327.888.676 1.853 1.041 2.896l-2.339.001zm-2.625-7.504c-.049.141-.118.333-.213.576-.094.242-.2.521-.319.84-.121.317-.254.668-.402 1.051-.147.382-.299.783-.45 1.201h2.772c-.147-.42-.291-.822-.433-1.205a43.073 43.073 0 0 0-.396-1.053c-.125-.317-.233-.598-.33-.84a13.884 13.884 0 0 0-.229-.57z"/>',format:'<path d="M10.5 2v1.5H12c.235 0 .401-.009.5 0 .008.088 0 .279 0 .5v2H14V3.437c0-.237-.01-.409-.031-.593-.022-.185-.067-.42-.25-.594s-.407-.2-.594-.219A5.693 5.693 0 0 0 12.5 2zm0-2L7.187 2.5 10.5 5zm.5 5.187L13.5 8.5 16 5.187zm-.958-.339h-2.03l-3.234 8.456c-.154.392-.336.994-.854 1.022v.518h2.744v-.518c-.644-.168-.658-.462-.434-1.036l.784-2.086h3.43l.854 2.086c.238.574.308.924-.406 1.036v.518h3.276v-.518c-.434-.056-.546-.364-.686-.728l-3.444-8.75M7.424 10l1.26-3.318L10 10H7.424M4.912.975h-1.63L.686 7.764c-.124.314-.27.798-.686.82V9h2.203v-.416c-.517-.135-.528-.37-.348-.832l.629-1.674h2.754l.685 1.674c.192.461.248.742-.325.832V9c1.73.137 1.837-.002 2.079-1L4.912.975M2.81 5.11l1.012-2.664L4.878 5.11H2.81"/>',grip:'<path d="M14.656 5.156l-10 10 .688.688 10-10-.688-.688zm0 3l-7 7 .688.688 7-7-.688-.688zm0 3l-4 4 .688.688 4-4-.688-.688z"/>',horizontalrule:'<path d="M2 2v1h12V2H2zm0 2v1h9V4H2zm0 2v1h12V6H2zm0 2v2h12V8H2z"/>',image:'<path d="M.5 2.5v11h15v-11H.5zm1 1h13v9h-13v-9z"/><circle cx="4" cy="6" r="1.25"/><path d="M1 11h14v2H1z"/><path d="M5 12l2-4 2 4z"/><path d="M7 12l4-7 4 7z"/>',indent:'<path d="M1 1h14v2H1zm5 4h9v2H6zm0 4h9v2H6zm-5 4h14v2H1zm4-5L1 5v6z"/>',italic:'<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-weight="bold" font-size="15" font-style="italic">i</text>',justify:'<path d="M1 1h14v2H1zm0 4h14v2H1zm0 4h14v2H1zm0 4h14v2H1z"/>',left:'<path d="M1 1h14v2H1zm0 4h10v2H1zm0 4h14v2H1zm0 4h10v2H1z"/>',link:'<path d="M2 4c-.625 0-1.009.438-1.188.75s-.269.63-.344.969c-.15.677-.219 1.476-.219 2.28s.068 1.605.219 2.282c.075.339.165.625.344.938s.563.78 1.188.78h4v-2H2.469c-.022-.065-.042-.06-.063-.155-.1-.447-.156-1.15-.156-1.844s.057-1.396.156-1.844c.02-.088.042-.092.063-.156H6V4H2zm8 0v2h3.531c.021.064.043.068.063.156.1.448.156 1.149.156 1.844s-.057 1.396-.156 1.844c-.021.096-.041.09-.063.156H10v2h4c.625 0 1.009-.47 1.188-.781s.269-.6.344-.938c.15-.678.219-1.476.219-2.281s-.068-1.604-.219-2.281c-.075-.34-.165-.656-.344-.97S14.625 4 14 4h-4zM5.719 7c-.523.074-.949.602-.875 1.125S5.477 9.074 6 9h4c.528.01 1-.472 1-1s-.472-1.007-1-1H6a.593.593 0 0 0-.188 0h-.093z"/>',ltr:'<path d="M10.313 1.937c-.98 0-1.752.284-2.344.813-.592.529-.906 1.228-.906 2.094 0 .811.275 1.467.781 1.969.506.497 1.227.792 2.156.906V14h2V3h1v11h1V1.939zM2 4v8l4-4z"/>',maximize:'<path d="M2 7l1.75-1.75-2-2L0 5V0h5L3.25 1.75l2 2L7 2v5H2zm9 9l1.75-1.75-2-2L9 14V9h5l-1.75 1.75 2 2L16 11v5h-5zm-6 0l-1.75-1.75 2-2L7 14V9H2l1.75 1.75-2 2L0 11v5h5zm6-16l1.75 1.75-2 2L9 2v5h5l-1.75-1.75 2-2L16 5V0h-5z"/>',orderedlist:'<path d="M6 2h9v2H6zm0 5h9v2H6zm0 5h9v2H6zm-2.799.846q.392.1.594.352.205.25.205.636 0 .576-.441.877-.441.298-1.287.298-.298 0-.599-.05-.298-.046-.591-.142v-.77q.28.14.555.212.277.07.545.07.396 0 .607-.137.212-.138.212-.394 0-.265-.218-.4-.215-.137-.638-.137h-.4v-.644h.421q.376 0 .56-.116.185-.12.185-.36 0-.224-.18-.346-.178-.122-.505-.122-.242 0-.488.055-.246.054-.49.16v-.731q.295-.083.586-.125.29-.041.57-.041.756 0 1.13.249.375.246.375.744 0 .34-.179.558-.179.215-.529.304zm-.905-3.609H4v.734H1.186v-.734L2.599 7.99q.19-.172.28-.335.091-.163.091-.34 0-.272-.184-.438-.182-.166-.485-.166-.234 0-.511.101-.278.099-.594.296v-.851q.337-.112.667-.169.329-.06.645-.06.696 0 1.08.307.386.306.386.853 0 .317-.163.592-.164.272-.688.731l-.827.726zM1.228 4.276h.903V1.714l-.927.19V1.21l.922-.191h.971v3.258H4v.706H1.228v-.706z"/>',outdent:'<path d="M1 1h14v2H1zm0 4h9v2H1zm0 4h9v2H1zm0 4h14v2H1zm10-5l4-3v6z"/>',paste:'<path d="M4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5H6v2.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.436.436 0 0 0 0-.125.916.916 0 0 0-.031-.063v-.031a.749.749 0 0 0-.063-.063.749.749 0 0 0-.063-.063l-2.875-2.844a.498.498 0 0 0-.125-.156A.498.498 0 0 0 11.5 4H10V1.5a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0c-.239.045.032-.003 0 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.64.64 0 0 0-.062 0 .493.493 0 0 0-.094.031.474.474 0 0 0-.125.063l-.031.031-.031.031a.916.916 0 0 0-.063.031.47.47 0 0 0-.031.094l-.031.031A.506.506 0 0 0 6 4.5V11H2V2zm5 3h4v2.5a.5.5 0 0 0 .5.5H14v6H7v-2.406a.492.492 0 0 0 0-.094V5zm5 .688L13.313 7H12V5.688zM4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5V5h2.5a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0c-.239.045.032-.003 0 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.5.5 0 0 0-.5.5V11H2V2zm4.406 2A.5.5 0 0 0 6 4.5v10a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.331.331 0 0 0 0-.063v-.063a.916.916 0 0 0-.031-.063V7.28a.523.523 0 0 0-.094-.094l-.031-.031-2.875-2.844a.498.498 0 0 0-.125-.156A.503.503 0 0 0 11.5 4h-5a.492.492 0 0 0-.094 0c-.239.045.032-.003 0 0zM7 5h4v2.5a.5.5 0 0 0 .5.5H14v6H7V5zm5 .688L13.313 7H12V5.688zM8 12h5v1H8v-1zm0-2h5v1H8v-1zm0-2h5v1H8V8zm0-2h3v1H8V6z"/>',pastetext:'<path d="M4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5H6v2.5a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.436.436 0 0 0 0-.125.916.916 0 0 0-.031-.063v-.031a.749.749 0 0 0-.063-.063.749.749 0 0 0-.063-.063l-2.875-2.844a.498.498 0 0 0-.125-.156A.498.498 0 0 0 11.5 4H10V1.5a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.64.64 0 0 0-.062 0 .493.493 0 0 0-.094.031.474.474 0 0 0-.125.063l-.031.031-.031.031a.916.916 0 0 0-.063.031.47.47 0 0 0-.031.094l-.031.031A.506.506 0 0 0 6 4.5V11H2V2zm5 3h4v2.5a.5.5 0 0 0 .5.5H14v6H7v-2.406a.492.492 0 0 0 0-.094V5zm5 .688L13.313 7H12V5.688zM4.406 0A.5.5 0 0 0 4 .5V1H1.5a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5V5h2.5a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5H7V.5a.5.5 0 0 0-.5-.5h-2a.492.492 0 0 0-.094 0zM2 2h1v.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V2h1v2H6.5a.5.5 0 0 0-.5.5V11H2V2zm4.406 2A.5.5 0 0 0 6 4.5v10a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V7.594a.492.492 0 0 0 0-.094.331.331 0 0 0 0-.063v-.062a.916.916 0 0 0-.031-.063v-.031a.523.523 0 0 0-.094-.094l-.031-.031-2.875-2.844a.498.498 0 0 0-.125-.156A.5.5 0 0 0 11.5 4h-5a.492.492 0 0 0-.094 0zM7 5h4v2.5a.5.5 0 0 0 .5.5H14v6H7V5zm5 .688L13.313 7H12V5.688z"/>',print:'<path d="M4 1v3H1v8h2V6h10v6h2V4h-3V1zm1 1h6v2H5zM4 7v8h8V7zm1 1h6v6H5zm1 1v1h4V9zm0 2v1h4v-1z"/>',quote:'<path d="M8 2.013c-1.998 0-3.818.382-5.188 1.125S.499 5.054.499 6.513c0 1.237.926 2.345 2.281 3.156s3.197 1.344 5.219 1.344c.344 0 .563.019.906 0l5.875 2.938c.377.18.854-.32.656-.688l-1.813-3.656c1.242-.79 1.875-2.014 1.875-3.094 0-1.46-.943-2.632-2.313-3.375S9.998 2.013 8 2.013z"/>',redo:'<path d="M9 7l5-5v5z"/><path d="M9.553 2.205c1 .268 1.932.796 2.69 1.553l.706.707-1.414 1.414-.707-.707a3.995 3.995 0 0 0-3.863-1.035 3.995 3.995 0 0 0-2.828 2.828 3.995 3.995 0 0 0 1.035 3.863l.707.707-1.414 1.414-.707-.707a6.003 6.003 0 0 1-1.553-5.795 6.003 6.003 0 0 1 7.348-4.242z"/>',removeformat:'<path d="M8.781 2l-.125.125L3.781 7l-.125.125-3 3-.313.313.25.344 3 4 .156.219h2.47l.125-.156 3-3 .313-.313 4.688-4.688.313-.313-.25-.344-3-4-.156-.188H8.781zm.407 1h.594l-4 4h-.594l4-4zm1.75.25l2.406 3.188-4.281 4.28-2.406-3.187 4.281-4.281z"/>',right:'<path d="M1 1h14v2H1zm4 4h10v2H5zM1 9h14v2H1zm4 4h10v2H5z"/>',rtl:'<path d="M5.344 2.001c-.98 0-1.783.284-2.375.813-.592.529-.875 1.227-.875 2.093 0 .811.244 1.467.75 1.969.506.497 1.227.792 2.156.906V14h2V3.001L8 3v11h1V2zM14 4l-4 4 4 4z"/>',size:'<path d="M12.5.656L10 4h5L12.5.656zM4.594 4.5a49.476 49.476 0 0 0-.875 1.906c-.277.65-.581 1.334-.875 2.063-.286.729-.572 1.52-.875 2.344S1.338 12.53 1 13.5h2.094c.095-.313.2-.64.313-.97.121-.328.262-.64.375-.968h3.5c.113.329.231.64.344.969.121.329.217.656.313.969h2.188c-.338-.971-.666-1.864-.969-2.688s-.611-1.615-.906-2.344a56.045 56.045 0 0 0-.844-2.063c-.286-.66-.581-1.282-.875-1.906H4.594zM10 6l2.5 3.313L15 6h-5zm-4.5.53c.052.13.132.307.219.532.086.225.2.486.313.78.121.296.245.614.375.97s.268.734.406 1.125H4.25c.139-.391.245-.77.375-1.125.139-.355.293-.674.406-.97s.194-.555.281-.78c.087-.224.145-.401.188-.531z"/>',source:'<path d="M4.937 3.939L1 8.499l3.937 4.564L6 12 3 8.499 6 5zm6.126 0L10 5.002l3 3.503-3 3.497 1.063 1.063L15 8.505z"/>',strike:'<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-size="15" font-weight="bold">S</text><path d="M1 7v1h14V7H1z"/>',subscript:'<path d="M11 10v1h3v1h-3v3h4v-1h-3v-1h3v-3zM1 3l3 5-3 5h2l3-5H4l3 5h2L6 8l3-5H7L4 8h2L3 3z"/>',superscript:'<path d="M11 1v1h3v1h-3v3h4V5h-3V4h3V1zM1 3l3 5-3 5h2l3-5H4l3 5h2L6 8l3-5H7L4 8h2L3 3z"/>',table:'<path d="M1 2h14v2H1zm0 2v10h14V4H1zm1 1h3.5v2H2V5zm4.5 0h3v2h-3V5zm4 0H14v2h-3.5V5zM2 8h3.5v2H2V8zm4.5 0h3v2h-3V8zm4 0H14v2h-3.5V8zM2 11h3.5v2H2v-2zm4.5 0h3v2h-3v-2zm4 0H14v2h-3.5v-2z"/>',time:'<path d="M8 0C3 0 0 4 0 8s3 8 8 8 8-4 8-8-3-8-8-8zm0 2c3.461 0 6 2.539 6 6s-2.539 6-6 6c-3.46 0-6-2.539-6-6s2.54-6 6-6zM7 3v6l2.5 2L11 9.5 9 8V3z"/>',underline:'<text x="50%" y="50%" text-anchor="middle" dy=".5ex" font-family="Dejavu Sans, Helvetica, Arial, sans-serif" font-weight="bold" font-size="15" text-decoration="underline">U</text>',undo:'<path d="M2 7h5L2 2z"/><path d="M6.447 2.205c-1 .268-1.932.796-2.69 1.553l-.706.707 1.414 1.414.707-.707a3.995 3.995 0 0 1 3.863-1.035 3.995 3.995 0 0 1 2.828 2.828 3.995 3.995 0 0 1-1.035 3.863l-.707.707 1.414 1.414.707-.707a6.003 6.003 0 0 0 1.553-5.795 6.003 6.003 0 0 0-7.348-4.242z"/>',unlink:'<path d="M2 4c-.625 0-1.009.438-1.188.75s-.269.63-.344.969c-.15.677-.219 1.476-.219 2.28s.068 1.605.219 2.282c.075.339.165.625.344.938s.563.78 1.188.78h4v-2H2.469c-.022-.065-.042-.06-.063-.155-.1-.447-.156-1.15-.156-1.844s.057-1.396.156-1.844c.02-.088.042-.092.063-.156H6V4H2zm8 0v2h3.531c.021.064.043.068.063.156.1.448.156 1.149.156 1.844s-.057 1.396-.156 1.844c-.021.095-.041.09-.063.156H10v2h4c.625 0 1.009-.47 1.188-.781s.269-.6.344-.938c.15-.678.219-1.476.219-2.281s-.068-1.604-.219-2.281c-.075-.34-.165-.656-.344-.97S14.625 4 14 4h-4z"/>',youtube:'<path d="M2 2C1 2 0 3 0 4v8c0 1 1 2 2 2h12c1 0 2-1 2-2V4c0-1-1-2-2-2H2zm4 3l6 3-6 3V5z"/>'};a.icons.monocons=function(){var z,v={};return{create:function(h){return h in c&&(v[h]=a.dom.parseHTML('<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 16 16" unselectable="on">'+c[h]+"</svg>").firstChild,"color"===h&&(z=v[h].querySelector(".sce-color"))),v[h]},update:function(h,a){var v;z&&(v="inherit",!h&&a&&(v=a.ownerDocument.queryCommandValue("forecolor")),t.css(z,"fill",v))},rtl:function(h){var a=v.grip;a&&(h=h?"scaleX(-1)":"",t.css(a,"transform",h),t.css(a,"msTransform",h),t.css(a,"webkitTransform",h))}}},a.icons.monocons.icons=c}((document,sceditor)); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/jquery.sceditor.bbcode.min.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(){"use strict";var r=(A=jQuery)&&"object"==typeof A&&"default"in A?A:{default:A};function e(e,t){return typeof t===e}var ye=e.bind(null,"string"),be=e.bind(null,"undefined"),xe=e.bind(null,"function"),o=e.bind(null,"number");function t(e){return!Object.keys(e).length}function we(e,t){var n=e===!!e,r=n?2:1,o=n?t:e,i=n&&e;function a(e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype}for(;r<arguments.length;r++){var l,s=arguments[r];for(l in s){var c,u,d=o[l],f=s[l];be(f)||"__proto__"!==l&&"constructor"!==l&&(u=a(f),c=Array.isArray(f),i&&(u||c)?(u=a(d)===u&&Array.isArray(d)===c,o[l]=we(!0,u?d:c?[]:{},f)):o[l]=f)}}return o}function ke(e,t){-1<(t=e.indexOf(t))&&e.splice(t,1)}function Te(t,n){if(Array.isArray(t)||"length"in t&&o(t.length))for(var e=0;e<t.length;e++)n(e,t[e]);else Object.keys(t).forEach(function(e){n(e,t[e])})}var i={},Ce=1,Se=3,l=8;function a(e){return e=parseFloat(e),isFinite(e)?e:0}function Ee(e,t,n){var r=(n||document).createElement(e);return Te(t||{},function(e,t){"style"===e?r.style.cssText=t:e in r?r[e]=t:r.setAttribute(e,t)}),r}function De(e,t){for(var n=e||{};(n=n.parentNode)&&!/(9|11)/.test(n.nodeType);)if(!t||Ue(n,t))return n}function Ne(e,t){return Ue(e,t)?e:De(e,t)}function Ae(e){e.parentNode&&e.parentNode.removeChild(e)}function Me(e,t){e.appendChild(t)}function Re(e,t){return e.querySelectorAll(t)}var _e=!0;function Oe(n,e,r,o,i){e.split(" ").forEach(function(e){var t;ye(r)?(t=o["_sce-event-"+e+r]||function(e){for(var t=e.target;t&&t!==n;){if(Ue(t,r))return void o.call(t,e);t=t.parentNode}},o["_sce-event-"+e+r]=t):(t=r,i=o),n.addEventListener(e,t,i||!1)})}function Be(n,e,r,o,i){e.split(" ").forEach(function(e){var t;ye(r)?t=o["_sce-event-"+e+r]:(t=r,i=o),n.removeEventListener(e,t,i||!1)})}function Fe(e,t,n){if(arguments.length<3)return e.getAttribute(t);null==n?He(e,t):e.setAttribute(t,n)}function He(e,t){e.removeAttribute(t)}function Ie(e){je(e,"display","none")}function ze(e){je(e,"display","")}function Le(e){(Qe(e)?Ie:ze)(e)}function je(n,e,t){if(arguments.length<3){if(ye(e))return 1===n.nodeType?getComputedStyle(n)[e]:null;Te(e,function(e,t){je(n,e,t)})}else{var r=(t||0===t)&&!isNaN(t);n.style[e]=r?t+"px":t}}function Pe(e,t,n){var r=arguments.length,o={};if(e.nodeType===Ce)return 1===r?(Te(e.attributes,function(e,t){/^data\-/i.test(t.name)&&(o[t.name.substr(5)]=t.value)}),o):2===r?Fe(e,"data-"+t):void Fe(e,"data-"+t,String(n))}function Ue(e,t){var n=!1;return e&&e.nodeType===Ce?(e.matches||e.msMatchesSelector||e.webkitMatchesSelector).call(e,t):n}function We(e,t){return t.parentNode.insertBefore(e,t)}function s(e){return e.className.trim().split(/\s+/)}function qe(e,t){return Ue(e,"."+t)}function Ve(e,t){var n=s(e);n.indexOf(t)<0&&n.push(t),e.className=n.join(" ")}function $e(e,t){var n=s(e);ke(n,t),e.className=n.join(" ")}function Ge(e,t,n){((n=be(n)?!qe(e,t):n)?Ve:$e)(e,t)}function Ye(e,t){if(be(t)){var n=a((r=getComputedStyle(e)).paddingLeft)+a(r.paddingRight),r=a(r.borderLeftWidth)+a(r.borderRightWidth);return e.offsetWidth-n-r}je(e,"width",t)}function Ke(e,t){if(be(t)){var n=a((r=getComputedStyle(e)).paddingTop)+a(r.paddingBottom),r=a(r.borderTopWidth)+a(r.borderBottomWidth);return e.offsetHeight-n-r}je(e,"height",t)}function Xe(e,t,n){var r;xe(window.CustomEvent)?r=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(r=e.ownerDocument.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n),e.dispatchEvent(r)}function Qe(e){return e.getClientRects().length}function Ze(e,t,n,r,o){for(e=o?e.lastChild:e.firstChild;e;){var i=o?e.previousSibling:e.nextSibling;if(!n&&!1===t(e)||!r&&!1===Ze(e,t,n,r,o)||n&&!1===t(e))return!1;e=i}}function Je(e,t,n,r){Ze(e,t,n,r,!0)}function et(e,t){var n=(t=t||document).createDocumentFragment(),r=Ee("div",{},t);for(r.innerHTML=e;r.firstChild;)Me(n,r.firstChild);return n}function tt(e){return e&&(!Ue(e,"p,div")||e.className||Fe(e,"style")||!t(Pe(e)))}function nt(e,t){var n=Ee(t,{},e.ownerDocument);for(Te(e.attributes,function(e,t){try{Fe(n,t.name,t.value)}catch(e){}});e.firstChild;)Me(n,e.firstChild);return e.parentNode.replaceChild(n,e),n}var c="|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|details|section|article|aside|nav|main|header|hgroup|footer|fieldset|dl|dt|dd|figure|figcaption|";function rt(e){return!!/11?|9/.test(e.nodeType)&&"|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr|isindex|link|meta|param|command|embed|keygen|source|track|object|".indexOf("|"+e.nodeName.toLowerCase()+"|")<0}function ot(e,t){var n=(e||{}).nodeType||Se;return n!==Ce?n===Se:"code"===(e=e.tagName.toLowerCase())?!t:c.indexOf("|"+e+"|")<0}function d(e){return e.lastChild&&d(e.lastChild)&&Ae(e.lastChild),3===e.nodeType?!e.nodeValue:rt(e)&&!e.childNodes.length}function it(e){Ze(e,function(e){var t=!ot(e,!0)&&e.nodeType!==l,n=e.parentNode;if(t&&(ot(n,!0)||"P"===n.tagName)){for(var r=e;ot(r.parentNode,!0)||"P"===r.parentNode.tagName;)r=r.parentNode;for(var o=f(r,e),i=e;n&&ot(n,!0);){if(n.nodeType===Ce){for(var a=n.cloneNode();i.firstChild;)Me(a,i.firstChild);Me(i,a)}n=n.parentNode}We(i,r),d(o)||We(o,i),d(r)&&Ae(r)}t&&Ue(e,"ul,ol")&&Ue(e.parentNode,"ul,ol")&&(o="li",t=(t=e).previousElementSibling,(t=o&&t&&!Ue(t,o)?null:t)||We(t=Ee("li"),e),Me(t,e))})}function u(e,t){return e?(t?e.previousSibling:e.nextSibling)||u(e.parentNode,t):null}function at(e){var t,n,r,o,i,a,l=je(e,"whiteSpace"),s=/line$/i.test(l),c=e.firstChild;if(!/pre(\-wrap)?$/i.test(l))for(;c;){if(i=c.nextSibling,t=c.nodeValue,(a=c.nodeType)===Ce&&c.firstChild&&at(c),a===Se){for(n=u(c),r=u(c,!0),a=!1;qe(r,"sceditor-ignore");)r=u(r,!0);if(ot(c)&&r){for(o=r;o.lastChild;)for(o=o.lastChild;qe(o,"sceditor-ignore");)o=u(o,!0);a=o.nodeType===Se?/[\t\n\r ]$/.test(o.nodeValue):!ot(o)}t=t.replace(/\u200B/g,""),r&&ot(r)&&!a||(t=t.replace(s?/^[\t ]+/:/^[\t\n\r ]+/,"")),(t=n&&ot(n)?t:t.replace(s?/[\t ]+$/:/[\t\n\r ]+$/,"")).length?c.nodeValue=t.replace(s?/[\t ]+/g:/[\t\n\r ]+/g," "):Ae(c)}c=i}}function f(e,t){var n=e.ownerDocument.createRange();return n.setStartBefore(e),n.setEndAfter(t),n.extractContents()}function lt(e){for(var t=0,n=0;e;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;return{left:t,top:n}}function p(e,t){var n=e.style;return i[t]||(i[t]=t.replace(/^-ms-/,"ms-").replace(/-(\w)/g,function(e,t){return t.toUpperCase()})),n=n[t=i[t]],"textAlign"===t&&(n=n||je(e,t),je(e.parentNode,t)===n||"block"!==je(e,"display")||Ue(e,"hr,th"))?"":n}function st(e,t){var n=e.attributes.length;if(n===t.attributes.length){for(;n--;){var r=e.attributes[n];if("style"===r.name?!function(e,t){var n=e.style.length;if(n===t.style.length){for(;n--;){var r=e.style[n];if(e.style[r]!==t.style[r])return}return 1}}(e,t):r.value!==Fe(t,r.name))return}return 1}}function ct(e){for(;e.firstChild;)We(e.firstChild,e);Ae(e)}var ut={toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,image,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source",toolbarExclude:null,style:"jquery.sceditor.default.css",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana",colors:"#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef",locale:Fe(document.documentElement,"lang")||"en",charset:"utf-8",emoticonsCompat:!1,emoticonsEnabled:!0,emoticonsRoot:"",emoticons:{dropdown:{":)":"emoticons/smile.png",":angel:":"emoticons/angel.png",":angry:":"emoticons/angry.png","8-)":"emoticons/cool.png",":'(":"emoticons/cwy.png",":ermm:":"emoticons/ermm.png",":D":"emoticons/grin.png","<3":"emoticons/heart.png",":(":"emoticons/sad.png",":O":"emoticons/shocked.png",":P":"emoticons/tongue.png",";)":"emoticons/wink.png"},more:{":alien:":"emoticons/alien.png",":blink:":"emoticons/blink.png",":blush:":"emoticons/blush.png",":cheerful:":"emoticons/cheerful.png",":devil:":"emoticons/devil.png",":dizzy:":"emoticons/dizzy.png",":getlost:":"emoticons/getlost.png",":happy:":"emoticons/happy.png",":kissing:":"emoticons/kissing.png",":ninja:":"emoticons/ninja.png",":pinch:":"emoticons/pinch.png",":pouty:":"emoticons/pouty.png",":sick:":"emoticons/sick.png",":sideways:":"emoticons/sideways.png",":silly:":"emoticons/silly.png",":sleeping:":"emoticons/sleeping.png",":unsure:":"emoticons/unsure.png",":woot:":"emoticons/w00t.png",":wassat:":"emoticons/wassat.png"},hidden:{":whistling:":"emoticons/whistling.png",":love:":"emoticons/wub.png"}},width:null,height:null,resizeEnabled:!0,resizeMinWidth:null,resizeMinHeight:null,resizeMaxHeight:null,resizeMaxWidth:null,resizeHeight:!0,resizeWidth:!0,dateFormat:"year-month-day",toolbarContainer:null,enablePasteFiltering:!1,disablePasting:!1,readOnly:!1,rtl:!1,autofocus:!1,autofocusEnd:!0,autoExpand:!1,autoUpdate:!1,spellcheck:!0,runWithoutWysiwygSupport:!1,startInSourceMode:!1,id:null,plugins:"",zIndex:null,bbcodeTrim:!1,disableBlockRemove:!1,allowedIframeUrls:[],parserOptions:{},dropDownCss:{}},m=/^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i;function dt(e){return e.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function ft(e,t){if(!e)return e;var n={"&":"&","<":"<",">":">"," ":" ","\r\n":"<br />","\r":"<br />","\n":"<br />"};return!1!==t&&(n['"']=""",n["'"]="'",n["`"]="`"),e.replace(/ {2}|\r\n|[&<>\r\n'"`]/g,function(e){return n[e]||e})}var h={html:'<!DOCTYPE html><html{attrs}><head><meta http-equiv="Content-Type" content="text/html;charset={charset}" /><link rel="stylesheet" type="text/css" href="{style}" /></head><body contenteditable="true" {spellcheck}><p></p></body></html>',toolbarButton:'<a class="sceditor-button sceditor-button-{name}" data-sceditor-command="{name}" unselectable="on"><div unselectable="on">{dispName}</div></a>',emoticon:'<img src="{url}" data-sceditor-emoticon="{key}" alt="{key}" title="{tooltip}" />',fontOpt:'<a class="sceditor-font-option" href="#" data-font="{font}"><font face="{font}">{font}</font></a>',sizeOpt:'<a class="sceditor-fontsize-option" data-size="{size}" href="#"><font size="{size}">{size}</font></a>',pastetext:'<div><label for="txt">{label}</label> <textarea cols="20" rows="7" id="txt"></textarea></div><div><input type="button" class="button" value="{insert}" /></div>',table:'<div><label for="rows">{rows}</label><input type="text" id="rows" value="2" /></div><div><label for="cols">{cols}</label><input type="text" id="cols" value="2" /></div><div><input type="button" class="button" value="{insert}" /></div>',image:'<div><label for="image">{url}</label> <input type="text" id="image" dir="ltr" placeholder="https://" /></div><div><label for="width">{width}</label> <input type="text" id="width" size="2" dir="ltr" /></div><div><label for="height">{height}</label> <input type="text" id="height" size="2" dir="ltr" /></div><div><input type="button" class="button" value="{insert}" /></div>',email:'<div><label for="email">{label}</label> <input type="text" id="email" dir="ltr" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{insert}" /></div>',link:'<div><label for="link">{url}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{ins}" /></div>',youtubeMenu:'<div><label for="link">{label}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><input type="button" class="button" value="{insert}" /></div>',youtube:'<iframe width="560" height="315" frameborder="0" allowfullscreen src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" data-youtube-id="{id}"></iframe>'};function pt(e,t,n){var r=h[e];return Object.keys(t).forEach(function(e){r=r.replace(new RegExp(dt("{"+e+"}"),"g"),t[e])}),r=n?et(r):r}function n(e){if("mozHidden"in document)for(var t,n=e.getBody();n;){if((t=n).firstChild)t=t.firstChild;else{for(;t&&!t.nextSibling;)t=t.parentNode;t=t&&t.nextSibling}3===n.nodeType&&/[\n\r\t]+/.test(n.nodeValue)&&(/^pre/.test(je(n.parentNode,"whiteSpace"))||Ae(n)),n=t}}var mt={bold:{exec:"bold",tooltip:"Bold",shortcut:"Ctrl+B"},italic:{exec:"italic",tooltip:"Italic",shortcut:"Ctrl+I"},underline:{exec:"underline",tooltip:"Underline",shortcut:"Ctrl+U"},strike:{exec:"strikethrough",tooltip:"Strikethrough"},subscript:{exec:"subscript",tooltip:"Subscript"},superscript:{exec:"superscript",tooltip:"Superscript"},left:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===je(e,"direction"),e=je(e,"textAlign");return/left/.test(e)||e===(t?"start":"end")}},exec:"justifyleft",tooltip:"Align left"},center:{exec:"justifycenter",tooltip:"Center"},right:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===je(e,"direction"),e=je(e,"textAlign");return/right/.test(e)||e===(t?"end":"start")}},exec:"justifyright",tooltip:"Align right"},justify:{exec:"justifyfull",tooltip:"Justify"},font:{_dropDown:function(t,e,n){var r=Ee("div");Oe(r,"click","a",function(e){n(Pe(this,"font")),t.closeDropDown(!0),e.preventDefault()}),t.opts.fonts.split(",").forEach(function(e){Me(r,pt("fontOpt",{font:e},!0))}),t.createDropDown(e,"font-picker",r)},exec:function(e){var t=this;mt.font._dropDown(t,e,function(e){t.execCommand("fontname",e)})},tooltip:"Font Name"},size:{_dropDown:function(t,e,n){var r=Ee("div");Oe(r,"click","a",function(e){n(Pe(this,"size")),t.closeDropDown(!0),e.preventDefault()});for(var o=1;o<=7;o++)Me(r,pt("sizeOpt",{size:o},!0));t.createDropDown(e,"fontsize-picker",r)},exec:function(e){var t=this;mt.size._dropDown(t,e,function(e){t.execCommand("fontsize",e)})},tooltip:"Font Size"},color:{_dropDown:function(t,e,n){var r=Ee("div"),o="",i=mt.color;i._htmlCache||(t.opts.colors.split("|").forEach(function(e){o+='<div class="sceditor-color-column">',e.split(",").forEach(function(e){o+='<a href="#" class="sceditor-color-option" style="background-color: '+e+'" data-color="'+e+'"></a>'}),o+="</div>"}),i._htmlCache=o),Me(r,et(i._htmlCache)),Oe(r,"click","a",function(e){n(Pe(this,"color")),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"color-picker",r)},exec:function(e){var t=this;mt.color._dropDown(t,e,function(e){t.execCommand("forecolor",e)})},tooltip:"Font Color"},removeformat:{exec:"removeformat",tooltip:"Remove Formatting"},cut:{exec:"cut",tooltip:"Cut",errorMessage:"Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X"},copy:{exec:"copy",tooltip:"Copy",errorMessage:"Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C"},paste:{exec:"paste",tooltip:"Paste",errorMessage:"Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V"},pastetext:{exec:function(e){var t,n=Ee("div"),r=this;Me(n,pt("pastetext",{label:r._("Paste your text inside the following box:"),insert:r._("Insert")},!0)),Oe(n,"click",".button",function(e){(t=Re(n,"#txt")[0].value)&&r.wysiwygEditorInsertText(t),r.closeDropDown(!0),e.preventDefault()}),r.createDropDown(e,"pastetext",n)},tooltip:"Paste Text"},bulletlist:{exec:function(){n(this),this.execCommand("insertunorderedlist")},tooltip:"Bullet list"},orderedlist:{exec:function(){n(this),this.execCommand("insertorderedlist")},tooltip:"Numbered list"},indent:{state:function(e,t){var n;return Ue(t,"li")||Ue(t,"ul,ol,menu")&&(t=(n=this.getRangeHelper().selectedRange()).startContainer.parentNode,n=n.endContainer.parentNode,t!==t.parentNode.firstElementChild||Ue(n,"li")&&n!==n.parentNode.lastElementChild)?0:-1},exec:function(){var e=this.getRangeHelper().getFirstBlockParent();this.focus(),Ne(e,"ul,ol,menu")&&this.execCommand("indent")},tooltip:"Add indent"},outdent:{state:function(e,t){return Ne(t,"ul,ol,menu")?0:-1},exec:function(){Ne(this.getRangeHelper().getFirstBlockParent(),"ul,ol,menu")&&this.execCommand("outdent")},tooltip:"Remove one indent"},table:{exec:function(e){var o=this,i=Ee("div");Me(i,pt("table",{rows:o._("Rows:"),cols:o._("Cols:"),insert:o._("Insert")},!0)),Oe(i,"click",".button",function(e){var t=Number(Re(i,"#rows")[0].value),n=Number(Re(i,"#cols")[0].value),r="<table>";0<t&&0<n&&(r+=Array(t+1).join("<tr>"+Array(n+1).join("<td><br /></td>")+"</tr>"),r+="</table>",o.wysiwygEditorInsertHtml(r),o.closeDropDown(!0),e.preventDefault())}),o.createDropDown(e,"inserttable",i)},tooltip:"Insert a table"},horizontalrule:{exec:"inserthorizontalrule",tooltip:"Insert a horizontal rule"},code:{exec:function(){this.wysiwygEditorInsertHtml("<code>","<br /></code>")},tooltip:"Code"},image:{_dropDown:function(t,e,n,r){var o=Ee("div");Me(o,pt("image",{url:t._("URL:"),width:t._("Width (optional):"),height:t._("Height (optional):"),insert:t._("Insert")},!0));var i=Re(o,"#image")[0];i.value=n,Oe(o,"click",".button",function(e){i.value&&r(i.value,Re(o,"#width")[0].value,Re(o,"#height")[0].value),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertimage",o)},exec:function(e){var o=this;mt.image._dropDown(o,e,"",function(e,t,n){var r="";t&&(r+=' width="'+parseInt(t,10)+'"'),n&&(r+=' height="'+parseInt(n,10)+'"'),r+=' src="'+ft(e)+'"',o.wysiwygEditorInsertHtml("<img"+r+" />")})},tooltip:"Insert an image"},email:{_dropDown:function(n,e,r){var o=Ee("div");Me(o,pt("email",{label:n._("E-mail:"),desc:n._("Description (optional):"),insert:n._("Insert")},!0)),Oe(o,"click",".button",function(e){var t=Re(o,"#email")[0].value;t&&r(t,Re(o,"#des")[0].value),n.closeDropDown(!0),e.preventDefault()}),n.createDropDown(e,"insertemail",o)},exec:function(e){var n=this;mt.email._dropDown(n,e,function(e,t){!n.getRangeHelper().selectedHtml()||t?n.wysiwygEditorInsertHtml('<a href="mailto:'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink","mailto:"+e)})},tooltip:"Insert an email"},link:{_dropDown:function(t,e,n){var r=Ee("div");Me(r,pt("link",{url:t._("URL:"),desc:t._("Description (optional):"),ins:t._("Insert")},!0));var o=Re(r,"#link")[0];function i(e){o.value&&n(o.value,Re(r,"#des")[0].value),t.closeDropDown(!0),e.preventDefault()}Oe(r,"click",".button",i),Oe(r,"keypress",function(e){13===e.which&&o.value&&i(e)},_e),t.createDropDown(e,"insertlink",r)},exec:function(e){var n=this;mt.link._dropDown(n,e,function(e,t){t||!n.getRangeHelper().selectedHtml()?n.wysiwygEditorInsertHtml('<a href="'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink",e)})},tooltip:"Insert a link"},unlink:{state:function(){return Ne(this.currentNode(),"a")?0:-1},exec:function(){var e=Ne(this.currentNode(),"a");if(e){for(;e.firstChild;)We(e.firstChild,e);Ae(e)}},tooltip:"Unlink"},quote:{exec:function(e,t,n){var r="<blockquote>",o="</blockquote>";t?(r=r+(n=n?"<cite>"+ft(n)+"</cite>":"")+t+o,o=null):""===this.getRangeHelper().selectedHtml()&&(o="<br />"+o),this.wysiwygEditorInsertHtml(r,o)},tooltip:"Insert a Quote"},emoticon:{exec:function(u){var d=this,f=function(e){var n,t=d.opts,r=t.emoticonsRoot||"",o=t.emoticonsCompat,i=d.getRangeHelper(),a=o&&" "!==i.getOuterText(!0,1)?" ":"",l=o&&" "!==i.getOuterText(!1,1)?" ":"",s=Ee("div"),c=Ee("div"),i=we({},t.emoticons.dropdown,e?t.emoticons.more:{});return Me(s,c),n=Math.sqrt(Object.keys(i).length),Oe(s,"click","img",function(e){d.insert(a+Fe(this,"alt")+l,null,!1).closeDropDown(!0),e.preventDefault()}),Te(i,function(e,t){Me(c,Ee("img",{src:r+(t.url||t),alt:e,title:t.tooltip||e})),c.children.length>=n&&(c=Ee("div"),Me(s,c))}),!e&&t.emoticons.more&&(Me(t=Ee("a",{className:"sceditor-more"}),document.createTextNode(d._("More"))),Oe(t,"click",function(e){d.createDropDown(u,"more-emoticons",f(!0)),e.preventDefault()}),Me(s,t)),s};d.createDropDown(u,"emoticons",f(!1))},txtExec:function(e){mt.emoticon.exec.call(this,e)},tooltip:"Insert an emoticon"},youtube:{_dropDown:function(o,e,i){var a=Ee("div");Me(a,pt("youtubeMenu",{label:o._("Video URL:"),insert:o._("Insert")},!0)),Oe(a,"click",".button",function(e){var t=(n=Re(a,"#link")[0].value).match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/),n=n.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/),r=0;n&&Te(n[1].split(/[hms]/),function(e,t){""!==t&&(r=60*r+Number(t))}),t&&/^[a-zA-Z0-9_\-]{11}$/.test(t[1])&&i(t[1],r),o.closeDropDown(!0),e.preventDefault()}),o.createDropDown(e,"insertlink",a)},exec:function(e){var n=this;mt.youtube._dropDown(n,e,function(e,t){n.wysiwygEditorInsertHtml(pt("youtube",{id:e,time:t}))})},tooltip:"Insert a YouTube video"},date:{_date:function(e){var t=new Date,n=t.getYear(),r=t.getMonth()+1;return n<2e3&&(n=1900+n),r<10&&(r="0"+r),(t=t.getDate())<10&&(t="0"+t),e.opts.dateFormat.replace(/year/i,n).replace(/month/i,r).replace(/day/i,t)},exec:function(){this.insertText(mt.date._date(this))},txtExec:function(){this.insertText(mt.date._date(this))},tooltip:"Insert current date"},time:{_time:function(){var e=new Date,t=e.getHours(),n=e.getMinutes();return(t=t<10?"0"+t:t)+":"+(n=n<10?"0"+n:n)+":"+((e=e.getSeconds())<10?"0"+e:e)},exec:function(){this.insertText(mt.time._time())},txtExec:function(){this.insertText(mt.time._time())},tooltip:"Insert current time"},ltr:{state:function(e,t){return t&&"ltr"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!Ue(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!Ue(t,"body")))&&(e="ltr"===je(t,"direction")?"":"ltr",je(t,"direction",e))},tooltip:"Left-to-Right"},rtl:{state:function(e,t){return t&&"rtl"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!Ue(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!Ue(t,"body")))&&(e="rtl"===je(t,"direction")?"":"rtl",je(t,"direction",e))},tooltip:"Right-to-Left"},print:{exec:"print",tooltip:"Print"},maximize:{state:function(){return this.maximize()},exec:function(){this.maximize(!this.maximize()),this.focus()},txtExec:function(){this.maximize(!this.maximize()),this.focus()},tooltip:"Maximize",shortcut:"Ctrl+Shift+M"},source:{state:function(){return this.sourceMode()},exec:function(){this.toggleSourceMode(),this.focus()},txtExec:function(){this.toggleSourceMode(),this.focus()},tooltip:"View source",shortcut:"Ctrl+Shift+S"},ignore:{}},g={};function ht(i){function a(e){return"signal"+e.charAt(0).toUpperCase()+e.slice(1)}function e(e,t){for(var n,r=a((e=[].slice.call(e)).shift()),o=0;o<l.length;o++)if(r in l[o]&&(n=l[o][r].apply(i,e),t))return n}var o=this,l=[];o.call=function(){e(arguments,!1)},o.callOnlyFirst=function(){return e(arguments,!0)},o.hasHandler=function(e){var t=l.length;for(e=a(e);t--;)if(e in l[t])return!0;return!1},o.exists=function(e){return e in g&&"function"==typeof(e=g[e])&&"object"==typeof e.prototype},o.isRegistered=function(e){if(o.exists(e))for(var t=l.length;t--;)if(l[t]instanceof g[e])return!0;return!1},o.register=function(e){return!(!o.exists(e)||o.isRegistered(e)||(e=new g[e],l.push(e),"init"in e&&e.init.call(i),0))},o.deregister=function(e){var t,n=l.length,r=!1;if(!o.isRegistered(e))return r;for(;n--;)l[n]instanceof g[e]&&(r=!0,"destroy"in(t=l.splice(n,1)[0])&&t.destroy.call(i));return r},o.destroy=function(){for(var e=l.length;e--;)"destroy"in l[e]&&l[e].destroy.call(i);l=[],i=null}}ht.plugins=g;var v=function(e,t,n){var r,o,i,a,l,s="",c=e.startContainer,u=e.startOffset;for(c&&3!==c.nodeType&&(c=c.childNodes[u],u=0),i=a=u;n>s.length&&c&&3===c.nodeType;)r=c.nodeValue,o=n-s.length,l&&(a=r.length,i=0),l=c,c=t?(u=i=Math.max(a-o,0),s=r.substr(i,a-i)+s,l.previousSibling):(u=i+(a=Math.min(o,r.length)),s+=r.substr(i,a),l.nextSibling);return{node:l||c,offset:u,text:s}};function gt(o,e,i){var a,l,s=e||o.contentDocument||o.document,c="sceditor-start-marker",u="sceditor-end-marker",g=this;g.insertHTML=function(e,t){var n,r;if(!g.selectedRange())return!1;for(t&&(e+=g.selectedHtml()+t),r=Ee("p",{},s),n=s.createDocumentFragment(),r.innerHTML=i(e);r.firstChild;)Me(n,r.firstChild);g.insertNode(n)},l=function(e,t,n){var r,o=s.createDocumentFragment();if("string"==typeof e?(t&&(e+=g.selectedHtml()+t),o=et(e)):(Me(o,e),t&&(Me(o,g.selectedRange().extractContents()),Me(o,t))),r=o.lastChild){for(;!ot(r.lastChild,!0);)r=r.lastChild;return(rt(r)?r.lastChild||Me(r,document.createTextNode("")):r=o,g.removeMarkers(),Me(r,a(c)),Me(r,a(u)),n)?(Me(n=Ee("div"),o),n.innerHTML):o}},g.insertNode=function(e,t){var n,r,o=l(e,t),t=(e=g.selectedRange()).commonAncestorContainer,i=[];if(!o)return!1;function a(e){e&&d(e)&&i.indexOf(e)<0&&Ae(e)}e.startContainer!==e.endContainer&&(Te(t.childNodes,function(e,t){d(t)&&i.push(t)}),n=o.firstChild,r=o.lastChild),e.deleteContents(),t&&3!==t.nodeType&&!rt(t)?We(o,t):(e.insertNode(o),a(n&&n.previousSibling),a(r&&r.nextSibling)),g.restoreRange()},g.cloneSelected=function(){var e=g.selectedRange();if(e)return e.cloneRange()},g.selectedRange=function(){var e,t,n=o.getSelection();if(n){if(n.rangeCount<=0){for(t=s.body;t.firstChild;)t=t.firstChild;(e=s.createRange()).setStartBefore(t),n.addRange(e)}return 0<n.rangeCount?n.getRangeAt(0):e}},g.hasSelection=function(){var e=o.getSelection();return e&&0<e.rangeCount},g.selectedHtml=function(){var e,t=g.selectedRange();return t?(Me(e=Ee("p",{},s),t.cloneContents()),e.innerHTML):""},g.parentNode=function(){var e=g.selectedRange();if(e)return e.commonAncestorContainer},g.getFirstBlockParent=function(e){var t=function(e){return ot(e,!0)?(e=e?e.parentNode:null)&&t(e):e};return t(e||g.parentNode())},g.insertNodeAt=function(e,t){var n=g.selectedRange(),r=g.cloneSelected();if(!r)return!1;r.collapse(e),r.insertNode(t),g.selectRange(n)},a=function(e){return g.removeMarker(e),(e=Ee("span",{id:e,className:"sceditor-selection sceditor-ignore",style:"display:none;line-height:0"},s)).innerHTML=" ",e},g.insertMarkers=function(){var e=g.selectedRange(),t=a(c);g.removeMarkers(),g.insertNodeAt(!0,t),e&&e.collapsed?t.parentNode.insertBefore(a(u),t.nextSibling):g.insertNodeAt(!1,a(u))},g.getMarker=function(e){return s.getElementById(e)},g.removeMarker=function(e){(e=g.getMarker(e))&&Ae(e)},g.removeMarkers=function(){g.removeMarker(c),g.removeMarker(u)},g.saveRange=function(){g.insertMarkers()},g.selectRange=function(e){var t,n=o.getSelection(),r=e.endContainer;if(e.collapsed&&r&&!ot(r,!0)){for(t=r.lastChild;t&&Ue(t,".sceditor-ignore");)t=t.previousSibling;Ue(t,"br")&&((r=s.createRange()).setEndAfter(t),r.collapse(!1),g.compare(e,r)&&(e.setStartBefore(t),e.collapse(!0)))}n&&(g.clear(),n.addRange(e))},g.restoreRange=function(){var e,t=g.selectedRange(),n=g.getMarker(c),r=g.getMarker(u);if(!n||!r||!t)return!1;e=n.nextSibling===r,(t=s.createRange()).setStartBefore(n),t.setEndAfter(r),e&&t.collapse(!0),g.selectRange(t),g.removeMarkers()},g.selectOuterText=function(e,t){var n=g.cloneSelected();if(!n)return!1;n.collapse(!1),e=v(n,!0,e),t=v(n,!1,t),n.setStart(e.node,e.offset),n.setEnd(t.node,t.offset),g.selectRange(n)},g.getOuterText=function(e,t){var n=g.cloneSelected();return n?(n.collapse(!e),v(n,e,t).text):""},g.replaceKeyword=function(e,t,n,r,o,i){n||e.sort(function(e,t){return e[0].length-t[0].length});var a,l,s,c,u,d,f,p="(^|[\\s ])",m=e.length,h=o?1:0,r=r||e[m-1][0].length;for(o&&r++,i=i||"",c=(a=g.getOuterText(!0,r)).length,a+=i,t&&(a+=g.getOuterText(!1,r));m--;)if(f=(d=e[m][0]).length,s=Math.max(0,c-f-h),u=-1,o?(l=a.substr(s).match(new RegExp(p+dt(d)+p)))&&(u=l.index+s+l[1].length):u=a.indexOf(d,s),-1<u&&u<=c&&c<=u+f+h)return u=c-u,g.selectOuterText(u,f-u-(/^\S/.test(i)?1:0)),g.insertHTML(e[m][1]),!0;return!1},g.compare=function(e,t){return t=t||g.selectedRange(),e&&t?0===e.compareBoundaryPoints(Range.END_TO_END,t)&&0===e.compareBoundaryPoints(Range.START_TO_START,t):!e&&!t},g.clear=function(){var e=o.getSelection();e&&(e.removeAllRanges?e.removeAllRanges():e.empty&&e.empty())}}var y,b,x,w=navigator.userAgent,vt=/iPhone|iPod|iPad| wosbrowser\//i.test(w),yt=(b=!!window.document.documentMode,D="-ms-ime-align"in document.documentElement.style,(A=document.createElement("div")).contentEditable=!0,"contentEditable"in document.documentElement&&"true"===A.contentEditable&&(A=/Opera Mobi|Opera Mini/i.test(w),/Android/i.test(w)&&(A=!0,/Safari/.test(w)&&(A=!(y=/Safari\/(\d+)/.exec(w))||!y[1]||y[1]<534)),/ Silk\//i.test(w)&&(A=!(y=/AppleWebKit\/(\d+)/.exec(w))||!y[1]||y[1]<534),vt&&(A=/OS [0-4](_\d)+ like Mac/i.test(w)),/Firefox/i.test(w)&&(A=!1),/OneBrowser/i.test(w)&&(A=!1),"UCWEB"===navigator.vendor&&(A=!1),!(A=!(!b&&!D)||A))),k=Object.hasOwnProperty,T=Object.setPrototypeOf,C=Object.isFrozen,S=Object.getPrototypeOf,E=Object.getOwnPropertyDescriptor,bt=Object.freeze,D=Object.seal,N=Object.create,A="undefined"!=typeof Reflect&&Reflect,M=(M=A.apply)||function(e,t,n){return e.apply(t,n)},bt=bt||function(e){return e},D=D||function(e){return e},R=(R=A.construct)||function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))},xt=_(Array.prototype.forEach),wt=_(Array.prototype.pop),kt=_(Array.prototype.push),Tt=_(String.prototype.toLowerCase),Ct=_(String.prototype.match),St=_(String.prototype.replace),Et=_(String.prototype.indexOf),Dt=_(String.prototype.trim),Nt=_(RegExp.prototype.test),At=(x=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return R(x,t)});function _(o){return function(e){for(var t=arguments.length,n=Array(1<t?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return M(o,e,n)}}function Mt(e,t){T&&T(e,null);for(var n=t.length;n--;){var r,o=t[n];"string"!=typeof o||(r=Tt(o))!==o&&(C(t)||(t[n]=r),o=r),e[o]=!0}return e}function Rt(e){var t=N(null),n=void 0;for(n in e)M(k,e,[n])&&(t[n]=e[n]);return t}function _t(e,t){for(;null!==e;){var n=E(e,t);if(n){if(n.get)return _(n.get);if("function"==typeof n.value)return _(n.value)}e=S(e)}return null}var Ot=bt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Bt=bt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ft=bt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ht=bt(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),It=bt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),zt=bt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Lt=bt(["#text"]),jt=bt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns"]),Pt=bt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ut=bt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=bt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),qt=D(/\{\{[\s\S]*|[\s\S]*\}\}/gm),Vt=D(/<%[\s\S]*|[\s\S]*%>/gm),$t=D(/^data-[\-\w.\u00B7-\uFFFF]/),Gt=D(/^aria-[\-\w]+$/),Yt=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Kt=D(/^(?:\w+script|data):/i),Xt=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function Zt(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var Jt=function t(e){function c(e){return t(e)}var l=0<arguments.length&&void 0!==e?e:"undefined"==typeof window?null:window;if(c.version="2.2.6",c.removed=[],!l||!l.document||9!==l.document.nodeType)return c.isSupported=!1,c;var s=l.document,i=l.document,u=l.DocumentFragment,n=l.HTMLTemplateElement,d=l.Node,a=l.Element,r=l.NodeFilter,o=l.NamedNodeMap,f=void 0===o?l.NamedNodeMap||l.MozNamedAttrMap:o,p=l.Text,m=l.Comment,h=l.DOMParser,e=l.trustedTypes,g=_t(o=a.prototype,"cloneNode"),v=_t(o,"nextSibling"),y=_t(o,"childNodes"),b=_t(o,"parentNode");"function"!=typeof n||(n=i.createElement("template")).content&&n.content.ownerDocument&&(i=n.content.ownerDocument);var x=function(e,t){if("object"!==(void 0===e?"undefined":Qt(e))||"function"!=typeof e.createPolicy)return null;var n=null,r="data-tt-policy-suffix",o="dompurify"+((n=t.currentScript&&t.currentScript.hasAttribute(r)?t.currentScript.getAttribute(r):n)?"#"+n:"");try{return e.createPolicy(o,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(e,s),w=x&&ee?x.createHTML(""):"",k=i.implementation,T=i.createNodeIterator,C=i.getElementsByTagName,S=i.createDocumentFragment,E=s.importNode,D={};try{D=Rt(i).documentMode?i.documentMode:{}}catch(e){}var N={};function A(e){ce&&ce===e||(e=Rt(e=e&&"object"===(void 0===e?"undefined":Qt(e))?e:{}),z="ALLOWED_TAGS"in e?Mt({},e.ALLOWED_TAGS):L,j="ALLOWED_ATTR"in e?Mt({},e.ALLOWED_ATTR):P,le="ADD_URI_SAFE_ATTR"in e?Mt(Rt(se),e.ADD_URI_SAFE_ATTR):se,ie="ADD_DATA_URI_TAGS"in e?Mt(Rt(ae),e.ADD_DATA_URI_TAGS):ae,U="FORBID_TAGS"in e?Mt({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?Mt({},e.FORBID_ATTR):{},M="USE_PROFILES"in e&&e.USE_PROFILES,q=!1!==e.ALLOW_ARIA_ATTR,V=!1!==e.ALLOW_DATA_ATTR,$=e.ALLOW_UNKNOWN_PROTOCOLS||!1,G=e.SAFE_FOR_TEMPLATES||!1,Y=e.WHOLE_DOCUMENT||!1,Q=e.RETURN_DOM||!1,Z=e.RETURN_DOM_FRAGMENT||!1,J=!1!==e.RETURN_DOM_IMPORT,ee=e.RETURN_TRUSTED_TYPE||!1,X=e.FORCE_BODY||!1,te=!1!==e.SANITIZE_DOM,ne=!1!==e.KEEP_CONTENT,re=e.IN_PLACE||!1,I=e.ALLOWED_URI_REGEXP||I,G&&(V=!1),Z&&(Q=!0),M&&(z=Mt({},[].concat(Zt(Lt))),j=[],!0===M.html&&(Mt(z,Ot),Mt(j,jt)),!0===M.svg&&(Mt(z,Bt),Mt(j,Pt),Mt(j,Wt)),!0===M.svgFilters&&(Mt(z,Ft),Mt(j,Pt),Mt(j,Wt)),!0===M.mathMl&&(Mt(z,It),Mt(j,Ut),Mt(j,Wt))),e.ADD_TAGS&&Mt(z=z===L?Rt(z):z,e.ADD_TAGS),e.ADD_ATTR&&Mt(j=j===P?Rt(j):j,e.ADD_ATTR),e.ADD_URI_SAFE_ATTR&&Mt(le,e.ADD_URI_SAFE_ATTR),ne&&(z["#text"]=!0),Y&&Mt(z,["html","head","body"]),z.table&&(Mt(z,["tbody"]),delete U.tbody),bt&&bt(e),ce=e)}c.isSupported=k&&void 0!==k.createHTMLDocument&&9!==D;var M,R=qt,_=Vt,O=$t,B=Gt,F=Kt,H=Xt,I=Yt,z=null,L=Mt({},[].concat(Zt(Ot),Zt(Bt),Zt(Ft),Zt(It),Zt(Lt))),j=null,P=Mt({},[].concat(Zt(jt),Zt(Pt),Zt(Ut),Zt(Wt))),U=null,W=null,q=!0,V=!0,$=!1,G=!1,Y=!1,K=!1,X=!1,Q=!1,Z=!1,J=!0,ee=!1,te=!0,ne=!0,re=!1,oe=Mt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ie=null,ae=Mt({},["audio","video","img","source","image","track"]),le=null,se=Mt({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),ce=null,ue=i.createElement("form"),de=Mt({},["mi","mo","mn","ms","mtext"]),fe=Mt({},["foreignobject","desc","title","annotation-xml"]),pe=Mt({},Bt);Mt(pe,Ft),Mt(pe,Ht);var me=Mt({},It);function he(t){kt(c.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=w}catch(e){t.remove()}}}function ge(e,t){try{kt(c.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){kt(c.removed,{attribute:null,from:t})}t.removeAttribute(e)}function ve(e){var t=void 0,n=void 0;X?e="<remove></remove>"+e:n=(r=Ct(e,/^[\r\n\t ]+/))&&r[0];var r,o=x?x.createHTML(e):e;try{t=(new h).parseFromString(o,"text/html")}catch(e){}return t&&t.documentElement||((r=(t=k.createHTMLDocument("")).body).parentNode.removeChild(r.parentNode.firstElementChild),r.outerHTML=o),e&&n&&t.body.insertBefore(i.createTextNode(n),t.body.childNodes[0]||null),C.call(t,Y?"html":"body")[0]}function ye(e){return T.call(e.ownerDocument||e,e,r.SHOW_ELEMENT|r.SHOW_COMMENT|r.SHOW_TEXT,function(){return r.FILTER_ACCEPT},!1)}function be(e){return"object"===(void 0===d?"undefined":Qt(d))?e instanceof d:e&&"object"===(void 0===e?"undefined":Qt(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function xe(e,t,n){N[e]&&xt(N[e],function(e){e.call(c,t,n,ce)})}function we(e){var t;if(xe("beforeSanitizeElements",e,null),!((n=e)instanceof p||n instanceof m||"string"==typeof n.nodeName&&"string"==typeof n.textContent&&"function"==typeof n.removeChild&&n.attributes instanceof f&&"function"==typeof n.removeAttribute&&"function"==typeof n.setAttribute&&"string"==typeof n.namespaceURI&&"function"==typeof n.insertBefore))return he(e),1;if(Ct(e.nodeName,/[\u0080-\uFFFF]/))return he(e),1;var n=Tt(e.nodeName);if(xe("uponSanitizeElement",e,{tagName:n,allowedTags:z}),!be(e.firstElementChild)&&(!be(e.content)||!be(e.content.firstElementChild))&&Nt(/<[/\w]/g,e.innerHTML)&&Nt(/<[/\w]/g,e.textContent))return he(e),1;if(z[n]&&!U[n])return e instanceof a&&!function(e){var t=b(e);t&&t.tagName||(t={namespaceURI:Ee,tagName:"template"});var n=Tt(e.tagName),r=Tt(t.tagName);return e.namespaceURI===Se?t.namespaceURI===Ee?"svg"===n:t.namespaceURI===Ce?"svg"===n&&("annotation-xml"===r||de[r]):Boolean(pe[n]):e.namespaceURI===Ce?t.namespaceURI===Ee?"math"===n:t.namespaceURI===Se?"math"===n&&fe[r]:Boolean(me[n]):e.namespaceURI===Ee&&(t.namespaceURI!==Se||fe[r])&&(t.namespaceURI!==Ce||de[r])&&(r=Mt({},["title","style","font","a","script"]),!me[n]&&(r[n]||!pe[n]))}(e)||("noscript"===n||"noembed"===n)&&Nt(/<\/no(script|embed)/i,e.innerHTML)?(he(e),1):(G&&3===e.nodeType&&(t=e.textContent,t=St(t,R," "),t=St(t,_," "),e.textContent!==t&&(kt(c.removed,{element:e.cloneNode()}),e.textContent=t)),xe("afterSanitizeElements",e,null),0);if(ne&&!oe[n])for(var r=b(e),o=y(e),i=o.length-1;0<=i;--i)r.insertBefore(g(o[i],!0),v(e));return he(e),1}function ke(e,t,n){if(te&&("id"===t||"name"===t)&&(n in i||n in ue))return!1;if(!(V&&Nt(O,t)||q&&Nt(B,t))){if(!j[t]||W[t])return!1;if(!le[t]&&!Nt(I,St(n,H,""))&&("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Et(n,"data:")||!ie[e])&&(!$||Nt(F,St(n,H,"")))&&n)return!1}return!0}function Te(e){var t,n=void 0,r=void 0;xe("beforeSanitizeAttributes",e,null);var o=e.attributes;if(o){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j},r=o.length;r--;){var a=(t=o[r]).name,l=t.namespaceURI,n=Dt(t.value),s=Tt(a);if(i.attrName=s,i.attrValue=n,i.keepAttr=!0,i.forceKeepAttr=void 0,xe("uponSanitizeAttribute",e,i),n=i.attrValue,!i.forceKeepAttr&&(ge(a,e),i.keepAttr))if(Nt(/\/>/i,n))ge(a,e);else if(G&&(n=St(n,R," "),n=St(n,_," ")),ke(e.nodeName.toLowerCase(),s,n))try{l?e.setAttributeNS(l,a,n):e.setAttribute(a,n),wt(c.removed)}catch(e){}}xe("afterSanitizeAttributes",e,null)}}Mt(me,zt);var Ce="http://www.w3.org/1998/Math/MathML",Se="http://www.w3.org/2000/svg",Ee="http://www.w3.org/1999/xhtml";return c.sanitize=function(e,t){var n,r=void 0,o=void 0,i=void 0;if("string"!=typeof(e=e||"\x3c!--\x3e")&&!be(e)){if("function"!=typeof e.toString)throw At("toString is not a function");if("string"!=typeof(e=e.toString()))throw At("dirty is not a string, aborting")}if(!c.isSupported){if("object"===Qt(l.toStaticHTML)||"function"==typeof l.toStaticHTML){if("string"==typeof e)return l.toStaticHTML(e);if(be(e))return l.toStaticHTML(e.outerHTML)}return e}if(K||A(t),c.removed=[],!(re="string"==typeof e?!1:re))if(e instanceof d)1===(t=(r=ve("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===t.nodeName||"HTML"===t.nodeName?r=t:r.appendChild(t);else{if(!Q&&!G&&!Y&&-1===e.indexOf("<"))return x&&ee?x.createHTML(e):e;if(!(r=ve(e)))return Q?null:w}r&&X&&he(r.firstChild);for(var a=ye(re?e:r);n=a.nextNode();)3===n.nodeType&&n===o||we(n)||(n.content instanceof u&&function e(t){var n,r=ye(t);for(xe("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)xe("uponSanitizeShadowNode",n,null),we(n)||(n.content instanceof u&&e(n.content),Te(n));xe("afterSanitizeShadowDOM",t,null)}(n.content),Te(n),o=n);if(o=null,re)return e;if(Q){if(Z)for(i=S.call(r.ownerDocument);r.firstChild;)i.appendChild(r.firstChild);else i=r;return J?E.call(s,i,!0):i}return e=Y?r.outerHTML:r.innerHTML,G&&(e=St(e,R," "),e=St(e,_," ")),x&&ee?x.createHTML(e):e},c.setConfig=function(e){A(e),K=!0},c.clearConfig=function(){ce=null,K=!1},c.isValidAttribute=function(e,t,n){return ce||A({}),ke(e=Tt(e),t=Tt(t),n)},c.addHook=function(e,t){"function"==typeof t&&(N[e]=N[e]||[],kt(N[e],t))},c.removeHook=function(e){N[e]&&wt(N[e])},c.removeHooks=function(e){N[e]&&(N[e]=[])},c.removeAllHooks=function(){N={}},c}(),en=window,tn=document,nn=/^image\/(p?jpe?g|gif|png|bmp)$/i;function rn(o,e){var a,x,u,i,l,f,d,s,r,c,p,t,m,h,g,v,y,b,n,w,k,T,C,S,E,D,N,A,M,R,_,O,B,F,H,I,z,L,j,P,U,W,q,V,$,G,Y,K,X,Q,Z,J,ee,te,ne,re,oe,ie,ae,le,se=this,ce={},ue=[],de=[],fe={},pe={},me={};se.commands=we(!0,{},e.commands||mt);var he=se.opts=we(!0,{},ut,e);se.opts.emoticons=e.emoticons||ut.emoticons,Array.isArray(he.allowedIframeUrls)||(he.allowedIframeUrls=[]),he.allowedIframeUrls.push("https://www.youtube-nocookie.com/embed/");var ge=Jt();function ve(e){return ge.sanitize(e,{ADD_TAGS:["iframe"],ADD_ATTR:["allowfullscreen","frameborder","target"]})}ge.addHook("uponSanitizeElement",function(e,t){var n=he.allowedIframeUrls;if("iframe"===t.tagName){for(var r=Fe(e,"src")||"",o=0;o<n.length;o++){var i=n[o];if(ye(i)&&r.substr(0,i.length)===i)return;if(i.test&&i.test(r))return}Ae(e)}}),ge.addHook("afterSanitizeAttributes",function(e){"target"in e&&Fe(e,"data-sce-target",Fe(e,"target")),He(e,"target")}),e=function(){o._sceditor=se,he.locale&&"en"!==he.locale&&M(),We(x=Ee("div",{className:"sceditor-container"}),o),je(x,"z-index",he.zIndex),n=o.required,o.required=!1;var e=rn.formats[he.format];a=e?new e:{},h=new ht(se),(he.plugins||"").split(",").forEach(function(e){h.register(e.trim())}),"init"in a&&a.init.call(se),F(),R(),A(),_(),O(),yt||se.toggleSourceMode(),Y();var t=function(){Be(en,"load",t),he.autofocus&&J(!!he.autofocusEnd),le(),X(),h.call("ready"),"onReady"in a&&a.onReady.call(se)};Oe(en,"load",t),"complete"===tn.readyState&&t()},M=function(){var e;(t=rn.locale[he.locale])||(e=he.locale.split("-"),t=rn.locale[e[0]]),t&&t.dateFormat&&(he.dateFormat=t.dateFormat)},A=function(){s=Ee("textarea"),i=Ee("iframe",{frameborder:0,allowfullscreen:!0}),he.startInSourceMode?(Ve(x,"sourceMode"),Ie(i)):(Ve(x,"wysiwygMode"),Ie(s)),he.spellcheck||Fe(x,"spellcheck","false"),"https:"===en.location.protocol&&Fe(i,"src","about:blank"),Me(x,i),Me(x,s),se.dimensions(he.width||Ye(o),he.height||Ke(o));var e=vt?" ios":"";(d=i.contentDocument).open(),d.write(pt("html",{attrs:' class="'+e+'"',spellcheck:he.spellcheck?"":'spellcheck="false"',charset:he.charset,style:he.style})),d.close(),f=d.body,l=i.contentWindow,se.readOnly(!!he.readOnly),vt&&(Ke(f,"100%"),Oe(f,"touchend",se.focus)),e=Fe(o,"tabindex"),Fe(s,"tabindex",e),Fe(i,"tabindex",e),m=new gt(l,null,ve),Ie(o),se.val(o.value),(e=he.placeholder||Fe(o,"placeholder"))&&(s.placeholder=e,Fe(f,"placeholder",e))},_=function(){he.autoUpdate&&(Oe(f,"blur",ae),Oe(s,"blur",ae)),null===he.rtl&&(he.rtl="rtl"===je(s,"direction")),se.rtl(!!he.rtl),he.autoExpand&&(Oe(f,"load",le,_e),Oe(f,"input keyup",le)),he.resizeEnabled&&B(),Fe(x,"id",he.id),se.emoticons(he.emoticonsEnabled)},O=function(){var e=o.form,t="compositionstart compositionend",n="keydown keyup keypress focus blur contextmenu input",r="onselectionchange"in d?"selectionchange":"keyup focus blur contextmenu mouseup touchend click";Oe(tn,"click",$),e&&(Oe(e,"reset",U),Oe(e,"submit",se.updateOriginal,_e)),Oe(window,"pagehide",se.updateOriginal),Oe(window,"pageshow",U),Oe(f,"keypress",P),Oe(f,"keydown",L),Oe(f,"keydown",j),Oe(f,"keyup",X),Oe(f,"blur",oe),Oe(f,"keyup",ie),Oe(f,"paste",H),Oe(f,"cut copy",I),Oe(f,t,q),Oe(f,r,Q),Oe(f,n,V),he.emoticonsCompat&&en.getSelection&&Oe(f,"keyup",te),Oe(f,"blur",function(){se.val()||Ve(f,"placeholder")}),Oe(f,"focus",function(){$e(f,"placeholder")}),Oe(s,"blur",oe),Oe(s,"keyup",ie),Oe(s,"keydown",L),Oe(s,t,q),Oe(s,n,V),Oe(d,"mousedown",W),Oe(d,r,Q),Oe(d,"keyup",X),Oe(x,"selectionchanged",Z),Oe(x,"selectionchanged",Y),Oe(x,"selectionchanged valuechanged nodechanged pasteraw paste",V)},R=function(){var i,a=se.commands,l=(he.toolbarExclude||"").split(","),e=he.toolbar.split("|");u=Ee("div",{className:"sceditor-toolbar",unselectable:"on"}),he.icons in rn.icons&&(E=new rn.icons[he.icons]),Te(e,function(e,t){i=Ee("div",{className:"sceditor-group"}),Te(t.split(","),function(e,t){var n,r,o=a[t];!o||-1<l.indexOf(t)||(n=o.shortcut,r=pt("toolbarButton",{name:t,dispName:se._(o.name||o.tooltip||t)},!0).firstChild,E&&E.create&&E.create(t)&&(We(E.create(t),r.firstChild),Ve(r,"has-icon")),r._sceTxtMode=!!o.txtExec,r._sceWysiwygMode=!!o.exec,Ge(r,"disabled",!o.exec),Oe(r,"click",function(e){qe(r,"disabled")||N(r,o),Y(),e.preventDefault()}),Oe(r,"mousedown",function(e){se.closeDropDown(),e.preventDefault()}),o.tooltip&&Fe(r,"title",se._(o.tooltip)+(n?" ("+n+")":"")),n&&se.addShortcut(n,t),o.state?de.push({name:t,state:o.state}):ye(o.exec)&&de.push({name:t,state:o.exec}),Me(i,r),pe[t]=r)}),i.firstChild&&Me(u,i)}),Me(he.toolbarContainer||x,u)},B=function(){function t(e){r="touchmove"===e.type?(e=en.event,s=e.changedTouches[0].pageX,e.changedTouches[0].pageY):(s=e.pageX,e.pageY);var t=u+(r-l),n=m?c-(s-a):c+(s-a);0<y&&y<n&&(n=y),0<v&&n<v&&(n=v),he.resizeWidth||(n=!1),0<g&&g<t&&(t=g),0<h&&t<h&&(t=h),he.resizeHeight||(t=!1),(n||t)&&se.dimensions(n,t),e.preventDefault()}var r,e=Ee("div",{className:"sceditor-grip"}),n=Ee("div",{className:"sceditor-resize-cover"}),o="touchmove mousemove",i="touchcancel touchend mouseup",a=0,l=0,s=0,c=0,u=0,d=Ye(x),f=Ke(x),p=!1,m=se.rtl(),h=he.resizeMinHeight||f/1.5,g=he.resizeMaxHeight||2.5*f,v=he.resizeMinWidth||d/1.25,y=he.resizeMaxWidth||1.25*d,b=function(e){p&&(p=!1,Ie(n),$e(x,"resizing"),Be(tn,o,t),Be(tn,i,b),e.preventDefault())};E&&E.create&&(d=E.create("grip"))&&(Me(e,d),Ve(e,"has-icon")),Me(x,e),Me(x,n),Ie(n),Oe(e,"touchstart mousedown",function(e){l="touchstart"===e.type?(e=en.event,a=e.touches[0].pageX,e.touches[0].pageY):(a=e.pageX,e.pageY),c=Ye(x),u=Ke(x),p=!0,Ve(x,"resizing"),ze(n),Oe(tn,o,t),Oe(tn,i,b),e.preventDefault()})},F=function(){var e=he.emoticons,n=he.emoticonsRoot||"";Te(me=e?we({},e.more,e.dropdown,e.hidden):me,function(e,t){me[e]=pt("emoticon",{key:e,url:n+(t.url||t),tooltip:t.tooltip||e}),he.emoticonsEnabled&&ue.push(Ee("img",{src:n+(t.url||t)}))})},J=function(e){var t,n=f.firstChild;if(Qe(x)){if(se.sourceMode())return t=e?s.value.length:0,void s.setSelectionRange(t,t);if(at(f),e)for((n=f.lastChild)||(n=Ee("p",{},d),Me(f,n));n.lastChild;)Ue(n=n.lastChild,"br")&&n.previousSibling&&(n=n.previousSibling);t=d.createRange(),rt(n)?t.selectNodeContents(n):(t.setStartBefore(n),e&&t.setStartAfter(n)),t.collapse(!e),m.selectRange(t),y=t,e&&(f.scrollTop=f.scrollHeight),se.focus()}},se.readOnly=function(e){return"boolean"!=typeof e?!s.readonly:(f.contentEditable=!e,s.readonly=!e,G(e),se)},se.rtl=function(e){var t=e?"rtl":"ltr";return"boolean"!=typeof e?"rtl"===Fe(s,"dir"):(Fe(f,"dir",t),Fe(s,"dir",t),$e(x,"rtl"),$e(x,"ltr"),Ve(x,t),E&&E.rtl&&E.rtl(e),se)},G=function(n){var r=se.inSourceMode()?"_sceTxtMode":"_sceWysiwygMode";Te(pe,function(e,t){Ge(t,"disabled",n||!t[r])})},se.width=function(e,t){return e||0===e?(se.dimensions(e,null,t),se):Ye(x)},se.dimensions=function(e,t,n){return t=!(!t&&0!==t)&&t,!1===(e=!(!e&&0!==e)&&e)&&!1===t?{width:se.width(),height:se.height()}:(!1!==e&&(!1!==n&&(he.width=e),Ye(x,e)),!1!==t&&(!1!==n&&(he.height=t),Ke(x,t)),se)},se.height=function(e,t){return e||0===e?(se.dimensions(null,e,t),se):Ke(x)},se.maximize=function(e){var t="sceditor-maximize";return be(e)?qe(x,t):((e=!!e)&&(C=en.pageYOffset),Ge(tn.documentElement,t,e),Ge(tn.body,t,e),Ge(x,t,e),se.width(e?"100%":he.width,!1),se.height(e?"100%":he.height,!1),e||en.scrollTo(0,C),le(),se)},le=function(){he.autoExpand&&!T&&(T=setTimeout(se.expandToContent,200))},se.expandToContent=function(e){var t,n;se.maximize()||(clearTimeout(T),T=!1,k||(t=he.resizeMinHeight||he.height||Ke(o),k={min:t,max:he.resizeMaxHeight||2*t}),(n=tn.createRange()).selectNodeContents(f),t=n.getBoundingClientRect(),n=d.documentElement.clientHeight-1,t=t.bottom-t.top,n=se.height()+1+(t-n),e||-1===k.max||(n=Math.min(n,k.max)),se.height(Math.ceil(Math.max(n,k.min))))},se.destroy=function(){var e;h&&(h.destroy(),h=m=null,r&&Ae(r),Be(tn,"click",$),(e=o.form)&&(Be(e,"reset",U),Be(e,"submit",se.updateOriginal,_e)),Be(window,"pagehide",se.updateOriginal),Be(window,"pageshow",U),Ae(s),Ae(u),Ae(x),delete o._sceditor,ze(o),o.required=n)},se.createDropDown=function(e,t,n){t="sceditor-"+t,se.closeDropDown(),r&&qe(r,t)||(e=we({top:e.offsetTop,left:e.offsetLeft,marginTop:e.clientHeight},he.dropDownCss),je(r=Ee("div",{className:"sceditor-dropdown "+t}),e),Me(r,n),Me(x,r),Oe(r,"click focusin",function(e){e.stopPropagation()}),!r||(n=Re(r,"input,textarea")[0])&&n.focus())},$=function(e){3!==e.which&&r&&!e.defaultPrevented&&(ae(),se.closeDropDown())},I=function(e){var t=m.selectedRange();if(t){for(var n,r,o=Ee("div",{},d),i=t.commonAncestorContainer;i&&ot(i,!0);)i.nodeType===Ce&&(r=i.cloneNode(),o.firstChild&&Me(r,o.firstChild),Me(o,r),n=n||r),i=i.parentNode;Me(n||o,t.cloneContents()),at(o),e.clipboardData.setData("text/html",o.innerHTML),Te(Re(o,"p"),function(e,t){nt(t,"div")}),Te(Re(o,"br"),function(e,t){t.nextSibling&&ot(t.nextSibling,!0)||Ae(t)}),Me(f,o),e.clipboardData.setData("text/plain",o.innerText),Ae(o),"cut"===e.type&&t.deleteContents(),e.preventDefault()}},H=function(e){var t,n,r=f,o=e.clipboardData;if(o){var i={},a=o.types,l=o.items;e.preventDefault();for(var s=0;s<a.length;s++){if(a.indexOf("text/html")<0&&en.FileReader&&l&&nn.test(l[s].type))return t=o.items[s].getAsFile(),n=void 0,(n=new FileReader).onload=function(e){z({html:'<img src="'+e.target.result+'" />'})},void n.readAsDataURL(t);i[a[s]]=o.getData(a[s])}i.text=i["text/plain"],i.html=ve(i["text/html"]),z(i)}else if(!S){var c=r.scrollTop;for(m.saveRange(),S=tn.createDocumentFragment();r.firstChild;)Me(S,r.firstChild);setTimeout(function(){var e=r.innerHTML;r.innerHTML="",Me(r,S),r.scrollTop=c,S=!1,m.restoreRange(),z({html:ve(e)})},0)}},z=function(e){var t=Ee("div",{},d);h.call("pasteRaw",e),Xe(x,"pasteraw",e),e.html?(t.innerHTML=ve(e.html),it(t)):t.innerHTML=ft(e.text||""),e={val:t.innerHTML},"fragmentToSource"in a&&(e.val=a.fragmentToSource(e.val,d,g)),h.call("paste",e),Xe(x,"paste",e),"fragmentToHtml"in a&&(e.val=a.fragmentToHtml(e.val,g)),h.call("pasteHtml",e),t=m.getFirstBlockParent(),se.wysiwygEditorInsertHtml(e.val,null,!0),function e(t){if(t.nodeType===Ce){for(var n=t.parentNode,r=t.tagName,o=t.childNodes.length;o--;)e(t.childNodes[o]);if(ot(t)){for(o=t.style.length;o--;){var i=t.style[o];je(n,i)===je(t,i)&&t.style.removeProperty(i)}if(!t.style.length)if(He(t,"style"),"FONT"===r&&(je(t,"fontFamily").toLowerCase()===je(n,"fontFamily").toLowerCase()&&He(t,"face"),je(t,"color")===je(n,"color")&&He(t,"color"),je(t,"fontSize")===je(n,"fontSize")&&He(t,"size")),!t.attributes.length&&/SPAN|FONT/.test(r))ct(t);else if(/B|STRONG|EM|SPAN|FONT/.test(r))for(var a=/B|STRONG/.test(r),l="EM"===r;n&&ot(n)&&(!a||/bold|700/i.test(je(n,"fontWeight")))&&(!l||"italic"===je(n,"fontStyle"));){if((n.tagName===r||a&&/B|STRONG/.test(n.tagName))&&st(n,t)){ct(t);break}n=n.parentNode}var s=t.nextSibling;s&&s.tagName===r&&st(s,t)&&(Me(t,s),ct(s))}}}(t)},se.closeDropDown=function(e){r&&(Ae(r),r=null),!0===e&&se.focus()},se.wysiwygEditorInsertHtml=function(e,t,n){var r=Ke(i);se.focus(),!n&&Ne(v,"code")||(m.insertHTML(e,t),m.saveRange(),D(),it(f),ze(n=Re(f,"#sceditor-end-marker")[0]),e=f.scrollTop,t=lt(n).top+1.5*n.offsetHeight-r,Ie(n),(e<t||t+r<e)&&(f.scrollTop=t),re(!1),m.restoreRange(),X())},se.wysiwygEditorInsertText=function(e,t){se.wysiwygEditorInsertHtml(ft(e),ft(t))},se.insertText=function(e,t){return se.inSourceMode()?se.sourceEditorInsertText(e,t):se.wysiwygEditorInsertText(e,t),se},se.sourceEditorInsertText=function(e,t){var n,r=s.selectionStart,o=s.selectionEnd,i=s.scrollTop;s.focus(),n=s.value,t&&(e+=n.substring(r,o)+t),s.value=n.substring(0,r)+e+n.substring(o,n.length),s.selectionStart=r+e.length-(t?t.length:0),s.selectionEnd=s.selectionStart,s.scrollTop=i,s.focus(),re()},se.getRangeHelper=function(){return m},se.sourceEditorCaret=function(e){return s.focus(),e?(s.selectionStart=e.start,s.selectionEnd=e.end,this):{start:s.selectionStart,end:s.selectionEnd}},se.val=function(e,t){return ye(e)?(se.inSourceMode()?se.setSourceEditorValue(e):(!1!==t&&"toHtml"in a&&(e=a.toHtml(e)),se.setWysiwygEditorValue(e)),se):se.inSourceMode()?se.getSourceEditorValue(!1):se.getWysiwygEditorValue(t)},se.insert=function(e,t,n,r,o){return se.inSourceMode()?se.sourceEditorInsertText(e,t):(t&&(i=m.selectedHtml(),e+=(i=!1!==n&&"fragmentToSource"in a?a.fragmentToSource(i,d,g):i)+t),!1!==n&&"fragmentToHtml"in a&&(e=a.fragmentToHtml(e,g)),!1!==n&&!0===o&&(e=e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")),se.wysiwygEditorInsertHtml(e)),se;var i},se.getWysiwygEditorValue=function(e){for(var t,n=Ee("div",{},d),r=f.childNodes,o=0;o<r.length;o++)Me(n,r[o].cloneNode(!0));return Me(f,n),it(n),Ae(n),t=n.innerHTML,!1!==e&&a.hasOwnProperty("toSource")?a.toSource(t,d):t},se.getBody=function(){return f},se.getContentAreaContainer=function(){return i},se.getSourceEditorValue=function(e){var t=s.value;return!1!==e&&"toHtml"in a?a.toHtml(t):t},se.setWysiwygEditorValue=function(e){e=e||"<p><br /></p>",f.innerHTML=ve(e),D(),X(),re(),le()},se.setSourceEditorValue=function(e){s.value=e,re()},se.updateOriginal=function(){o.value=se.val()},D=function(){var e,l,s,c,t,u,d;he.emoticonsEnabled&&(e=f,l=me,s=he.emoticonsCompat,c=e.ownerDocument,t="(^|\\s| | | | |$)",u=[],d={},De(e,"code")||(Te(l,function(e){d[e]=new RegExp(t+dt(e)+t),u.push(e)}),u.sort(function(e,t){return t.length-e.length}),function e(t){for(t=t.firstChild;t;){if(t.nodeType!==Ce||Ue(t,"code")||e(t),t.nodeType===Se)for(var n=0;n<u.length;n++){var r,o=t.nodeValue,i=u[n],a=s?o.search(d[i]):o.indexOf(i);-1<a&&(r=o.indexOf(i,a),a=et(l[i],c),i=o.substr(r+i.length),a.appendChild(c.createTextNode(i)),t.nodeValue=o.substr(0,r),t.parentNode.insertBefore(a,t.nextSibling))}t=t.nextSibling}}(e)))},se.inSourceMode=function(){return qe(x,"sourceMode")},se.sourceMode=function(e){var t=se.inSourceMode();return"boolean"!=typeof e?t:((t&&!e||!t&&e)&&se.toggleSourceMode(),se)},se.toggleSourceMode=function(){var e=se.inSourceMode();!yt&&e||(e||(m.saveRange(),m.clear()),y=null,se.blur(),e?se.setWysiwygEditorValue(se.getSourceEditorValue()):se.setSourceEditorValue(se.getWysiwygEditorValue()),Le(s),Le(i),Ge(x,"wysiwygMode",e),Ge(x,"sourceMode",!e),G(),Y())},K=function(){return s.focus(),s.value.substring(s.selectionStart,s.selectionEnd)},N=function(e,t){se.inSourceMode()?t.txtExec&&(Array.isArray(t.txtExec)?se.sourceEditorInsertText.apply(se,t.txtExec):t.txtExec.call(se,e,K())):t.exec&&(xe(t.exec)?t.exec.call(se,e):se.execCommand(t.exec,t.hasOwnProperty("execParam")?t.execParam:null))},se.execCommand=function(e,t){var n=!1,r=se.commands[e];if(se.focus(),!Ne(m.parentNode(),"code")){try{n=d.execCommand(e,!1,t)}catch(e){}!n&&r&&r.errorMessage&&alert(se._(r.errorMessage)),Y()}},Q=function(){function e(){if(l.getSelection()&&l.getSelection().rangeCount<=0)y=null;else if(m&&!m.compare(y)){if((y=m.cloneSelected())&&y.collapsed){var e=y.startContainer,t=y.startOffset;for(t&&e.nodeType!==Se&&(e=e.childNodes[t]);e&&e.parentNode!==f;)e=e.parentNode;e&&ot(e,!0)&&(m.saveRange(),n=d,Ze(f,function(e){ot(e,!0)?(r||e.nodeType===Se?/\S/.test(e.nodeValue):!Ue(e,".sceditor-ignore"))&&(r||We(r=Ee("p",{},n),e),Me(r,e)):r=null},!1,!0),m.restoreRange())}Xe(x,"selectionchanged")}var n,r;b=!1}b||(b=!0,"onselectionchange"in d?e():setTimeout(e,100))},Z=function(){var e,t=m.parentNode();g!==t&&(e=g,g=t,v=m.getFirstBlockParent(t),Xe(x,"nodechanged",{oldNode:e,newNode:g}))},se.currentNode=function(){return g},se.currentBlockNode=function(){return v},Y=function(){var e,t,n="active",r=d,o=se.sourceMode();if(se.readOnly())Te(Re(u,n),function(e,t){$e(t,n)});else{o||(t=m.parentNode(),e=m.getFirstBlockParent(t));for(var i=0;i<de.length;i++){var a=0,l=pe[de[i].name],s=de[i].state,c=o&&!l._sceTxtMode||!o&&!l._sceWysiwygMode;if(ye(s)){if(!o)try{-1<(a=r.queryCommandEnabled(s)?0:-1)&&(a=r.queryCommandState(s)?1:0)}catch(e){}}else c||(a=s.call(se,t,e));Ge(l,"disabled",c||a<0),Ge(l,n,0<a)}E&&E.update&&E.update(o,t,e)}},P=function(e){var t,n,r;e.defaultPrevented||(se.closeDropDown(),13!==e.which||!Ue(v,"li,ul,ol")&&tt(v)&&(t=Ee("br",{},d),m.insertNode(t),(r=(n=t.parentNode).lastChild)&&r.nodeType===Se&&""===r.nodeValue&&(Ae(r),r=n.lastChild),!ot(n,!0)&&r===t&&ot(t.previousSibling)&&m.insertHTML("<br>"),e.preventDefault()))},X=function(){Je(f,function(e){if(e.nodeType===Ce&&!/inline/.test(je(e,"display"))&&!Ue(e,".sceditor-nlf")&&tt(e)){var t=Ee("p",{},d);return t.className="sceditor-nlf",t.innerHTML="<br />",Me(f,t),!1}if(3===e.nodeType&&!/^\s*$/.test(e.nodeValue)||Ue(e,"br"))return!1})},U=function(){se.val(o.value)},W=function(){se.closeDropDown()},se._=function(){var n=arguments;return t&&t[n[0]]&&(n[0]=t[n[0]]),n[0].replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[+t+1]?n[+t+1]:"{"+t+"}"})},V=function(t){h&&h.call(t.type+"Event",t,se);var e=(t.target===s?"scesrc":"scewys")+t.type;ce[e]&&ce[e].forEach(function(e){e.call(se,t)})},se.bind=function(e,t,n,r){for(var o,i,a=(e=e.split(" ")).length;a--;)xe(t)&&(o="scewys"+e[a],i="scesrc"+e[a],n||(ce[o]=ce[o]||[],ce[o].push(t)),r||(ce[i]=ce[i]||[],ce[i].push(t)),"valuechanged"===e[a]&&(re.hasHandler=!0));return se},se.unbind=function(e,t,n,r){for(var o=(e=e.split(" ")).length;o--;)xe(t)&&(n||ke(ce["scewys"+e[o]]||[],t),r||ke(ce["scesrc"+e[o]]||[],t));return se},se.blur=function(e,t,n){return xe(e)?se.bind("blur",e,t,n):(se.sourceMode()?s:f).blur(),se},se.focus=function(e,t,n){if(xe(e))se.bind("focus",e,t,n);else if(se.inSourceMode())s.focus();else{if(Re(d,":focus").length)return;var r,n=m.selectedRange();y||J(!0),n&&1===n.endOffset&&n.collapsed&&(r=n.endContainer)&&1===r.childNodes.length&&Ue(r.firstChild,"br")&&(n.setStartBefore(r.firstChild),n.collapse(!0),m.selectRange(n)),l.focus(),f.focus()}return Y(),se},se.keyDown=function(e,t,n){return se.bind("keydown",e,t,n)},se.keyPress=function(e,t,n){return se.bind("keypress",e,t,n)},se.keyUp=function(e,t,n){return se.bind("keyup",e,t,n)},se.nodeChanged=function(e){return se.bind("nodechanged",e,!1,!0)},se.selectionChanged=function(e){return se.bind("selectionchanged",e,!1,!0)},se.valueChanged=function(e,t,n){return se.bind("valuechanged",e,t,n)},ee=function(e){var n=0,r=se.emoticonsCache,t=String.fromCharCode(e.which);Ne(v,"code")||(r||(r=[],Te(me,function(e,t){r[n++]=[e,t]}),r.sort(function(e,t){return e[0].length-t[0].length}),se.emoticonsCache=r,se.longestEmoticonCode=r[r.length-1][0].length),m.replaceKeyword(se.emoticonsCache,!0,!0,se.longestEmoticonCode,he.emoticonsCompat,t)&&(he.emoticonsCompat&&/^\s$/.test(t)||e.preventDefault()))},te=function(){!function(e,t){var n=/[^\s\xA0\u2002\u2003\u2009]+/,r=e&&Re(e,"img[data-sceditor-emoticon]");if(e&&r.length)for(var o=0;o<r.length;o++){var i,a,l,s,c=r[o],u=c.parentNode,d=c.previousSibling,f=c.nextSibling;(d&&n.test(d.nodeValue.slice(-1))||f&&n.test((f.nodeValue||"")[0]))&&(a=-1,l=(i=t.cloneSelected()).startContainer,s=d.nodeValue||"",s+=Pe(c,"sceditor-emoticon"),l===f&&(a=s.length+i.startOffset),l===e&&e.childNodes[i.startOffset]===f&&(a=s.length),l===d&&(a=i.startOffset),(f=f&&f.nodeType===Se?f:u.insertBefore(u.ownerDocument.createTextNode(""),f)).insertData(0,s),Ae(d),Ae(c),-1<a&&(i.setStart(f,a),i.collapse(!0),t.selectRange(i)))}}(v,m)},se.emoticons=function(e){return e||!1===e?((he.emoticonsEnabled=e)?(Oe(f,"keypress",ee),se.sourceMode()||(m.saveRange(),D(),re(!1),m.restoreRange())):(Te(Re(f,"img[data-sceditor-emoticon]"),function(e,t){var n=Pe(t,"sceditor-emoticon"),n=d.createTextNode(n);t.parentNode.replaceChild(n,t)}),Be(f,"keypress",ee),re()),se):he.emoticonsEnabled},se.css=function(e){return w||(w=Ee("style",{id:"inline"},d),Me(d.head,w)),ye(e)?(w.styleSheet?w.styleSheet.cssText=e:w.innerHTML=e,se):w.styleSheet?w.styleSheet.cssText:w.innerHTML},L=function(e){var t=[],n={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|","[":"{","]":"}"},r={109:"-",110:"del",111:"/",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},o=e.which,i={8:"backspace",9:"tab",13:"enter",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"win",92:"win",93:"select",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}[o]||String.fromCharCode(o).toLowerCase();(e.ctrlKey||e.metaKey)&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&(t.push("shift"),r[o]?i=r[o]:n[i]&&(i=n[i])),i&&(o<16||18<o)&&t.push(i),t=t.join("+"),fe[t]&&!1===fe[t].call(se)&&(e.stopPropagation(),e.preventDefault())},se.addShortcut=function(e,t){return e=e.toLowerCase(),ye(t)?fe[e]=function(){return N(pe[t],se.commands[t]),!1}:fe[e]=t,se},se.removeShortcut=function(e){return delete fe[e.toLowerCase()],se},j=function(e){var t,n,r;if(!he.disableBlockRemove&&8===e.which&&(n=m.selectedRange())&&(t=n.startContainer,0===n.startOffset&&(r=ne())&&!Ue(r,"body"))){for(;t!==r;){for(;t.previousSibling;)if((t=t.previousSibling).nodeType!==Se||t.nodeValue)return;if(!(t=t.parentNode))return}se.clearBlockFormatting(r),e.preventDefault()}},ne=function(){for(var e=v;!tt(e)||ot(e,!0);)if(!(e=e.parentNode)||Ue(e,"body"))return;return e},se.clearBlockFormatting=function(e){return!(e=e||ne())||Ue(e,"body")||(m.saveRange(),e.className="",Fe(e,"style",""),Ue(e,"p,div,td")||nt(e,"p"),m.restoreRange()),se},re=function(e){var t,n,r;h&&(h.hasHandler("valuechangedEvent")||re.hasHandler)&&(r=!(n=se.sourceMode())&&m.hasSelection(),e=(c=!1)!==e&&!d.getElementById("sceditor-start-marker"),p&&(clearTimeout(p),p=!1),r&&e&&m.saveRange(),(t=n?s.value:f.innerHTML)!==re.lastVal&&(re.lastVal=t,Xe(x,"valuechanged",{rawValue:n?se.val():t})),r&&e&&m.removeMarkers())},oe=function(){p&&re()},ie=function(e){var t=e.which,e=13===(n=ie.lastChar)||32===n,n=8===n||46===n;ie.lastChar=t,c||(13===t||32===t?e?ie.triggerNext=!0:re():8===t||46===t?n?ie.triggerNext=!0:re():ie.triggerNext&&(re(),ie.triggerNext=!1),clearTimeout(p),p=setTimeout(function(){c||re()},1500))},q=function(e){(c=/start/i.test(e.type))||re()},ae=function(){se.updateOriginal()},e()}rn.locale={},rn.formats={},rn.icons={},rn.command={get:function(e){return mt[e]||null},set:function(e,t){return!(!e||!t)&&((t=we(mt[e]||{},t)).remove=function(){rn.command.remove(e)},mt[e]=t,this)},remove:function(e){return mt[e]&&delete mt[e],this}},window.sceditor={command:rn.command,commands:mt,defaultOptions:ut,ios:vt,isWysiwygSupported:yt,regexEscape:dt,escapeEntities:ft,escapeUriScheme:function(e){var t,n=window.location;return e&&/^[^\/]*:/i.test(e)&&!m.test(e)?((t=n.pathname.split("/")).pop(),n.protocol+"//"+n.host+t.join("/")+"/"+e):e},dom:{css:je,attr:Fe,removeAttr:He,is:Ue,closest:Ne,width:Ye,height:Ke,traverse:Ze,rTraverse:Je,parseHTML:et,hasStyling:tt,convertElement:nt,blockLevelList:c,canHaveChildren:rt,isInline:ot,copyCSS:function(e,t){t.style&&e.style&&(t.style.cssText=e.style.cssText+t.style.cssText)},fixNesting:it,findCommonAncestor:function(e,t){for(;e=e.parentNode;)if(e!==t&&e.contains&&e.contains(t))return e},getSibling:u,removeWhiteSpace:at,extractContents:f,getOffset:lt,getStyle:p,hasStyle:function(e,t,n){return!!(t=p(e,t))&&(!n||t===n||Array.isArray(n)&&-1<n.indexOf(t))}},locale:rn.locale,icons:rn.icons,utils:{each:Te,isEmptyObject:t,extend:we},plugins:ht.plugins,formats:rn.formats,create:function(e,t){t=t||{},De(e,".sceditor-container")||(t.runWithoutWysiwygSupport||yt)&&new rn(e,t)},instance:function(e){return e._sceditor}},r.default.sceditor=window.sceditor,r.default.fn.sceditor=function(e){var t,n=[];return this.each(function(){t=this._sceditor,"state"===e?n.push(!!t):"instance"===e?n.push(t):t||r.default.sceditor.create(this,e)}),n.length?1===n.length?n[0]:n:this}}(),function(e){"use strict";var d=e.escapeEntities,a=e.escapeUriScheme,f=e.dom,t=e.utils,p=f.css,m=f.attr,h=f.is,n=t.extend,g=t.each,v="data-sceditor-emoticon",i=e.command.get,y={always:1,never:2,auto:3},r={bold:{txtExec:["[b]","[/b]"]},italic:{txtExec:["[i]","[/i]"]},underline:{txtExec:["[u]","[/u]"]},strike:{txtExec:["[s]","[/s]"]},subscript:{txtExec:["[sub]","[/sub]"]},superscript:{txtExec:["[sup]","[/sup]"]},left:{txtExec:["[left]","[/left]"]},center:{txtExec:["[center]","[/center]"]},right:{txtExec:["[right]","[/right]"]},justify:{txtExec:["[justify]","[/justify]"]},font:{txtExec:function(e){var t=this;i("font")._dropDown(t,e,function(e){t.insertText("[font="+e+"]","[/font]")})}},size:{txtExec:function(e){var t=this;i("size")._dropDown(t,e,function(e){t.insertText("[size="+e+"]","[/size]")})}},color:{txtExec:function(e){var t=this;i("color")._dropDown(t,e,function(e){t.insertText("[color="+e+"]","[/color]")})}},bulletlist:{txtExec:function(e,t){this.insertText("[ul]\n[li]"+t.split(/\r?\n/).join("[/li]\n[li]")+"[/li]\n[/ul]")}},orderedlist:{txtExec:function(e,t){this.insertText("[ol]\n[li]"+t.split(/\r?\n/).join("[/li]\n[li]")+"[/li]\n[/ol]")}},table:{txtExec:["[table][tr][td]","[/td][/tr][/table]"]},horizontalrule:{txtExec:["[hr]"]},code:{txtExec:["[code]","[/code]"]},image:{txtExec:function(e,t){var o=this;i("image")._dropDown(o,e,t,function(e,t,n){var r="";t&&(r+=" width="+t),n&&(r+=" height="+n),o.insertText("[img"+r+"]"+e+"[/img]")})}},email:{txtExec:function(e,n){var r=this;i("email")._dropDown(r,e,function(e,t){r.insertText("[email="+e+"]"+(t||n||e)+"[/email]")})}},link:{txtExec:function(e,n){var r=this;i("link")._dropDown(r,e,function(e,t){r.insertText("[url="+e+"]"+(t||n||e)+"[/url]")})}},quote:{txtExec:["[quote]","[/quote]"]},youtube:{txtExec:function(e){var t=this;i("youtube")._dropDown(t,e,function(e){t.insertText("[youtube]"+e+"[/youtube]")})}},rtl:{txtExec:["[rtl]","[/rtl]"]},ltr:{txtExec:["[ltr]","[/ltr]"]}},b={b:{tags:{b:null,strong:null},styles:{"font-weight":["bold","bolder","401","700","800","900"]},format:"[b]{0}[/b]",html:"<strong>{0}</strong>"},i:{tags:{i:null,em:null},styles:{"font-style":["italic","oblique"]},format:"[i]{0}[/i]",html:"<em>{0}</em>"},u:{tags:{u:null},styles:{"text-decoration":["underline"]},format:"[u]{0}[/u]",html:"<u>{0}</u>"},s:{tags:{s:null,strike:null},styles:{"text-decoration":["line-through"]},format:"[s]{0}[/s]",html:"<s>{0}</s>"},sub:{tags:{sub:null},format:"[sub]{0}[/sub]",html:"<sub>{0}</sub>"},sup:{tags:{sup:null},format:"[sup]{0}[/sup]",html:"<sup>{0}</sup>"},font:{tags:{font:{face:null}},styles:{"font-family":null},quoteType:y.never,format:function(e,t){var n;return"[font="+k(n=!h(e,"font")||!(n=m(e,"face"))?p(e,"font-family"):n)+"]"+t+"[/font]"},html:'<font face="{defaultattr}">{0}</font>'},size:{tags:{font:{size:null}},styles:{"font-size":null},format:function(e,t){var n=m(e,"size"),r=2;return-1<(n=n||p(e,"fontSize")).indexOf("px")?((n=+n.replace("px",""))<12&&(r=1),15<n&&(r=3),17<n&&(r=4),23<n&&(r=5),31<n&&(r=6),47<n&&(r=7)):r=n,"[size="+r+"]"+t+"[/size]"},html:'<font size="{defaultattr}">{!0}</font>'},color:{tags:{font:{color:null}},styles:{color:null},quoteType:y.never,format:function(e,t){var n;return"[color="+s(n=!h(e,"font")||!(n=m(e,"color"))?e.style.color||p(e,"color"):n)+"]"+t+"[/color]"},html:function(e,t,n){return'<font color="'+d(s(t.defaultattr),!0)+'">'+n+"</font>"}},ul:{tags:{ul:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ul]{0}[/ul]",html:"<ul>{0}</ul>"},list:{breakStart:!0,isInline:!1,skipLastLineBreak:!0,html:"<ul>{0}</ul>"},ol:{tags:{ol:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ol]{0}[/ol]",html:"<ol>{0}</ol>"},li:{tags:{li:null},isInline:!1,closedBy:["/ul","/ol","/list","*","li"],format:"[li]{0}[/li]",html:"<li>{0}</li>"},"*":{isInline:!1,closedBy:["/ul","/ol","/list","*","li"],html:"<li>{0}</li>"},table:{tags:{table:null},isInline:!1,isHtmlInline:!0,skipLastLineBreak:!0,format:"[table]{0}[/table]",html:"<table>{0}</table>"},tr:{tags:{tr:null},isInline:!1,skipLastLineBreak:!0,format:"[tr]{0}[/tr]",html:"<tr>{0}</tr>"},th:{tags:{th:null},allowsEmpty:!0,isInline:!1,format:"[th]{0}[/th]",html:"<th>{0}</th>"},td:{tags:{td:null},allowsEmpty:!0,isInline:!1,format:"[td]{0}[/td]",html:"<td>{0}</td>"},emoticon:{allowsEmpty:!0,tags:{img:{src:null,"data-sceditor-emoticon":null}},format:function(e,t){return m(e,v)+t},html:"{0}"},hr:{tags:{hr:null},allowsEmpty:!0,isSelfClosing:!0,isInline:!1,format:"[hr]{0}",html:"<hr />"},img:{allowsEmpty:!0,tags:{img:{src:null}},allowedChildren:["#"],quoteType:y.never,format:function(t,e){var n="",r=function(e){return t.style?t.style[e]:null};return m(t,v)?e:(e=m(t,"width")||r("width"),r=m(t,"height")||r("height"),"[img"+(n=t.complete&&(e||r)||e&&r?"="+f.width(t)+"x"+f.height(t):n)+"]"+m(t,"src")+"[/img]")},html:function(e,t,n){var r="",o=t.width,i=t.height;return t.defaultattr&&(o=(t=t.defaultattr.split(/x/i))[0],i=2===t.length?t[1]:t[0]),void 0!==o&&(r+=' width="'+d(o,!0)+'"'),void 0!==i&&(r+=' height="'+d(i,!0)+'"'),"<img"+r+' src="'+a(n)+'" />'}},url:{allowsEmpty:!0,tags:{a:{href:null}},quoteType:y.never,format:function(e,t){e=m(e,"href");return"mailto:"===e.substr(0,7)?'[email="'+e.substr(7)+'"]'+t+"[/email]":"[url="+e+"]"+t+"[/url]"},html:function(e,t,n){return t.defaultattr=d(t.defaultattr,!0)||n,'<a href="'+a(t.defaultattr)+'">'+n+"</a>"}},email:{quoteType:y.never,html:function(e,t,n){return'<a href="mailto:'+(d(t.defaultattr,!0)||n)+'">'+n+"</a>"}},quote:{tags:{blockquote:null},isInline:!1,quoteType:y.never,format:function(e,t){for(var n,r="data-author",o="",i=e.children,a=0;!n&&a<i.length;a++)h(i[a],"cite")&&(n=i[a]);return(n||m(e,r))&&(o=n&&n.textContent||m(e,r),m(e,r,o),n&&e.removeChild(n),t=this.elementToBbcode(e),o="="+o.replace(/(^\s+|\s+$)/g,""),n&&e.insertBefore(n,e.firstChild)),"[quote"+o+"]"+t+"[/quote]"},html:function(e,t,n){return"<blockquote>"+(n=t.defaultattr?"<cite>"+d(t.defaultattr)+"</cite>"+n:n)+"</blockquote>"}},code:{tags:{code:null},isInline:!1,allowedChildren:["#","#newline"],format:"[code]{0}[/code]",html:"<code>{0}</code>"},left:{styles:{"text-align":["left","-webkit-left","-moz-left","-khtml-left"]},isInline:!1,allowsEmpty:!0,format:"[left]{0}[/left]",html:'<div align="left">{0}</div>'},center:{styles:{"text-align":["center","-webkit-center","-moz-center","-khtml-center"]},isInline:!1,allowsEmpty:!0,format:"[center]{0}[/center]",html:'<div align="center">{0}</div>'},right:{styles:{"text-align":["right","-webkit-right","-moz-right","-khtml-right"]},isInline:!1,allowsEmpty:!0,format:"[right]{0}[/right]",html:'<div align="right">{0}</div>'},justify:{styles:{"text-align":["justify","-webkit-justify","-moz-justify","-khtml-justify"]},isInline:!1,allowsEmpty:!0,format:"[justify]{0}[/justify]",html:'<div align="justify">{0}</div>'},youtube:{allowsEmpty:!0,tags:{iframe:{"data-youtube-id":null}},format:function(e,t){return(e=m(e,"data-youtube-id"))?"[youtube]"+e+"[/youtube]":t},html:'<iframe width="560" height="315" frameborder="0" src="https://www.youtube-nocookie.com/embed/{0}?wmode=opaque" data-youtube-id="{0}" allowfullscreen></iframe>'},rtl:{styles:{direction:["rtl"]},isInline:!1,format:"[rtl]{0}[/rtl]",html:'<div style="direction: rtl">{0}</div>'},ltr:{styles:{direction:["ltr"]},isInline:!1,format:"[ltr]{0}[/ltr]",html:'<div style="direction: ltr">{0}</div>'},ignore:{}};function x(e,r){return e.replace(/\{([^}]+)\}/g,function(e,t){var n=!0;return"!"===t.charAt(0)&&(n=!1,t=t.substring(1)),"0"===t&&(n=!1),void 0===r[t]?e:n?d(r[t],!0):r[t]})}function w(e){return"function"==typeof e}function k(e){return e&&e.replace(/\\(.)/g,"$1").replace(/^(["'])(.*?)\1$/,"$2")}var T="open",C="content",S="newline",E="close";function l(e,t,n,r,o,i){var a=this;a.type=e,a.name=t,a.val=n,a.attrs=r||{},a.children=o||[],a.closing=i||null}function D(e){var m=this;function a(e,t){var n,r,o;return e===T&&(n=t.match(/\[([^\]\s=]+)(?:([^\]]+))?\]/))&&(o=i(n[1]),n[2]&&(n[2]=n[2].trim())&&(r=function(e){var t,n=/([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g,r={};if("="===e.charAt(0)&&e.indexOf("=",1)<0)r.defaultattr=k(e.substr(1));else for("="===e.charAt(0)&&(e="defaultattr"+e);t=n.exec(e);)r[i(t[1])]=k(t[3])||t[4];return r}(n[2]))),e===E&&(n=t.match(/\[\/([^\[\]]+)\]/))&&(o=i(n[1])),(o=e===S?"#newline":o)&&(e!==T&&e!==E||b[o])||(e=C,o="#"),new l(e,o,t,r)}function f(e,t,n){for(var r=n.length;r--;)if(n[r].type===t&&n[r].name===e)return 1}function p(e,t){e=(e?b[e.name]:{}).allowedChildren;return!m.opts.fixInvalidChildren||!e||-1<e.indexOf(t.name||"#")}function h(e,t,n){var r=/\s|=/.test(e);return w(t)?t(e,n):t===y.never||t===y.auto&&!r?e:'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}function g(e){return e.length?e[e.length-1]:null}function i(e){return e.toLowerCase()}m.opts=n({},D.defaults,e),m.tokenize=function(e){var t,n,r,o=[],i=[{type:C,regex:/^([^\[\r\n]+|\[)/},{type:S,regex:/^(\r\n|\r|\n)/},{type:T,regex:/^\[[^\[\]]+\]/},{type:E,regex:/^\[\/[^\[\]]+\]/}];e:for(;e.length;){for(r=i.length;r--;)if(n=i[r].type,(t=e.match(i[r].regex))&&t[0]){o.push(a(n,t[0])),e=e.substr(t[0].length);continue e}e.length&&o.push(a(C,e)),e=""}return o},m.parse=function(e,t){var n=function(e){function t(){return g(d)}function n(e){(t()?t().children:u).push(e)}function r(e){return t()&&(i=b[t().name])&&i.closedBy&&-1<i.closedBy.indexOf(e)}var o,i,a,l,s,c=[],u=[],d=[];for(;o=e.shift();)switch(s=e[0],p(t(),o)||o.type===E&&t()&&o.name===t().name||(o.name="#",o.type=C),o.type){case T:r(o.name)&&d.pop(),n(o),(i=b[o.name])&&!i.isSelfClosing&&(i.closedBy||f(o.name,E,e))?d.push(o):i&&i.isSelfClosing||(o.type=C);break;case E:if(t()&&o.name!==t().name&&r("/"+o.name)&&d.pop(),t()&&o.name===t().name)t().closing=o,d.pop();else if(f(o.name,T,d)){for(;a=d.pop();){if(a.name===o.name){a.closing=o;break}a=a.clone(),c.length&&a.children.push(g(c)),c.push(a)}for(s&&s.type===S&&(i=b[o.name])&&!1===i.isInline&&(n(s),e.shift()),n(g(c)),l=c.length;l--;)d.push(c[l]);c.length=0}else o.type=C,n(o);break;case S:t()&&s&&r((s.type===E?"/":"")+s.name)&&(s.type===E&&s.name===t().name||((i=b[t().name])&&i.breakAfter||i&&!1===i.isInline&&m.opts.breakAfterBlock&&!1!==i.breakAfter)&&d.pop()),n(o);break;default:n(o)}return u}(m.tokenize(e)),e=m.opts;return e.fixInvalidNesting&&function e(t,n,r,o){var i,a,l,s;var c=function(e){var e=b[e.name];return!e||!1!==e.isInline};n=n||[];o=o||t;for(a=0;a<t.length;a++)if((i=t[a])&&i.type===T){var u;if(r&&!c(i))if(d=g(n),s=d.splitAt(i),l=1<n.length?n[n.length-2].children:o,p(i,d)&&((u=d.clone()).children=i.children,i.children=[u]),-1<(u=l.indexOf(d))){s.children.splice(0,1),l.splice(u+1,0,i,s);var d=s.children[0];return void(d&&d.type===S&&(c(i)||(s.children.splice(0,1),l.splice(u+2,0,d))))}n.push(i),e(i.children,n,r||c(i),o),n.pop()}}(n),function e(t,n,r){var o,i,a,l,s,c,u,d;var f=t.length;n&&(l=b[n.name]);var p=f;for(;p--;)(o=t[p])&&(o.type===S?(i=0<p?t[p-1]:null,a=p<f-1?t[p+1]:null,d=!1,!r&&l&&!0!==l.isSelfClosing&&(i?c||a||(!1===l.isInline&&m.opts.breakEndBlock&&!1!==l.breakEnd&&(d=!0),l.breakEnd&&(d=!0),c=d):(!1===l.isInline&&m.opts.breakStartBlock&&!1!==l.breakStart&&(d=!0),l.breakStart&&(d=!0))),i&&i.type===T&&(s=b[i.name])&&(r?!1===s.isInline&&(d=!0):(!1===s.isInline&&m.opts.breakAfterBlock&&!1!==s.breakAfter&&(d=!0),s.breakAfter&&(d=!0))),!r&&!u&&a&&a.type===T&&(s=b[a.name])&&(!1===s.isInline&&m.opts.breakBeforeBlock&&!1!==s.breakBefore&&(d=!0),s.breakBefore&&(d=!0),u=d)?t.splice(p,1):(d&&t.splice(p,1),u=!1)):o.type===T&&e(o.children,o,r))}(n,null,t),e.removeEmptyTags&&function e(t){var n,r;var o=function(e){for(var t=e.length;t--;){var n=e[t].type;if(n===T||n===E)return!1;if(n===C&&/\S|\u00A0/.test(e[t].val))return!1}return!0};var i=t.length;for(;i--;)(n=t[i])&&n.type===T&&(r=b[n.name],e(n.children),o(n.children)&&r&&!r.isSelfClosing&&!r.allowsEmpty&&t.splice.apply(t,[i,1].concat(n.children)))}(n),n},m.toHTML=function(e,t){return function e(t,n){var r,o,i,a,l,s,c,u="";s=function(e){return!1!==(!e||(void 0!==e.isHtmlInline?e.isHtmlInline:e.isInline))};for(;0<t.length;)if(r=t.shift()){if(r.type===T)c=r.children[r.children.length-1]||{},o=b[r.name],a=n&&s(o),i=e(r.children,!1),i=o&&o.html?(s(o)||!s(b[c.name])||o.isPreFormatted||o.skipLastLineBreak||(i+="<br />"),w(o.html)?o.html.call(m,r,r.attrs,i):(r.attrs[0]=i,x(o.html,r.attrs))):r.val+i+(r.closing?r.closing.val:"");else{if(r.type===S){if(!n){u+="<br />";continue}l||(u+="<div>"),u+="<br />",t.length||(u+="<br />"),u+="</div>\n",l=!1;continue}a=n,i=d(r.val,!0)}a&&!l?(u+="<div>",l=!0):!a&&l&&(u+="</div>\n",l=!1),u+=i}l&&(u+="</div>\n");return u}(m.parse(e,t),!0)},m.toBBCode=function(e,t){return function e(t){var n,r,o,i,a,l,s,c,u,d="";for(;0<t.length;)if(n=t.shift())if(o=b[n.name],u=!(!o||!1!==o.isInline),i=o&&o.isSelfClosing,l=u&&m.opts.breakBeforeBlock&&!1!==o.breakBefore||o&&o.breakBefore,s=u&&!i&&m.opts.breakStartBlock&&!1!==o.breakStart||o&&o.breakStart,c=u&&m.opts.breakEndBlock&&!1!==o.breakEnd||o&&o.breakEnd,u=u&&m.opts.breakAfterBlock&&!1!==o.breakAfter||o&&o.breakAfter,a=(o?o.quoteType:null)||m.opts.quoteType||y.auto,o||n.type!==T)if(n.type===T){if(l&&(d+="\n"),d+="["+n.name,n.attrs)for(r in n.attrs.defaultattr&&(d+="="+h(n.attrs.defaultattr,a,"defaultattr"),delete n.attrs.defaultattr),n.attrs)n.attrs.hasOwnProperty(r)&&(d+=" "+r+"="+h(n.attrs[r],a,r));d+="]",s&&(d+="\n"),n.children&&(d+=e(n.children)),i||o.excludeClosing||(c&&(d+="\n"),d+="[/"+n.name+"]"),u&&(d+="\n"),n.closing&&i&&(d+=n.closing.val)}else d+=n.val;else d+=n.val,n.children&&(d+=e(n.children)),n.closing&&(d+=n.closing.val);return d}(m.parse(e,t))}}function o(e){return e=parseInt(e,10),isNaN(e)?"00":(e=Math.max(0,Math.min(e,255)).toString(16)).length<2?"0"+e:e}function s(e){var t;return(t=(e=e||"#000").match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))?"#"+o(t[1])+o(t[2])+o(t[3]):(t=e.match(/#([0-f])([0-f])([0-f])\s*?$/i))?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:e}function c(){var s=this;s.stripQuotes=k;var l={},u={ul:["li","ol","ul"],ol:["li","ol","ul"],table:["tr"],tr:["td","th"],code:["br","p","div"]};function d(o,i,t){function a(e){var t=e[0],n=e[1],r=f.getStyle(o,t),e=o.parentNode;return!(!r||e&&f.hasStyle(e,t,r))&&(!n||n.includes(r))}function e(e){l[e]&&l[e][t]&&g(l[e][t],function(e,t){var n=b[e].strictMatch;if(void 0===n&&(n=s.opts.strictMatch),!t||t[n?"every":"some"]((r=n,function(e){var t=e[0],e=e[1];if("style"===t&&"CODE"===o.nodeName)return!1;if("style"===t&&e)return e[r?"every":"some"](a);t=m(o,t);return t&&(!e||e.includes(t))}))){var r,e=b[e].format;return i=w(e)?e.call(s,o,i):function(e){var n=arguments;return e.replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[+t+1]?n[+t+1]:"{"+t+"}"})}(e,i),!1}})}return e("*"),e(o.nodeName.toLowerCase()),i}function c(e){var c=function(e,l){var s="";return f.traverse(e,function(e){var t="",n=e.nodeType,r=e.nodeName.toLowerCase(),o=u[r],i=e.firstChild,a=!0;"object"==typeof l&&(a=-1<l.indexOf(r),(a=h(e,"img")&&m(e,v)?!0:a)||(o=l)),3!==n&&1!==n||(1===n?h(e,".sceditor-nlf")&&!i||("iframe"!==r&&(t=c(e,o)),a?("code"!==r&&(t=d(e,t,!1)),t=d(e,t,!0),s+=function(e,t){var n=e.nodeName.toLowerCase(),r=f.isInline;if(!r(e,!0)||"br"===n){for(var o,i,a=e.previousSibling;a&&1===a.nodeType&&!h(a,"br")&&r(a,!0)&&!a.firstChild;)a=a.previousSibling;for(;o=((i=e.parentNode)&&i.lastChild)===e,e=i,i&&o&&r(i,!0););o&&"li"!==n||(t+="\n"),"br"!==n&&a&&!h(a,"br")&&r(a,!0)&&(t="\n"+t)}return t}(e,t)):s+=t):s+=e.nodeValue)},!1,!0),s};return c(e)}function e(e,t,n){var r,o,t=new D(s.opts.parserOptions).toHTML(s.opts.bbcodeTrim?t.trim():t);return e||n?(e=t,o=document.createElement("div"),n=function(e,t){if(!f.hasStyling(e)){if(1!==e.childNodes.length||!h(e.firstChild,"br"))for(;r=e.firstChild;)o.insertBefore(r,e);!t||e!==(t=o.lastChild)&&h(t,"div")&&e.nextSibling===t&&o.insertBefore(document.createElement("br"),e),o.removeChild(e)}},p(o,"display","none"),o.innerHTML=e.replace(/<\/div>\n/g,"</div>"),(e=o.firstChild)&&h(e,"div")&&n(e,!0),(e=o.lastChild)&&h(e,"div")&&n(e),o.innerHTML):t}function t(e,t,n,r){var o,i=(n=n||document).createElement("div"),a=n.createElement("div"),l=new D(s.opts.parserOptions);for(a.innerHTML=t,p(i,"visibility","hidden"),i.appendChild(a),n.body.appendChild(i),e&&(i.insertBefore(n.createTextNode("#"),i.firstChild),i.appendChild(n.createTextNode("#"))),r&&p(a,"whiteSpace",p(r,"whiteSpace")),o=a.getElementsByClassName("sceditor-ignore");o.length;)o[0].parentNode.removeChild(o[0]);return f.removeWhiteSpace(i),a=c(a),n.body.removeChild(i),a=l.toBBCode(a,!0),a=s.opts.bbcodeTrim?a.trim():a}s.init=function(){s.opts=this.opts,s.elementToBbcode=c,g(b,function(n,e){var r=!1===e.isInline,t=b[n].tags,e=b[n].styles;e&&(l["*"]=l["*"]||{},l["*"][r]=l["*"][r]||{},l["*"][r][n]=[["style",Object.entries(e)]]),t&&g(t,function(e,t){t&&t.style&&(t.style=Object.entries(t.style)),l[e]=l[e]||{},l[e][r]=l[e][r]||{},l[e][r][n]=t&&Object.entries(t)})}),this.commands=n(!0,{},r,this.commands),this.toBBCode=s.toSource,this.fromBBCode=s.toHtml},s.toHtml=e.bind(null,!1),s.fragmentToHtml=e.bind(null,!0),s.toSource=t.bind(null,!1),s.fragmentToSource=t.bind(null,!0)}l.prototype={clone:function(){var e=this;return new l(e.type,e.name,e.val,n({},e.attrs),[],e.closing?e.closing.clone():null)},splitAt:function(e){var t=this.clone(),n=this.children.indexOf(e);return-1<n&&(e=this.children.length-n,t.children=this.children.splice(n,e)),t}},D.QuoteType=y,D.defaults={breakBeforeBlock:!1,breakStartBlock:!1,breakEndBlock:!1,breakAfterBlock:!0,removeEmptyTags:!0,fixInvalidNesting:!0,fixInvalidChildren:!0,quoteType:y.auto,strictMatch:!1},c.get=function(e){return b[e]||null},c.set=function(e,t){return e&&t&&((t=n(b[e]||{},t)).remove=function(){delete b[e]},b[e]=t),this},c.rename=function(e,t){return e in b&&(b[t]=b[e],delete b[e]),this},c.remove=function(e){return e in b&&delete b[e],this},c.formatBBCodeString=x,e.formats.bbcode=c,e.BBCodeParser=D}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/jquery.sceditor.min.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(){"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=e(jQuery);function t(e,t){return typeof t===e}var ye=t.bind(null,"string"),be=t.bind(null,"undefined"),xe=t.bind(null,"function"),r=t.bind(null,"number");function n(e){return!Object.keys(e).length}function we(e,t){var n=e===!!e,o=n?2:1,r=n?t:e,i=n&&e;function a(e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype}for(;o<arguments.length;o++){var l,s=arguments[o];for(l in s){var c,u,d=r[l],f=s[l];be(f)||"__proto__"!==l&&"constructor"!==l&&(u=a(f),c=Array.isArray(f),i&&(u||c)?(u=a(d)===u&&Array.isArray(d)===c,r[l]=we(!0,u?d:c?[]:{},f)):r[l]=f)}}return r}function Te(e,t){t=e.indexOf(t);-1<t&&e.splice(t,1)}function Ce(t,n){if(Array.isArray(t)||"length"in t&&r(t.length))for(var e=0;e<t.length;e++)n(e,t[e]);else Object.keys(t).forEach(function(e){n(e,t[e])})}var i={},Se=1,ke=3,l=8;function a(e){return e=parseFloat(e),isFinite(e)?e:0}function De(e,t,n){var o=(n||document).createElement(e);return Ce(t||{},function(e,t){"style"===e?o.style.cssText=t:e in o?o[e]=t:o.setAttribute(e,t)}),o}function Ee(e,t){for(var n=e||{};(n=n.parentNode)&&!/(9|11)/.test(n.nodeType);)if(!t||Ue(n,t))return n}function Ne(e,t){return Ue(e,t)?e:Ee(e,t)}function Me(e){e.parentNode&&e.parentNode.removeChild(e)}function Ae(e,t){e.appendChild(t)}function Re(e,t){return e.querySelectorAll(t)}var _e=!0;function Fe(n,e,o,r,i){e.split(" ").forEach(function(e){var t;ye(o)?(t=r["_sce-event-"+e+o]||function(e){for(var t=e.target;t&&t!==n;){if(Ue(t,o))return void r.call(t,e);t=t.parentNode}},r["_sce-event-"+e+o]=t):(t=o,i=r),n.addEventListener(e,t,i||!1)})}function Oe(n,e,o,r,i){e.split(" ").forEach(function(e){var t;ye(o)?t=r["_sce-event-"+e+o]:(t=o,i=r),n.removeEventListener(e,t,i||!1)})}function He(e,t,n){if(arguments.length<3)return e.getAttribute(t);null==n?ze(e,t):e.setAttribute(t,n)}function ze(e,t){e.removeAttribute(t)}function Le(e){Pe(e,"display","none")}function Ie(e){Pe(e,"display","")}function Be(e){(Ze(e)?Le:Ie)(e)}function Pe(n,e,t){if(arguments.length<3){if(ye(e))return 1===n.nodeType?getComputedStyle(n)[e]:null;Ce(e,function(e,t){Pe(n,e,t)})}else{var o=(t||0===t)&&!isNaN(t);n.style[e]=o?t+"px":t}}function je(e,t,n){var o=arguments.length,r={};if(e.nodeType===Se)return 1===o?(Ce(e.attributes,function(e,t){/^data\-/i.test(t.name)&&(r[t.name.substr(5)]=t.value)}),r):2===o?He(e,"data-"+t):void He(e,"data-"+t,String(n))}function Ue(e,t){var n=!1;return n=e&&e.nodeType===Se?(e.matches||e.msMatchesSelector||e.webkitMatchesSelector).call(e,t):n}function We(e,t){return t.parentNode.insertBefore(e,t)}function s(e){return e.className.trim().split(/\s+/)}function Ve(e,t){return Ue(e,"."+t)}function qe(e,t){var n=s(e);n.indexOf(t)<0&&n.push(t),e.className=n.join(" ")}function Ge(e,t){var n=s(e);Te(n,t),e.className=n.join(" ")}function $e(e,t,n){((n=be(n)?!Ve(e,t):n)?qe:Ge)(e,t)}function Ye(e,t){if(be(t)){var n=getComputedStyle(e),o=a(n.paddingLeft)+a(n.paddingRight),n=a(n.borderLeftWidth)+a(n.borderRightWidth);return e.offsetWidth-o-n}Pe(e,"width",t)}function Ke(e,t){if(be(t)){var n=getComputedStyle(e),o=a(n.paddingTop)+a(n.paddingBottom),n=a(n.borderTopWidth)+a(n.borderBottomWidth);return e.offsetHeight-o-n}Pe(e,"height",t)}function Xe(e,t,n){var o;xe(window.CustomEvent)?o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(o=e.ownerDocument.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n),e.dispatchEvent(o)}function Ze(e){return e.getClientRects().length}function Qe(e,t,n,o,r){for(e=r?e.lastChild:e.firstChild;e;){var i=r?e.previousSibling:e.nextSibling;if(!n&&!1===t(e)||!o&&!1===Qe(e,t,n,o,r)||n&&!1===t(e))return!1;e=i}}function Je(e,t,n,o){Qe(e,t,n,o,!0)}function et(e,t){var n=(t=t||document).createDocumentFragment(),o=De("div",{},t);for(o.innerHTML=e;o.firstChild;)Ae(n,o.firstChild);return n}function tt(e){return e&&(!Ue(e,"p,div")||e.className||He(e,"style")||!n(je(e)))}function nt(e,t){var n=De(t,{},e.ownerDocument);for(Ce(e.attributes,function(e,t){try{He(n,t.name,t.value)}catch(e){}});e.firstChild;)Ae(n,e.firstChild);return e.parentNode.replaceChild(n,e),n}var c="|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|details|section|article|aside|nav|main|header|hgroup|footer|fieldset|dl|dt|dd|figure|figcaption|";function ot(e){return!!/11?|9/.test(e.nodeType)&&"|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr|isindex|link|meta|param|command|embed|keygen|source|track|object|".indexOf("|"+e.nodeName.toLowerCase()+"|")<0}function rt(e,t){var n=(e||{}).nodeType||ke;return n!==Se?n===ke:"code"===(e=e.tagName.toLowerCase())?!t:c.indexOf("|"+e+"|")<0}function d(e){return e.lastChild&&d(e.lastChild)&&Me(e.lastChild),3===e.nodeType?!e.nodeValue:ot(e)&&!e.childNodes.length}function it(e){Qe(e,function(e){var t=!rt(e,!0)&&e.nodeType!==l,n=e.parentNode;if(t&&(rt(n,!0)||"P"===n.tagName)){for(var o=e;rt(o.parentNode,!0)||"P"===o.parentNode.tagName;)o=o.parentNode;for(var r=f(o,e),i=e;n&&rt(n,!0);){if(n.nodeType===Se){for(var a=n.cloneNode();i.firstChild;)Ae(a,i.firstChild);Ae(i,a)}n=n.parentNode}We(i,o),d(r)||We(r,i),d(o)&&Me(o)}t&&Ue(e,"ul,ol")&&Ue(e.parentNode,"ul,ol")&&(r="li",t=(t=e).previousElementSibling,(t=!r||!t||Ue(t,r)?t:null)||We(t=De("li"),e),Ae(t,e))})}function u(e,t){return e?(t?e.previousSibling:e.nextSibling)||u(e.parentNode,t):null}function at(e){var t,n,o,r,i,a,l=Pe(e,"whiteSpace"),s=/line$/i.test(l),c=e.firstChild;if(!/pre(\-wrap)?$/i.test(l))for(;c;){if(i=c.nextSibling,t=c.nodeValue,(a=c.nodeType)===Se&&c.firstChild&&at(c),a===ke){for(n=u(c),o=u(c,!0),a=!1;Ve(o,"sceditor-ignore");)o=u(o,!0);if(rt(c)&&o){for(r=o;r.lastChild;)for(r=r.lastChild;Ve(r,"sceditor-ignore");)r=u(r,!0);a=r.nodeType===ke?/[\t\n\r ]$/.test(r.nodeValue):!rt(r)}t=t.replace(/\u200B/g,""),o&&rt(o)&&!a||(t=t.replace(s?/^[\t ]+/:/^[\t\n\r ]+/,"")),(t=!n||!rt(n)?t.replace(s?/[\t ]+$/:/[\t\n\r ]+$/,""):t).length?c.nodeValue=t.replace(s?/[\t ]+/g:/[\t\n\r ]+/g," "):Me(c)}c=i}}function f(e,t){var n=e.ownerDocument.createRange();return n.setStartBefore(e),n.setEndAfter(t),n.extractContents()}function lt(e){for(var t=0,n=0;e;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;return{left:t,top:n}}function p(e,t){var n=e.style;return i[t]||(i[t]=t.replace(/^-ms-/,"ms-").replace(/-(\w)/g,function(e,t){return t.toUpperCase()})),n=n[t=i[t]],"textAlign"===t&&(n=n||Pe(e,t),Pe(e.parentNode,t)===n||"block"!==Pe(e,"display")||Ue(e,"hr,th"))?"":n}function st(e,t){var n=e.attributes.length;if(n===t.attributes.length){for(;n--;){var o=e.attributes[n];if("style"===o.name?!function(e,t){var n=e.style.length;if(n===t.style.length){for(;n--;){var o=e.style[n];if(e.style[o]!==t.style[o])return}return 1}}(e,t):o.value!==He(t,o.name))return}return 1}}function ct(e){for(;e.firstChild;)We(e.firstChild,e);Me(e)}var ut={toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,image,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source",toolbarExclude:null,style:"jquery.sceditor.default.css",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana",colors:"#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef",locale:He(document.documentElement,"lang")||"en",charset:"utf-8",emoticonsCompat:!1,emoticonsEnabled:!0,emoticonsRoot:"",emoticons:{dropdown:{":)":"emoticons/smile.png",":angel:":"emoticons/angel.png",":angry:":"emoticons/angry.png","8-)":"emoticons/cool.png",":'(":"emoticons/cwy.png",":ermm:":"emoticons/ermm.png",":D":"emoticons/grin.png","<3":"emoticons/heart.png",":(":"emoticons/sad.png",":O":"emoticons/shocked.png",":P":"emoticons/tongue.png",";)":"emoticons/wink.png"},more:{":alien:":"emoticons/alien.png",":blink:":"emoticons/blink.png",":blush:":"emoticons/blush.png",":cheerful:":"emoticons/cheerful.png",":devil:":"emoticons/devil.png",":dizzy:":"emoticons/dizzy.png",":getlost:":"emoticons/getlost.png",":happy:":"emoticons/happy.png",":kissing:":"emoticons/kissing.png",":ninja:":"emoticons/ninja.png",":pinch:":"emoticons/pinch.png",":pouty:":"emoticons/pouty.png",":sick:":"emoticons/sick.png",":sideways:":"emoticons/sideways.png",":silly:":"emoticons/silly.png",":sleeping:":"emoticons/sleeping.png",":unsure:":"emoticons/unsure.png",":woot:":"emoticons/w00t.png",":wassat:":"emoticons/wassat.png"},hidden:{":whistling:":"emoticons/whistling.png",":love:":"emoticons/wub.png"}},width:null,height:null,resizeEnabled:!0,resizeMinWidth:null,resizeMinHeight:null,resizeMaxHeight:null,resizeMaxWidth:null,resizeHeight:!0,resizeWidth:!0,dateFormat:"year-month-day",toolbarContainer:null,enablePasteFiltering:!1,disablePasting:!1,readOnly:!1,rtl:!1,autofocus:!1,autofocusEnd:!0,autoExpand:!1,autoUpdate:!1,spellcheck:!0,runWithoutWysiwygSupport:!1,startInSourceMode:!1,id:null,plugins:"",zIndex:null,bbcodeTrim:!1,disableBlockRemove:!1,allowedIframeUrls:[],parserOptions:{},dropDownCss:{}},m=/^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i;function dt(e){return e.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function ft(e,t){if(!e)return e;var n={"&":"&","<":"<",">":">"," ":" ","\r\n":"<br />","\r":"<br />","\n":"<br />"};return!1!==t&&(n['"']=""",n["'"]="'",n["`"]="`"),e=e.replace(/ {2}|\r\n|[&<>\r\n'"`]/g,function(e){return n[e]||e})}var g={html:'<!DOCTYPE html><html{attrs}><head><meta http-equiv="Content-Type" content="text/html;charset={charset}" /><link rel="stylesheet" type="text/css" href="{style}" /></head><body contenteditable="true" {spellcheck}><p></p></body></html>',toolbarButton:'<a class="sceditor-button sceditor-button-{name}" data-sceditor-command="{name}" unselectable="on"><div unselectable="on">{dispName}</div></a>',emoticon:'<img src="{url}" data-sceditor-emoticon="{key}" alt="{key}" title="{tooltip}" />',fontOpt:'<a class="sceditor-font-option" href="#" data-font="{font}"><font face="{font}">{font}</font></a>',sizeOpt:'<a class="sceditor-fontsize-option" data-size="{size}" href="#"><font size="{size}">{size}</font></a>',pastetext:'<div><label for="txt">{label}</label> <textarea cols="20" rows="7" id="txt"></textarea></div><div><input type="button" class="button" value="{insert}" /></div>',table:'<div><label for="rows">{rows}</label><input type="text" id="rows" value="2" /></div><div><label for="cols">{cols}</label><input type="text" id="cols" value="2" /></div><div><input type="button" class="button" value="{insert}" /></div>',image:'<div><label for="image">{url}</label> <input type="text" id="image" dir="ltr" placeholder="https://" /></div><div><label for="width">{width}</label> <input type="text" id="width" size="2" dir="ltr" /></div><div><label for="height">{height}</label> <input type="text" id="height" size="2" dir="ltr" /></div><div><input type="button" class="button" value="{insert}" /></div>',email:'<div><label for="email">{label}</label> <input type="text" id="email" dir="ltr" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{insert}" /></div>',link:'<div><label for="link">{url}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{ins}" /></div>',youtubeMenu:'<div><label for="link">{label}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><input type="button" class="button" value="{insert}" /></div>',youtube:'<iframe width="560" height="315" frameborder="0" allowfullscreen src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" data-youtube-id="{id}"></iframe>'};function pt(e,t,n){var o=g[e];return Object.keys(t).forEach(function(e){o=o.replace(new RegExp(dt("{"+e+"}"),"g"),t[e])}),o=n?et(o):o}function h(e){if("mozHidden"in document)for(var t,n=e.getBody();n;){if((t=n).firstChild)t=t.firstChild;else{for(;t&&!t.nextSibling;)t=t.parentNode;t=t&&t.nextSibling}3===n.nodeType&&/[\n\r\t]+/.test(n.nodeValue)&&(/^pre/.test(Pe(n.parentNode,"whiteSpace"))||Me(n)),n=t}}var mt={bold:{exec:"bold",tooltip:"Bold",shortcut:"Ctrl+B"},italic:{exec:"italic",tooltip:"Italic",shortcut:"Ctrl+I"},underline:{exec:"underline",tooltip:"Underline",shortcut:"Ctrl+U"},strike:{exec:"strikethrough",tooltip:"Strikethrough"},subscript:{exec:"subscript",tooltip:"Subscript"},superscript:{exec:"superscript",tooltip:"Superscript"},left:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===Pe(e,"direction"),e=Pe(e,"textAlign");return/left/.test(e)||e===(t?"start":"end")}},exec:"justifyleft",tooltip:"Align left"},center:{exec:"justifycenter",tooltip:"Center"},right:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===Pe(e,"direction"),e=Pe(e,"textAlign");return/right/.test(e)||e===(t?"end":"start")}},exec:"justifyright",tooltip:"Align right"},justify:{exec:"justifyfull",tooltip:"Justify"},font:{_dropDown:function(t,e,n){var o=De("div");Fe(o,"click","a",function(e){n(je(this,"font")),t.closeDropDown(!0),e.preventDefault()}),t.opts.fonts.split(",").forEach(function(e){Ae(o,pt("fontOpt",{font:e},!0))}),t.createDropDown(e,"font-picker",o)},exec:function(e){var t=this;mt.font._dropDown(t,e,function(e){t.execCommand("fontname",e)})},tooltip:"Font Name"},size:{_dropDown:function(t,e,n){var o=De("div");Fe(o,"click","a",function(e){n(je(this,"size")),t.closeDropDown(!0),e.preventDefault()});for(var r=1;r<=7;r++)Ae(o,pt("sizeOpt",{size:r},!0));t.createDropDown(e,"fontsize-picker",o)},exec:function(e){var t=this;mt.size._dropDown(t,e,function(e){t.execCommand("fontsize",e)})},tooltip:"Font Size"},color:{_dropDown:function(t,e,n){var o=De("div"),r="",i=mt.color;i._htmlCache||(t.opts.colors.split("|").forEach(function(e){r+='<div class="sceditor-color-column">',e.split(",").forEach(function(e){r+='<a href="#" class="sceditor-color-option" style="background-color: '+e+'" data-color="'+e+'"></a>'}),r+="</div>"}),i._htmlCache=r),Ae(o,et(i._htmlCache)),Fe(o,"click","a",function(e){n(je(this,"color")),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"color-picker",o)},exec:function(e){var t=this;mt.color._dropDown(t,e,function(e){t.execCommand("forecolor",e)})},tooltip:"Font Color"},removeformat:{exec:"removeformat",tooltip:"Remove Formatting"},cut:{exec:"cut",tooltip:"Cut",errorMessage:"Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X"},copy:{exec:"copy",tooltip:"Copy",errorMessage:"Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C"},paste:{exec:"paste",tooltip:"Paste",errorMessage:"Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V"},pastetext:{exec:function(e){var t,n=De("div"),o=this;Ae(n,pt("pastetext",{label:o._("Paste your text inside the following box:"),insert:o._("Insert")},!0)),Fe(n,"click",".button",function(e){(t=Re(n,"#txt")[0].value)&&o.wysiwygEditorInsertText(t),o.closeDropDown(!0),e.preventDefault()}),o.createDropDown(e,"pastetext",n)},tooltip:"Paste Text"},bulletlist:{exec:function(){h(this),this.execCommand("insertunorderedlist")},tooltip:"Bullet list"},orderedlist:{exec:function(){h(this),this.execCommand("insertorderedlist")},tooltip:"Numbered list"},indent:{state:function(e,t){var n;return Ue(t,"li")||Ue(t,"ul,ol,menu")&&(t=(n=this.getRangeHelper().selectedRange()).startContainer.parentNode,n=n.endContainer.parentNode,t!==t.parentNode.firstElementChild||Ue(n,"li")&&n!==n.parentNode.lastElementChild)?0:-1},exec:function(){var e=this.getRangeHelper().getFirstBlockParent();this.focus(),Ne(e,"ul,ol,menu")&&this.execCommand("indent")},tooltip:"Add indent"},outdent:{state:function(e,t){return Ne(t,"ul,ol,menu")?0:-1},exec:function(){Ne(this.getRangeHelper().getFirstBlockParent(),"ul,ol,menu")&&this.execCommand("outdent")},tooltip:"Remove one indent"},table:{exec:function(e){var r=this,i=De("div");Ae(i,pt("table",{rows:r._("Rows:"),cols:r._("Cols:"),insert:r._("Insert")},!0)),Fe(i,"click",".button",function(e){var t=Number(Re(i,"#rows")[0].value),n=Number(Re(i,"#cols")[0].value),o="<table>";0<t&&0<n&&(o+=Array(t+1).join("<tr>"+Array(n+1).join("<td><br /></td>")+"</tr>"),o+="</table>",r.wysiwygEditorInsertHtml(o),r.closeDropDown(!0),e.preventDefault())}),r.createDropDown(e,"inserttable",i)},tooltip:"Insert a table"},horizontalrule:{exec:"inserthorizontalrule",tooltip:"Insert a horizontal rule"},code:{exec:function(){this.wysiwygEditorInsertHtml("<code>","<br /></code>")},tooltip:"Code"},image:{_dropDown:function(t,e,n,o){var r=De("div");Ae(r,pt("image",{url:t._("URL:"),width:t._("Width (optional):"),height:t._("Height (optional):"),insert:t._("Insert")},!0));var i=Re(r,"#image")[0];i.value=n,Fe(r,"click",".button",function(e){i.value&&o(i.value,Re(r,"#width")[0].value,Re(r,"#height")[0].value),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertimage",r)},exec:function(e){var r=this;mt.image._dropDown(r,e,"",function(e,t,n){var o="";t&&(o+=' width="'+parseInt(t,10)+'"'),n&&(o+=' height="'+parseInt(n,10)+'"'),o+=' src="'+ft(e)+'"',r.wysiwygEditorInsertHtml("<img"+o+" />")})},tooltip:"Insert an image"},email:{_dropDown:function(n,e,o){var r=De("div");Ae(r,pt("email",{label:n._("E-mail:"),desc:n._("Description (optional):"),insert:n._("Insert")},!0)),Fe(r,"click",".button",function(e){var t=Re(r,"#email")[0].value;t&&o(t,Re(r,"#des")[0].value),n.closeDropDown(!0),e.preventDefault()}),n.createDropDown(e,"insertemail",r)},exec:function(e){var n=this;mt.email._dropDown(n,e,function(e,t){!n.getRangeHelper().selectedHtml()||t?n.wysiwygEditorInsertHtml('<a href="mailto:'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink","mailto:"+e)})},tooltip:"Insert an email"},link:{_dropDown:function(t,e,n){var o=De("div");Ae(o,pt("link",{url:t._("URL:"),desc:t._("Description (optional):"),ins:t._("Insert")},!0));var r=Re(o,"#link")[0];function i(e){r.value&&n(r.value,Re(o,"#des")[0].value),t.closeDropDown(!0),e.preventDefault()}Fe(o,"click",".button",i),Fe(o,"keypress",function(e){13===e.which&&r.value&&i(e)},_e),t.createDropDown(e,"insertlink",o)},exec:function(e){var n=this;mt.link._dropDown(n,e,function(e,t){t||!n.getRangeHelper().selectedHtml()?n.wysiwygEditorInsertHtml('<a href="'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink",e)})},tooltip:"Insert a link"},unlink:{state:function(){return Ne(this.currentNode(),"a")?0:-1},exec:function(){var e=Ne(this.currentNode(),"a");if(e){for(;e.firstChild;)We(e.firstChild,e);Me(e)}},tooltip:"Unlink"},quote:{exec:function(e,t,n){var o="<blockquote>",r="</blockquote>";t?(o=o+(n=n?"<cite>"+ft(n)+"</cite>":"")+t+r,r=null):""===this.getRangeHelper().selectedHtml()&&(r="<br />"+r),this.wysiwygEditorInsertHtml(o,r)},tooltip:"Insert a Quote"},emoticon:{exec:function(u){var d=this,f=function(e){var n,t=d.opts,o=t.emoticonsRoot||"",r=t.emoticonsCompat,i=d.getRangeHelper(),a=r&&" "!==i.getOuterText(!0,1)?" ":"",l=r&&" "!==i.getOuterText(!1,1)?" ":"",s=De("div"),c=De("div"),i=we({},t.emoticons.dropdown,e?t.emoticons.more:{});return Ae(s,c),n=Math.sqrt(Object.keys(i).length),Fe(s,"click","img",function(e){d.insert(a+He(this,"alt")+l,null,!1).closeDropDown(!0),e.preventDefault()}),Ce(i,function(e,t){Ae(c,De("img",{src:o+(t.url||t),alt:e,title:t.tooltip||e})),c.children.length>=n&&(c=De("div"),Ae(s,c))}),!e&&t.emoticons.more&&(Ae(t=De("a",{className:"sceditor-more"}),document.createTextNode(d._("More"))),Fe(t,"click",function(e){d.createDropDown(u,"more-emoticons",f(!0)),e.preventDefault()}),Ae(s,t)),s};d.createDropDown(u,"emoticons",f(!1))},txtExec:function(e){mt.emoticon.exec.call(this,e)},tooltip:"Insert an emoticon"},youtube:{_dropDown:function(r,e,i){var a=De("div");Ae(a,pt("youtubeMenu",{label:r._("Video URL:"),insert:r._("Insert")},!0)),Fe(a,"click",".button",function(e){var t=Re(a,"#link")[0].value,n=t.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/),t=t.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/),o=0;t&&Ce(t[1].split(/[hms]/),function(e,t){""!==t&&(o=60*o+Number(t))}),n&&/^[a-zA-Z0-9_\-]{11}$/.test(n[1])&&i(n[1],o),r.closeDropDown(!0),e.preventDefault()}),r.createDropDown(e,"insertlink",a)},exec:function(e){var n=this;mt.youtube._dropDown(n,e,function(e,t){n.wysiwygEditorInsertHtml(pt("youtube",{id:e,time:t}))})},tooltip:"Insert a YouTube video"},date:{_date:function(e){var t=new Date,n=t.getYear(),o=t.getMonth()+1,t=t.getDate();return n<2e3&&(n=1900+n),o<10&&(o="0"+o),t<10&&(t="0"+t),e.opts.dateFormat.replace(/year/i,n).replace(/month/i,o).replace(/day/i,t)},exec:function(){this.insertText(mt.date._date(this))},txtExec:function(){this.insertText(mt.date._date(this))},tooltip:"Insert current date"},time:{_time:function(){var e=new Date,t=e.getHours(),n=e.getMinutes(),e=e.getSeconds();return(t=t<10?"0"+t:t)+":"+(n=n<10?"0"+n:n)+":"+(e=e<10?"0"+e:e)},exec:function(){this.insertText(mt.time._time())},txtExec:function(){this.insertText(mt.time._time())},tooltip:"Insert current time"},ltr:{state:function(e,t){return t&&"ltr"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!Ue(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!Ue(t,"body")))&&(e="ltr"===Pe(t,"direction")?"":"ltr",Pe(t,"direction",e))},tooltip:"Left-to-Right"},rtl:{state:function(e,t){return t&&"rtl"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!Ue(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!Ue(t,"body")))&&(e="rtl"===Pe(t,"direction")?"":"rtl",Pe(t,"direction",e))},tooltip:"Right-to-Left"},print:{exec:"print",tooltip:"Print"},maximize:{state:function(){return this.maximize()},exec:function(){this.maximize(!this.maximize()),this.focus()},txtExec:function(){this.maximize(!this.maximize()),this.focus()},tooltip:"Maximize",shortcut:"Ctrl+Shift+M"},source:{state:function(){return this.sourceMode()},exec:function(){this.toggleSourceMode(),this.focus()},txtExec:function(){this.toggleSourceMode(),this.focus()},tooltip:"View source",shortcut:"Ctrl+Shift+S"},ignore:{}},v={};function gt(i){function a(e){return"signal"+e.charAt(0).toUpperCase()+e.slice(1)}function e(e,t){e=[].slice.call(e);for(var n,o=a(e.shift()),r=0;r<l.length;r++)if(o in l[r]&&(n=l[r][o].apply(i,e),t))return n}var r=this,l=[];r.call=function(){e(arguments,!1)},r.callOnlyFirst=function(){return e(arguments,!0)},r.hasHandler=function(e){var t=l.length;for(e=a(e);t--;)if(e in l[t])return!0;return!1},r.exists=function(e){return e in v&&("function"==typeof(e=v[e])&&"object"==typeof e.prototype)},r.isRegistered=function(e){if(r.exists(e))for(var t=l.length;t--;)if(l[t]instanceof v[e])return!0;return!1},r.register=function(e){return!(!r.exists(e)||r.isRegistered(e))&&(e=new v[e],l.push(e),"init"in e&&e.init.call(i),!0)},r.deregister=function(e){var t,n=l.length,o=!1;if(!r.isRegistered(e))return o;for(;n--;)l[n]instanceof v[e]&&(o=!0,"destroy"in(t=l.splice(n,1)[0])&&t.destroy.call(i));return o},r.destroy=function(){for(var e=l.length;e--;)"destroy"in l[e]&&l[e].destroy.call(i);l=[],i=null}}gt.plugins=v;var y=function(e,t,n){var o,r,i,a,l,s="",c=e.startContainer,u=e.startOffset;for(c&&3!==c.nodeType&&(c=c.childNodes[u],u=0),i=a=u;n>s.length&&c&&3===c.nodeType;)o=c.nodeValue,r=n-s.length,l&&(a=o.length,i=0),l=c,c=t?(u=i=Math.max(a-r,0),s=o.substr(i,a-i)+s,l.previousSibling):(u=i+(a=Math.min(r,o.length)),s+=o.substr(i,a),l.nextSibling);return{node:l||c,offset:u,text:s}};function ht(r,e,i){var a,l,s=e||r.contentDocument||r.document,c="sceditor-start-marker",u="sceditor-end-marker",h=this;h.insertHTML=function(e,t){var n,o;if(!h.selectedRange())return!1;for(t&&(e+=h.selectedHtml()+t),o=De("p",{},s),n=s.createDocumentFragment(),o.innerHTML=i(e);o.firstChild;)Ae(n,o.firstChild);h.insertNode(n)},l=function(e,t,n){var o,r=s.createDocumentFragment();if("string"==typeof e?(t&&(e+=h.selectedHtml()+t),r=et(e)):(Ae(r,e),t&&(Ae(r,h.selectedRange().extractContents()),Ae(r,t))),o=r.lastChild){for(;!rt(o.lastChild,!0);)o=o.lastChild;if(ot(o)?o.lastChild||Ae(o,document.createTextNode("")):o=r,h.removeMarkers(),Ae(o,a(c)),Ae(o,a(u)),n){n=De("div");return Ae(n,r),n.innerHTML}return r}},h.insertNode=function(e,t){var n,o,r=l(e,t),e=h.selectedRange(),t=e.commonAncestorContainer,i=[];if(!r)return!1;function a(e){e&&d(e)&&i.indexOf(e)<0&&Me(e)}e.startContainer!==e.endContainer&&(Ce(t.childNodes,function(e,t){d(t)&&i.push(t)}),n=r.firstChild,o=r.lastChild),e.deleteContents(),t&&3!==t.nodeType&&!ot(t)?We(r,t):(e.insertNode(r),a(n&&n.previousSibling),a(o&&o.nextSibling)),h.restoreRange()},h.cloneSelected=function(){var e=h.selectedRange();if(e)return e.cloneRange()},h.selectedRange=function(){var e,t,n=r.getSelection();if(n){if(n.rangeCount<=0){for(t=s.body;t.firstChild;)t=t.firstChild;(e=s.createRange()).setStartBefore(t),n.addRange(e)}return e=0<n.rangeCount?n.getRangeAt(0):e}},h.hasSelection=function(){var e=r.getSelection();return e&&0<e.rangeCount},h.selectedHtml=function(){var e,t=h.selectedRange();return t?(Ae(e=De("p",{},s),t.cloneContents()),e.innerHTML):""},h.parentNode=function(){var e=h.selectedRange();if(e)return e.commonAncestorContainer},h.getFirstBlockParent=function(e){var t=function(e){return rt(e,!0)?(e=e?e.parentNode:null)&&t(e):e};return t(e||h.parentNode())},h.insertNodeAt=function(e,t){var n=h.selectedRange(),o=h.cloneSelected();if(!o)return!1;o.collapse(e),o.insertNode(t),h.selectRange(n)},a=function(e){h.removeMarker(e);e=De("span",{id:e,className:"sceditor-selection sceditor-ignore",style:"display:none;line-height:0"},s);return e.innerHTML=" ",e},h.insertMarkers=function(){var e=h.selectedRange(),t=a(c);h.removeMarkers(),h.insertNodeAt(!0,t),e&&e.collapsed?t.parentNode.insertBefore(a(u),t.nextSibling):h.insertNodeAt(!1,a(u))},h.getMarker=function(e){return s.getElementById(e)},h.removeMarker=function(e){e=h.getMarker(e);e&&Me(e)},h.removeMarkers=function(){h.removeMarker(c),h.removeMarker(u)},h.saveRange=function(){h.insertMarkers()},h.selectRange=function(e){var t,n=r.getSelection(),o=e.endContainer;if(e.collapsed&&o&&!rt(o,!0)){for(t=o.lastChild;t&&Ue(t,".sceditor-ignore");)t=t.previousSibling;Ue(t,"br")&&((o=s.createRange()).setEndAfter(t),o.collapse(!1),h.compare(e,o)&&(e.setStartBefore(t),e.collapse(!0)))}n&&(h.clear(),n.addRange(e))},h.restoreRange=function(){var e,t=h.selectedRange(),n=h.getMarker(c),o=h.getMarker(u);if(!n||!o||!t)return!1;e=n.nextSibling===o,(t=s.createRange()).setStartBefore(n),t.setEndAfter(o),e&&t.collapse(!0),h.selectRange(t),h.removeMarkers()},h.selectOuterText=function(e,t){var n=h.cloneSelected();if(!n)return!1;n.collapse(!1),e=y(n,!0,e),t=y(n,!1,t),n.setStart(e.node,e.offset),n.setEnd(t.node,t.offset),h.selectRange(n)},h.getOuterText=function(e,t){var n=h.cloneSelected();return n?(n.collapse(!e),y(n,e,t).text):""},h.replaceKeyword=function(e,t,n,o,r,i){n||e.sort(function(e,t){return e[0].length-t[0].length});var a,l,s,c,u,d,f,p="(^|[\\s ])",m=e.length,g=r?1:0,o=o||e[m-1][0].length;for(r&&o++,i=i||"",c=(a=h.getOuterText(!0,o)).length,a+=i,t&&(a+=h.getOuterText(!1,o));m--;)if(d=e[m][0],f=d.length,s=Math.max(0,c-f-g),u=-1,r?(l=a.substr(s).match(new RegExp(p+dt(d)+p)))&&(u=l.index+s+l[1].length):u=a.indexOf(d,s),-1<u&&u<=c&&c<=u+f+g)return u=c-u,h.selectOuterText(u,f-u-(/^\S/.test(i)?1:0)),h.insertHTML(e[m][1]),!0;return!1},h.compare=function(e,t){return t=t||h.selectedRange(),e&&t?0===e.compareBoundaryPoints(Range.END_TO_END,t)&&0===e.compareBoundaryPoints(Range.START_TO_START,t):!e&&!t},h.clear=function(){var e=r.getSelection();e&&(e.removeAllRanges?e.removeAllRanges():e.empty&&e.empty())}}var b,x,w,T=navigator.userAgent,vt=/iPhone|iPod|iPad| wosbrowser\//i.test(T),yt=(x=!!window.document.documentMode,N="-ms-ime-align"in document.documentElement.style,(A=document.createElement("div")).contentEditable=!0,"contentEditable"in document.documentElement&&"true"===A.contentEditable&&(A=/Opera Mobi|Opera Mini/i.test(T),/Android/i.test(T)&&(A=!0,/Safari/.test(T)&&(A=!(b=/Safari\/(\d+)/.exec(T))||!b[1]||b[1]<534)),/ Silk\//i.test(T)&&(A=!(b=/AppleWebKit\/(\d+)/.exec(T))||!b[1]||b[1]<534),vt&&(A=/OS [0-4](_\d)+ like Mac/i.test(T)),/Firefox/i.test(T)&&(A=!1),/OneBrowser/i.test(T)&&(A=!1),"UCWEB"===navigator.vendor&&(A=!1),!(A=x||N?!0:A))),C=Object.hasOwnProperty,S=Object.setPrototypeOf,k=Object.isFrozen,D=Object.getPrototypeOf,E=Object.getOwnPropertyDescriptor,bt=Object.freeze,N=Object.seal,M=Object.create,A="undefined"!=typeof Reflect&&Reflect,R=(R=A.apply)||function(e,t,n){return e.apply(t,n)},bt=bt||function(e){return e},N=N||function(e){return e},_=(_=A.construct)||function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))},xt=F(Array.prototype.forEach),wt=F(Array.prototype.pop),Tt=F(Array.prototype.push),Ct=F(String.prototype.toLowerCase),St=F(String.prototype.match),kt=F(String.prototype.replace),Dt=F(String.prototype.indexOf),Et=F(String.prototype.trim),Nt=F(RegExp.prototype.test),Mt=(w=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _(w,t)});function F(r){return function(e){for(var t=arguments.length,n=Array(1<t?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return R(r,e,n)}}function At(e,t){S&&S(e,null);for(var n=t.length;n--;){var o,r=t[n];"string"!=typeof r||(o=Ct(r))!==r&&(k(t)||(t[n]=o),r=o),e[r]=!0}return e}function Rt(e){var t=M(null),n=void 0;for(n in e)R(C,e,[n])&&(t[n]=e[n]);return t}function _t(e,t){for(;null!==e;){var n=E(e,t);if(n){if(n.get)return F(n.get);if("function"==typeof n.value)return F(n.value)}e=D(e)}return null}var Ft=bt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ot=bt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ht=bt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),zt=bt(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Lt=bt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),It=bt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Bt=bt(["#text"]),Pt=bt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns"]),jt=bt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ut=bt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=bt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Vt=N(/\{\{[\s\S]*|[\s\S]*\}\}/gm),qt=N(/<%[\s\S]*|[\s\S]*%>/gm),Gt=N(/^data-[\-\w.\u00B7-\uFFFF]/),$t=N(/^aria-[\-\w]+$/),Yt=N(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Kt=N(/^(?:\w+script|data):/i),Xt=N(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function Qt(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var Jt=function(){return"undefined"==typeof window?null:window},en=function(e,t){if("object"!==(void 0===e?"undefined":Zt(e))||"function"!=typeof e.createPolicy)return null;var n=null,o="data-tt-policy-suffix",r="dompurify"+((n=t.currentScript&&t.currentScript.hasAttribute(o)?t.currentScript.getAttribute(o):n)?"#"+n:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},tn=function t(e){function u(e){return t(e)}var l=0<arguments.length&&void 0!==e?e:Jt();if(u.version="2.2.6",u.removed=[],!l||!l.document||9!==l.document.nodeType)return u.isSupported=!1,u;var s=l.document,i=l.document,c=l.DocumentFragment,n=l.HTMLTemplateElement,d=l.Node,a=l.Element,o=l.NodeFilter,r=l.NamedNodeMap,f=void 0===r?l.NamedNodeMap||l.MozNamedAttrMap:r,p=l.Text,m=l.Comment,g=l.DOMParser,e=l.trustedTypes,r=a.prototype,h=_t(r,"cloneNode"),v=_t(r,"nextSibling"),y=_t(r,"childNodes"),b=_t(r,"parentNode");"function"!=typeof n||(n=i.createElement("template")).content&&n.content.ownerDocument&&(i=n.content.ownerDocument);var x=en(e,s),w=x&&ee?x.createHTML(""):"",T=i.implementation,C=i.createNodeIterator,S=i.getElementsByTagName,k=i.createDocumentFragment,D=s.importNode,E={};try{E=Rt(i).documentMode?i.documentMode:{}}catch(e){}var N={};u.isSupported=T&&void 0!==T.createHTMLDocument&&9!==E;function M(e){ce&&ce===e||(e=Rt(e=e&&"object"===(void 0===e?"undefined":Zt(e))?e:{}),I="ALLOWED_TAGS"in e?At({},e.ALLOWED_TAGS):B,P="ALLOWED_ATTR"in e?At({},e.ALLOWED_ATTR):j,le="ADD_URI_SAFE_ATTR"in e?At(Rt(se),e.ADD_URI_SAFE_ATTR):se,ie="ADD_DATA_URI_TAGS"in e?At(Rt(ae),e.ADD_DATA_URI_TAGS):ae,U="FORBID_TAGS"in e?At({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?At({},e.FORBID_ATTR):{},A="USE_PROFILES"in e&&e.USE_PROFILES,V=!1!==e.ALLOW_ARIA_ATTR,q=!1!==e.ALLOW_DATA_ATTR,G=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=e.SAFE_FOR_TEMPLATES||!1,Y=e.WHOLE_DOCUMENT||!1,Z=e.RETURN_DOM||!1,Q=e.RETURN_DOM_FRAGMENT||!1,J=!1!==e.RETURN_DOM_IMPORT,ee=e.RETURN_TRUSTED_TYPE||!1,X=e.FORCE_BODY||!1,te=!1!==e.SANITIZE_DOM,ne=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||L,$&&(q=!1),Q&&(Z=!0),A&&(I=At({},[].concat(Qt(Bt))),P=[],!0===A.html&&(At(I,Ft),At(P,Pt)),!0===A.svg&&(At(I,Ot),At(P,jt),At(P,Wt)),!0===A.svgFilters&&(At(I,Ht),At(P,jt),At(P,Wt)),!0===A.mathMl&&(At(I,Lt),At(P,Ut),At(P,Wt))),e.ADD_TAGS&&At(I=I===B?Rt(I):I,e.ADD_TAGS),e.ADD_ATTR&&At(P=P===j?Rt(P):P,e.ADD_ATTR),e.ADD_URI_SAFE_ATTR&&At(le,e.ADD_URI_SAFE_ATTR),ne&&(I["#text"]=!0),Y&&At(I,["html","head","body"]),I.table&&(At(I,["tbody"]),delete U.tbody),bt&&bt(e),ce=e)}var A,R=Vt,_=qt,F=Gt,O=$t,H=Kt,z=Xt,L=Yt,I=null,B=At({},[].concat(Qt(Ft),Qt(Ot),Qt(Ht),Qt(Lt),Qt(Bt))),P=null,j=At({},[].concat(Qt(Pt),Qt(jt),Qt(Ut),Qt(Wt))),U=null,W=null,V=!0,q=!0,G=!1,$=!1,Y=!1,K=!1,X=!1,Z=!1,Q=!1,J=!0,ee=!1,te=!0,ne=!0,oe=!1,re=At({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ie=null,ae=At({},["audio","video","img","source","image","track"]),le=null,se=At({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),ce=null,ue=i.createElement("form"),de=At({},["mi","mo","mn","ms","mtext"]),fe=At({},["foreignobject","desc","title","annotation-xml"]),pe=At({},Ot);At(pe,Ht),At(pe,zt);var me=At({},Lt);At(me,It);function ge(t){Tt(u.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=w}catch(e){t.remove()}}}function he(e,t){try{Tt(u.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Tt(u.removed,{attribute:null,from:t})}t.removeAttribute(e)}function ve(e){var t=void 0,n=void 0;X?e="<remove></remove>"+e:n=(o=St(e,/^[\r\n\t ]+/))&&o[0];var o,r=x?x.createHTML(e):e;try{t=(new g).parseFromString(r,"text/html")}catch(e){}return t&&t.documentElement||((o=(t=T.createHTMLDocument("")).body).parentNode.removeChild(o.parentNode.firstElementChild),o.outerHTML=r),e&&n&&t.body.insertBefore(i.createTextNode(n),t.body.childNodes[0]||null),S.call(t,Y?"html":"body")[0]}function ye(e){return C.call(e.ownerDocument||e,e,o.SHOW_ELEMENT|o.SHOW_COMMENT|o.SHOW_TEXT,function(){return o.FILTER_ACCEPT},!1)}function be(e){return"object"===(void 0===d?"undefined":Zt(d))?e instanceof d:e&&"object"===(void 0===e?"undefined":Zt(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function xe(e,t,n){N[e]&&xt(N[e],function(e){e.call(u,t,n,ce)})}function we(e){var t;if(xe("beforeSanitizeElements",e,null),!((n=e)instanceof p||n instanceof m||"string"==typeof n.nodeName&&"string"==typeof n.textContent&&"function"==typeof n.removeChild&&n.attributes instanceof f&&"function"==typeof n.removeAttribute&&"function"==typeof n.setAttribute&&"string"==typeof n.namespaceURI&&"function"==typeof n.insertBefore))return ge(e),1;if(St(e.nodeName,/[\u0080-\uFFFF]/))return ge(e),1;var n=Ct(e.nodeName);if(xe("uponSanitizeElement",e,{tagName:n,allowedTags:I}),!be(e.firstElementChild)&&(!be(e.content)||!be(e.content.firstElementChild))&&Nt(/<[/\w]/g,e.innerHTML)&&Nt(/<[/\w]/g,e.textContent))return ge(e),1;if(I[n]&&!U[n])return e instanceof a&&!function(e){var t=b(e);t&&t.tagName||(t={namespaceURI:Ee,tagName:"template"});var n=Ct(e.tagName),o=Ct(t.tagName);return e.namespaceURI===De?t.namespaceURI===Ee?"svg"===n:t.namespaceURI===ke?"svg"===n&&("annotation-xml"===o||de[o]):Boolean(pe[n]):e.namespaceURI===ke?t.namespaceURI===Ee?"math"===n:t.namespaceURI===De?"math"===n&&fe[o]:Boolean(me[n]):e.namespaceURI===Ee&&((t.namespaceURI!==De||fe[o])&&((t.namespaceURI!==ke||de[o])&&(o=At({},["title","style","font","a","script"]),!me[n]&&(o[n]||!pe[n]))))}(e)||("noscript"===n||"noembed"===n)&&Nt(/<\/no(script|embed)/i,e.innerHTML)?(ge(e),1):($&&3===e.nodeType&&(t=e.textContent,t=kt(t,R," "),t=kt(t,_," "),e.textContent!==t&&(Tt(u.removed,{element:e.cloneNode()}),e.textContent=t)),xe("afterSanitizeElements",e,null),0);if(ne&&!re[n])for(var o=b(e),r=y(e),i=r.length-1;0<=i;--i)o.insertBefore(h(r[i],!0),v(e));return ge(e),1}function Te(e,t,n){if(te&&("id"===t||"name"===t)&&(n in i||n in ue))return!1;if(!(q&&Nt(F,t)||V&&Nt(O,t))){if(!P[t]||W[t])return!1;if(!le[t]&&!Nt(L,kt(n,z,""))&&("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Dt(n,"data:")||!ie[e])&&(!G||Nt(H,kt(n,z,"")))&&n)return!1}return!0}function Ce(e){var t=void 0,n=void 0,o=void 0;xe("beforeSanitizeAttributes",e,null);var r=e.attributes;if(r){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P},o=r.length;o--;){var a=(t=r[o]).name,l=t.namespaceURI,n=Et(t.value),s=Ct(a);if(i.attrName=s,i.attrValue=n,i.keepAttr=!0,i.forceKeepAttr=void 0,xe("uponSanitizeAttribute",e,i),n=i.attrValue,!i.forceKeepAttr&&(he(a,e),i.keepAttr))if(Nt(/\/>/i,n))he(a,e);else{$&&(n=kt(n,R," "),n=kt(n,_," "));var c=e.nodeName.toLowerCase();if(Te(c,s,n))try{l?e.setAttributeNS(l,a,n):e.setAttribute(a,n),wt(u.removed)}catch(e){}}}xe("afterSanitizeAttributes",e,null)}}function Se(e){var t,n=ye(e);for(xe("beforeSanitizeShadowDOM",e,null);t=n.nextNode();)xe("uponSanitizeShadowNode",t,null),we(t)||(t.content instanceof c&&Se(t.content),Ce(t));xe("afterSanitizeShadowDOM",e,null)}var ke="http://www.w3.org/1998/Math/MathML",De="http://www.w3.org/2000/svg",Ee="http://www.w3.org/1999/xhtml";return u.sanitize=function(e,t){var n,o=void 0,r=void 0,i=void 0;if("string"!=typeof(e=e||"\x3c!--\x3e")&&!be(e)){if("function"!=typeof e.toString)throw Mt("toString is not a function");if("string"!=typeof(e=e.toString()))throw Mt("dirty is not a string, aborting")}if(!u.isSupported){if("object"===Zt(l.toStaticHTML)||"function"==typeof l.toStaticHTML){if("string"==typeof e)return l.toStaticHTML(e);if(be(e))return l.toStaticHTML(e.outerHTML)}return e}if(K||M(t),u.removed=[],"string"==typeof e&&(oe=!1),!oe)if(e instanceof d)1===(t=(o=ve("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===t.nodeName||"HTML"===t.nodeName?o=t:o.appendChild(t);else{if(!Z&&!$&&!Y&&-1===e.indexOf("<"))return x&&ee?x.createHTML(e):e;if(!(o=ve(e)))return Z?null:w}o&&X&&ge(o.firstChild);for(var a=ye(oe?e:o);n=a.nextNode();)3===n.nodeType&&n===r||we(n)||(n.content instanceof c&&Se(n.content),Ce(n),r=n);if(r=null,oe)return e;if(Z){if(Q)for(i=k.call(o.ownerDocument);o.firstChild;)i.appendChild(o.firstChild);else i=o;return i=J?D.call(s,i,!0):i}return e=Y?o.outerHTML:o.innerHTML,$&&(e=kt(e,R," "),e=kt(e,_," ")),x&&ee?x.createHTML(e):e},u.setConfig=function(e){M(e),K=!0},u.clearConfig=function(){ce=null,K=!1},u.isValidAttribute=function(e,t,n){return ce||M({}),e=Ct(e),t=Ct(t),Te(e,t,n)},u.addHook=function(e,t){"function"==typeof t&&(N[e]=N[e]||[],Tt(N[e],t))},u.removeHook=function(e){N[e]&&wt(N[e])},u.removeHooks=function(e){N[e]&&(N[e]=[])},u.removeAllHooks=function(){N={}},u}(),nn=window,on=document,rn=/^image\/(p?jpe?g|gif|png|bmp)$/i;function an(r,e){var a,x,u,i,l,f,d,s,o,c,p,t,m,g,h,v,y,b,n,w,T,C,S,k,D,E,N,M,A,R,_,F,O,H,z,L,I,B,P,j,U,W,V,q,G,$,Y,K,X,Z,Q,J,ee,te,ne,oe,re,ie,ae,le,se=this,ce={},ue=[],de=[],fe={},pe={},me={};se.commands=we(!0,{},e.commands||mt);var ge=se.opts=we(!0,{},ut,e);se.opts.emoticons=e.emoticons||ut.emoticons,Array.isArray(ge.allowedIframeUrls)||(ge.allowedIframeUrls=[]),ge.allowedIframeUrls.push("https://www.youtube-nocookie.com/embed/");var he=tn();function ve(e){return he.sanitize(e,{ADD_TAGS:["iframe"],ADD_ATTR:["allowfullscreen","frameborder","target"]})}he.addHook("uponSanitizeElement",function(e,t){var n=ge.allowedIframeUrls;if("iframe"===t.tagName){for(var o=He(e,"src")||"",r=0;r<n.length;r++){var i=n[r];if(ye(i)&&o.substr(0,i.length)===i)return;if(i.test&&i.test(o))return}Me(e)}}),he.addHook("afterSanitizeAttributes",function(e){"target"in e&&He(e,"data-sce-target",He(e,"target")),ze(e,"target")}),e=function(){r._sceditor=se,ge.locale&&"en"!==ge.locale&&A(),We(x=De("div",{className:"sceditor-container"}),r),Pe(x,"z-index",ge.zIndex),n=r.required,r.required=!1;var e=an.formats[ge.format];a=e?new e:{},g=new gt(se),(ge.plugins||"").split(",").forEach(function(e){g.register(e.trim())}),"init"in a&&a.init.call(se),H(),R(),M(),_(),F(),yt||se.toggleSourceMode(),Y();var t=function(){Oe(nn,"load",t),ge.autofocus&&J(!!ge.autofocusEnd),le(),X(),g.call("ready"),"onReady"in a&&a.onReady.call(se)};Fe(nn,"load",t),"complete"===on.readyState&&t()},A=function(){var e;(t=an.locale[ge.locale])||(e=ge.locale.split("-"),t=an.locale[e[0]]),t&&t.dateFormat&&(ge.dateFormat=t.dateFormat)},M=function(){s=De("textarea"),i=De("iframe",{frameborder:0,allowfullscreen:!0}),ge.startInSourceMode?(qe(x,"sourceMode"),Le(i)):(qe(x,"wysiwygMode"),Le(s)),ge.spellcheck||He(x,"spellcheck","false"),"https:"===nn.location.protocol&&He(i,"src","about:blank"),Ae(x,i),Ae(x,s),se.dimensions(ge.width||Ye(r),ge.height||Ke(r));var e=vt?" ios":"";(d=i.contentDocument).open(),d.write(pt("html",{attrs:' class="'+e+'"',spellcheck:ge.spellcheck?"":'spellcheck="false"',charset:ge.charset,style:ge.style})),d.close(),f=d.body,l=i.contentWindow,se.readOnly(!!ge.readOnly),vt&&(Ke(f,"100%"),Fe(f,"touchend",se.focus));e=He(r,"tabindex");He(s,"tabindex",e),He(i,"tabindex",e),m=new ht(l,null,ve),Le(r),se.val(r.value);e=ge.placeholder||He(r,"placeholder");e&&(s.placeholder=e,He(f,"placeholder",e))},_=function(){ge.autoUpdate&&(Fe(f,"blur",ae),Fe(s,"blur",ae)),null===ge.rtl&&(ge.rtl="rtl"===Pe(s,"direction")),se.rtl(!!ge.rtl),ge.autoExpand&&(Fe(f,"load",le,_e),Fe(f,"input keyup",le)),ge.resizeEnabled&&O(),He(x,"id",ge.id),se.emoticons(ge.emoticonsEnabled)},F=function(){var e=r.form,t="compositionstart compositionend",n="keydown keyup keypress focus blur contextmenu input",o="onselectionchange"in d?"selectionchange":"keyup focus blur contextmenu mouseup touchend click";Fe(on,"click",G),e&&(Fe(e,"reset",U),Fe(e,"submit",se.updateOriginal,_e)),Fe(window,"pagehide",se.updateOriginal),Fe(window,"pageshow",U),Fe(f,"keypress",j),Fe(f,"keydown",B),Fe(f,"keydown",P),Fe(f,"keyup",X),Fe(f,"blur",re),Fe(f,"keyup",ie),Fe(f,"paste",z),Fe(f,"cut copy",L),Fe(f,t,V),Fe(f,o,Z),Fe(f,n,q),ge.emoticonsCompat&&nn.getSelection&&Fe(f,"keyup",te),Fe(f,"blur",function(){se.val()||qe(f,"placeholder")}),Fe(f,"focus",function(){Ge(f,"placeholder")}),Fe(s,"blur",re),Fe(s,"keyup",ie),Fe(s,"keydown",B),Fe(s,t,V),Fe(s,n,q),Fe(d,"mousedown",W),Fe(d,o,Z),Fe(d,"keyup",X),Fe(x,"selectionchanged",Q),Fe(x,"selectionchanged",Y),Fe(x,"selectionchanged valuechanged nodechanged pasteraw paste",q)},R=function(){var i,a=se.commands,l=(ge.toolbarExclude||"").split(","),e=ge.toolbar.split("|");u=De("div",{className:"sceditor-toolbar",unselectable:"on"}),ge.icons in an.icons&&(D=new an.icons[ge.icons]),Ce(e,function(e,t){i=De("div",{className:"sceditor-group"}),Ce(t.split(","),function(e,t){var n,o,r=a[t];!r||-1<l.indexOf(t)||(n=r.shortcut,o=pt("toolbarButton",{name:t,dispName:se._(r.name||r.tooltip||t)},!0).firstChild,D&&D.create&&D.create(t)&&(We(D.create(t),o.firstChild),qe(o,"has-icon")),o._sceTxtMode=!!r.txtExec,o._sceWysiwygMode=!!r.exec,$e(o,"disabled",!r.exec),Fe(o,"click",function(e){Ve(o,"disabled")||N(o,r),Y(),e.preventDefault()}),Fe(o,"mousedown",function(e){se.closeDropDown(),e.preventDefault()}),r.tooltip&&He(o,"title",se._(r.tooltip)+(n?" ("+n+")":"")),n&&se.addShortcut(n,t),r.state?de.push({name:t,state:r.state}):ye(r.exec)&&de.push({name:t,state:r.exec}),Ae(i,o),pe[t]=o)}),i.firstChild&&Ae(u,i)}),Ae(ge.toolbarContainer||x,u)},O=function(){var e=De("div",{className:"sceditor-grip"}),t=De("div",{className:"sceditor-resize-cover"}),n="touchmove mousemove",o="touchcancel touchend mouseup",r=0,i=0,a=0,l=0,s=0,c=0,u=Ye(x),d=Ke(x),f=!1,p=se.rtl(),m=ge.resizeMinHeight||d/1.5,g=ge.resizeMaxHeight||2.5*d,h=ge.resizeMinWidth||u/1.25,v=ge.resizeMaxWidth||1.25*u,y=function(e){l="touchmove"===e.type?(e=nn.event,a=e.changedTouches[0].pageX,e.changedTouches[0].pageY):(a=e.pageX,e.pageY);var t=c+(l-i),n=p?s-(a-r):s+(a-r);0<v&&v<n&&(n=v),0<h&&n<h&&(n=h),ge.resizeWidth||(n=!1),0<g&&g<t&&(t=g),0<m&&t<m&&(t=m),ge.resizeHeight||(t=!1),(n||t)&&se.dimensions(n,t),e.preventDefault()},b=function(e){f&&(f=!1,Le(t),Ge(x,"resizing"),Oe(on,n,y),Oe(on,o,b),e.preventDefault())};D&&D.create&&((u=D.create("grip"))&&(Ae(e,u),qe(e,"has-icon"))),Ae(x,e),Ae(x,t),Le(t),Fe(e,"touchstart mousedown",function(e){i="touchstart"===e.type?(e=nn.event,r=e.touches[0].pageX,e.touches[0].pageY):(r=e.pageX,e.pageY),s=Ye(x),c=Ke(x),f=!0,qe(x,"resizing"),Ie(t),Fe(on,n,y),Fe(on,o,b),e.preventDefault()})},H=function(){var e=ge.emoticons,n=ge.emoticonsRoot||"";Ce(me=e?we({},e.more,e.dropdown,e.hidden):me,function(e,t){me[e]=pt("emoticon",{key:e,url:n+(t.url||t),tooltip:t.tooltip||e}),ge.emoticonsEnabled&&ue.push(De("img",{src:n+(t.url||t)}))})},J=function(e){var t,n=f.firstChild;if(Ze(x)){if(se.sourceMode())return t=e?s.value.length:0,void s.setSelectionRange(t,t);if(at(f),e)for((n=f.lastChild)||(n=De("p",{},d),Ae(f,n));n.lastChild;)Ue(n=n.lastChild,"br")&&n.previousSibling&&(n=n.previousSibling);t=d.createRange(),ot(n)?t.selectNodeContents(n):(t.setStartBefore(n),e&&t.setStartAfter(n)),t.collapse(!e),m.selectRange(t),y=t,e&&(f.scrollTop=f.scrollHeight),se.focus()}},se.readOnly=function(e){return"boolean"!=typeof e?!s.readonly:(f.contentEditable=!e,s.readonly=!e,$(e),se)},se.rtl=function(e){var t=e?"rtl":"ltr";return"boolean"!=typeof e?"rtl"===He(s,"dir"):(He(f,"dir",t),He(s,"dir",t),Ge(x,"rtl"),Ge(x,"ltr"),qe(x,t),D&&D.rtl&&D.rtl(e),se)},$=function(n){var o=se.inSourceMode()?"_sceTxtMode":"_sceWysiwygMode";Ce(pe,function(e,t){$e(t,"disabled",n||!t[o])})},se.width=function(e,t){return e||0===e?(se.dimensions(e,null,t),se):Ye(x)},se.dimensions=function(e,t,n){return t=!(!t&&0!==t)&&t,!1===(e=!(!e&&0!==e)&&e)&&!1===t?{width:se.width(),height:se.height()}:(!1!==e&&(!1!==n&&(ge.width=e),Ye(x,e)),!1!==t&&(!1!==n&&(ge.height=t),Ke(x,t)),se)},se.height=function(e,t){return e||0===e?(se.dimensions(null,e,t),se):Ke(x)},se.maximize=function(e){var t="sceditor-maximize";return be(e)?Ve(x,t):((e=!!e)&&(S=nn.pageYOffset),$e(on.documentElement,t,e),$e(on.body,t,e),$e(x,t,e),se.width(e?"100%":ge.width,!1),se.height(e?"100%":ge.height,!1),e||nn.scrollTo(0,S),le(),se)},le=function(){ge.autoExpand&&!C&&(C=setTimeout(se.expandToContent,200))},se.expandToContent=function(e){var t,n;se.maximize()||(clearTimeout(C),C=!1,T||(t=ge.resizeMinHeight||ge.height||Ke(r),T={min:t,max:ge.resizeMaxHeight||2*t}),(n=on.createRange()).selectNodeContents(f),t=n.getBoundingClientRect(),n=d.documentElement.clientHeight-1,t=t.bottom-t.top,n=se.height()+1+(t-n),e||-1===T.max||(n=Math.min(n,T.max)),se.height(Math.ceil(Math.max(n,T.min))))},se.destroy=function(){var e;g&&(g.destroy(),g=m=null,o&&Me(o),Oe(on,"click",G),(e=r.form)&&(Oe(e,"reset",U),Oe(e,"submit",se.updateOriginal,_e)),Oe(window,"pagehide",se.updateOriginal),Oe(window,"pageshow",U),Me(s),Me(u),Me(x),delete r._sceditor,Ie(r),r.required=n)},se.createDropDown=function(e,t,n){t="sceditor-"+t;se.closeDropDown(),o&&Ve(o,t)||(e=we({top:e.offsetTop,left:e.offsetLeft,marginTop:e.clientHeight},ge.dropDownCss),Pe(o=De("div",{className:"sceditor-dropdown "+t}),e),Ae(o,n),Ae(x,o),Fe(o,"click focusin",function(e){e.stopPropagation()}),!o||(n=Re(o,"input,textarea")[0])&&n.focus())},G=function(e){3!==e.which&&o&&!e.defaultPrevented&&(ae(),se.closeDropDown())},L=function(e){var t=m.selectedRange();if(t){for(var n,o,r=De("div",{},d),i=t.commonAncestorContainer;i&&rt(i,!0);)i.nodeType===Se&&(o=i.cloneNode(),r.firstChild&&Ae(o,r.firstChild),Ae(r,o),n=n||o),i=i.parentNode;Ae(n||r,t.cloneContents()),at(r),e.clipboardData.setData("text/html",r.innerHTML),Ce(Re(r,"p"),function(e,t){nt(t,"div")}),Ce(Re(r,"br"),function(e,t){t.nextSibling&&rt(t.nextSibling,!0)||Me(t)}),Ae(f,r),e.clipboardData.setData("text/plain",r.innerText),Me(r),"cut"===e.type&&t.deleteContents(),e.preventDefault()}},z=function(e){var t,n,o=f,r=e.clipboardData;if(r){var i={},a=r.types,l=r.items;e.preventDefault();for(var s=0;s<a.length;s++){if(a.indexOf("text/html")<0&&nn.FileReader&&l&&rn.test(l[s].type))return t=r.items[s].getAsFile(),n=void 0,(n=new FileReader).onload=function(e){I({html:'<img src="'+e.target.result+'" />'})},void n.readAsDataURL(t);i[a[s]]=r.getData(a[s])}i.text=i["text/plain"],i.html=ve(i["text/html"]),I(i)}else if(!k){var c=o.scrollTop;for(m.saveRange(),k=on.createDocumentFragment();o.firstChild;)Ae(k,o.firstChild);setTimeout(function(){var e=o.innerHTML;o.innerHTML="",Ae(o,k),o.scrollTop=c,k=!1,m.restoreRange(),I({html:ve(e)})},0)}},I=function(e){var t=De("div",{},d);g.call("pasteRaw",e),Xe(x,"pasteraw",e),e.html?(t.innerHTML=ve(e.html),it(t)):t.innerHTML=ft(e.text||"");e={val:t.innerHTML};"fragmentToSource"in a&&(e.val=a.fragmentToSource(e.val,d,h)),g.call("paste",e),Xe(x,"paste",e),"fragmentToHtml"in a&&(e.val=a.fragmentToHtml(e.val,h)),g.call("pasteHtml",e);t=m.getFirstBlockParent();se.wysiwygEditorInsertHtml(e.val,null,!0),function e(t){if(t.nodeType===Se){for(var n=t.parentNode,o=t.tagName,r=t.childNodes.length;r--;)e(t.childNodes[r]);if(rt(t)){for(r=t.style.length;r--;){var i=t.style[r];Pe(n,i)===Pe(t,i)&&t.style.removeProperty(i)}if(!t.style.length)if(ze(t,"style"),"FONT"===o&&(Pe(t,"fontFamily").toLowerCase()===Pe(n,"fontFamily").toLowerCase()&&ze(t,"face"),Pe(t,"color")===Pe(n,"color")&&ze(t,"color"),Pe(t,"fontSize")===Pe(n,"fontSize")&&ze(t,"size")),!t.attributes.length&&/SPAN|FONT/.test(o))ct(t);else if(/B|STRONG|EM|SPAN|FONT/.test(o))for(var a=/B|STRONG/.test(o),l="EM"===o;n&&rt(n)&&(!a||/bold|700/i.test(Pe(n,"fontWeight")))&&(!l||"italic"===Pe(n,"fontStyle"));){if((n.tagName===o||a&&/B|STRONG/.test(n.tagName))&&st(n,t)){ct(t);break}n=n.parentNode}var s=t.nextSibling;s&&s.tagName===o&&st(s,t)&&(Ae(t,s),ct(s))}}}(t)},se.closeDropDown=function(e){o&&(Me(o),o=null),!0===e&&se.focus()},se.wysiwygEditorInsertHtml=function(e,t,n){var o=Ke(i);se.focus(),!n&&Ne(v,"code")||(m.insertHTML(e,t),m.saveRange(),E(),it(f),Ie(n=Re(f,"#sceditor-end-marker")[0]),e=f.scrollTop,t=lt(n).top+1.5*n.offsetHeight-o,Le(n),(e<t||t+o<e)&&(f.scrollTop=t),oe(!1),m.restoreRange(),X())},se.wysiwygEditorInsertText=function(e,t){se.wysiwygEditorInsertHtml(ft(e),ft(t))},se.insertText=function(e,t){return se.inSourceMode()?se.sourceEditorInsertText(e,t):se.wysiwygEditorInsertText(e,t),se},se.sourceEditorInsertText=function(e,t){var n,o=s.selectionStart,r=s.selectionEnd,i=s.scrollTop;s.focus(),n=s.value,t&&(e+=n.substring(o,r)+t),s.value=n.substring(0,o)+e+n.substring(r,n.length),s.selectionStart=o+e.length-(t?t.length:0),s.selectionEnd=s.selectionStart,s.scrollTop=i,s.focus(),oe()},se.getRangeHelper=function(){return m},se.sourceEditorCaret=function(e){return s.focus(),e?(s.selectionStart=e.start,s.selectionEnd=e.end,this):{start:s.selectionStart,end:s.selectionEnd}},se.val=function(e,t){return ye(e)?(se.inSourceMode()?se.setSourceEditorValue(e):(!1!==t&&"toHtml"in a&&(e=a.toHtml(e)),se.setWysiwygEditorValue(e)),se):se.inSourceMode()?se.getSourceEditorValue(!1):se.getWysiwygEditorValue(t)},se.insert=function(e,t,n,o,r){return se.inSourceMode()?se.sourceEditorInsertText(e,t):(t&&(i=m.selectedHtml(),e+=(i=!1!==n&&"fragmentToSource"in a?a.fragmentToSource(i,d,h):i)+t),!1!==n&&"fragmentToHtml"in a&&(e=a.fragmentToHtml(e,h)),!1!==n&&!0===r&&(e=e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")),se.wysiwygEditorInsertHtml(e)),se;var i},se.getWysiwygEditorValue=function(e){for(var t,n=De("div",{},d),o=f.childNodes,r=0;r<o.length;r++)Ae(n,o[r].cloneNode(!0));return Ae(f,n),it(n),Me(n),t=n.innerHTML,t=!1!==e&&a.hasOwnProperty("toSource")?a.toSource(t,d):t},se.getBody=function(){return f},se.getContentAreaContainer=function(){return i},se.getSourceEditorValue=function(e){var t=s.value;return t=!1!==e&&"toHtml"in a?a.toHtml(t):t},se.setWysiwygEditorValue=function(e){e=e||"<p><br /></p>",f.innerHTML=ve(e),E(),X(),oe(),le()},se.setSourceEditorValue=function(e){s.value=e,oe()},se.updateOriginal=function(){r.value=se.val()},E=function(){var e,l,s,c,t,u,d;ge.emoticonsEnabled&&(e=f,l=me,s=ge.emoticonsCompat,c=e.ownerDocument,t="(^|\\s| | | | |$)",u=[],d={},Ee(e,"code")||(Ce(l,function(e){d[e]=new RegExp(t+dt(e)+t),u.push(e)}),u.sort(function(e,t){return t.length-e.length}),function e(t){for(t=t.firstChild;t;){if(t.nodeType!==Se||Ue(t,"code")||e(t),t.nodeType===ke)for(var n=0;n<u.length;n++){var o,r=t.nodeValue,i=u[n],a=s?r.search(d[i]):r.indexOf(i);-1<a&&(o=r.indexOf(i,a),a=et(l[i],c),i=r.substr(o+i.length),a.appendChild(c.createTextNode(i)),t.nodeValue=r.substr(0,o),t.parentNode.insertBefore(a,t.nextSibling))}t=t.nextSibling}}(e)))},se.inSourceMode=function(){return Ve(x,"sourceMode")},se.sourceMode=function(e){var t=se.inSourceMode();return"boolean"!=typeof e?t:((t&&!e||!t&&e)&&se.toggleSourceMode(),se)},se.toggleSourceMode=function(){var e=se.inSourceMode();!yt&&e||(e||(m.saveRange(),m.clear()),y=null,se.blur(),e?se.setWysiwygEditorValue(se.getSourceEditorValue()):se.setSourceEditorValue(se.getWysiwygEditorValue()),Be(s),Be(i),$e(x,"wysiwygMode",e),$e(x,"sourceMode",!e),$(),Y())},K=function(){return s.focus(),s.value.substring(s.selectionStart,s.selectionEnd)},N=function(e,t){se.inSourceMode()?t.txtExec&&(Array.isArray(t.txtExec)?se.sourceEditorInsertText.apply(se,t.txtExec):t.txtExec.call(se,e,K())):t.exec&&(xe(t.exec)?t.exec.call(se,e):se.execCommand(t.exec,t.hasOwnProperty("execParam")?t.execParam:null))},se.execCommand=function(e,t){var n=!1,o=se.commands[e];if(se.focus(),!Ne(m.parentNode(),"code")){try{n=d.execCommand(e,!1,t)}catch(e){}!n&&o&&o.errorMessage&&alert(se._(o.errorMessage)),Y()}},Z=function(){function e(){if(l.getSelection()&&l.getSelection().rangeCount<=0)y=null;else if(m&&!m.compare(y)){if((y=m.cloneSelected())&&y.collapsed){var e=y.startContainer,t=y.startOffset;for(t&&e.nodeType!==ke&&(e=e.childNodes[t]);e&&e.parentNode!==f;)e=e.parentNode;e&&rt(e,!0)&&(m.saveRange(),n=d,Qe(f,function(e){rt(e,!0)?(o||e.nodeType===ke?/\S/.test(e.nodeValue):!Ue(e,".sceditor-ignore"))&&(o||We(o=De("p",{},n),e),Ae(o,e)):o=null},!1,!0),m.restoreRange())}Xe(x,"selectionchanged")}var n,o;b=!1}b||(b=!0,"onselectionchange"in d?e():setTimeout(e,100))},Q=function(){var e,t=m.parentNode();h!==t&&(e=h,h=t,v=m.getFirstBlockParent(t),Xe(x,"nodechanged",{oldNode:e,newNode:h}))},se.currentNode=function(){return h},se.currentBlockNode=function(){return v},Y=function(){var e,t,n="active",o=d,r=se.sourceMode();if(se.readOnly())Ce(Re(u,n),function(e,t){Ge(t,n)});else{r||(t=m.parentNode(),e=m.getFirstBlockParent(t));for(var i=0;i<de.length;i++){var a=0,l=pe[de[i].name],s=de[i].state,c=r&&!l._sceTxtMode||!r&&!l._sceWysiwygMode;if(ye(s)){if(!r)try{-1<(a=o.queryCommandEnabled(s)?0:-1)&&(a=o.queryCommandState(s)?1:0)}catch(e){}}else c||(a=s.call(se,t,e));$e(l,"disabled",c||a<0),$e(l,n,0<a)}D&&D.update&&D.update(r,t,e)}},j=function(e){var t,n,o;e.defaultPrevented||(se.closeDropDown(),13!==e.which||!Ue(v,"li,ul,ol")&&tt(v)&&(t=De("br",{},d),m.insertNode(t),(o=(n=t.parentNode).lastChild)&&o.nodeType===ke&&""===o.nodeValue&&(Me(o),o=n.lastChild),!rt(n,!0)&&o===t&&rt(t.previousSibling)&&m.insertHTML("<br>"),e.preventDefault()))},X=function(){Je(f,function(e){if(e.nodeType===Se&&!/inline/.test(Pe(e,"display"))&&!Ue(e,".sceditor-nlf")&&tt(e)){var t=De("p",{},d);return t.className="sceditor-nlf",t.innerHTML="<br />",Ae(f,t),!1}if(3===e.nodeType&&!/^\s*$/.test(e.nodeValue)||Ue(e,"br"))return!1})},U=function(){se.val(r.value)},W=function(){se.closeDropDown()},se._=function(){var n=arguments;return t&&t[n[0]]&&(n[0]=t[n[0]]),n[0].replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[+t+1]?n[+t+1]:"{"+t+"}"})},q=function(t){g&&g.call(t.type+"Event",t,se);var e=(t.target===s?"scesrc":"scewys")+t.type;ce[e]&&ce[e].forEach(function(e){e.call(se,t)})},se.bind=function(e,t,n,o){for(var r,i,a=(e=e.split(" ")).length;a--;)xe(t)&&(r="scewys"+e[a],i="scesrc"+e[a],n||(ce[r]=ce[r]||[],ce[r].push(t)),o||(ce[i]=ce[i]||[],ce[i].push(t)),"valuechanged"===e[a]&&(oe.hasHandler=!0));return se},se.unbind=function(e,t,n,o){for(var r=(e=e.split(" ")).length;r--;)xe(t)&&(n||Te(ce["scewys"+e[r]]||[],t),o||Te(ce["scesrc"+e[r]]||[],t));return se},se.blur=function(e,t,n){return xe(e)?se.bind("blur",e,t,n):(se.sourceMode()?s:f).blur(),se},se.focus=function(e,t,n){if(xe(e))se.bind("focus",e,t,n);else if(se.inSourceMode())s.focus();else{if(Re(d,":focus").length)return;var o,n=m.selectedRange();y||J(!0),n&&1===n.endOffset&&n.collapsed&&(o=n.endContainer)&&1===o.childNodes.length&&Ue(o.firstChild,"br")&&(n.setStartBefore(o.firstChild),n.collapse(!0),m.selectRange(n)),l.focus(),f.focus()}return Y(),se},se.keyDown=function(e,t,n){return se.bind("keydown",e,t,n)},se.keyPress=function(e,t,n){return se.bind("keypress",e,t,n)},se.keyUp=function(e,t,n){return se.bind("keyup",e,t,n)},se.nodeChanged=function(e){return se.bind("nodechanged",e,!1,!0)},se.selectionChanged=function(e){return se.bind("selectionchanged",e,!1,!0)},se.valueChanged=function(e,t,n){return se.bind("valuechanged",e,t,n)},ee=function(e){var n=0,o=se.emoticonsCache,t=String.fromCharCode(e.which);Ne(v,"code")||(o||(o=[],Ce(me,function(e,t){o[n++]=[e,t]}),o.sort(function(e,t){return e[0].length-t[0].length}),se.emoticonsCache=o,se.longestEmoticonCode=o[o.length-1][0].length),m.replaceKeyword(se.emoticonsCache,!0,!0,se.longestEmoticonCode,ge.emoticonsCompat,t)&&(ge.emoticonsCompat&&/^\s$/.test(t)||e.preventDefault()))},te=function(){!function(e,t){var n=/[^\s\xA0\u2002\u2003\u2009]+/,o=e&&Re(e,"img[data-sceditor-emoticon]");if(e&&o.length)for(var r=0;r<o.length;r++){var i,a,l,s,c=o[r],u=c.parentNode,d=c.previousSibling,f=c.nextSibling;(d&&n.test(d.nodeValue.slice(-1))||f&&n.test((f.nodeValue||"")[0]))&&(a=-1,l=(i=t.cloneSelected()).startContainer,s=d.nodeValue||"",s+=je(c,"sceditor-emoticon"),l===f&&(a=s.length+i.startOffset),l===e&&e.childNodes[i.startOffset]===f&&(a=s.length),l===d&&(a=i.startOffset),(f=!f||f.nodeType!==ke?u.insertBefore(u.ownerDocument.createTextNode(""),f):f).insertData(0,s),Me(d),Me(c),-1<a&&(i.setStart(f,a),i.collapse(!0),t.selectRange(i)))}}(v,m)},se.emoticons=function(e){return e||!1===e?((ge.emoticonsEnabled=e)?(Fe(f,"keypress",ee),se.sourceMode()||(m.saveRange(),E(),oe(!1),m.restoreRange())):(Ce(Re(f,"img[data-sceditor-emoticon]"),function(e,t){var n=je(t,"sceditor-emoticon"),n=d.createTextNode(n);t.parentNode.replaceChild(n,t)}),Oe(f,"keypress",ee),oe()),se):ge.emoticonsEnabled},se.css=function(e){return w||(w=De("style",{id:"inline"},d),Ae(d.head,w)),ye(e)?(w.styleSheet?w.styleSheet.cssText=e:w.innerHTML=e,se):w.styleSheet?w.styleSheet.cssText:w.innerHTML},B=function(e){var t=[],n={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|","[":"{","]":"}"},o={109:"-",110:"del",111:"/",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},r=e.which,i={8:"backspace",9:"tab",13:"enter",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"win",92:"win",93:"select",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}[r]||String.fromCharCode(r).toLowerCase();(e.ctrlKey||e.metaKey)&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&(t.push("shift"),o[r]?i=o[r]:n[i]&&(i=n[i])),i&&(r<16||18<r)&&t.push(i),t=t.join("+"),fe[t]&&!1===fe[t].call(se)&&(e.stopPropagation(),e.preventDefault())},se.addShortcut=function(e,t){return e=e.toLowerCase(),ye(t)?fe[e]=function(){return N(pe[t],se.commands[t]),!1}:fe[e]=t,se},se.removeShortcut=function(e){return delete fe[e.toLowerCase()],se},P=function(e){var t,n,o;if(!ge.disableBlockRemove&&8===e.which&&(n=m.selectedRange())&&(t=n.startContainer,0===n.startOffset&&(o=ne())&&!Ue(o,"body"))){for(;t!==o;){for(;t.previousSibling;)if((t=t.previousSibling).nodeType!==ke||t.nodeValue)return;if(!(t=t.parentNode))return}se.clearBlockFormatting(o),e.preventDefault()}},ne=function(){for(var e=v;!tt(e)||rt(e,!0);)if(!(e=e.parentNode)||Ue(e,"body"))return;return e},se.clearBlockFormatting=function(e){return!(e=e||ne())||Ue(e,"body")||(m.saveRange(),e.className="",He(e,"style",""),Ue(e,"p,div,td")||nt(e,"p"),m.restoreRange()),se},oe=function(e){var t,n,o;g&&(g.hasHandler("valuechangedEvent")||oe.hasHandler)&&(o=!(n=se.sourceMode())&&m.hasSelection(),e=(c=!1)!==e&&!d.getElementById("sceditor-start-marker"),p&&(clearTimeout(p),p=!1),o&&e&&m.saveRange(),(t=n?s.value:f.innerHTML)!==oe.lastVal&&(oe.lastVal=t,Xe(x,"valuechanged",{rawValue:n?se.val():t})),o&&e&&m.removeMarkers())},re=function(){p&&oe()},ie=function(e){var t=e.which,n=ie.lastChar,e=13===n||32===n,n=8===n||46===n;ie.lastChar=t,c||(13===t||32===t?e?ie.triggerNext=!0:oe():8===t||46===t?n?ie.triggerNext=!0:oe():ie.triggerNext&&(oe(),ie.triggerNext=!1),clearTimeout(p),p=setTimeout(function(){c||oe()},1500))},V=function(e){(c=/start/i.test(e.type))||oe()},ae=function(){se.updateOriginal()},e()}an.locale={},an.formats={},an.icons={},an.command={get:function(e){return mt[e]||null},set:function(e,t){return!(!e||!t)&&((t=we(mt[e]||{},t)).remove=function(){an.command.remove(e)},mt[e]=t,this)},remove:function(e){return mt[e]&&delete mt[e],this}},window.sceditor={command:an.command,commands:mt,defaultOptions:ut,ios:vt,isWysiwygSupported:yt,regexEscape:dt,escapeEntities:ft,escapeUriScheme:function(e){var t,n=window.location;return e&&/^[^\/]*:/i.test(e)&&!m.test(e)?((t=n.pathname.split("/")).pop(),n.protocol+"//"+n.host+t.join("/")+"/"+e):e},dom:{css:Pe,attr:He,removeAttr:ze,is:Ue,closest:Ne,width:Ye,height:Ke,traverse:Qe,rTraverse:Je,parseHTML:et,hasStyling:tt,convertElement:nt,blockLevelList:c,canHaveChildren:ot,isInline:rt,copyCSS:function(e,t){t.style&&e.style&&(t.style.cssText=e.style.cssText+t.style.cssText)},fixNesting:it,findCommonAncestor:function(e,t){for(;e=e.parentNode;)if((n=e)!==(o=t)&&n.contains&&n.contains(o))return e;var n,o},getSibling:u,removeWhiteSpace:at,extractContents:f,getOffset:lt,getStyle:p,hasStyle:function(e,t,n){return!!(t=p(e,t))&&(!n||t===n||Array.isArray(n)&&-1<n.indexOf(t))}},locale:an.locale,icons:an.icons,utils:{each:Ce,isEmptyObject:n,extend:we},plugins:gt.plugins,formats:an.formats,create:function(e,t){t=t||{},Ee(e,".sceditor-container")||(t.runWithoutWysiwygSupport||yt)&&new an(e,t)},instance:function(e){return e._sceditor}},o.default.sceditor=window.sceditor,o.default.fn.sceditor=function(e){var t,n=[];return this.each(function(){t=this._sceditor,"state"===e?n.push(!!t):"instance"===e?n.push(t):t||o.default.sceditor.create(this,e)}),n.length?1===n.length?n[0]:n:this}}(); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/jquery.sceditor.xhtml.min.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(){"use strict";var o=(A=jQuery)&&"object"==typeof A&&"default"in A?A:{default:A};function e(e,t){return typeof t===e}var ye=e.bind(null,"string"),be=e.bind(null,"undefined"),xe=e.bind(null,"function"),r=e.bind(null,"number");function t(e){return!Object.keys(e).length}function we(e,t){var n=e===!!e,o=n?2:1,r=n?t:e,i=n&&e;function a(e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype}for(;o<arguments.length;o++){var l,s=arguments[o];for(l in s){var c,u,d=r[l],f=s[l];be(f)||"__proto__"!==l&&"constructor"!==l&&(u=a(f),c=Array.isArray(f),i&&(u||c)?(u=a(d)===u&&Array.isArray(d)===c,r[l]=we(!0,u?d:c?[]:{},f)):r[l]=f)}}return r}function Te(e,t){-1<(t=e.indexOf(t))&&e.splice(t,1)}function Ce(t,n){if(Array.isArray(t)||"length"in t&&r(t.length))for(var e=0;e<t.length;e++)n(e,t[e]);else Object.keys(t).forEach(function(e){n(e,t[e])})}var i={},Se=1,ke=3,l=8;function a(e){return e=parseFloat(e),isFinite(e)?e:0}function Ee(e,t,n){var o=(n||document).createElement(e);return Ce(t||{},function(e,t){"style"===e?o.style.cssText=t:e in o?o[e]=t:o.setAttribute(e,t)}),o}function De(e,t){for(var n=e||{};(n=n.parentNode)&&!/(9|11)/.test(n.nodeType);)if(!t||Ue(n,t))return n}function Ne(e,t){return Ue(e,t)?e:De(e,t)}function Ae(e){e.parentNode&&e.parentNode.removeChild(e)}function Me(e,t){e.appendChild(t)}function Re(e,t){return e.querySelectorAll(t)}var _e=!0;function Oe(n,e,o,r,i){e.split(" ").forEach(function(e){var t;ye(o)?(t=r["_sce-event-"+e+o]||function(e){for(var t=e.target;t&&t!==n;){if(Ue(t,o))return void r.call(t,e);t=t.parentNode}},r["_sce-event-"+e+o]=t):(t=o,i=r),n.addEventListener(e,t,i||!1)})}function Fe(n,e,o,r,i){e.split(" ").forEach(function(e){var t;ye(o)?t=r["_sce-event-"+e+o]:(t=o,i=r),n.removeEventListener(e,t,i||!1)})}function ze(e,t,n){if(arguments.length<3)return e.getAttribute(t);null==n?He(e,t):e.setAttribute(t,n)}function He(e,t){e.removeAttribute(t)}function Le(e){Pe(e,"display","none")}function Ie(e){Pe(e,"display","")}function Be(e){(Ze(e)?Le:Ie)(e)}function Pe(n,e,t){if(arguments.length<3){if(ye(e))return 1===n.nodeType?getComputedStyle(n)[e]:null;Ce(e,function(e,t){Pe(n,e,t)})}else{var o=(t||0===t)&&!isNaN(t);n.style[e]=o?t+"px":t}}function je(e,t,n){var o=arguments.length,r={};if(e.nodeType===Se)return 1===o?(Ce(e.attributes,function(e,t){/^data\-/i.test(t.name)&&(r[t.name.substr(5)]=t.value)}),r):2===o?ze(e,"data-"+t):void ze(e,"data-"+t,String(n))}function Ue(e,t){var n=!1;return e&&e.nodeType===Se?(e.matches||e.msMatchesSelector||e.webkitMatchesSelector).call(e,t):n}function We(e,t){return t.parentNode.insertBefore(e,t)}function s(e){return e.className.trim().split(/\s+/)}function Ve(e,t){return Ue(e,"."+t)}function qe(e,t){var n=s(e);n.indexOf(t)<0&&n.push(t),e.className=n.join(" ")}function Ge(e,t){var n=s(e);Te(n,t),e.className=n.join(" ")}function $e(e,t,n){((n=be(n)?!Ve(e,t):n)?qe:Ge)(e,t)}function Ye(e,t){if(be(t)){var n=a((o=getComputedStyle(e)).paddingLeft)+a(o.paddingRight),o=a(o.borderLeftWidth)+a(o.borderRightWidth);return e.offsetWidth-n-o}Pe(e,"width",t)}function Ke(e,t){if(be(t)){var n=a((o=getComputedStyle(e)).paddingTop)+a(o.paddingBottom),o=a(o.borderTopWidth)+a(o.borderBottomWidth);return e.offsetHeight-n-o}Pe(e,"height",t)}function Xe(e,t,n){var o;xe(window.CustomEvent)?o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(o=e.ownerDocument.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n),e.dispatchEvent(o)}function Ze(e){return e.getClientRects().length}function Qe(e,t,n,o,r){for(e=r?e.lastChild:e.firstChild;e;){var i=r?e.previousSibling:e.nextSibling;if(!n&&!1===t(e)||!o&&!1===Qe(e,t,n,o,r)||n&&!1===t(e))return!1;e=i}}function Je(e,t,n,o){Qe(e,t,n,o,!0)}function et(e,t){var n=(t=t||document).createDocumentFragment(),o=Ee("div",{},t);for(o.innerHTML=e;o.firstChild;)Me(n,o.firstChild);return n}function tt(e){return e&&(!Ue(e,"p,div")||e.className||ze(e,"style")||!t(je(e)))}function nt(e,t){var n=Ee(t,{},e.ownerDocument);for(Ce(e.attributes,function(e,t){try{ze(n,t.name,t.value)}catch(e){}});e.firstChild;)Me(n,e.firstChild);return e.parentNode.replaceChild(n,e),n}var c="|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|details|section|article|aside|nav|main|header|hgroup|footer|fieldset|dl|dt|dd|figure|figcaption|";function ot(e){return!!/11?|9/.test(e.nodeType)&&"|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr|isindex|link|meta|param|command|embed|keygen|source|track|object|".indexOf("|"+e.nodeName.toLowerCase()+"|")<0}function rt(e,t){var n=(e||{}).nodeType||ke;return n!==Se?n===ke:"code"===(e=e.tagName.toLowerCase())?!t:c.indexOf("|"+e+"|")<0}function d(e){return e.lastChild&&d(e.lastChild)&&Ae(e.lastChild),3===e.nodeType?!e.nodeValue:ot(e)&&!e.childNodes.length}function it(e){Qe(e,function(e){var t=!rt(e,!0)&&e.nodeType!==l,n=e.parentNode;if(t&&(rt(n,!0)||"P"===n.tagName)){for(var o=e;rt(o.parentNode,!0)||"P"===o.parentNode.tagName;)o=o.parentNode;for(var r=f(o,e),i=e;n&&rt(n,!0);){if(n.nodeType===Se){for(var a=n.cloneNode();i.firstChild;)Me(a,i.firstChild);Me(i,a)}n=n.parentNode}We(i,o),d(r)||We(r,i),d(o)&&Ae(o)}t&&Ue(e,"ul,ol")&&Ue(e.parentNode,"ul,ol")&&(r="li",t=(t=e).previousElementSibling,(t=r&&t&&!Ue(t,r)?null:t)||We(t=Ee("li"),e),Me(t,e))})}function u(e,t){return e?(t?e.previousSibling:e.nextSibling)||u(e.parentNode,t):null}function at(e){var t,n,o,r,i,a,l=Pe(e,"whiteSpace"),s=/line$/i.test(l),c=e.firstChild;if(!/pre(\-wrap)?$/i.test(l))for(;c;){if(i=c.nextSibling,t=c.nodeValue,(a=c.nodeType)===Se&&c.firstChild&&at(c),a===ke){for(n=u(c),o=u(c,!0),a=!1;Ve(o,"sceditor-ignore");)o=u(o,!0);if(rt(c)&&o){for(r=o;r.lastChild;)for(r=r.lastChild;Ve(r,"sceditor-ignore");)r=u(r,!0);a=r.nodeType===ke?/[\t\n\r ]$/.test(r.nodeValue):!rt(r)}t=t.replace(/\u200B/g,""),o&&rt(o)&&!a||(t=t.replace(s?/^[\t ]+/:/^[\t\n\r ]+/,"")),(t=n&&rt(n)?t:t.replace(s?/[\t ]+$/:/[\t\n\r ]+$/,"")).length?c.nodeValue=t.replace(s?/[\t ]+/g:/[\t\n\r ]+/g," "):Ae(c)}c=i}}function f(e,t){var n=e.ownerDocument.createRange();return n.setStartBefore(e),n.setEndAfter(t),n.extractContents()}function lt(e){for(var t=0,n=0;e;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;return{left:t,top:n}}function p(e,t){var n=e.style;return i[t]||(i[t]=t.replace(/^-ms-/,"ms-").replace(/-(\w)/g,function(e,t){return t.toUpperCase()})),n=n[t=i[t]],"textAlign"===t&&(n=n||Pe(e,t),Pe(e.parentNode,t)===n||"block"!==Pe(e,"display")||Ue(e,"hr,th"))?"":n}function st(e,t){var n=e.attributes.length;if(n===t.attributes.length){for(;n--;){var o=e.attributes[n];if("style"===o.name?!function(e,t){var n=e.style.length;if(n===t.style.length){for(;n--;){var o=e.style[n];if(e.style[o]!==t.style[o])return}return 1}}(e,t):o.value!==ze(t,o.name))return}return 1}}function ct(e){for(;e.firstChild;)We(e.firstChild,e);Ae(e)}var ut={toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,image,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source",toolbarExclude:null,style:"jquery.sceditor.default.css",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana",colors:"#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef",locale:ze(document.documentElement,"lang")||"en",charset:"utf-8",emoticonsCompat:!1,emoticonsEnabled:!0,emoticonsRoot:"",emoticons:{dropdown:{":)":"emoticons/smile.png",":angel:":"emoticons/angel.png",":angry:":"emoticons/angry.png","8-)":"emoticons/cool.png",":'(":"emoticons/cwy.png",":ermm:":"emoticons/ermm.png",":D":"emoticons/grin.png","<3":"emoticons/heart.png",":(":"emoticons/sad.png",":O":"emoticons/shocked.png",":P":"emoticons/tongue.png",";)":"emoticons/wink.png"},more:{":alien:":"emoticons/alien.png",":blink:":"emoticons/blink.png",":blush:":"emoticons/blush.png",":cheerful:":"emoticons/cheerful.png",":devil:":"emoticons/devil.png",":dizzy:":"emoticons/dizzy.png",":getlost:":"emoticons/getlost.png",":happy:":"emoticons/happy.png",":kissing:":"emoticons/kissing.png",":ninja:":"emoticons/ninja.png",":pinch:":"emoticons/pinch.png",":pouty:":"emoticons/pouty.png",":sick:":"emoticons/sick.png",":sideways:":"emoticons/sideways.png",":silly:":"emoticons/silly.png",":sleeping:":"emoticons/sleeping.png",":unsure:":"emoticons/unsure.png",":woot:":"emoticons/w00t.png",":wassat:":"emoticons/wassat.png"},hidden:{":whistling:":"emoticons/whistling.png",":love:":"emoticons/wub.png"}},width:null,height:null,resizeEnabled:!0,resizeMinWidth:null,resizeMinHeight:null,resizeMaxHeight:null,resizeMaxWidth:null,resizeHeight:!0,resizeWidth:!0,dateFormat:"year-month-day",toolbarContainer:null,enablePasteFiltering:!1,disablePasting:!1,readOnly:!1,rtl:!1,autofocus:!1,autofocusEnd:!0,autoExpand:!1,autoUpdate:!1,spellcheck:!0,runWithoutWysiwygSupport:!1,startInSourceMode:!1,id:null,plugins:"",zIndex:null,bbcodeTrim:!1,disableBlockRemove:!1,allowedIframeUrls:[],parserOptions:{},dropDownCss:{}},m=/^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i;function dt(e){return e.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function ft(e,t){if(!e)return e;var n={"&":"&","<":"<",">":">"," ":" ","\r\n":"<br />","\r":"<br />","\n":"<br />"};return!1!==t&&(n['"']=""",n["'"]="'",n["`"]="`"),e.replace(/ {2}|\r\n|[&<>\r\n'"`]/g,function(e){return n[e]||e})}var g={html:'<!DOCTYPE html><html{attrs}><head><meta http-equiv="Content-Type" content="text/html;charset={charset}" /><link rel="stylesheet" type="text/css" href="{style}" /></head><body contenteditable="true" {spellcheck}><p></p></body></html>',toolbarButton:'<a class="sceditor-button sceditor-button-{name}" data-sceditor-command="{name}" unselectable="on"><div unselectable="on">{dispName}</div></a>',emoticon:'<img src="{url}" data-sceditor-emoticon="{key}" alt="{key}" title="{tooltip}" />',fontOpt:'<a class="sceditor-font-option" href="#" data-font="{font}"><font face="{font}">{font}</font></a>',sizeOpt:'<a class="sceditor-fontsize-option" data-size="{size}" href="#"><font size="{size}">{size}</font></a>',pastetext:'<div><label for="txt">{label}</label> <textarea cols="20" rows="7" id="txt"></textarea></div><div><input type="button" class="button" value="{insert}" /></div>',table:'<div><label for="rows">{rows}</label><input type="text" id="rows" value="2" /></div><div><label for="cols">{cols}</label><input type="text" id="cols" value="2" /></div><div><input type="button" class="button" value="{insert}" /></div>',image:'<div><label for="image">{url}</label> <input type="text" id="image" dir="ltr" placeholder="https://" /></div><div><label for="width">{width}</label> <input type="text" id="width" size="2" dir="ltr" /></div><div><label for="height">{height}</label> <input type="text" id="height" size="2" dir="ltr" /></div><div><input type="button" class="button" value="{insert}" /></div>',email:'<div><label for="email">{label}</label> <input type="text" id="email" dir="ltr" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{insert}" /></div>',link:'<div><label for="link">{url}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{ins}" /></div>',youtubeMenu:'<div><label for="link">{label}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><input type="button" class="button" value="{insert}" /></div>',youtube:'<iframe width="560" height="315" frameborder="0" allowfullscreen src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" data-youtube-id="{id}"></iframe>'};function pt(e,t,n){var o=g[e];return Object.keys(t).forEach(function(e){o=o.replace(new RegExp(dt("{"+e+"}"),"g"),t[e])}),o=n?et(o):o}function n(e){if("mozHidden"in document)for(var t,n=e.getBody();n;){if((t=n).firstChild)t=t.firstChild;else{for(;t&&!t.nextSibling;)t=t.parentNode;t=t&&t.nextSibling}3===n.nodeType&&/[\n\r\t]+/.test(n.nodeValue)&&(/^pre/.test(Pe(n.parentNode,"whiteSpace"))||Ae(n)),n=t}}var mt={bold:{exec:"bold",tooltip:"Bold",shortcut:"Ctrl+B"},italic:{exec:"italic",tooltip:"Italic",shortcut:"Ctrl+I"},underline:{exec:"underline",tooltip:"Underline",shortcut:"Ctrl+U"},strike:{exec:"strikethrough",tooltip:"Strikethrough"},subscript:{exec:"subscript",tooltip:"Subscript"},superscript:{exec:"superscript",tooltip:"Superscript"},left:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===Pe(e,"direction"),e=Pe(e,"textAlign");return/left/.test(e)||e===(t?"start":"end")}},exec:"justifyleft",tooltip:"Align left"},center:{exec:"justifycenter",tooltip:"Center"},right:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===Pe(e,"direction"),e=Pe(e,"textAlign");return/right/.test(e)||e===(t?"end":"start")}},exec:"justifyright",tooltip:"Align right"},justify:{exec:"justifyfull",tooltip:"Justify"},font:{_dropDown:function(t,e,n){var o=Ee("div");Oe(o,"click","a",function(e){n(je(this,"font")),t.closeDropDown(!0),e.preventDefault()}),t.opts.fonts.split(",").forEach(function(e){Me(o,pt("fontOpt",{font:e},!0))}),t.createDropDown(e,"font-picker",o)},exec:function(e){var t=this;mt.font._dropDown(t,e,function(e){t.execCommand("fontname",e)})},tooltip:"Font Name"},size:{_dropDown:function(t,e,n){var o=Ee("div");Oe(o,"click","a",function(e){n(je(this,"size")),t.closeDropDown(!0),e.preventDefault()});for(var r=1;r<=7;r++)Me(o,pt("sizeOpt",{size:r},!0));t.createDropDown(e,"fontsize-picker",o)},exec:function(e){var t=this;mt.size._dropDown(t,e,function(e){t.execCommand("fontsize",e)})},tooltip:"Font Size"},color:{_dropDown:function(t,e,n){var o=Ee("div"),r="",i=mt.color;i._htmlCache||(t.opts.colors.split("|").forEach(function(e){r+='<div class="sceditor-color-column">',e.split(",").forEach(function(e){r+='<a href="#" class="sceditor-color-option" style="background-color: '+e+'" data-color="'+e+'"></a>'}),r+="</div>"}),i._htmlCache=r),Me(o,et(i._htmlCache)),Oe(o,"click","a",function(e){n(je(this,"color")),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"color-picker",o)},exec:function(e){var t=this;mt.color._dropDown(t,e,function(e){t.execCommand("forecolor",e)})},tooltip:"Font Color"},removeformat:{exec:"removeformat",tooltip:"Remove Formatting"},cut:{exec:"cut",tooltip:"Cut",errorMessage:"Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X"},copy:{exec:"copy",tooltip:"Copy",errorMessage:"Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C"},paste:{exec:"paste",tooltip:"Paste",errorMessage:"Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V"},pastetext:{exec:function(e){var t,n=Ee("div"),o=this;Me(n,pt("pastetext",{label:o._("Paste your text inside the following box:"),insert:o._("Insert")},!0)),Oe(n,"click",".button",function(e){(t=Re(n,"#txt")[0].value)&&o.wysiwygEditorInsertText(t),o.closeDropDown(!0),e.preventDefault()}),o.createDropDown(e,"pastetext",n)},tooltip:"Paste Text"},bulletlist:{exec:function(){n(this),this.execCommand("insertunorderedlist")},tooltip:"Bullet list"},orderedlist:{exec:function(){n(this),this.execCommand("insertorderedlist")},tooltip:"Numbered list"},indent:{state:function(e,t){var n;return Ue(t,"li")||Ue(t,"ul,ol,menu")&&(t=(n=this.getRangeHelper().selectedRange()).startContainer.parentNode,n=n.endContainer.parentNode,t!==t.parentNode.firstElementChild||Ue(n,"li")&&n!==n.parentNode.lastElementChild)?0:-1},exec:function(){var e=this.getRangeHelper().getFirstBlockParent();this.focus(),Ne(e,"ul,ol,menu")&&this.execCommand("indent")},tooltip:"Add indent"},outdent:{state:function(e,t){return Ne(t,"ul,ol,menu")?0:-1},exec:function(){Ne(this.getRangeHelper().getFirstBlockParent(),"ul,ol,menu")&&this.execCommand("outdent")},tooltip:"Remove one indent"},table:{exec:function(e){var r=this,i=Ee("div");Me(i,pt("table",{rows:r._("Rows:"),cols:r._("Cols:"),insert:r._("Insert")},!0)),Oe(i,"click",".button",function(e){var t=Number(Re(i,"#rows")[0].value),n=Number(Re(i,"#cols")[0].value),o="<table>";0<t&&0<n&&(o+=Array(t+1).join("<tr>"+Array(n+1).join("<td><br /></td>")+"</tr>"),o+="</table>",r.wysiwygEditorInsertHtml(o),r.closeDropDown(!0),e.preventDefault())}),r.createDropDown(e,"inserttable",i)},tooltip:"Insert a table"},horizontalrule:{exec:"inserthorizontalrule",tooltip:"Insert a horizontal rule"},code:{exec:function(){this.wysiwygEditorInsertHtml("<code>","<br /></code>")},tooltip:"Code"},image:{_dropDown:function(t,e,n,o){var r=Ee("div");Me(r,pt("image",{url:t._("URL:"),width:t._("Width (optional):"),height:t._("Height (optional):"),insert:t._("Insert")},!0));var i=Re(r,"#image")[0];i.value=n,Oe(r,"click",".button",function(e){i.value&&o(i.value,Re(r,"#width")[0].value,Re(r,"#height")[0].value),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertimage",r)},exec:function(e){var r=this;mt.image._dropDown(r,e,"",function(e,t,n){var o="";t&&(o+=' width="'+parseInt(t,10)+'"'),n&&(o+=' height="'+parseInt(n,10)+'"'),o+=' src="'+ft(e)+'"',r.wysiwygEditorInsertHtml("<img"+o+" />")})},tooltip:"Insert an image"},email:{_dropDown:function(n,e,o){var r=Ee("div");Me(r,pt("email",{label:n._("E-mail:"),desc:n._("Description (optional):"),insert:n._("Insert")},!0)),Oe(r,"click",".button",function(e){var t=Re(r,"#email")[0].value;t&&o(t,Re(r,"#des")[0].value),n.closeDropDown(!0),e.preventDefault()}),n.createDropDown(e,"insertemail",r)},exec:function(e){var n=this;mt.email._dropDown(n,e,function(e,t){!n.getRangeHelper().selectedHtml()||t?n.wysiwygEditorInsertHtml('<a href="mailto:'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink","mailto:"+e)})},tooltip:"Insert an email"},link:{_dropDown:function(t,e,n){var o=Ee("div");Me(o,pt("link",{url:t._("URL:"),desc:t._("Description (optional):"),ins:t._("Insert")},!0));var r=Re(o,"#link")[0];function i(e){r.value&&n(r.value,Re(o,"#des")[0].value),t.closeDropDown(!0),e.preventDefault()}Oe(o,"click",".button",i),Oe(o,"keypress",function(e){13===e.which&&r.value&&i(e)},_e),t.createDropDown(e,"insertlink",o)},exec:function(e){var n=this;mt.link._dropDown(n,e,function(e,t){t||!n.getRangeHelper().selectedHtml()?n.wysiwygEditorInsertHtml('<a href="'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink",e)})},tooltip:"Insert a link"},unlink:{state:function(){return Ne(this.currentNode(),"a")?0:-1},exec:function(){var e=Ne(this.currentNode(),"a");if(e){for(;e.firstChild;)We(e.firstChild,e);Ae(e)}},tooltip:"Unlink"},quote:{exec:function(e,t,n){var o="<blockquote>",r="</blockquote>";t?(o=o+(n=n?"<cite>"+ft(n)+"</cite>":"")+t+r,r=null):""===this.getRangeHelper().selectedHtml()&&(r="<br />"+r),this.wysiwygEditorInsertHtml(o,r)},tooltip:"Insert a Quote"},emoticon:{exec:function(u){var d=this,f=function(e){var n,t=d.opts,o=t.emoticonsRoot||"",r=t.emoticonsCompat,i=d.getRangeHelper(),a=r&&" "!==i.getOuterText(!0,1)?" ":"",l=r&&" "!==i.getOuterText(!1,1)?" ":"",s=Ee("div"),c=Ee("div"),i=we({},t.emoticons.dropdown,e?t.emoticons.more:{});return Me(s,c),n=Math.sqrt(Object.keys(i).length),Oe(s,"click","img",function(e){d.insert(a+ze(this,"alt")+l,null,!1).closeDropDown(!0),e.preventDefault()}),Ce(i,function(e,t){Me(c,Ee("img",{src:o+(t.url||t),alt:e,title:t.tooltip||e})),c.children.length>=n&&(c=Ee("div"),Me(s,c))}),!e&&t.emoticons.more&&(Me(t=Ee("a",{className:"sceditor-more"}),document.createTextNode(d._("More"))),Oe(t,"click",function(e){d.createDropDown(u,"more-emoticons",f(!0)),e.preventDefault()}),Me(s,t)),s};d.createDropDown(u,"emoticons",f(!1))},txtExec:function(e){mt.emoticon.exec.call(this,e)},tooltip:"Insert an emoticon"},youtube:{_dropDown:function(r,e,i){var a=Ee("div");Me(a,pt("youtubeMenu",{label:r._("Video URL:"),insert:r._("Insert")},!0)),Oe(a,"click",".button",function(e){var t=(n=Re(a,"#link")[0].value).match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/),n=n.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/),o=0;n&&Ce(n[1].split(/[hms]/),function(e,t){""!==t&&(o=60*o+Number(t))}),t&&/^[a-zA-Z0-9_\-]{11}$/.test(t[1])&&i(t[1],o),r.closeDropDown(!0),e.preventDefault()}),r.createDropDown(e,"insertlink",a)},exec:function(e){var n=this;mt.youtube._dropDown(n,e,function(e,t){n.wysiwygEditorInsertHtml(pt("youtube",{id:e,time:t}))})},tooltip:"Insert a YouTube video"},date:{_date:function(e){var t=new Date,n=t.getYear(),o=t.getMonth()+1;return n<2e3&&(n=1900+n),o<10&&(o="0"+o),(t=t.getDate())<10&&(t="0"+t),e.opts.dateFormat.replace(/year/i,n).replace(/month/i,o).replace(/day/i,t)},exec:function(){this.insertText(mt.date._date(this))},txtExec:function(){this.insertText(mt.date._date(this))},tooltip:"Insert current date"},time:{_time:function(){var e=new Date,t=e.getHours(),n=e.getMinutes();return(t=t<10?"0"+t:t)+":"+(n=n<10?"0"+n:n)+":"+((e=e.getSeconds())<10?"0"+e:e)},exec:function(){this.insertText(mt.time._time())},txtExec:function(){this.insertText(mt.time._time())},tooltip:"Insert current time"},ltr:{state:function(e,t){return t&&"ltr"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!Ue(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!Ue(t,"body")))&&(e="ltr"===Pe(t,"direction")?"":"ltr",Pe(t,"direction",e))},tooltip:"Left-to-Right"},rtl:{state:function(e,t){return t&&"rtl"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!Ue(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!Ue(t,"body")))&&(e="rtl"===Pe(t,"direction")?"":"rtl",Pe(t,"direction",e))},tooltip:"Right-to-Left"},print:{exec:"print",tooltip:"Print"},maximize:{state:function(){return this.maximize()},exec:function(){this.maximize(!this.maximize()),this.focus()},txtExec:function(){this.maximize(!this.maximize()),this.focus()},tooltip:"Maximize",shortcut:"Ctrl+Shift+M"},source:{state:function(){return this.sourceMode()},exec:function(){this.toggleSourceMode(),this.focus()},txtExec:function(){this.toggleSourceMode(),this.focus()},tooltip:"View source",shortcut:"Ctrl+Shift+S"},ignore:{}},h={};function gt(i){function a(e){return"signal"+e.charAt(0).toUpperCase()+e.slice(1)}function e(e,t){for(var n,o=a((e=[].slice.call(e)).shift()),r=0;r<l.length;r++)if(o in l[r]&&(n=l[r][o].apply(i,e),t))return n}var r=this,l=[];r.call=function(){e(arguments,!1)},r.callOnlyFirst=function(){return e(arguments,!0)},r.hasHandler=function(e){var t=l.length;for(e=a(e);t--;)if(e in l[t])return!0;return!1},r.exists=function(e){return e in h&&"function"==typeof(e=h[e])&&"object"==typeof e.prototype},r.isRegistered=function(e){if(r.exists(e))for(var t=l.length;t--;)if(l[t]instanceof h[e])return!0;return!1},r.register=function(e){return!(!r.exists(e)||r.isRegistered(e)||(e=new h[e],l.push(e),"init"in e&&e.init.call(i),0))},r.deregister=function(e){var t,n=l.length,o=!1;if(!r.isRegistered(e))return o;for(;n--;)l[n]instanceof h[e]&&(o=!0,"destroy"in(t=l.splice(n,1)[0])&&t.destroy.call(i));return o},r.destroy=function(){for(var e=l.length;e--;)"destroy"in l[e]&&l[e].destroy.call(i);l=[],i=null}}gt.plugins=h;var v=function(e,t,n){var o,r,i,a,l,s="",c=e.startContainer,u=e.startOffset;for(c&&3!==c.nodeType&&(c=c.childNodes[u],u=0),i=a=u;n>s.length&&c&&3===c.nodeType;)o=c.nodeValue,r=n-s.length,l&&(a=o.length,i=0),l=c,c=t?(u=i=Math.max(a-r,0),s=o.substr(i,a-i)+s,l.previousSibling):(u=i+(a=Math.min(r,o.length)),s+=o.substr(i,a),l.nextSibling);return{node:l||c,offset:u,text:s}};function ht(r,e,i){var a,l,s=e||r.contentDocument||r.document,c="sceditor-start-marker",u="sceditor-end-marker",h=this;h.insertHTML=function(e,t){var n,o;if(!h.selectedRange())return!1;for(t&&(e+=h.selectedHtml()+t),o=Ee("p",{},s),n=s.createDocumentFragment(),o.innerHTML=i(e);o.firstChild;)Me(n,o.firstChild);h.insertNode(n)},l=function(e,t,n){var o,r=s.createDocumentFragment();if("string"==typeof e?(t&&(e+=h.selectedHtml()+t),r=et(e)):(Me(r,e),t&&(Me(r,h.selectedRange().extractContents()),Me(r,t))),o=r.lastChild){for(;!rt(o.lastChild,!0);)o=o.lastChild;return(ot(o)?o.lastChild||Me(o,document.createTextNode("")):o=r,h.removeMarkers(),Me(o,a(c)),Me(o,a(u)),n)?(Me(n=Ee("div"),r),n.innerHTML):r}},h.insertNode=function(e,t){var n,o,r=l(e,t),t=(e=h.selectedRange()).commonAncestorContainer,i=[];if(!r)return!1;function a(e){e&&d(e)&&i.indexOf(e)<0&&Ae(e)}e.startContainer!==e.endContainer&&(Ce(t.childNodes,function(e,t){d(t)&&i.push(t)}),n=r.firstChild,o=r.lastChild),e.deleteContents(),t&&3!==t.nodeType&&!ot(t)?We(r,t):(e.insertNode(r),a(n&&n.previousSibling),a(o&&o.nextSibling)),h.restoreRange()},h.cloneSelected=function(){var e=h.selectedRange();if(e)return e.cloneRange()},h.selectedRange=function(){var e,t,n=r.getSelection();if(n){if(n.rangeCount<=0){for(t=s.body;t.firstChild;)t=t.firstChild;(e=s.createRange()).setStartBefore(t),n.addRange(e)}return 0<n.rangeCount?n.getRangeAt(0):e}},h.hasSelection=function(){var e=r.getSelection();return e&&0<e.rangeCount},h.selectedHtml=function(){var e,t=h.selectedRange();return t?(Me(e=Ee("p",{},s),t.cloneContents()),e.innerHTML):""},h.parentNode=function(){var e=h.selectedRange();if(e)return e.commonAncestorContainer},h.getFirstBlockParent=function(e){var t=function(e){return rt(e,!0)?(e=e?e.parentNode:null)&&t(e):e};return t(e||h.parentNode())},h.insertNodeAt=function(e,t){var n=h.selectedRange(),o=h.cloneSelected();if(!o)return!1;o.collapse(e),o.insertNode(t),h.selectRange(n)},a=function(e){return h.removeMarker(e),(e=Ee("span",{id:e,className:"sceditor-selection sceditor-ignore",style:"display:none;line-height:0"},s)).innerHTML=" ",e},h.insertMarkers=function(){var e=h.selectedRange(),t=a(c);h.removeMarkers(),h.insertNodeAt(!0,t),e&&e.collapsed?t.parentNode.insertBefore(a(u),t.nextSibling):h.insertNodeAt(!1,a(u))},h.getMarker=function(e){return s.getElementById(e)},h.removeMarker=function(e){(e=h.getMarker(e))&&Ae(e)},h.removeMarkers=function(){h.removeMarker(c),h.removeMarker(u)},h.saveRange=function(){h.insertMarkers()},h.selectRange=function(e){var t,n=r.getSelection(),o=e.endContainer;if(e.collapsed&&o&&!rt(o,!0)){for(t=o.lastChild;t&&Ue(t,".sceditor-ignore");)t=t.previousSibling;Ue(t,"br")&&((o=s.createRange()).setEndAfter(t),o.collapse(!1),h.compare(e,o)&&(e.setStartBefore(t),e.collapse(!0)))}n&&(h.clear(),n.addRange(e))},h.restoreRange=function(){var e,t=h.selectedRange(),n=h.getMarker(c),o=h.getMarker(u);if(!n||!o||!t)return!1;e=n.nextSibling===o,(t=s.createRange()).setStartBefore(n),t.setEndAfter(o),e&&t.collapse(!0),h.selectRange(t),h.removeMarkers()},h.selectOuterText=function(e,t){var n=h.cloneSelected();if(!n)return!1;n.collapse(!1),e=v(n,!0,e),t=v(n,!1,t),n.setStart(e.node,e.offset),n.setEnd(t.node,t.offset),h.selectRange(n)},h.getOuterText=function(e,t){var n=h.cloneSelected();return n?(n.collapse(!e),v(n,e,t).text):""},h.replaceKeyword=function(e,t,n,o,r,i){n||e.sort(function(e,t){return e[0].length-t[0].length});var a,l,s,c,u,d,f,p="(^|[\\s ])",m=e.length,g=r?1:0,o=o||e[m-1][0].length;for(r&&o++,i=i||"",c=(a=h.getOuterText(!0,o)).length,a+=i,t&&(a+=h.getOuterText(!1,o));m--;)if(f=(d=e[m][0]).length,s=Math.max(0,c-f-g),u=-1,r?(l=a.substr(s).match(new RegExp(p+dt(d)+p)))&&(u=l.index+s+l[1].length):u=a.indexOf(d,s),-1<u&&u<=c&&c<=u+f+g)return u=c-u,h.selectOuterText(u,f-u-(/^\S/.test(i)?1:0)),h.insertHTML(e[m][1]),!0;return!1},h.compare=function(e,t){return t=t||h.selectedRange(),e&&t?0===e.compareBoundaryPoints(Range.END_TO_END,t)&&0===e.compareBoundaryPoints(Range.START_TO_START,t):!e&&!t},h.clear=function(){var e=r.getSelection();e&&(e.removeAllRanges?e.removeAllRanges():e.empty&&e.empty())}}var y,b,x,w=navigator.userAgent,vt=/iPhone|iPod|iPad| wosbrowser\//i.test(w),yt=(b=!!window.document.documentMode,D="-ms-ime-align"in document.documentElement.style,(A=document.createElement("div")).contentEditable=!0,"contentEditable"in document.documentElement&&"true"===A.contentEditable&&(A=/Opera Mobi|Opera Mini/i.test(w),/Android/i.test(w)&&(A=!0,/Safari/.test(w)&&(A=!(y=/Safari\/(\d+)/.exec(w))||!y[1]||y[1]<534)),/ Silk\//i.test(w)&&(A=!(y=/AppleWebKit\/(\d+)/.exec(w))||!y[1]||y[1]<534),vt&&(A=/OS [0-4](_\d)+ like Mac/i.test(w)),/Firefox/i.test(w)&&(A=!1),/OneBrowser/i.test(w)&&(A=!1),"UCWEB"===navigator.vendor&&(A=!1),!(A=!(!b&&!D)||A))),T=Object.hasOwnProperty,C=Object.setPrototypeOf,S=Object.isFrozen,k=Object.getPrototypeOf,E=Object.getOwnPropertyDescriptor,bt=Object.freeze,D=Object.seal,N=Object.create,A="undefined"!=typeof Reflect&&Reflect,M=(M=A.apply)||function(e,t,n){return e.apply(t,n)},bt=bt||function(e){return e},D=D||function(e){return e},R=(R=A.construct)||function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))},xt=_(Array.prototype.forEach),wt=_(Array.prototype.pop),Tt=_(Array.prototype.push),Ct=_(String.prototype.toLowerCase),St=_(String.prototype.match),kt=_(String.prototype.replace),Et=_(String.prototype.indexOf),Dt=_(String.prototype.trim),Nt=_(RegExp.prototype.test),At=(x=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return R(x,t)});function _(r){return function(e){for(var t=arguments.length,n=Array(1<t?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return M(r,e,n)}}function Mt(e,t){C&&C(e,null);for(var n=t.length;n--;){var o,r=t[n];"string"!=typeof r||(o=Ct(r))!==r&&(S(t)||(t[n]=o),r=o),e[r]=!0}return e}function Rt(e){var t=N(null),n=void 0;for(n in e)M(T,e,[n])&&(t[n]=e[n]);return t}function _t(e,t){for(;null!==e;){var n=E(e,t);if(n){if(n.get)return _(n.get);if("function"==typeof n.value)return _(n.value)}e=k(e)}return null}var Ot=bt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ft=bt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),zt=bt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ht=bt(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Lt=bt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),It=bt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Bt=bt(["#text"]),Pt=bt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns"]),jt=bt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ut=bt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=bt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Vt=D(/\{\{[\s\S]*|[\s\S]*\}\}/gm),qt=D(/<%[\s\S]*|[\s\S]*%>/gm),Gt=D(/^data-[\-\w.\u00B7-\uFFFF]/),$t=D(/^aria-[\-\w]+$/),Yt=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Kt=D(/^(?:\w+script|data):/i),Xt=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function Qt(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var Jt=function t(e){function c(e){return t(e)}var l=0<arguments.length&&void 0!==e?e:"undefined"==typeof window?null:window;if(c.version="2.2.6",c.removed=[],!l||!l.document||9!==l.document.nodeType)return c.isSupported=!1,c;var s=l.document,i=l.document,u=l.DocumentFragment,n=l.HTMLTemplateElement,d=l.Node,a=l.Element,o=l.NodeFilter,r=l.NamedNodeMap,f=void 0===r?l.NamedNodeMap||l.MozNamedAttrMap:r,p=l.Text,m=l.Comment,g=l.DOMParser,e=l.trustedTypes,h=_t(r=a.prototype,"cloneNode"),v=_t(r,"nextSibling"),y=_t(r,"childNodes"),b=_t(r,"parentNode");"function"!=typeof n||(n=i.createElement("template")).content&&n.content.ownerDocument&&(i=n.content.ownerDocument);var x=function(e,t){if("object"!==(void 0===e?"undefined":Zt(e))||"function"!=typeof e.createPolicy)return null;var n=null,o="data-tt-policy-suffix",r="dompurify"+((n=t.currentScript&&t.currentScript.hasAttribute(o)?t.currentScript.getAttribute(o):n)?"#"+n:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(e,s),w=x&&ee?x.createHTML(""):"",T=i.implementation,C=i.createNodeIterator,S=i.getElementsByTagName,k=i.createDocumentFragment,E=s.importNode,D={};try{D=Rt(i).documentMode?i.documentMode:{}}catch(e){}var N={};function A(e){ce&&ce===e||(e=Rt(e=e&&"object"===(void 0===e?"undefined":Zt(e))?e:{}),I="ALLOWED_TAGS"in e?Mt({},e.ALLOWED_TAGS):B,P="ALLOWED_ATTR"in e?Mt({},e.ALLOWED_ATTR):j,le="ADD_URI_SAFE_ATTR"in e?Mt(Rt(se),e.ADD_URI_SAFE_ATTR):se,ie="ADD_DATA_URI_TAGS"in e?Mt(Rt(ae),e.ADD_DATA_URI_TAGS):ae,U="FORBID_TAGS"in e?Mt({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?Mt({},e.FORBID_ATTR):{},M="USE_PROFILES"in e&&e.USE_PROFILES,V=!1!==e.ALLOW_ARIA_ATTR,q=!1!==e.ALLOW_DATA_ATTR,G=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=e.SAFE_FOR_TEMPLATES||!1,Y=e.WHOLE_DOCUMENT||!1,Z=e.RETURN_DOM||!1,Q=e.RETURN_DOM_FRAGMENT||!1,J=!1!==e.RETURN_DOM_IMPORT,ee=e.RETURN_TRUSTED_TYPE||!1,X=e.FORCE_BODY||!1,te=!1!==e.SANITIZE_DOM,ne=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||L,$&&(q=!1),Q&&(Z=!0),M&&(I=Mt({},[].concat(Qt(Bt))),P=[],!0===M.html&&(Mt(I,Ot),Mt(P,Pt)),!0===M.svg&&(Mt(I,Ft),Mt(P,jt),Mt(P,Wt)),!0===M.svgFilters&&(Mt(I,zt),Mt(P,jt),Mt(P,Wt)),!0===M.mathMl&&(Mt(I,Lt),Mt(P,Ut),Mt(P,Wt))),e.ADD_TAGS&&Mt(I=I===B?Rt(I):I,e.ADD_TAGS),e.ADD_ATTR&&Mt(P=P===j?Rt(P):P,e.ADD_ATTR),e.ADD_URI_SAFE_ATTR&&Mt(le,e.ADD_URI_SAFE_ATTR),ne&&(I["#text"]=!0),Y&&Mt(I,["html","head","body"]),I.table&&(Mt(I,["tbody"]),delete U.tbody),bt&&bt(e),ce=e)}c.isSupported=T&&void 0!==T.createHTMLDocument&&9!==D;var M,R=Vt,_=qt,O=Gt,F=$t,z=Kt,H=Xt,L=Yt,I=null,B=Mt({},[].concat(Qt(Ot),Qt(Ft),Qt(zt),Qt(Lt),Qt(Bt))),P=null,j=Mt({},[].concat(Qt(Pt),Qt(jt),Qt(Ut),Qt(Wt))),U=null,W=null,V=!0,q=!0,G=!1,$=!1,Y=!1,K=!1,X=!1,Z=!1,Q=!1,J=!0,ee=!1,te=!0,ne=!0,oe=!1,re=Mt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ie=null,ae=Mt({},["audio","video","img","source","image","track"]),le=null,se=Mt({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),ce=null,ue=i.createElement("form"),de=Mt({},["mi","mo","mn","ms","mtext"]),fe=Mt({},["foreignobject","desc","title","annotation-xml"]),pe=Mt({},Ft);Mt(pe,zt),Mt(pe,Ht);var me=Mt({},Lt);function ge(t){Tt(c.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=w}catch(e){t.remove()}}}function he(e,t){try{Tt(c.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Tt(c.removed,{attribute:null,from:t})}t.removeAttribute(e)}function ve(e){var t=void 0,n=void 0;X?e="<remove></remove>"+e:n=(o=St(e,/^[\r\n\t ]+/))&&o[0];var o,r=x?x.createHTML(e):e;try{t=(new g).parseFromString(r,"text/html")}catch(e){}return t&&t.documentElement||((o=(t=T.createHTMLDocument("")).body).parentNode.removeChild(o.parentNode.firstElementChild),o.outerHTML=r),e&&n&&t.body.insertBefore(i.createTextNode(n),t.body.childNodes[0]||null),S.call(t,Y?"html":"body")[0]}function ye(e){return C.call(e.ownerDocument||e,e,o.SHOW_ELEMENT|o.SHOW_COMMENT|o.SHOW_TEXT,function(){return o.FILTER_ACCEPT},!1)}function be(e){return"object"===(void 0===d?"undefined":Zt(d))?e instanceof d:e&&"object"===(void 0===e?"undefined":Zt(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function xe(e,t,n){N[e]&&xt(N[e],function(e){e.call(c,t,n,ce)})}function we(e){var t;if(xe("beforeSanitizeElements",e,null),!((n=e)instanceof p||n instanceof m||"string"==typeof n.nodeName&&"string"==typeof n.textContent&&"function"==typeof n.removeChild&&n.attributes instanceof f&&"function"==typeof n.removeAttribute&&"function"==typeof n.setAttribute&&"string"==typeof n.namespaceURI&&"function"==typeof n.insertBefore))return ge(e),1;if(St(e.nodeName,/[\u0080-\uFFFF]/))return ge(e),1;var n=Ct(e.nodeName);if(xe("uponSanitizeElement",e,{tagName:n,allowedTags:I}),!be(e.firstElementChild)&&(!be(e.content)||!be(e.content.firstElementChild))&&Nt(/<[/\w]/g,e.innerHTML)&&Nt(/<[/\w]/g,e.textContent))return ge(e),1;if(I[n]&&!U[n])return e instanceof a&&!function(e){var t=b(e);t&&t.tagName||(t={namespaceURI:Ee,tagName:"template"});var n=Ct(e.tagName),o=Ct(t.tagName);return e.namespaceURI===ke?t.namespaceURI===Ee?"svg"===n:t.namespaceURI===Se?"svg"===n&&("annotation-xml"===o||de[o]):Boolean(pe[n]):e.namespaceURI===Se?t.namespaceURI===Ee?"math"===n:t.namespaceURI===ke?"math"===n&&fe[o]:Boolean(me[n]):e.namespaceURI===Ee&&(t.namespaceURI!==ke||fe[o])&&(t.namespaceURI!==Se||de[o])&&(o=Mt({},["title","style","font","a","script"]),!me[n]&&(o[n]||!pe[n]))}(e)||("noscript"===n||"noembed"===n)&&Nt(/<\/no(script|embed)/i,e.innerHTML)?(ge(e),1):($&&3===e.nodeType&&(t=e.textContent,t=kt(t,R," "),t=kt(t,_," "),e.textContent!==t&&(Tt(c.removed,{element:e.cloneNode()}),e.textContent=t)),xe("afterSanitizeElements",e,null),0);if(ne&&!re[n])for(var o=b(e),r=y(e),i=r.length-1;0<=i;--i)o.insertBefore(h(r[i],!0),v(e));return ge(e),1}function Te(e,t,n){if(te&&("id"===t||"name"===t)&&(n in i||n in ue))return!1;if(!(q&&Nt(O,t)||V&&Nt(F,t))){if(!P[t]||W[t])return!1;if(!le[t]&&!Nt(L,kt(n,H,""))&&("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Et(n,"data:")||!ie[e])&&(!G||Nt(z,kt(n,H,"")))&&n)return!1}return!0}function Ce(e){var t,n=void 0,o=void 0;xe("beforeSanitizeAttributes",e,null);var r=e.attributes;if(r){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P},o=r.length;o--;){var a=(t=r[o]).name,l=t.namespaceURI,n=Dt(t.value),s=Ct(a);if(i.attrName=s,i.attrValue=n,i.keepAttr=!0,i.forceKeepAttr=void 0,xe("uponSanitizeAttribute",e,i),n=i.attrValue,!i.forceKeepAttr&&(he(a,e),i.keepAttr))if(Nt(/\/>/i,n))he(a,e);else if($&&(n=kt(n,R," "),n=kt(n,_," ")),Te(e.nodeName.toLowerCase(),s,n))try{l?e.setAttributeNS(l,a,n):e.setAttribute(a,n),wt(c.removed)}catch(e){}}xe("afterSanitizeAttributes",e,null)}}Mt(me,It);var Se="http://www.w3.org/1998/Math/MathML",ke="http://www.w3.org/2000/svg",Ee="http://www.w3.org/1999/xhtml";return c.sanitize=function(e,t){var n,o=void 0,r=void 0,i=void 0;if("string"!=typeof(e=e||"\x3c!--\x3e")&&!be(e)){if("function"!=typeof e.toString)throw At("toString is not a function");if("string"!=typeof(e=e.toString()))throw At("dirty is not a string, aborting")}if(!c.isSupported){if("object"===Zt(l.toStaticHTML)||"function"==typeof l.toStaticHTML){if("string"==typeof e)return l.toStaticHTML(e);if(be(e))return l.toStaticHTML(e.outerHTML)}return e}if(K||A(t),c.removed=[],!(oe="string"==typeof e?!1:oe))if(e instanceof d)1===(t=(o=ve("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===t.nodeName||"HTML"===t.nodeName?o=t:o.appendChild(t);else{if(!Z&&!$&&!Y&&-1===e.indexOf("<"))return x&&ee?x.createHTML(e):e;if(!(o=ve(e)))return Z?null:w}o&&X&&ge(o.firstChild);for(var a=ye(oe?e:o);n=a.nextNode();)3===n.nodeType&&n===r||we(n)||(n.content instanceof u&&function e(t){var n,o=ye(t);for(xe("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)xe("uponSanitizeShadowNode",n,null),we(n)||(n.content instanceof u&&e(n.content),Ce(n));xe("afterSanitizeShadowDOM",t,null)}(n.content),Ce(n),r=n);if(r=null,oe)return e;if(Z){if(Q)for(i=k.call(o.ownerDocument);o.firstChild;)i.appendChild(o.firstChild);else i=o;return J?E.call(s,i,!0):i}return e=Y?o.outerHTML:o.innerHTML,$&&(e=kt(e,R," "),e=kt(e,_," ")),x&&ee?x.createHTML(e):e},c.setConfig=function(e){A(e),K=!0},c.clearConfig=function(){ce=null,K=!1},c.isValidAttribute=function(e,t,n){return ce||A({}),Te(e=Ct(e),t=Ct(t),n)},c.addHook=function(e,t){"function"==typeof t&&(N[e]=N[e]||[],Tt(N[e],t))},c.removeHook=function(e){N[e]&&wt(N[e])},c.removeHooks=function(e){N[e]&&(N[e]=[])},c.removeAllHooks=function(){N={}},c}(),en=window,tn=document,nn=/^image\/(p?jpe?g|gif|png|bmp)$/i;function on(r,e){var a,x,u,i,l,f,d,s,o,c,p,t,m,g,h,v,y,b,n,w,T,C,S,k,E,D,N,A,M,R,_,O,F,z,H,L,I,B,P,j,U,W,V,q,G,$,Y,K,X,Z,Q,J,ee,te,ne,oe,re,ie,ae,le,se=this,ce={},ue=[],de=[],fe={},pe={},me={};se.commands=we(!0,{},e.commands||mt);var ge=se.opts=we(!0,{},ut,e);se.opts.emoticons=e.emoticons||ut.emoticons,Array.isArray(ge.allowedIframeUrls)||(ge.allowedIframeUrls=[]),ge.allowedIframeUrls.push("https://www.youtube-nocookie.com/embed/");var he=Jt();function ve(e){return he.sanitize(e,{ADD_TAGS:["iframe"],ADD_ATTR:["allowfullscreen","frameborder","target"]})}he.addHook("uponSanitizeElement",function(e,t){var n=ge.allowedIframeUrls;if("iframe"===t.tagName){for(var o=ze(e,"src")||"",r=0;r<n.length;r++){var i=n[r];if(ye(i)&&o.substr(0,i.length)===i)return;if(i.test&&i.test(o))return}Ae(e)}}),he.addHook("afterSanitizeAttributes",function(e){"target"in e&&ze(e,"data-sce-target",ze(e,"target")),He(e,"target")}),e=function(){r._sceditor=se,ge.locale&&"en"!==ge.locale&&M(),We(x=Ee("div",{className:"sceditor-container"}),r),Pe(x,"z-index",ge.zIndex),n=r.required,r.required=!1;var e=on.formats[ge.format];a=e?new e:{},g=new gt(se),(ge.plugins||"").split(",").forEach(function(e){g.register(e.trim())}),"init"in a&&a.init.call(se),z(),R(),A(),_(),O(),yt||se.toggleSourceMode(),Y();var t=function(){Fe(en,"load",t),ge.autofocus&&J(!!ge.autofocusEnd),le(),X(),g.call("ready"),"onReady"in a&&a.onReady.call(se)};Oe(en,"load",t),"complete"===tn.readyState&&t()},M=function(){var e;(t=on.locale[ge.locale])||(e=ge.locale.split("-"),t=on.locale[e[0]]),t&&t.dateFormat&&(ge.dateFormat=t.dateFormat)},A=function(){s=Ee("textarea"),i=Ee("iframe",{frameborder:0,allowfullscreen:!0}),ge.startInSourceMode?(qe(x,"sourceMode"),Le(i)):(qe(x,"wysiwygMode"),Le(s)),ge.spellcheck||ze(x,"spellcheck","false"),"https:"===en.location.protocol&&ze(i,"src","about:blank"),Me(x,i),Me(x,s),se.dimensions(ge.width||Ye(r),ge.height||Ke(r));var e=vt?" ios":"";(d=i.contentDocument).open(),d.write(pt("html",{attrs:' class="'+e+'"',spellcheck:ge.spellcheck?"":'spellcheck="false"',charset:ge.charset,style:ge.style})),d.close(),f=d.body,l=i.contentWindow,se.readOnly(!!ge.readOnly),vt&&(Ke(f,"100%"),Oe(f,"touchend",se.focus)),e=ze(r,"tabindex"),ze(s,"tabindex",e),ze(i,"tabindex",e),m=new ht(l,null,ve),Le(r),se.val(r.value),(e=ge.placeholder||ze(r,"placeholder"))&&(s.placeholder=e,ze(f,"placeholder",e))},_=function(){ge.autoUpdate&&(Oe(f,"blur",ae),Oe(s,"blur",ae)),null===ge.rtl&&(ge.rtl="rtl"===Pe(s,"direction")),se.rtl(!!ge.rtl),ge.autoExpand&&(Oe(f,"load",le,_e),Oe(f,"input keyup",le)),ge.resizeEnabled&&F(),ze(x,"id",ge.id),se.emoticons(ge.emoticonsEnabled)},O=function(){var e=r.form,t="compositionstart compositionend",n="keydown keyup keypress focus blur contextmenu input",o="onselectionchange"in d?"selectionchange":"keyup focus blur contextmenu mouseup touchend click";Oe(tn,"click",G),e&&(Oe(e,"reset",U),Oe(e,"submit",se.updateOriginal,_e)),Oe(window,"pagehide",se.updateOriginal),Oe(window,"pageshow",U),Oe(f,"keypress",j),Oe(f,"keydown",B),Oe(f,"keydown",P),Oe(f,"keyup",X),Oe(f,"blur",re),Oe(f,"keyup",ie),Oe(f,"paste",H),Oe(f,"cut copy",L),Oe(f,t,V),Oe(f,o,Z),Oe(f,n,q),ge.emoticonsCompat&&en.getSelection&&Oe(f,"keyup",te),Oe(f,"blur",function(){se.val()||qe(f,"placeholder")}),Oe(f,"focus",function(){Ge(f,"placeholder")}),Oe(s,"blur",re),Oe(s,"keyup",ie),Oe(s,"keydown",B),Oe(s,t,V),Oe(s,n,q),Oe(d,"mousedown",W),Oe(d,o,Z),Oe(d,"keyup",X),Oe(x,"selectionchanged",Q),Oe(x,"selectionchanged",Y),Oe(x,"selectionchanged valuechanged nodechanged pasteraw paste",q)},R=function(){var i,a=se.commands,l=(ge.toolbarExclude||"").split(","),e=ge.toolbar.split("|");u=Ee("div",{className:"sceditor-toolbar",unselectable:"on"}),ge.icons in on.icons&&(E=new on.icons[ge.icons]),Ce(e,function(e,t){i=Ee("div",{className:"sceditor-group"}),Ce(t.split(","),function(e,t){var n,o,r=a[t];!r||-1<l.indexOf(t)||(n=r.shortcut,o=pt("toolbarButton",{name:t,dispName:se._(r.name||r.tooltip||t)},!0).firstChild,E&&E.create&&E.create(t)&&(We(E.create(t),o.firstChild),qe(o,"has-icon")),o._sceTxtMode=!!r.txtExec,o._sceWysiwygMode=!!r.exec,$e(o,"disabled",!r.exec),Oe(o,"click",function(e){Ve(o,"disabled")||N(o,r),Y(),e.preventDefault()}),Oe(o,"mousedown",function(e){se.closeDropDown(),e.preventDefault()}),r.tooltip&&ze(o,"title",se._(r.tooltip)+(n?" ("+n+")":"")),n&&se.addShortcut(n,t),r.state?de.push({name:t,state:r.state}):ye(r.exec)&&de.push({name:t,state:r.exec}),Me(i,o),pe[t]=o)}),i.firstChild&&Me(u,i)}),Me(ge.toolbarContainer||x,u)},F=function(){function t(e){o="touchmove"===e.type?(e=en.event,s=e.changedTouches[0].pageX,e.changedTouches[0].pageY):(s=e.pageX,e.pageY);var t=u+(o-l),n=m?c-(s-a):c+(s-a);0<y&&y<n&&(n=y),0<v&&n<v&&(n=v),ge.resizeWidth||(n=!1),0<h&&h<t&&(t=h),0<g&&t<g&&(t=g),ge.resizeHeight||(t=!1),(n||t)&&se.dimensions(n,t),e.preventDefault()}var o,e=Ee("div",{className:"sceditor-grip"}),n=Ee("div",{className:"sceditor-resize-cover"}),r="touchmove mousemove",i="touchcancel touchend mouseup",a=0,l=0,s=0,c=0,u=0,d=Ye(x),f=Ke(x),p=!1,m=se.rtl(),g=ge.resizeMinHeight||f/1.5,h=ge.resizeMaxHeight||2.5*f,v=ge.resizeMinWidth||d/1.25,y=ge.resizeMaxWidth||1.25*d,b=function(e){p&&(p=!1,Le(n),Ge(x,"resizing"),Fe(tn,r,t),Fe(tn,i,b),e.preventDefault())};E&&E.create&&(d=E.create("grip"))&&(Me(e,d),qe(e,"has-icon")),Me(x,e),Me(x,n),Le(n),Oe(e,"touchstart mousedown",function(e){l="touchstart"===e.type?(e=en.event,a=e.touches[0].pageX,e.touches[0].pageY):(a=e.pageX,e.pageY),c=Ye(x),u=Ke(x),p=!0,qe(x,"resizing"),Ie(n),Oe(tn,r,t),Oe(tn,i,b),e.preventDefault()})},z=function(){var e=ge.emoticons,n=ge.emoticonsRoot||"";Ce(me=e?we({},e.more,e.dropdown,e.hidden):me,function(e,t){me[e]=pt("emoticon",{key:e,url:n+(t.url||t),tooltip:t.tooltip||e}),ge.emoticonsEnabled&&ue.push(Ee("img",{src:n+(t.url||t)}))})},J=function(e){var t,n=f.firstChild;if(Ze(x)){if(se.sourceMode())return t=e?s.value.length:0,void s.setSelectionRange(t,t);if(at(f),e)for((n=f.lastChild)||(n=Ee("p",{},d),Me(f,n));n.lastChild;)Ue(n=n.lastChild,"br")&&n.previousSibling&&(n=n.previousSibling);t=d.createRange(),ot(n)?t.selectNodeContents(n):(t.setStartBefore(n),e&&t.setStartAfter(n)),t.collapse(!e),m.selectRange(t),y=t,e&&(f.scrollTop=f.scrollHeight),se.focus()}},se.readOnly=function(e){return"boolean"!=typeof e?!s.readonly:(f.contentEditable=!e,s.readonly=!e,$(e),se)},se.rtl=function(e){var t=e?"rtl":"ltr";return"boolean"!=typeof e?"rtl"===ze(s,"dir"):(ze(f,"dir",t),ze(s,"dir",t),Ge(x,"rtl"),Ge(x,"ltr"),qe(x,t),E&&E.rtl&&E.rtl(e),se)},$=function(n){var o=se.inSourceMode()?"_sceTxtMode":"_sceWysiwygMode";Ce(pe,function(e,t){$e(t,"disabled",n||!t[o])})},se.width=function(e,t){return e||0===e?(se.dimensions(e,null,t),se):Ye(x)},se.dimensions=function(e,t,n){return t=!(!t&&0!==t)&&t,!1===(e=!(!e&&0!==e)&&e)&&!1===t?{width:se.width(),height:se.height()}:(!1!==e&&(!1!==n&&(ge.width=e),Ye(x,e)),!1!==t&&(!1!==n&&(ge.height=t),Ke(x,t)),se)},se.height=function(e,t){return e||0===e?(se.dimensions(null,e,t),se):Ke(x)},se.maximize=function(e){var t="sceditor-maximize";return be(e)?Ve(x,t):((e=!!e)&&(S=en.pageYOffset),$e(tn.documentElement,t,e),$e(tn.body,t,e),$e(x,t,e),se.width(e?"100%":ge.width,!1),se.height(e?"100%":ge.height,!1),e||en.scrollTo(0,S),le(),se)},le=function(){ge.autoExpand&&!C&&(C=setTimeout(se.expandToContent,200))},se.expandToContent=function(e){var t,n;se.maximize()||(clearTimeout(C),C=!1,T||(t=ge.resizeMinHeight||ge.height||Ke(r),T={min:t,max:ge.resizeMaxHeight||2*t}),(n=tn.createRange()).selectNodeContents(f),t=n.getBoundingClientRect(),n=d.documentElement.clientHeight-1,t=t.bottom-t.top,n=se.height()+1+(t-n),e||-1===T.max||(n=Math.min(n,T.max)),se.height(Math.ceil(Math.max(n,T.min))))},se.destroy=function(){var e;g&&(g.destroy(),g=m=null,o&&Ae(o),Fe(tn,"click",G),(e=r.form)&&(Fe(e,"reset",U),Fe(e,"submit",se.updateOriginal,_e)),Fe(window,"pagehide",se.updateOriginal),Fe(window,"pageshow",U),Ae(s),Ae(u),Ae(x),delete r._sceditor,Ie(r),r.required=n)},se.createDropDown=function(e,t,n){t="sceditor-"+t,se.closeDropDown(),o&&Ve(o,t)||(e=we({top:e.offsetTop,left:e.offsetLeft,marginTop:e.clientHeight},ge.dropDownCss),Pe(o=Ee("div",{className:"sceditor-dropdown "+t}),e),Me(o,n),Me(x,o),Oe(o,"click focusin",function(e){e.stopPropagation()}),!o||(n=Re(o,"input,textarea")[0])&&n.focus())},G=function(e){3!==e.which&&o&&!e.defaultPrevented&&(ae(),se.closeDropDown())},L=function(e){var t=m.selectedRange();if(t){for(var n,o,r=Ee("div",{},d),i=t.commonAncestorContainer;i&&rt(i,!0);)i.nodeType===Se&&(o=i.cloneNode(),r.firstChild&&Me(o,r.firstChild),Me(r,o),n=n||o),i=i.parentNode;Me(n||r,t.cloneContents()),at(r),e.clipboardData.setData("text/html",r.innerHTML),Ce(Re(r,"p"),function(e,t){nt(t,"div")}),Ce(Re(r,"br"),function(e,t){t.nextSibling&&rt(t.nextSibling,!0)||Ae(t)}),Me(f,r),e.clipboardData.setData("text/plain",r.innerText),Ae(r),"cut"===e.type&&t.deleteContents(),e.preventDefault()}},H=function(e){var t,n,o=f,r=e.clipboardData;if(r){var i={},a=r.types,l=r.items;e.preventDefault();for(var s=0;s<a.length;s++){if(a.indexOf("text/html")<0&&en.FileReader&&l&&nn.test(l[s].type))return t=r.items[s].getAsFile(),n=void 0,(n=new FileReader).onload=function(e){I({html:'<img src="'+e.target.result+'" />'})},void n.readAsDataURL(t);i[a[s]]=r.getData(a[s])}i.text=i["text/plain"],i.html=ve(i["text/html"]),I(i)}else if(!k){var c=o.scrollTop;for(m.saveRange(),k=tn.createDocumentFragment();o.firstChild;)Me(k,o.firstChild);setTimeout(function(){var e=o.innerHTML;o.innerHTML="",Me(o,k),o.scrollTop=c,k=!1,m.restoreRange(),I({html:ve(e)})},0)}},I=function(e){var t=Ee("div",{},d);g.call("pasteRaw",e),Xe(x,"pasteraw",e),e.html?(t.innerHTML=ve(e.html),it(t)):t.innerHTML=ft(e.text||""),e={val:t.innerHTML},"fragmentToSource"in a&&(e.val=a.fragmentToSource(e.val,d,h)),g.call("paste",e),Xe(x,"paste",e),"fragmentToHtml"in a&&(e.val=a.fragmentToHtml(e.val,h)),g.call("pasteHtml",e),t=m.getFirstBlockParent(),se.wysiwygEditorInsertHtml(e.val,null,!0),function e(t){if(t.nodeType===Se){for(var n=t.parentNode,o=t.tagName,r=t.childNodes.length;r--;)e(t.childNodes[r]);if(rt(t)){for(r=t.style.length;r--;){var i=t.style[r];Pe(n,i)===Pe(t,i)&&t.style.removeProperty(i)}if(!t.style.length)if(He(t,"style"),"FONT"===o&&(Pe(t,"fontFamily").toLowerCase()===Pe(n,"fontFamily").toLowerCase()&&He(t,"face"),Pe(t,"color")===Pe(n,"color")&&He(t,"color"),Pe(t,"fontSize")===Pe(n,"fontSize")&&He(t,"size")),!t.attributes.length&&/SPAN|FONT/.test(o))ct(t);else if(/B|STRONG|EM|SPAN|FONT/.test(o))for(var a=/B|STRONG/.test(o),l="EM"===o;n&&rt(n)&&(!a||/bold|700/i.test(Pe(n,"fontWeight")))&&(!l||"italic"===Pe(n,"fontStyle"));){if((n.tagName===o||a&&/B|STRONG/.test(n.tagName))&&st(n,t)){ct(t);break}n=n.parentNode}var s=t.nextSibling;s&&s.tagName===o&&st(s,t)&&(Me(t,s),ct(s))}}}(t)},se.closeDropDown=function(e){o&&(Ae(o),o=null),!0===e&&se.focus()},se.wysiwygEditorInsertHtml=function(e,t,n){var o=Ke(i);se.focus(),!n&&Ne(v,"code")||(m.insertHTML(e,t),m.saveRange(),D(),it(f),Ie(n=Re(f,"#sceditor-end-marker")[0]),e=f.scrollTop,t=lt(n).top+1.5*n.offsetHeight-o,Le(n),(e<t||t+o<e)&&(f.scrollTop=t),oe(!1),m.restoreRange(),X())},se.wysiwygEditorInsertText=function(e,t){se.wysiwygEditorInsertHtml(ft(e),ft(t))},se.insertText=function(e,t){return se.inSourceMode()?se.sourceEditorInsertText(e,t):se.wysiwygEditorInsertText(e,t),se},se.sourceEditorInsertText=function(e,t){var n,o=s.selectionStart,r=s.selectionEnd,i=s.scrollTop;s.focus(),n=s.value,t&&(e+=n.substring(o,r)+t),s.value=n.substring(0,o)+e+n.substring(r,n.length),s.selectionStart=o+e.length-(t?t.length:0),s.selectionEnd=s.selectionStart,s.scrollTop=i,s.focus(),oe()},se.getRangeHelper=function(){return m},se.sourceEditorCaret=function(e){return s.focus(),e?(s.selectionStart=e.start,s.selectionEnd=e.end,this):{start:s.selectionStart,end:s.selectionEnd}},se.val=function(e,t){return ye(e)?(se.inSourceMode()?se.setSourceEditorValue(e):(!1!==t&&"toHtml"in a&&(e=a.toHtml(e)),se.setWysiwygEditorValue(e)),se):se.inSourceMode()?se.getSourceEditorValue(!1):se.getWysiwygEditorValue(t)},se.insert=function(e,t,n,o,r){return se.inSourceMode()?se.sourceEditorInsertText(e,t):(t&&(i=m.selectedHtml(),e+=(i=!1!==n&&"fragmentToSource"in a?a.fragmentToSource(i,d,h):i)+t),!1!==n&&"fragmentToHtml"in a&&(e=a.fragmentToHtml(e,h)),!1!==n&&!0===r&&(e=e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")),se.wysiwygEditorInsertHtml(e)),se;var i},se.getWysiwygEditorValue=function(e){for(var t,n=Ee("div",{},d),o=f.childNodes,r=0;r<o.length;r++)Me(n,o[r].cloneNode(!0));return Me(f,n),it(n),Ae(n),t=n.innerHTML,!1!==e&&a.hasOwnProperty("toSource")?a.toSource(t,d):t},se.getBody=function(){return f},se.getContentAreaContainer=function(){return i},se.getSourceEditorValue=function(e){var t=s.value;return!1!==e&&"toHtml"in a?a.toHtml(t):t},se.setWysiwygEditorValue=function(e){e=e||"<p><br /></p>",f.innerHTML=ve(e),D(),X(),oe(),le()},se.setSourceEditorValue=function(e){s.value=e,oe()},se.updateOriginal=function(){r.value=se.val()},D=function(){var e,l,s,c,t,u,d;ge.emoticonsEnabled&&(e=f,l=me,s=ge.emoticonsCompat,c=e.ownerDocument,t="(^|\\s| | | | |$)",u=[],d={},De(e,"code")||(Ce(l,function(e){d[e]=new RegExp(t+dt(e)+t),u.push(e)}),u.sort(function(e,t){return t.length-e.length}),function e(t){for(t=t.firstChild;t;){if(t.nodeType!==Se||Ue(t,"code")||e(t),t.nodeType===ke)for(var n=0;n<u.length;n++){var o,r=t.nodeValue,i=u[n],a=s?r.search(d[i]):r.indexOf(i);-1<a&&(o=r.indexOf(i,a),a=et(l[i],c),i=r.substr(o+i.length),a.appendChild(c.createTextNode(i)),t.nodeValue=r.substr(0,o),t.parentNode.insertBefore(a,t.nextSibling))}t=t.nextSibling}}(e)))},se.inSourceMode=function(){return Ve(x,"sourceMode")},se.sourceMode=function(e){var t=se.inSourceMode();return"boolean"!=typeof e?t:((t&&!e||!t&&e)&&se.toggleSourceMode(),se)},se.toggleSourceMode=function(){var e=se.inSourceMode();!yt&&e||(e||(m.saveRange(),m.clear()),y=null,se.blur(),e?se.setWysiwygEditorValue(se.getSourceEditorValue()):se.setSourceEditorValue(se.getWysiwygEditorValue()),Be(s),Be(i),$e(x,"wysiwygMode",e),$e(x,"sourceMode",!e),$(),Y())},K=function(){return s.focus(),s.value.substring(s.selectionStart,s.selectionEnd)},N=function(e,t){se.inSourceMode()?t.txtExec&&(Array.isArray(t.txtExec)?se.sourceEditorInsertText.apply(se,t.txtExec):t.txtExec.call(se,e,K())):t.exec&&(xe(t.exec)?t.exec.call(se,e):se.execCommand(t.exec,t.hasOwnProperty("execParam")?t.execParam:null))},se.execCommand=function(e,t){var n=!1,o=se.commands[e];if(se.focus(),!Ne(m.parentNode(),"code")){try{n=d.execCommand(e,!1,t)}catch(e){}!n&&o&&o.errorMessage&&alert(se._(o.errorMessage)),Y()}},Z=function(){function e(){if(l.getSelection()&&l.getSelection().rangeCount<=0)y=null;else if(m&&!m.compare(y)){if((y=m.cloneSelected())&&y.collapsed){var e=y.startContainer,t=y.startOffset;for(t&&e.nodeType!==ke&&(e=e.childNodes[t]);e&&e.parentNode!==f;)e=e.parentNode;e&&rt(e,!0)&&(m.saveRange(),n=d,Qe(f,function(e){rt(e,!0)?(o||e.nodeType===ke?/\S/.test(e.nodeValue):!Ue(e,".sceditor-ignore"))&&(o||We(o=Ee("p",{},n),e),Me(o,e)):o=null},!1,!0),m.restoreRange())}Xe(x,"selectionchanged")}var n,o;b=!1}b||(b=!0,"onselectionchange"in d?e():setTimeout(e,100))},Q=function(){var e,t=m.parentNode();h!==t&&(e=h,h=t,v=m.getFirstBlockParent(t),Xe(x,"nodechanged",{oldNode:e,newNode:h}))},se.currentNode=function(){return h},se.currentBlockNode=function(){return v},Y=function(){var e,t,n="active",o=d,r=se.sourceMode();if(se.readOnly())Ce(Re(u,n),function(e,t){Ge(t,n)});else{r||(t=m.parentNode(),e=m.getFirstBlockParent(t));for(var i=0;i<de.length;i++){var a=0,l=pe[de[i].name],s=de[i].state,c=r&&!l._sceTxtMode||!r&&!l._sceWysiwygMode;if(ye(s)){if(!r)try{-1<(a=o.queryCommandEnabled(s)?0:-1)&&(a=o.queryCommandState(s)?1:0)}catch(e){}}else c||(a=s.call(se,t,e));$e(l,"disabled",c||a<0),$e(l,n,0<a)}E&&E.update&&E.update(r,t,e)}},j=function(e){var t,n,o;e.defaultPrevented||(se.closeDropDown(),13!==e.which||!Ue(v,"li,ul,ol")&&tt(v)&&(t=Ee("br",{},d),m.insertNode(t),(o=(n=t.parentNode).lastChild)&&o.nodeType===ke&&""===o.nodeValue&&(Ae(o),o=n.lastChild),!rt(n,!0)&&o===t&&rt(t.previousSibling)&&m.insertHTML("<br>"),e.preventDefault()))},X=function(){Je(f,function(e){if(e.nodeType===Se&&!/inline/.test(Pe(e,"display"))&&!Ue(e,".sceditor-nlf")&&tt(e)){var t=Ee("p",{},d);return t.className="sceditor-nlf",t.innerHTML="<br />",Me(f,t),!1}if(3===e.nodeType&&!/^\s*$/.test(e.nodeValue)||Ue(e,"br"))return!1})},U=function(){se.val(r.value)},W=function(){se.closeDropDown()},se._=function(){var n=arguments;return t&&t[n[0]]&&(n[0]=t[n[0]]),n[0].replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[+t+1]?n[+t+1]:"{"+t+"}"})},q=function(t){g&&g.call(t.type+"Event",t,se);var e=(t.target===s?"scesrc":"scewys")+t.type;ce[e]&&ce[e].forEach(function(e){e.call(se,t)})},se.bind=function(e,t,n,o){for(var r,i,a=(e=e.split(" ")).length;a--;)xe(t)&&(r="scewys"+e[a],i="scesrc"+e[a],n||(ce[r]=ce[r]||[],ce[r].push(t)),o||(ce[i]=ce[i]||[],ce[i].push(t)),"valuechanged"===e[a]&&(oe.hasHandler=!0));return se},se.unbind=function(e,t,n,o){for(var r=(e=e.split(" ")).length;r--;)xe(t)&&(n||Te(ce["scewys"+e[r]]||[],t),o||Te(ce["scesrc"+e[r]]||[],t));return se},se.blur=function(e,t,n){return xe(e)?se.bind("blur",e,t,n):(se.sourceMode()?s:f).blur(),se},se.focus=function(e,t,n){if(xe(e))se.bind("focus",e,t,n);else if(se.inSourceMode())s.focus();else{if(Re(d,":focus").length)return;var o,n=m.selectedRange();y||J(!0),n&&1===n.endOffset&&n.collapsed&&(o=n.endContainer)&&1===o.childNodes.length&&Ue(o.firstChild,"br")&&(n.setStartBefore(o.firstChild),n.collapse(!0),m.selectRange(n)),l.focus(),f.focus()}return Y(),se},se.keyDown=function(e,t,n){return se.bind("keydown",e,t,n)},se.keyPress=function(e,t,n){return se.bind("keypress",e,t,n)},se.keyUp=function(e,t,n){return se.bind("keyup",e,t,n)},se.nodeChanged=function(e){return se.bind("nodechanged",e,!1,!0)},se.selectionChanged=function(e){return se.bind("selectionchanged",e,!1,!0)},se.valueChanged=function(e,t,n){return se.bind("valuechanged",e,t,n)},ee=function(e){var n=0,o=se.emoticonsCache,t=String.fromCharCode(e.which);Ne(v,"code")||(o||(o=[],Ce(me,function(e,t){o[n++]=[e,t]}),o.sort(function(e,t){return e[0].length-t[0].length}),se.emoticonsCache=o,se.longestEmoticonCode=o[o.length-1][0].length),m.replaceKeyword(se.emoticonsCache,!0,!0,se.longestEmoticonCode,ge.emoticonsCompat,t)&&(ge.emoticonsCompat&&/^\s$/.test(t)||e.preventDefault()))},te=function(){!function(e,t){var n=/[^\s\xA0\u2002\u2003\u2009]+/,o=e&&Re(e,"img[data-sceditor-emoticon]");if(e&&o.length)for(var r=0;r<o.length;r++){var i,a,l,s,c=o[r],u=c.parentNode,d=c.previousSibling,f=c.nextSibling;(d&&n.test(d.nodeValue.slice(-1))||f&&n.test((f.nodeValue||"")[0]))&&(a=-1,l=(i=t.cloneSelected()).startContainer,s=d.nodeValue||"",s+=je(c,"sceditor-emoticon"),l===f&&(a=s.length+i.startOffset),l===e&&e.childNodes[i.startOffset]===f&&(a=s.length),l===d&&(a=i.startOffset),(f=f&&f.nodeType===ke?f:u.insertBefore(u.ownerDocument.createTextNode(""),f)).insertData(0,s),Ae(d),Ae(c),-1<a&&(i.setStart(f,a),i.collapse(!0),t.selectRange(i)))}}(v,m)},se.emoticons=function(e){return e||!1===e?((ge.emoticonsEnabled=e)?(Oe(f,"keypress",ee),se.sourceMode()||(m.saveRange(),D(),oe(!1),m.restoreRange())):(Ce(Re(f,"img[data-sceditor-emoticon]"),function(e,t){var n=je(t,"sceditor-emoticon"),n=d.createTextNode(n);t.parentNode.replaceChild(n,t)}),Fe(f,"keypress",ee),oe()),se):ge.emoticonsEnabled},se.css=function(e){return w||(w=Ee("style",{id:"inline"},d),Me(d.head,w)),ye(e)?(w.styleSheet?w.styleSheet.cssText=e:w.innerHTML=e,se):w.styleSheet?w.styleSheet.cssText:w.innerHTML},B=function(e){var t=[],n={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|","[":"{","]":"}"},o={109:"-",110:"del",111:"/",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},r=e.which,i={8:"backspace",9:"tab",13:"enter",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"win",92:"win",93:"select",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}[r]||String.fromCharCode(r).toLowerCase();(e.ctrlKey||e.metaKey)&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&(t.push("shift"),o[r]?i=o[r]:n[i]&&(i=n[i])),i&&(r<16||18<r)&&t.push(i),t=t.join("+"),fe[t]&&!1===fe[t].call(se)&&(e.stopPropagation(),e.preventDefault())},se.addShortcut=function(e,t){return e=e.toLowerCase(),ye(t)?fe[e]=function(){return N(pe[t],se.commands[t]),!1}:fe[e]=t,se},se.removeShortcut=function(e){return delete fe[e.toLowerCase()],se},P=function(e){var t,n,o;if(!ge.disableBlockRemove&&8===e.which&&(n=m.selectedRange())&&(t=n.startContainer,0===n.startOffset&&(o=ne())&&!Ue(o,"body"))){for(;t!==o;){for(;t.previousSibling;)if((t=t.previousSibling).nodeType!==ke||t.nodeValue)return;if(!(t=t.parentNode))return}se.clearBlockFormatting(o),e.preventDefault()}},ne=function(){for(var e=v;!tt(e)||rt(e,!0);)if(!(e=e.parentNode)||Ue(e,"body"))return;return e},se.clearBlockFormatting=function(e){return!(e=e||ne())||Ue(e,"body")||(m.saveRange(),e.className="",ze(e,"style",""),Ue(e,"p,div,td")||nt(e,"p"),m.restoreRange()),se},oe=function(e){var t,n,o;g&&(g.hasHandler("valuechangedEvent")||oe.hasHandler)&&(o=!(n=se.sourceMode())&&m.hasSelection(),e=(c=!1)!==e&&!d.getElementById("sceditor-start-marker"),p&&(clearTimeout(p),p=!1),o&&e&&m.saveRange(),(t=n?s.value:f.innerHTML)!==oe.lastVal&&(oe.lastVal=t,Xe(x,"valuechanged",{rawValue:n?se.val():t})),o&&e&&m.removeMarkers())},re=function(){p&&oe()},ie=function(e){var t=e.which,e=13===(n=ie.lastChar)||32===n,n=8===n||46===n;ie.lastChar=t,c||(13===t||32===t?e?ie.triggerNext=!0:oe():8===t||46===t?n?ie.triggerNext=!0:oe():ie.triggerNext&&(oe(),ie.triggerNext=!1),clearTimeout(p),p=setTimeout(function(){c||oe()},1500))},V=function(e){(c=/start/i.test(e.type))||oe()},ae=function(){se.updateOriginal()},e()}on.locale={},on.formats={},on.icons={},on.command={get:function(e){return mt[e]||null},set:function(e,t){return!(!e||!t)&&((t=we(mt[e]||{},t)).remove=function(){on.command.remove(e)},mt[e]=t,this)},remove:function(e){return mt[e]&&delete mt[e],this}},window.sceditor={command:on.command,commands:mt,defaultOptions:ut,ios:vt,isWysiwygSupported:yt,regexEscape:dt,escapeEntities:ft,escapeUriScheme:function(e){var t,n=window.location;return e&&/^[^\/]*:/i.test(e)&&!m.test(e)?((t=n.pathname.split("/")).pop(),n.protocol+"//"+n.host+t.join("/")+"/"+e):e},dom:{css:Pe,attr:ze,removeAttr:He,is:Ue,closest:Ne,width:Ye,height:Ke,traverse:Qe,rTraverse:Je,parseHTML:et,hasStyling:tt,convertElement:nt,blockLevelList:c,canHaveChildren:ot,isInline:rt,copyCSS:function(e,t){t.style&&e.style&&(t.style.cssText=e.style.cssText+t.style.cssText)},fixNesting:it,findCommonAncestor:function(e,t){for(;e=e.parentNode;)if(e!==t&&e.contains&&e.contains(t))return e},getSibling:u,removeWhiteSpace:at,extractContents:f,getOffset:lt,getStyle:p,hasStyle:function(e,t,n){return!!(t=p(e,t))&&(!n||t===n||Array.isArray(n)&&-1<n.indexOf(t))}},locale:on.locale,icons:on.icons,utils:{each:Ce,isEmptyObject:t,extend:we},plugins:gt.plugins,formats:on.formats,create:function(e,t){t=t||{},De(e,".sceditor-container")||(t.runWithoutWysiwygSupport||yt)&&new on(e,t)},instance:function(e){return e._sceditor}},o.default.sceditor=window.sceditor,o.default.fn.sceditor=function(e){var t,n=[];return this.each(function(){t=this._sceditor,"state"===e?n.push(!!t):"instance"===e?n.push(t):t||o.default.sceditor.create(this,e)}),n.length?1===n.length?n[0]:n:this}}(),function(y){"use strict";var b=y.dom,e=y.utils,x=b.css,o=b.attr,w=b.is,T=b.removeAttr,n=b.convertElement,i=e.extend,a=e.each,C=e.isEmptyObject,l=y.command.get,t={bold:{txtExec:["<strong>","</strong>"]},italic:{txtExec:["<em>","</em>"]},underline:{txtExec:['<span style="text-decoration:underline;">',"</span>"]},strike:{txtExec:['<span style="text-decoration:line-through;">',"</span>"]},subscript:{txtExec:["<sub>","</sub>"]},superscript:{txtExec:["<sup>","</sup>"]},left:{txtExec:['<div style="text-align:left;">',"</div>"]},center:{txtExec:['<div style="text-align:center;">',"</div>"]},right:{txtExec:['<div style="text-align:right;">',"</div>"]},justify:{txtExec:['<div style="text-align:justify;">',"</div>"]},font:{txtExec:function(e){var t=this;l("font")._dropDown(t,e,function(e){t.insertText('<span style="font-family:'+e+';">',"</span>")})}},size:{txtExec:function(e){var t=this;l("size")._dropDown(t,e,function(e){t.insertText('<span style="font-size:'+e+';">',"</span>")})}},color:{txtExec:function(e){var t=this;l("color")._dropDown(t,e,function(e){t.insertText('<span style="color:'+e+';">',"</span>")})}},bulletlist:{txtExec:["<ul><li>","</li></ul>"]},orderedlist:{txtExec:["<ol><li>","</li></ol>"]},table:{txtExec:["<table><tr><td>","</td></tr></table>"]},horizontalrule:{txtExec:["<hr />"]},code:{txtExec:["<code>","</code>"]},image:{txtExec:function(e,t){var r=this;l("image")._dropDown(r,e,t,function(e,t,n){var o="";t&&(o+=' width="'+t+'"'),n&&(o+=' height="'+n+'"'),r.insertText("<img"+o+' src="'+e+'" />')})}},email:{txtExec:function(e,n){var o=this;l("email")._dropDown(o,e,function(e,t){o.insertText('<a href="mailto:'+e+'">'+(t||n||e)+"</a>")})}},link:{txtExec:function(e,n){var o=this;l("link")._dropDown(o,e,function(e,t){o.insertText('<a href="'+e+'">'+(t||n||e)+"</a>")})}},quote:{txtExec:["<blockquote>","</blockquote>"]},youtube:{txtExec:function(e){var n=this;l("youtube")._dropDown(n,e,function(e,t){n.insertText('<iframe width="560" height="315" src="https://www.youtube.com/embed/{id}?wmode=opaque&start='+t+'" data-youtube-id="'+e+'" frameborder="0" allowfullscreen></iframe>')})}},rtl:{txtExec:['<div stlye="direction:rtl;">',"</div>"]},ltr:{txtExec:['<div stlye="direction:ltr;">',"</div>"]}};function S(){var r=this,n={},g={};function e(e,t,n){var p,o,r,i,a,l,s,c,u,d,f,m=n.createElement("div");return m.innerHTML=t,x(m,"visibility","hidden"),n.body.appendChild(m),t=m,b.traverse(t,function(e){var t=e.nodeName.toLowerCase();h("*",e),h(t,e)},!0),p=m,b.traverse(p,function(e){var t,n=e.nodeName.toLowerCase(),o=e.parentNode,r=e.nodeType,i=!b.isInline(e),a=e.previousSibling,l=e.nextSibling,s="iframe"!==n&&function e(t,n){var o=t.childNodes,r=t.nodeName.toLowerCase(),i=t.nodeValue,a=o.length,l=S.allowedEmptyTags||[];if(n&&"br"===r)return!0;if(w(t,".sceditor-ignore"))return!0;if(-1<l.indexOf(r)||"td"===r||!b.canHaveChildren(t))return!1;if(i&&/\S|\u00A0/.test(i))return!1;for(;a--;)if(!e(o[a],n&&!t.previousSibling&&!t.nextSibling))return!1;if(t.getBoundingClientRect&&(t.className||t.hasAttributes("style")))return!(i=t.getBoundingClientRect()).width||!i.height;return!0}(e,o===p&&(!a&&!l)&&"br"!==n),c=e.ownerDocument,u=S.allowedTags,d=e.firstChild,f=S.disallowedTags;if(3!==r&&(4===r?n="!cdata":"!"!==n&&8!==r||(n="!comment"),1===r&&w(e,".sceditor-nlf")&&(!d||1===e.childNodes.length&&/br/i.test(d.nodeName)?s=!0:(e.classList.remove("sceditor-nlf"),e.className||T(e,"class"))),s?t=!0:u&&u.length?t=u.indexOf(n)<0:f&&f.length&&(t=-1<f.indexOf(n)),t)){if(!s){for(i&&a&&b.isInline(a)&&o.insertBefore(c.createTextNode(" "),e);e.firstChild;)o.insertBefore(e.firstChild,l);i&&l&&b.isInline(l)&&o.insertBefore(c.createTextNode(" "),l)}o.removeChild(e)}},!0),t=m,u=(c=S.allowedAttribs)&&!C(c),f=(d=S.disallowedAttribs)&&!C(d),g={},b.traverse(t,function(e){if(e.attributes&&(o=e.nodeName.toLowerCase(),a=e.attributes.length))for(g[o]||(g[o]=u?v(c["*"],c[o]):v(d["*"],d[o]));a--;)r=e.attributes[a],i=r.name,l=g[o][i],s=!1,u?s=null!==l&&(!Array.isArray(l)||l.indexOf(r.value)<0):f&&(s=null===l||Array.isArray(l)&&-1<l.indexOf(r.value)),s&&e.removeAttribute(i)}),e||function(e){var t;b.removeWhiteSpace(e);for(var n,o=e.firstChild;o;)n=o.nextSibling,b.isInline(o)&&!w(o,".sceditor-ignore")?(t||(t=e.ownerDocument.createElement("p"),o.parentNode.insertBefore(t,o)),t.appendChild(o)):t=null,o=n}(m),e=(new y.XHTMLSerializer).serialize(m,!0),n.body.removeChild(m),e}function h(e,o){n[e]&&n[e].forEach(function(n){n.tags[e]?a(n.tags[e],function(e,t){o.getAttributeNode&&(!(e=o.getAttributeNode(e))||t&&t.indexOf(e.value)<0||n.conv.call(r,o))}):n.conv&&n.conv.call(r,o)})}function v(e,t){var n={};return e&&(n=i({},n,e)),t&&a(t,function(e,t){Array.isArray(t)?n[e]=(n[e]||[]).concat(t):n[e]||(n[e]=null)}),n}r.init=function(){C(S.converters||{})||a(S.converters,function(e,t){a(t.tags,function(e){n[e]||(n[e]=[]),n[e].push(t)})}),this.commands=i(!0,{},t,this.commands)},r.toSource=e.bind(null,!1),r.fragmentToSource=e.bind(null,!0)}y.XHTMLSerializer=function(){var o={indentStr:"\t"},r=[],d=0;function f(e){var t={"&":"&","<":"<",">":">",'"':"""," ":" "};return e?e.replace(/[&<>"\xa0]/g,function(e){return t[e]||e}):""}function p(t,e){switch(t.nodeType){case 1:!function(e,t){var n,o,r,i=e.nodeName.toLowerCase(),a="iframe"===i,l=e.attributes.length,s=e.firstChild,c=t||/pre(?:\-wrap)?$/i.test(x(e,"whiteSpace")),u=!e.firstChild&&!b.canHaveChildren(e)&&!a;if(!w(e,".sceditor-ignore")){for(m("<"+i,!t&&g(e));l--;)o=e.attributes[l],r=o.value,m(" "+o.name.toLowerCase()+'="'+f(r)+'"',!1);for(m(u?" />":">",!1),a||(n=s);n;)d++,p(n,c),n=n.nextSibling,d--;u||m("</"+i+">",!c&&!a&&g(e)&&s&&g(s))}}(t,e);break;case 3:o=e,r=(n=t).nodeValue,!void((r=!o?r.replace(/[^\S\u00A0]+/g," "):r)&&m(f(r),!o&&g(n)));break;case 4:m("<![CDATA["+f(t.nodeValue)+"]]>");break;case 8:m("\x3c!-- "+f(t.nodeValue)+" --\x3e");break;case 9:case 11:!function(){for(var e=t.firstChild;e;)p(e),e=e.nextSibling}()}var n,o,r}function m(e,t){var n=d;if(!1!==t)for(r.length&&r.push("\n");n--;)r.push(o.indentStr);r.push(e)}function g(e){var t=e.previousSibling;return 1!==e.nodeType&&t?!b.isInline(t):!t&&!b.isInline(e.parentNode)||!b.isInline(e)}this.serialize=function(e,t){if(r=[],t)for(e=e.firstChild;e;)p(e),e=e.nextSibling;else p(e);return r.join("")}},S.converters=[{tags:{"*":{width:null}},conv:function(e){x(e,"width",o(e,"width")),T(e,"width")}},{tags:{"*":{height:null}},conv:function(e){x(e,"height",o(e,"height")),T(e,"height")}},{tags:{li:{value:null}},conv:function(e){T(e,"value")}},{tags:{"*":{text:null}},conv:function(e){x(e,"color",o(e,"text")),T(e,"text")}},{tags:{"*":{color:null}},conv:function(e){x(e,"color",o(e,"color")),T(e,"color")}},{tags:{"*":{face:null}},conv:function(e){x(e,"fontFamily",o(e,"face")),T(e,"face")}},{tags:{"*":{align:null}},conv:function(e){x(e,"textAlign",o(e,"align")),T(e,"align")}},{tags:{"*":{border:null}},conv:function(e){x(e,"borderWidth",o(e,"border")),T(e,"border")}},{tags:{applet:{name:null},img:{name:null},layer:{name:null},map:{name:null},object:{name:null},param:{name:null}},conv:function(e){o(e,"id")||o(e,"id",o(e,"name")),T(e,"name")}},{tags:{"*":{vspace:null}},conv:function(e){x(e,"marginTop",+o(e,"vspace")),x(e,"marginBottom",+o(e,"vspace")),T(e,"vspace")}},{tags:{"*":{hspace:null}},conv:function(e){x(e,"marginLeft",+o(e,"hspace")),x(e,"marginRight",+o(e,"hspace")),T(e,"hspace")}},{tags:{hr:{noshade:null}},conv:function(e){x(e,"borderStyle","solid"),T(e,"noshade")}},{tags:{"*":{nowrap:null}},conv:function(e){x(e,"whiteSpace","nowrap"),T(e,"nowrap")}},{tags:{big:null},conv:function(e){x(n(e,"span"),"fontSize","larger")}},{tags:{small:null},conv:function(e){x(n(e,"span"),"fontSize","smaller")}},{tags:{b:null},conv:function(e){n(e,"strong")}},{tags:{u:null},conv:function(e){x(n(e,"span"),"textDecoration","underline")}},{tags:{s:null,strike:null},conv:function(e){x(n(e,"span"),"textDecoration","line-through")}},{tags:{dir:null},conv:function(e){n(e,"ul")}},{tags:{center:null},conv:function(e){x(n(e,"div"),"textAlign","center")}},{tags:{font:{size:null}},conv:function(e){x(e,"fontSize",x(e,"fontSize")),T(e,"size")}},{tags:{font:null},conv:function(e){n(e,"span")}},{tags:{"*":{type:["_moz"]}},conv:function(e){T(e,"type")}},{tags:{"*":{_moz_dirty:null}},conv:function(e){T(e,"_moz_dirty")}},{tags:{"*":{_moz_editor_bogus_node:null}},conv:function(e){e.parentNode.removeChild(e)}},{tags:{"*":{"data-sce-target":null}},conv:function(e){var t=o(e,"rel")||"",n=o(e,"data-sce-target");"_blank"===n&&w(e,"a")&&(/(^|\s)noopener(\s|$)/.test(t)||o(e,"rel","noopener"+(t?" "+t:"")),o(e,"target",n)),T(e,"data-sce-target")}},{tags:{code:null},conv:function(e){for(var t=e.getElementsByTagName("div");e=t[0];)e.style.display="block",n(e,"span")}}],S.allowedAttribs={},S.disallowedAttribs={},S.allowedTags=[],S.disallowedTags=[],S.allowedEmptyTags=[],y.formats.xhtml=S}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/alternative-lists.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(n){"use strict";var e=n.utils;n.plugins["alternative-lists"]=function(){var l,i,s;this.init=function(){var t=this.opts;t.format&&"bbcode"!==t.format||(n.command.get("orderedlist").txtExec=i,n.command.get("bulletlist").txtExec=l,n.formats.bbcode.set("list",{breakStart:!0,isInline:!1,skipLastLineBreak:!0,html:function(t,l,i){var s="disc",e=null;return"function"==typeof(e=("1"===(s=l.defaultattr?l.defaultattr:s)?n.formats.bbcode.get("ol"):n.formats.bbcode.get("ul")).html)?e.call(this,t,l,i):(t.attrs[0]=i,n.formats.bbcode.formatBBCodeString(e,t.attrs))}}),n.formats.bbcode.set("ul",{tags:{ul:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[list]{0}[/list]",html:"<ul>{0}</ul>"}),n.formats.bbcode.set("ol",{tags:{ol:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[list=1]{0}[/list]",html:"<ol>{0}</ol>"}),n.formats.bbcode.set("li",{tags:{li:null},isInline:!1,closedBy:["/ul","/ol","/list","*","li"],format:"[*]{0}",html:"<li>{0}</li>"}),n.formats.bbcode.set("*",{isInline:!1,excludeClosing:!0,closedBy:["/ul","/ol","/list","*","li"],html:"<li>{0}</li>"}))},s=function(t,l,i){var s="";e.each(i.split(/\r?\n/),function(t){s+=(s?"\n":"")+"[*]"+t}),""===l?t.insertText("[list]\n"+s+"\n[/list]"):t.insertText("[list="+l+"]\n"+s+"\n[/list]")},i=function(t,l){s(this,"1",l)},l=function(t,l){s(this,"",l)}}}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/autosave.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(e){"use strict";var t="sce-autodraft-"+location.pathname+location.search;function c(e){localStorage.removeItem(e||t)}e.plugins.autosave=function(){var a,e=this,o=!1,r=t,n=864e5,s=function(e){localStorage.setItem(r,JSON.stringify(e))},i=function(){return JSON.parse(localStorage.getItem(r))};e.init=function(){var e=(a=this).opts&&a.opts.autosave||{};s=e.save||s,i=e.load||i,r=e.storageKey||r,n=e.expires||n,function(){for(var e=0;e<localStorage.length;e++){var t,a=localStorage.key(e);!/^sce\-autodraft\-/.test(a)||(t=JSON.parse(localStorage.getItem(r)))&&t.time<Date.now()-n&&c(a)}}()},e.signalReady=function(){for(var e=a.getContentAreaContainer();e;){if(/form/i.test(e.nodeName)){e.addEventListener("submit",c.bind(null,r),!0);break}e=e.parentNode}var t=i();t?(o=!0,a.sourceMode(t.sourceMode),a.val(t.value,!1),a.focus(),t.sourceMode?a.sourceEditorCaret(t.caret):a.getRangeHelper().restoreRange(),o=!1):s({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:a.val(null,!1),time:Date.now()})},e.signalValuechangedEvent=function(e){o||s({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:e.detail.rawValue,time:Date.now()})}},e.plugins.autosave.clear=c}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/autoyoutube.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(a,n){"use strict";var c=n.dom,d=/(^|\s)(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/watch\?v=)([^"&?\/ ]{11})(?:\&[\&_\?0-9a-z\#]+)?(\s|$)/i;function l(e){return'<iframe width="560" height="315" frameborder="0" src="https://www.youtube-nocookie.com/embed/'+e+'" data-youtube-id="'+e+'" allowfullscreen></iframe>'}n.plugins.autoyoutube=function(){this.signalPasteRaw=function(e){var t;c.closest(this.currentNode(),"code")||(e.html||e.text)&&((t=a.createElement("div")).innerHTML=e.html||n.escapeEntities(e.text),function e(t,n){var r,i,o=t.firstChild,s=t.textContent||"",u=(s=n?s.trim():s).match(d);if(s===s.trim()&&u&&u[0].length===s.length)return c.removeAttr(t,"style"),c.removeAttr(t,"class"),void(t.innerHTML=l(u[2]));for(;o;)3===o.nodeType?(r=o.nodeValue,i=o.parentNode,(u=r.match(d))&&(i.insertBefore(a.createTextNode(r.substr(0,u.index)+u[1]),o),i.insertBefore(c.parseHTML(l(u[2])),o),o.nodeValue=u[3]+r.substr(u.index+u[0].length))):c.is(o,"code")||e(o),o=o.nextSibling}(t,!0),e.html=t.innerHTML)}}}(document,sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/dragdrop.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(n){"use strict";var v=void 0!==window.FileReader,c=/data:[^;]+;base64,/i;n.plugins.dragdrop=function(){var A,r,o,a,i,s;function d(){i.style.display="none",a.className=a.className.replace(/(^| )dnd( |$)/g,"")}function l(e){return!("application/x-moz-file"!==e.type&&A.allowedTypes&&A.allowedTypes.indexOf(e.type)<0)&&(!A.isAllowed||A.isAllowed(e))}function f(e){var n=document.createElement("img");function t(e){var t=r.getBody().ownerDocument.getElementById(n.id);t&&("string"==typeof e&&t.insertAdjacentHTML("afterend",e),t.parentNode.removeChild(t))}return n.src="data:image/gif;base64,R0lGODlhlgBkAPABAH19ffb29iH5BAAKAAAAIf4aQ3JlYXRlZCB3aXRoIGFqYXhsb2FkLmluZm8AIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAlgBkAAAC1YyPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2Py+f0uv2OvwD2fP6iD/gH6Pc2GIhg2JeQSNjGuLf4GMlYKIloefAIUEl52ZmJyaY5mUhqyFnqmQr6KRoaMKp66hbLumpQ69oK+5qrOyg4a6qYV2x8jJysvMzc7PwMHS09TV1tfY2drb3N3e39DR4uPk5ebn6Onq6+zt7u/g4fL99UAAAh+QQACgAAACwAAAAAlgBkAIEAAAB9fX329vYAAAAC3JSPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2Py+f0uv2OvwD2fP4iABgY+CcoCNeHuJdQyLjIaOiWiOj4CEhZ+SbZd/nI2RipqYhQOThKGpAZCuBZyArZprpqSupaCqtaazmLCRqai7rb2av5W5wqSShcm8fc7PwMHS09TV1tfY2drb3N3e39DR4uPk5ebn6Onq6+zt7u/g4fLz9PX29/j5/vVAAAIfkEAAoAAAAsAAAAAJYAZACBAAAAfX199vb2AAAAAuCUj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9jr8E9nz+AgAYGLjQVwhXiJgguAiYgGjo9tinyCjoKLn3hpmJUGmJsBmguUnpCXCJOZraaXoKShoJe9DqehCqKlnqiZobuzrbyvuIO8xqKpxIPKlwrPCbBx0tPU1dbX2Nna29zd3t/Q0eLj5OXm5+jp6uvs7e7v4OHy8/T19vf4+fr7/P379UAAAh+QQACgAAACwAAAAAlgBkAIEAAAB9fX329vYAAAAC4JSPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2Py+f0uv2OvwT2fP6iD7gAMEhICAeImIAYiFDoOPi22KcouZfw6BhZGUBZeYlp6LbJiTD6CQqg6Vm6eQqqKtkZ24iaKtrKunpQa9tmmju7Wwu7KFtMi3oYDMzompkHHS09TV1tfY2drb3N3e39DR4uPk5ebn6Onq6+zt7u/g4fLz9PX29/j5+vv8/f31QAADs=",n.className="sceditor-ignore",n.id="sce-dragdrop-"+s++,function(){return e?e.parentNode.replaceChild(n,e):r.wysiwygEditorInsertHtml(n.outerHTML),{insert:function(e){t(e)},cancel:t}}}function e(e){for(var t=e.dataTransfer,n=t.files.length||!t.items?t.files:t.items,r=0;r<n.length;r++)if("string"===n[r].kind)return;"none"===i.style.display&&(i.style.display="block",a.className+=" dnd"),e.preventDefault()}function t(e){var t=e.dataTransfer,n=t.files.length||!t.items?t.files:t.items;d();for(var r=0;r<n.length;r++){if("string"===n[r].kind)return;l(n[r])&&o(n[r],f())}e.preventDefault()}v&&(s=0,this.signalReady=function(){A=(r=this).opts.dragdrop||{},o=A.handleFile,a=r.getContentAreaContainer().parentNode,i=a.appendChild(n.dom.parseHTML('<div class="sceditor-dnd-cover" style="display: none"><p>'+r._("Drop files here")+"</p></div>").firstChild),a.addEventListener("dragover",e),a.addEventListener("dragleave",d),a.addEventListener("dragend",d),a.addEventListener("drop",t),r.getBody().addEventListener("dragover",e),r.getBody().addEventListener("drop",d)},this.signalPasteHtml=function(e){if(!("handlePaste"in A)||A.handlePaste){var t=document.createElement("div");t.innerHTML=e.val;for(var n=t.querySelectorAll("img"),r=0;r<n.length;r++){var a,i=n[r];c.test(i.src)&&((a=function(e){for(var t=e.substr(5,e.indexOf(";")-5),n=atob(e.substr(e.indexOf(",")+1)),r=new Uint8Array(n.length),a=0;a<n.length;a++)r[a]=n[a].charCodeAt(0);try{return new Blob([r],{type:t})}catch(e){return null}}(i.src))&&l(a)?o(a,f(i)):i.parentNode.removeChild(i))}e.val=t.innerHTML}})}}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/format.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(i){"use strict";i.plugins.format=function(){var n,a,c={p:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",address:"Address",pre:"Preformatted Text"};this.init=function(){var e=this.opts,t=e.paragraphformat;e.format&&"bbcode"===e.format||(t&&(t.tags&&(c=t.tags),t.excludeTags&&t.excludeTags.forEach(function(e){delete c[e]})),this.commands.format||(this.commands.format={exec:a,txtExec:a,tooltip:"Format Paragraph"}),e.toolbar===i.defaultOptions.toolbar&&(e.toolbar=e.toolbar.replace(",color,",",color,format,")))},n=function(e,t){e.sourceMode()?e.insert("<"+t+">","</"+t+">"):e.execCommand("formatblock","<"+t+">")},a=function(e){var o=this,r=document.createElement("div");i.utils.each(c,function(t,a){var e=document.createElement("a");e.className="sceditor-option",e.textContent=a.name||a,e.addEventListener("click",function(e){o.closeDropDown(!0),a.exec?a.exec(o):n(o,t),e.preventDefault()}),r.appendChild(e)}),o.createDropDown(e,"format",r)}}}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/plaintext.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(t){"use strict";var i=t.utils,l=t.dom;t.plugins.plaintext=function(){var n=!0;this.init=function(){var t=this.commands,e=this.opts;e&&e.plaintext&&e.plaintext.addButton&&(n=e.plaintext.enabled,t.pastetext=i.extend(t.pastetext||{},{state:function(){return n?1:0},exec:function(){n=!n}}))},this.signalPasteRaw=function(t){var e;n&&(t.html&&!t.text&&((e=document.createElement("div")).innerHTML=t.html,i.each(e.querySelectorAll("p"),function(t,e){l.convertElement(e,"div")}),i.each(e.querySelectorAll("br"),function(t,e){e.nextSibling&&l.isInline(e.nextSibling,!0)||e.parentNode.removeChild(e)}),document.body.appendChild(e),t.text=e.innerText,document.body.removeChild(e)),t.html=null)}}}(sceditor); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/undo.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(){"use strict";sceditor.plugins.undo=function(){var n,o,r,i,a=this,s="",c=0,u=!1,d=!1,l=!1,e=50,t=[],g=0;function f(e){var t;d=!0,o.sourceMode(e.sourceMode),e.sourceMode?(o.val(e.value,!1),o.sourceEditorCaret(e.caret)):(o.getBody().innerHTML=e.value,function(e,t){try{var n=t.startPositions,o=t.endPositions;e.setStart(S(r,n),n[0]),e.setEnd(S(r,o),o[0])}catch(e){console&&console.warn&&console.warn("[SCEditor] Undo plugin lost caret",e)}}(t=o.getRangeHelper().selectedRange(),e.caret),o.getRangeHelper().selectRange(t)),o.focus(),d=!1}function p(e,t){var n=e[t];e[t]=function(){var e=u;!e&&!d&&i&&o.getRangeHelper().hasSelection()&&h(),u=!0,n.apply(this,arguments),e||(u=!1,d||(v(),s=""))}}function v(){g&&(t.length-=g,g=0),0<e&&t.length>e&&t.shift(),i={},h(),t.push(i)}function h(){var e,t=o.sourceMode();i.caret=t?o.sourceEditorCaret():(e=o.getRangeHelper().selectedRange(),r.normalize(),{startPositions:y(e.startContainer,e.startOffset),endPositions:y(e.endContainer,e.endOffset)}),i.sourceMode=t,i.value=t?o.getSourceEditorValue(!1):o.getBody().innerHTML}function E(){n===document.activeElement&&a.signalSelectionchangedEvent()}function y(e,t){for(var n=[t],o=e;o&&"BODY"!==o.tagName;)n.push(function(e){var t=0;for(;e=e.previousSibling;)t++;return t}(o)),o=o.parentNode;return n}function S(e,t){for(var n=t.length-1;e&&0<n;n--)e=e.childNodes[t[n]];return e}a.init=function(){e=(o=this).undoLimit||e,o.addShortcut("ctrl+z",a.undo),o.addShortcut("ctrl+shift+z",a.redo),o.addShortcut("ctrl+y",a.redo)},a.signalReady=function(){function e(e){"historyUndo"===e.inputType?(a.undo(),e.preventDefault()):"historyRedo"===e.inputType&&(a.redo(),e.preventDefault())}function t(){s="",v()}n=o.getContentAreaContainer().nextSibling,r=o.getBody(),v(),p(o,"setWysiwygEditorValue"),p(o,"setSourceEditorValue"),p(o,"sourceEditorInsertText"),p(o.getRangeHelper(),"insertNode"),p(o,"toggleSourceMode"),r.addEventListener("beforeinput",e),n.addEventListener("beforeinput",e),r.addEventListener("compositionend",t),n.addEventListener("compositionend",t),document.addEventListener("selectionchange",E)},a.destroy=function(){document.removeEventListener("selectionchange",E)},a.undo=function(){return i=null,g<t.length-1&&(g++,f(t[t.length-1-g])),!1},a.redo=function(){return 0<g&&(g--,f(t[t.length-1-g])),!1},a.signalSelectionchangedEvent=function(){d||l?l=!1:(i&&h(),s="")},a.signalInputEvent=function(e){var t=e.inputType;if(l=!0,t&&!e.isComposing)switch(e.inputType){case"deleteContentBackward":i&&s===t&&c<20?h():(v(),c=0),s=t;break;case"insertText":c+=e.data?e.data.length:1,i&&s===t&&c<20&&!/\s$/.test(e.data)?h():(v(),c=0),s=t;break;default:s="sce-misc",c=0,v()}}}}(); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/plugins/v1compat.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(t,r){"use strict";var e=t.plugins;function n(c){if(c._scePatched)return c;function t(){for(var t=[],e=0;e<arguments.length;e++){var n=arguments[e];n&&n.nodeType?t.push(r(n)):t.push(n)}return c.apply(this,t)}return t._scePatched=!0,t}function c(t){if(t._scePatched)return t;function e(){return r(t.apply(this,arguments))}return e._scePatched=!0,e}var o,a=t.command.set;t.command.set=function(t,e){return e&&"function"==typeof e.exec&&(e.exec=n(e.exec)),e&&"function"==typeof e.txtExec&&(e.txtExec=n(e.txtExec)),a.call(this,t,e)},e.bbcode&&(o=e.bbcode.bbcode.set,e.bbcode.bbcode.set=function(t,e){return e&&"function"==typeof e.format&&(e.format=n(e.format)),o.call(this,t,e)});var i=t.create;t.create=function(t,e){i.call(this,t,e),t&&t._sceditor&&((t=t._sceditor).getBody=c(t.getBody),t.getContentAreaContainer=c(t.getContentAreaContainer))}}(sceditor,jQuery); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/sceditor.min.js Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,3 @@ +/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */ + +!function(){"use strict";function e(e,t){return typeof t===e}var ye=e.bind(null,"string"),be=e.bind(null,"undefined"),xe=e.bind(null,"function"),o=e.bind(null,"number");function t(e){return!Object.keys(e).length}function we(e,t){var n=e===!!e,o=n?2:1,r=n?t:e,i=n&&e;function a(e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype}for(;o<arguments.length;o++){var l,s=arguments[o];for(l in s){var c,u,d=r[l],f=s[l];be(f)||"__proto__"!==l&&"constructor"!==l&&(u=a(f),c=Array.isArray(f),i&&(u||c)?(u=a(d)===u&&Array.isArray(d)===c,r[l]=we(!0,u?d:c?[]:{},f)):r[l]=f)}}return r}function Te(e,t){t=e.indexOf(t);-1<t&&e.splice(t,1)}function Ce(t,n){if(Array.isArray(t)||"length"in t&&o(t.length))for(var e=0;e<t.length;e++)n(e,t[e]);else Object.keys(t).forEach(function(e){n(e,t[e])})}var r={},Se=1,ke=3,l=8;function i(e){return e=parseFloat(e),isFinite(e)?e:0}function De(e,t,n){var o=(n||document).createElement(e);return Ce(t||{},function(e,t){"style"===e?o.style.cssText=t:e in o?o[e]=t:o.setAttribute(e,t)}),o}function Ee(e,t){for(var n=e||{};(n=n.parentNode)&&!/(9|11)/.test(n.nodeType);)if(!t||je(n,t))return n}function Ne(e,t){return je(e,t)?e:Ee(e,t)}function Me(e){e.parentNode&&e.parentNode.removeChild(e)}function Ae(e,t){e.appendChild(t)}function Re(e,t){return e.querySelectorAll(t)}var _e=!0;function Fe(n,e,o,r,i){e.split(" ").forEach(function(e){var t;ye(o)?(t=r["_sce-event-"+e+o]||function(e){for(var t=e.target;t&&t!==n;){if(je(t,o))return void r.call(t,e);t=t.parentNode}},r["_sce-event-"+e+o]=t):(t=o,i=r),n.addEventListener(e,t,i||!1)})}function Oe(n,e,o,r,i){e.split(" ").forEach(function(e){var t;ye(o)?t=r["_sce-event-"+e+o]:(t=o,i=r),n.removeEventListener(e,t,i||!1)})}function He(e,t,n){if(arguments.length<3)return e.getAttribute(t);null==n?ze(e,t):e.setAttribute(t,n)}function ze(e,t){e.removeAttribute(t)}function Le(e){Pe(e,"display","none")}function Ie(e){Pe(e,"display","")}function Be(e){(Ze(e)?Le:Ie)(e)}function Pe(n,e,t){if(arguments.length<3){if(ye(e))return 1===n.nodeType?getComputedStyle(n)[e]:null;Ce(e,function(e,t){Pe(n,e,t)})}else{var o=(t||0===t)&&!isNaN(t);n.style[e]=o?t+"px":t}}function Ue(e,t,n){var o=arguments.length,r={};if(e.nodeType===Se)return 1===o?(Ce(e.attributes,function(e,t){/^data\-/i.test(t.name)&&(r[t.name.substr(5)]=t.value)}),r):2===o?He(e,"data-"+t):void He(e,"data-"+t,String(n))}function je(e,t){var n=!1;return n=e&&e.nodeType===Se?(e.matches||e.msMatchesSelector||e.webkitMatchesSelector).call(e,t):n}function We(e,t){return t.parentNode.insertBefore(e,t)}function a(e){return e.className.trim().split(/\s+/)}function Ve(e,t){return je(e,"."+t)}function qe(e,t){var n=a(e);n.indexOf(t)<0&&n.push(t),e.className=n.join(" ")}function Ge(e,t){var n=a(e);Te(n,t),e.className=n.join(" ")}function $e(e,t,n){((n=be(n)?!Ve(e,t):n)?qe:Ge)(e,t)}function Ye(e,t){if(be(t)){var n=getComputedStyle(e),o=i(n.paddingLeft)+i(n.paddingRight),n=i(n.borderLeftWidth)+i(n.borderRightWidth);return e.offsetWidth-o-n}Pe(e,"width",t)}function Ke(e,t){if(be(t)){var n=getComputedStyle(e),o=i(n.paddingTop)+i(n.paddingBottom),n=i(n.borderTopWidth)+i(n.borderBottomWidth);return e.offsetHeight-o-n}Pe(e,"height",t)}function Xe(e,t,n){var o;xe(window.CustomEvent)?o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(o=e.ownerDocument.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n),e.dispatchEvent(o)}function Ze(e){return e.getClientRects().length}function Je(e,t,n,o,r){for(e=r?e.lastChild:e.firstChild;e;){var i=r?e.previousSibling:e.nextSibling;if(!n&&!1===t(e)||!o&&!1===Je(e,t,n,o,r)||n&&!1===t(e))return!1;e=i}}function Qe(e,t,n,o){Je(e,t,n,o,!0)}function et(e,t){var n=(t=t||document).createDocumentFragment(),o=De("div",{},t);for(o.innerHTML=e;o.firstChild;)Ae(n,o.firstChild);return n}function tt(e){return e&&(!je(e,"p,div")||e.className||He(e,"style")||!t(Ue(e)))}function nt(e,t){var n=De(t,{},e.ownerDocument);for(Ce(e.attributes,function(e,t){try{He(n,t.name,t.value)}catch(e){}});e.firstChild;)Ae(n,e.firstChild);return e.parentNode.replaceChild(n,e),n}var s="|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|details|section|article|aside|nav|main|header|hgroup|footer|fieldset|dl|dt|dd|figure|figcaption|";function ot(e){return!!/11?|9/.test(e.nodeType)&&"|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr|isindex|link|meta|param|command|embed|keygen|source|track|object|".indexOf("|"+e.nodeName.toLowerCase()+"|")<0}function rt(e,t){var n=(e||{}).nodeType||ke;return n!==Se?n===ke:"code"===(e=e.tagName.toLowerCase())?!t:s.indexOf("|"+e+"|")<0}function d(e){return e.lastChild&&d(e.lastChild)&&Me(e.lastChild),3===e.nodeType?!e.nodeValue:ot(e)&&!e.childNodes.length}function it(e){Je(e,function(e){var t=!rt(e,!0)&&e.nodeType!==l,n=e.parentNode;if(t&&(rt(n,!0)||"P"===n.tagName)){for(var o=e;rt(o.parentNode,!0)||"P"===o.parentNode.tagName;)o=o.parentNode;for(var r=c(o,e),i=e;n&&rt(n,!0);){if(n.nodeType===Se){for(var a=n.cloneNode();i.firstChild;)Ae(a,i.firstChild);Ae(i,a)}n=n.parentNode}We(i,o),d(r)||We(r,i),d(o)&&Me(o)}t&&je(e,"ul,ol")&&je(e.parentNode,"ul,ol")&&(r="li",t=(t=e).previousElementSibling,(t=!r||!t||je(t,r)?t:null)||We(t=De("li"),e),Ae(t,e))})}function u(e,t){return e?(t?e.previousSibling:e.nextSibling)||u(e.parentNode,t):null}function at(e){var t,n,o,r,i,a,l=Pe(e,"whiteSpace"),s=/line$/i.test(l),c=e.firstChild;if(!/pre(\-wrap)?$/i.test(l))for(;c;){if(i=c.nextSibling,t=c.nodeValue,(a=c.nodeType)===Se&&c.firstChild&&at(c),a===ke){for(n=u(c),o=u(c,!0),a=!1;Ve(o,"sceditor-ignore");)o=u(o,!0);if(rt(c)&&o){for(r=o;r.lastChild;)for(r=r.lastChild;Ve(r,"sceditor-ignore");)r=u(r,!0);a=r.nodeType===ke?/[\t\n\r ]$/.test(r.nodeValue):!rt(r)}t=t.replace(/\u200B/g,""),o&&rt(o)&&!a||(t=t.replace(s?/^[\t ]+/:/^[\t\n\r ]+/,"")),(t=!n||!rt(n)?t.replace(s?/[\t ]+$/:/[\t\n\r ]+$/,""):t).length?c.nodeValue=t.replace(s?/[\t ]+/g:/[\t\n\r ]+/g," "):Me(c)}c=i}}function c(e,t){var n=e.ownerDocument.createRange();return n.setStartBefore(e),n.setEndAfter(t),n.extractContents()}function lt(e){for(var t=0,n=0;e;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;return{left:t,top:n}}function f(e,t){var n=e.style;return r[t]||(r[t]=t.replace(/^-ms-/,"ms-").replace(/-(\w)/g,function(e,t){return t.toUpperCase()})),n=n[t=r[t]],"textAlign"===t&&(n=n||Pe(e,t),Pe(e.parentNode,t)===n||"block"!==Pe(e,"display")||je(e,"hr,th"))?"":n}function st(e,t){var n=e.attributes.length;if(n===t.attributes.length){for(;n--;){var o=e.attributes[n];if("style"===o.name?!function(e,t){var n=e.style.length;if(n===t.style.length){for(;n--;){var o=e.style[n];if(e.style[o]!==t.style[o])return}return 1}}(e,t):o.value!==He(t,o.name))return}return 1}}function ct(e){for(;e.firstChild;)We(e.firstChild,e);Me(e)}var ut={toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,image,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source",toolbarExclude:null,style:"jquery.sceditor.default.css",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana",colors:"#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef",locale:He(document.documentElement,"lang")||"en",charset:"utf-8",emoticonsCompat:!1,emoticonsEnabled:!0,emoticonsRoot:"",emoticons:{dropdown:{":)":"emoticons/smile.png",":angel:":"emoticons/angel.png",":angry:":"emoticons/angry.png","8-)":"emoticons/cool.png",":'(":"emoticons/cwy.png",":ermm:":"emoticons/ermm.png",":D":"emoticons/grin.png","<3":"emoticons/heart.png",":(":"emoticons/sad.png",":O":"emoticons/shocked.png",":P":"emoticons/tongue.png",";)":"emoticons/wink.png"},more:{":alien:":"emoticons/alien.png",":blink:":"emoticons/blink.png",":blush:":"emoticons/blush.png",":cheerful:":"emoticons/cheerful.png",":devil:":"emoticons/devil.png",":dizzy:":"emoticons/dizzy.png",":getlost:":"emoticons/getlost.png",":happy:":"emoticons/happy.png",":kissing:":"emoticons/kissing.png",":ninja:":"emoticons/ninja.png",":pinch:":"emoticons/pinch.png",":pouty:":"emoticons/pouty.png",":sick:":"emoticons/sick.png",":sideways:":"emoticons/sideways.png",":silly:":"emoticons/silly.png",":sleeping:":"emoticons/sleeping.png",":unsure:":"emoticons/unsure.png",":woot:":"emoticons/w00t.png",":wassat:":"emoticons/wassat.png"},hidden:{":whistling:":"emoticons/whistling.png",":love:":"emoticons/wub.png"}},width:null,height:null,resizeEnabled:!0,resizeMinWidth:null,resizeMinHeight:null,resizeMaxHeight:null,resizeMaxWidth:null,resizeHeight:!0,resizeWidth:!0,dateFormat:"year-month-day",toolbarContainer:null,enablePasteFiltering:!1,disablePasting:!1,readOnly:!1,rtl:!1,autofocus:!1,autofocusEnd:!0,autoExpand:!1,autoUpdate:!1,spellcheck:!0,runWithoutWysiwygSupport:!1,startInSourceMode:!1,id:null,plugins:"",zIndex:null,bbcodeTrim:!1,disableBlockRemove:!1,allowedIframeUrls:[],parserOptions:{},dropDownCss:{}},p=/^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i;function dt(e){return e.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function ft(e,t){if(!e)return e;var n={"&":"&","<":"<",">":">"," ":" ","\r\n":"<br />","\r":"<br />","\n":"<br />"};return!1!==t&&(n['"']=""",n["'"]="'",n["`"]="`"),e=e.replace(/ {2}|\r\n|[&<>\r\n'"`]/g,function(e){return n[e]||e})}var m={html:'<!DOCTYPE html><html{attrs}><head><meta http-equiv="Content-Type" content="text/html;charset={charset}" /><link rel="stylesheet" type="text/css" href="{style}" /></head><body contenteditable="true" {spellcheck}><p></p></body></html>',toolbarButton:'<a class="sceditor-button sceditor-button-{name}" data-sceditor-command="{name}" unselectable="on"><div unselectable="on">{dispName}</div></a>',emoticon:'<img src="{url}" data-sceditor-emoticon="{key}" alt="{key}" title="{tooltip}" />',fontOpt:'<a class="sceditor-font-option" href="#" data-font="{font}"><font face="{font}">{font}</font></a>',sizeOpt:'<a class="sceditor-fontsize-option" data-size="{size}" href="#"><font size="{size}">{size}</font></a>',pastetext:'<div><label for="txt">{label}</label> <textarea cols="20" rows="7" id="txt"></textarea></div><div><input type="button" class="button" value="{insert}" /></div>',table:'<div><label for="rows">{rows}</label><input type="text" id="rows" value="2" /></div><div><label for="cols">{cols}</label><input type="text" id="cols" value="2" /></div><div><input type="button" class="button" value="{insert}" /></div>',image:'<div><label for="image">{url}</label> <input type="text" id="image" dir="ltr" placeholder="https://" /></div><div><label for="width">{width}</label> <input type="text" id="width" size="2" dir="ltr" /></div><div><label for="height">{height}</label> <input type="text" id="height" size="2" dir="ltr" /></div><div><input type="button" class="button" value="{insert}" /></div>',email:'<div><label for="email">{label}</label> <input type="text" id="email" dir="ltr" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{insert}" /></div>',link:'<div><label for="link">{url}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{ins}" /></div>',youtubeMenu:'<div><label for="link">{label}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><input type="button" class="button" value="{insert}" /></div>',youtube:'<iframe width="560" height="315" frameborder="0" allowfullscreen src="https://www.youtube-nocookie.com/embed/{id}?wmode=opaque&start={time}" data-youtube-id="{id}"></iframe>'};function pt(e,t,n){var o=m[e];return Object.keys(t).forEach(function(e){o=o.replace(new RegExp(dt("{"+e+"}"),"g"),t[e])}),o=n?et(o):o}function n(e){if("mozHidden"in document)for(var t,n=e.getBody();n;){if((t=n).firstChild)t=t.firstChild;else{for(;t&&!t.nextSibling;)t=t.parentNode;t=t&&t.nextSibling}3===n.nodeType&&/[\n\r\t]+/.test(n.nodeValue)&&(/^pre/.test(Pe(n.parentNode,"whiteSpace"))||Me(n)),n=t}}var mt={bold:{exec:"bold",tooltip:"Bold",shortcut:"Ctrl+B"},italic:{exec:"italic",tooltip:"Italic",shortcut:"Ctrl+I"},underline:{exec:"underline",tooltip:"Underline",shortcut:"Ctrl+U"},strike:{exec:"strikethrough",tooltip:"Strikethrough"},subscript:{exec:"subscript",tooltip:"Subscript"},superscript:{exec:"superscript",tooltip:"Superscript"},left:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===Pe(e,"direction"),e=Pe(e,"textAlign");return/left/.test(e)||e===(t?"start":"end")}},exec:"justifyleft",tooltip:"Align left"},center:{exec:"justifycenter",tooltip:"Center"},right:{state:function(e){if(e=e&&3===e.nodeType?e.parentNode:e){var t="ltr"===Pe(e,"direction"),e=Pe(e,"textAlign");return/right/.test(e)||e===(t?"end":"start")}},exec:"justifyright",tooltip:"Align right"},justify:{exec:"justifyfull",tooltip:"Justify"},font:{_dropDown:function(t,e,n){var o=De("div");Fe(o,"click","a",function(e){n(Ue(this,"font")),t.closeDropDown(!0),e.preventDefault()}),t.opts.fonts.split(",").forEach(function(e){Ae(o,pt("fontOpt",{font:e},!0))}),t.createDropDown(e,"font-picker",o)},exec:function(e){var t=this;mt.font._dropDown(t,e,function(e){t.execCommand("fontname",e)})},tooltip:"Font Name"},size:{_dropDown:function(t,e,n){var o=De("div");Fe(o,"click","a",function(e){n(Ue(this,"size")),t.closeDropDown(!0),e.preventDefault()});for(var r=1;r<=7;r++)Ae(o,pt("sizeOpt",{size:r},!0));t.createDropDown(e,"fontsize-picker",o)},exec:function(e){var t=this;mt.size._dropDown(t,e,function(e){t.execCommand("fontsize",e)})},tooltip:"Font Size"},color:{_dropDown:function(t,e,n){var o=De("div"),r="",i=mt.color;i._htmlCache||(t.opts.colors.split("|").forEach(function(e){r+='<div class="sceditor-color-column">',e.split(",").forEach(function(e){r+='<a href="#" class="sceditor-color-option" style="background-color: '+e+'" data-color="'+e+'"></a>'}),r+="</div>"}),i._htmlCache=r),Ae(o,et(i._htmlCache)),Fe(o,"click","a",function(e){n(Ue(this,"color")),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"color-picker",o)},exec:function(e){var t=this;mt.color._dropDown(t,e,function(e){t.execCommand("forecolor",e)})},tooltip:"Font Color"},removeformat:{exec:"removeformat",tooltip:"Remove Formatting"},cut:{exec:"cut",tooltip:"Cut",errorMessage:"Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X"},copy:{exec:"copy",tooltip:"Copy",errorMessage:"Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C"},paste:{exec:"paste",tooltip:"Paste",errorMessage:"Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V"},pastetext:{exec:function(e){var t,n=De("div"),o=this;Ae(n,pt("pastetext",{label:o._("Paste your text inside the following box:"),insert:o._("Insert")},!0)),Fe(n,"click",".button",function(e){(t=Re(n,"#txt")[0].value)&&o.wysiwygEditorInsertText(t),o.closeDropDown(!0),e.preventDefault()}),o.createDropDown(e,"pastetext",n)},tooltip:"Paste Text"},bulletlist:{exec:function(){n(this),this.execCommand("insertunorderedlist")},tooltip:"Bullet list"},orderedlist:{exec:function(){n(this),this.execCommand("insertorderedlist")},tooltip:"Numbered list"},indent:{state:function(e,t){var n;return je(t,"li")||je(t,"ul,ol,menu")&&(t=(n=this.getRangeHelper().selectedRange()).startContainer.parentNode,n=n.endContainer.parentNode,t!==t.parentNode.firstElementChild||je(n,"li")&&n!==n.parentNode.lastElementChild)?0:-1},exec:function(){var e=this.getRangeHelper().getFirstBlockParent();this.focus(),Ne(e,"ul,ol,menu")&&this.execCommand("indent")},tooltip:"Add indent"},outdent:{state:function(e,t){return Ne(t,"ul,ol,menu")?0:-1},exec:function(){Ne(this.getRangeHelper().getFirstBlockParent(),"ul,ol,menu")&&this.execCommand("outdent")},tooltip:"Remove one indent"},table:{exec:function(e){var r=this,i=De("div");Ae(i,pt("table",{rows:r._("Rows:"),cols:r._("Cols:"),insert:r._("Insert")},!0)),Fe(i,"click",".button",function(e){var t=Number(Re(i,"#rows")[0].value),n=Number(Re(i,"#cols")[0].value),o="<table>";0<t&&0<n&&(o+=Array(t+1).join("<tr>"+Array(n+1).join("<td><br /></td>")+"</tr>"),o+="</table>",r.wysiwygEditorInsertHtml(o),r.closeDropDown(!0),e.preventDefault())}),r.createDropDown(e,"inserttable",i)},tooltip:"Insert a table"},horizontalrule:{exec:"inserthorizontalrule",tooltip:"Insert a horizontal rule"},code:{exec:function(){this.wysiwygEditorInsertHtml("<code>","<br /></code>")},tooltip:"Code"},image:{_dropDown:function(t,e,n,o){var r=De("div");Ae(r,pt("image",{url:t._("URL:"),width:t._("Width (optional):"),height:t._("Height (optional):"),insert:t._("Insert")},!0));var i=Re(r,"#image")[0];i.value=n,Fe(r,"click",".button",function(e){i.value&&o(i.value,Re(r,"#width")[0].value,Re(r,"#height")[0].value),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertimage",r)},exec:function(e){var r=this;mt.image._dropDown(r,e,"",function(e,t,n){var o="";t&&(o+=' width="'+parseInt(t,10)+'"'),n&&(o+=' height="'+parseInt(n,10)+'"'),o+=' src="'+ft(e)+'"',r.wysiwygEditorInsertHtml("<img"+o+" />")})},tooltip:"Insert an image"},email:{_dropDown:function(n,e,o){var r=De("div");Ae(r,pt("email",{label:n._("E-mail:"),desc:n._("Description (optional):"),insert:n._("Insert")},!0)),Fe(r,"click",".button",function(e){var t=Re(r,"#email")[0].value;t&&o(t,Re(r,"#des")[0].value),n.closeDropDown(!0),e.preventDefault()}),n.createDropDown(e,"insertemail",r)},exec:function(e){var n=this;mt.email._dropDown(n,e,function(e,t){!n.getRangeHelper().selectedHtml()||t?n.wysiwygEditorInsertHtml('<a href="mailto:'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink","mailto:"+e)})},tooltip:"Insert an email"},link:{_dropDown:function(t,e,n){var o=De("div");Ae(o,pt("link",{url:t._("URL:"),desc:t._("Description (optional):"),ins:t._("Insert")},!0));var r=Re(o,"#link")[0];function i(e){r.value&&n(r.value,Re(o,"#des")[0].value),t.closeDropDown(!0),e.preventDefault()}Fe(o,"click",".button",i),Fe(o,"keypress",function(e){13===e.which&&r.value&&i(e)},_e),t.createDropDown(e,"insertlink",o)},exec:function(e){var n=this;mt.link._dropDown(n,e,function(e,t){t||!n.getRangeHelper().selectedHtml()?n.wysiwygEditorInsertHtml('<a href="'+ft(e)+'">'+ft(t||e)+"</a>"):n.execCommand("createlink",e)})},tooltip:"Insert a link"},unlink:{state:function(){return Ne(this.currentNode(),"a")?0:-1},exec:function(){var e=Ne(this.currentNode(),"a");if(e){for(;e.firstChild;)We(e.firstChild,e);Me(e)}},tooltip:"Unlink"},quote:{exec:function(e,t,n){var o="<blockquote>",r="</blockquote>";t?(o=o+(n=n?"<cite>"+ft(n)+"</cite>":"")+t+r,r=null):""===this.getRangeHelper().selectedHtml()&&(r="<br />"+r),this.wysiwygEditorInsertHtml(o,r)},tooltip:"Insert a Quote"},emoticon:{exec:function(u){var d=this,f=function(e){var n,t=d.opts,o=t.emoticonsRoot||"",r=t.emoticonsCompat,i=d.getRangeHelper(),a=r&&" "!==i.getOuterText(!0,1)?" ":"",l=r&&" "!==i.getOuterText(!1,1)?" ":"",s=De("div"),c=De("div"),i=we({},t.emoticons.dropdown,e?t.emoticons.more:{});return Ae(s,c),n=Math.sqrt(Object.keys(i).length),Fe(s,"click","img",function(e){d.insert(a+He(this,"alt")+l,null,!1).closeDropDown(!0),e.preventDefault()}),Ce(i,function(e,t){Ae(c,De("img",{src:o+(t.url||t),alt:e,title:t.tooltip||e})),c.children.length>=n&&(c=De("div"),Ae(s,c))}),!e&&t.emoticons.more&&(Ae(t=De("a",{className:"sceditor-more"}),document.createTextNode(d._("More"))),Fe(t,"click",function(e){d.createDropDown(u,"more-emoticons",f(!0)),e.preventDefault()}),Ae(s,t)),s};d.createDropDown(u,"emoticons",f(!1))},txtExec:function(e){mt.emoticon.exec.call(this,e)},tooltip:"Insert an emoticon"},youtube:{_dropDown:function(r,e,i){var a=De("div");Ae(a,pt("youtubeMenu",{label:r._("Video URL:"),insert:r._("Insert")},!0)),Fe(a,"click",".button",function(e){var t=Re(a,"#link")[0].value,n=t.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/),t=t.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/),o=0;t&&Ce(t[1].split(/[hms]/),function(e,t){""!==t&&(o=60*o+Number(t))}),n&&/^[a-zA-Z0-9_\-]{11}$/.test(n[1])&&i(n[1],o),r.closeDropDown(!0),e.preventDefault()}),r.createDropDown(e,"insertlink",a)},exec:function(e){var n=this;mt.youtube._dropDown(n,e,function(e,t){n.wysiwygEditorInsertHtml(pt("youtube",{id:e,time:t}))})},tooltip:"Insert a YouTube video"},date:{_date:function(e){var t=new Date,n=t.getYear(),o=t.getMonth()+1,t=t.getDate();return n<2e3&&(n=1900+n),o<10&&(o="0"+o),t<10&&(t="0"+t),e.opts.dateFormat.replace(/year/i,n).replace(/month/i,o).replace(/day/i,t)},exec:function(){this.insertText(mt.date._date(this))},txtExec:function(){this.insertText(mt.date._date(this))},tooltip:"Insert current date"},time:{_time:function(){var e=new Date,t=e.getHours(),n=e.getMinutes(),e=e.getSeconds();return(t=t<10?"0"+t:t)+":"+(n=n<10?"0"+n:n)+":"+(e=e<10?"0"+e:e)},exec:function(){this.insertText(mt.time._time())},txtExec:function(){this.insertText(mt.time._time())},tooltip:"Insert current time"},ltr:{state:function(e,t){return t&&"ltr"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!je(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!je(t,"body")))&&(e="ltr"===Pe(t,"direction")?"":"ltr",Pe(t,"direction",e))},tooltip:"Left-to-Right"},rtl:{state:function(e,t){return t&&"rtl"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!je(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!je(t,"body")))&&(e="rtl"===Pe(t,"direction")?"":"rtl",Pe(t,"direction",e))},tooltip:"Right-to-Left"},print:{exec:"print",tooltip:"Print"},maximize:{state:function(){return this.maximize()},exec:function(){this.maximize(!this.maximize()),this.focus()},txtExec:function(){this.maximize(!this.maximize()),this.focus()},tooltip:"Maximize",shortcut:"Ctrl+Shift+M"},source:{state:function(){return this.sourceMode()},exec:function(){this.toggleSourceMode(),this.focus()},txtExec:function(){this.toggleSourceMode(),this.focus()},tooltip:"View source",shortcut:"Ctrl+Shift+S"},ignore:{}},g={};function gt(i){function a(e){return"signal"+e.charAt(0).toUpperCase()+e.slice(1)}function e(e,t){e=[].slice.call(e);for(var n,o=a(e.shift()),r=0;r<l.length;r++)if(o in l[r]&&(n=l[r][o].apply(i,e),t))return n}var r=this,l=[];r.call=function(){e(arguments,!1)},r.callOnlyFirst=function(){return e(arguments,!0)},r.hasHandler=function(e){var t=l.length;for(e=a(e);t--;)if(e in l[t])return!0;return!1},r.exists=function(e){return e in g&&("function"==typeof(e=g[e])&&"object"==typeof e.prototype)},r.isRegistered=function(e){if(r.exists(e))for(var t=l.length;t--;)if(l[t]instanceof g[e])return!0;return!1},r.register=function(e){return!(!r.exists(e)||r.isRegistered(e))&&(e=new g[e],l.push(e),"init"in e&&e.init.call(i),!0)},r.deregister=function(e){var t,n=l.length,o=!1;if(!r.isRegistered(e))return o;for(;n--;)l[n]instanceof g[e]&&(o=!0,"destroy"in(t=l.splice(n,1)[0])&&t.destroy.call(i));return o},r.destroy=function(){for(var e=l.length;e--;)"destroy"in l[e]&&l[e].destroy.call(i);l=[],i=null}}gt.plugins=g;var v=function(e,t,n){var o,r,i,a,l,s="",c=e.startContainer,u=e.startOffset;for(c&&3!==c.nodeType&&(c=c.childNodes[u],u=0),i=a=u;n>s.length&&c&&3===c.nodeType;)o=c.nodeValue,r=n-s.length,l&&(a=o.length,i=0),l=c,c=t?(u=i=Math.max(a-r,0),s=o.substr(i,a-i)+s,l.previousSibling):(u=i+(a=Math.min(r,o.length)),s+=o.substr(i,a),l.nextSibling);return{node:l||c,offset:u,text:s}};function ht(r,e,i){var a,l,s=e||r.contentDocument||r.document,c="sceditor-start-marker",u="sceditor-end-marker",h=this;h.insertHTML=function(e,t){var n,o;if(!h.selectedRange())return!1;for(t&&(e+=h.selectedHtml()+t),o=De("p",{},s),n=s.createDocumentFragment(),o.innerHTML=i(e);o.firstChild;)Ae(n,o.firstChild);h.insertNode(n)},l=function(e,t,n){var o,r=s.createDocumentFragment();if("string"==typeof e?(t&&(e+=h.selectedHtml()+t),r=et(e)):(Ae(r,e),t&&(Ae(r,h.selectedRange().extractContents()),Ae(r,t))),o=r.lastChild){for(;!rt(o.lastChild,!0);)o=o.lastChild;if(ot(o)?o.lastChild||Ae(o,document.createTextNode("")):o=r,h.removeMarkers(),Ae(o,a(c)),Ae(o,a(u)),n){n=De("div");return Ae(n,r),n.innerHTML}return r}},h.insertNode=function(e,t){var n,o,r=l(e,t),e=h.selectedRange(),t=e.commonAncestorContainer,i=[];if(!r)return!1;function a(e){e&&d(e)&&i.indexOf(e)<0&&Me(e)}e.startContainer!==e.endContainer&&(Ce(t.childNodes,function(e,t){d(t)&&i.push(t)}),n=r.firstChild,o=r.lastChild),e.deleteContents(),t&&3!==t.nodeType&&!ot(t)?We(r,t):(e.insertNode(r),a(n&&n.previousSibling),a(o&&o.nextSibling)),h.restoreRange()},h.cloneSelected=function(){var e=h.selectedRange();if(e)return e.cloneRange()},h.selectedRange=function(){var e,t,n=r.getSelection();if(n){if(n.rangeCount<=0){for(t=s.body;t.firstChild;)t=t.firstChild;(e=s.createRange()).setStartBefore(t),n.addRange(e)}return e=0<n.rangeCount?n.getRangeAt(0):e}},h.hasSelection=function(){var e=r.getSelection();return e&&0<e.rangeCount},h.selectedHtml=function(){var e,t=h.selectedRange();return t?(Ae(e=De("p",{},s),t.cloneContents()),e.innerHTML):""},h.parentNode=function(){var e=h.selectedRange();if(e)return e.commonAncestorContainer},h.getFirstBlockParent=function(e){var t=function(e){return rt(e,!0)?(e=e?e.parentNode:null)&&t(e):e};return t(e||h.parentNode())},h.insertNodeAt=function(e,t){var n=h.selectedRange(),o=h.cloneSelected();if(!o)return!1;o.collapse(e),o.insertNode(t),h.selectRange(n)},a=function(e){h.removeMarker(e);e=De("span",{id:e,className:"sceditor-selection sceditor-ignore",style:"display:none;line-height:0"},s);return e.innerHTML=" ",e},h.insertMarkers=function(){var e=h.selectedRange(),t=a(c);h.removeMarkers(),h.insertNodeAt(!0,t),e&&e.collapsed?t.parentNode.insertBefore(a(u),t.nextSibling):h.insertNodeAt(!1,a(u))},h.getMarker=function(e){return s.getElementById(e)},h.removeMarker=function(e){e=h.getMarker(e);e&&Me(e)},h.removeMarkers=function(){h.removeMarker(c),h.removeMarker(u)},h.saveRange=function(){h.insertMarkers()},h.selectRange=function(e){var t,n=r.getSelection(),o=e.endContainer;if(e.collapsed&&o&&!rt(o,!0)){for(t=o.lastChild;t&&je(t,".sceditor-ignore");)t=t.previousSibling;je(t,"br")&&((o=s.createRange()).setEndAfter(t),o.collapse(!1),h.compare(e,o)&&(e.setStartBefore(t),e.collapse(!0)))}n&&(h.clear(),n.addRange(e))},h.restoreRange=function(){var e,t=h.selectedRange(),n=h.getMarker(c),o=h.getMarker(u);if(!n||!o||!t)return!1;e=n.nextSibling===o,(t=s.createRange()).setStartBefore(n),t.setEndAfter(o),e&&t.collapse(!0),h.selectRange(t),h.removeMarkers()},h.selectOuterText=function(e,t){var n=h.cloneSelected();if(!n)return!1;n.collapse(!1),e=v(n,!0,e),t=v(n,!1,t),n.setStart(e.node,e.offset),n.setEnd(t.node,t.offset),h.selectRange(n)},h.getOuterText=function(e,t){var n=h.cloneSelected();return n?(n.collapse(!e),v(n,e,t).text):""},h.replaceKeyword=function(e,t,n,o,r,i){n||e.sort(function(e,t){return e[0].length-t[0].length});var a,l,s,c,u,d,f,p="(^|[\\s ])",m=e.length,g=r?1:0,o=o||e[m-1][0].length;for(r&&o++,i=i||"",c=(a=h.getOuterText(!0,o)).length,a+=i,t&&(a+=h.getOuterText(!1,o));m--;)if(d=e[m][0],f=d.length,s=Math.max(0,c-f-g),u=-1,r?(l=a.substr(s).match(new RegExp(p+dt(d)+p)))&&(u=l.index+s+l[1].length):u=a.indexOf(d,s),-1<u&&u<=c&&c<=u+f+g)return u=c-u,h.selectOuterText(u,f-u-(/^\S/.test(i)?1:0)),h.insertHTML(e[m][1]),!0;return!1},h.compare=function(e,t){return t=t||h.selectedRange(),e&&t?0===e.compareBoundaryPoints(Range.END_TO_END,t)&&0===e.compareBoundaryPoints(Range.START_TO_START,t):!e&&!t},h.clear=function(){var e=r.getSelection();e&&(e.removeAllRanges?e.removeAllRanges():e.empty&&e.empty())}}var h,y,b,x=navigator.userAgent,vt=/iPhone|iPod|iPad| wosbrowser\//i.test(x),yt=(y=!!window.document.documentMode,D="-ms-ime-align"in document.documentElement.style,(N=document.createElement("div")).contentEditable=!0,"contentEditable"in document.documentElement&&"true"===N.contentEditable&&(N=/Opera Mobi|Opera Mini/i.test(x),/Android/i.test(x)&&(N=!0,/Safari/.test(x)&&(N=!(h=/Safari\/(\d+)/.exec(x))||!h[1]||h[1]<534)),/ Silk\//i.test(x)&&(N=!(h=/AppleWebKit\/(\d+)/.exec(x))||!h[1]||h[1]<534),vt&&(N=/OS [0-4](_\d)+ like Mac/i.test(x)),/Firefox/i.test(x)&&(N=!1),/OneBrowser/i.test(x)&&(N=!1),"UCWEB"===navigator.vendor&&(N=!1),!(N=y||D?!0:N))),w=Object.hasOwnProperty,T=Object.setPrototypeOf,C=Object.isFrozen,S=Object.getPrototypeOf,k=Object.getOwnPropertyDescriptor,bt=Object.freeze,D=Object.seal,E=Object.create,N="undefined"!=typeof Reflect&&Reflect,M=(M=N.apply)||function(e,t,n){return e.apply(t,n)},bt=bt||function(e){return e},D=D||function(e){return e},A=(A=N.construct)||function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))},xt=R(Array.prototype.forEach),wt=R(Array.prototype.pop),Tt=R(Array.prototype.push),Ct=R(String.prototype.toLowerCase),St=R(String.prototype.match),kt=R(String.prototype.replace),Dt=R(String.prototype.indexOf),Et=R(String.prototype.trim),Nt=R(RegExp.prototype.test),Mt=(b=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return A(b,t)});function R(r){return function(e){for(var t=arguments.length,n=Array(1<t?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return M(r,e,n)}}function At(e,t){T&&T(e,null);for(var n=t.length;n--;){var o,r=t[n];"string"!=typeof r||(o=Ct(r))!==r&&(C(t)||(t[n]=o),r=o),e[r]=!0}return e}function Rt(e){var t=E(null),n=void 0;for(n in e)M(w,e,[n])&&(t[n]=e[n]);return t}function _t(e,t){for(;null!==e;){var n=k(e,t);if(n){if(n.get)return R(n.get);if("function"==typeof n.value)return R(n.value)}e=S(e)}return null}var Ft=bt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ot=bt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ht=bt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),zt=bt(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Lt=bt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),It=bt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Bt=bt(["#text"]),Pt=bt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns"]),Ut=bt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),jt=bt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wt=bt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Vt=D(/\{\{[\s\S]*|[\s\S]*\}\}/gm),qt=D(/<%[\s\S]*|[\s\S]*%>/gm),Gt=D(/^data-[\-\w.\u00B7-\uFFFF]/),$t=D(/^aria-[\-\w]+$/),Yt=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Kt=D(/^(?:\w+script|data):/i),Xt=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function Jt(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var Qt=function(){return"undefined"==typeof window?null:window},en=function(e,t){if("object"!==(void 0===e?"undefined":Zt(e))||"function"!=typeof e.createPolicy)return null;var n=null,o="data-tt-policy-suffix",r="dompurify"+((n=t.currentScript&&t.currentScript.hasAttribute(o)?t.currentScript.getAttribute(o):n)?"#"+n:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},tn=function t(e){function u(e){return t(e)}var l=0<arguments.length&&void 0!==e?e:Qt();if(u.version="2.2.6",u.removed=[],!l||!l.document||9!==l.document.nodeType)return u.isSupported=!1,u;var s=l.document,i=l.document,c=l.DocumentFragment,n=l.HTMLTemplateElement,d=l.Node,a=l.Element,o=l.NodeFilter,r=l.NamedNodeMap,f=void 0===r?l.NamedNodeMap||l.MozNamedAttrMap:r,p=l.Text,m=l.Comment,g=l.DOMParser,e=l.trustedTypes,r=a.prototype,h=_t(r,"cloneNode"),v=_t(r,"nextSibling"),y=_t(r,"childNodes"),b=_t(r,"parentNode");"function"!=typeof n||(n=i.createElement("template")).content&&n.content.ownerDocument&&(i=n.content.ownerDocument);var x=en(e,s),w=x&&ee?x.createHTML(""):"",T=i.implementation,C=i.createNodeIterator,S=i.getElementsByTagName,k=i.createDocumentFragment,D=s.importNode,E={};try{E=Rt(i).documentMode?i.documentMode:{}}catch(e){}var N={};u.isSupported=T&&void 0!==T.createHTMLDocument&&9!==E;function M(e){ce&&ce===e||(e=Rt(e=e&&"object"===(void 0===e?"undefined":Zt(e))?e:{}),I="ALLOWED_TAGS"in e?At({},e.ALLOWED_TAGS):B,P="ALLOWED_ATTR"in e?At({},e.ALLOWED_ATTR):U,le="ADD_URI_SAFE_ATTR"in e?At(Rt(se),e.ADD_URI_SAFE_ATTR):se,ie="ADD_DATA_URI_TAGS"in e?At(Rt(ae),e.ADD_DATA_URI_TAGS):ae,j="FORBID_TAGS"in e?At({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?At({},e.FORBID_ATTR):{},A="USE_PROFILES"in e&&e.USE_PROFILES,V=!1!==e.ALLOW_ARIA_ATTR,q=!1!==e.ALLOW_DATA_ATTR,G=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=e.SAFE_FOR_TEMPLATES||!1,Y=e.WHOLE_DOCUMENT||!1,Z=e.RETURN_DOM||!1,J=e.RETURN_DOM_FRAGMENT||!1,Q=!1!==e.RETURN_DOM_IMPORT,ee=e.RETURN_TRUSTED_TYPE||!1,X=e.FORCE_BODY||!1,te=!1!==e.SANITIZE_DOM,ne=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,L=e.ALLOWED_URI_REGEXP||L,$&&(q=!1),J&&(Z=!0),A&&(I=At({},[].concat(Jt(Bt))),P=[],!0===A.html&&(At(I,Ft),At(P,Pt)),!0===A.svg&&(At(I,Ot),At(P,Ut),At(P,Wt)),!0===A.svgFilters&&(At(I,Ht),At(P,Ut),At(P,Wt)),!0===A.mathMl&&(At(I,Lt),At(P,jt),At(P,Wt))),e.ADD_TAGS&&At(I=I===B?Rt(I):I,e.ADD_TAGS),e.ADD_ATTR&&At(P=P===U?Rt(P):P,e.ADD_ATTR),e.ADD_URI_SAFE_ATTR&&At(le,e.ADD_URI_SAFE_ATTR),ne&&(I["#text"]=!0),Y&&At(I,["html","head","body"]),I.table&&(At(I,["tbody"]),delete j.tbody),bt&&bt(e),ce=e)}var A,R=Vt,_=qt,F=Gt,O=$t,H=Kt,z=Xt,L=Yt,I=null,B=At({},[].concat(Jt(Ft),Jt(Ot),Jt(Ht),Jt(Lt),Jt(Bt))),P=null,U=At({},[].concat(Jt(Pt),Jt(Ut),Jt(jt),Jt(Wt))),j=null,W=null,V=!0,q=!0,G=!1,$=!1,Y=!1,K=!1,X=!1,Z=!1,J=!1,Q=!0,ee=!1,te=!0,ne=!0,oe=!1,re=At({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ie=null,ae=At({},["audio","video","img","source","image","track"]),le=null,se=At({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),ce=null,ue=i.createElement("form"),de=At({},["mi","mo","mn","ms","mtext"]),fe=At({},["foreignobject","desc","title","annotation-xml"]),pe=At({},Ot);At(pe,Ht),At(pe,zt);var me=At({},Lt);At(me,It);function ge(t){Tt(u.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=w}catch(e){t.remove()}}}function he(e,t){try{Tt(u.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Tt(u.removed,{attribute:null,from:t})}t.removeAttribute(e)}function ve(e){var t=void 0,n=void 0;X?e="<remove></remove>"+e:n=(o=St(e,/^[\r\n\t ]+/))&&o[0];var o,r=x?x.createHTML(e):e;try{t=(new g).parseFromString(r,"text/html")}catch(e){}return t&&t.documentElement||((o=(t=T.createHTMLDocument("")).body).parentNode.removeChild(o.parentNode.firstElementChild),o.outerHTML=r),e&&n&&t.body.insertBefore(i.createTextNode(n),t.body.childNodes[0]||null),S.call(t,Y?"html":"body")[0]}function ye(e){return C.call(e.ownerDocument||e,e,o.SHOW_ELEMENT|o.SHOW_COMMENT|o.SHOW_TEXT,function(){return o.FILTER_ACCEPT},!1)}function be(e){return"object"===(void 0===d?"undefined":Zt(d))?e instanceof d:e&&"object"===(void 0===e?"undefined":Zt(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function xe(e,t,n){N[e]&&xt(N[e],function(e){e.call(u,t,n,ce)})}function we(e){var t;if(xe("beforeSanitizeElements",e,null),!((n=e)instanceof p||n instanceof m||"string"==typeof n.nodeName&&"string"==typeof n.textContent&&"function"==typeof n.removeChild&&n.attributes instanceof f&&"function"==typeof n.removeAttribute&&"function"==typeof n.setAttribute&&"string"==typeof n.namespaceURI&&"function"==typeof n.insertBefore))return ge(e),1;if(St(e.nodeName,/[\u0080-\uFFFF]/))return ge(e),1;var n=Ct(e.nodeName);if(xe("uponSanitizeElement",e,{tagName:n,allowedTags:I}),!be(e.firstElementChild)&&(!be(e.content)||!be(e.content.firstElementChild))&&Nt(/<[/\w]/g,e.innerHTML)&&Nt(/<[/\w]/g,e.textContent))return ge(e),1;if(I[n]&&!j[n])return e instanceof a&&!function(e){var t=b(e);t&&t.tagName||(t={namespaceURI:Ee,tagName:"template"});var n=Ct(e.tagName),o=Ct(t.tagName);return e.namespaceURI===De?t.namespaceURI===Ee?"svg"===n:t.namespaceURI===ke?"svg"===n&&("annotation-xml"===o||de[o]):Boolean(pe[n]):e.namespaceURI===ke?t.namespaceURI===Ee?"math"===n:t.namespaceURI===De?"math"===n&&fe[o]:Boolean(me[n]):e.namespaceURI===Ee&&((t.namespaceURI!==De||fe[o])&&((t.namespaceURI!==ke||de[o])&&(o=At({},["title","style","font","a","script"]),!me[n]&&(o[n]||!pe[n]))))}(e)||("noscript"===n||"noembed"===n)&&Nt(/<\/no(script|embed)/i,e.innerHTML)?(ge(e),1):($&&3===e.nodeType&&(t=e.textContent,t=kt(t,R," "),t=kt(t,_," "),e.textContent!==t&&(Tt(u.removed,{element:e.cloneNode()}),e.textContent=t)),xe("afterSanitizeElements",e,null),0);if(ne&&!re[n])for(var o=b(e),r=y(e),i=r.length-1;0<=i;--i)o.insertBefore(h(r[i],!0),v(e));return ge(e),1}function Te(e,t,n){if(te&&("id"===t||"name"===t)&&(n in i||n in ue))return!1;if(!(q&&Nt(F,t)||V&&Nt(O,t))){if(!P[t]||W[t])return!1;if(!le[t]&&!Nt(L,kt(n,z,""))&&("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Dt(n,"data:")||!ie[e])&&(!G||Nt(H,kt(n,z,"")))&&n)return!1}return!0}function Ce(e){var t=void 0,n=void 0,o=void 0;xe("beforeSanitizeAttributes",e,null);var r=e.attributes;if(r){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P},o=r.length;o--;){var a=(t=r[o]).name,l=t.namespaceURI,n=Et(t.value),s=Ct(a);if(i.attrName=s,i.attrValue=n,i.keepAttr=!0,i.forceKeepAttr=void 0,xe("uponSanitizeAttribute",e,i),n=i.attrValue,!i.forceKeepAttr&&(he(a,e),i.keepAttr))if(Nt(/\/>/i,n))he(a,e);else{$&&(n=kt(n,R," "),n=kt(n,_," "));var c=e.nodeName.toLowerCase();if(Te(c,s,n))try{l?e.setAttributeNS(l,a,n):e.setAttribute(a,n),wt(u.removed)}catch(e){}}}xe("afterSanitizeAttributes",e,null)}}function Se(e){var t,n=ye(e);for(xe("beforeSanitizeShadowDOM",e,null);t=n.nextNode();)xe("uponSanitizeShadowNode",t,null),we(t)||(t.content instanceof c&&Se(t.content),Ce(t));xe("afterSanitizeShadowDOM",e,null)}var ke="http://www.w3.org/1998/Math/MathML",De="http://www.w3.org/2000/svg",Ee="http://www.w3.org/1999/xhtml";return u.sanitize=function(e,t){var n,o=void 0,r=void 0,i=void 0;if("string"!=typeof(e=e||"\x3c!--\x3e")&&!be(e)){if("function"!=typeof e.toString)throw Mt("toString is not a function");if("string"!=typeof(e=e.toString()))throw Mt("dirty is not a string, aborting")}if(!u.isSupported){if("object"===Zt(l.toStaticHTML)||"function"==typeof l.toStaticHTML){if("string"==typeof e)return l.toStaticHTML(e);if(be(e))return l.toStaticHTML(e.outerHTML)}return e}if(K||M(t),u.removed=[],"string"==typeof e&&(oe=!1),!oe)if(e instanceof d)1===(t=(o=ve("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===t.nodeName||"HTML"===t.nodeName?o=t:o.appendChild(t);else{if(!Z&&!$&&!Y&&-1===e.indexOf("<"))return x&&ee?x.createHTML(e):e;if(!(o=ve(e)))return Z?null:w}o&&X&&ge(o.firstChild);for(var a=ye(oe?e:o);n=a.nextNode();)3===n.nodeType&&n===r||we(n)||(n.content instanceof c&&Se(n.content),Ce(n),r=n);if(r=null,oe)return e;if(Z){if(J)for(i=k.call(o.ownerDocument);o.firstChild;)i.appendChild(o.firstChild);else i=o;return i=Q?D.call(s,i,!0):i}return e=Y?o.outerHTML:o.innerHTML,$&&(e=kt(e,R," "),e=kt(e,_," ")),x&&ee?x.createHTML(e):e},u.setConfig=function(e){M(e),K=!0},u.clearConfig=function(){ce=null,K=!1},u.isValidAttribute=function(e,t,n){return ce||M({}),e=Ct(e),t=Ct(t),Te(e,t,n)},u.addHook=function(e,t){"function"==typeof t&&(N[e]=N[e]||[],Tt(N[e],t))},u.removeHook=function(e){N[e]&&wt(N[e])},u.removeHooks=function(e){N[e]&&(N[e]=[])},u.removeAllHooks=function(){N={}},u}(),nn=window,on=document,rn=/^image\/(p?jpe?g|gif|png|bmp)$/i;function an(r,e){var a,x,u,i,l,f,d,s,o,c,p,t,m,g,h,v,y,b,n,w,T,C,S,k,D,E,N,M,A,R,_,F,O,H,z,L,I,B,P,U,j,W,V,q,G,$,Y,K,X,Z,J,Q,ee,te,ne,oe,re,ie,ae,le,se=this,ce={},ue=[],de=[],fe={},pe={},me={};se.commands=we(!0,{},e.commands||mt);var ge=se.opts=we(!0,{},ut,e);se.opts.emoticons=e.emoticons||ut.emoticons,Array.isArray(ge.allowedIframeUrls)||(ge.allowedIframeUrls=[]),ge.allowedIframeUrls.push("https://www.youtube-nocookie.com/embed/");var he=tn();function ve(e){return he.sanitize(e,{ADD_TAGS:["iframe"],ADD_ATTR:["allowfullscreen","frameborder","target"]})}he.addHook("uponSanitizeElement",function(e,t){var n=ge.allowedIframeUrls;if("iframe"===t.tagName){for(var o=He(e,"src")||"",r=0;r<n.length;r++){var i=n[r];if(ye(i)&&o.substr(0,i.length)===i)return;if(i.test&&i.test(o))return}Me(e)}}),he.addHook("afterSanitizeAttributes",function(e){"target"in e&&He(e,"data-sce-target",He(e,"target")),ze(e,"target")}),e=function(){r._sceditor=se,ge.locale&&"en"!==ge.locale&&A(),We(x=De("div",{className:"sceditor-container"}),r),Pe(x,"z-index",ge.zIndex),n=r.required,r.required=!1;var e=an.formats[ge.format];a=e?new e:{},g=new gt(se),(ge.plugins||"").split(",").forEach(function(e){g.register(e.trim())}),"init"in a&&a.init.call(se),H(),R(),M(),_(),F(),yt||se.toggleSourceMode(),Y();var t=function(){Oe(nn,"load",t),ge.autofocus&&Q(!!ge.autofocusEnd),le(),X(),g.call("ready"),"onReady"in a&&a.onReady.call(se)};Fe(nn,"load",t),"complete"===on.readyState&&t()},A=function(){var e;(t=an.locale[ge.locale])||(e=ge.locale.split("-"),t=an.locale[e[0]]),t&&t.dateFormat&&(ge.dateFormat=t.dateFormat)},M=function(){s=De("textarea"),i=De("iframe",{frameborder:0,allowfullscreen:!0}),ge.startInSourceMode?(qe(x,"sourceMode"),Le(i)):(qe(x,"wysiwygMode"),Le(s)),ge.spellcheck||He(x,"spellcheck","false"),"https:"===nn.location.protocol&&He(i,"src","about:blank"),Ae(x,i),Ae(x,s),se.dimensions(ge.width||Ye(r),ge.height||Ke(r));var e=vt?" ios":"";(d=i.contentDocument).open(),d.write(pt("html",{attrs:' class="'+e+'"',spellcheck:ge.spellcheck?"":'spellcheck="false"',charset:ge.charset,style:ge.style})),d.close(),f=d.body,l=i.contentWindow,se.readOnly(!!ge.readOnly),vt&&(Ke(f,"100%"),Fe(f,"touchend",se.focus));e=He(r,"tabindex");He(s,"tabindex",e),He(i,"tabindex",e),m=new ht(l,null,ve),Le(r),se.val(r.value);e=ge.placeholder||He(r,"placeholder");e&&(s.placeholder=e,He(f,"placeholder",e))},_=function(){ge.autoUpdate&&(Fe(f,"blur",ae),Fe(s,"blur",ae)),null===ge.rtl&&(ge.rtl="rtl"===Pe(s,"direction")),se.rtl(!!ge.rtl),ge.autoExpand&&(Fe(f,"load",le,_e),Fe(f,"input keyup",le)),ge.resizeEnabled&&O(),He(x,"id",ge.id),se.emoticons(ge.emoticonsEnabled)},F=function(){var e=r.form,t="compositionstart compositionend",n="keydown keyup keypress focus blur contextmenu input",o="onselectionchange"in d?"selectionchange":"keyup focus blur contextmenu mouseup touchend click";Fe(on,"click",G),e&&(Fe(e,"reset",j),Fe(e,"submit",se.updateOriginal,_e)),Fe(window,"pagehide",se.updateOriginal),Fe(window,"pageshow",j),Fe(f,"keypress",U),Fe(f,"keydown",B),Fe(f,"keydown",P),Fe(f,"keyup",X),Fe(f,"blur",re),Fe(f,"keyup",ie),Fe(f,"paste",z),Fe(f,"cut copy",L),Fe(f,t,V),Fe(f,o,Z),Fe(f,n,q),ge.emoticonsCompat&&nn.getSelection&&Fe(f,"keyup",te),Fe(f,"blur",function(){se.val()||qe(f,"placeholder")}),Fe(f,"focus",function(){Ge(f,"placeholder")}),Fe(s,"blur",re),Fe(s,"keyup",ie),Fe(s,"keydown",B),Fe(s,t,V),Fe(s,n,q),Fe(d,"mousedown",W),Fe(d,o,Z),Fe(d,"keyup",X),Fe(x,"selectionchanged",J),Fe(x,"selectionchanged",Y),Fe(x,"selectionchanged valuechanged nodechanged pasteraw paste",q)},R=function(){var i,a=se.commands,l=(ge.toolbarExclude||"").split(","),e=ge.toolbar.split("|");u=De("div",{className:"sceditor-toolbar",unselectable:"on"}),ge.icons in an.icons&&(D=new an.icons[ge.icons]),Ce(e,function(e,t){i=De("div",{className:"sceditor-group"}),Ce(t.split(","),function(e,t){var n,o,r=a[t];!r||-1<l.indexOf(t)||(n=r.shortcut,o=pt("toolbarButton",{name:t,dispName:se._(r.name||r.tooltip||t)},!0).firstChild,D&&D.create&&D.create(t)&&(We(D.create(t),o.firstChild),qe(o,"has-icon")),o._sceTxtMode=!!r.txtExec,o._sceWysiwygMode=!!r.exec,$e(o,"disabled",!r.exec),Fe(o,"click",function(e){Ve(o,"disabled")||N(o,r),Y(),e.preventDefault()}),Fe(o,"mousedown",function(e){se.closeDropDown(),e.preventDefault()}),r.tooltip&&He(o,"title",se._(r.tooltip)+(n?" ("+n+")":"")),n&&se.addShortcut(n,t),r.state?de.push({name:t,state:r.state}):ye(r.exec)&&de.push({name:t,state:r.exec}),Ae(i,o),pe[t]=o)}),i.firstChild&&Ae(u,i)}),Ae(ge.toolbarContainer||x,u)},O=function(){var e=De("div",{className:"sceditor-grip"}),t=De("div",{className:"sceditor-resize-cover"}),n="touchmove mousemove",o="touchcancel touchend mouseup",r=0,i=0,a=0,l=0,s=0,c=0,u=Ye(x),d=Ke(x),f=!1,p=se.rtl(),m=ge.resizeMinHeight||d/1.5,g=ge.resizeMaxHeight||2.5*d,h=ge.resizeMinWidth||u/1.25,v=ge.resizeMaxWidth||1.25*u,y=function(e){l="touchmove"===e.type?(e=nn.event,a=e.changedTouches[0].pageX,e.changedTouches[0].pageY):(a=e.pageX,e.pageY);var t=c+(l-i),n=p?s-(a-r):s+(a-r);0<v&&v<n&&(n=v),0<h&&n<h&&(n=h),ge.resizeWidth||(n=!1),0<g&&g<t&&(t=g),0<m&&t<m&&(t=m),ge.resizeHeight||(t=!1),(n||t)&&se.dimensions(n,t),e.preventDefault()},b=function(e){f&&(f=!1,Le(t),Ge(x,"resizing"),Oe(on,n,y),Oe(on,o,b),e.preventDefault())};D&&D.create&&((u=D.create("grip"))&&(Ae(e,u),qe(e,"has-icon"))),Ae(x,e),Ae(x,t),Le(t),Fe(e,"touchstart mousedown",function(e){i="touchstart"===e.type?(e=nn.event,r=e.touches[0].pageX,e.touches[0].pageY):(r=e.pageX,e.pageY),s=Ye(x),c=Ke(x),f=!0,qe(x,"resizing"),Ie(t),Fe(on,n,y),Fe(on,o,b),e.preventDefault()})},H=function(){var e=ge.emoticons,n=ge.emoticonsRoot||"";Ce(me=e?we({},e.more,e.dropdown,e.hidden):me,function(e,t){me[e]=pt("emoticon",{key:e,url:n+(t.url||t),tooltip:t.tooltip||e}),ge.emoticonsEnabled&&ue.push(De("img",{src:n+(t.url||t)}))})},Q=function(e){var t,n=f.firstChild;if(Ze(x)){if(se.sourceMode())return t=e?s.value.length:0,void s.setSelectionRange(t,t);if(at(f),e)for((n=f.lastChild)||(n=De("p",{},d),Ae(f,n));n.lastChild;)je(n=n.lastChild,"br")&&n.previousSibling&&(n=n.previousSibling);t=d.createRange(),ot(n)?t.selectNodeContents(n):(t.setStartBefore(n),e&&t.setStartAfter(n)),t.collapse(!e),m.selectRange(t),y=t,e&&(f.scrollTop=f.scrollHeight),se.focus()}},se.readOnly=function(e){return"boolean"!=typeof e?!s.readonly:(f.contentEditable=!e,s.readonly=!e,$(e),se)},se.rtl=function(e){var t=e?"rtl":"ltr";return"boolean"!=typeof e?"rtl"===He(s,"dir"):(He(f,"dir",t),He(s,"dir",t),Ge(x,"rtl"),Ge(x,"ltr"),qe(x,t),D&&D.rtl&&D.rtl(e),se)},$=function(n){var o=se.inSourceMode()?"_sceTxtMode":"_sceWysiwygMode";Ce(pe,function(e,t){$e(t,"disabled",n||!t[o])})},se.width=function(e,t){return e||0===e?(se.dimensions(e,null,t),se):Ye(x)},se.dimensions=function(e,t,n){return t=!(!t&&0!==t)&&t,!1===(e=!(!e&&0!==e)&&e)&&!1===t?{width:se.width(),height:se.height()}:(!1!==e&&(!1!==n&&(ge.width=e),Ye(x,e)),!1!==t&&(!1!==n&&(ge.height=t),Ke(x,t)),se)},se.height=function(e,t){return e||0===e?(se.dimensions(null,e,t),se):Ke(x)},se.maximize=function(e){var t="sceditor-maximize";return be(e)?Ve(x,t):((e=!!e)&&(S=nn.pageYOffset),$e(on.documentElement,t,e),$e(on.body,t,e),$e(x,t,e),se.width(e?"100%":ge.width,!1),se.height(e?"100%":ge.height,!1),e||nn.scrollTo(0,S),le(),se)},le=function(){ge.autoExpand&&!C&&(C=setTimeout(se.expandToContent,200))},se.expandToContent=function(e){var t,n;se.maximize()||(clearTimeout(C),C=!1,T||(t=ge.resizeMinHeight||ge.height||Ke(r),T={min:t,max:ge.resizeMaxHeight||2*t}),(n=on.createRange()).selectNodeContents(f),t=n.getBoundingClientRect(),n=d.documentElement.clientHeight-1,t=t.bottom-t.top,n=se.height()+1+(t-n),e||-1===T.max||(n=Math.min(n,T.max)),se.height(Math.ceil(Math.max(n,T.min))))},se.destroy=function(){var e;g&&(g.destroy(),g=m=null,o&&Me(o),Oe(on,"click",G),(e=r.form)&&(Oe(e,"reset",j),Oe(e,"submit",se.updateOriginal,_e)),Oe(window,"pagehide",se.updateOriginal),Oe(window,"pageshow",j),Me(s),Me(u),Me(x),delete r._sceditor,Ie(r),r.required=n)},se.createDropDown=function(e,t,n){t="sceditor-"+t;se.closeDropDown(),o&&Ve(o,t)||(e=we({top:e.offsetTop,left:e.offsetLeft,marginTop:e.clientHeight},ge.dropDownCss),Pe(o=De("div",{className:"sceditor-dropdown "+t}),e),Ae(o,n),Ae(x,o),Fe(o,"click focusin",function(e){e.stopPropagation()}),!o||(n=Re(o,"input,textarea")[0])&&n.focus())},G=function(e){3!==e.which&&o&&!e.defaultPrevented&&(ae(),se.closeDropDown())},L=function(e){var t=m.selectedRange();if(t){for(var n,o,r=De("div",{},d),i=t.commonAncestorContainer;i&&rt(i,!0);)i.nodeType===Se&&(o=i.cloneNode(),r.firstChild&&Ae(o,r.firstChild),Ae(r,o),n=n||o),i=i.parentNode;Ae(n||r,t.cloneContents()),at(r),e.clipboardData.setData("text/html",r.innerHTML),Ce(Re(r,"p"),function(e,t){nt(t,"div")}),Ce(Re(r,"br"),function(e,t){t.nextSibling&&rt(t.nextSibling,!0)||Me(t)}),Ae(f,r),e.clipboardData.setData("text/plain",r.innerText),Me(r),"cut"===e.type&&t.deleteContents(),e.preventDefault()}},z=function(e){var t,n,o=f,r=e.clipboardData;if(r){var i={},a=r.types,l=r.items;e.preventDefault();for(var s=0;s<a.length;s++){if(a.indexOf("text/html")<0&&nn.FileReader&&l&&rn.test(l[s].type))return t=r.items[s].getAsFile(),n=void 0,(n=new FileReader).onload=function(e){I({html:'<img src="'+e.target.result+'" />'})},void n.readAsDataURL(t);i[a[s]]=r.getData(a[s])}i.text=i["text/plain"],i.html=ve(i["text/html"]),I(i)}else if(!k){var c=o.scrollTop;for(m.saveRange(),k=on.createDocumentFragment();o.firstChild;)Ae(k,o.firstChild);setTimeout(function(){var e=o.innerHTML;o.innerHTML="",Ae(o,k),o.scrollTop=c,k=!1,m.restoreRange(),I({html:ve(e)})},0)}},I=function(e){var t=De("div",{},d);g.call("pasteRaw",e),Xe(x,"pasteraw",e),e.html?(t.innerHTML=ve(e.html),it(t)):t.innerHTML=ft(e.text||"");e={val:t.innerHTML};"fragmentToSource"in a&&(e.val=a.fragmentToSource(e.val,d,h)),g.call("paste",e),Xe(x,"paste",e),"fragmentToHtml"in a&&(e.val=a.fragmentToHtml(e.val,h)),g.call("pasteHtml",e);t=m.getFirstBlockParent();se.wysiwygEditorInsertHtml(e.val,null,!0),function e(t){if(t.nodeType===Se){for(var n=t.parentNode,o=t.tagName,r=t.childNodes.length;r--;)e(t.childNodes[r]);if(rt(t)){for(r=t.style.length;r--;){var i=t.style[r];Pe(n,i)===Pe(t,i)&&t.style.removeProperty(i)}if(!t.style.length)if(ze(t,"style"),"FONT"===o&&(Pe(t,"fontFamily").toLowerCase()===Pe(n,"fontFamily").toLowerCase()&&ze(t,"face"),Pe(t,"color")===Pe(n,"color")&&ze(t,"color"),Pe(t,"fontSize")===Pe(n,"fontSize")&&ze(t,"size")),!t.attributes.length&&/SPAN|FONT/.test(o))ct(t);else if(/B|STRONG|EM|SPAN|FONT/.test(o))for(var a=/B|STRONG/.test(o),l="EM"===o;n&&rt(n)&&(!a||/bold|700/i.test(Pe(n,"fontWeight")))&&(!l||"italic"===Pe(n,"fontStyle"));){if((n.tagName===o||a&&/B|STRONG/.test(n.tagName))&&st(n,t)){ct(t);break}n=n.parentNode}var s=t.nextSibling;s&&s.tagName===o&&st(s,t)&&(Ae(t,s),ct(s))}}}(t)},se.closeDropDown=function(e){o&&(Me(o),o=null),!0===e&&se.focus()},se.wysiwygEditorInsertHtml=function(e,t,n){var o=Ke(i);se.focus(),!n&&Ne(v,"code")||(m.insertHTML(e,t),m.saveRange(),E(),it(f),Ie(n=Re(f,"#sceditor-end-marker")[0]),e=f.scrollTop,t=lt(n).top+1.5*n.offsetHeight-o,Le(n),(e<t||t+o<e)&&(f.scrollTop=t),oe(!1),m.restoreRange(),X())},se.wysiwygEditorInsertText=function(e,t){se.wysiwygEditorInsertHtml(ft(e),ft(t))},se.insertText=function(e,t){return se.inSourceMode()?se.sourceEditorInsertText(e,t):se.wysiwygEditorInsertText(e,t),se},se.sourceEditorInsertText=function(e,t){var n,o=s.selectionStart,r=s.selectionEnd,i=s.scrollTop;s.focus(),n=s.value,t&&(e+=n.substring(o,r)+t),s.value=n.substring(0,o)+e+n.substring(r,n.length),s.selectionStart=o+e.length-(t?t.length:0),s.selectionEnd=s.selectionStart,s.scrollTop=i,s.focus(),oe()},se.getRangeHelper=function(){return m},se.sourceEditorCaret=function(e){return s.focus(),e?(s.selectionStart=e.start,s.selectionEnd=e.end,this):{start:s.selectionStart,end:s.selectionEnd}},se.val=function(e,t){return ye(e)?(se.inSourceMode()?se.setSourceEditorValue(e):(!1!==t&&"toHtml"in a&&(e=a.toHtml(e)),se.setWysiwygEditorValue(e)),se):se.inSourceMode()?se.getSourceEditorValue(!1):se.getWysiwygEditorValue(t)},se.insert=function(e,t,n,o,r){return se.inSourceMode()?se.sourceEditorInsertText(e,t):(t&&(i=m.selectedHtml(),e+=(i=!1!==n&&"fragmentToSource"in a?a.fragmentToSource(i,d,h):i)+t),!1!==n&&"fragmentToHtml"in a&&(e=a.fragmentToHtml(e,h)),!1!==n&&!0===r&&(e=e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")),se.wysiwygEditorInsertHtml(e)),se;var i},se.getWysiwygEditorValue=function(e){for(var t,n=De("div",{},d),o=f.childNodes,r=0;r<o.length;r++)Ae(n,o[r].cloneNode(!0));return Ae(f,n),it(n),Me(n),t=n.innerHTML,t=!1!==e&&a.hasOwnProperty("toSource")?a.toSource(t,d):t},se.getBody=function(){return f},se.getContentAreaContainer=function(){return i},se.getSourceEditorValue=function(e){var t=s.value;return t=!1!==e&&"toHtml"in a?a.toHtml(t):t},se.setWysiwygEditorValue=function(e){e=e||"<p><br /></p>",f.innerHTML=ve(e),E(),X(),oe(),le()},se.setSourceEditorValue=function(e){s.value=e,oe()},se.updateOriginal=function(){r.value=se.val()},E=function(){var e,l,s,c,t,u,d;ge.emoticonsEnabled&&(e=f,l=me,s=ge.emoticonsCompat,c=e.ownerDocument,t="(^|\\s| | | | |$)",u=[],d={},Ee(e,"code")||(Ce(l,function(e){d[e]=new RegExp(t+dt(e)+t),u.push(e)}),u.sort(function(e,t){return t.length-e.length}),function e(t){for(t=t.firstChild;t;){if(t.nodeType!==Se||je(t,"code")||e(t),t.nodeType===ke)for(var n=0;n<u.length;n++){var o,r=t.nodeValue,i=u[n],a=s?r.search(d[i]):r.indexOf(i);-1<a&&(o=r.indexOf(i,a),a=et(l[i],c),i=r.substr(o+i.length),a.appendChild(c.createTextNode(i)),t.nodeValue=r.substr(0,o),t.parentNode.insertBefore(a,t.nextSibling))}t=t.nextSibling}}(e)))},se.inSourceMode=function(){return Ve(x,"sourceMode")},se.sourceMode=function(e){var t=se.inSourceMode();return"boolean"!=typeof e?t:((t&&!e||!t&&e)&&se.toggleSourceMode(),se)},se.toggleSourceMode=function(){var e=se.inSourceMode();!yt&&e||(e||(m.saveRange(),m.clear()),y=null,se.blur(),e?se.setWysiwygEditorValue(se.getSourceEditorValue()):se.setSourceEditorValue(se.getWysiwygEditorValue()),Be(s),Be(i),$e(x,"wysiwygMode",e),$e(x,"sourceMode",!e),$(),Y())},K=function(){return s.focus(),s.value.substring(s.selectionStart,s.selectionEnd)},N=function(e,t){se.inSourceMode()?t.txtExec&&(Array.isArray(t.txtExec)?se.sourceEditorInsertText.apply(se,t.txtExec):t.txtExec.call(se,e,K())):t.exec&&(xe(t.exec)?t.exec.call(se,e):se.execCommand(t.exec,t.hasOwnProperty("execParam")?t.execParam:null))},se.execCommand=function(e,t){var n=!1,o=se.commands[e];if(se.focus(),!Ne(m.parentNode(),"code")){try{n=d.execCommand(e,!1,t)}catch(e){}!n&&o&&o.errorMessage&&alert(se._(o.errorMessage)),Y()}},Z=function(){function e(){if(l.getSelection()&&l.getSelection().rangeCount<=0)y=null;else if(m&&!m.compare(y)){if((y=m.cloneSelected())&&y.collapsed){var e=y.startContainer,t=y.startOffset;for(t&&e.nodeType!==ke&&(e=e.childNodes[t]);e&&e.parentNode!==f;)e=e.parentNode;e&&rt(e,!0)&&(m.saveRange(),n=d,Je(f,function(e){rt(e,!0)?(o||e.nodeType===ke?/\S/.test(e.nodeValue):!je(e,".sceditor-ignore"))&&(o||We(o=De("p",{},n),e),Ae(o,e)):o=null},!1,!0),m.restoreRange())}Xe(x,"selectionchanged")}var n,o;b=!1}b||(b=!0,"onselectionchange"in d?e():setTimeout(e,100))},J=function(){var e,t=m.parentNode();h!==t&&(e=h,h=t,v=m.getFirstBlockParent(t),Xe(x,"nodechanged",{oldNode:e,newNode:h}))},se.currentNode=function(){return h},se.currentBlockNode=function(){return v},Y=function(){var e,t,n="active",o=d,r=se.sourceMode();if(se.readOnly())Ce(Re(u,n),function(e,t){Ge(t,n)});else{r||(t=m.parentNode(),e=m.getFirstBlockParent(t));for(var i=0;i<de.length;i++){var a=0,l=pe[de[i].name],s=de[i].state,c=r&&!l._sceTxtMode||!r&&!l._sceWysiwygMode;if(ye(s)){if(!r)try{-1<(a=o.queryCommandEnabled(s)?0:-1)&&(a=o.queryCommandState(s)?1:0)}catch(e){}}else c||(a=s.call(se,t,e));$e(l,"disabled",c||a<0),$e(l,n,0<a)}D&&D.update&&D.update(r,t,e)}},U=function(e){var t,n,o;e.defaultPrevented||(se.closeDropDown(),13!==e.which||!je(v,"li,ul,ol")&&tt(v)&&(t=De("br",{},d),m.insertNode(t),(o=(n=t.parentNode).lastChild)&&o.nodeType===ke&&""===o.nodeValue&&(Me(o),o=n.lastChild),!rt(n,!0)&&o===t&&rt(t.previousSibling)&&m.insertHTML("<br>"),e.preventDefault()))},X=function(){Qe(f,function(e){if(e.nodeType===Se&&!/inline/.test(Pe(e,"display"))&&!je(e,".sceditor-nlf")&&tt(e)){var t=De("p",{},d);return t.className="sceditor-nlf",t.innerHTML="<br />",Ae(f,t),!1}if(3===e.nodeType&&!/^\s*$/.test(e.nodeValue)||je(e,"br"))return!1})},j=function(){se.val(r.value)},W=function(){se.closeDropDown()},se._=function(){var n=arguments;return t&&t[n[0]]&&(n[0]=t[n[0]]),n[0].replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[+t+1]?n[+t+1]:"{"+t+"}"})},q=function(t){g&&g.call(t.type+"Event",t,se);var e=(t.target===s?"scesrc":"scewys")+t.type;ce[e]&&ce[e].forEach(function(e){e.call(se,t)})},se.bind=function(e,t,n,o){for(var r,i,a=(e=e.split(" ")).length;a--;)xe(t)&&(r="scewys"+e[a],i="scesrc"+e[a],n||(ce[r]=ce[r]||[],ce[r].push(t)),o||(ce[i]=ce[i]||[],ce[i].push(t)),"valuechanged"===e[a]&&(oe.hasHandler=!0));return se},se.unbind=function(e,t,n,o){for(var r=(e=e.split(" ")).length;r--;)xe(t)&&(n||Te(ce["scewys"+e[r]]||[],t),o||Te(ce["scesrc"+e[r]]||[],t));return se},se.blur=function(e,t,n){return xe(e)?se.bind("blur",e,t,n):(se.sourceMode()?s:f).blur(),se},se.focus=function(e,t,n){if(xe(e))se.bind("focus",e,t,n);else if(se.inSourceMode())s.focus();else{if(Re(d,":focus").length)return;var o,n=m.selectedRange();y||Q(!0),n&&1===n.endOffset&&n.collapsed&&(o=n.endContainer)&&1===o.childNodes.length&&je(o.firstChild,"br")&&(n.setStartBefore(o.firstChild),n.collapse(!0),m.selectRange(n)),l.focus(),f.focus()}return Y(),se},se.keyDown=function(e,t,n){return se.bind("keydown",e,t,n)},se.keyPress=function(e,t,n){return se.bind("keypress",e,t,n)},se.keyUp=function(e,t,n){return se.bind("keyup",e,t,n)},se.nodeChanged=function(e){return se.bind("nodechanged",e,!1,!0)},se.selectionChanged=function(e){return se.bind("selectionchanged",e,!1,!0)},se.valueChanged=function(e,t,n){return se.bind("valuechanged",e,t,n)},ee=function(e){var n=0,o=se.emoticonsCache,t=String.fromCharCode(e.which);Ne(v,"code")||(o||(o=[],Ce(me,function(e,t){o[n++]=[e,t]}),o.sort(function(e,t){return e[0].length-t[0].length}),se.emoticonsCache=o,se.longestEmoticonCode=o[o.length-1][0].length),m.replaceKeyword(se.emoticonsCache,!0,!0,se.longestEmoticonCode,ge.emoticonsCompat,t)&&(ge.emoticonsCompat&&/^\s$/.test(t)||e.preventDefault()))},te=function(){!function(e,t){var n=/[^\s\xA0\u2002\u2003\u2009]+/,o=e&&Re(e,"img[data-sceditor-emoticon]");if(e&&o.length)for(var r=0;r<o.length;r++){var i,a,l,s,c=o[r],u=c.parentNode,d=c.previousSibling,f=c.nextSibling;(d&&n.test(d.nodeValue.slice(-1))||f&&n.test((f.nodeValue||"")[0]))&&(a=-1,l=(i=t.cloneSelected()).startContainer,s=d.nodeValue||"",s+=Ue(c,"sceditor-emoticon"),l===f&&(a=s.length+i.startOffset),l===e&&e.childNodes[i.startOffset]===f&&(a=s.length),l===d&&(a=i.startOffset),(f=!f||f.nodeType!==ke?u.insertBefore(u.ownerDocument.createTextNode(""),f):f).insertData(0,s),Me(d),Me(c),-1<a&&(i.setStart(f,a),i.collapse(!0),t.selectRange(i)))}}(v,m)},se.emoticons=function(e){return e||!1===e?((ge.emoticonsEnabled=e)?(Fe(f,"keypress",ee),se.sourceMode()||(m.saveRange(),E(),oe(!1),m.restoreRange())):(Ce(Re(f,"img[data-sceditor-emoticon]"),function(e,t){var n=Ue(t,"sceditor-emoticon"),n=d.createTextNode(n);t.parentNode.replaceChild(n,t)}),Oe(f,"keypress",ee),oe()),se):ge.emoticonsEnabled},se.css=function(e){return w||(w=De("style",{id:"inline"},d),Ae(d.head,w)),ye(e)?(w.styleSheet?w.styleSheet.cssText=e:w.innerHTML=e,se):w.styleSheet?w.styleSheet.cssText:w.innerHTML},B=function(e){var t=[],n={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|","[":"{","]":"}"},o={109:"-",110:"del",111:"/",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},r=e.which,i={8:"backspace",9:"tab",13:"enter",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"win",92:"win",93:"select",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}[r]||String.fromCharCode(r).toLowerCase();(e.ctrlKey||e.metaKey)&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&(t.push("shift"),o[r]?i=o[r]:n[i]&&(i=n[i])),i&&(r<16||18<r)&&t.push(i),t=t.join("+"),fe[t]&&!1===fe[t].call(se)&&(e.stopPropagation(),e.preventDefault())},se.addShortcut=function(e,t){return e=e.toLowerCase(),ye(t)?fe[e]=function(){return N(pe[t],se.commands[t]),!1}:fe[e]=t,se},se.removeShortcut=function(e){return delete fe[e.toLowerCase()],se},P=function(e){var t,n,o;if(!ge.disableBlockRemove&&8===e.which&&(n=m.selectedRange())&&(t=n.startContainer,0===n.startOffset&&(o=ne())&&!je(o,"body"))){for(;t!==o;){for(;t.previousSibling;)if((t=t.previousSibling).nodeType!==ke||t.nodeValue)return;if(!(t=t.parentNode))return}se.clearBlockFormatting(o),e.preventDefault()}},ne=function(){for(var e=v;!tt(e)||rt(e,!0);)if(!(e=e.parentNode)||je(e,"body"))return;return e},se.clearBlockFormatting=function(e){return!(e=e||ne())||je(e,"body")||(m.saveRange(),e.className="",He(e,"style",""),je(e,"p,div,td")||nt(e,"p"),m.restoreRange()),se},oe=function(e){var t,n,o;g&&(g.hasHandler("valuechangedEvent")||oe.hasHandler)&&(o=!(n=se.sourceMode())&&m.hasSelection(),e=(c=!1)!==e&&!d.getElementById("sceditor-start-marker"),p&&(clearTimeout(p),p=!1),o&&e&&m.saveRange(),(t=n?s.value:f.innerHTML)!==oe.lastVal&&(oe.lastVal=t,Xe(x,"valuechanged",{rawValue:n?se.val():t})),o&&e&&m.removeMarkers())},re=function(){p&&oe()},ie=function(e){var t=e.which,n=ie.lastChar,e=13===n||32===n,n=8===n||46===n;ie.lastChar=t,c||(13===t||32===t?e?ie.triggerNext=!0:oe():8===t||46===t?n?ie.triggerNext=!0:oe():ie.triggerNext&&(oe(),ie.triggerNext=!1),clearTimeout(p),p=setTimeout(function(){c||oe()},1500))},V=function(e){(c=/start/i.test(e.type))||oe()},ae=function(){se.updateOriginal()},e()}an.locale={},an.formats={},an.icons={},an.command={get:function(e){return mt[e]||null},set:function(e,t){return!(!e||!t)&&((t=we(mt[e]||{},t)).remove=function(){an.command.remove(e)},mt[e]=t,this)},remove:function(e){return mt[e]&&delete mt[e],this}},window.sceditor={command:an.command,commands:mt,defaultOptions:ut,ios:vt,isWysiwygSupported:yt,regexEscape:dt,escapeEntities:ft,escapeUriScheme:function(e){var t,n=window.location;return e&&/^[^\/]*:/i.test(e)&&!p.test(e)?((t=n.pathname.split("/")).pop(),n.protocol+"//"+n.host+t.join("/")+"/"+e):e},dom:{css:Pe,attr:He,removeAttr:ze,is:je,closest:Ne,width:Ye,height:Ke,traverse:Je,rTraverse:Qe,parseHTML:et,hasStyling:tt,convertElement:nt,blockLevelList:s,canHaveChildren:ot,isInline:rt,copyCSS:function(e,t){t.style&&e.style&&(t.style.cssText=e.style.cssText+t.style.cssText)},fixNesting:it,findCommonAncestor:function(e,t){for(;e=e.parentNode;)if((n=e)!==(o=t)&&n.contains&&n.contains(o))return e;var n,o},getSibling:u,removeWhiteSpace:at,extractContents:c,getOffset:lt,getStyle:f,hasStyle:function(e,t,n){return!!(t=f(e,t))&&(!n||t===n||Array.isArray(n)&&-1<n.indexOf(t))}},locale:an.locale,icons:an.icons,utils:{each:Ce,isEmptyObject:t,extend:we},plugins:gt.plugins,formats:an.formats,create:function(e,t){t=t||{},Ee(e,".sceditor-container")||(t.runWithoutWysiwygSupport||yt)&&new an(e,t)},instance:function(e){return e._sceditor}}}(); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/themes/content/default.min.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1 @@ +/*! SCEditor | (C) 2011-2013, Sam Clarke | sceditor.com/license */body,code:before,html,p,table{margin:0;padding:0;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;color:#111;line-height:1.25;overflow:visible}html{height:100%}.ios{overflow:auto;-webkit-overflow-scrolling:touch}.ios body{position:relative;overflow:auto}body{min-height:100%;word-wrap:break-word}body.placeholder:before{content:attr(placeholder);color:#555;font-style:italic}ol,ul{margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0}table,td{border:1px dotted #000;empty-cells:show}table td{min-width:5px}code{display:block;background:#f1f1f1;white-space:pre;padding:1em;text-align:left;margin:.25em 0;direction:ltr}blockquote{background:#fff7d9;margin:.25em 0;border-left:.3em solid #f4e59f;padding:.5em .5em .5em .75em}blockquote cite{font-weight:700;display:block;font-size:1em;margin:0 -.5em .25em -.75em;padding:0 .5em .15em .75em;border-bottom:1px solid #f4e59f}h1,h2,h3,h4,h5,h6{padding:0;margin:0}div,p{min-height:1.25em} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/themes/default.min.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1 @@ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */.sceditor-button div,div.sceditor-grip{background-image:url(famfamfam.png);background-repeat:no-repeat;width:16px;height:16px}.sceditor-button-youtube div{background-position:0 0}.sceditor-button-link div{background-position:0 -16px}.sceditor-button-unlink div{background-position:0 -32px}.sceditor-button-underline div{background-position:0 -48px}.sceditor-button-time div{background-position:0 -64px}.sceditor-button-table div{background-position:0 -80px}.sceditor-button-superscript div{background-position:0 -96px}.sceditor-button-subscript div{background-position:0 -112px}.sceditor-button-strike div{background-position:0 -128px}.sceditor-button-source div{background-position:0 -144px}.sceditor-button-size div{background-position:0 -160px}.sceditor-button-rtl div{background-position:0 -176px}.sceditor-button-right div{background-position:0 -192px}.sceditor-button-removeformat div{background-position:0 -208px}.sceditor-button-quote div{background-position:0 -224px}.sceditor-button-print div{background-position:0 -240px}.sceditor-button-pastetext div{background-position:0 -256px}.sceditor-button-paste div{background-position:0 -272px}.sceditor-button-outdent div{background-position:0 -288px}.sceditor-button-orderedlist div{background-position:0 -304px}.sceditor-button-maximize div{background-position:0 -320px}.sceditor-button-ltr div{background-position:0 -336px}.sceditor-button-left div{background-position:0 -352px}.sceditor-button-justify div{background-position:0 -368px}.sceditor-button-italic div{background-position:0 -384px}.sceditor-button-indent div{background-position:0 -400px}.sceditor-button-image div{background-position:0 -416px}.sceditor-button-horizontalrule div{background-position:0 -432px}.sceditor-button-format div{background-position:0 -448px}.sceditor-button-font div{background-position:0 -464px}.sceditor-button-emoticon div{background-position:0 -480px}.sceditor-button-email div{background-position:0 -496px}.sceditor-button-date div{background-position:0 -512px}.sceditor-button-cut div{background-position:0 -528px}.sceditor-button-copy div{background-position:0 -544px}.sceditor-button-color div{background-position:0 -560px}.sceditor-button-code div{background-position:0 -576px}.sceditor-button-center div{background-position:0 -592px}.sceditor-button-bulletlist div{background-position:0 -608px}.sceditor-button-bold div{background-position:0 -624px}div.sceditor-grip{background-position:0 -640px}.rtl div.sceditor-grip{background-position:0 -650px}.sceditor-container{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:column;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;position:relative;background:#fff;border:1px solid #d9d9d9;font-size:13px;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;color:#333;line-height:1;font-weight:700;height:250px;border-radius:4px;background-clip:padding-box}.sceditor-container *,.sceditor-container :after,.sceditor-container :before{-webkit-box-sizing:content-box;box-sizing:content-box}.sceditor-container,.sceditor-container div,div.sceditor-dropdown,div.sceditor-dropdown div{padding:0;margin:0;z-index:3}.sceditor-container iframe,.sceditor-container textarea{display:block;-ms-flex:1 1 0%;-webkit-box-flex:1;flex:1 1 0%;line-height:1.25;border:0;outline:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;color:#111;padding:0;margin:5px;resize:none;background:#fff;height:auto!important;width:auto!important;width:calc(100% - 10px)!important;min-height:1px}.sceditor-container textarea{margin:7px 5px}div.sceditor-dnd-cover{position:absolute;top:0;left:0;bottom:0;right:0;background:hsla(0,0%,100%,.2);border:5px dashed #aaa;z-index:200;font-size:2em;text-align:center;color:#aaa}div.sceditor-dnd-cover p{position:relative;top:45%;pointer-events:none}div.sceditor-resize-cover{position:absolute;top:0;left:0;background:#000;width:100%;height:100%;z-index:10;opacity:.3}div.sceditor-grip{overflow:hidden;width:10px;height:10px;cursor:pointer;position:absolute;bottom:0;right:0;z-index:3;line-height:0}div.sceditor-grip.has-icon{background-image:none}.sceditor-maximize{position:fixed;top:0;left:0;height:100%!important;width:100%!important;border-radius:0;background-clip:padding-box;z-index:2000}body.sceditor-maximize,html.sceditor-maximize{height:100%;width:100%;padding:0;margin:0;overflow:hidden}.sceditor-maximize div.sceditor-grip{display:none}.sceditor-maximize div.sceditor-toolbar{border-radius:0;background-clip:padding-box}div.sceditor-dropdown{position:absolute;border:1px solid #ccc;background:#fff;z-index:4000;padding:10px;font-weight:400;font-size:15px;border-radius:2px;background-clip:padding-box;-webkit-box-shadow:1px 2px 4px rgba(0,0,0,.2);box-shadow:1px 2px 4px rgba(0,0,0,.2)}div.sceditor-dropdown *,div.sceditor-dropdown :after,div.sceditor-dropdown :before{-webkit-box-sizing:border-box;box-sizing:border-box}div.sceditor-dropdown a,div.sceditor-dropdown a:link{color:#333}div.sceditor-dropdown form{margin:0}div.sceditor-dropdown label{display:block;font-weight:700;color:#3c3c3c;padding:4px 0}div.sceditor-dropdown input,div.sceditor-dropdown textarea{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;outline:0;padding:4px;border:1px solid #ccc;border-top-color:#888;margin:0 0 .75em;border-radius:1px;background-clip:padding-box}div.sceditor-dropdown textarea{padding:6px}div.sceditor-dropdown input:focus,div.sceditor-dropdown textarea:focus{border-color:#666 #aaa #aaa;-webkit-box-shadow:inset 0 1px 5px rgba(0,0,0,.1);box-shadow:inset 0 1px 5px rgba(0,0,0,.1)}div.sceditor-dropdown .button{font-weight:700;color:#444;padding:6px 12px;background:#ececec;border:1px solid #ccc;border-radius:2px;background-clip:padding-box;cursor:pointer;margin:.3em 0 0}div.sceditor-dropdown .button:hover{background:#f3f3f3;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.15);box-shadow:0 1px 1px rgba(0,0,0,.15)}div.sceditor-font-picker,div.sceditor-fontsize-picker,div.sceditor-format{padding:6px 0}div.sceditor-color-picker{padding:4px}div.sceditor-emoticons,div.sceditor-more-emoticons{padding:0}.sceditor-pastetext textarea{border:1px solid #bbb;width:20em}.sceditor-emoticons img,.sceditor-more-emoticons img{padding:0;cursor:pointer;margin:2px}.sceditor-more{border-top:1px solid #bbb;display:block;text-align:center;cursor:pointer;font-weight:700;padding:6px 0}.sceditor-dropdown a:hover{background:#eee}.sceditor-font-option,.sceditor-fontsize-option,.sceditor-format a{display:block;padding:7px 10px;cursor:pointer;text-decoration:none;color:#222}.sceditor-fontsize-option{padding:7px 13px}.sceditor-color-column{float:left}.sceditor-color-option{display:block;border:2px solid #fff;height:18px;width:18px;overflow:hidden}.sceditor-color-option:hover{border:1px solid #aaa}div.sceditor-toolbar{-ms-flex-negative:0;flex-shrink:0;overflow:hidden;padding:3px 5px 2px;background:#f7f7f7;border-bottom:1px solid silver;line-height:0;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-radius:3px 3px 0 0;background-clip:padding-box}div.sceditor-group{display:inline-block;background:#ddd;margin:1px 5px 1px 0;padding:1px;border-bottom:1px solid #aaa;border-radius:3px;background-clip:padding-box}.sceditor-button{float:left;cursor:pointer;padding:3px 5px;width:16px;height:20px;border-radius:3px;background-clip:padding-box}.sceditor-button.active,.sceditor-button:active,.sceditor-button:hover{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2)}.sceditor-button:active{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3)}.sceditor-button.disabled:hover{background:inherit;cursor:default;-webkit-box-shadow:none;box-shadow:none}.sceditor-button,.sceditor-button div{display:block}.sceditor-button svg{display:inline-block;height:16px;width:16px;margin:2px 0;fill:#111;text-decoration:none;pointer-events:none;line-height:1}.sceditor-button.disabled svg{fill:#888}.sceditor-button div{display:inline-block;margin:2px 0;padding:0;overflow:hidden;line-height:0;font-size:0;color:rgba(0,0,0,0)}.sceditor-button.has-icon div{display:none}.sceditor-button.disabled div{opacity:.3}.sceditor-button.text,.sceditor-button.text-icon,.sceditor-button.text-icon div,.sceditor-button.text div,.text-icon .sceditor-button,.text-icon .sceditor-button div,.text .sceditor-button,.text .sceditor-button div{display:inline-block;width:auto;line-height:16px;font-size:1em;color:inherit;text-indent:0}.sceditor-button.has-icon div,.sceditor-button.text div,.text-icon .sceditor-button.has-icon div,.text .sceditor-button div{padding:0 2px;background:none}.sceditor-button.text svg,.text .sceditor-button svg{display:none}.sceditor-button.text-icon div,.text-icon .sceditor-button div{padding:0 2px 0 20px}.rtl div.sceditor-toolbar{text-align:right}.rtl .sceditor-button{float:right}.rtl div.sceditor-grip{right:auto;left:0} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/themes/defaultdark.min.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1 @@ +/*! SCEditor | (C) 2017, Sam Clarke | sceditor.com/license */.sceditor-button div,div.sceditor-grip{background-image:url(famfamfam.png);background-repeat:no-repeat;width:16px;height:16px}.sceditor-button-youtube div{background-position:0 0}.sceditor-button-link div{background-position:0 -16px}.sceditor-button-unlink div{background-position:0 -32px}.sceditor-button-underline div{background-position:0 -48px}.sceditor-button-time div{background-position:0 -64px}.sceditor-button-table div{background-position:0 -80px}.sceditor-button-superscript div{background-position:0 -96px}.sceditor-button-subscript div{background-position:0 -112px}.sceditor-button-strike div{background-position:0 -128px}.sceditor-button-source div{background-position:0 -144px}.sceditor-button-size div{background-position:0 -160px}.sceditor-button-rtl div{background-position:0 -176px}.sceditor-button-right div{background-position:0 -192px}.sceditor-button-removeformat div{background-position:0 -208px}.sceditor-button-quote div{background-position:0 -224px}.sceditor-button-print div{background-position:0 -240px}.sceditor-button-pastetext div{background-position:0 -256px}.sceditor-button-paste div{background-position:0 -272px}.sceditor-button-outdent div{background-position:0 -288px}.sceditor-button-orderedlist div{background-position:0 -304px}.sceditor-button-maximize div{background-position:0 -320px}.sceditor-button-ltr div{background-position:0 -336px}.sceditor-button-left div{background-position:0 -352px}.sceditor-button-justify div{background-position:0 -368px}.sceditor-button-italic div{background-position:0 -384px}.sceditor-button-indent div{background-position:0 -400px}.sceditor-button-image div{background-position:0 -416px}.sceditor-button-horizontalrule div{background-position:0 -432px}.sceditor-button-format div{background-position:0 -448px}.sceditor-button-font div{background-position:0 -464px}.sceditor-button-emoticon div{background-position:0 -480px}.sceditor-button-email div{background-position:0 -496px}.sceditor-button-date div{background-position:0 -512px}.sceditor-button-cut div{background-position:0 -528px}.sceditor-button-copy div{background-position:0 -544px}.sceditor-button-color div{background-position:0 -560px}.sceditor-button-code div{background-position:0 -576px}.sceditor-button-center div{background-position:0 -592px}.sceditor-button-bulletlist div{background-position:0 -608px}.sceditor-button-bold div{background-position:0 -624px}div.sceditor-grip{background-position:0 -640px}.rtl div.sceditor-grip{background-position:0 -650px}.sceditor-container{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:column;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;position:relative;background:#fff;border:1px solid #d9d9d9;font-size:13px;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;color:#333;line-height:1;font-weight:700;height:250px;border-radius:4px;background-clip:padding-box}.sceditor-container *,.sceditor-container :after,.sceditor-container :before{-webkit-box-sizing:content-box;box-sizing:content-box}.sceditor-container,.sceditor-container div,div.sceditor-dropdown,div.sceditor-dropdown div{padding:0;margin:0;z-index:3}.sceditor-container iframe,.sceditor-container textarea{display:block;-ms-flex:1 1 0%;-webkit-box-flex:1;flex:1 1 0%;line-height:1.25;border:0;outline:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;color:#111;padding:0;margin:5px;resize:none;background:#fff;height:auto!important;width:auto!important;width:calc(100% - 10px)!important;min-height:1px}.sceditor-container textarea{margin:7px 5px}div.sceditor-dnd-cover{position:absolute;top:0;left:0;bottom:0;right:0;background:hsla(0,0%,100%,.2);border:5px dashed #aaa;z-index:200;font-size:2em;text-align:center;color:#aaa}div.sceditor-dnd-cover p{position:relative;top:45%;pointer-events:none}div.sceditor-resize-cover{position:absolute;top:0;left:0;background:#000;width:100%;height:100%;z-index:10;opacity:.3}div.sceditor-grip{overflow:hidden;width:10px;height:10px;cursor:pointer;position:absolute;bottom:0;right:0;z-index:3;line-height:0}div.sceditor-grip.has-icon{background-image:none}.sceditor-maximize{position:fixed;top:0;left:0;height:100%!important;width:100%!important;border-radius:0;background-clip:padding-box;z-index:2000}body.sceditor-maximize,html.sceditor-maximize{height:100%;width:100%;padding:0;margin:0;overflow:hidden}.sceditor-maximize div.sceditor-grip{display:none}.sceditor-maximize div.sceditor-toolbar{border-radius:0;background-clip:padding-box}div.sceditor-dropdown{position:absolute;border:1px solid #ccc;background:#fff;z-index:4000;padding:10px;font-weight:400;font-size:15px;border-radius:2px;background-clip:padding-box;-webkit-box-shadow:1px 2px 4px rgba(0,0,0,.2);box-shadow:1px 2px 4px rgba(0,0,0,.2)}div.sceditor-dropdown *,div.sceditor-dropdown :after,div.sceditor-dropdown :before{-webkit-box-sizing:border-box;box-sizing:border-box}div.sceditor-dropdown a,div.sceditor-dropdown a:link{color:#333}div.sceditor-dropdown form{margin:0}div.sceditor-dropdown label{display:block;font-weight:700;color:#3c3c3c;padding:4px 0}div.sceditor-dropdown input,div.sceditor-dropdown textarea{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;outline:0;padding:4px;border:1px solid #ccc;border-top-color:#888;margin:0 0 .75em;border-radius:1px;background-clip:padding-box}div.sceditor-dropdown textarea{padding:6px}div.sceditor-dropdown input:focus,div.sceditor-dropdown textarea:focus{border-color:#666 #aaa #aaa;-webkit-box-shadow:inset 0 1px 5px rgba(0,0,0,.1);box-shadow:inset 0 1px 5px rgba(0,0,0,.1)}div.sceditor-dropdown .button{font-weight:700;color:#444;padding:6px 12px;background:#ececec;border:1px solid #ccc;border-radius:2px;background-clip:padding-box;cursor:pointer;margin:.3em 0 0}div.sceditor-dropdown .button:hover{background:#f3f3f3;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.15);box-shadow:0 1px 1px rgba(0,0,0,.15)}div.sceditor-font-picker,div.sceditor-fontsize-picker,div.sceditor-format{padding:6px 0}div.sceditor-color-picker{padding:4px}div.sceditor-emoticons,div.sceditor-more-emoticons{padding:0}.sceditor-pastetext textarea{border:1px solid #bbb;width:20em}.sceditor-emoticons img,.sceditor-more-emoticons img{padding:0;cursor:pointer;margin:2px}.sceditor-more{border-top:1px solid #bbb;display:block;text-align:center;cursor:pointer;font-weight:700;padding:6px 0}.sceditor-dropdown a:hover{background:#eee}.sceditor-font-option,.sceditor-fontsize-option,.sceditor-format a{display:block;padding:7px 10px;cursor:pointer;text-decoration:none;color:#222}.sceditor-fontsize-option{padding:7px 13px}.sceditor-color-column{float:left}.sceditor-color-option{display:block;border:2px solid #fff;height:18px;width:18px;overflow:hidden}.sceditor-color-option:hover{border:1px solid #aaa}div.sceditor-toolbar{-ms-flex-negative:0;flex-shrink:0;overflow:hidden;padding:3px 5px 2px;background:#f7f7f7;border-bottom:1px solid silver;line-height:0;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-radius:3px 3px 0 0;background-clip:padding-box}div.sceditor-group{display:inline-block;background:#ddd;margin:1px 5px 1px 0;padding:1px;border-bottom:1px solid #aaa;border-radius:3px;background-clip:padding-box}.sceditor-button{float:left;cursor:pointer;padding:3px 5px;width:16px;height:20px;border-radius:3px;background-clip:padding-box}.sceditor-button.active,.sceditor-button:active,.sceditor-button:hover{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2)}.sceditor-button:active{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3)}.sceditor-button.disabled:hover{background:inherit;cursor:default;-webkit-box-shadow:none;box-shadow:none}.sceditor-button,.sceditor-button div{display:block}.sceditor-button svg{display:inline-block;height:16px;width:16px;margin:2px 0;fill:#111;text-decoration:none;pointer-events:none;line-height:1}.sceditor-button.disabled svg{fill:#888}.sceditor-button div{display:inline-block;margin:2px 0;padding:0;overflow:hidden;line-height:0;font-size:0;color:rgba(0,0,0,0)}.sceditor-button.has-icon div{display:none}.sceditor-button.disabled div{opacity:.3}.sceditor-button.text,.sceditor-button.text-icon,.sceditor-button.text-icon div,.sceditor-button.text div,.text-icon .sceditor-button,.text-icon .sceditor-button div,.text .sceditor-button,.text .sceditor-button div{display:inline-block;width:auto;line-height:16px;font-size:1em;color:inherit;text-indent:0}.sceditor-button.has-icon div,.sceditor-button.text div,.text-icon .sceditor-button.has-icon div,.text .sceditor-button div{padding:0 2px;background:none}.sceditor-button.text svg,.text .sceditor-button svg{display:none}.sceditor-button.text-icon div,.text-icon .sceditor-button div{padding:0 2px 0 20px}.rtl div.sceditor-toolbar{text-align:right}.rtl .sceditor-button{float:right}.rtl div.sceditor-grip{right:auto;left:0}div.sceditor-toolbar{background:#5d5d5d}div.sceditor-group{background:#303030;border-bottom:1px solid #000}.sceditor-button.active,.sceditor-button:active,.sceditor-button:hover{background:#6b6b6b}.sceditor-button svg{fill:#fff}.sceditor-button.disabled svg{fill:#777} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/themes/modern.min.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1 @@ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */.sceditor-button div,div.sceditor-grip{background-image:url(famfamfam.png);background-repeat:no-repeat;width:16px;height:16px}.sceditor-button-youtube div{background-position:0 0}.sceditor-button-link div{background-position:0 -16px}.sceditor-button-unlink div{background-position:0 -32px}.sceditor-button-underline div{background-position:0 -48px}.sceditor-button-time div{background-position:0 -64px}.sceditor-button-table div{background-position:0 -80px}.sceditor-button-superscript div{background-position:0 -96px}.sceditor-button-subscript div{background-position:0 -112px}.sceditor-button-strike div{background-position:0 -128px}.sceditor-button-source div{background-position:0 -144px}.sceditor-button-size div{background-position:0 -160px}.sceditor-button-rtl div{background-position:0 -176px}.sceditor-button-right div{background-position:0 -192px}.sceditor-button-removeformat div{background-position:0 -208px}.sceditor-button-quote div{background-position:0 -224px}.sceditor-button-print div{background-position:0 -240px}.sceditor-button-pastetext div{background-position:0 -256px}.sceditor-button-paste div{background-position:0 -272px}.sceditor-button-outdent div{background-position:0 -288px}.sceditor-button-orderedlist div{background-position:0 -304px}.sceditor-button-maximize div{background-position:0 -320px}.sceditor-button-ltr div{background-position:0 -336px}.sceditor-button-left div{background-position:0 -352px}.sceditor-button-justify div{background-position:0 -368px}.sceditor-button-italic div{background-position:0 -384px}.sceditor-button-indent div{background-position:0 -400px}.sceditor-button-image div{background-position:0 -416px}.sceditor-button-horizontalrule div{background-position:0 -432px}.sceditor-button-format div{background-position:0 -448px}.sceditor-button-font div{background-position:0 -464px}.sceditor-button-emoticon div{background-position:0 -480px}.sceditor-button-email div{background-position:0 -496px}.sceditor-button-date div{background-position:0 -512px}.sceditor-button-cut div{background-position:0 -528px}.sceditor-button-copy div{background-position:0 -544px}.sceditor-button-color div{background-position:0 -560px}.sceditor-button-code div{background-position:0 -576px}.sceditor-button-center div{background-position:0 -592px}.sceditor-button-bulletlist div{background-position:0 -608px}.sceditor-button-bold div{background-position:0 -624px}div.sceditor-grip{background-position:0 -640px}.rtl div.sceditor-grip{background-position:0 -650px}.sceditor-container{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:column;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;position:relative;background:#fff;border:1px solid #d9d9d9;font-size:13px;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;color:#333;line-height:1;font-weight:700;height:250px;border-radius:4px;background-clip:padding-box}.sceditor-container *,.sceditor-container :after,.sceditor-container :before{-webkit-box-sizing:content-box;box-sizing:content-box}.sceditor-container,.sceditor-container div,div.sceditor-dropdown,div.sceditor-dropdown div{padding:0;margin:0;z-index:3}.sceditor-container iframe,.sceditor-container textarea{display:block;-ms-flex:1 1 0%;-webkit-box-flex:1;flex:1 1 0%;line-height:1.25;border:0;outline:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;color:#111;padding:0;margin:5px;resize:none;background:#fff;height:auto!important;width:auto!important;width:calc(100% - 10px)!important;min-height:1px}.sceditor-container textarea{margin:7px 5px}div.sceditor-dnd-cover{position:absolute;top:0;left:0;bottom:0;right:0;background:hsla(0,0%,100%,.2);border:5px dashed #aaa;z-index:200;font-size:2em;text-align:center;color:#aaa}div.sceditor-dnd-cover p{position:relative;top:45%;pointer-events:none}div.sceditor-resize-cover{position:absolute;top:0;left:0;background:#000;width:100%;height:100%;z-index:10;opacity:.3}div.sceditor-grip{overflow:hidden;width:10px;height:10px;cursor:pointer;position:absolute;bottom:0;right:0;z-index:3;line-height:0}div.sceditor-grip.has-icon{background-image:none}.sceditor-maximize{position:fixed;top:0;left:0;height:100%!important;width:100%!important;border-radius:0;background-clip:padding-box;z-index:2000}body.sceditor-maximize,html.sceditor-maximize{height:100%;width:100%;padding:0;margin:0;overflow:hidden}.sceditor-maximize div.sceditor-grip{display:none}.sceditor-maximize div.sceditor-toolbar{border-radius:0;background-clip:padding-box}div.sceditor-dropdown{position:absolute;border:1px solid #ccc;background:#fff;z-index:4000;padding:10px;font-weight:400;font-size:15px;border-radius:2px;background-clip:padding-box;-webkit-box-shadow:1px 2px 4px rgba(0,0,0,.2);box-shadow:1px 2px 4px rgba(0,0,0,.2)}div.sceditor-dropdown *,div.sceditor-dropdown :after,div.sceditor-dropdown :before{-webkit-box-sizing:border-box;box-sizing:border-box}div.sceditor-dropdown a,div.sceditor-dropdown a:link{color:#333}div.sceditor-dropdown form{margin:0}div.sceditor-dropdown label{display:block;font-weight:700;color:#3c3c3c;padding:4px 0}div.sceditor-dropdown input,div.sceditor-dropdown textarea{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;outline:0;padding:4px;border:1px solid #ccc;border-top-color:#888;margin:0 0 .75em;border-radius:1px;background-clip:padding-box}div.sceditor-dropdown textarea{padding:6px}div.sceditor-dropdown input:focus,div.sceditor-dropdown textarea:focus{border-color:#666 #aaa #aaa;-webkit-box-shadow:inset 0 1px 5px rgba(0,0,0,.1);box-shadow:inset 0 1px 5px rgba(0,0,0,.1)}div.sceditor-dropdown .button{font-weight:700;color:#444;padding:6px 12px;background:#ececec;border:1px solid #ccc;border-radius:2px;background-clip:padding-box;cursor:pointer;margin:.3em 0 0}div.sceditor-dropdown .button:hover{background:#f3f3f3;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.15);box-shadow:0 1px 1px rgba(0,0,0,.15)}div.sceditor-font-picker,div.sceditor-fontsize-picker,div.sceditor-format{padding:6px 0}div.sceditor-color-picker{padding:4px}div.sceditor-emoticons,div.sceditor-more-emoticons{padding:0}.sceditor-pastetext textarea{border:1px solid #bbb;width:20em}.sceditor-emoticons img,.sceditor-more-emoticons img{padding:0;cursor:pointer;margin:2px}.sceditor-more{border-top:1px solid #bbb;display:block;text-align:center;cursor:pointer;font-weight:700;padding:6px 0}.sceditor-dropdown a:hover{background:#eee}.sceditor-font-option,.sceditor-fontsize-option,.sceditor-format a{display:block;padding:7px 10px;cursor:pointer;text-decoration:none;color:#222}.sceditor-fontsize-option{padding:7px 13px}.sceditor-color-column{float:left}.sceditor-color-option{display:block;border:2px solid #fff;height:18px;width:18px;overflow:hidden}.sceditor-color-option:hover{border:1px solid #aaa}div.sceditor-toolbar{-ms-flex-negative:0;flex-shrink:0;overflow:hidden;padding:3px 5px 2px;background:#f7f7f7;border-bottom:1px solid silver;line-height:0;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-radius:3px 3px 0 0;background-clip:padding-box}div.sceditor-group{display:inline-block;background:#ddd;margin:1px 5px 1px 0;padding:1px;border-bottom:1px solid #aaa;border-radius:3px;background-clip:padding-box}.sceditor-button{float:left;cursor:pointer;padding:3px 5px;width:16px;height:20px;border-radius:3px}.sceditor-button.active,.sceditor-button:active,.sceditor-button:hover{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2)}.sceditor-button:active{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3)}.sceditor-button.disabled:hover{background:inherit;cursor:default;-webkit-box-shadow:none;box-shadow:none}.sceditor-button,.sceditor-button div{display:block}.sceditor-button svg{display:inline-block;height:16px;width:16px;margin:2px 0;fill:#111;text-decoration:none;pointer-events:none;line-height:1}.sceditor-button.disabled svg{fill:#888}.sceditor-button div{display:inline-block;margin:2px 0;padding:0;overflow:hidden;line-height:0;font-size:0;color:rgba(0,0,0,0)}.sceditor-button.has-icon div{display:none}.sceditor-button.disabled div{opacity:.3}.sceditor-button.text,.sceditor-button.text-icon,.sceditor-button.text-icon div,.sceditor-button.text div,.text-icon .sceditor-button,.text-icon .sceditor-button div,.text .sceditor-button,.text .sceditor-button div{display:inline-block;width:auto;line-height:16px;font-size:1em;color:inherit;text-indent:0}.sceditor-button.has-icon div,.sceditor-button.text div,.text-icon .sceditor-button.has-icon div,.text .sceditor-button div{padding:0 2px;background:none}.sceditor-button.text svg,.text .sceditor-button svg{display:none}.sceditor-button.text-icon div,.text-icon .sceditor-button div{padding:0 2px 0 20px}.rtl div.sceditor-toolbar{text-align:right}.rtl .sceditor-button{float:right}.rtl div.sceditor-grip{right:auto;left:0}.sceditor-container{border:1px solid #999}.sceditor-container textarea{font-family:Consolas,Bitstream Vera Sans Mono,Andale Mono,Monaco,DejaVu Sans Mono,Lucida Console,monospace;background:#2e3436;color:#fff;margin:0;padding:5px}div.sceditor-toolbar{background:#ccc;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #ccc),to(#b2b2b2));background:-o-linear-gradient(top,#ccc 0,#b2b2b2);background:linear-gradient(180deg,#ccc 0,#b2b2b2)}div.sceditor-group{display:inline;background:rgba(0,0,0,0);margin:0;padding:0;border:0}.sceditor-button{padding:4px;margin:2px 1px 2px 3px;height:16px;border-radius:12px;background-clip:padding-box}.sceditor-button.active,.sceditor-button.active:hover,.sceditor-button:hover{-webkit-box-shadow:none;box-shadow:none}.sceditor-button:hover{background:#fff;background:hsla(0,0%,100%,.75);margin:1px 0 1px 2px;border:1px solid #eee}.sceditor-button.disabled:hover{margin:2px 1px 2px 3px;border:0}.sceditor-button.active{background:#b1b1b1;background:rgba(0,0,0,.1);margin:1px 0 1px 2px;border:1px solid #999}.sceditor-button.active:hover{background:#fff;background:hsla(0,0%,100%,.25)}.sceditor-button.active:active,.sceditor-button:active{margin:1px 0 1px 2px;border:1px solid #999;-webkit-box-shadow:inset 0 0 4px rgba(0,0,0,.5);box-shadow:inset 0 0 4px rgba(0,0,0,.5)}.sceditor-button div,.sceditor-button svg{margin:0} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/themes/office-toolbar.min.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1 @@ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */.sceditor-button div,div.sceditor-grip{background-image:url(famfamfam.png);background-repeat:no-repeat;width:16px;height:16px}.sceditor-button-youtube div{background-position:0 0}.sceditor-button-link div{background-position:0 -16px}.sceditor-button-unlink div{background-position:0 -32px}.sceditor-button-underline div{background-position:0 -48px}.sceditor-button-time div{background-position:0 -64px}.sceditor-button-table div{background-position:0 -80px}.sceditor-button-superscript div{background-position:0 -96px}.sceditor-button-subscript div{background-position:0 -112px}.sceditor-button-strike div{background-position:0 -128px}.sceditor-button-source div{background-position:0 -144px}.sceditor-button-size div{background-position:0 -160px}.sceditor-button-rtl div{background-position:0 -176px}.sceditor-button-right div{background-position:0 -192px}.sceditor-button-removeformat div{background-position:0 -208px}.sceditor-button-quote div{background-position:0 -224px}.sceditor-button-print div{background-position:0 -240px}.sceditor-button-pastetext div{background-position:0 -256px}.sceditor-button-paste div{background-position:0 -272px}.sceditor-button-outdent div{background-position:0 -288px}.sceditor-button-orderedlist div{background-position:0 -304px}.sceditor-button-maximize div{background-position:0 -320px}.sceditor-button-ltr div{background-position:0 -336px}.sceditor-button-left div{background-position:0 -352px}.sceditor-button-justify div{background-position:0 -368px}.sceditor-button-italic div{background-position:0 -384px}.sceditor-button-indent div{background-position:0 -400px}.sceditor-button-image div{background-position:0 -416px}.sceditor-button-horizontalrule div{background-position:0 -432px}.sceditor-button-format div{background-position:0 -448px}.sceditor-button-font div{background-position:0 -464px}.sceditor-button-emoticon div{background-position:0 -480px}.sceditor-button-email div{background-position:0 -496px}.sceditor-button-date div{background-position:0 -512px}.sceditor-button-cut div{background-position:0 -528px}.sceditor-button-copy div{background-position:0 -544px}.sceditor-button-color div{background-position:0 -560px}.sceditor-button-code div{background-position:0 -576px}.sceditor-button-center div{background-position:0 -592px}.sceditor-button-bulletlist div{background-position:0 -608px}.sceditor-button-bold div{background-position:0 -624px}div.sceditor-grip{background-position:0 -640px}.rtl div.sceditor-grip{background-position:0 -650px}.sceditor-container{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:column;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;position:relative;background:#fff;border:1px solid #d9d9d9;font-size:13px;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;color:#333;line-height:1;font-weight:700;height:250px;border-radius:4px;background-clip:padding-box}.sceditor-container *,.sceditor-container :after,.sceditor-container :before{-webkit-box-sizing:content-box;box-sizing:content-box}.sceditor-container,.sceditor-container div,div.sceditor-dropdown,div.sceditor-dropdown div{padding:0;margin:0;z-index:3}.sceditor-container iframe,.sceditor-container textarea{display:block;-ms-flex:1 1 0%;-webkit-box-flex:1;flex:1 1 0%;line-height:1.25;border:0;outline:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;color:#111;padding:0;margin:5px;resize:none;background:#fff;height:auto!important;width:auto!important;width:calc(100% - 10px)!important;min-height:1px}.sceditor-container textarea{margin:7px 5px}div.sceditor-dnd-cover{position:absolute;top:0;left:0;bottom:0;right:0;background:hsla(0,0%,100%,.2);border:5px dashed #aaa;z-index:200;font-size:2em;text-align:center;color:#aaa}div.sceditor-dnd-cover p{position:relative;top:45%;pointer-events:none}div.sceditor-resize-cover{position:absolute;top:0;left:0;background:#000;width:100%;height:100%;z-index:10;opacity:.3}div.sceditor-grip{overflow:hidden;width:10px;height:10px;cursor:pointer;position:absolute;bottom:0;right:0;z-index:3;line-height:0}div.sceditor-grip.has-icon{background-image:none}.sceditor-maximize{position:fixed;top:0;left:0;height:100%!important;width:100%!important;border-radius:0;background-clip:padding-box;z-index:2000}body.sceditor-maximize,html.sceditor-maximize{height:100%;width:100%;padding:0;margin:0;overflow:hidden}.sceditor-maximize div.sceditor-grip{display:none}.sceditor-maximize div.sceditor-toolbar{border-radius:0;background-clip:padding-box}div.sceditor-dropdown{position:absolute;border:1px solid #ccc;background:#fff;z-index:4000;padding:10px;font-weight:400;font-size:15px;border-radius:2px;background-clip:padding-box;-webkit-box-shadow:1px 2px 4px rgba(0,0,0,.2);box-shadow:1px 2px 4px rgba(0,0,0,.2)}div.sceditor-dropdown *,div.sceditor-dropdown :after,div.sceditor-dropdown :before{-webkit-box-sizing:border-box;box-sizing:border-box}div.sceditor-dropdown a,div.sceditor-dropdown a:link{color:#333}div.sceditor-dropdown form{margin:0}div.sceditor-dropdown label{display:block;font-weight:700;color:#3c3c3c;padding:4px 0}div.sceditor-dropdown input,div.sceditor-dropdown textarea{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;outline:0;padding:4px;border:1px solid #ccc;border-top-color:#888;margin:0 0 .75em;border-radius:1px;background-clip:padding-box}div.sceditor-dropdown textarea{padding:6px}div.sceditor-dropdown input:focus,div.sceditor-dropdown textarea:focus{border-color:#666 #aaa #aaa;-webkit-box-shadow:inset 0 1px 5px rgba(0,0,0,.1);box-shadow:inset 0 1px 5px rgba(0,0,0,.1)}div.sceditor-dropdown .button{font-weight:700;color:#444;padding:6px 12px;background:#ececec;border:1px solid #ccc;border-radius:2px;background-clip:padding-box;cursor:pointer;margin:.3em 0 0}div.sceditor-dropdown .button:hover{background:#f3f3f3;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.15);box-shadow:0 1px 1px rgba(0,0,0,.15)}div.sceditor-font-picker,div.sceditor-fontsize-picker,div.sceditor-format{padding:6px 0}div.sceditor-color-picker{padding:4px}div.sceditor-emoticons,div.sceditor-more-emoticons{padding:0}.sceditor-pastetext textarea{border:1px solid #bbb;width:20em}.sceditor-emoticons img,.sceditor-more-emoticons img{padding:0;cursor:pointer;margin:2px}.sceditor-more{border-top:1px solid #bbb;display:block;text-align:center;cursor:pointer;font-weight:700;padding:6px 0}.sceditor-dropdown a:hover{background:#eee}.sceditor-font-option,.sceditor-fontsize-option,.sceditor-format a{display:block;padding:7px 10px;cursor:pointer;text-decoration:none;color:#222}.sceditor-fontsize-option{padding:7px 13px}.sceditor-color-column{float:left}.sceditor-color-option{display:block;border:2px solid #fff;height:18px;width:18px;overflow:hidden}.sceditor-color-option:hover{border:1px solid #aaa}div.sceditor-toolbar{-ms-flex-negative:0;flex-shrink:0;overflow:hidden;padding:3px 5px 2px;background:#f7f7f7;border-bottom:1px solid silver;line-height:0;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-radius:3px 3px 0 0;background-clip:padding-box}div.sceditor-group{display:inline-block;background:#ddd;margin:1px 5px 1px 0;padding:1px;border-bottom:1px solid #aaa;border-radius:3px;background-clip:padding-box}.sceditor-button{float:left;cursor:pointer;padding:3px 5px;width:16px;height:20px;border-radius:3px}.sceditor-button.active,.sceditor-button:active,.sceditor-button:hover{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2)}.sceditor-button:active{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3)}.sceditor-button.disabled:hover{background:inherit;cursor:default;-webkit-box-shadow:none;box-shadow:none}.sceditor-button,.sceditor-button div{display:block}.sceditor-button svg{display:inline-block;height:16px;width:16px;margin:2px 0;fill:#111;text-decoration:none;pointer-events:none;line-height:1}.sceditor-button.disabled svg{fill:#888}.sceditor-button div{display:inline-block;margin:2px 0;padding:0;overflow:hidden;line-height:0;font-size:0;color:rgba(0,0,0,0)}.sceditor-button.has-icon div{display:none}.sceditor-button.disabled div{opacity:.3}.sceditor-button.text,.sceditor-button.text-icon,.sceditor-button.text-icon div,.sceditor-button.text div,.text-icon .sceditor-button,.text-icon .sceditor-button div,.text .sceditor-button,.text .sceditor-button div{display:inline-block;width:auto;line-height:16px;font-size:1em;color:inherit;text-indent:0}.sceditor-button.has-icon div,.sceditor-button.text div,.text-icon .sceditor-button.has-icon div,.text .sceditor-button div{padding:0 2px;background:none}.sceditor-button.text svg,.text .sceditor-button svg{display:none}.sceditor-button.text-icon div,.text-icon .sceditor-button div{padding:0 2px 0 20px}.rtl div.sceditor-toolbar{text-align:right}.rtl .sceditor-button{float:right}.rtl div.sceditor-grip{right:auto;left:0}.sceditor-container{border:1px solid #8db2e3}.sceditor-container textarea{font-family:Consolas,Bitstream Vera Sans Mono,Andale Mono,Monaco,DejaVu Sans Mono,Lucida Console,monospace}div.sceditor-toolbar{border-bottom:1px solid #95a9c3;background:#dee8f5;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #dee8f5),color-stop(29%, #c7d8ed),color-stop(61%, #ccdcee),to(#c0d8ef));background:-o-linear-gradient(top,#dee8f5 0,#c7d8ed 29%,#ccdcee 61%,#c0d8ef);background:linear-gradient(180deg,#dee8f5 0,#c7d8ed 29%,#ccdcee 61%,#c0d8ef)}div.sceditor-group{border:1px solid #7596bf;background:rgba(0,0,0,0);padding:0;background:#cadcf0;background:-webkit-gradient(linear,left top, left bottom,color-stop(24%, #cadcf0),color-stop(38%, #bcd0e9),color-stop(99%, #d0e1f7));background:-o-linear-gradient(top,#cadcf0 24%,#bcd0e9 38%,#d0e1f7 99%);background:linear-gradient(180deg,#cadcf0 24%,#bcd0e9 38%,#d0e1f7 99%)}.sceditor-button{height:16px;padding:3px 4px;border-radius:0;background-clip:padding-box;-webkit-box-shadow:inset 0 1px #d5e3f1,inset 0 -1px #e3edfb,inset 1px 0 #cddcef,inset -1px 0 #b8ceea;box-shadow:inset 0 1px #d5e3f1,inset 0 -1px #e3edfb,inset 1px 0 #cddcef,inset -1px 0 #b8ceea}.sceditor-button:first-child{border-radius:4px 0 0 4px;background-clip:padding-box}.sceditor-button:last-child{border-radius:0 4px 4px 0;background-clip:padding-box}.sceditor-button div,.sceditor-button svg{margin:0}.sceditor-button.active{background:#fbdbb5;background:-webkit-gradient(linear,left top, left bottom,color-stop(11%, #fbdbb5),color-stop(29%, #feb456),color-stop(99%, #fdeb9f));background:-o-linear-gradient(top,#fbdbb5 11%,#feb456 29%,#fdeb9f 99%);background:linear-gradient(180deg,#fbdbb5 11%,#feb456 29%,#fdeb9f 99%);-webkit-box-shadow:inset 0 1px #ebd1b4,inset 0 -1px #ffe47f,inset -1px 0 #b8ceea;box-shadow:inset 0 1px #ebd1b4,inset 0 -1px #ffe47f,inset -1px 0 #b8ceea}.sceditor-button:hover{background:#fef7d5;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #fef7d5),color-stop(42%, #fae5a9),color-stop(0, #ffd048),to(#ffe59f));background:-o-linear-gradient(top,#fef7d5 0,#fae5a9 42%,#ffd048 0,#ffe59f);background:linear-gradient(180deg,#fef7d5 0,#fae5a9 42%,#ffd048 0,#ffe59f);-webkit-box-shadow:inset 0 1px #fffbe8,inset -1px 0 #ffefc4,inset 0 -1px #fff9cc;box-shadow:inset 0 1px #fffbe8,inset -1px 0 #ffefc4,inset 0 -1px #fff9cc}.sceditor-button:active{background:#e7a66d;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #e7a66d),color-stop(1%, #fcb16d),color-stop(42%, #ff8d05),to(#ffc450));background:-o-linear-gradient(top,#e7a66d 0,#fcb16d 1%,#ff8d05 42%,#ffc450);background:linear-gradient(180deg,#e7a66d 0,#fcb16d 1%,#ff8d05 42%,#ffc450);-webkit-box-shadow:inset 0 1px 1px #7b6645,inset 0 -1px #d19c33;box-shadow:inset 0 1px 1px #7b6645,inset 0 -1px #d19c33}.sceditor-button.active:hover{background:#dba368;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #dba368),color-stop(4%, #ffbd79),color-stop(34%, #fea335),color-stop(66%, #ffc64c),to(#fee069));background:-o-linear-gradient(top,#dba368 0,#ffbd79 4%,#fea335 34%,#ffc64c 66%,#fee069);background:linear-gradient(180deg,#dba368 0,#ffbd79 4%,#fea335 34%,#ffc64c 66%,#fee069);-webkit-box-shadow:inset 0 1px 1px #9e8255,inset 0 -1px #fcce6b;box-shadow:inset 0 1px 1px #9e8255,inset 0 -1px #fcce6b} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/themes/office.min.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1 @@ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */.sceditor-button div,div.sceditor-grip{background-image:url(famfamfam.png);background-repeat:no-repeat;width:16px;height:16px}.sceditor-button-youtube div{background-position:0 0}.sceditor-button-link div{background-position:0 -16px}.sceditor-button-unlink div{background-position:0 -32px}.sceditor-button-underline div{background-position:0 -48px}.sceditor-button-time div{background-position:0 -64px}.sceditor-button-table div{background-position:0 -80px}.sceditor-button-superscript div{background-position:0 -96px}.sceditor-button-subscript div{background-position:0 -112px}.sceditor-button-strike div{background-position:0 -128px}.sceditor-button-source div{background-position:0 -144px}.sceditor-button-size div{background-position:0 -160px}.sceditor-button-rtl div{background-position:0 -176px}.sceditor-button-right div{background-position:0 -192px}.sceditor-button-removeformat div{background-position:0 -208px}.sceditor-button-quote div{background-position:0 -224px}.sceditor-button-print div{background-position:0 -240px}.sceditor-button-pastetext div{background-position:0 -256px}.sceditor-button-paste div{background-position:0 -272px}.sceditor-button-outdent div{background-position:0 -288px}.sceditor-button-orderedlist div{background-position:0 -304px}.sceditor-button-maximize div{background-position:0 -320px}.sceditor-button-ltr div{background-position:0 -336px}.sceditor-button-left div{background-position:0 -352px}.sceditor-button-justify div{background-position:0 -368px}.sceditor-button-italic div{background-position:0 -384px}.sceditor-button-indent div{background-position:0 -400px}.sceditor-button-image div{background-position:0 -416px}.sceditor-button-horizontalrule div{background-position:0 -432px}.sceditor-button-format div{background-position:0 -448px}.sceditor-button-font div{background-position:0 -464px}.sceditor-button-emoticon div{background-position:0 -480px}.sceditor-button-email div{background-position:0 -496px}.sceditor-button-date div{background-position:0 -512px}.sceditor-button-cut div{background-position:0 -528px}.sceditor-button-copy div{background-position:0 -544px}.sceditor-button-color div{background-position:0 -560px}.sceditor-button-code div{background-position:0 -576px}.sceditor-button-center div{background-position:0 -592px}.sceditor-button-bulletlist div{background-position:0 -608px}.sceditor-button-bold div{background-position:0 -624px}div.sceditor-grip{background-position:0 -640px}.rtl div.sceditor-grip{background-position:0 -650px}.sceditor-container{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:column;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;position:relative;background:#fff;border:1px solid #d9d9d9;font-size:13px;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;color:#333;line-height:1;font-weight:700;height:250px;border-radius:4px;background-clip:padding-box}.sceditor-container *,.sceditor-container :after,.sceditor-container :before{-webkit-box-sizing:content-box;box-sizing:content-box}.sceditor-container,.sceditor-container div,div.sceditor-dropdown,div.sceditor-dropdown div{padding:0;margin:0;z-index:3}.sceditor-container iframe,.sceditor-container textarea{display:block;-ms-flex:1 1 0%;-webkit-box-flex:1;flex:1 1 0%;line-height:1.25;border:0;outline:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;color:#111;padding:0;margin:5px;resize:none;height:auto!important;width:auto!important;width:calc(100% - 10px)!important;min-height:1px}.sceditor-container textarea{margin:7px 5px}div.sceditor-dnd-cover{position:absolute;top:0;left:0;bottom:0;right:0;background:hsla(0,0%,100%,.2);border:5px dashed #aaa;z-index:200;font-size:2em;text-align:center;color:#aaa}div.sceditor-dnd-cover p{position:relative;top:45%;pointer-events:none}div.sceditor-resize-cover{position:absolute;top:0;left:0;background:#000;width:100%;height:100%;z-index:10;opacity:.3}div.sceditor-grip{overflow:hidden;width:10px;height:10px;cursor:pointer;position:absolute;bottom:0;right:0;z-index:3;line-height:0}div.sceditor-grip.has-icon{background-image:none}.sceditor-maximize{position:fixed;top:0;left:0;height:100%!important;width:100%!important;border-radius:0;background-clip:padding-box;z-index:2000}body.sceditor-maximize,html.sceditor-maximize{height:100%;width:100%;padding:0;margin:0;overflow:hidden}.sceditor-maximize div.sceditor-grip{display:none}.sceditor-maximize div.sceditor-toolbar{border-radius:0;background-clip:padding-box}div.sceditor-dropdown{position:absolute;border:1px solid #ccc;background:#fff;z-index:4000;padding:10px;font-weight:400;font-size:15px;border-radius:2px;background-clip:padding-box;-webkit-box-shadow:1px 2px 4px rgba(0,0,0,.2);box-shadow:1px 2px 4px rgba(0,0,0,.2)}div.sceditor-dropdown *,div.sceditor-dropdown :after,div.sceditor-dropdown :before{-webkit-box-sizing:border-box;box-sizing:border-box}div.sceditor-dropdown a,div.sceditor-dropdown a:link{color:#333}div.sceditor-dropdown form{margin:0}div.sceditor-dropdown label{display:block;font-weight:700;color:#3c3c3c;padding:4px 0}div.sceditor-dropdown input,div.sceditor-dropdown textarea{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;outline:0;padding:4px;border:1px solid #ccc;border-top-color:#888;margin:0 0 .75em;border-radius:1px;background-clip:padding-box}div.sceditor-dropdown textarea{padding:6px}div.sceditor-dropdown input:focus,div.sceditor-dropdown textarea:focus{border-color:#666 #aaa #aaa;-webkit-box-shadow:inset 0 1px 5px rgba(0,0,0,.1);box-shadow:inset 0 1px 5px rgba(0,0,0,.1)}div.sceditor-dropdown .button{font-weight:700;color:#444;padding:6px 12px;background:#ececec;border:1px solid #ccc;border-radius:2px;background-clip:padding-box;cursor:pointer;margin:.3em 0 0}div.sceditor-dropdown .button:hover{background:#f3f3f3;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.15);box-shadow:0 1px 1px rgba(0,0,0,.15)}div.sceditor-font-picker,div.sceditor-fontsize-picker,div.sceditor-format{padding:6px 0}div.sceditor-color-picker{padding:4px}div.sceditor-emoticons,div.sceditor-more-emoticons{padding:0}.sceditor-pastetext textarea{border:1px solid #bbb;width:20em}.sceditor-emoticons img,.sceditor-more-emoticons img{padding:0;cursor:pointer;margin:2px}.sceditor-more{border-top:1px solid #bbb;display:block;text-align:center;cursor:pointer;font-weight:700;padding:6px 0}.sceditor-dropdown a:hover{background:#eee}.sceditor-font-option,.sceditor-fontsize-option,.sceditor-format a{display:block;padding:7px 10px;cursor:pointer;text-decoration:none;color:#222}.sceditor-fontsize-option{padding:7px 13px}.sceditor-color-column{float:left}.sceditor-color-option{display:block;border:2px solid #fff;height:18px;width:18px;overflow:hidden}.sceditor-color-option:hover{border:1px solid #aaa}div.sceditor-toolbar{-ms-flex-negative:0;flex-shrink:0;overflow:hidden;padding:3px 5px 2px;background:#f7f7f7;border-bottom:1px solid silver;line-height:0;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-radius:3px 3px 0 0;background-clip:padding-box}div.sceditor-group{display:inline-block;background:#ddd;margin:1px 5px 1px 0;padding:1px;border-bottom:1px solid #aaa;border-radius:3px;background-clip:padding-box}.sceditor-button{float:left;cursor:pointer;padding:3px 5px;width:16px;height:20px;border-radius:3px}.sceditor-button.active,.sceditor-button:active,.sceditor-button:hover{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2)}.sceditor-button:active{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3)}.sceditor-button.disabled:hover{background:inherit;cursor:default;-webkit-box-shadow:none;box-shadow:none}.sceditor-button,.sceditor-button div{display:block}.sceditor-button svg{display:inline-block;height:16px;width:16px;margin:2px 0;fill:#111;text-decoration:none;pointer-events:none;line-height:1}.sceditor-button.disabled svg{fill:#888}.sceditor-button div{display:inline-block;margin:2px 0;padding:0;overflow:hidden;line-height:0;font-size:0;color:rgba(0,0,0,0)}.sceditor-button.has-icon div{display:none}.sceditor-button.disabled div{opacity:.3}.sceditor-button.text,.sceditor-button.text-icon,.sceditor-button.text-icon div,.sceditor-button.text div,.text-icon .sceditor-button,.text-icon .sceditor-button div,.text .sceditor-button,.text .sceditor-button div{display:inline-block;width:auto;line-height:16px;font-size:1em;color:inherit;text-indent:0}.sceditor-button.has-icon div,.sceditor-button.text div,.text-icon .sceditor-button.has-icon div,.text .sceditor-button div{padding:0 2px;background:none}.sceditor-button.text svg,.text .sceditor-button svg{display:none}.sceditor-button.text-icon div,.text-icon .sceditor-button div{padding:0 2px 0 20px}.rtl div.sceditor-toolbar{text-align:right}.rtl .sceditor-button{float:right}.rtl div.sceditor-grip{right:auto;left:0}.sceditor-container{border:1px solid #8db2e3}.sceditor-container textarea{font-family:Consolas,Bitstream Vera Sans Mono,Andale Mono,Monaco,DejaVu Sans Mono,Lucida Console,monospace}div.sceditor-toolbar{border-bottom:1px solid #95a9c3;background:#dee8f5;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #dee8f5),color-stop(29%, #c7d8ed),color-stop(61%, #ccdcee),to(#c0d8ef));background:-o-linear-gradient(top,#dee8f5 0,#c7d8ed 29%,#ccdcee 61%,#c0d8ef);background:linear-gradient(180deg,#dee8f5 0,#c7d8ed 29%,#ccdcee 61%,#c0d8ef)}div.sceditor-group{border:1px solid #7596bf;background:rgba(0,0,0,0);padding:0;background:#cadcf0;background:-webkit-gradient(linear,left top, left bottom,color-stop(24%, #cadcf0),color-stop(38%, #bcd0e9),color-stop(99%, #d0e1f7));background:-o-linear-gradient(top,#cadcf0 24%,#bcd0e9 38%,#d0e1f7 99%);background:linear-gradient(180deg,#cadcf0 24%,#bcd0e9 38%,#d0e1f7 99%)}.sceditor-button{height:16px;padding:3px 4px;border-radius:0;background-clip:padding-box;-webkit-box-shadow:inset 0 1px #d5e3f1,inset 0 -1px #e3edfb,inset 1px 0 #cddcef,inset -1px 0 #b8ceea;box-shadow:inset 0 1px #d5e3f1,inset 0 -1px #e3edfb,inset 1px 0 #cddcef,inset -1px 0 #b8ceea}.sceditor-button:first-child{border-radius:4px 0 0 4px;background-clip:padding-box}.sceditor-button:last-child{border-radius:0 4px 4px 0;background-clip:padding-box}.sceditor-button div,.sceditor-button svg{margin:0}.sceditor-button.active{background:#fbdbb5;background:-webkit-gradient(linear,left top, left bottom,color-stop(11%, #fbdbb5),color-stop(29%, #feb456),color-stop(99%, #fdeb9f));background:-o-linear-gradient(top,#fbdbb5 11%,#feb456 29%,#fdeb9f 99%);background:linear-gradient(180deg,#fbdbb5 11%,#feb456 29%,#fdeb9f 99%);-webkit-box-shadow:inset 0 1px #ebd1b4,inset 0 -1px #ffe47f,inset -1px 0 #b8ceea;box-shadow:inset 0 1px #ebd1b4,inset 0 -1px #ffe47f,inset -1px 0 #b8ceea}.sceditor-button:hover{background:#fef7d5;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #fef7d5),color-stop(42%, #fae5a9),color-stop(0, #ffd048),to(#ffe59f));background:-o-linear-gradient(top,#fef7d5 0,#fae5a9 42%,#ffd048 0,#ffe59f);background:linear-gradient(180deg,#fef7d5 0,#fae5a9 42%,#ffd048 0,#ffe59f);-webkit-box-shadow:inset 0 1px #fffbe8,inset -1px 0 #ffefc4,inset 0 -1px #fff9cc;box-shadow:inset 0 1px #fffbe8,inset -1px 0 #ffefc4,inset 0 -1px #fff9cc}.sceditor-button:active{background:#e7a66d;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #e7a66d),color-stop(1%, #fcb16d),color-stop(42%, #ff8d05),to(#ffc450));background:-o-linear-gradient(top,#e7a66d 0,#fcb16d 1%,#ff8d05 42%,#ffc450);background:linear-gradient(180deg,#e7a66d 0,#fcb16d 1%,#ff8d05 42%,#ffc450);-webkit-box-shadow:inset 0 1px 1px #7b6645,inset 0 -1px #d19c33;box-shadow:inset 0 1px 1px #7b6645,inset 0 -1px #d19c33}.sceditor-button.active:hover{background:#dba368;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #dba368),color-stop(4%, #ffbd79),color-stop(34%, #fea335),color-stop(66%, #ffc64c),to(#fee069));background:-o-linear-gradient(top,#dba368 0,#ffbd79 4%,#fea335 34%,#ffc64c 66%,#fee069);background:linear-gradient(180deg,#dba368 0,#ffbd79 4%,#fea335 34%,#ffc64c 66%,#fee069);-webkit-box-shadow:inset 0 1px 1px #9e8255,inset 0 -1px #fcce6b;box-shadow:inset 0 1px 1px #9e8255,inset 0 -1px #fcce6b}.sceditor-container{background:#a3c2ea;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #a3c2ea),color-stop(39%, #6d92c1),color-stop(64%, #577fb3),to(#6591cc));background:-o-linear-gradient(top,#a3c2ea 0,#6d92c1 39%,#577fb3 64%,#6591cc);background:linear-gradient(180deg,#a3c2ea 0,#6d92c1 39%,#577fb3 64%,#6591cc)}.sceditor-container iframe,.sceditor-container textarea{border:1px solid #646464;background:#fff;margin:7px 40px;padding:20px;width:calc(100% - 120px)!important;-webkit-box-shadow:1px 1px 5px #293a52;box-shadow:1px 1px 5px #293a52} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/minified/themes/square.min.css Thu Aug 04 15:21:29 2022 -0600 @@ -0,0 +1,1 @@ +/*! SCEditor | (C) 2011-2016, Sam Clarke | sceditor.com/license */.sceditor-button div,div.sceditor-grip{background-image:url(famfamfam.png);background-repeat:no-repeat;width:16px;height:16px}.sceditor-button-youtube div{background-position:0 0}.sceditor-button-link div{background-position:0 -16px}.sceditor-button-unlink div{background-position:0 -32px}.sceditor-button-underline div{background-position:0 -48px}.sceditor-button-time div{background-position:0 -64px}.sceditor-button-table div{background-position:0 -80px}.sceditor-button-superscript div{background-position:0 -96px}.sceditor-button-subscript div{background-position:0 -112px}.sceditor-button-strike div{background-position:0 -128px}.sceditor-button-source div{background-position:0 -144px}.sceditor-button-size div{background-position:0 -160px}.sceditor-button-rtl div{background-position:0 -176px}.sceditor-button-right div{background-position:0 -192px}.sceditor-button-removeformat div{background-position:0 -208px}.sceditor-button-quote div{background-position:0 -224px}.sceditor-button-print div{background-position:0 -240px}.sceditor-button-pastetext div{background-position:0 -256px}.sceditor-button-paste div{background-position:0 -272px}.sceditor-button-outdent div{background-position:0 -288px}.sceditor-button-orderedlist div{background-position:0 -304px}.sceditor-button-maximize div{background-position:0 -320px}.sceditor-button-ltr div{background-position:0 -336px}.sceditor-button-left div{background-position:0 -352px}.sceditor-button-justify div{background-position:0 -368px}.sceditor-button-italic div{background-position:0 -384px}.sceditor-button-indent div{background-position:0 -400px}.sceditor-button-image div{background-position:0 -416px}.sceditor-button-horizontalrule div{background-position:0 -432px}.sceditor-button-format div{background-position:0 -448px}.sceditor-button-font div{background-position:0 -464px}.sceditor-button-emoticon div{background-position:0 -480px}.sceditor-button-email div{background-position:0 -496px}.sceditor-button-date div{background-position:0 -512px}.sceditor-button-cut div{background-position:0 -528px}.sceditor-button-copy div{background-position:0 -544px}.sceditor-button-color div{background-position:0 -560px}.sceditor-button-code div{background-position:0 -576px}.sceditor-button-center div{background-position:0 -592px}.sceditor-button-bulletlist div{background-position:0 -608px}.sceditor-button-bold div{background-position:0 -624px}div.sceditor-grip{background-position:0 -640px}.rtl div.sceditor-grip{background-position:0 -650px}.sceditor-container{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:column;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;position:relative;background:#fff;border:1px solid #d9d9d9;font-size:13px;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;color:#333;line-height:1;font-weight:700;height:250px;border-radius:4px}.sceditor-container *,.sceditor-container :after,.sceditor-container :before{-webkit-box-sizing:content-box;box-sizing:content-box}.sceditor-container,.sceditor-container div,div.sceditor-dropdown,div.sceditor-dropdown div{padding:0;margin:0;z-index:3}.sceditor-container iframe,.sceditor-container textarea{display:block;-ms-flex:1 1 0%;-webkit-box-flex:1;flex:1 1 0%;line-height:1.25;border:0;outline:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:14px;color:#111;padding:0;margin:5px;resize:none;background:#fff;height:auto!important;width:auto!important;width:calc(100% - 10px)!important;min-height:1px}.sceditor-container textarea{margin:7px 5px}div.sceditor-dnd-cover{position:absolute;top:0;left:0;bottom:0;right:0;background:hsla(0,0%,100%,.2);border:5px dashed #aaa;z-index:200;font-size:2em;text-align:center;color:#aaa}div.sceditor-dnd-cover p{position:relative;top:45%;pointer-events:none}div.sceditor-resize-cover{position:absolute;top:0;left:0;background:#000;width:100%;height:100%;z-index:10;opacity:.3}div.sceditor-grip{overflow:hidden;width:10px;height:10px;cursor:pointer;position:absolute;bottom:0;right:0;z-index:3;line-height:0}div.sceditor-grip.has-icon{background-image:none}.sceditor-maximize{position:fixed;top:0;left:0;height:100%!important;width:100%!important;border-radius:0;background-clip:padding-box;z-index:2000}body.sceditor-maximize,html.sceditor-maximize{height:100%;width:100%;padding:0;margin:0;overflow:hidden}.sceditor-maximize div.sceditor-grip{display:none}.sceditor-maximize div.sceditor-toolbar{border-radius:0;background-clip:padding-box}div.sceditor-dropdown{position:absolute;border:1px solid #ccc;background:#fff;z-index:4000;padding:10px;font-weight:400;font-size:15px;border-radius:2px;background-clip:padding-box;-webkit-box-shadow:1px 2px 4px rgba(0,0,0,.2);box-shadow:1px 2px 4px rgba(0,0,0,.2)}div.sceditor-dropdown *,div.sceditor-dropdown :after,div.sceditor-dropdown :before{-webkit-box-sizing:border-box;box-sizing:border-box}div.sceditor-dropdown a,div.sceditor-dropdown a:link{color:#333}div.sceditor-dropdown form{margin:0}div.sceditor-dropdown label{display:block;font-weight:700;color:#3c3c3c;padding:4px 0}div.sceditor-dropdown input,div.sceditor-dropdown textarea{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;outline:0;padding:4px;border:1px solid #ccc;border-top-color:#888;margin:0 0 .75em;border-radius:1px;background-clip:padding-box}div.sceditor-dropdown textarea{padding:6px}div.sceditor-dropdown input:focus,div.sceditor-dropdown textarea:focus{border-color:#666 #aaa #aaa;-webkit-box-shadow:inset 0 1px 5px rgba(0,0,0,.1);box-shadow:inset 0 1px 5px rgba(0,0,0,.1)}div.sceditor-dropdown .button{font-weight:700;color:#444;padding:6px 12px;background:#ececec;border:1px solid #ccc;border-radius:2px;background-clip:padding-box;cursor:pointer;margin:.3em 0 0}div.sceditor-dropdown .button:hover{background:#f3f3f3;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.15);box-shadow:0 1px 1px rgba(0,0,0,.15)}div.sceditor-font-picker,div.sceditor-fontsize-picker,div.sceditor-format{padding:6px 0}div.sceditor-color-picker{padding:4px}div.sceditor-emoticons,div.sceditor-more-emoticons{padding:0}.sceditor-pastetext textarea{border:1px solid #bbb;width:20em}.sceditor-emoticons img,.sceditor-more-emoticons img{padding:0;cursor:pointer;margin:2px}.sceditor-more{border-top:1px solid #bbb;display:block;text-align:center;cursor:pointer;font-weight:700;padding:6px 0}.sceditor-dropdown a:hover{background:#eee}.sceditor-font-option,.sceditor-fontsize-option,.sceditor-format a{display:block;padding:7px 10px;cursor:pointer;text-decoration:none;color:#222}.sceditor-fontsize-option{padding:7px 13px}.sceditor-color-column{float:left}.sceditor-color-option{display:block;border:2px solid #fff;height:18px;width:18px;overflow:hidden}.sceditor-color-option:hover{border:1px solid #aaa}div.sceditor-toolbar{-ms-flex-negative:0;flex-shrink:0;overflow:hidden;padding:3px 5px 2px;background:#f7f7f7;border-bottom:1px solid silver;line-height:0;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border-radius:3px 3px 0 0;background-clip:padding-box}div.sceditor-group{display:inline-block;background:#ddd;margin:1px 5px 1px 0;padding:1px;border-bottom:1px solid #aaa;border-radius:3px}.sceditor-button{float:left;cursor:pointer;padding:3px 5px;width:16px;height:20px;border-radius:3px}.sceditor-button.active,.sceditor-button:active,.sceditor-button:hover{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2)}.sceditor-button:active{background:#fff;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3);box-shadow:inset 1px 1px 0 rgba(0,0,0,.3),inset -1px 0 rgba(0,0,0,.3),inset 0 -1px 0 rgba(0,0,0,.2),inset 0 0 8px rgba(0,0,0,.3)}.sceditor-button.disabled:hover{background:inherit;cursor:default;-webkit-box-shadow:none;box-shadow:none}.sceditor-button,.sceditor-button div{display:block}.sceditor-button svg{display:inline-block;height:16px;width:16px;margin:2px 0;fill:#111;text-decoration:none;pointer-events:none;line-height:1}.sceditor-button.disabled svg{fill:#888}.sceditor-button div{display:inline-block;margin:2px 0;padding:0;overflow:hidden;line-height:0;font-size:0;color:rgba(0,0,0,0)}.sceditor-button.has-icon div{display:none}.sceditor-button.disabled div{opacity:.3}.sceditor-button.text,.sceditor-button.text-icon,.sceditor-button.text-icon div,.sceditor-button.text div,.text-icon .sceditor-button,.text-icon .sceditor-button div,.text .sceditor-button,.text .sceditor-button div{display:inline-block;width:auto;line-height:16px;font-size:1em;color:inherit;text-indent:0}.sceditor-button.has-icon div,.sceditor-button.text div,.text-icon .sceditor-button.has-icon div,.text .sceditor-button div{padding:0 2px;background:none}.sceditor-button.text svg,.text .sceditor-button svg{display:none}.sceditor-button.text-icon div,.text-icon .sceditor-button div{padding:0 2px 0 20px}.rtl div.sceditor-toolbar{text-align:right}.rtl .sceditor-button{float:right}.rtl div.sceditor-grip{right:auto;left:0}.sceditor-container{border:1px solid #d6d6d6;border-radius:0;background-clip:padding-box}.sceditor-container textarea{font-family:Consolas,Bitstream Vera Sans Mono,Andale Mono,Monaco,DejaVu Sans Mono,Lucida Console,monospace;background:#2e3436;color:#fff;margin:0;padding:5px}div.sceditor-group,div.sceditor-toolbar{background:#f2f2f2;background:-webkit-gradient(linear,left top, left bottom,color-stop(0, #f2f2f2),color-stop(89%, #ddd));background:-o-linear-gradient(top,#f2f2f2 0,#ddd 89%);background:linear-gradient(180deg,#f2f2f2 0,#ddd 89%)}div.sceditor-toolbar{padding:0;border-bottom:1px solid #bbb;background-size:100% 32px}div.sceditor-group{margin:0;padding:2px 4px;border:0;border-right:1px solid #ccc;border-left:1px solid #eaeaea;border-radius:0;background-clip:padding-box}div.sceditor-group:last-child{border-right:0}div.sceditor-group:first-child{border-left:0}.sceditor-button{height:16px;padding:5px;margin:1px;border-radius:0;background-clip:padding-box}.sceditor-button div,.sceditor-button svg{margin:0}.sceditor-button.active,.sceditor-button.active:hover,.sceditor-button:active,.sceditor-button:hover{margin:0;-webkit-box-shadow:none;box-shadow:none}.sceditor-button.active{background:#f4f4f4;border:1px solid #ccc}.sceditor-button:hover{background:#fefefe;border:1px solid #ddd}.sceditor-button.disabled:hover{margin:1px;border:0}.sceditor-button:active{background:#eee;border:1px solid #ccc}.sceditor-button.active:hover{background:#f8f8f8;border:1px solid #ddd} \ No newline at end of file