[ 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$3 = tinymce.util.Tools.resolve('tinymce.PluginManager'); 13 14 var unique = 0; 15 var generate = function (prefix) { 16 var date = new Date(); 17 var time = date.getTime(); 18 var random = Math.floor(Math.random() * 1000000000); 19 unique++; 20 return prefix + '_' + random + unique + String(time); 21 }; 22 23 var createTableHtml = function (cols, rows) { 24 var html = '<table data-mce-id="mce" style="width: 100%">'; 25 html += '<tbody>'; 26 for (var y = 0; y < rows; y++) { 27 html += '<tr>'; 28 for (var x = 0; x < cols; x++) { 29 html += '<td><br></td>'; 30 } 31 html += '</tr>'; 32 } 33 html += '</tbody>'; 34 html += '</table>'; 35 return html; 36 }; 37 var getInsertedElement = function (editor) { 38 var elms = editor.dom.select('*[data-mce-id]'); 39 return elms[0]; 40 }; 41 var insertTableHtml = function (editor, cols, rows) { 42 editor.undoManager.transact(function () { 43 editor.insertContent(createTableHtml(cols, rows)); 44 var tableElm = getInsertedElement(editor); 45 tableElm.removeAttribute('data-mce-id'); 46 var cellElm = editor.dom.select('td,th', tableElm); 47 editor.selection.setCursorLocation(cellElm[0], 0); 48 }); 49 }; 50 var insertTable = function (editor, cols, rows) { 51 editor.plugins.table ? editor.plugins.table.insertTable(cols, rows) : insertTableHtml(editor, cols, rows); 52 }; 53 var insertBlob = function (editor, base64, blob) { 54 var blobCache = editor.editorUpload.blobCache; 55 var blobInfo = blobCache.create(generate('mceu'), blob, base64); 56 blobCache.add(blobInfo); 57 editor.insertContent(editor.dom.createHTML('img', { src: blobInfo.blobUri() })); 58 }; 59 60 var global$2 = tinymce.util.Tools.resolve('tinymce.util.Promise'); 61 62 var blobToBase64 = function (blob) { 63 return new global$2(function (resolve) { 64 var reader = new FileReader(); 65 reader.onloadend = function () { 66 resolve(reader.result.split(',')[1]); 67 }; 68 reader.readAsDataURL(blob); 69 }); 70 }; 71 72 var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); 73 74 var global = tinymce.util.Tools.resolve('tinymce.util.Delay'); 75 76 var pickFile = function (editor) { 77 return new global$2(function (resolve) { 78 var fileInput = document.createElement('input'); 79 fileInput.type = 'file'; 80 fileInput.accept = 'image/*'; 81 fileInput.style.position = 'fixed'; 82 fileInput.style.left = '0'; 83 fileInput.style.top = '0'; 84 fileInput.style.opacity = '0.001'; 85 document.body.appendChild(fileInput); 86 var changeHandler = function (e) { 87 resolve(Array.prototype.slice.call(e.target.files)); 88 }; 89 fileInput.addEventListener('change', changeHandler); 90 var cancelHandler = function (e) { 91 var cleanup = function () { 92 resolve([]); 93 fileInput.parentNode.removeChild(fileInput); 94 }; 95 if (global$1.os.isAndroid() && e.type !== 'remove') { 96 global.setEditorTimeout(editor, cleanup, 0); 97 } else { 98 cleanup(); 99 } 100 editor.off('focusin remove', cancelHandler); 101 }; 102 editor.on('focusin remove', cancelHandler); 103 fileInput.click(); 104 }); 105 }; 106 107 var setupButtons = function (editor) { 108 editor.ui.registry.addButton('quickimage', { 109 icon: 'image', 110 tooltip: 'Insert image', 111 onAction: function () { 112 pickFile(editor).then(function (files) { 113 if (files.length > 0) { 114 var blob_1 = files[0]; 115 blobToBase64(blob_1).then(function (base64) { 116 insertBlob(editor, base64, blob_1); 117 }); 118 } 119 }); 120 } 121 }); 122 editor.ui.registry.addButton('quicktable', { 123 icon: 'table', 124 tooltip: 'Insert table', 125 onAction: function () { 126 insertTable(editor, 2, 2); 127 } 128 }); 129 }; 130 131 var typeOf = function (x) { 132 var t = typeof x; 133 if (x === null) { 134 return 'null'; 135 } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { 136 return 'array'; 137 } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { 138 return 'string'; 139 } else { 140 return t; 141 } 142 }; 143 var isType = function (type) { 144 return function (value) { 145 return typeOf(value) === type; 146 }; 147 }; 148 var isSimpleType = function (type) { 149 return function (value) { 150 return typeof value === type; 151 }; 152 }; 153 var eq = function (t) { 154 return function (a) { 155 return t === a; 156 }; 157 }; 158 var isString = isType('string'); 159 var isObject = isType('object'); 160 var isArray = isType('array'); 161 var isBoolean = isSimpleType('boolean'); 162 var isUndefined = eq(undefined); 163 var isFunction = isSimpleType('function'); 164 165 var noop = function () { 166 }; 167 var constant = function (value) { 168 return function () { 169 return value; 170 }; 171 }; 172 var identity = function (x) { 173 return x; 174 }; 175 var never = constant(false); 176 var always = constant(true); 177 178 var none = function () { 179 return NONE; 180 }; 181 var NONE = function () { 182 var call = function (thunk) { 183 return thunk(); 184 }; 185 var id = identity; 186 var me = { 187 fold: function (n, _s) { 188 return n(); 189 }, 190 isSome: never, 191 isNone: always, 192 getOr: id, 193 getOrThunk: call, 194 getOrDie: function (msg) { 195 throw new Error(msg || 'error: getOrDie called on none.'); 196 }, 197 getOrNull: constant(null), 198 getOrUndefined: constant(undefined), 199 or: id, 200 orThunk: call, 201 map: none, 202 each: noop, 203 bind: none, 204 exists: never, 205 forall: always, 206 filter: function () { 207 return none(); 208 }, 209 toArray: function () { 210 return []; 211 }, 212 toString: constant('none()') 213 }; 214 return me; 215 }(); 216 var some = function (a) { 217 var constant_a = constant(a); 218 var self = function () { 219 return me; 220 }; 221 var bind = function (f) { 222 return f(a); 223 }; 224 var me = { 225 fold: function (n, s) { 226 return s(a); 227 }, 228 isSome: always, 229 isNone: never, 230 getOr: constant_a, 231 getOrThunk: constant_a, 232 getOrDie: constant_a, 233 getOrNull: constant_a, 234 getOrUndefined: constant_a, 235 or: self, 236 orThunk: self, 237 map: function (f) { 238 return some(f(a)); 239 }, 240 each: function (f) { 241 f(a); 242 }, 243 bind: bind, 244 exists: bind, 245 forall: bind, 246 filter: function (f) { 247 return f(a) ? me : NONE; 248 }, 249 toArray: function () { 250 return [a]; 251 }, 252 toString: function () { 253 return 'some(' + a + ')'; 254 } 255 }; 256 return me; 257 }; 258 var from = function (value) { 259 return value === null || value === undefined ? NONE : some(value); 260 }; 261 var Optional = { 262 some: some, 263 none: none, 264 from: from 265 }; 266 267 function ClosestOrAncestor (is, ancestor, scope, a, isRoot) { 268 if (is(scope, a)) { 269 return Optional.some(scope); 270 } else if (isFunction(isRoot) && isRoot(scope)) { 271 return Optional.none(); 272 } else { 273 return ancestor(scope, a, isRoot); 274 } 275 } 276 277 var ELEMENT = 1; 278 279 var fromHtml = function (html, scope) { 280 var doc = scope || document; 281 var div = doc.createElement('div'); 282 div.innerHTML = html; 283 if (!div.hasChildNodes() || div.childNodes.length > 1) { 284 console.error('HTML does not have a single root node', html); 285 throw new Error('HTML must have a single root node'); 286 } 287 return fromDom(div.childNodes[0]); 288 }; 289 var fromTag = function (tag, scope) { 290 var doc = scope || document; 291 var node = doc.createElement(tag); 292 return fromDom(node); 293 }; 294 var fromText = function (text, scope) { 295 var doc = scope || document; 296 var node = doc.createTextNode(text); 297 return fromDom(node); 298 }; 299 var fromDom = function (node) { 300 if (node === null || node === undefined) { 301 throw new Error('Node cannot be null or undefined'); 302 } 303 return { dom: node }; 304 }; 305 var fromPoint = function (docElm, x, y) { 306 return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom); 307 }; 308 var SugarElement = { 309 fromHtml: fromHtml, 310 fromTag: fromTag, 311 fromText: fromText, 312 fromDom: fromDom, 313 fromPoint: fromPoint 314 }; 315 316 var is = function (element, selector) { 317 var dom = element.dom; 318 if (dom.nodeType !== ELEMENT) { 319 return false; 320 } else { 321 var elem = dom; 322 if (elem.matches !== undefined) { 323 return elem.matches(selector); 324 } else if (elem.msMatchesSelector !== undefined) { 325 return elem.msMatchesSelector(selector); 326 } else if (elem.webkitMatchesSelector !== undefined) { 327 return elem.webkitMatchesSelector(selector); 328 } else if (elem.mozMatchesSelector !== undefined) { 329 return elem.mozMatchesSelector(selector); 330 } else { 331 throw new Error('Browser lacks native selectors'); 332 } 333 } 334 }; 335 336 typeof window !== 'undefined' ? window : Function('return this;')(); 337 338 var name = function (element) { 339 var r = element.dom.nodeName; 340 return r.toLowerCase(); 341 }; 342 343 var ancestor$1 = function (scope, predicate, isRoot) { 344 var element = scope.dom; 345 var stop = isFunction(isRoot) ? isRoot : never; 346 while (element.parentNode) { 347 element = element.parentNode; 348 var el = SugarElement.fromDom(element); 349 if (predicate(el)) { 350 return Optional.some(el); 351 } else if (stop(el)) { 352 break; 353 } 354 } 355 return Optional.none(); 356 }; 357 var closest$1 = function (scope, predicate, isRoot) { 358 var is = function (s, test) { 359 return test(s); 360 }; 361 return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot); 362 }; 363 364 var ancestor = function (scope, selector, isRoot) { 365 return ancestor$1(scope, function (e) { 366 return is(e, selector); 367 }, isRoot); 368 }; 369 var closest = function (scope, selector, isRoot) { 370 var is$1 = function (element, selector) { 371 return is(element, selector); 372 }; 373 return ClosestOrAncestor(is$1, ancestor, scope, selector, isRoot); 374 }; 375 376 var validDefaultOrDie = function (value, predicate) { 377 if (predicate(value)) { 378 return true; 379 } 380 throw new Error('Default value doesn\'t match requested type.'); 381 }; 382 var items = function (value, defaultValue) { 383 if (isArray(value) || isObject(value)) { 384 throw new Error('expected a string but found: ' + value); 385 } 386 if (isUndefined(value)) { 387 return defaultValue; 388 } 389 if (isBoolean(value)) { 390 return value === false ? '' : defaultValue; 391 } 392 return value; 393 }; 394 var getToolbarItemsOr_ = function (predicate) { 395 return function (editor, name, defaultValue) { 396 validDefaultOrDie(defaultValue, predicate); 397 var value = editor.getParam(name, defaultValue); 398 return items(value, defaultValue); 399 }; 400 }; 401 var getToolbarItemsOr = getToolbarItemsOr_(isString); 402 403 var getTextSelectionToolbarItems = function (editor) { 404 return getToolbarItemsOr(editor, 'quickbars_selection_toolbar', 'bold italic | quicklink h2 h3 blockquote'); 405 }; 406 var getInsertToolbarItems = function (editor) { 407 return getToolbarItemsOr(editor, 'quickbars_insert_toolbar', 'quickimage quicktable'); 408 }; 409 var getImageToolbarItems = function (editor) { 410 return getToolbarItemsOr(editor, 'quickbars_image_toolbar', 'alignleft aligncenter alignright'); 411 }; 412 413 var addToEditor$1 = function (editor) { 414 var insertToolbarItems = getInsertToolbarItems(editor); 415 if (insertToolbarItems.trim().length > 0) { 416 editor.ui.registry.addContextToolbar('quickblock', { 417 predicate: function (node) { 418 var sugarNode = SugarElement.fromDom(node); 419 var textBlockElementsMap = editor.schema.getTextBlockElements(); 420 var isRoot = function (elem) { 421 return elem.dom === editor.getBody(); 422 }; 423 return closest(sugarNode, 'table', isRoot).fold(function () { 424 return closest$1(sugarNode, function (elem) { 425 return name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom); 426 }, isRoot).isSome(); 427 }, never); 428 }, 429 items: insertToolbarItems, 430 position: 'line', 431 scope: 'editor' 432 }); 433 } 434 }; 435 436 var addToEditor = function (editor) { 437 var isEditable = function (node) { 438 return editor.dom.getContentEditableParent(node) !== 'false'; 439 }; 440 var isImage = function (node) { 441 return node.nodeName === 'IMG' || node.nodeName === 'FIGURE' && /image/i.test(node.className); 442 }; 443 var imageToolbarItems = getImageToolbarItems(editor); 444 if (imageToolbarItems.trim().length > 0) { 445 editor.ui.registry.addContextToolbar('imageselection', { 446 predicate: isImage, 447 items: imageToolbarItems, 448 position: 'node' 449 }); 450 } 451 var textToolbarItems = getTextSelectionToolbarItems(editor); 452 if (textToolbarItems.trim().length > 0) { 453 editor.ui.registry.addContextToolbar('textselection', { 454 predicate: function (node) { 455 return !isImage(node) && !editor.selection.isCollapsed() && isEditable(node); 456 }, 457 items: textToolbarItems, 458 position: 'selection', 459 scope: 'editor' 460 }); 461 } 462 }; 463 464 function Plugin () { 465 global$3.add('quickbars', function (editor) { 466 setupButtons(editor); 467 addToEditor$1(editor); 468 addToEditor(editor); 469 }); 470 } 471 472 Plugin(); 473 474 }());
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 |