[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 /** 2 * Copyright (c) Tiny Technologies, Inc. All rights reserved. 3 * Licensed under the LGPL or a commercial license. 4 * For LGPL see License.txt in the project root for license information. 5 * For commercial licenses see https://www.tiny.cloud/ 6 * 7 * Version: 5.10.5 (2022-05-25) 8 */ 9 (function () { 10 'use strict'; 11 12 var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 14 var global = tinymce.util.Tools.resolve('tinymce.util.Tools'); 15 16 var getNonEditableClass = function (editor) { 17 return editor.getParam('noneditable_noneditable_class', 'mceNonEditable'); 18 }; 19 var getEditableClass = function (editor) { 20 return editor.getParam('noneditable_editable_class', 'mceEditable'); 21 }; 22 var getNonEditableRegExps = function (editor) { 23 var nonEditableRegExps = editor.getParam('noneditable_regexp', []); 24 if (nonEditableRegExps && nonEditableRegExps.constructor === RegExp) { 25 return [nonEditableRegExps]; 26 } else { 27 return nonEditableRegExps; 28 } 29 }; 30 31 var hasClass = function (checkClassName) { 32 return function (node) { 33 return (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1; 34 }; 35 }; 36 var replaceMatchWithSpan = function (editor, content, cls) { 37 return function (match) { 38 var args = arguments, index = args[args.length - 2]; 39 var prevChar = index > 0 ? content.charAt(index - 1) : ''; 40 if (prevChar === '"') { 41 return match; 42 } 43 if (prevChar === '>') { 44 var findStartTagIndex = content.lastIndexOf('<', index); 45 if (findStartTagIndex !== -1) { 46 var tagHtml = content.substring(findStartTagIndex, index); 47 if (tagHtml.indexOf('contenteditable="false"') !== -1) { 48 return match; 49 } 50 } 51 } 52 return '<span class="' + cls + '" data-mce-content="' + editor.dom.encode(args[0]) + '">' + editor.dom.encode(typeof args[1] === 'string' ? args[1] : args[0]) + '</span>'; 53 }; 54 }; 55 var convertRegExpsToNonEditable = function (editor, nonEditableRegExps, e) { 56 var i = nonEditableRegExps.length, content = e.content; 57 if (e.format === 'raw') { 58 return; 59 } 60 while (i--) { 61 content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, getNonEditableClass(editor))); 62 } 63 e.content = content; 64 }; 65 var setup = function (editor) { 66 var contentEditableAttrName = 'contenteditable'; 67 var editClass = ' ' + global.trim(getEditableClass(editor)) + ' '; 68 var nonEditClass = ' ' + global.trim(getNonEditableClass(editor)) + ' '; 69 var hasEditClass = hasClass(editClass); 70 var hasNonEditClass = hasClass(nonEditClass); 71 var nonEditableRegExps = getNonEditableRegExps(editor); 72 editor.on('PreInit', function () { 73 if (nonEditableRegExps.length > 0) { 74 editor.on('BeforeSetContent', function (e) { 75 convertRegExpsToNonEditable(editor, nonEditableRegExps, e); 76 }); 77 } 78 editor.parser.addAttributeFilter('class', function (nodes) { 79 var i = nodes.length, node; 80 while (i--) { 81 node = nodes[i]; 82 if (hasEditClass(node)) { 83 node.attr(contentEditableAttrName, 'true'); 84 } else if (hasNonEditClass(node)) { 85 node.attr(contentEditableAttrName, 'false'); 86 } 87 } 88 }); 89 editor.serializer.addAttributeFilter(contentEditableAttrName, function (nodes) { 90 var i = nodes.length, node; 91 while (i--) { 92 node = nodes[i]; 93 if (!hasEditClass(node) && !hasNonEditClass(node)) { 94 continue; 95 } 96 if (nonEditableRegExps.length > 0 && node.attr('data-mce-content')) { 97 node.name = '#text'; 98 node.type = 3; 99 node.raw = true; 100 node.value = node.attr('data-mce-content'); 101 } else { 102 node.attr(contentEditableAttrName, null); 103 } 104 } 105 }); 106 }); 107 }; 108 109 function Plugin () { 110 global$1.add('noneditable', function (editor) { 111 setup(editor); 112 }); 113 } 114 115 Plugin(); 116 117 }());
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |