[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_editors_tinymce/js/plugins/highlighter/ -> source.min.js (source)

   1  if(!window.parent.Joomla||"function"!=typeof window.parent.Joomla.getOptions)throw new Error("Joomla API not found");const rootPath=window.parent.Joomla.getOptions("system.paths").rootFull,cmPath=`$rootPath}/media/vendor/codemirror`;let tinymce,editor,codemirror,CMsettings={indentOnInit:!0,config:{mode:"htmlmixed",theme:"default",lineNumbers:!0,lineWrapping:!0,indentUnit:2,tabSize:2,indentWithTabs:!0,matchBrackets:!0,saveCursorPosition:!0,styleActiveLine:!0},jsFiles:[`$cmPath}/lib/codemirror.min.js`,`$cmPath}/addon/edit/matchbrackets.min.js`,`$cmPath}/mode/xml/xml.min.js`,`$cmPath}/mode/javascript/javascript.min.js`,`$cmPath}/mode/css/css.min.js`,`$cmPath}/mode/htmlmixed/htmlmixed.min.js`,`$cmPath}/addon/dialog/dialog.min.js`,`$cmPath}/addon/search/searchcursor.min.js`,`$cmPath}/addon/search/search.min.js`,`$cmPath}/addon/selection/active-line.min.js`],cssFiles:[`$cmPath}/lib/codemirror.css`,`$cmPath}/addon/dialog/dialog.css`]};const chr=0,isMac=/macintosh|mac os/i.test(navigator.userAgent),loadScript=e=>new Promise(((t,n)=>{const o=document.createElement("script");o.src=e,o.onload=()=>t(),o.onerror=()=>n(new Error(`Failed to load the script $e}`)),document.head.appendChild(o)})),findDepth=(e,t)=>{let n=0;for(let o=e.indexOf(t)-1;o>=0;o-=1)switch(e.charAt(o)){case"<":n-=1;break;case">":case"&":n+=1}return n};window.tinymceHighlighterSubmit=()=>{const e="&#x0;",{isDirty:t}=codemirror,{doc:n}=codemirror;n.somethingSelected()&&n.setCursor(n.getCursor()),n.replaceSelection(e);const o=codemirror.getCursor();let r=n.getLine(o.line);0!==findDepth(r,e)&&(r=r.replace(e,""),n.replaceRange(r,window.CodeMirror.Pos(o.line,0),window.CodeMirror.Pos(o.line)));const i=codemirror.getValue(),s=new RegExp("<script(.*?)>(.*?)&#x0;(.*?)<\/script>","ms"),c=new RegExp("<style(.*?)>(.*?)&#x0;(.*?)</style>","ms"),d=new RegExp("<[^>]*(&#x0;).*>|^(&#x0;)|(&#x0;)$");-1!==i.search(s)||-1!==i.search(c)||-1!==i.search(d)?editor.setContent(i.replace(e,"")):editor.setContent(i.replace(e,'<span id="CmCaReT"></span>')),editor.isNotDirty=!t,t&&editor.nodeChanged();const a=editor.dom.select("span#CmCaReT")[0];a&&(editor.selection.scrollIntoView(a),editor.selection.setCursorLocation(a,0),editor.dom.remove(a))},document.addEventListener("keydown",(e=>{const t=e||window.event;let n=!1;n="key"in t?"Escape"===t.key||"Esc"===t.key:27===t.keyCode,n&&tinymce.activeEditor.windowManager.close()}));const start=()=>{if("function"!=typeof window.CodeMirror)throw new Error(`CodeMirror not found in "$CMsettings.path}", aborting...`);const e=window.parent.document.querySelectorAll(".tox-dialog__footer")[0],t=window.parent.document.createElement("div"),n='<td style="font-size:11px;background:#777;color:#fff;padding:0 4px">',o='<td style="font-size:11px;padding-right:5px">';t.innerHTML=`\n<table cellspacing="0" cellpadding="0" style="border-spacing:4px">\n  <tr>\n    $n}$isMac?"&#8984;-F":"Ctrl-F</td>"}$o}$tinymce.translate("Start search")}</td>\n    $n}$isMac?"&#8984;-G":"Ctrl-G"}</td>\n    $o}$tinymce.translate("Find next")}</td>\n    $n}$isMac?"&#8984;-Alt-F":"Shift-Ctrl-F"}</td>\n    $o}$tinymce.translate("Find previous")}</td>\n  </tr>\n  <tr>\n    $n}$isMac?"&#8984;-Alt-F":"Shift-Ctrl-F"}</td>\n    $o}$tinymce.translate("Replace")}</td>\n    $n}$isMac?"Shift-&#8984;-Alt-F":"Shift-Ctrl-R"}</td>\n    $o}$tinymce.translate("Replace all")}</td>\n  </tr>\n</table>`,t.style.position="absolute",t.style.left="5px",t.style.bottom="5px",e.appendChild(t);let r=editor.getContent({source_view:!0});r=r.replace(/<span\s+style="display: none;"\s+class="CmCaReT"([^>]*)>([^<]*)<\/span>/gm,String.fromCharCode(0)),editor.dom.remove(editor.dom.select(".CmCaReT")),tinymce.each(editor.contextToolbars,(e=>{e.panel&&e.panel.hide()})),window.CodeMirror.defineInitHook((e=>{e.focus();const t=e.getSearchCursor(String.fromCharCode(0),!1);if(t.findNext()&&(e.setCursor(t.to()),t.replace("")),editor.settings.codemirror.indentOnInit){const t=e.lineCount();e.operation((()=>{for(let n=0;n<t;++n)e.indentLine(n)}))}})),CMsettings.config.value=r,codemirror=window.CodeMirror(document.body,CMsettings.config),codemirror.isDirty=!1,codemirror.on("change",(e=>{e.isDirty=!0})),codemirror.setSize("100%","100%"),codemirror.refresh()};if(tinymce=window.parent.tinymce,!tinymce)throw new Error("tinyMCE not found");editor=tinymce.activeEditor;const userSettings=editor.settings.codemirror;userSettings.fullscreen&&(CMsettings.jsFiles.push(`$cmPath}/addon/display/fullscreen.min.js`),CMsettings.cssFiles.push(`$cmPath}/addon/display/fullscreen.css`)),CMsettings={...CMsettings,...userSettings},CMsettings.cssFiles.forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)})),CMsettings.jsFiles.reduce(((e,t)=>e.then((()=>{return e=t,new Promise(((t,n)=>{const o=document.createElement("script");o.src=e,o.onload=()=>t(),o.onerror=()=>n(new Error(`Failed to load the script $e}`)),document.head.appendChild(o)}));var e}))),Promise.resolve(!0)).then((()=>{CMsettings.config.theme&&(document.documentElement.className+=CMsettings.config.theme.replace(/(^|\s)\s*/g," cm-s-")),start()}));


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer