| 1 |
- (function(e,t){"use strict";var n={};function r(e,t){var r,i=[];for(var o=0;o<e.length;++o){r=n[e[o]]||a(e[o]);if(!r){throw"module definition dependecy not found: "+e[o]}i.push(r)}t.apply(null,i)}function i(e,i,o){if(typeof e!=="string"){throw"invalid module definition, module id must be defined and be a string"}if(i===t){throw"invalid module definition, dependencies must be specified"}if(o===t){throw"invalid module definition, definition function must be specified"}r(i,function(){n[e]=o.apply(null,arguments)})}function o(e){return!!n[e]}function a(t){var n=e;var r=t.split(/[.\/]/);for(var i=0;i<r.length;++i){if(!n[r[i]]){return}n=n[r[i]]}return n}function l(r){for(var i=0;i<r.length;i++){var o=e;var a=r[i];var l=a.split(/[.\/]/);for(var c=0;c<l.length-1;++c){if(o[l[c]]===t){o[l[c]]={}}o=o[l[c]]}o[l[l.length-1]]=n[a]}}i("tinymce/spellcheckerplugin/DomTextMatcher",[],function(){return function(e,t){var n,r=[],i,o=t.dom;var a,l,c;a=t.schema.getBlockElements();l=t.schema.getWhiteSpaceElements();c=t.schema.getShortEndedElements();function s(e,t){if(!e[0]){throw"findAndReplaceDOMText cannot handle zero-length matches"}return{start:e.index,end:e.index+e[0].length,text:e[0],data:t}}function u(e){var t;if(e.nodeType===3){return e.data}if(l[e.nodeName]&&!a[e.nodeName]){return""}t="";if(a[e.nodeName]||c[e.nodeName]){t+="\n"}if(e=e.firstChild){do{t+=u(e)}while(e=e.nextSibling)}return t}function d(e,t,n){var r,i,o,s,u=[],d=0,f=e,h,g=0;t=t.slice(0);t.sort(function(e,t){return e.start-t.start});h=t.shift();e:while(true){if(a[f.nodeName]||c[f.nodeName]){d++}if(f.nodeType===3){if(!i&&f.length+d>=h.end){i=f;s=h.end-d}else if(r){u.push(f)}if(!r&&f.length+d>h.start){r=f;o=h.start-d}d+=f.length}if(r&&i){f=n({startNode:r,startNodeIndex:o,endNode:i,endNodeIndex:s,innerNodes:u,match:h.text,matchIndex:g});d-=i.length-s;r=null;i=null;u=[];h=t.shift();g++;if(!h){break}}else if((!l[f.nodeName]||a[f.nodeName])&&f.firstChild){f=f.firstChild;continue}else if(f.nextSibling){f=f.nextSibling;continue}while(true){if(f.nextSibling){f=f.nextSibling;break}else if(f.parentNode!==e){f=f.parentNode}else{break e}}}}function f(e){function t(t,n){var i=r[n];if(!i.stencil){i.stencil=e(i)}var a=i.stencil.cloneNode(false);a.setAttribute("data-mce-index",n);if(t){a.appendChild(o.doc.createTextNode(t))}return a}return function(e){var n,r,i,a=e.startNode,l=e.endNode,c=e.matchIndex,s=o.doc;if(a===l){var u=a;i=u.parentNode;if(e.startNodeIndex>0){n=s.createTextNode(u.data.substring(0,e.startNodeIndex));i.insertBefore(n,u)}var d=t(e.match,c);i.insertBefore(d,u);if(e.endNodeIndex<u.length){r=s.createTextNode(u.data.substring(e.endNodeIndex));i.insertBefore(r,u)}u.parentNode.removeChild(u);return d}else{n=s.createTextNode(a.data.substring(0,e.startNodeIndex));r=s.createTextNode(l.data.substring(e.endNodeIndex));var f=t(a.data.substring(e.startNodeIndex),c);var h=[];for(var g=0,p=e.innerNodes.length;g<p;++g){var m=e.innerNodes[g];var v=t(m.data,c);m.parentNode.replaceChild(v,m);h.push(v)}var x=t(l.data.substring(0,e.endNodeIndex),c);i=a.parentNode;i.insertBefore(n,a);i.insertBefore(f,a);i.removeChild(a);i=l.parentNode;i.insertBefore(x,l);i.insertBefore(r,l);i.removeChild(l);return x}}}function h(e){var t=e.parentNode;t.insertBefore(e.firstChild,e);e.parentNode.removeChild(e)}function g(t){var n=e.getElementsByTagName("*"),r=[];t=typeof t=="number"?""+t:null;for(var i=0;i<n.length;i++){var o=n[i],a=o.getAttribute("data-mce-index");if(a!==null&&a.length){if(a===t||t===null){r.push(o)}}}return r}function p(e){var t=r.length;while(t--){if(r[t]===e){return t}}return-1}function m(e){var t=[];v(function(n,r){if(e(n,r)){t.push(n)}});r=t;return this}function v(e){for(var t=0,n=r.length;t<n;t++){if(e(r[t],t)===false){break}}return this}function x(t){if(r.length){d(e,r,f(t))}return this}function N(e,t){if(i&&e.global){while(n=e.exec(i)){r.push(s(n,t))}}return this}function k(e){var t,n=g(e?p(e):null);t=n.length;while(t--){h(n[t])}return this}function w(e){return r[e.getAttribute("data-mce-index")]}function b(e){return g(p(e))[0]}function y(e,t,n){r.push({start:e,end:e+t,text:i.substr(e,t),data:n});return this}function S(e){var n=g(p(e));var r=t.dom.createRng();r.setStartBefore(n[0]);r.setEndAfter(n[n.length-1]);return r}function T(e,n){var r=S(e);r.deleteContents();if(n.length>0){r.insertNode(t.dom.doc.createTextNode(n))}return r}function B(){r.splice(0,r.length);k();return this}i=u(e);return{text:i,matches:r,each:v,filter:m,reset:B,matchFromElement:w,elementFromMatch:b,find:N,add:y,wrap:x,unwrap:k,replace:T,rangeFromMatch:S,indexOf:p}}});i("tinymce/spellcheckerplugin/Plugin",["tinymce/spellcheckerplugin/DomTextMatcher","tinymce/PluginManager","tinymce/util/Tools","tinymce/ui/Menu","tinymce/dom/DOMUtils","tinymce/util/XHR","tinymce/util/URI","tinymce/util/JSON"],function(e,t,n,r,i,o,a,l){t.add("spellchecker",function(t,c){var s,u=this,d,f,h,g=t.settings;function p(){if(!u.textMatcher){u.textMatcher=new e(t.getBody(),t)}return u.textMatcher}function m(e,t){var r=[];n.each(t,function(e){r.push({selectable:true,text:e.name,data:e.value})});return r}var v=g.spellchecker_languages||"English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,"+"German=de,Italian=it,Polish=pl,Portuguese=pt_BR,"+"Spanish=es,Swedish=sv";s=m("Language",n.map(v.split(","),function(e){var t=e.split("=");return{name:t[0],value:t[1]}}));function x(e){for(var t in e){return false}return true}function N(e,o){var a=[],l=d[e];n.each(l,function(e){a.push({text:e,onclick:function(){t.insertContent(t.dom.encode(e));t.dom.remove(o);b()}})});a.push.apply(a,[{text:"-"},{text:"Ignore",onclick:function(){y(e,o)}},{text:"Ignore all",onclick:function(){y(e,o,true)}},{text:"Finish",onclick:S}]);h=new r({items:a,context:"contextmenu",onautohide:function(e){if(e.target.className.indexOf("spellchecker")!=-1){e.preventDefault()}},onhide:function(){h.remove();h=null}});h.renderTo(document.body);var c=i.DOM.getPos(t.getContentAreaContainer());var s=t.dom.getPos(o[0]);var u=t.dom.getRoot();if(u.nodeName=="BODY"){s.x-=u.ownerDocument.documentElement.scrollLeft||u.scrollLeft;s.y-=u.ownerDocument.documentElement.scrollTop||u.scrollTop}else{s.x-=u.scrollLeft;s.y-=u.scrollTop}c.x+=s.x;c.y+=s.y;h.moveTo(c.x,c.y+o[0].offsetHeight)}function k(){return t.getParam("spellchecker_wordchar_pattern")||new RegExp("[^"+'\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`'+"§©«®±¶·¸»"+"¼½¾¿×÷¤”“„"+"]+","g")}function w(){if(f){S();return}else{S()}f=true;function e(e){t.setProgressState(false);if(x(e)){t.windowManager.alert("No misspellings found");f=false;return}d=e;p().find(k()).filter(function(t){return!!e[t.text]}).wrap(function(e){return t.dom.create("span",{class:"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":e.text})});t.fire("SpellcheckStart")}function n(e){t.windowManager.alert(e);t.setProgressState(false);S()}function r(e,t,r){o.send({url:new a(c).toAbsolute(g.spellchecker_rpc_url),type:"post",content_type:"application/x-www-form-urlencoded",data:"text="+encodeURIComponent(t)+"&lang="+g.spellchecker_language,success:function(e){e=l.parse(e);if(!e){n("Sever response wasn't proper JSON.")}else if(e.error){n(e.error)}else{r(e.words)}},error:function(e,t){n("Spellchecker request error: "+t.status)}})}t.setProgressState(true);var i=g.spellchecker_callback||r;i.call(u,"spellcheck",p().text,e,n);t.focus()}function b(){if(!t.dom.select("span.mce-spellchecker-word").length){S()}}function y(e,r,i){t.selection.collapse();if(i){n.each(t.dom.select("span.mce-spellchecker-word"),function(n){if(n.getAttribute("data-mce-word")==e){t.dom.remove(n,true)}})}else{t.dom.remove(r,true)}b()}function S(){p().reset();u.textMatcher=null;if(f){f=false;t.fire("SpellcheckEnd")}}function T(e){var t=e.getAttribute("data-mce-index");if(typeof t=="number"){return""+t}return t}function B(e){var r,i=[];r=n.toArray(t.getBody().getElementsByTagName("span"));if(r.length){for(var o=0;o<r.length;o++){var a=T(r[o]);if(a===null||!a.length){continue}if(a===e.toString()){i.push(r[o])}}}return i}t.on("click",function(e){var n=e.target;if(n.className=="mce-spellchecker-word"){e.preventDefault();var r=B(T(n));if(r.length>0){var i=t.dom.createRng();i.setStartBefore(r[0]);i.setEndAfter(r[r.length-1]);t.selection.setRng(i);N(n.getAttribute("data-mce-word"),r)}}});t.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:w,selectable:true,onPostRender:function(){var e=this;t.on("SpellcheckStart SpellcheckEnd",function(){e.active(f)})}});function C(e){var t=g.spellchecker_language;e.control.items().each(function(e){e.active(e.settings.data===t)})}var I={tooltip:"Spellcheck",onclick:w,onPostRender:function(){var e=this;t.on("SpellcheckStart SpellcheckEnd",function(){e.active(f)})}};if(s.length>1){I.type="splitbutton";I.menu=s;I.onshow=C;I.onselect=function(e){g.spellchecker_language=e.control.settings.data}}t.addButton("spellchecker",I);t.addCommand("mceSpellCheck",w);t.on("remove",function(){if(h){h.remove();h=null}});t.on("change",b);this.getTextMatcher=p;this.getWordCharPattern=k;this.getLanguage=function(){return g.spellchecker_language};g.spellchecker_language=g.spellchecker_language||g.language||"en"})});l(["tinymce/spellcheckerplugin/DomTextMatcher","tinymce/spellcheckerplugin/Plugin"])})(this);
|