Rev 637 | Rev 759 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 637 | Rev 679 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
3 | * Licensed under the LGPL or a commercial license. |
3 | * Licensed under the LGPL or a commercial license. |
4 | * For LGPL see License.txt in the project root for license information. |
4 | * For LGPL see License.txt in the project root for license information. |
5 | * For commercial licenses see https://www.tiny.cloud/ |
5 | * For commercial licenses see https://www.tiny.cloud/ |
6 | * |
6 | * |
7 | * Version: 5.9.2 (2021-09-08) |
7 | * Version: 5.10.2 (2021-11-17) |
8 | */ |
8 | */ |
9 | (function () { |
9 | (function () { |
10 | 'use strict'; |
10 | 'use strict'; |
11 | 11 | ||
12 | var global$9 = tinymce.util.Tools.resolve('tinymce.PluginManager'); |
12 | var global$9 = tinymce.util.Tools.resolve('tinymce.PluginManager'); |
Line 663... | Line 663... | ||
663 | return getVideoHtml(data, videoTemplateCallback); |
663 | return getVideoHtml(data, videoTemplateCallback); |
664 | } |
664 | } |
665 | } |
665 | } |
666 | }; |
666 | }; |
667 | 667 | ||
- | 668 | var isMediaElement = function (element) { |
|
- | 669 | return element.hasAttribute('data-mce-object') || element.hasAttribute('data-ephox-embed-iri'); |
|
- | 670 | }; |
|
- | 671 | var setup$2 = function (editor) { |
|
- | 672 | editor.on('click keyup touchend', function () { |
|
- | 673 | var selectedNode = editor.selection.getNode(); |
|
- | 674 | if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) { |
|
- | 675 | if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) { |
|
- | 676 | selectedNode.setAttribute('data-mce-selected', '2'); |
|
- | 677 | } |
|
- | 678 | } |
|
- | 679 | }); |
|
- | 680 | editor.on('ObjectSelected', function (e) { |
|
- | 681 | var objectType = e.target.getAttribute('data-mce-object'); |
|
- | 682 | if (objectType === 'script') { |
|
- | 683 | e.preventDefault(); |
|
- | 684 | } |
|
- | 685 | }); |
|
- | 686 | editor.on('ObjectResized', function (e) { |
|
- | 687 | var target = e.target; |
|
- | 688 | if (target.getAttribute('data-mce-object')) { |
|
- | 689 | var html = target.getAttribute('data-mce-html'); |
|
- | 690 | if (html) { |
|
- | 691 | html = unescape(html); |
|
- | 692 | target.setAttribute('data-mce-html', escape(updateHtml(html, { |
|
- | 693 | width: String(e.width), |
|
- | 694 | height: String(e.height) |
|
- | 695 | }))); |
|
- | 696 | } |
|
- | 697 | } |
|
- | 698 | }); |
|
- | 699 | }; |
|
- | 700 | ||
668 | var global$3 = tinymce.util.Tools.resolve('tinymce.util.Promise'); |
701 | var global$3 = tinymce.util.Tools.resolve('tinymce.util.Promise'); |
669 | 702 | ||
670 | var cache = {}; |
703 | var cache = {}; |
671 | var embedPromise = function (data, dataToHtml, handler) { |
704 | var embedPromise = function (data, dataToHtml, handler) { |
672 | return new global$3(function (res, rej) { |
705 | return new global$3(function (res, rej) { |
Line 790... | Line 823... | ||
790 | }; |
823 | }; |
791 | }; |
824 | }; |
792 | var snippetToData = function (editor, embedSnippet) { |
825 | var snippetToData = function (editor, embedSnippet) { |
793 | return htmlToData(getScripts(editor), embedSnippet); |
826 | return htmlToData(getScripts(editor), embedSnippet); |
794 | }; |
827 | }; |
795 | var isMediaElement = function (element) { |
- | |
796 | return element.hasAttribute('data-mce-object') || element.hasAttribute('data-ephox-embed-iri'); |
- | |
797 | }; |
- | |
798 | var getEditorData = function (editor) { |
828 | var getEditorData = function (editor) { |
799 | var element = editor.selection.getNode(); |
829 | var element = editor.selection.getNode(); |
800 | var snippet = isMediaElement(element) ? editor.serializer.serialize(element, { selection: true }) : ''; |
830 | var snippet = isMediaElement(element) ? editor.serializer.serialize(element, { selection: true }) : ''; |
801 | return __assign({ embed: snippet }, htmlToData(getScripts(editor), snippet)); |
831 | return __assign({ embed: snippet }, htmlToData(getScripts(editor), snippet)); |
802 | }; |
832 | }; |
Line 1126... | Line 1156... | ||
1126 | each$1(attrs, function (attrName) { |
1156 | each$1(attrs, function (attrName) { |
1127 | previewNode.attr(attrName, node.attr(attrName)); |
1157 | previewNode.attr(attrName, node.attr(attrName)); |
1128 | }); |
1158 | }); |
1129 | var sanitizedHtml = previewWrapper.attr('data-mce-html'); |
1159 | var sanitizedHtml = previewWrapper.attr('data-mce-html'); |
1130 | if (isNonNullable(sanitizedHtml)) { |
1160 | if (isNonNullable(sanitizedHtml)) { |
1131 | appendNodeContent(editor, name, previewNode, sanitizedHtml); |
1161 | appendNodeContent(editor, name, previewNode, unescape(sanitizedHtml)); |
1132 | } |
1162 | } |
1133 | } |
1163 | } |
1134 | var shimNode = new global$2('span', 1); |
1164 | var shimNode = new global$2('span', 1); |
1135 | shimNode.attr('class', 'mce-shim'); |
1165 | shimNode.attr('class', 'mce-shim'); |
1136 | previewWrapper.append(previewNode); |
1166 | previewWrapper.append(previewNode); |
Line 1206... | Line 1236... | ||
1206 | } |
1236 | } |
1207 | } |
1237 | } |
1208 | }; |
1238 | }; |
1209 | }; |
1239 | }; |
1210 | 1240 | ||
1211 | var setup$2 = function (editor) { |
1241 | var setup$1 = function (editor) { |
1212 | editor.on('preInit', function () { |
1242 | editor.on('preInit', function () { |
1213 | var specialElements = editor.schema.getSpecialElements(); |
1243 | var specialElements = editor.schema.getSpecialElements(); |
1214 | global$8.each('video audio iframe object'.split(' '), function (name) { |
1244 | global$8.each('video audio iframe object'.split(' '), function (name) { |
1215 | specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi'); |
1245 | specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi'); |
1216 | }); |
1246 | }); |
Line 1281... | Line 1311... | ||
1281 | } |
1311 | } |
1282 | }); |
1312 | }); |
1283 | }); |
1313 | }); |
1284 | }; |
1314 | }; |
1285 | 1315 | ||
1286 | var setup$1 = function (editor) { |
1316 | var setup = function (editor) { |
1287 | editor.on('ResolveName', function (e) { |
1317 | editor.on('ResolveName', function (e) { |
1288 | var name; |
1318 | var name; |
1289 | if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) { |
1319 | if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) { |
1290 | e.name = name; |
1320 | e.name = name; |
1291 | } |
1321 | } |
1292 | }); |
1322 | }); |
1293 | }; |
1323 | }; |
1294 | 1324 | ||
1295 | var setup = function (editor) { |
- | |
1296 | editor.on('click keyup touchend', function () { |
- | |
1297 | var selectedNode = editor.selection.getNode(); |
- | |
1298 | if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) { |
- | |
1299 | if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) { |
- | |
1300 | selectedNode.setAttribute('data-mce-selected', '2'); |
- | |
1301 | } |
- | |
1302 | } |
- | |
1303 | }); |
- | |
1304 | editor.on('ObjectSelected', function (e) { |
- | |
1305 | var objectType = e.target.getAttribute('data-mce-object'); |
- | |
1306 | if (objectType === 'script') { |
- | |
1307 | e.preventDefault(); |
- | |
1308 | } |
- | |
1309 | }); |
- | |
1310 | editor.on('ObjectResized', function (e) { |
- | |
1311 | var target = e.target; |
- | |
1312 | if (target.getAttribute('data-mce-object')) { |
- | |
1313 | var html = target.getAttribute('data-mce-html'); |
- | |
1314 | if (html) { |
- | |
1315 | html = unescape(html); |
- | |
1316 | target.setAttribute('data-mce-html', escape(updateHtml(html, { |
- | |
1317 | width: String(e.width), |
- | |
1318 | height: String(e.height) |
- | |
1319 | }))); |
- | |
1320 | } |
- | |
1321 | } |
- | |
1322 | }); |
- | |
1323 | }; |
- | |
1324 | - | ||
1325 | var stateSelectorAdapter = function (editor, selector) { |
- | |
1326 | return function (buttonApi) { |
- | |
1327 | return editor.selection.selectorChangedWithUnbind(selector.join(','), buttonApi.setActive).unbind; |
- | |
1328 | }; |
- | |
1329 | }; |
- | |
1330 | var register = function (editor) { |
1325 | var register = function (editor) { |
1331 | var onAction = function () { |
1326 | var onAction = function () { |
1332 | return editor.execCommand('mceMedia'); |
1327 | return editor.execCommand('mceMedia'); |
1333 | }; |
1328 | }; |
1334 | editor.ui.registry.addToggleButton('media', { |
1329 | editor.ui.registry.addToggleButton('media', { |
1335 | tooltip: 'Insert/edit media', |
1330 | tooltip: 'Insert/edit media', |
1336 | icon: 'embed', |
1331 | icon: 'embed', |
1337 | onAction: onAction, |
1332 | onAction: onAction, |
1338 | onSetup: stateSelectorAdapter(editor, [ |
1333 | onSetup: function (buttonApi) { |
1339 | 'img[data-mce-object]', |
1334 | var selection = editor.selection; |
1340 | 'span[data-mce-object]', |
1335 | buttonApi.setActive(isMediaElement(selection.getNode())); |
1341 | 'div[data-ephox-embed-iri]' |
1336 | return selection.selectorChangedWithUnbind('img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]', buttonApi.setActive).unbind; |
1342 | ]) |
1337 | } |
1343 | }); |
1338 | }); |
1344 | editor.ui.registry.addMenuItem('media', { |
1339 | editor.ui.registry.addMenuItem('media', { |
1345 | icon: 'embed', |
1340 | icon: 'embed', |
1346 | text: 'Media...', |
1341 | text: 'Media...', |
1347 | onAction: onAction |
1342 | onAction: onAction |
Line 1350... | Line 1345... | ||
1350 | 1345 | ||
1351 | function Plugin () { |
1346 | function Plugin () { |
1352 | global$9.add('media', function (editor) { |
1347 | global$9.add('media', function (editor) { |
1353 | register$1(editor); |
1348 | register$1(editor); |
1354 | register(editor); |
1349 | register(editor); |
- | 1350 | setup(editor); |
|
1355 | setup$1(editor); |
1351 | setup$1(editor); |
1356 | setup$2(editor); |
1352 | setup$2(editor); |
1357 | setup(editor); |
- | |
1358 | return get(editor); |
1353 | return get(editor); |
1359 | }); |
1354 | }); |
1360 | } |
1355 | } |
1361 | 1356 | ||
1362 | Plugin(); |
1357 | Plugin(); |