12345 |
- /*
- Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
- For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- !function(){CKEDITOR.on("dialogDefinition",function(e){var t;t=e.data.name,e=e.data.definition,"link"==t?(e.removeContents("target"),e.removeContents("upload"),e.removeContents("advanced"),t=e.getContents("info"),t.remove("emailSubject"),t.remove("emailBody")):"image"==t&&(e.removeContents("advanced"),t=e.getContents("Link"),t.remove("cmbTarget"),t=e.getContents("info"),t.remove("txtAlt"),t.remove("basic"))});var e,t={b:"strong",u:"u",i:"em",s:"s",color:"span",size:"span",left:"div",right:"div",center:"div",justify:"div",quote:"blockquote",code:"code",url:"a",email:"span",img:"span","*":"li",list:"ol"},n={strong:"b",b:"b",u:"u",em:"i",i:"i",s:"s",code:"code",li:"*"},i={strong:"b",em:"i",u:"u",s:"s",li:"*",ul:"list",ol:"list",code:"code",a:"link",img:"img",blockquote:"quote"},r={color:"color",size:"font-size",left:"text-align",center:"text-align",right:"text-align",justify:"text-align"},s={url:"href",email:"mailhref",quote:"cite",list:"listType"},a=CKEDITOR.dtd,l=CKEDITOR.tools.extend({table:1},a.$block,a.$listItem,a.$tableContent,a.$list),o=/\s*(?:;\s*|$)/,u={smiley:":)",sad:":(",wink:";)",laugh:":D",cheeky:":P",blush:":*)",surprise:":-o",indecision:":|",angry:">:(",angel:"o:)",cool:"8-)",devil:">:-)",crying:";(",kiss:":-*"},c={},h=[];for(e in u)c[u[e]]=e,h.push(u[e].replace(/\(|\)|\:|\/|\*|\-|\|/g,function(e){return"\\"+e}));var h=new RegExp(h.join("|"),"g"),f=function(){var e,t=[],n={nbsp:" ",shy:""};for(e in n)t.push(e);return t=new RegExp("&("+t.join("|")+");","g"),function(e){return e.replace(t,function(e,t){return n[t]})}}();CKEDITOR.BBCodeParser=function(){this._={bbcPartsRegex:/(?:\[([^\/\]=]*?)(?:=([^\]]*?))?\])|(?:\[\/([a-z]{1,16})\])/gi}},CKEDITOR.BBCodeParser.prototype={parse:function(e){for(var n,i,a=0;n=this._.bbcPartsRegex.exec(e);)if(i=n.index,i>a&&(a=e.substring(a,i),this.onText(a,1)),a=this._.bbcPartsRegex.lastIndex,(i=(n[1]||n[3]||"").toLowerCase())&&!t[i])this.onText(n[0]);else if(n[1]){var l=t[i],u={},c={};if(n=n[2],("left"==i||"right"==i||"center"==i||"justify"==i)&&(n=i),n)if("list"==i&&(isNaN(n)?/^[a-z]+$/.test(n)?n="lower-alpha":/^[A-Z]+$/.test(n)&&(n="upper-alpha"):n="decimal"),r[i]){"size"==i&&(n+="%"),c[r[i]]=n,n=u;var h="",f=void 0;for(f in c)var d=(f+":"+c[f]).replace(o,";"),h=h+d;n.style=h}else s[i]&&(u[s[i]]=CKEDITOR.tools.htmlDecode(n));("email"==i||"img"==i)&&(u.bbcode=i),this.onTagOpen(l,u,CKEDITOR.dtd.$empty[l])}else n[3]&&this.onTagClose(t[i]);e.length>a&&this.onText(e.substring(a,e.length),1)}},CKEDITOR.htmlParser.fragment.fromBBCode=function(e){function t(e){if(0<u.length)for(var t=0;t<u.length;t++){var n=u[t],i=n.name,r=CKEDITOR.dtd[i],s=m.name&&CKEDITOR.dtd[m.name];s&&!s[i]||e&&r&&!r[e]&&CKEDITOR.dtd[e]||(n=n.clone(),n.parent=m,m=n,u.splice(t,1),t--)}}function n(e,t){var n=m.children.length,r=n>0&&m.children[n-1],n=!r&&d.getRule(i[m.name],"breakAfterOpen"),r=r&&r.type==CKEDITOR.NODE_ELEMENT&&d.getRule(i[r.name],"breakAfterClose"),s=e&&d.getRule(i[e],t?"breakBeforeClose":"breakBeforeOpen");f&&(n||r||s)&&f--,f&&e in l&&f++;for(;f&&f--;)m.children.push(new CKEDITOR.htmlParser.element("br"))}function r(e,t){n(e.name,1),t=t||m||o;var i=t.children.length;e.previous=i>0&&t.children[i-1]||null,e.parent=t,t.children.push(e),e.returnPoint&&(m=e.returnPoint,delete e.returnPoint)}var s,a=new CKEDITOR.BBCodeParser,o=new CKEDITOR.htmlParser.fragment,u=[],f=0,m=o;a.onTagOpen=function(e,i){var l=new CKEDITOR.htmlParser.element(e,i);if(CKEDITOR.dtd.$removeEmpty[e])u.push(l);else{var o=m.name,c=o&&(CKEDITOR.dtd[o]||(m._.isBlockLike?CKEDITOR.dtd.div:CKEDITOR.dtd.span));if(c&&!c[e]){var h,c=!1;if(e==o?r(m,m.parent):(e in CKEDITOR.dtd.$listItem?(a.onTagOpen("ul",{}),h=m):(r(m,m.parent),u.unshift(m)),c=!0),m=h?h:m.returnPoint||m.parent,c)return void a.onTagOpen.apply(this,arguments)}t(e),n(e),l.parent=m,l.returnPoint=s,s=0,l.isEmpty?r(l):m=l}},a.onTagClose=function(e){for(var t=u.length-1;t>=0;t--)if(e==u[t].name)return void u.splice(t,1);for(var n=[],i=[],s=m;s.type&&s.name!=e;)s._.isBlockLike||i.unshift(s),n.push(s),s=s.parent;if(s.type){for(t=0;t<n.length;t++)e=n[t],r(e,e.parent);m=s,r(s,s.parent),s==m&&(m=m.parent),u=u.concat(i)}},a.onText=function(e){var i=CKEDITOR.dtd[m.name];(!i||i["#"])&&(n(),t(),e.replace(/(\r\n|[\r\n])|[^\r\n]*/g,function(e,t){if(void 0!==t&&t.length)f++;else if(e.length){var n=0;e.replace(h,function(t,i){r(new CKEDITOR.htmlParser.text(e.substring(n,i)),m),r(new CKEDITOR.htmlParser.element("smiley",{desc:c[t]}),m),n=i+t.length}),n!=e.length&&r(new CKEDITOR.htmlParser.text(e.substring(n,e.length)),m)}}))};for(a.parse(CKEDITOR.tools.htmlEncode(e));m.type!=CKEDITOR.NODE_DOCUMENT_FRAGMENT;)e=m.parent,r(m,e),m=e;return o};var d=new(CKEDITOR.tools.createClass({$:function(){this._={output:[],rules:[]},this.setRules("list",{breakBeforeOpen:1,breakAfterOpen:1,breakBeforeClose:1,breakAfterClose:1}),this.setRules("*",{breakBeforeOpen:1,breakAfterOpen:0,breakBeforeClose:1,breakAfterClose:0}),this.setRules("quote",{breakBeforeOpen:1,breakAfterOpen:0,breakBeforeClose:0,breakAfterClose:1})},proto:{setRules:function(e,t){var n=this._.rules[e];n?CKEDITOR.tools.extend(n,t,!0):this._.rules[e]=t},getRule:function(e,t){return this._.rules[e]&&this._.rules[e][t]},openTag:function(e){e in t&&(this.getRule(e,"breakBeforeOpen")&&this.lineBreak(1),this.write("[",e))},openTagClose:function(e){"br"==e?this._.output.push("\n"):e in t&&(this.write("]"),this.getRule(e,"breakAfterOpen")&&this.lineBreak(1))},attribute:function(e,t){"option"==e&&this.write("=",t)},closeTag:function(e){e in t&&(this.getRule(e,"breakBeforeClose")&&this.lineBreak(1),"*"!=e&&this.write("[/",e,"]"),this.getRule(e,"breakAfterClose")&&this.lineBreak(1))},text:function(e){this.write(e)},comment:function(){},lineBreak:function(){!this._.hasLineBreak&&this._.output.length&&(this.write("\n"),this._.hasLineBreak=1)},write:function(){this._.hasLineBreak=0;var e=Array.prototype.join.call(arguments,"");this._.output.push(e)},reset:function(){this._.output=[],this._.hasLineBreak=0},getHtml:function(e){var t=this._.output.join("");return e&&this.reset(),f(t)}}}));CKEDITOR.plugins.add("bbcode",{requires:"entities",beforeInit:function(e){CKEDITOR.tools.extend(e.config,{enterMode:CKEDITOR.ENTER_BR,basicEntities:!1,entities:!1,fillEmptyBlocks:!1},!0),e.filter.disable(),e.activeEnterMode=e.enterMode=CKEDITOR.ENTER_BR},init:function(e){function t(e){var t=e.data;e=CKEDITOR.htmlParser.fragment.fromBBCode(e.data.dataValue);var n=new CKEDITOR.htmlParser.basicWriter;e.writeHtml(n,r),e=n.getHtml(!0),t.dataValue=e}var i=e.config,r=new CKEDITOR.htmlParser.filter;r.addRules({elements:{blockquote:function(e){var t=new CKEDITOR.htmlParser.element("div");if(t.children=e.children,e.children=[t],t=e.attributes.cite){var n=new CKEDITOR.htmlParser.element("cite");n.add(new CKEDITOR.htmlParser.text(t.replace(/^"|"$/g,""))),delete e.attributes.cite,e.children.unshift(n)}},span:function(e){var t;(t=e.attributes.bbcode)&&("img"==t?(e.name="img",e.attributes.src=e.children[0].value,e.children=[]):"email"==t&&(e.name="a",e.attributes.href="mailto:"+e.children[0].value),delete e.attributes.bbcode)},ol:function(e){e.attributes.listType?"decimal"!=e.attributes.listType&&(e.attributes.style="list-style-type:"+e.attributes.listType):e.name="ul",delete e.attributes.listType},a:function(e){e.attributes.href||(e.attributes.href=e.children[0].value)},smiley:function(e){e.name="img";var t=e.attributes.desc,n=i.smiley_images[CKEDITOR.tools.indexOf(i.smiley_descriptions,t)],n=CKEDITOR.tools.htmlEncode(i.smiley_path+n);e.attributes={src:n,"data-cke-saved-src":n,title:t,alt:t}}}}),e.dataProcessor.htmlFilter.addRules({elements:{$:function(t){var i,r=t.attributes,s=CKEDITOR.tools.parseCssText(r.style,1),a=t.name;if(a in n)a=n[a];else if("span"==a)(i=s.color)?(a="color",i=CKEDITOR.tools.convertRgbToHex(i)):(i=s["font-size"])&&(r=i.match(/(\d+)%$/))&&(i=r[1],a="size");else if("ol"==a||"ul"==a){if(i=s["list-style-type"])switch(i){case"lower-alpha":i="a";break;case"upper-alpha":i="A"}else"ol"==a&&(i=1);a="list"}else if("blockquote"==a){try{var l=t.children[0],o=t.children[1],c="cite"==l.name&&l.children[0].value;c&&(i='"'+c+'"',t.children=o.children)}catch(h){}a="quote"}else if("a"==a)(i=r.href)&&(-1!==i.indexOf("mailto:")?(a="email",t.children=[new CKEDITOR.htmlParser.text(i.replace("mailto:",""))],i=""):((a=1==t.children.length&&t.children[0])&&a.type==CKEDITOR.NODE_TEXT&&a.value==i&&(i=""),a="url"));else if("img"==a){if(t.isEmpty=0,s=r["data-cke-saved-src"]||r.src,r=r.alt,s&&-1!=s.indexOf(e.config.smiley_path)&&r)return new CKEDITOR.htmlParser.text(u[r]);t.children=[new CKEDITOR.htmlParser.text(s)]}return t.name=a,i&&(t.attributes.option=i),null},div:function(e){var t=CKEDITOR.tools.parseCssText(e.attributes.style,1)["text-align"]||"";return t?(e.name=t,null):void 0},br:function(e){return(e=e.next)&&e.name in l?!1:void 0}}},1),e.dataProcessor.writer=d,e.elementMode==CKEDITOR.ELEMENT_MODE_INLINE?e.once("contentDom",function(){e.on("setData",t)}):e.on("setData",t)},afterInit:function(e){var t;e._.elementsPath&&(t=e._.elementsPath.filters)&&t.push(function(t){var n=t.getName(),r=i[n]||!1;return"link"==r&&0===t.getAttribute("href").indexOf("mailto:")?r="email":"span"==n?t.getStyle("font-size")?r="size":t.getStyle("color")&&(r="color"):"div"==n&&t.getStyle("text-align")?r=t.getStyle("text-align"):"img"==r&&(t=t.data("cke-saved-src")||t.getAttribute("src"))&&0===t.indexOf(e.config.smiley_path)&&(r="smiley"),r})}})}();
|