-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.min.js
More file actions
5 lines (5 loc) · 5.83 KB
/
plugin.min.js
File metadata and controls
5 lines (5 loc) · 5.83 KB
1
2
3
4
5
(()=>{var D=Object.defineProperty,P=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var k=(h,s,o)=>s in h?D(h,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):h[s]=o,v=(h,s)=>{for(var o in s||(s={}))M.call(s,o)&&k(h,o,s[o]);if(S)for(var o of S(s))A.call(s,o)&&k(h,o,s[o]);return h},y=(h,s)=>P(h,C(s));(function(s){"use strict";let o=["youtube","vimeo"];o.youtube={pattern:/youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-_]+)(?:\?|&)?(.+)?/i,api:"//www.youtube.com/embed/",options:[{name:"rel",type:"checkbox",text:"Show suggested videos when the video finishes"},{name:"controls",type:"checkbox",text:"Show player controls"},{name:"showinfo",type:"checkbox",text:"Show video title and player actions"}]},o.vimeo={pattern:/(?:player.)?vimeo.com\/(?:video\/)?([0-9]+)(?:\?|&)?(.+)?/,api:"//player.vimeo.com/video/",options:[{name:"portrait",type:"checkbox",text:"Show portrait in overlay"},{name:"title",type:"checkbox",text:"Show title in overlay"},{name:"byline",type:"checkbox",text:"Show byline in overlay"}]};function f(a){let n={};return o.forEach(function(t){let i=o[t],r=a.match(i.pattern);if(r){n.name=t;let c=r[1],l=i.api+c;return n.url=l,n}}),Object.keys(n).length===0?!1:n}function p(a,n){this.showDialog=this.showDialog.bind(this),this.render=this.render.bind(this);let e=this;e.editor=a,e.currentProvider=null,this.configs={};let t={title:"Insert a video",initialData:{},body:{type:"panel",items:[]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onChange:function(d){e.providerChange(d),e.render()},onSubmit:function(d){e.onsubmit(),d.close()}},i=[{type:"input",label:"Source",name:"url"},{type:"grid",columns:3,items:[{type:"input",label:"Width",name:"width"},{type:"input",label:"Height",name:"height"},{type:"checkbox",label:"Fullscreen",name:"fullscreen"}]}],r=[...i,{type:"htmlpanel",html:"<div id='preview'></div>"}],c=[...i,{type:"checkbox",label:"Show suggested videos when the video finishes",name:"rel"},{type:"checkbox",label:"Show player controls",name:"controls"},{type:"checkbox",label:"Show video title and player actions",name:"showinfo"},{type:"htmlpanel",html:"<div id='preview'></div>"}],l=[...i,{type:"checkbox",label:"Show portrait in overlay",name:"portrait"},{type:"checkbox",label:"Show title in overlay",name:"title"},{type:"checkbox",label:"Show byline in overlay",name:"byline"},{type:"htmlpanel",html:"<div id='preview'></div>"}];this.configs.unknown=y(v({},t),{body:{type:"panel",items:r}}),this.configs.youtube=y(v({},t),{body:{type:"panel",items:c}}),this.configs.vimeo=y(v({},t),{body:{type:"panel",items:l}}),a.ui.registry.addIcon("video",`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 48 48" xml:space="preserve"><g><g><g>
<path d="M44,4.982H4c-2.2,0-4,1.8-4,4v30.036c0,2.2,1.8,4,4,4h40c2.2,0,4-1.8,4-4V8.982C48,6.782,46.2,4.982,44,4.982z M20.204,12.789l9.593,6.55l-9.593,6.55V12.789z M40.001,35.212H18.875c-0.57,1.239-1.816,2.104-3.27,2.104 s-2.699-0.866-3.27-2.104H8c-0.829,0-1.5-0.673-1.5-1.5c0-0.828,0.671-1.5,1.5-1.5h4.336c0.57-1.24,1.815-2.106,3.27-2.106 s2.7,0.866,3.27,2.106h21.126c0.828,0,1.5,0.672,1.5,1.5C41.502,34.54,40.829,35.212,40.001,35.212z" fill="#333333"/>
<circle cx="15.605" cy="33.712" r="1.397" fill="#333333"/>
</g></g></g></svg>`),a.ui.registry.addButton("video",{icon:"video",tooltip:"Insert/edit video",onAction:m=>e.showDialog()}),a.ui.registry.addMenuItem("video",{icon:"video",text:"Video",onAction:m=>e.showDialog(),context:"insert"})}p.prototype.showDialog=function(){let n=this.editor,e=n.dom,t={},i=this,r=n.selection.getNode();if(r){let l=e.getAttrib(r,"src");l||(r=r.children[0],l=e.getAttrib(r,"src")),t.url=l,e.getAttrib(r,"allowfullscreen")&&(t.fullscreen=!0),t.width=e.getAttrib(r,"width"),t.height=e.getAttrib(r,"height")}t.width||(t.width="400"),t.height||(t.height="300"),this.window=null;let c=f(t.url);if(c.name==="youtube"||c.name==="vimeo"){let l=t.url.split("?")[1],u=new URLSearchParams(l),m=o[c.name].options||[];t.url=c.url,m.forEach(function(g){let w=g.name,x=u.get(w);x==="0"||x===!1?t[w]=!1:t[w]=!0});let d=this.configs[c.name];d.initialData=t,this.currentProvider=c.name,this.window=this.editor.windowManager.open(d)}else{let l=this.configs.unknown;l.initialData=t,this.currentProvider=null,this.window=this.editor.windowManager.open(l)}i.render()},p.prototype.providerChange=function(n){let e=n.getData(),t=f(e.url);if(!(t.name===this.currentProvider||this.currentProvider===null&&t===!1))if(t.name==="youtube"){e.rel=!0,e.controls=!0,e.showinfo=!0;let i=this.configs[t.name];i.initialData=e,n.redial(i),this.currentProvider=t.name}else if(t.name==="vimeo"){e.portrait=!0,e.title=!0,e.byline=!0;let i=this.configs[t.name];i.initialData=e,n.redial(i),this.currentProvider=t.name}else{let i=this.configs.unknown;i.initialData=e,n.redial(i),this.currentProvider=null}},p.prototype.render=function(){let n=this.window.getData(),e=this.html(!0);if(!n.url)return"";e=this.html(!0);let i=$AM.find("#preview")[0];return i.innerHTML=e,e},p.prototype.html=function(n){let e=this.window.getData(),t=e.url,i=f(e.url),r=[];i&&((o[i.name].options||[]).forEach(function(b){let g=b.name,w=e[g];(w==="0"||w===!1)&&r.push(g+"=0")}),t=i.url),r.length&&(t+="?"+r.join("&"));let c=e.width,l=e.height,u="<iframe src='"+t+"' width='"+c+"' height='"+l+"'";return e.fullscreen&&(u+=" allowfullscreen"),n&&(u+=" style='width: "+c+"px; height: "+l+"px;'"),u+=" ></iframe>",u},p.prototype.onsubmit=function(){this.editor.insertContent(this.html())},s.PluginManager.add("video",(a,n)=>{let e=new p(a,n);return{getMetadata:()=>({name:"Video - Add embeded video easily.",url:"http://www.brandextract.com"})}})})(window.tinymce);})();
//# sourceMappingURL=plugin.min.js.map