BookStack/public/libs/tinymce/plugins/spellchecker/plugin.min.js

1 line
9.9 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var e=function(t){var n=t,r=function(){return n};return{get:r,set:function(e){n=e},clone:function(){return e(r())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=function(e){return!(!/(^|[ ,])tinymcespellchecker([, ]|$)/.test(e.settings.plugins)||!t.get("tinymcespellchecker")||("undefined"!=typeof window.console&&window.console.log&&window.console.log("Spell Checker Pro is incompatible with Spell Checker plugin! Remove 'spellchecker' from the 'plugins' option."),0))},r=function(e){return e.getParam("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")},o=function(e){var t=e.getParam("language","en");return e.getParam("spellchecker_language",t)},i=function(e){return e.getParam("spellchecker_rpc_url")},c=function(e){return e.getParam("spellchecker_callback")},a=function(e){var t=new RegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`\xa7\xa9\xab\xae\xb1\xb6\xb7\xb8\xbb\xbc\xbd\xbe\xbf\xd7\xf7\xa4\u201d\u201c\u201e\xa0\u2002\u2003\u2009]+',"g");return e.getParam("spellchecker_wordchar_pattern",t)},l=tinymce.util.Tools.resolve("tinymce.util.Tools"),s=tinymce.util.Tools.resolve("tinymce.util.URI"),u=tinymce.util.Tools.resolve("tinymce.util.XHR"),d=function(e){return e.fire("SpellcheckStart")},f=function(e){return e.fire("SpellcheckEnd")};function h(e){return e&&1===e.nodeType&&"false"===e.contentEditable}function g(e,t){var n,r,o,i,c,a=[],l=t.dom;function s(e,t){if(!e[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");return{start:e.index,end:e.index+e[0].length,text:e[0],data:t}}function u(t){var n=e.getElementsByTagName("*"),r=[];t="number"==typeof t?""+t:null;for(var o=0;o<n.length;o++){var i=n[o],c=i.getAttribute("data-mce-index");null!==c&&c.length&&-1!==i.className.indexOf("mce-spellchecker-word")&&(c!==t&&null!==t||r.push(i))}return r}function d(e){for(var t=a.length;t--;)if(a[t]===e)return t;return-1}function f(e){for(var t=0,n=a.length;t<n&&!1!==e(a[t],t);t++);return this}function g(e){var t,n,r=u(e?d(e):null);for(t=r.length;t--;)(n=r[t]).parentNode.insertBefore(n.firstChild,n),n.parentNode.removeChild(n);return this}function m(e){var n=u(d(e)),r=t.dom.createRng();return r.setStartBefore(n[0]),r.setEndAfter(n[n.length-1]),r}return o=t.schema.getBlockElements(),i=t.schema.getWhiteSpaceElements(),c=t.schema.getShortEndedElements(),{text:r=function p(e){var t;if(3===e.nodeType)return e.data;if(i[e.nodeName]&&!o[e.nodeName])return"";if(h(e))return"\n";if(t="",(o[e.nodeName]||c[e.nodeName])&&(t+="\n"),e=e.firstChild)for(;t+=p(e),e=e.nextSibling;);return t}(e),matches:a,each:f,filter:function(e){var t=[];return f(function(n,r){e(n,r)&&t.push(n)}),a=t,this},reset:function(){return a.splice(0,a.length),g(),this},matchFromElement:function(e){return a[e.getAttribute("data-mce-index")]},elementFromMatch:function(e){return u(d(e))[0]},find:function(e,t){if(r&&e.global)for(;n=e.exec(r);)a.push(s(n,t));return this},add:function(e,t,n){return a.push({start:e,end:e+t,text:r.substr(e,t),data:n}),this},wrap:function(t){return a.length&&function(e,t,n){var r,a,l,s,u,d=[],f=0,g=e,m=0;(t=t.slice(0)).sort(function(e,t){return e.start-t.start}),u=t.shift();e:for(;;){if((o[g.nodeName]||c[g.nodeName]||h(g))&&f++,3===g.nodeType&&(!a&&g.length+f>=u.end?(a=g,s=u.end-f):r&&d.push(g),!r&&g.length+f>u.start&&(r=g,l=u.start-f),f+=g.length),r&&a){if(g=n({startNode:r,startNodeIndex:l,endNode:a,endNodeIndex:s,innerNodes:d,match:u.text,matchIndex:m}),f-=a.length-s,r=null,a=null,d=[],m++,!(u=t.shift()))break}else if(i[g.nodeName]&&!o[g.nodeName]||!g.firstChild){if(g.nextSibling){g=g.nextSibling;continue}}else if(!h(g)){g=g.firstChild;continue}for(;;){if(g.nextSibling){g=g.nextSibling;break}if(g.parentNode===e)break e;g=g.parentNode}}}(e,a,function(e){function t(t,n){var r=a[n];r.stencil||(r.stencil=e(r));var o=r.stencil.cloneNode(!1);return o.setAttribute("data-mce-index",n),t&&o.appendChild(l.doc.createTextNode(t)),o}return function(e){var n,r,o,i=e.startNode,c=e.endNode,a=e.matchIndex,s=l.doc;if(i==