tinymce-rails 8.5.0 → 8.5.1
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4486e9b8502a1b61f8387cdc3f0300a844abf2cb16b426f8acbec6284a5f72ba
|
|
4
|
+
data.tar.gz: 02e1bf5a2912e9a5d245fb430fa62045d0a95ce6074501865da930397eb3ecdb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44e191b0f1e9c580229074fd82e9947e8137e4643e7d0987ca30065dfbc7d06196a8d052b082cc6c340d5fe19080464708980c19b1994efcd957d75157ef110e
|
|
7
|
+
data.tar.gz: 529a035b4ff61d5f90f4136fd0fa9a861bd33f18b1b2adfda3ca53e52ca0cb220de66fe418b91364a93a0e0e790b47998f989f345082ce9e85be869d5657ea97
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TinyMCE version 8.5.
|
|
2
|
+
* TinyMCE version 8.5.1 (2026-05-19)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
(function () {
|
|
@@ -23996,7 +23996,7 @@
|
|
|
23996
23996
|
}
|
|
23997
23997
|
}
|
|
23998
23998
|
});
|
|
23999
|
-
// Convert comments to cdata
|
|
23999
|
+
// Convert comments to cdata
|
|
24000
24000
|
htmlParser.addNodeFilter('#comment', (nodes) => {
|
|
24001
24001
|
let i = nodes.length;
|
|
24002
24002
|
while (i--) {
|
|
@@ -24007,12 +24007,6 @@
|
|
|
24007
24007
|
node.type = 4;
|
|
24008
24008
|
node.value = dom.decode(value.replace(/^\[CDATA\[|\]\]$/g, ''));
|
|
24009
24009
|
}
|
|
24010
|
-
else if (value?.indexOf('mce:protected ') === 0) {
|
|
24011
|
-
node.name = '#text';
|
|
24012
|
-
node.type = 3;
|
|
24013
|
-
node.raw = true;
|
|
24014
|
-
node.value = unescape(value).substr(14);
|
|
24015
|
-
}
|
|
24016
24010
|
}
|
|
24017
24011
|
});
|
|
24018
24012
|
htmlParser.addNodeFilter('xml:namespace,input', (nodes, name) => {
|
|
@@ -30094,6 +30088,45 @@
|
|
|
30094
30088
|
});
|
|
30095
30089
|
};
|
|
30096
30090
|
|
|
30091
|
+
const setupInputFiltering = (editor, protect) => {
|
|
30092
|
+
editor.on('BeforeSetContent', (e) => {
|
|
30093
|
+
each$e(protect, (pattern) => {
|
|
30094
|
+
e.content = e.content.replace(pattern, (str) => {
|
|
30095
|
+
return '<!--mce:protected ' + escape(str) + '-->';
|
|
30096
|
+
});
|
|
30097
|
+
});
|
|
30098
|
+
});
|
|
30099
|
+
};
|
|
30100
|
+
const setupOutputFiltering = (editor, protect) => {
|
|
30101
|
+
editor.serializer.addNodeFilter('#comment', (nodes) => {
|
|
30102
|
+
let i = nodes.length;
|
|
30103
|
+
while (i--) {
|
|
30104
|
+
const node = nodes[i];
|
|
30105
|
+
const value = node.value;
|
|
30106
|
+
if (value?.indexOf('mce:protected ') === 0) {
|
|
30107
|
+
const protectedHtml = unescape(value).substr(14);
|
|
30108
|
+
const valid = exists(protect, (pattern) => {
|
|
30109
|
+
const matches = protectedHtml.match(pattern);
|
|
30110
|
+
return matches !== null && matches[0].length === protectedHtml.length;
|
|
30111
|
+
});
|
|
30112
|
+
if (valid) {
|
|
30113
|
+
node.name = '#text';
|
|
30114
|
+
node.type = 3;
|
|
30115
|
+
node.raw = true;
|
|
30116
|
+
node.value = protectedHtml;
|
|
30117
|
+
}
|
|
30118
|
+
else {
|
|
30119
|
+
node.remove();
|
|
30120
|
+
}
|
|
30121
|
+
}
|
|
30122
|
+
}
|
|
30123
|
+
});
|
|
30124
|
+
};
|
|
30125
|
+
const registerProtectedHtmlFilters = (editor, protect) => {
|
|
30126
|
+
setupInputFiltering(editor, protect);
|
|
30127
|
+
setupOutputFiltering(editor, protect);
|
|
30128
|
+
};
|
|
30129
|
+
|
|
30097
30130
|
/**
|
|
30098
30131
|
* This module shows the invisible block that the caret is currently in when contents is added to that block.
|
|
30099
30132
|
*/
|
|
@@ -36730,6 +36763,11 @@
|
|
|
36730
36763
|
};
|
|
36731
36764
|
const createParser = (editor) => {
|
|
36732
36765
|
const parser = DomParser(mkParserSettings(editor), editor.schema);
|
|
36766
|
+
parser.addAttributeFilter('data-mce-src,data-mce-href,data-mce-style', (nodes, name) => {
|
|
36767
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
36768
|
+
nodes[i].attr(name, null);
|
|
36769
|
+
}
|
|
36770
|
+
});
|
|
36733
36771
|
// Convert src and href into data-mce-src, data-mce-href and data-mce-style
|
|
36734
36772
|
parser.addAttributeFilter('src,href,style,tabindex', (nodes, name) => {
|
|
36735
36773
|
const dom = editor.dom;
|
|
@@ -36916,13 +36954,7 @@
|
|
|
36916
36954
|
}
|
|
36917
36955
|
const protect = getProtect(editor);
|
|
36918
36956
|
if (protect) {
|
|
36919
|
-
editor
|
|
36920
|
-
Tools.each(protect, (pattern) => {
|
|
36921
|
-
e.content = e.content.replace(pattern, (str) => {
|
|
36922
|
-
return '<!--mce:protected ' + escape(str) + '-->';
|
|
36923
|
-
});
|
|
36924
|
-
});
|
|
36925
|
-
});
|
|
36957
|
+
registerProtectedHtmlFilters(editor, protect);
|
|
36926
36958
|
}
|
|
36927
36959
|
editor.on('SetContent', () => {
|
|
36928
36960
|
editor.addVisual(editor.getBody());
|
|
@@ -40745,14 +40777,14 @@
|
|
|
40745
40777
|
* @property minorVersion
|
|
40746
40778
|
* @type String
|
|
40747
40779
|
*/
|
|
40748
|
-
minorVersion: '5.
|
|
40780
|
+
minorVersion: '5.1',
|
|
40749
40781
|
/**
|
|
40750
40782
|
* Release date of TinyMCE build.
|
|
40751
40783
|
*
|
|
40752
40784
|
* @property releaseDate
|
|
40753
40785
|
* @type String
|
|
40754
40786
|
*/
|
|
40755
|
-
releaseDate: '2026-
|
|
40787
|
+
releaseDate: '2026-05-19',
|
|
40756
40788
|
/**
|
|
40757
40789
|
* Collection of language pack data.
|
|
40758
40790
|
*
|
|
@@ -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)))}();
|