sceditor
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -0,1 +1,43 @@ | ||
Version 3.1.0: | ||
Fixed issue with destroy() not correctly unbinding from form submit event. | ||
- Thanks to @BurninLeo for reporting and fixing | ||
Fixed issue with image width and height not always using base-10. | ||
- Thanks to @euantorano for reporting and fixing | ||
Fixed label for image drop-down having wrong ID for input. | ||
Fixed issue with pasting from Word sometimes pasting an image. | ||
Fixed issue with focus being lost after maximizing and switching between | ||
WYSIWYG and source modes. | ||
- Thanks to @live627 for reporting and fixing | ||
Added input event to events that can be bound to. | ||
Fixed issue with pasting copying browser and style sheet styles. | ||
- Thanks to @abetis and @paullaffitte for reporting | ||
Fixed autosave plugin losing caret position on page refresh. | ||
- Thanks to Lars for reporting | ||
Fixed issue some block elements like <details> being treated as inline elements. | ||
Fixed issues with fixNesting() where <hr> would split sometimes split | ||
quotes, <code> tags were sometimes split and <p> tags containing | ||
<blockquotes> were not fixed correctly. | ||
- Thanks to @timint and MyBB users for reporting. | ||
Fixed issue with content being lost when back button pressed or tab suspended. | ||
- Thanks to @johnaweiss for reporting and @ for fixing | ||
Updated XHTML format to convert div tags pasted into code blocks to spans to | ||
prevent them being split. | ||
Updated undo plugin to be much more reliable. | ||
- Thanks to @q2apro for reporting issues. | ||
Updated editor to set selection to end if focus() is called when there is no | ||
current selection. | ||
Added alternative lists BBCode plugin which adds phpBB format BBCode lists. | ||
- Thanks to @abetis for creating. | ||
Fixed bug with editor losing content when back button pressed. | ||
- Thanks to @johnaweiss for reporting and @jdarwood007 for initial fix. | ||
Fixed bug with Firefox alignment status not always being correct. | ||
- Thanks to @RezaRamezanpour for reporting. | ||
Added strict matching mode option which requires all attributes or styles | ||
to match. | ||
- Thanks to @live627 for implementing | ||
Updated YouTube plugin to strip unnecessary styles when converting a link | ||
to an embed. | ||
- Thanks to @Sesquipedalian for reporting | ||
Added support for matching styles like an attribute. | ||
Version 3.0.0: | ||
@@ -2,0 +44,0 @@ Fixes XSS issues by using dompurify. |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
!function(t){"use strict";var f=t.escapeEntities,o=t.escapeUriScheme,h=t.dom,e=t.utils,m=h.css,p=h.attr,g=h.is,n=e.extend,b=e.each,v="data-sceditor-emoticon",l=t.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(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]"]}},x={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(t,e){var n;return"[font="+E(n=!g(t,"font")||!(n=p(t,"face"))?m(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=p(t,"size"),r=2;return-1<(n=n||m(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:y.never,format:function(t,e){var n;return"[color="+s(n=!g(t,"font")||!(n=p(t,"color"))?t.style.color||m(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 p(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:y.never,format:function(e,t){var n="",r=function(t){return e.style?e.style[t]:null};return p(e,v)?t:(t=p(e,"width")||r("width"),r=p(e,"height")||r("height"),"[img"+(n=e.complete&&(t||r)||t&&r?"="+h.width(e)+"x"+h.height(e):n)+"]"+p(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:y.never,format:function(t,e){t=p(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:y.never,html:function(t,e,n){return'<a href="mailto:'+(f(e.defaultattr,!0)||n)+'">'+n+"</a>"}},quote:{tags:{blockquote:null},isInline:!1,quoteType:y.never,format:function(t,e){for(var n,r="data-author",i="",l=t.children,o=0;!n&&o<l.length;o++)g(l[o],"cite")&&(n=l[o]);return(n||p(t,r))&&(i=n&&n.textContent||p(t,r),p(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=p(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 k(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 w(t){return"function"==typeof t}function E(t){return t&&t.replace(/\\(.)/g,"$1").replace(/^(["'])(.*?)\1$/,"$2")}function B(t){var n=arguments;return t.replace(/\{(\d+)\}/g,function(t,e){return void 0!==n[+e+1]?n[+e+1]:"{"+e+"}"})}var C="open",I="content",T="newline",S="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 L(t){var m=this;function o(t,e){var n,r,i;return t===C&&(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=E(t.substr(1));else for("="===t.charAt(0)&&(t="defaultattr"+t);e=n.exec(t);)r[l(e[1])]=E(e[3])||e[4];return r}(n[2]))),t===S&&(n=e.match(/\[\/([^\[\]]+)\]/))&&(i=l(n[1])),(i=t===T?"#newline":i)&&(t!==C&&t!==S||x[i])||(t=I,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?x[t.name]:{}).allowedChildren;return!m.opts.fixInvalidChildren||!t||-1<t.indexOf(e.name||"#")}function p(t,e,n){var r=/\s|=/.test(t);return w(e)?e(t,n):e===y.never||e===y.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({},L.defaults,t),m.tokenize=function(t){var e,n,r,i=[],l=[{type:I,regex:/^([^\[\r\n]+|\[)/},{type:T,regex:/^(\r\n|\r|\n)/},{type:C,regex:/^\[[^\[\]]+\]/},{type:S,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(I,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=x[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===S&&e()&&i.name===e().name||(i.name="#",i.type=I),i.type){case C:r(i.name)&&f.pop(),n(i),(l=x[i.name])&&!l.isSelfClosing&&(l.closedBy||d(i.name,S,t))?f.push(i):l&&l.isSelfClosing||(i.type=I);break;case S: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,C,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===T&&(l=x[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=I,n(i);break;case T:e()&&s&&r((s.type===S?"/":"")+s.name)&&(s.type===S&&s.name===e().name||((l=x[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=x[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===C){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===T&&(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=x[n.name]);var h=d;for(;h--;)(i=e[h])&&(i.type===T?(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===C&&(s=x[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===C&&(s=x[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===C&&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===C||n===S)return!1;if(n===I&&/\S|\u00A0/.test(t[e].val))return!1}return!0};var l=e.length;for(;l--;)(n=e[l])&&n.type===C&&(r=x[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===C)u=r.children[r.children.length-1]||{},i=x[r.name],o=n&&s(i),l=t(r.children,!1),l=i&&i.html?(s(i)||!s(x[u.name])||i.isPreFormatted||i.skipLastLineBreak||(l+="<br />"),w(i.html)?i.html.call(m,r,r.attrs,l):(r.attrs[0]=l,k(i.html,r.attrs))):r.val+l+(r.closing?r.closing.val:"");else{if(r.type===T){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=x[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||y.auto,i||n.type!==C)if(n.type===C){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=E;var o={},a={},c={ul:["li","ol","ul"],ol:["li","ol","ul"],table:["tr"],tr:["td","th"],code:["br","p","div"]};function f(n,r,t){var i,l,o=h.getStyle;return a[t=!!t]&&b(a[t],function(t,e){(i=o(n,t))&&o(n.parentNode,t)!==i&&b(e,function(t,e){(!e||-1<e.indexOf(i.toString()))&&(l=x[t].format,r=w(l)?l.call(s,n,r):B(l,r))})}),r}function d(n,r,t){var i,l,e=n.nodeName.toLowerCase();return t=!!t,o[e]&&o[e][t]&&b(o[e][t],function(t,e){e&&(i=!1,b(e,function(t,e){if(p(n,t)&&!(e&&e.indexOf(p(n,t))<0))return!(i=!0)}),!i)||(l=x[t].format,r=w(l)?l.call(s,n,r):B(l,r))}),r}function u(t){var u=function(t,a){var s="";return h.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=g(t,"img")&&p(t,v)?!0:o)||(i=a)),3!==n&&1!==n||(1===n?g(t,".sceditor-nlf")&&!l||("iframe"!==r&&(e=u(t,i)),o?("code"!==r&&(e=f(t,e),e=f(t,e=d(t,e),!0)),e=d(t,e,!0),s+=function(t,e){var n=t.nodeName.toLowerCase(),r=h.isInline;if(!r(t,!0)||"br"===n){for(var i,l,o=t.previousSibling;o&&1===o.nodeType&&!g(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&&!g(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 L(s.opts.parserOptions).toHTML(s.opts.bbcodeTrim?e.trim():e);return t||n?(t=e,i=document.createElement("div"),n=function(t,e){if(!h.hasStyling(t)){if(1!==t.childNodes.length||!g(t.firstChild,"br"))for(;r=t.firstChild;)i.insertBefore(r,t);!e||t!==(e=i.lastChild)&&g(e,"div")&&t.nextSibling===e&&i.insertBefore(document.createElement("br"),t),i.removeChild(t)}},m(i,"display","none"),i.innerHTML=t.replace(/<\/div>\n/g,"</div>"),(t=i.firstChild)&&g(t,"div")&&n(t,!0),(t=i.lastChild)&&g(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 L(s.opts.parserOptions);for(o.innerHTML=e,m(l,"visibility","hidden"),l.appendChild(o),n.body.appendChild(l),t&&(l.insertBefore(n.createTextNode("#"),l.firstChild),l.appendChild(n.createTextNode("#"))),r&&m(o,"whiteSpace",m(r,"whiteSpace")),i=o.getElementsByClassName("sceditor-ignore");i.length;)i[0].parentNode.removeChild(i[0]);return h.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,b(x,function(n){var r,t=x[n].tags,e=x[n].styles;t&&b(t,function(t,e){r=!1===x[n].isInline,o[t]=o[t]||{},o[t][r]=o[t][r]||{},o[t][r][n]=e}),e&&b(e,function(t,e){r=!1===x[n].isInline,a[r]=a[r]||{},a[r][t]=a[r][t]||{},a[r][t][n]=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}},L.QuoteType=y,L.defaults={breakBeforeBlock:!1,breakStartBlock:!1,breakEndBlock:!1,breakAfterBlock:!0,removeEmptyTags:!0,fixInvalidNesting:!0,fixInvalidChildren:!0,quoteType:y.auto},u.get=function(t){return x[t]||null},u.set=function(t,e){return t&&e&&((e=n(x[t]||{},e)).remove=function(){delete x[t]},x[t]=e),this},u.rename=function(t,e){return t in x&&(x[e]=x[t],delete x[t]),this},u.remove=function(t){return t in x&&delete x[t],this},u.formatBBCodeString=k,t.formats.bbcode=u,t.BBCodeParser=L}(sceditor); | ||
!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&&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); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (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,e=b.convertElement,r=t.extend,a=t.each,S=t.isEmptyObject,l=m.command.get,s={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 C(){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=C.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=C.allowedTags,d=t.firstChild,f=C.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=C.allowedAttribs)&&!S(c),f=(d=C.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&&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(C.converters||{})||a(C.converters,function(t,e){a(e.tags,function(t){n[t]||(n[t]=[]),n[t].push(e)})}),this.commands=r(!0,{},s,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(/[\r\n]/," ").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("")}},C.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(e(t,"span"),"fontSize","larger")}},{tags:{small:null},conv:function(t){w(e(t,"span"),"fontSize","smaller")}},{tags:{b:null},conv:function(t){e(t,"strong")}},{tags:{u:null},conv:function(t){w(e(t,"span"),"textDecoration","underline")}},{tags:{s:null,strike:null},conv:function(t){w(e(t,"span"),"textDecoration","line-through")}},{tags:{dir:null},conv:function(t){e(t,"ul")}},{tags:{center:null},conv:function(t){w(e(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){e(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")}}],C.allowedAttribs={},C.disallowedAttribs={},C.allowedTags=[],C.disallowedTags=[],C.allowedEmptyTags=[],m.formats.xhtml=C}(sceditor); | ||
!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); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (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)); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (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)); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
!function(e){"use strict";var t="sce-autodraft-"+location.pathname+location.search;function i(e){localStorage.removeItem(e||t)}e.plugins.autosave=function(){var a,e=this,o=t,r=864e5,n=function(e){localStorage.setItem(o,JSON.stringify(e))},s=function(){return JSON.parse(localStorage.getItem(o))};e.init=function(){var e=(a=this).opts&&a.opts.autosave||{};n=e.save||n,s=e.load||s,o=e.storageKey||o,r=e.expires||r,function(){for(var e=0;e<localStorage.length;e++){var t,a=localStorage.key(e);!/^sce\-autodraft\-/.test(a)||(t=JSON.parse(localStorage.getItem(o)))&&t.time<Date.now()-r&&i(a)}}()},e.signalReady=function(){for(var e=a.getContentAreaContainer();e;){if(/form/i.test(e.nodeName)){e.addEventListener("submit",i.bind(null,o),!0);break}e=e.parentNode}var t=s();t&&(a.sourceMode(t.sourceMode),a.val(t.value,!1),a.focus(),t.sourceMode?a.sourceEditorCaret(t.caret):a.getRangeHelper().restoreRange()),n({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:a.val(null,!1),time:Date.now()})},e.signalValuechangedEvent=function(e){n({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:e.detail.rawValue,time:Date.now()})}},e.plugins.autosave.clear=i}(sceditor); | ||
!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); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
!function(s,e){"use strict";var u=e.dom,a=/(^|\s)(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/watch\?v=)([^"&?\/ ]{11})(?:\&[\&_\?0-9a-z\#]+)?(\s|$)/i;e.plugins.autoyoutube=function(){this.signalPasteRaw=function(e){var t;u.closest(this.currentNode(),"code")||(e.html||e.text)&&(t=s.createElement("div"),e.html?t.innerHTML=e.html:t.textContent=e.text,function e(t){for(var o,n,i,r=t.firstChild;r;)3===r.nodeType?(o=r.nodeValue,i=r.parentNode,(n=o.match(a))&&(i.insertBefore(s.createTextNode(o.substr(0,n.index)+n[1]),r),i.insertBefore(u.parseHTML('<iframe width="560" height="315" frameborder="0" src="https://www.youtube-nocookie.com/embed/'+(i=n[2])+'" data-youtube-id="'+i+'" allowfullscreen></iframe>'),r),r.nodeValue=n[3]+o.substr(n.index+n[0].length))):u.is(r,"code")||e(r),r=r.nextSibling}(t),e.html=t.innerHTML)}}}(document,sceditor); | ||
!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); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (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); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (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); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
!function(t){"use strict";var i=t.utils.extend;t.plugins.plaintext=function(){var e=!0;this.init=function(){var t=this.commands,n=this.opts;n&&n.plaintext&&n.plaintext.addButton&&(e=n.plaintext.enabled,t.pastetext=i(t.pastetext||{},{state:function(){return e?1:0},exec:function(){e=!e}}))},this.signalPasteRaw=function(t){var n;e&&(t.html&&!t.text&&((n=document.createElement("div")).innerHTML=t.html,t.text=n.innerText),t.html=null)}}}(sceditor); | ||
!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); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
!function(){"use strict";sceditor.plugins.undo=function(){function r(e){l=!0,u=e.value,o.sourceMode(e.sourceMode),o.val(e.value,!1),o.focus(),e.sourceMode?o.sourceEditorCaret(e.caret):o.getRangeHelper().restoreRange(),l=!1}var o,u,e=this,a=0,n=50,c=[],s=[],l=!1;e.init=function(){n=(o=this).undoLimit||n,o.addShortcut("ctrl+z",e.undo),o.addShortcut("ctrl+shift+z",e.redo),o.addShortcut("ctrl+y",e.redo)},e.undo=function(){var e=s.pop(),t=o.val(null,!1);return(e=e&&!c.length&&t===e.value?s.pop():e)&&(c.length||c.push({caret:o.sourceEditorCaret(),sourceMode:o.sourceMode(),value:t}),c.push(e),r(e)),!1},e.redo=function(){var e=c.pop();return s.length||(s.push(e),e=c.pop()),e&&(s.push(e),r(e)),!1},e.signalReady=function(){var e=o.val(null,!1);u=e,s.push({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:e})},e.signalValuechangedEvent=function(e){var t=e.detail.rawValue;0<n&&s.length>n&&s.shift(),!l&&u&&u!==t&&(c.length=0,(a+=function(e,t){for(var r,o,u,a=e.length,n=t.length,c=Math.max(a,n),s=0;s<c&&e.charAt(s)===t.charAt(s);s++);for(o=a<n?n-a:0,u=n<a?a-n:0,r=c-1;0<=r&&e.charAt(r-o)===t.charAt(r-u);r--);return r-s+1}(u,t))<20||a<50&&!/\s$/g.test(e.rawValue)||(s.push({caret:o.sourceEditorCaret(),sourceMode:o.sourceMode(),value:t}),a=0,u=t))}}}(); | ||
!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()}}}}(); |
@@ -1,3 +0,3 @@ | ||
/* SCEditor v3.0.0 | (C) 2017, Sam Clarke | sceditor.com/license */ | ||
/* SCEditor v3.1.0 | (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); |
{ | ||
"name": "sceditor", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "A lightweight HTML and BBCode WYSIWYG editor.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://www.sceditor.com/", |
# [SCEditor](http://www.sceditor.com/) v3.0.0 | ||
[![Build Status](http://img.shields.io/travis/samclarke/SCEditor/master.svg?style=flat-square)](https://travis-ci.org/samclarke/SCEditor) | ||
[![Dependency Status](http://img.shields.io/gemnasium/samclarke/SCEditor.svg?style=flat-square)](https://gemnasium.com/samclarke/SCEditor) | ||
[![SemVer](http://img.shields.io/:semver-✓-brightgreen.svg?style=flat-square)](http://semver.org) | ||
[![License](http://img.shields.io/npm/l/sceditor.svg?style=flat-square)](https://github.com/samclarke/SCEditor/blob/master/LICENSE.md) | ||
[![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) | ||
@@ -8,0 +7,0 @@ A lightweight WYSIWYG BBCode and XHTML editor. |
@@ -2087,3 +2087,3 @@ /** | ||
* @name BBCodeParser.QuoteType | ||
* @since v1.4.0 | ||
* @since 1.4.0 | ||
*/ | ||
@@ -2155,3 +2155,17 @@ BBCodeParser.QuoteType = QuoteType; | ||
*/ | ||
quoteType: QuoteType.auto | ||
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 | ||
}; | ||
@@ -2228,8 +2242,2 @@ | ||
/** | ||
* Same as tagsToBBCodes but instead of HTML tags it's styles | ||
* @private | ||
*/ | ||
var stylesToBBCodes = {}; | ||
/** | ||
* Allowed children of specific HTML tags. Empty array if no | ||
@@ -2248,3 +2256,3 @@ * children other than text nodes are allowed | ||
/** | ||
* Populates tagsToBBCodes and stylesToBBCodes to enable faster lookups | ||
* Populates tagsToBBCodes and stylesToBBCodes for easier lookups | ||
* | ||
@@ -2254,33 +2262,30 @@ * @private | ||
function buildBbcodeCache() { | ||
each(bbcodeHandlers, function (bbcode) { | ||
var isBlock, | ||
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) { | ||
isBlock = bbcodeHandlers[bbcode].isInline === false; | ||
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; | ||
tagsToBBCodes[tag][isBlock][bbcode] = | ||
values && Object.entries(values); | ||
}); | ||
} | ||
if (styles) { | ||
each(styles, function (style, values) { | ||
isBlock = bbcodeHandlers[bbcode].isInline === false; | ||
stylesToBBCodes[isBlock] = | ||
stylesToBBCodes[isBlock] || {}; | ||
stylesToBBCodes[isBlock][style] = | ||
stylesToBBCodes[isBlock][style] || {}; | ||
stylesToBBCodes[isBlock][style][bbcode] = values; | ||
}); | ||
} | ||
}); | ||
@@ -2290,49 +2295,2 @@ }; | ||
/** | ||
* Checks if any bbcode styles match the elements styles | ||
* | ||
* @param {!HTMLElement} element | ||
* @param {string} content | ||
* @param {boolean} [blockLevel=false] | ||
* @return {string} Content with any matching | ||
* bbcode tags wrapped around it. | ||
* @private | ||
*/ | ||
function handleStyles(element, content, blockLevel) { | ||
var styleValue, format, | ||
getStyle = dom.getStyle; | ||
// convert blockLevel to boolean | ||
blockLevel = !!blockLevel; | ||
if (!stylesToBBCodes[blockLevel]) { | ||
return content; | ||
} | ||
each(stylesToBBCodes[blockLevel], function (property, bbcodes) { | ||
styleValue = getStyle(element, property); | ||
// 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 (!styleValue || | ||
getStyle(element.parentNode, property) === styleValue) { | ||
return; | ||
} | ||
each(bbcodes, function (bbcode, values) { | ||
if (!values || values.indexOf(styleValue.toString()) > -1) { | ||
format = bbcodeHandlers[bbcode].format; | ||
if (isFunction(format)) { | ||
content = format.call(base, element, content); | ||
} else { | ||
content = _formatString(format, content); | ||
} | ||
} | ||
}); | ||
}); | ||
return content; | ||
} | ||
/** | ||
* Handles adding newlines after block level elements | ||
@@ -2396,8 +2354,8 @@ * | ||
/** | ||
* Handles a HTML tag and finds any matching bbcodes | ||
* 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=false] If to convert block level tags | ||
* @return {string} Content with any matching bbcode tags | ||
* @param {boolean} blockLevel | ||
* @return {string} Content with any matching BBCode tags | ||
* wrapped around it. | ||
@@ -2407,39 +2365,54 @@ * @private | ||
function handleTags(element, content, blockLevel) { | ||
var convertBBCode, format, | ||
tag = element.nodeName.toLowerCase(); | ||
function isStyleMatch(style) { | ||
var property = style[0]; | ||
var values = style[1]; | ||
var val = dom.getStyle(element, property); | ||
var parent = element.parentNode; | ||
// convert blockLevel to boolean | ||
blockLevel = !!blockLevel; | ||
// 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; | ||
} | ||
if (tagsToBBCodes[tag] && tagsToBBCodes[tag][blockLevel]) { | ||
// loop all bbcodes for this tag | ||
each(tagsToBBCodes[tag][blockLevel], function ( | ||
bbcode, bbcodeAttribs) { | ||
// if the bbcode requires any attributes then check this has | ||
// all needed | ||
if (bbcodeAttribs) { | ||
convertBBCode = false; | ||
return !values || values.includes(val); | ||
} | ||
// loop all the bbcode attribs | ||
each(bbcodeAttribs, function (attrib, values) { | ||
// Skip if the element doesn't have the attibue or | ||
// the attribute doesn't match one of the require | ||
// values | ||
if (!attr(element, attrib) || (values && | ||
values.indexOf(attr(element, attrib)) < 0)) { | ||
return; | ||
} | ||
function createAttributeMatch(isStrict) { | ||
return function (attribute) { | ||
var name = attribute[0]; | ||
var value = attribute[1]; | ||
// break this loop as we have matched this bbcode | ||
convertBBCode = true; | ||
return false; | ||
}); | ||
if (name === 'style' && value) { | ||
return value[isStrict ? 'every' : 'some'](isStyleMatch); | ||
} else { | ||
var val = attr(element, name); | ||
if (!convertBBCode) { | ||
return; | ||
} | ||
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)) { | ||
@@ -2450,5 +2423,8 @@ content = format.call(base, element, content); | ||
} | ||
return false; | ||
}); | ||
} | ||
handleTag('*'); | ||
handleTag(element.nodeName.toLowerCase()); | ||
return content; | ||
@@ -2517,8 +2493,4 @@ } | ||
if (tag !== 'code') { | ||
// handle inline bbcodes | ||
curTag = handleStyles(node, curTag); | ||
curTag = handleTags(node, curTag); | ||
// handle blocklevel bbcodes | ||
curTag = handleStyles(node, curTag, true); | ||
// First parse inline codes | ||
curTag = handleTags(node, curTag, false); | ||
} | ||
@@ -2525,0 +2497,0 @@ |
@@ -259,2 +259,5 @@ /** | ||
/** | ||
* Replace spaces including newlines with a single | ||
* space except for non-breaking spaces | ||
* | ||
* @param {string} str | ||
@@ -265,6 +268,3 @@ * @return {string} | ||
function trim(str) { | ||
return str | ||
// New lines will be shown as spaces so just convert to spaces. | ||
.replace(/[\r\n]/, ' ') | ||
.replace(/[^\S|\u00A0]+/g, ' '); | ||
return str.replace(/[^\S\u00A0]+/g, ' '); | ||
}; | ||
@@ -784,3 +784,3 @@ | ||
if (filtersA) { | ||
extend(ret, filtersA); | ||
ret = extend({}, ret, filtersA); | ||
} | ||
@@ -1204,2 +1204,14 @@ | ||
} | ||
}, | ||
{ | ||
tags: { | ||
code: null | ||
}, | ||
conv: function (node) { | ||
var node, nodes = node.getElementsByTagName('div'); | ||
while ((node = nodes[0])) { | ||
node.style.display = 'block'; | ||
convertElement(node, 'span'); | ||
} | ||
} | ||
} | ||
@@ -1206,0 +1218,0 @@ ]; |
@@ -104,3 +104,5 @@ import * as dom from './dom.js'; | ||
return align === 'left' || align === (isLtr ? 'start' : 'end'); | ||
// Can be -moz-left | ||
return /left/.test(align) || | ||
align === (isLtr ? 'start' : 'end'); | ||
} | ||
@@ -129,3 +131,5 @@ }, | ||
return align === 'right' || align === (isLtr ? 'end' : 'start'); | ||
// Can be -moz-right | ||
return /right/.test(align) || | ||
align === (isLtr ? 'end' : 'start'); | ||
} | ||
@@ -495,7 +499,7 @@ }, | ||
if (width) { | ||
attrs += ' width="' + parseInt(width) + '"'; | ||
attrs += ' width="' + parseInt(width, 10) + '"'; | ||
} | ||
if (height) { | ||
attrs += ' height="' + parseInt(height) + '"'; | ||
attrs += ' height="' + parseInt(height, 10) + '"'; | ||
} | ||
@@ -751,3 +755,3 @@ | ||
var val = dom.find(content, '#link')[0].value; | ||
var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)(.{11})/); | ||
var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/); | ||
var timeMatch = val.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/); | ||
@@ -929,5 +933,7 @@ var time = 0; | ||
this.maximize(!this.maximize()); | ||
this.focus(); | ||
}, | ||
txtExec: function () { | ||
this.maximize(!this.maximize()); | ||
this.focus(); | ||
}, | ||
@@ -946,5 +952,7 @@ tooltip: 'Maximize', | ||
this.toggleSourceMode(); | ||
this.focus(); | ||
}, | ||
txtExec: function () { | ||
this.toggleSourceMode(); | ||
this.focus(); | ||
}, | ||
@@ -951,0 +959,0 @@ tooltip: 'View source', |
@@ -702,3 +702,5 @@ import * as utils from './utils.js'; | ||
export 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|'; | ||
'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|'; | ||
@@ -759,2 +761,3 @@ /** | ||
* @param {HTMLElement} to | ||
* @deprecated since v3.1.0 | ||
*/ | ||
@@ -768,2 +771,17 @@ export function copyCSS(from, to) { | ||
/** | ||
* Checks if a DOM node is empty | ||
* | ||
* @param {Node} node | ||
* @returns {boolean} | ||
*/ | ||
export 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. | ||
@@ -777,26 +795,40 @@ * | ||
export function fixNesting(node) { | ||
var getLastInlineParent = function (node) { | ||
while (isInline(node.parentNode, true)) { | ||
node = node.parentNode; | ||
} | ||
return node; | ||
}; | ||
traverse(node, function (node) { | ||
var list = 'ul,ol', | ||
isBlock = !isInline(node, true); | ||
isBlock = !isInline(node, true) && node.nodeType !== COMMENT_NODE, | ||
parent = node.parentNode; | ||
// Any blocklevel element inside an inline element needs fixing. | ||
if (isBlock && isInline(node.parentNode, true)) { | ||
var parent = getLastInlineParent(node), | ||
before = extractContents(parent, node), | ||
middle = node; | ||
// 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; | ||
} | ||
// copy current styling so when moved out of the parent | ||
// it still has the same styling | ||
copyCSS(parent, middle); | ||
var before = extractContents(lastInlineParent, node); | ||
var middle = node; | ||
insertBefore(before, parent); | ||
insertBefore(middle, parent); | ||
// 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); | ||
} | ||
} | ||
@@ -1027,1 +1059,155 @@ | ||
} | ||
/** | ||
* 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 | ||
*/ | ||
export 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); | ||
} | ||
} |
import * as dom from './dom.js'; | ||
import * as escape from './escape.js'; | ||
import * as utils from './utils.js'; | ||
@@ -201,5 +202,7 @@ | ||
base.insertNode = function (node, endNode) { | ||
var input = _prepareInput(node, endNode), | ||
var first, last, | ||
input = _prepareInput(node, endNode), | ||
range = base.selectedRange(), | ||
parent = range.commonAncestorContainer; | ||
parent = range.commonAncestorContainer, | ||
emptyNodes = []; | ||
@@ -210,2 +213,20 @@ if (!input) { | ||
function removeIfEmpty(node) { | ||
// Only remove empty node if it wasn't already empty | ||
if (node && dom.isEmpty(node) && emptyNodes.indexOf(node) < 0) { | ||
dom.remove(node); | ||
} | ||
} | ||
if (range.startContainer !== range.endContainer) { | ||
utils.each(parent.childNodes, function (_, node) { | ||
if (dom.isEmpty(node)) { | ||
emptyNodes.push(node); | ||
} | ||
}); | ||
first = input.firstChild; | ||
last = input.lastChild; | ||
} | ||
range.deleteContents(); | ||
@@ -221,2 +242,11 @@ | ||
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); | ||
} | ||
@@ -223,0 +253,0 @@ |
@@ -50,3 +50,3 @@ import * as dom from './dom.js'; | ||
image: | ||
'<div><label for="link">{url}</label> ' + | ||
'<div><label for="image">{url}</label> ' + | ||
'<input type="text" id="image" dir="ltr" placeholder="https://" /></div>' + | ||
@@ -53,0 +53,0 @@ '<div><label for="width">{width}</label> ' + |
@@ -60,2 +60,7 @@ /** | ||
function isObject(value) { | ||
return value !== null && typeof value === 'object' && | ||
Object.getPrototypeOf(value) === Object.prototype; | ||
} | ||
for (; i < arguments.length; i++) { | ||
@@ -67,21 +72,32 @@ var source = arguments[i]; | ||
for (var key in source) { | ||
var targetValue = target[key]; | ||
var value = source[key]; | ||
// Skip undefined values to match jQuery and | ||
// skip if target to prevent infinite loop | ||
if (!isUndefined(value)) { | ||
var isObject = value !== null && typeof value === 'object' && | ||
Object.getPrototypeOf(value) === Object.prototype; | ||
var isArray = Array.isArray(value); | ||
// Skip undefined values to match jQuery | ||
if (isUndefined(value)) { | ||
continue; | ||
} | ||
if (isDeep && (isObject || isArray)) { | ||
target[key] = extend( | ||
true, | ||
target[key] || (isArray ? [] : {}), | ||
value | ||
); | ||
} else { | ||
target[key] = value; | ||
} | ||
// 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; | ||
} | ||
} | ||
@@ -88,0 +104,0 @@ } |
@@ -24,2 +24,3 @@ /** | ||
var editor; | ||
var isLoading = false; | ||
var storageKey = defaultKey; | ||
@@ -76,2 +77,3 @@ // 86400000 = 24 hrs (24 * 60 * 60 * 1000) | ||
if (state) { | ||
isLoading = true; | ||
editor.sourceMode(state.sourceMode); | ||
@@ -86,19 +88,22 @@ editor.val(state.value, false); | ||
} | ||
isLoading = false; | ||
} else { | ||
saveHandler({ | ||
caret: this.sourceEditorCaret(), | ||
sourceMode: this.sourceMode(), | ||
value: editor.val(null, false), | ||
time: Date.now() | ||
}); | ||
} | ||
saveHandler({ | ||
caret: this.sourceEditorCaret(), | ||
sourceMode: this.sourceMode(), | ||
value: editor.val(null, false), | ||
time: Date.now() | ||
}); | ||
}; | ||
base.signalValuechangedEvent = function (e) { | ||
saveHandler({ | ||
caret: this.sourceEditorCaret(), | ||
sourceMode: this.sourceMode(), | ||
value: e.detail.rawValue, | ||
time: Date.now() | ||
}); | ||
if (!isLoading) { | ||
saveHandler({ | ||
caret: this.sourceEditorCaret(), | ||
sourceMode: this.sourceMode(), | ||
value: e.detail.rawValue, | ||
time: Date.now() | ||
}); | ||
} | ||
}; | ||
@@ -105,0 +110,0 @@ }; |
@@ -38,5 +38,21 @@ /** | ||
function convertYoutubeLinks(root) { | ||
var node = root.firstChild; | ||
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) { | ||
@@ -46,11 +62,10 @@ // 3 is TextNodes | ||
var text = node.nodeValue; | ||
var parent = node.parentNode; | ||
var match = text.match(ytUrlRegex); | ||
var nodeParent = node.parentNode; | ||
if (match) { | ||
parent.insertBefore(document.createTextNode( | ||
if ((match = text.match(ytUrlRegex))) { | ||
nodeParent.insertBefore(document.createTextNode( | ||
text.substr(0, match.index) + match[1] | ||
), node); | ||
parent.insertBefore( | ||
nodeParent.insertBefore( | ||
dom.parseHTML(youtubeEmbedCode(match[2])), node | ||
@@ -82,13 +97,10 @@ ); | ||
if (data.html || data.text) { | ||
var html = document.createElement('div'); | ||
var node = document.createElement('div'); | ||
if (data.html) { | ||
html.innerHTML = data.html; | ||
} else { | ||
html.textContent = data.text; | ||
} | ||
node.innerHTML = data.html || | ||
sceditor.escapeEntities(data.text); | ||
convertYoutubeLinks(html); | ||
convertYoutubeLinks(node, true); | ||
data.html = html.innerHTML; | ||
data.html = node.innerHTML; | ||
} | ||
@@ -95,0 +107,0 @@ }; |
@@ -15,3 +15,4 @@ /** | ||
var extend = sceditor.utils.extend; | ||
var utils = sceditor.utils; | ||
var dom = sceditor.dom; | ||
@@ -37,3 +38,3 @@ /** | ||
commands.pastetext = extend(commands.pastetext || {}, { | ||
commands.pastetext = utils.extend(commands.pastetext || {}, { | ||
state: function () { | ||
@@ -54,3 +55,21 @@ return plainTextEnabled ? 1 : 0; | ||
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); | ||
} | ||
@@ -57,0 +76,0 @@ |
@@ -6,72 +6,109 @@ (function (sceditor) { | ||
var base = this; | ||
var sourceEditor; | ||
var editor; | ||
var body; | ||
var lastInputType = ''; | ||
var charChangedCount = 0; | ||
var previousValue; | ||
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 redoStates = []; | ||
var undoStates = []; | ||
var ignoreNextValueChanged = false; | ||
var redoPosition = 0; | ||
var lastState; | ||
/** | ||
* Sets the editor to the specified state. | ||
* | ||
* @param {Object} state | ||
* @private | ||
*/ | ||
var applyState = function (state) { | ||
ignoreNextValueChanged = true; | ||
previousValue = state.value; | ||
function applyState(state) { | ||
isApplying = true; | ||
editor.sourceMode(state.sourceMode); | ||
editor.val(state.value, false); | ||
editor.focus(); | ||
if (state.sourceMode) { | ||
editor.val(state.value, false); | ||
editor.sourceEditorCaret(state.caret); | ||
} else { | ||
editor.getRangeHelper().restoreRange(); | ||
editor.getBody().innerHTML = state.value; | ||
var range = editor.getRangeHelper().selectedRange(); | ||
setRangePositions(range, state.caret); | ||
editor.getRangeHelper().selectRange(range); | ||
} | ||
ignoreNextValueChanged = false; | ||
editor.focus(); | ||
isApplying = false; | ||
}; | ||
/** | ||
* Calculates the number of characters that have changed | ||
* between two strings. | ||
* | ||
* @param {String} strA | ||
* @param {String} strB | ||
* @return {String} | ||
* @private | ||
* Patches a function on the object to call store() after invocation | ||
* @param {Object} obj | ||
* @param {string} fn | ||
*/ | ||
var simpleDiff = function (strA, strB) { | ||
var start, end, aLenDiff, bLenDiff, | ||
aLength = strA.length, | ||
bLength = strB.length, | ||
length = Math.max(aLength, bLength); | ||
function patch(obj, fn) { | ||
var origFn = obj[fn]; | ||
obj[fn] = function () { | ||
// sourceMode calls other patched methods so need to ignore them | ||
var ignore = isInPatchedFn; | ||
// Calculate the start | ||
for (start = 0; start < length; start++) { | ||
if (strA.charAt(start) !== strB.charAt(start)) { | ||
break; | ||
// Store caret position before any change is made | ||
if (!ignore && !isApplying && lastState && | ||
editor.getRangeHelper().hasSelection()) { | ||
updateLastState(); | ||
} | ||
} | ||
// Calculate the end | ||
aLenDiff = aLength < bLength ? bLength - aLength : 0; | ||
bLenDiff = bLength < aLength ? aLength - bLength : 0; | ||
isInPatchedFn = true; | ||
origFn.apply(this, arguments); | ||
for (end = length - 1; end >= 0; end--) { | ||
if (strA.charAt(end - aLenDiff) !== | ||
strB.charAt(end - bLenDiff)) { | ||
break; | ||
if (!ignore) { | ||
isInPatchedFn = false; | ||
if (!isApplying) { | ||
storeState(); | ||
lastInputType = ''; | ||
} | ||
} | ||
}; | ||
} | ||
/** | ||
* Stores the editors current state | ||
*/ | ||
function storeState() { | ||
if (redoPosition) { | ||
undoStates.length -= redoPosition; | ||
redoPosition = 0; | ||
} | ||
return (end - start) + 1; | ||
}; | ||
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 () { | ||
@@ -85,4 +122,2 @@ // The this variable will be set to the instance of the editor | ||
// addShortcut is the easiest way to add handlers to specific | ||
// shortcuts | ||
editor.addShortcut('ctrl+z', base.undo); | ||
@@ -93,37 +128,78 @@ editor.addShortcut('ctrl+shift+z', base.redo); | ||
base.undo = function () { | ||
var state = undoStates.pop(); | ||
var rawEditorValue = editor.val(null, false); | ||
if (state && !redoStates.length && rawEditorValue === state.value) { | ||
state = undoStates.pop(); | ||
function documentSelectionChangeHandler() { | ||
if (sourceEditor === document.activeElement) { | ||
base.signalSelectionchangedEvent(); | ||
} | ||
} | ||
if (state) { | ||
if (!redoStates.length) { | ||
redoStates.push({ | ||
'caret': editor.sourceEditorCaret(), | ||
'sourceMode': editor.sourceMode(), | ||
'value': rawEditorValue | ||
}); | ||
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(); | ||
} | ||
} | ||
redoStates.push(state); | ||
applyState(state); | ||
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); | ||
return false; | ||
// Chrome doesn't trigger selectionchange on textarea so need to | ||
// listen to global event | ||
document.addEventListener('selectionchange', | ||
documentSelectionChangeHandler); | ||
}; | ||
base.redo = function () { | ||
var state = redoStates.pop(); | ||
base.destroy = function () { | ||
document.removeEventListener('selectionchange', | ||
documentSelectionChangeHandler); | ||
}; | ||
if (!undoStates.length) { | ||
undoStates.push(state); | ||
state = redoStates.pop(); | ||
base.undo = function () { | ||
lastState = null; | ||
if (redoPosition < undoStates.length - 1) { | ||
redoPosition++; | ||
applyState(undoStates[undoStates.length - 1 - redoPosition]); | ||
} | ||
if (state) { | ||
undoStates.push(state); | ||
applyState(state); | ||
return false; | ||
}; | ||
base.redo = function () { | ||
if (redoPosition > 0) { | ||
redoPosition--; | ||
applyState(undoStates[undoStates.length - 1 - redoPosition]); | ||
} | ||
@@ -134,58 +210,157 @@ | ||
base.signalReady = function () { | ||
var rawValue = editor.val(null, 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 = ''; | ||
}; | ||
// Store the initial value as the last value | ||
previousValue = rawValue; | ||
/** | ||
* 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; | ||
undoStates.push({ | ||
'caret': this.sourceEditorCaret(), | ||
'sourceMode': this.sourceMode(), | ||
'value': rawValue | ||
}); | ||
// 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; | ||
} | ||
}; | ||
/** | ||
* Handle the valueChanged signal. | ||
* | ||
* e.rawValue will either be the raw HTML from the WYSIWYG editor with | ||
* the rangeHelper range markers inserted, or it will be the raw value | ||
* of the source editor (BBCode or HTML depending on plugins). | ||
* @return {void} | ||
* Creates a positions object form passed range | ||
* @param {Range} range | ||
* @return {Object<string, Array<number>} | ||
*/ | ||
base.signalValuechangedEvent = function (e) { | ||
var rawValue = e.detail.rawValue; | ||
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(); | ||
if (undoLimit > 0 && undoStates.length > undoLimit) { | ||
undoStates.shift(); | ||
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); | ||
} | ||
} | ||
} | ||
// If the editor hasn't fully loaded yet, | ||
// then the previous value won't be set. | ||
if (ignoreNextValueChanged || !previousValue || | ||
previousValue === rawValue) { | ||
return; | ||
/** | ||
* 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; | ||
} | ||
// Value has changed so remove all redo states | ||
redoStates.length = 0; | ||
charChangedCount += simpleDiff(previousValue, rawValue); | ||
return positions; | ||
} | ||
if (charChangedCount < 20) { | ||
return; | ||
// ?? | ||
} else if (charChangedCount < 50 && !/\s$/g.test(e.rawValue)) { | ||
return; | ||
/** | ||
* Returns index of passed node | ||
* @param {Node} node | ||
* @returns {number} | ||
*/ | ||
function nodeIndex(node) { | ||
var i = 0; | ||
while ((node = node.previousSibling)) { | ||
i++; | ||
} | ||
return i; | ||
} | ||
undoStates.push({ | ||
'caret': editor.sourceEditorCaret(), | ||
'sourceMode': editor.sourceMode(), | ||
'value': rawValue | ||
}); | ||
charChangedCount = 0; | ||
previousValue = rawValue; | ||
}; | ||
/** | ||
* 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)); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
976214
179
13683
139