9 lines
20 KiB
JavaScript
9 lines
20 KiB
JavaScript
|
/**
|
||
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||
|
* Licensed under the LGPL or a commercial license.
|
||
|
* For LGPL see License.txt in the project root for license information.
|
||
|
* For commercial licenses see https://www.tiny.cloud/
|
||
|
*
|
||
|
* Version: 5.1.4 (2019-12-11)
|
||
|
*/
|
||
|
!function(c){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),r=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),t={},n=t,g=void 0!==t?t:"undefined"!=typeof WorkerGlobalScope&&c.self instanceof WorkerGlobalScope?c.self:{},i=function(){var u=/\blang(?:uage)?-(?!\*)(\w+)\b/i,S=g.Prism={util:{encode:function(e){return e instanceof s?new s(e.type,S.util.encode(e.content),e.alias):"Array"===S.util.type(e)?e.map(S.util.encode):e.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){switch(S.util.type(e)){case"Object":var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=S.util.clone(e[n]));return t;case"Array":return e.map&&e.map(function(e){return S.util.clone(e)})}return e}},languages:{extend:function(e,t){var n=S.util.clone(S.languages[e]);for(var a in t)n[a]=t[a];return n},insertBefore:function(n,e,t,a){var r=(a=a||S.languages)[n];if(2===arguments.length){for(var i in t=e)t.hasOwnProperty(i)&&(r[i]=t[i]);return r}var o={};for(var s in r)if(r.hasOwnProperty(s)){if(s===e)for(var i in t)t.hasOwnProperty(i)&&(o[i]=t[i]);o[s]=r[s]}return S.languages.DFS(S.languages,function(e,t){t===a[n]&&e!==n&&(this[e]=o)}),a[n]=o},DFS:function(e,t,n){for(var a in e)e.hasOwnProperty(a)&&(t.call(e,a,e[a],n||a),"Object"===S.util.type(e[a])?S.languages.DFS(e[a],t):"Array"===S.util.type(e[a])&&S.languages.DFS(e[a],t,a))}},plugins:{},highlightAll:function(e,t){for(var n=c.document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),a=0,r=void 0;r=n[a++];)S.highlightElement(r,!0===e,t)},highlightElement:function(e,t,n){for(var a,r,i=e;i&&!u.test(i.className);)i=i.parentNode;i&&(a=(i.className.match(u)||[,""])[1],r=S.languages[a]),e.className=e.className.replace(u,"").replace(/\s+/g," ")+" language-"+a,i=e.parentNode,/pre/i.test(i.nodeName)&&(i.className=i.className.replace(u,"").replace(/\s+/g," ")+" language-"+a);var o=e.textContent,s={element:e,language:a,grammar:r,code:o};if(o&&r)if(S.hooks.run("before-highlight",s),t&&g.Worker){var l=new c.Worker(S.filename);l.onmessage=function(e){s.highlightedCode=e.data,S.hooks.run("before-insert",s),s.element.innerHTML=s.highlightedCode,n&&n.call(s.element),S.hooks.run("after-highlight",s),S.hooks.run("complete",s)},l.postMessage(JSON.stringify({language:s.language,code:s.code,immediateClose:!0}))}else s.highlightedCode=S.highlight(s.code,s.grammar,s.language),S.hooks.run("before-insert",s),s.element.innerHTML=s.highlightedCode,n&&n.call(e),S.hooks.run("after-highlight",s),S.hooks.run("complete",s);else S.hooks.run("complete",s)},highlight:function(e,t,n){var a=S.tokenize(e,t);return s.stringify(S.util.encode(a),n)},tokenize:function(e,t,n){var a=S.Token,r=[e],i=t.rest;if(i){for(var o in i)t[o]=i[o];delete t.rest}e:for(var o in t)if(t.hasOwnProperty(o)&&t[o]){var s=t[o];s="Array"===S.util.type(s)?s:[s];for(var l=0;l<s.length;++l){var u=s[l],c=u.inside,g=!!u.lookbehind,d=0,p=u.alias;u=u.pattern||u;for(var f=0;f<r.length;f++){var h=r[f];if(r.length>e.length)break e;if(!(h instanceof a)){u.lastIndex=0;var m=u.exec(h);if(m){g&&(d=m[1].length);var b=m.index-1+d,y=b+(m=m[0].slice(d)).length,v=h.slice(0,b+1),k=h.slice(y+1),w=[f,1];v&&w.push(v);var x=new a(o,c?S.tokenize(m,c):m,p);w.push(x),k&&w.push(k),Array.prototype.splice.apply(r,w)}}}}}return r},hooks:{all:{},add:function(e,t){var n=S.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=S.hooks.all[e];if(n&&n.length)for(var a=0,r=void 0;r=n[a++];)r(t)}}},s=S.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(s.stringify=function(t,n,e){if("string"==typeof t)return t;if("Array"===S.util.type(t))return t.map(function(e){return s.stringify(e,n,t)}).join("");var a={type:t.type,content:s.stringify(t.content,n,e),tag:"span",classes:["token",t.type],attributes:{},language:n,parent:e};if("comment"===a.type&&(a.attributes.spellcheck="true"),t.alias){var r="Array"===S.util.type(t.alias)?t.alias:[t.alias];Array.prototype.push.apply(a.classes,r)}
|