@bobfrankston/rmfmail 1.1.225 → 1.1.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/compose/compose.bundle.js +22 -10
- package/client/compose/compose.bundle.js.map +2 -2
- package/client/lib/rmf-tiny.js +35 -10
- package/client/lib/tinymce/CHANGELOG.md +12 -0
- package/client/lib/tinymce/composer.json +1 -1
- package/client/lib/tinymce/models/dom/model.js +1 -1
- package/client/lib/tinymce/package.json +1 -1
- package/client/lib/tinymce/plugins/accordion/plugin.js +1 -1
- package/client/lib/tinymce/plugins/advlist/plugin.js +1 -1
- package/client/lib/tinymce/plugins/anchor/plugin.js +1 -1
- package/client/lib/tinymce/plugins/autolink/plugin.js +1 -1
- package/client/lib/tinymce/plugins/autoresize/plugin.js +1 -1
- package/client/lib/tinymce/plugins/autosave/plugin.js +1 -1
- package/client/lib/tinymce/plugins/charmap/plugin.js +1 -1
- package/client/lib/tinymce/plugins/code/plugin.js +1 -1
- package/client/lib/tinymce/plugins/codesample/plugin.js +1 -1
- package/client/lib/tinymce/plugins/directionality/plugin.js +1 -1
- package/client/lib/tinymce/plugins/emoticons/plugin.js +1 -1
- package/client/lib/tinymce/plugins/fullscreen/plugin.js +1 -1
- package/client/lib/tinymce/plugins/help/plugin.js +1 -1
- package/client/lib/tinymce/plugins/image/plugin.js +1 -1
- package/client/lib/tinymce/plugins/importcss/plugin.js +1 -1
- package/client/lib/tinymce/plugins/insertdatetime/plugin.js +1 -1
- package/client/lib/tinymce/plugins/link/plugin.js +1 -1
- package/client/lib/tinymce/plugins/lists/plugin.js +1 -1
- package/client/lib/tinymce/plugins/media/plugin.js +66 -41
- package/client/lib/tinymce/plugins/media/plugin.min.js +1 -1
- package/client/lib/tinymce/plugins/nonbreaking/plugin.js +1 -1
- package/client/lib/tinymce/plugins/pagebreak/plugin.js +1 -1
- package/client/lib/tinymce/plugins/preview/plugin.js +1 -1
- package/client/lib/tinymce/plugins/quickbars/plugin.js +1 -1
- package/client/lib/tinymce/plugins/save/plugin.js +1 -1
- package/client/lib/tinymce/plugins/searchreplace/plugin.js +1 -1
- package/client/lib/tinymce/plugins/table/plugin.js +1 -1
- package/client/lib/tinymce/plugins/visualblocks/plugin.js +1 -1
- package/client/lib/tinymce/plugins/visualchars/plugin.js +1 -1
- package/client/lib/tinymce/plugins/wordcount/plugin.js +1 -1
- package/client/lib/tinymce/themes/silver/theme.js +345 -155
- package/client/lib/tinymce/themes/silver/theme.min.js +3 -1
- package/client/lib/tinymce/tinymce.js +393 -171
- package/client/lib/tinymce/tinymce.min.js +4 -2
- package/docs/outlook.md +215 -0
- package/package.json +3 -3
- /package/packages/mailx-imap/{node_modules.npmglobalize-stash-62732 → node_modules.npmglobalize-stash-126048}/.package-lock.json +0 -0
package/client/lib/rmf-tiny.js
CHANGED
|
@@ -284,17 +284,20 @@ export async function createTinyMceEditor(container, opts = {}) {
|
|
|
284
284
|
// of our editor CSS. Bob 2026-05-31.
|
|
285
285
|
const BORDER_STYLES = { "border": "1px solid #888", "border-radius": "4px", "padding": "10px" };
|
|
286
286
|
const openCodeDialog = () => {
|
|
287
|
-
const cs = ed.plugins.codesample;
|
|
288
287
|
const preEl = ed.dom.getParent(ed.selection.getNode(), "pre");
|
|
289
288
|
let curLang = "text";
|
|
290
289
|
let curBorder = false;
|
|
290
|
+
let curCode = "";
|
|
291
291
|
if (preEl) {
|
|
292
292
|
const m = (preEl.className || "").match(/language-([\w-]+)/);
|
|
293
293
|
if (m)
|
|
294
294
|
curLang = m[1];
|
|
295
295
|
curBorder = !!(preEl.style && preEl.style.border && preEl.style.border !== "none");
|
|
296
|
+
// Read existing code straight off the DOM — don't depend on
|
|
297
|
+
// the codesample plugin's internal getCurrentCode (its API
|
|
298
|
+
// shape isn't stable across TinyMCE versions).
|
|
299
|
+
curCode = preEl.textContent || "";
|
|
296
300
|
}
|
|
297
|
-
const curCode = (cs && cs.getCurrentCode) ? (cs.getCurrentCode(ed) || "") : "";
|
|
298
301
|
ed.windowManager.open({
|
|
299
302
|
title: "Insert code",
|
|
300
303
|
size: "large",
|
|
@@ -313,15 +316,26 @@ export async function createTinyMceEditor(container, opts = {}) {
|
|
|
313
316
|
],
|
|
314
317
|
onSubmit: (api) => {
|
|
315
318
|
const data = api.getData();
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
319
|
+
const lang = data.language || "text";
|
|
320
|
+
const esc = (s) => String(s)
|
|
321
|
+
.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
322
|
+
const borderStyle = data.border
|
|
323
|
+
? ` style="${Object.entries(BORDER_STYLES).map(([k, v]) => `${k}:${v}`).join(";")}"`
|
|
324
|
+
: "";
|
|
325
|
+
// Build the block and insert it directly. The previous
|
|
326
|
+
// path called the codesample plugin's internal
|
|
327
|
+
// `insertCodeSample`, which silently inserted NOTHING on
|
|
328
|
+
// the current TinyMCE (Bob 2026-06-06 "nothing got
|
|
329
|
+
// inserted"). Direct insertContent / setOuterHTML is
|
|
330
|
+
// version-independent and can't silently no-op.
|
|
331
|
+
const html = `<pre class="language-${lang}"${borderStyle}><code>${esc(data.code || "")}</code></pre>`;
|
|
332
|
+
if (preEl && preEl.parentNode) {
|
|
333
|
+
ed.dom.setOuterHTML(preEl, html); // editing an existing block
|
|
324
334
|
}
|
|
335
|
+
else {
|
|
336
|
+
ed.insertContent(html); // fresh insert
|
|
337
|
+
}
|
|
338
|
+
ed.undoManager.add(); // snapshot + fire AddUndo → draft save
|
|
325
339
|
api.close();
|
|
326
340
|
},
|
|
327
341
|
});
|
|
@@ -506,6 +520,17 @@ export async function createTinyMceEditor(container, opts = {}) {
|
|
|
506
520
|
setHtml(html) { editor.setContent(html); },
|
|
507
521
|
getHtml() { return editor.getContent(); },
|
|
508
522
|
getText() { return editor.getContent({ format: "text" }); },
|
|
523
|
+
/** Subscribe to content changes. compose.ts calls this to drive draft
|
|
524
|
+
* auto-save; it was MISSING from the facade, so the call threw
|
|
525
|
+
* "editor.onContentChange is not a function" during compose init —
|
|
526
|
+
* aborting the rest of init and leaving change-tracking unwired, so
|
|
527
|
+
* edits made via dialogs (Insert code, Source code) were never
|
|
528
|
+
* captured into the draft and looked "ignored" (Bob 2026-06-06).
|
|
529
|
+
* `SetContent`/`ExecCommand` are the load-bearing events here: they're
|
|
530
|
+
* what the codesample + code (source) dialogs fire on apply. */
|
|
531
|
+
onContentChange(handler) {
|
|
532
|
+
editor.on("input change undo redo keyup SetContent ExecCommand AddUndo", () => handler());
|
|
533
|
+
},
|
|
509
534
|
focus() { editor.focus(); },
|
|
510
535
|
setCursor(pos) {
|
|
511
536
|
// TinyMCE works in ranges, not character indices. Map the
|
|
@@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
|
6
6
|
and is generated by [Changie](https://github.com/miniscruff/changie).
|
|
7
7
|
|
|
8
|
+
## 8.6.0 - 2026-06-03
|
|
9
|
+
|
|
10
|
+
### Security
|
|
11
|
+
- Updated DOMPurify version to 3.4.5. #TINY-14430
|
|
12
|
+
|
|
13
|
+
## 8.5.1 - 2026-05-19
|
|
14
|
+
|
|
15
|
+
### Security
|
|
16
|
+
- Fixed media plugin `data-mce-object` injection leading to stored XSS. #TINY-14357
|
|
17
|
+
- Fixed stored XSS vulnerability through `mce:protected` comments. #TINY-14353
|
|
18
|
+
- Fixed stored XSS vulnerability through `data-mce-` prefixed `src`, `href`, `style` attributes. #TINY-14333
|
|
19
|
+
|
|
8
20
|
## 8.5.0 - 2026-04-29
|
|
9
21
|
|
|
10
22
|
### Added
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TinyMCE version 8.
|
|
2
|
+
* TinyMCE version 8.6.0 (2026-06-03)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
(function () {
|
|
@@ -1287,13 +1287,74 @@
|
|
|
1287
1287
|
}
|
|
1288
1288
|
};
|
|
1289
1289
|
|
|
1290
|
-
const parseAndSanitize = (editor,
|
|
1290
|
+
const parseAndSanitize = (editor, html) => {
|
|
1291
1291
|
const getEditorOption = editor.options.get;
|
|
1292
1292
|
const sanitize = getEditorOption('xss_sanitization');
|
|
1293
1293
|
const validate = shouldFilterHtml(editor);
|
|
1294
|
-
return Parser(editor.schema, { sanitize, validate }).parse(html
|
|
1294
|
+
return Parser(editor.schema, { sanitize, validate }).parse(html);
|
|
1295
1295
|
};
|
|
1296
1296
|
|
|
1297
|
+
const buildMediaElement = (editor, node) => {
|
|
1298
|
+
const realElmName = node.attr('data-mce-object');
|
|
1299
|
+
const element = document.createElement(realElmName);
|
|
1300
|
+
// Add width/height to everything but audio
|
|
1301
|
+
if (realElmName !== 'audio') {
|
|
1302
|
+
const className = node.attr('class');
|
|
1303
|
+
const firstChild = node.firstChild;
|
|
1304
|
+
if (className && className.indexOf('mce-preview-object') !== -1 && firstChild) {
|
|
1305
|
+
const width = firstChild.attr('width');
|
|
1306
|
+
const height = firstChild.attr('height');
|
|
1307
|
+
if (isString(width)) {
|
|
1308
|
+
element.setAttribute('width', width);
|
|
1309
|
+
}
|
|
1310
|
+
if (isString(height)) {
|
|
1311
|
+
element.setAttribute('height', height);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
else {
|
|
1315
|
+
const width = node.attr('width');
|
|
1316
|
+
const height = node.attr('height');
|
|
1317
|
+
if (isString(width)) {
|
|
1318
|
+
element.setAttribute('width', width);
|
|
1319
|
+
}
|
|
1320
|
+
if (isString(height)) {
|
|
1321
|
+
element.setAttribute('height', height);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
const style = node.attr('style');
|
|
1326
|
+
if (isString(style)) {
|
|
1327
|
+
element.setAttribute('style', style);
|
|
1328
|
+
}
|
|
1329
|
+
// Unprefix all placeholder attributes
|
|
1330
|
+
const attribs = node.attributes ?? [];
|
|
1331
|
+
let ai = attribs.length;
|
|
1332
|
+
while (ai--) {
|
|
1333
|
+
const attrName = attribs[ai].name;
|
|
1334
|
+
if (attrName.indexOf('data-mce-p-') === 0) {
|
|
1335
|
+
element.setAttribute(attrName.substr(11), attribs[ai].value);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
// Inject innerhtml
|
|
1339
|
+
const innerHtml = node.attr('data-mce-html');
|
|
1340
|
+
if (isString(innerHtml)) {
|
|
1341
|
+
element.innerHTML = unescape(innerHtml);
|
|
1342
|
+
}
|
|
1343
|
+
else {
|
|
1344
|
+
element.innerHTML = '\u00a0';
|
|
1345
|
+
}
|
|
1346
|
+
const fragment = parseAndSanitize(editor, element.outerHTML);
|
|
1347
|
+
const newElement = fragment.getAll(realElmName)[0];
|
|
1348
|
+
if (isNonNullable(newElement)) {
|
|
1349
|
+
if (!isString(innerHtml)) {
|
|
1350
|
+
newElement.empty();
|
|
1351
|
+
}
|
|
1352
|
+
return Optional.some(newElement);
|
|
1353
|
+
}
|
|
1354
|
+
else {
|
|
1355
|
+
return Optional.none();
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1297
1358
|
const setup$1 = (editor) => {
|
|
1298
1359
|
editor.on('PreInit', () => {
|
|
1299
1360
|
const { schema, serializer, parser } = editor;
|
|
@@ -1317,50 +1378,14 @@
|
|
|
1317
1378
|
// Converts iframe, video etc into placeholder images
|
|
1318
1379
|
parser.addNodeFilter('iframe,video,audio,object,embed', placeHolderConverter(editor));
|
|
1319
1380
|
// Replaces placeholder images with real elements for video, object, iframe etc
|
|
1320
|
-
serializer.addAttributeFilter('data-mce-object', (nodes
|
|
1381
|
+
serializer.addAttributeFilter('data-mce-object', (nodes) => {
|
|
1321
1382
|
let i = nodes.length;
|
|
1322
1383
|
while (i--) {
|
|
1323
1384
|
const node = nodes[i];
|
|
1324
1385
|
if (!node.parent) {
|
|
1325
1386
|
continue;
|
|
1326
1387
|
}
|
|
1327
|
-
|
|
1328
|
-
const realElm = new global$2(realElmName, 1);
|
|
1329
|
-
// Add width/height to everything but audio
|
|
1330
|
-
if (realElmName !== 'audio') {
|
|
1331
|
-
const className = node.attr('class');
|
|
1332
|
-
if (className && className.indexOf('mce-preview-object') !== -1 && node.firstChild) {
|
|
1333
|
-
realElm.attr({
|
|
1334
|
-
width: node.firstChild.attr('width'),
|
|
1335
|
-
height: node.firstChild.attr('height')
|
|
1336
|
-
});
|
|
1337
|
-
}
|
|
1338
|
-
else {
|
|
1339
|
-
realElm.attr({
|
|
1340
|
-
width: node.attr('width'),
|
|
1341
|
-
height: node.attr('height')
|
|
1342
|
-
});
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
realElm.attr({
|
|
1346
|
-
style: node.attr('style')
|
|
1347
|
-
});
|
|
1348
|
-
// Unprefix all placeholder attributes
|
|
1349
|
-
const attribs = node.attributes ?? [];
|
|
1350
|
-
let ai = attribs.length;
|
|
1351
|
-
while (ai--) {
|
|
1352
|
-
const attrName = attribs[ai].name;
|
|
1353
|
-
if (attrName.indexOf('data-mce-p-') === 0) {
|
|
1354
|
-
realElm.attr(attrName.substr(11), attribs[ai].value);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
// Inject innerhtml
|
|
1358
|
-
const innerHtml = node.attr('data-mce-html');
|
|
1359
|
-
if (innerHtml) {
|
|
1360
|
-
const fragment = parseAndSanitize(editor, realElmName, unescape(innerHtml));
|
|
1361
|
-
each$1(fragment.children(), (child) => realElm.append(child));
|
|
1362
|
-
}
|
|
1363
|
-
node.replace(realElm);
|
|
1388
|
+
buildMediaElement(editor, node).fold(() => node.remove(), (realElm) => node.replace(realElm));
|
|
1364
1389
|
}
|
|
1365
1390
|
});
|
|
1366
1391
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(r=o=e,(a=String).prototype.isPrototypeOf(r)||o.constructor?.name===a.name)?"string":t;var r,o,a})(t)===e,r=t("string"),o=t("object"),a=t("array"),s=e=>!(e=>null==e)(e),i=e=>"function"==typeof e;class n{tag;value;static singletonNone=new n(!1);constructor(e,t){this.tag=e,this.value=t}static some(e){return new n(!0,e)}static none(){return n.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?n.some(e(this.value)):n.none()}bind(e){return this.tag?e(this.value):n.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:n.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(e??"Called getOrDie on None")}static from(e){return s(e)?n.some(e):n.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}Array.prototype.slice;const c=Array.prototype.push,l=(e,t)=>{for(let r=0,o=e.length;r<o;r++)t(e[r],r)},m=e=>{const t=[];for(let r=0,o=e.length;r<o;++r){if(!a(e[r]))throw new Error("Arr.flatten item "+r+" was not an array, input: "+e);c.apply(t,e[r])}return t};i(Array.from)&&Array.from;const u=Object.keys,d=Object.hasOwnProperty,h=(e,t)=>p(e,t)?n.from(e[t]):n.none(),p=(e,t)=>d.call(e,t),g=(e,t)=>((e,t)=>""===t||e.length>=t.length&&e.substr(0,0+t.length)===t)(e,t),b=e=>t=>t.options.get(e),w=b("audio_template_callback"),f=b("video_template_callback"),y=b("iframe_template_callback"),v=b("media_live_embeds"),x=b("media_filter_html"),_=b("media_url_resolver"),k=b("media_alt_source"),j=b("media_poster"),A=b("media_dimensions");var O=tinymce.util.Tools.resolve("tinymce.util.Tools"),S=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),$=tinymce.util.Tools.resolve("tinymce.html.DomParser");const C=S.DOM,T=e=>e.replace(/px$/,""),z=e=>{const t=e.attr("style"),r=t?C.parseStyle(t):{};return{type:"ephox-embed-iri",source:e.attr("data-ephox-embed-iri"),altsource:"",poster:"",width:h(r,"max-width").map(T).getOr(""),height:h(r,"max-height").map(T).getOr("")}},D=(e,t)=>{let r={};for(let o=$({validate:!1,forced_root_block:!1},t).parse(e);o;o=o.walk())if(1===o.type){const e=o.name;if(o.attr("data-ephox-embed-iri")){r=z(o);break}r.source||"param"!==e||(r.source=o.attr("movie")),"iframe"!==e&&"object"!==e&&"embed"!==e&&"video"!==e&&"audio"!==e||(r.type||(r.type=e),r=O.extend(o.attributes.map,r)),"source"===e&&(r.source?r.altsource||(r.altsource=o.attr("src")):r.source=o.attr("src")),"img"!==e||r.poster||(r.poster=o.attr("src"))}return r.source=r.source||r.src||"",r.altsource=r.altsource||"",r.poster=r.poster||"",r},F=e=>{const t=e.toLowerCase().split(".").pop()??"";return h({mp3:"audio/mpeg",m4a:"audio/x-m4a",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"},t).getOr("")};var M=tinymce.util.Tools.resolve("tinymce.html.Node"),N=tinymce.util.Tools.resolve("tinymce.html.Serializer");const P=(e,t={})=>$({forced_root_block:!1,validate:!1,allow_conditional_comments:!0,...t},e),R=S.DOM,E=e=>/^[0-9.]+$/.test(e)?e+"px":e,U=(e,t)=>{const r=t.attr("style"),o=r?R.parseStyle(r):{};s(e.width)&&(o["max-width"]=E(e.width)),s(e.height)&&(o["max-height"]=E(e.height)),t.attr("style",R.serializeStyle(o))},L=["source","altsource"],I=(e,t,r,o)=>{let a=0,s=0;const i=P(o);i.addNodeFilter("source",e=>a=e.length);const n=i.parse(e);for(let e=n;e;e=e.walk())if(1===e.type){const o=e.name;if(e.attr("data-ephox-embed-iri")){U(t,e);break}switch(o){case"video":case"object":case"embed":case"img":case"iframe":void 0!==t.height&&void 0!==t.width&&(e.attr("width",t.width),e.attr("height",t.height))}if(r)switch(o){case"video":e.attr("poster",t.poster),e.attr("src",null);for(let r=a;r<2;r++)if(t[L[r]]){const o=new M("source",1);o.attr("src",t[L[r]]),o.attr("type",t[L[r]+"mime"]||null),e.append(o)}break;case"iframe":e.attr("src",t.source);break;case"object":const r=e.getAll("img").length>0;if(t.poster&&!r){e.attr("src",t.poster);const r=new M("img",1);r.attr("src",t.poster),r.attr("width",t.width),r.attr("height",t.height),e.append(r)}break;case"source":if(s<2&&(e.attr("src",t[L[s]]),e.attr("type",t[L[s]+"mime"]||null),!t[L[s]])){e.remove();continue}s++;break;case"img":t.poster||e.remove()}}return N({},o).serialize(n)},B=[{regex:/youtu\.be\/([\w\-_\?&=.]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$2?$4",allowFullscreen:!0},{regex:/youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?h=$2&title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?h=$3&title=0&byline=0",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?title=0&byline=0",allowFullscreen:!0},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'maps.google.com/maps/ms?msid=$2&output=embed"',allowFullscreen:!1},{regex:/dailymotion\.com\/video\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0},{regex:/dai\.ly\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0}],G=(e,t)=>{const r=(e=>{const t=e.match(/^(https?:\/\/|www\.)(.+)$/i);return t&&t.length>1?"www."===t[1]?"https://":t[1]:"https://"})(t),o=e.regex.exec(t);let a=r+e.url;if(s(o))for(let e=0;e<o.length;e++)a=a.replace("$"+e,()=>o[e]?o[e]:"");return a.replace(/\?$/,"")},W=e=>{const t=B.filter(t=>t.regex.test(e));return t.length>0?O.extend({},t[0],{url:G(t[0],e)}):null},q=(e,t)=>{const r=O.extend({},t);if(!r.source&&(O.extend(r,D(r.embed??"",e.schema)),!r.source))return"";r.altsource||(r.altsource=""),r.poster||(r.poster=""),r.source=e.convertURL(r.source,"source"),r.altsource=e.convertURL(r.altsource,"source"),r.sourcemime=F(r.source),r.altsourcemime=F(r.altsource),r.poster=e.convertURL(r.poster,"poster");const o=W(r.source);if(o&&(r.source=o.url,r.type=o.type,r.allowfullscreen=o.allowFullscreen,r.width=r.width||String(o.w),r.height=r.height||String(o.h)),r.embed)return I(r.embed,r,!0,e.schema);{const t=w(e),o=f(e),a=y(e);return r.width=r.width||"300",r.height=r.height||"150",O.each(r,(t,o)=>{r[o]=e.dom.encode(""+t)}),"iframe"===r.type?((e,t)=>{if(t)return t(e);{const t=e.allowfullscreen?' allowFullscreen="1"':"";return'<iframe src="'+e.source+'" width="'+e.width+'" height="'+e.height+'"'+t+"></iframe>"}})(r,a):"application/x-shockwave-flash"===r.sourcemime?(e=>{let t='<object data="'+e.source+'" width="'+e.width+'" height="'+e.height+'" type="application/x-shockwave-flash">';return e.poster&&(t+='<img src="'+e.poster+'" width="'+e.width+'" height="'+e.height+'" />'),t+="</object>",t})(r):-1!==r.sourcemime.indexOf("audio")?((e,t)=>t?t(e):'<audio controls="controls" src="'+e.source+'">'+(e.altsource?'\n<source src="'+e.altsource+'"'+(e.altsourcemime?' type="'+e.altsourcemime+'"':"")+" />\n":"")+"</audio>")(r,t):((e,t)=>t?t(e):'<video width="'+e.width+'" height="'+e.height+'"'+(e.poster?' poster="'+e.poster+'"':"")+' controls="controls">\n<source src="'+e.source+'"'+(e.sourcemime?' type="'+e.sourcemime+'"':"")+" />\n"+(e.altsource?'<source src="'+e.altsource+'"'+(e.altsourcemime?' type="'+e.altsourcemime+'"':"")+" />\n":"")+"</video>")(r,o)}},H=e=>e.hasAttribute("data-mce-object")||e.hasAttribute("data-ephox-embed-iri"),J={},K=e=>t=>q(e,t),Q=(e,t)=>{const r=_(e);return r?((e,t,r)=>new Promise((o,a)=>{const s=r=>(r.html&&(J[e.source]=r),o({url:e.source,html:r.html?r.html:t(e)}));J[e.source]?s(J[e.source]):r({url:e.source}).then(s).catch(a)}))(t,K(e),r):((e,t)=>Promise.resolve({html:t(e),url:e.source}))(t,K(e))},V=(e,t)=>{const r={};return h(e,"dimensions").each(e=>{l(["width","height"],o=>{h(t,o).orThunk(()=>h(e,o)).each(e=>r[o]=e)})}),r},X=(e,t)=>{const r=t&&"dimensions"!==t?((e,t)=>h(t,e).bind(e=>h(e,"meta")))(t,e).getOr({}):{},a=((e,t,r)=>a=>{const s=()=>h(e,a),i=()=>h(t,a),c=e=>h(e,"value").bind(e=>e.length>0?n.some(e):n.none());return{[a]:(a===r?s().bind(e=>o(e)?c(e).orThunk(i):i().orThunk(()=>n.from(e))):i().orThunk(()=>s().bind(e=>o(e)?c(e):n.from(e)))).getOr("")}})(e,r,t);return{...a("source"),...a("altsource"),...a("poster"),...a("embed"),...V(e,r)}},Y=e=>{const t={...e,source:{value:h(e,"source").getOr("")},altsource:{value:h(e,"altsource").getOr("")},poster:{value:h(e,"poster").getOr("")}};return l(["width","height"],r=>{h(e,r).each(e=>{const o=t.dimensions||{};o[r]=e,t.dimensions=o})}),t},Z=e=>t=>{const r=t&&t.msg?"Media embed handler error: "+t.msg:"Media embed handler threw unknown error.";e.notificationManager.open({type:"error",text:r})},ee=(e,t)=>o=>{if(r(o.url)&&o.url.trim().length>0){const r=o.html,a={...D(r,t.schema),source:o.url,embed:r};e.setData(Y(a))}},te=(e,t)=>{const r=e.dom.select("*[data-mce-object]");e.insertContent(t),((e,t)=>{const r=e.dom.select("*[data-mce-object]");for(let e=0;e<t.length;e++)for(let o=r.length-1;o>=0;o--)t[e]===r[o]&&r.splice(o,1);e.selection.select(r[0])})(e,r),e.nodeChanged()},re=(e,t)=>s(t)&&"ephox-embed-iri"===t&&s(W(e)),oe=(e,t)=>((e,t)=>e.width!==t.width||e.height!==t.height)(e,t)&&re(t.source,e.type),ae=e=>{const t=(e=>{const t=e.selection.getNode(),r=H(t)?e.serializer.serialize(t,{selection:!0}):"",o=D(r,e.schema),a=(()=>{if(re(o.source,o.type)){const r=e.dom.getRect(t);return{width:r.w.toString().replace(/px$/,""),height:r.h.toString().replace(/px$/,"")}}return{}})();return{embed:r,...o,...a}})(e),r=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})(t),o=Y(t),a=A(e)?[{type:"sizeinput",name:"dimensions",label:"Constrain proportions",constrain:!0}]:[],s={title:"General",name:"general",items:m([[{name:"source",type:"urlinput",filetype:"media",label:"Source",picker_text:"Browse files"}],a])},i=[];k(e)&&i.push({name:"altsource",type:"urlinput",filetype:"media",label:"Alternative source URL"}),j(e)&&i.push({name:"poster",type:"urlinput",filetype:"image",label:"Media poster (Image URL)"});const n={title:"Advanced",name:"advanced",items:i},c=[s,{title:"Embed",items:[{type:"textarea",name:"embed",label:"Paste your embed code below:"}]}];i.length>0&&c.push(n);const l={type:"tabpanel",tabs:c},u=e.windowManager.open({title:"Insert/Edit Media",size:"normal",body:l,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{const o=X(t.getData());((e,t,r)=>{var o;t.embed=oe(e,t)&&A(r)?q(r,{...t,embed:""}):I(t.embed??"",t,!1,r.schema),t.embed&&(e.source===t.source||(o=t.source,p(J,o)))?te(r,t.embed):Q(r,t).then(e=>{te(r,e.html)}).catch(Z(r))})(r.get(),o,e),t.close()},onChange:(t,o)=>{switch(o.name){case"source":((t,r)=>{const o=X(r.getData(),"source");t.source!==o.source&&(ee(u,e)({url:o.source,html:""}),Q(e,o).then(ee(u,e)).catch(Z(e)))})(r.get(),t);break;case"embed":(t=>{const r=X(t.getData()),o=D(r.embed??"",e.schema);t.setData(Y(o))})(t);break;case"dimensions":case"altsource":case"poster":((t,r,o)=>{const a=X(t.getData(),r),s=oe(o,a)&&A(e)?{...a,embed:""}:a,i=q(e,s);t.setData(Y({...s,embed:i}))})(t,o.name,r.get())}r.set(X(t.getData()))},initialData:o})};var se=tinymce.util.Tools.resolve("tinymce.Env");const ie=e=>{const t=e.name;return"iframe"===t||"video"===t||"audio"===t},ne=(e,t,r,o=null)=>{const a=e.attr(r);return s(a)?a:p(t,r)?null:o},ce=(e,t,r)=>{const o="img"===t.name||"video"===e.name,a=o?"300":null,s="audio"===e.name?"30":"150",i=o?s:null;t.attr({width:ne(e,r,"width",a),height:ne(e,r,"height",i)})},le=(e,t)=>{const r=t.name,o=new M("img",1);return ue(e,t,o),ce(t,o,{}),o.attr({style:t.attr("style"),src:se.transparentSrc,"data-mce-object":r,class:"mce-object mce-object-"+r}),o},me=(e,t)=>{const r=t.name,o=new M("span",1);o.attr({contentEditable:"false",style:t.attr("style"),"data-mce-object":r,class:"mce-preview-object mce-object-"+r}),ue(e,t,o);const a=e.dom.parseStyle(t.attr("style")??""),i=new M(r,1);if(ce(t,i,a),i.attr({src:t.attr("src"),style:t.attr("style"),class:t.attr("class")}),"iframe"===r)i.attr({allowfullscreen:t.attr("allowfullscreen"),frameborder:"0",sandbox:t.attr("sandbox"),referrerpolicy:t.attr("referrerpolicy")});else{l(["controls","crossorigin","currentTime","loop","muted","poster","preload"],e=>{i.attr(e,t.attr(e))});const a=o.attr("data-mce-html");s(a)&&((e,t,r,o)=>{const a=P(e.schema).parse(o,{context:t});for(;a.firstChild;)r.append(a.firstChild)})(e,r,i,unescape(a))}const n=new M("span",1);return n.attr("class","mce-shim"),o.append(i),o.append(n),o},ue=(e,t,r)=>{const o=t.attributes??[];let a=o.length;for(;a--;){const t=o[a].name;let s=o[a].value;"width"===t||"height"===t||"style"===t||g(t,"data-mce-")||("data"!==t&&"src"!==t||(s=e.convertURL(s,t)),r.attr("data-mce-p-"+t,s))}const s=N({inner:!0},e.schema),i=new M("div",1);l(t.children(),e=>i.append(e));const n=s.serialize(i);n&&(r.attr("data-mce-html",escape(n)),r.empty())},de=e=>{const t=e.attr("class");return r(t)&&/\btiny-pageembed\b/.test(t)},he=e=>{let t=e;for(;t=t.parent;)if(t.attr("data-ephox-embed-iri")||de(t))return!0;return!1},pe=(e,t,r)=>{const o=(0,e.options.get)("xss_sanitization"),a=x(e);return P(e.schema,{sanitize:o,validate:a}).parse(r,{context:t})},ge=e=>t=>{const r=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",r),r(),()=>{e.off("NodeChange",r)}};e.add("media",e=>((e=>{const t=e.options.register;t("audio_template_callback",{processor:"function"}),t("video_template_callback",{processor:"function"}),t("iframe_template_callback",{processor:"function"}),t("media_live_embeds",{processor:"boolean",default:!0}),t("media_filter_html",{processor:"boolean",default:!0}),t("media_url_resolver",{processor:"function"}),t("media_alt_source",{processor:"boolean",default:!0}),t("media_poster",{processor:"boolean",default:!0}),t("media_dimensions",{processor:"boolean",default:!0})})(e),(e=>{e.addCommand("mceMedia",()=>{ae(e)})})(e),(e=>{const t=()=>e.execCommand("mceMedia");e.ui.registry.addToggleButton("media",{tooltip:"Insert/edit media",icon:"embed",onAction:t,onSetup:t=>{const r=e.selection;t.setActive(H(r.getNode()));const o=r.selectorChangedWithUnbind("img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]",t.setActive).unbind,a=ge(e)(t);return()=>{o(),a()}}}),e.ui.registry.addMenuItem("media",{icon:"embed",text:"Media...",onAction:t,onSetup:ge(e)})})(e),(e=>{e.on("ResolveName",e=>{let t;1===e.target.nodeType&&(t=e.target.getAttribute("data-mce-object"))&&(e.name=t)})})(e),(e=>{e.on("PreInit",()=>{const{schema:t,serializer:r,parser:o}=e,a=t.getBoolAttrs();l("webkitallowfullscreen mozallowfullscreen".split(" "),e=>{a[e]={}}),((e,t)=>{const r=u(e);for(let o=0,a=r.length;o<a;o++){const a=r[o];t(e[a],a)}})({embed:["wmode"]},(e,r)=>{const o=t.getElementRule(r);o&&l(e,e=>{o.attributes[e]={},o.attributesOrder.push(e)})}),o.addNodeFilter("iframe,video,audio,object,embed",(e=>t=>{let r,o=t.length;for(;o--;)r=t[o],r.parent&&(r.parent.attr("data-mce-object")||(ie(r)&&v(e)?he(r)||r.replace(me(e,r)):he(r)||r.replace(le(e,r))))})(e)),r.addAttributeFilter("data-mce-object",(t,r)=>{let o=t.length;for(;o--;){const a=t[o];if(!a.parent)continue;const s=a.attr(r),i=new M(s,1);if("audio"!==s){const e=a.attr("class");e&&-1!==e.indexOf("mce-preview-object")&&a.firstChild?i.attr({width:a.firstChild.attr("width"),height:a.firstChild.attr("height")}):i.attr({width:a.attr("width"),height:a.attr("height")})}i.attr({style:a.attr("style")});const n=a.attributes??[];let c=n.length;for(;c--;){const e=n[c].name;0===e.indexOf("data-mce-p-")&&i.attr(e.substr(11),n[c].value)}const m=a.attr("data-mce-html");if(m){const t=pe(e,s,unescape(m));l(t.children(),e=>i.append(e))}a.replace(i)}})}),e.on("SetContent",()=>{const t=e.dom;l(t.select("span.mce-preview-object"),e=>{0===t.select("span.mce-shim",e).length&&t.add(e,"span",{class:"mce-shim"})})})})(e),(e=>{e.on("mousedown",t=>{const r=e.dom.getParent(t.target,".mce-preview-object");r&&"2"===e.dom.getAttrib(r,"data-mce-selected")&&t.stopImmediatePropagation()}),e.on("click keyup touchend",()=>{const t=e.selection.getNode();t&&e.dom.hasClass(t,"mce-preview-object")&&e.dom.getAttrib(t,"data-mce-selected")&&t.setAttribute("data-mce-selected","2")}),e.on("ObjectResized",t=>{const r=t.target;if(r.getAttribute("data-mce-object")){let o=r.getAttribute("data-mce-html");o&&(o=unescape(o),r.setAttribute("data-mce-html",escape(I(o,{width:String(t.width),height:String(t.height)},!1,e.schema))))}})})(e),(e=>({showDialog:()=>{ae(e)}}))(e)))}();
|
|
1
|
+
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(r=o=e,(a=String).prototype.isPrototypeOf(r)||o.constructor?.name===a.name)?"string":t;var r,o,a})(t)===e,r=t("string"),o=t("object"),a=t("array"),s=e=>!(e=>null==e)(e),i=e=>"function"==typeof e;class n{tag;value;static singletonNone=new n(!1);constructor(e,t){this.tag=e,this.value=t}static some(e){return new n(!0,e)}static none(){return n.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?n.some(e(this.value)):n.none()}bind(e){return this.tag?e(this.value):n.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:n.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(e??"Called getOrDie on None")}static from(e){return s(e)?n.some(e):n.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}Array.prototype.slice;const c=Array.prototype.push,l=(e,t)=>{for(let r=0,o=e.length;r<o;r++)t(e[r],r)},m=e=>{const t=[];for(let r=0,o=e.length;r<o;++r){if(!a(e[r]))throw new Error("Arr.flatten item "+r+" was not an array, input: "+e);c.apply(t,e[r])}return t};i(Array.from)&&Array.from;const u=Object.keys,d=Object.hasOwnProperty,h=(e,t)=>p(e,t)?n.from(e[t]):n.none(),p=(e,t)=>d.call(e,t),g=(e,t)=>((e,t)=>""===t||e.length>=t.length&&e.substr(0,0+t.length)===t)(e,t),b=e=>t=>t.options.get(e),w=b("audio_template_callback"),y=b("video_template_callback"),f=b("iframe_template_callback"),v=b("media_live_embeds"),x=b("media_filter_html"),_=b("media_url_resolver"),k=b("media_alt_source"),A=b("media_poster"),j=b("media_dimensions");var O=tinymce.util.Tools.resolve("tinymce.util.Tools"),S=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),$=tinymce.util.Tools.resolve("tinymce.html.DomParser");const T=S.DOM,C=e=>e.replace(/px$/,""),M=e=>{const t=e.attr("style"),r=t?T.parseStyle(t):{};return{type:"ephox-embed-iri",source:e.attr("data-ephox-embed-iri"),altsource:"",poster:"",width:h(r,"max-width").map(C).getOr(""),height:h(r,"max-height").map(C).getOr("")}},z=(e,t)=>{let r={};for(let o=$({validate:!1,forced_root_block:!1},t).parse(e);o;o=o.walk())if(1===o.type){const e=o.name;if(o.attr("data-ephox-embed-iri")){r=M(o);break}r.source||"param"!==e||(r.source=o.attr("movie")),"iframe"!==e&&"object"!==e&&"embed"!==e&&"video"!==e&&"audio"!==e||(r.type||(r.type=e),r=O.extend(o.attributes.map,r)),"source"===e&&(r.source?r.altsource||(r.altsource=o.attr("src")):r.source=o.attr("src")),"img"!==e||r.poster||(r.poster=o.attr("src"))}return r.source=r.source||r.src||"",r.altsource=r.altsource||"",r.poster=r.poster||"",r},D=e=>{const t=e.toLowerCase().split(".").pop()??"";return h({mp3:"audio/mpeg",m4a:"audio/x-m4a",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"},t).getOr("")};var F=tinymce.util.Tools.resolve("tinymce.html.Node"),N=tinymce.util.Tools.resolve("tinymce.html.Serializer");const E=(e,t={})=>$({forced_root_block:!1,validate:!1,allow_conditional_comments:!0,...t},e),L=S.DOM,P=e=>/^[0-9.]+$/.test(e)?e+"px":e,R=(e,t)=>{const r=t.attr("style"),o=r?L.parseStyle(r):{};s(e.width)&&(o["max-width"]=P(e.width)),s(e.height)&&(o["max-height"]=P(e.height)),t.attr("style",L.serializeStyle(o))},U=["source","altsource"],I=(e,t,r,o)=>{let a=0,s=0;const i=E(o);i.addNodeFilter("source",e=>a=e.length);const n=i.parse(e);for(let e=n;e;e=e.walk())if(1===e.type){const o=e.name;if(e.attr("data-ephox-embed-iri")){R(t,e);break}switch(o){case"video":case"object":case"embed":case"img":case"iframe":void 0!==t.height&&void 0!==t.width&&(e.attr("width",t.width),e.attr("height",t.height))}if(r)switch(o){case"video":e.attr("poster",t.poster),e.attr("src",null);for(let r=a;r<2;r++)if(t[U[r]]){const o=new F("source",1);o.attr("src",t[U[r]]),o.attr("type",t[U[r]+"mime"]||null),e.append(o)}break;case"iframe":e.attr("src",t.source);break;case"object":const r=e.getAll("img").length>0;if(t.poster&&!r){e.attr("src",t.poster);const r=new F("img",1);r.attr("src",t.poster),r.attr("width",t.width),r.attr("height",t.height),e.append(r)}break;case"source":if(s<2&&(e.attr("src",t[U[s]]),e.attr("type",t[U[s]+"mime"]||null),!t[U[s]])){e.remove();continue}s++;break;case"img":t.poster||e.remove()}}return N({},o).serialize(n)},B=[{regex:/youtu\.be\/([\w\-_\?&=.]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$2?$4",allowFullscreen:!0},{regex:/youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?h=$2&title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?h=$3&title=0&byline=0",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?title=0&byline=0",allowFullscreen:!0},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'maps.google.com/maps/ms?msid=$2&output=embed"',allowFullscreen:!1},{regex:/dailymotion\.com\/video\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0},{regex:/dai\.ly\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0}],H=(e,t)=>{const r=(e=>{const t=e.match(/^(https?:\/\/|www\.)(.+)$/i);return t&&t.length>1?"www."===t[1]?"https://":t[1]:"https://"})(t),o=e.regex.exec(t);let a=r+e.url;if(s(o))for(let e=0;e<o.length;e++)a=a.replace("$"+e,()=>o[e]?o[e]:"");return a.replace(/\?$/,"")},G=e=>{const t=B.filter(t=>t.regex.test(e));return t.length>0?O.extend({},t[0],{url:H(t[0],e)}):null},W=(e,t)=>{const r=O.extend({},t);if(!r.source&&(O.extend(r,z(r.embed??"",e.schema)),!r.source))return"";r.altsource||(r.altsource=""),r.poster||(r.poster=""),r.source=e.convertURL(r.source,"source"),r.altsource=e.convertURL(r.altsource,"source"),r.sourcemime=D(r.source),r.altsourcemime=D(r.altsource),r.poster=e.convertURL(r.poster,"poster");const o=G(r.source);if(o&&(r.source=o.url,r.type=o.type,r.allowfullscreen=o.allowFullscreen,r.width=r.width||String(o.w),r.height=r.height||String(o.h)),r.embed)return I(r.embed,r,!0,e.schema);{const t=w(e),o=y(e),a=f(e);return r.width=r.width||"300",r.height=r.height||"150",O.each(r,(t,o)=>{r[o]=e.dom.encode(""+t)}),"iframe"===r.type?((e,t)=>{if(t)return t(e);{const t=e.allowfullscreen?' allowFullscreen="1"':"";return'<iframe src="'+e.source+'" width="'+e.width+'" height="'+e.height+'"'+t+"></iframe>"}})(r,a):"application/x-shockwave-flash"===r.sourcemime?(e=>{let t='<object data="'+e.source+'" width="'+e.width+'" height="'+e.height+'" type="application/x-shockwave-flash">';return e.poster&&(t+='<img src="'+e.poster+'" width="'+e.width+'" height="'+e.height+'" />'),t+="</object>",t})(r):-1!==r.sourcemime.indexOf("audio")?((e,t)=>t?t(e):'<audio controls="controls" src="'+e.source+'">'+(e.altsource?'\n<source src="'+e.altsource+'"'+(e.altsourcemime?' type="'+e.altsourcemime+'"':"")+" />\n":"")+"</audio>")(r,t):((e,t)=>t?t(e):'<video width="'+e.width+'" height="'+e.height+'"'+(e.poster?' poster="'+e.poster+'"':"")+' controls="controls">\n<source src="'+e.source+'"'+(e.sourcemime?' type="'+e.sourcemime+'"':"")+" />\n"+(e.altsource?'<source src="'+e.altsource+'"'+(e.altsourcemime?' type="'+e.altsourcemime+'"':"")+" />\n":"")+"</video>")(r,o)}},q=e=>e.hasAttribute("data-mce-object")||e.hasAttribute("data-ephox-embed-iri"),J={},K=e=>t=>W(e,t),Q=(e,t)=>{const r=_(e);return r?((e,t,r)=>new Promise((o,a)=>{const s=r=>(r.html&&(J[e.source]=r),o({url:e.source,html:r.html?r.html:t(e)}));J[e.source]?s(J[e.source]):r({url:e.source}).then(s).catch(a)}))(t,K(e),r):((e,t)=>Promise.resolve({html:t(e),url:e.source}))(t,K(e))},V=(e,t)=>{const r={};return h(e,"dimensions").each(e=>{l(["width","height"],o=>{h(t,o).orThunk(()=>h(e,o)).each(e=>r[o]=e)})}),r},X=(e,t)=>{const r=t&&"dimensions"!==t?((e,t)=>h(t,e).bind(e=>h(e,"meta")))(t,e).getOr({}):{},a=((e,t,r)=>a=>{const s=()=>h(e,a),i=()=>h(t,a),c=e=>h(e,"value").bind(e=>e.length>0?n.some(e):n.none());return{[a]:(a===r?s().bind(e=>o(e)?c(e).orThunk(i):i().orThunk(()=>n.from(e))):i().orThunk(()=>s().bind(e=>o(e)?c(e):n.from(e)))).getOr("")}})(e,r,t);return{...a("source"),...a("altsource"),...a("poster"),...a("embed"),...V(e,r)}},Y=e=>{const t={...e,source:{value:h(e,"source").getOr("")},altsource:{value:h(e,"altsource").getOr("")},poster:{value:h(e,"poster").getOr("")}};return l(["width","height"],r=>{h(e,r).each(e=>{const o=t.dimensions||{};o[r]=e,t.dimensions=o})}),t},Z=e=>t=>{const r=t&&t.msg?"Media embed handler error: "+t.msg:"Media embed handler threw unknown error.";e.notificationManager.open({type:"error",text:r})},ee=(e,t)=>o=>{if(r(o.url)&&o.url.trim().length>0){const r=o.html,a={...z(r,t.schema),source:o.url,embed:r};e.setData(Y(a))}},te=(e,t)=>{const r=e.dom.select("*[data-mce-object]");e.insertContent(t),((e,t)=>{const r=e.dom.select("*[data-mce-object]");for(let e=0;e<t.length;e++)for(let o=r.length-1;o>=0;o--)t[e]===r[o]&&r.splice(o,1);e.selection.select(r[0])})(e,r),e.nodeChanged()},re=(e,t)=>s(t)&&"ephox-embed-iri"===t&&s(G(e)),oe=(e,t)=>((e,t)=>e.width!==t.width||e.height!==t.height)(e,t)&&re(t.source,e.type),ae=e=>{const t=(e=>{const t=e.selection.getNode(),r=q(t)?e.serializer.serialize(t,{selection:!0}):"",o=z(r,e.schema),a=(()=>{if(re(o.source,o.type)){const r=e.dom.getRect(t);return{width:r.w.toString().replace(/px$/,""),height:r.h.toString().replace(/px$/,"")}}return{}})();return{embed:r,...o,...a}})(e),r=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})(t),o=Y(t),a=j(e)?[{type:"sizeinput",name:"dimensions",label:"Constrain proportions",constrain:!0}]:[],s={title:"General",name:"general",items:m([[{name:"source",type:"urlinput",filetype:"media",label:"Source",picker_text:"Browse files"}],a])},i=[];k(e)&&i.push({name:"altsource",type:"urlinput",filetype:"media",label:"Alternative source URL"}),A(e)&&i.push({name:"poster",type:"urlinput",filetype:"image",label:"Media poster (Image URL)"});const n={title:"Advanced",name:"advanced",items:i},c=[s,{title:"Embed",items:[{type:"textarea",name:"embed",label:"Paste your embed code below:"}]}];i.length>0&&c.push(n);const l={type:"tabpanel",tabs:c},u=e.windowManager.open({title:"Insert/Edit Media",size:"normal",body:l,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{const o=X(t.getData());((e,t,r)=>{var o;t.embed=oe(e,t)&&j(r)?W(r,{...t,embed:""}):I(t.embed??"",t,!1,r.schema),t.embed&&(e.source===t.source||(o=t.source,p(J,o)))?te(r,t.embed):Q(r,t).then(e=>{te(r,e.html)}).catch(Z(r))})(r.get(),o,e),t.close()},onChange:(t,o)=>{switch(o.name){case"source":((t,r)=>{const o=X(r.getData(),"source");t.source!==o.source&&(ee(u,e)({url:o.source,html:""}),Q(e,o).then(ee(u,e)).catch(Z(e)))})(r.get(),t);break;case"embed":(t=>{const r=X(t.getData()),o=z(r.embed??"",e.schema);t.setData(Y(o))})(t);break;case"dimensions":case"altsource":case"poster":((t,r,o)=>{const a=X(t.getData(),r),s=oe(o,a)&&j(e)?{...a,embed:""}:a,i=W(e,s);t.setData(Y({...s,embed:i}))})(t,o.name,r.get())}r.set(X(t.getData()))},initialData:o})};var se=tinymce.util.Tools.resolve("tinymce.Env");const ie=e=>{const t=e.name;return"iframe"===t||"video"===t||"audio"===t},ne=(e,t,r,o=null)=>{const a=e.attr(r);return s(a)?a:p(t,r)?null:o},ce=(e,t,r)=>{const o="img"===t.name||"video"===e.name,a=o?"300":null,s="audio"===e.name?"30":"150",i=o?s:null;t.attr({width:ne(e,r,"width",a),height:ne(e,r,"height",i)})},le=(e,t)=>{const r=t.name,o=new F("img",1);return ue(e,t,o),ce(t,o,{}),o.attr({style:t.attr("style"),src:se.transparentSrc,"data-mce-object":r,class:"mce-object mce-object-"+r}),o},me=(e,t)=>{const r=t.name,o=new F("span",1);o.attr({contentEditable:"false",style:t.attr("style"),"data-mce-object":r,class:"mce-preview-object mce-object-"+r}),ue(e,t,o);const a=e.dom.parseStyle(t.attr("style")??""),i=new F(r,1);if(ce(t,i,a),i.attr({src:t.attr("src"),style:t.attr("style"),class:t.attr("class")}),"iframe"===r)i.attr({allowfullscreen:t.attr("allowfullscreen"),frameborder:"0",sandbox:t.attr("sandbox"),referrerpolicy:t.attr("referrerpolicy")});else{l(["controls","crossorigin","currentTime","loop","muted","poster","preload"],e=>{i.attr(e,t.attr(e))});const a=o.attr("data-mce-html");s(a)&&((e,t,r,o)=>{const a=E(e.schema).parse(o,{context:t});for(;a.firstChild;)r.append(a.firstChild)})(e,r,i,unescape(a))}const n=new F("span",1);return n.attr("class","mce-shim"),o.append(i),o.append(n),o},ue=(e,t,r)=>{const o=t.attributes??[];let a=o.length;for(;a--;){const t=o[a].name;let s=o[a].value;"width"===t||"height"===t||"style"===t||g(t,"data-mce-")||("data"!==t&&"src"!==t||(s=e.convertURL(s,t)),r.attr("data-mce-p-"+t,s))}const s=N({inner:!0},e.schema),i=new F("div",1);l(t.children(),e=>i.append(e));const n=s.serialize(i);n&&(r.attr("data-mce-html",escape(n)),r.empty())},de=e=>{const t=e.attr("class");return r(t)&&/\btiny-pageembed\b/.test(t)},he=e=>{let t=e;for(;t=t.parent;)if(t.attr("data-ephox-embed-iri")||de(t))return!0;return!1},pe=(e,t)=>{const o=t.attr("data-mce-object"),a=document.createElement(o);if("audio"!==o){const e=t.attr("class"),o=t.firstChild;if(e&&-1!==e.indexOf("mce-preview-object")&&o){const e=o.attr("width"),t=o.attr("height");r(e)&&a.setAttribute("width",e),r(t)&&a.setAttribute("height",t)}else{const e=t.attr("width"),o=t.attr("height");r(e)&&a.setAttribute("width",e),r(o)&&a.setAttribute("height",o)}}const i=t.attr("style");r(i)&&a.setAttribute("style",i);const c=t.attributes??[];let l=c.length;for(;l--;){const e=c[l].name;0===e.indexOf("data-mce-p-")&&a.setAttribute(e.substr(11),c[l].value)}const m=t.attr("data-mce-html");r(m)?a.innerHTML=unescape(m):a.innerHTML="\xa0";const u=((e,t)=>{const r=(0,e.options.get)("xss_sanitization"),o=x(e);return E(e.schema,{sanitize:r,validate:o}).parse(t)})(e,a.outerHTML),d=u.getAll(o)[0];return s(d)?(r(m)||d.empty(),n.some(d)):n.none()},ge=e=>t=>{const r=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",r),r(),()=>{e.off("NodeChange",r)}};e.add("media",e=>((e=>{const t=e.options.register;t("audio_template_callback",{processor:"function"}),t("video_template_callback",{processor:"function"}),t("iframe_template_callback",{processor:"function"}),t("media_live_embeds",{processor:"boolean",default:!0}),t("media_filter_html",{processor:"boolean",default:!0}),t("media_url_resolver",{processor:"function"}),t("media_alt_source",{processor:"boolean",default:!0}),t("media_poster",{processor:"boolean",default:!0}),t("media_dimensions",{processor:"boolean",default:!0})})(e),(e=>{e.addCommand("mceMedia",()=>{ae(e)})})(e),(e=>{const t=()=>e.execCommand("mceMedia");e.ui.registry.addToggleButton("media",{tooltip:"Insert/edit media",icon:"embed",onAction:t,onSetup:t=>{const r=e.selection;t.setActive(q(r.getNode()));const o=r.selectorChangedWithUnbind("img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]",t.setActive).unbind,a=ge(e)(t);return()=>{o(),a()}}}),e.ui.registry.addMenuItem("media",{icon:"embed",text:"Media...",onAction:t,onSetup:ge(e)})})(e),(e=>{e.on("ResolveName",e=>{let t;1===e.target.nodeType&&(t=e.target.getAttribute("data-mce-object"))&&(e.name=t)})})(e),(e=>{e.on("PreInit",()=>{const{schema:t,serializer:r,parser:o}=e,a=t.getBoolAttrs();l("webkitallowfullscreen mozallowfullscreen".split(" "),e=>{a[e]={}}),((e,t)=>{const r=u(e);for(let o=0,a=r.length;o<a;o++){const a=r[o];t(e[a],a)}})({embed:["wmode"]},(e,r)=>{const o=t.getElementRule(r);o&&l(e,e=>{o.attributes[e]={},o.attributesOrder.push(e)})}),o.addNodeFilter("iframe,video,audio,object,embed",(e=>t=>{let r,o=t.length;for(;o--;)r=t[o],r.parent&&(r.parent.attr("data-mce-object")||(ie(r)&&v(e)?he(r)||r.replace(me(e,r)):he(r)||r.replace(le(e,r))))})(e)),r.addAttributeFilter("data-mce-object",t=>{let r=t.length;for(;r--;){const o=t[r];o.parent&&pe(e,o).fold(()=>o.remove(),e=>o.replace(e))}})}),e.on("SetContent",()=>{const t=e.dom;l(t.select("span.mce-preview-object"),e=>{0===t.select("span.mce-shim",e).length&&t.add(e,"span",{class:"mce-shim"})})})})(e),(e=>{e.on("mousedown",t=>{const r=e.dom.getParent(t.target,".mce-preview-object");r&&"2"===e.dom.getAttrib(r,"data-mce-selected")&&t.stopImmediatePropagation()}),e.on("click keyup touchend",()=>{const t=e.selection.getNode();t&&e.dom.hasClass(t,"mce-preview-object")&&e.dom.getAttrib(t,"data-mce-selected")&&t.setAttribute("data-mce-selected","2")}),e.on("ObjectResized",t=>{const r=t.target;if(r.getAttribute("data-mce-object")){let o=r.getAttribute("data-mce-html");o&&(o=unescape(o),r.setAttribute("data-mce-html",escape(I(o,{width:String(t.width),height:String(t.height)},!1,e.schema))))}})})(e),(e=>({showDialog:()=>{ae(e)}}))(e)))}();
|