@wangeditor-next/video-module 1.3.1 → 1.3.2-alpha.0

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/dist/index.js CHANGED
@@ -1,2 +1,1236 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@wangeditor-next/core"),require("slate"),require("snabbdom"),require("dom7"),require("nanoid")):"function"==typeof define&&define.amd?define(["@wangeditor-next/core","slate","snabbdom","dom7","nanoid"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).WangEditorVideoModule=e(t.core,t.slate,t.snabbdom,t.$,t.nanoid)}(this,(function(t,e,n,r,o){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var u=i(r);t.i18nAddResources("en",{videoModule:{delete:"Delete",uploadVideo:"Upload video",insertVideo:"Insert video",videoSrc:"Video source",videoSrcPlaceHolder:"Video file url, or third-party <iframe>",videoPoster:"Video poster",videoPosterPlaceHolder:"Poster image url",ok:"Ok",editSize:"Edit size",edit:"Edit video",width:"Width",height:"Height"}}),t.i18nAddResources("zh-CN",{videoModule:{delete:"删除视频",uploadVideo:"上传视频",insertVideo:"插入视频",videoSrc:"视频地址",videoSrcPlaceHolder:"视频文件 url 或第三方 <iframe>",videoPoster:"视频封面",videoPosterPlaceHolder:"封面图片 url",ok:"确定",editSize:"修改尺寸",edit:"编辑视频",width:"宽度",height:"高度"}});var a=function(){return a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)};function c(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,a)}c((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function f(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function d(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=f(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,o){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,o,(e=t[n](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(t){var e={exports:{}};return t(e,e.exports),e.exports}var h,y,g=function(t){return t&&t.Math==Math&&t},m=g("object"==typeof globalThis&&globalThis)||g("object"==typeof window&&window)||g("object"==typeof self&&self)||g("object"==typeof p&&p)||function(){return this}()||Function("return this")(),b=function(t){try{return!!t()}catch(t){return!0}},w=!b((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),S=Function.prototype.call,x=S.bind?S.bind(S):function(){return S.apply(S,arguments)},E={}.propertyIsEnumerable,O=Object.getOwnPropertyDescriptor,I={f:O&&!E.call({1:2},1)?function(t){var e=O(this,t);return!!e&&e.enumerable}:E},j=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},M=Function.prototype,P=M.bind,T=M.call,A=P&&P.bind(T),k=P?function(t){return t&&A(T,t)}:function(t){return t&&function(){return T.apply(t,arguments)}},N=k({}.toString),R=k("".slice),C=function(t){return R(N(t),8,-1)},V=m.Object,L=k("".split),D=b((function(){return!V("z").propertyIsEnumerable(0)}))?function(t){return"String"==C(t)?L(t,""):V(t)}:V,z=m.TypeError,F=function(t){if(null==t)throw z("Can't call method on "+t);return t},$=function(t){return D(F(t))},_=function(t){return"function"==typeof t},B=function(t){return"object"==typeof t?null!==t:_(t)},H=function(t){return _(t)?t:void 0},G=function(t,e){return arguments.length<2?H(m[t]):m[t]&&m[t][e]},W=k({}.isPrototypeOf),U=G("navigator","userAgent")||"",q=m.process,K=m.Deno,X=q&&q.versions||K&&K.version,Y=X&&X.v8;Y&&(y=(h=Y.split("."))[0]>0&&h[0]<4?1:+(h[0]+h[1])),!y&&U&&(!(h=U.match(/Edge\/(\d+)/))||h[1]>=74)&&(h=U.match(/Chrome\/(\d+)/))&&(y=+h[1]);var J=y,Q=!!Object.getOwnPropertySymbols&&!b((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&J&&J<41})),Z=Q&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,tt=m.Object,et=Z?function(t){return"symbol"==typeof t}:function(t){var e=G("Symbol");return _(e)&&W(e.prototype,tt(t))},nt=m.String,rt=function(t){try{return nt(t)}catch(t){return"Object"}},ot=m.TypeError,it=function(t){if(_(t))return t;throw ot(rt(t)+" is not a function")},ut=function(t,e){var n=t[e];return null==n?void 0:it(n)},at=m.TypeError,ct=Object.defineProperty,st=function(t,e){try{ct(m,t,{value:e,configurable:!0,writable:!0})}catch(n){m[t]=e}return e},ft="__core-js_shared__",lt=m[ft]||st(ft,{}),dt=v((function(t){(t.exports=function(t,e){return lt[t]||(lt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.19.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),pt=m.Object,vt=function(t){return pt(F(t))},ht=k({}.hasOwnProperty),yt=Object.hasOwn||function(t,e){return ht(vt(t),e)},gt=0,mt=Math.random(),bt=k(1..toString),wt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+bt(++gt+mt,36)},St=dt("wks"),xt=m.Symbol,Et=xt&&xt.for,Ot=Z?xt:xt&&xt.withoutSetter||wt,It=function(t){if(!yt(St,t)||!Q&&"string"!=typeof St[t]){var e="Symbol."+t;Q&&yt(xt,t)?St[t]=xt[t]:St[t]=Z&&Et?Et(e):Ot(e)}return St[t]},jt=m.TypeError,Mt=It("toPrimitive"),Pt=function(t,e){if(!B(t)||et(t))return t;var n,r=ut(t,Mt);if(r){if(void 0===e&&(e="default"),n=x(r,t,e),!B(n)||et(n))return n;throw jt("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&_(n=t.toString)&&!B(r=x(n,t)))return r;if(_(n=t.valueOf)&&!B(r=x(n,t)))return r;if("string"!==e&&_(n=t.toString)&&!B(r=x(n,t)))return r;throw at("Can't convert object to primitive value")}(t,e)},Tt=function(t){var e=Pt(t,"string");return et(e)?e:e+""},At=m.document,kt=B(At)&&B(At.createElement),Nt=function(t){return kt?At.createElement(t):{}},Rt=!w&&!b((function(){return 7!=Object.defineProperty(Nt("div"),"a",{get:function(){return 7}}).a})),Ct=Object.getOwnPropertyDescriptor,Vt={f:w?Ct:function(t,e){if(t=$(t),e=Tt(e),Rt)try{return Ct(t,e)}catch(t){}if(yt(t,e))return j(!x(I.f,t,e),t[e])}},Lt=m.String,Dt=m.TypeError,zt=function(t){if(B(t))return t;throw Dt(Lt(t)+" is not an object")},Ft=m.TypeError,$t=Object.defineProperty,_t={f:w?$t:function(t,e,n){if(zt(t),e=Tt(e),zt(n),Rt)try{return $t(t,e,n)}catch(t){}if("get"in n||"set"in n)throw Ft("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Bt=w?function(t,e,n){return _t.f(t,e,j(1,n))}:function(t,e,n){return t[e]=n,t},Ht=k(Function.toString);_(lt.inspectSource)||(lt.inspectSource=function(t){return Ht(t)});var Gt,Wt,Ut,qt=lt.inspectSource,Kt=m.WeakMap,Xt=_(Kt)&&/native code/.test(qt(Kt)),Yt=dt("keys"),Jt=function(t){return Yt[t]||(Yt[t]=wt(t))},Qt={},Zt="Object already initialized",te=m.TypeError,ee=m.WeakMap;if(Xt||lt.state){var ne=lt.state||(lt.state=new ee),re=k(ne.get),oe=k(ne.has),ie=k(ne.set);Gt=function(t,e){if(oe(ne,t))throw new te(Zt);return e.facade=t,ie(ne,t,e),e},Wt=function(t){return re(ne,t)||{}},Ut=function(t){return oe(ne,t)}}else{var ue=Jt("state");Qt[ue]=!0,Gt=function(t,e){if(yt(t,ue))throw new te(Zt);return e.facade=t,Bt(t,ue,e),e},Wt=function(t){return yt(t,ue)?t[ue]:{}},Ut=function(t){return yt(t,ue)}}var ae={set:Gt,get:Wt,has:Ut,enforce:function(t){return Ut(t)?Wt(t):Gt(t,{})},getterFor:function(t){return function(e){var n;if(!B(e)||(n=Wt(e)).type!==t)throw te("Incompatible receiver, "+t+" required");return n}}},ce=Function.prototype,se=w&&Object.getOwnPropertyDescriptor,fe=yt(ce,"name"),le={EXISTS:fe,PROPER:fe&&"something"===function(){}.name,CONFIGURABLE:fe&&(!w||w&&se(ce,"name").configurable)},de=v((function(t){var e=le.CONFIGURABLE,n=ae.get,r=ae.enforce,o=String(String).split("String");(t.exports=function(t,n,i,u){var a,c=!!u&&!!u.unsafe,s=!!u&&!!u.enumerable,f=!!u&&!!u.noTargetGet,l=u&&void 0!==u.name?u.name:n;_(i)&&("Symbol("===String(l).slice(0,7)&&(l="["+String(l).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!yt(i,"name")||e&&i.name!==l)&&Bt(i,"name",l),(a=r(i)).source||(a.source=o.join("string"==typeof l?l:""))),t!==m?(c?!f&&t[n]&&(s=!0):delete t[n],s?t[n]=i:Bt(t,n,i)):s?t[n]=i:st(n,i)})(Function.prototype,"toString",(function(){return _(this)&&n(this).source||qt(this)}))})),pe=Math.ceil,ve=Math.floor,he=function(t){var e=+t;return e!=e||0===e?0:(e>0?ve:pe)(e)},ye=Math.max,ge=Math.min,me=function(t,e){var n=he(t);return n<0?ye(n+e,0):ge(n,e)},be=Math.min,we=function(t){return t>0?be(he(t),9007199254740991):0},Se=function(t){return we(t.length)},xe=function(t){return function(e,n,r){var o,i=$(e),u=Se(i),a=me(r,u);if(t&&n!=n){for(;u>a;)if((o=i[a++])!=o)return!0}else for(;u>a;a++)if((t||a in i)&&i[a]===n)return t||a||0;return!t&&-1}},Ee={includes:xe(!0),indexOf:xe(!1)},Oe=Ee.indexOf,Ie=k([].push),je=function(t,e){var n,r=$(t),o=0,i=[];for(n in r)!yt(Qt,n)&&yt(r,n)&&Ie(i,n);for(;e.length>o;)yt(r,n=e[o++])&&(~Oe(i,n)||Ie(i,n));return i},Me=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pe=Me.concat("length","prototype"),Te={f:Object.getOwnPropertyNames||function(t){return je(t,Pe)}},Ae={f:Object.getOwnPropertySymbols},ke=k([].concat),Ne=G("Reflect","ownKeys")||function(t){var e=Te.f(zt(t)),n=Ae.f;return n?ke(e,n(t)):e},Re=function(t,e){for(var n=Ne(e),r=_t.f,o=Vt.f,i=0;i<n.length;i++){var u=n[i];yt(t,u)||r(t,u,o(e,u))}},Ce=/#|\.prototype\./,Ve=function(t,e){var n=De[Le(t)];return n==Fe||n!=ze&&(_(e)?b(e):!!e)},Le=Ve.normalize=function(t){return String(t).replace(Ce,".").toLowerCase()},De=Ve.data={},ze=Ve.NATIVE="N",Fe=Ve.POLYFILL="P",$e=Ve,_e=Vt.f,Be=function(t,e){var n,r,o,i,u,a=t.target,c=t.global,s=t.stat;if(n=c?m:s?m[a]||st(a,{}):(m[a]||{}).prototype)for(r in e){if(i=e[r],o=t.noTargetGet?(u=_e(n,r))&&u.value:n[r],!$e(c?r:a+(s?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Re(i,o)}(t.sham||o&&o.sham)&&Bt(i,"sham",!0),de(n,r,i,t)}},He={};He[It("toStringTag")]="z";var Ge,We="[object z]"===String(He),Ue=It("toStringTag"),qe=m.Object,Ke="Arguments"==C(function(){return arguments}()),Xe=We?C:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=qe(t),Ue))?n:Ke?C(e):"Object"==(r=C(e))&&_(e.callee)?"Arguments":r},Ye=m.String,Je=function(t){if("Symbol"===Xe(t))throw TypeError("Cannot convert a Symbol value to a string");return Ye(t)},Qe="\t\n\v\f\r                 \u2028\u2029\ufeff",Ze=k("".replace),tn="["+Qe+"]",en=RegExp("^"+tn+tn+"*"),nn=RegExp(tn+tn+"*$"),rn=function(t){return function(e){var n=Je(F(e));return 1&t&&(n=Ze(n,en,"")),2&t&&(n=Ze(n,nn,"")),n}},on={start:rn(1),end:rn(2),trim:rn(3)},un=le.PROPER,an=on.trim;function cn(t){return t.length?t[0].tagName.toLowerCase():""}function sn(t,e,n,r){void 0===e&&(e="auto"),void 0===n&&(n="auto"),void 0===r&&(r={});var o=u.default(t),i=r.width,a=void 0===i?"":i,c=r.height,s=void 0===c?"":c,f="";return a&&(f+="width: "+a+";"),s&&(f+="height: "+s+";"),o.attr("width",e),o.attr("height",n),o.attr("style",f),o[0].outerHTML}Be({target:"String",proto:!0,forced:(Ge="trim",b((function(){return!!Qe[Ge]()||"​…᠎"!=="​…᠎"[Ge]()||un&&Qe[Ge].name!==Ge})))},{trim:function(){return an(this)}}),Be({global:!0},{globalThis:m}),r.append&&(u.default.fn.append=r.append),r.on&&(u.default.fn.on=r.on),r.focus&&(u.default.fn.focus=r.focus),r.attr&&(u.default.fn.attr=r.attr),r.val&&(u.default.fn.val=r.val),r.html&&(u.default.fn.html=r.html),r.parent&&(u.default.fn.parent=r.parent),r.hasClass&&(u.default.fn.hasClass=r.hasClass),r.empty&&(u.default.fn.empty=r.empty);var fn={type:"video",renderElem:function(e,r,o){var i,u=e,a=u.src,c=void 0===a?"":a,s=u.poster,f=void 0===s?"":s,l=u.key,d=void 0===l?"":l,p=u.width,v=void 0===p?"auto":p,h=u.height,y=void 0===h?"auto":h,g=u.style,m=void 0===g?{}:g,b=u.textAlign,w=void 0===b?"center":b,S=t.DomEditor.isNodeSelected(o,e);if(0===c.trim().indexOf("<iframe ")){var x=sn(c,v,y,m);i=n.jsx("div",{className:"w-e-textarea-video-container","data-selected":S?"true":"",style:{textAlign:w},innerHTML:x})}else{var E=n.jsx("video",{key:d,poster:f,controls:!0,style:m},n.jsx("source",{src:c,type:"video/mp4"}),"Sorry, your browser doesn't support embedded videos.\n 抱歉,浏览器不支持 video 视频");"auto"!==v&&(E.data.width=v),"auto"!==y&&(E.data.height=y),i=n.jsx("div",{className:"w-e-textarea-video-container","data-selected":S?"true":"",style:{textAlign:w}},E)}return n.h("div",{props:{contentEditable:!1},on:{mousedown:function(t){return t.preventDefault()}}},i)}};var ln,dn={type:"video",elemToHtml:function(t,e){var n=t,r=n.src,o=void 0===r?"":r,i=n.poster,u=void 0===i?"":i,a=n.width,c=void 0===a?"auto":a,s=n.height,f=void 0===s?"auto":s,l=n.style,d=void 0===l?{}:l,p=n.textAlign,v='<div data-w-e-type="video" data-w-e-is-void style="text-align: '+(void 0===p?"center":p)+';">\n';if(0===o.trim().indexOf("<iframe ")){v+=sn(o,c,f,d)}else{var h=d.width,y=void 0===h?"":h,g=d.height,m=void 0===g?"":g,b="";y&&(b+="width: "+y+";"),m&&(b+="height: "+m+";"),v+='<video poster="'+u+'" controls="true" width="'+c+'" height="'+f+'" style="'+b+'"><source src="'+o+'" type="video/mp4"/></video>'}return v+="\n</div>"}},pn=Object.keys||function(t){return je(t,Me)},vn=w?Object.defineProperties:function(t,e){zt(t);for(var n,r=$(e),o=pn(e),i=o.length,u=0;i>u;)_t.f(t,n=o[u++],r[n]);return t},hn=G("document","documentElement"),yn=Jt("IE_PROTO"),gn=function(){},mn=function(t){return"<script>"+t+"</"+"script>"},bn=function(t){t.write(mn("")),t.close();var e=t.parentWindow.Object;return t=null,e},wn=function(){try{ln=new ActiveXObject("htmlfile")}catch(t){}var t,e;wn="undefined"!=typeof document?document.domain&&ln?bn(ln):((e=Nt("iframe")).style.display="none",hn.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(mn("document.F=Object")),t.close(),t.F):bn(ln);for(var n=Me.length;n--;)delete wn.prototype[Me[n]];return wn()};Qt[yn]=!0;var Sn=Object.create||function(t,e){var n;return null!==t?(gn.prototype=zt(t),n=new gn,gn.prototype=null,n[yn]=t):n=wn(),void 0===e?n:vn(n,e)},xn=It("unscopables"),En=Array.prototype;null==En[xn]&&_t.f(En,xn,{configurable:!0,value:Sn(null)});var On=function(t){En[xn][t]=!0},In=Ee.includes;Be({target:"Array",proto:!0},{includes:function(t){return In(this,t,arguments.length>1?arguments[1]:void 0)}}),On("includes");var jn={selector:"iframe,video,p",preParseHtml:function(t){var e=u.default(t),n=e;if("p"===cn(e)){var r=e.children();if(1===r.length){var o=r[0],i=o.tagName.toLowerCase();["iframe","video"].includes(i)&&(n=u.default(o))}}var a=cn(n);if("iframe"!==a&&"video"!==a)return n[0];if("video"===n.parent().attr("data-w-e-type"))return n[0];var c=u.default('<div data-w-e-type="video" data-w-e-is-void style="text-align: center;"></div>');return c.append(n),c[0]}},Mn=k(k.bind),Pn=function(t,e){return it(t),void 0===e?t:Mn?Mn(t,e):function(){return t.apply(e,arguments)}},Tn=Array.isArray||function(t){return"Array"==C(t)},An=function(){},kn=[],Nn=G("Reflect","construct"),Rn=/^\s*(?:class|function)\b/,Cn=k(Rn.exec),Vn=!Rn.exec(An),Ln=function(t){if(!_(t))return!1;try{return Nn(An,kn,t),!0}catch(t){return!1}},Dn=!Nn||b((function(){var t;return Ln(Ln.call)||!Ln(Object)||!Ln((function(){t=!0}))||t}))?function(t){if(!_(t))return!1;switch(Xe(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return Vn||!!Cn(Rn,qt(t))}:Ln,zn=It("species"),Fn=m.Array,$n=function(t,e){return new(function(t){var e;return Tn(t)&&(e=t.constructor,(Dn(e)&&(e===Fn||Tn(e.prototype))||B(e)&&null===(e=e[zn]))&&(e=void 0)),void 0===e?Fn:e}(t))(0===e?0:e)},_n=k([].push),Bn=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,u=7==t,a=5==t||i;return function(c,s,f,l){for(var d,p,v=vt(c),h=D(v),y=Pn(s,f),g=Se(h),m=0,b=l||$n,w=e?b(c,g):n||u?b(c,0):void 0;g>m;m++)if((a||m in h)&&(p=y(d=h[m],m,v),t))if(e)w[m]=p;else if(p)switch(t){case 3:return!0;case 5:return d;case 6:return m;case 2:_n(w,d)}else switch(t){case 4:return!1;case 7:_n(w,d)}return i?-1:r||o?o:w}},Hn={forEach:Bn(0),map:Bn(1),filter:Bn(2),some:Bn(3),every:Bn(4),find:Bn(5),findIndex:Bn(6),filterReject:Bn(7)},Gn=Hn.find,Wn="find",Un=!0;Wn in[]&&Array(1).find((function(){Un=!1})),Be({target:"Array",proto:!0,forced:Un},{find:function(t){return Gn(this,t,arguments.length>1?arguments[1]:void 0)}}),On(Wn);var qn=We?{}.toString:function(){return"[object "+Xe(this)+"]"};function Kn(t,e,n,r,o){return void 0===e&&(e=""),void 0===n&&(n="auto"),void 0===r&&(r="auto"),void 0===o&&(o={}),{type:"video",src:t,poster:e,width:n,height:r,style:o,children:[{text:""}]}}We||de(Object.prototype,"toString",qn,{unsafe:!0});var Xn,Yn,Jn={selector:'div[data-w-e-type="video"]',parseElemHtml:function(t,e,n){var r=u.default(t),o="",i="",a="auto",c="auto",s={},f=r.find("iframe");if(f.length>0)return a=f.attr("width")||"auto",c=f.attr("height")||"auto",s=f.attr("style")||{},Kn(o=f[0].outerHTML,i,a,c,s);var l=r.find("video");return(o=l.attr("src")||"")||l.length>0&&(o=l.find("source").attr("src")||""),a=l.attr("width")||"auto",c=l.attr("height")||"auto",Kn(o,i=l.attr("poster")||"",a,c,s=f.attr("style")||{})}},Qn=function(){var t=zt(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e},Zn=m.RegExp,tr=b((function(){var t=Zn("a","y");return t.lastIndex=2,null!=t.exec("abcd")})),er=tr||b((function(){return!Zn("a","y").sticky})),nr={BROKEN_CARET:tr||b((function(){var t=Zn("^r","gy");return t.lastIndex=2,null!=t.exec("str")})),MISSED_STICKY:er,UNSUPPORTED_Y:tr},rr=m.RegExp,or=b((function(){var t=rr(".","s");return!(t.dotAll&&t.exec("\n")&&"s"===t.flags)})),ir=m.RegExp,ur=b((function(){var t=ir("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")})),ar=ae.get,cr=dt("native-string-replace",String.prototype.replace),sr=RegExp.prototype.exec,fr=sr,lr=k("".charAt),dr=k("".indexOf),pr=k("".replace),vr=k("".slice),hr=(Yn=/b*/g,x(sr,Xn=/a/,"a"),x(sr,Yn,"a"),0!==Xn.lastIndex||0!==Yn.lastIndex),yr=nr.BROKEN_CARET,gr=void 0!==/()??/.exec("")[1];(hr||gr||yr||or||ur)&&(fr=function(t){var e,n,r,o,i,u,a,c=this,s=ar(c),f=Je(t),l=s.raw;if(l)return l.lastIndex=c.lastIndex,e=x(fr,l,f),c.lastIndex=l.lastIndex,e;var d=s.groups,p=yr&&c.sticky,v=x(Qn,c),h=c.source,y=0,g=f;if(p&&(v=pr(v,"y",""),-1===dr(v,"g")&&(v+="g"),g=vr(f,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==lr(f,c.lastIndex-1))&&(h="(?: "+h+")",g=" "+g,y++),n=new RegExp("^(?:"+h+")",v)),gr&&(n=new RegExp("^"+h+"$(?!\\s)",v)),hr&&(r=c.lastIndex),o=x(sr,p?n:c,g),p?o?(o.input=vr(o.input,y),o[0]=vr(o[0],y),o.index=c.lastIndex,c.lastIndex+=o[0].length):c.lastIndex=0:hr&&o&&(c.lastIndex=c.global?o.index+o[0].length:r),gr&&o&&o.length>1&&x(cr,o[0],n,(function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(o[i]=void 0)})),o&&d)for(o.groups=u=Sn(null),i=0;i<d.length;i++)u[(a=d[i])[0]]=o[a[1]];return o});var mr=fr;Be({target:"RegExp",proto:!0,forced:/./.exec!==mr},{exec:mr});var br=Function.prototype,wr=br.apply,Sr=br.bind,xr=br.call,Er="object"==typeof Reflect&&Reflect.apply||(Sr?xr.bind(wr):function(){return xr.apply(wr,arguments)}),Or=It("species"),Ir=RegExp.prototype,jr=k("".charAt),Mr=k("".charCodeAt),Pr=k("".slice),Tr=function(t){return function(e,n){var r,o,i=Je(F(e)),u=he(n),a=i.length;return u<0||u>=a?t?"":void 0:(r=Mr(i,u))<55296||r>56319||u+1===a||(o=Mr(i,u+1))<56320||o>57343?t?jr(i,u):r:t?Pr(i,u,u+2):o-56320+(r-55296<<10)+65536}},Ar={codeAt:Tr(!1),charAt:Tr(!0)},kr=Ar.charAt,Nr=function(t,e,n){return e+(n?kr(t,e).length:1)},Rr=Math.floor,Cr=k("".charAt),Vr=k("".replace),Lr=k("".slice),Dr=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,zr=/\$([$&'`]|\d{1,2})/g,Fr=function(t,e,n,r,o,i){var u=n+t.length,a=r.length,c=zr;return void 0!==o&&(o=vt(o),c=Dr),Vr(i,c,(function(i,c){var s;switch(Cr(c,0)){case"$":return"$";case"&":return t;case"`":return Lr(e,0,n);case"'":return Lr(e,u);case"<":s=o[Lr(c,1,-1)];break;default:var f=+c;if(0===f)return i;if(f>a){var l=Rr(f/10);return 0===l?i:l<=a?void 0===r[l-1]?Cr(c,1):r[l-1]+Cr(c,1):i}s=r[f-1]}return void 0===s?"":s}))},$r=m.TypeError,_r=function(t,e){var n=t.exec;if(_(n)){var r=x(n,t,e);return null!==r&&zt(r),r}if("RegExp"===C(t))return x(mr,t,e);throw $r("RegExp#exec called on incompatible receiver")},Br=It("replace"),Hr=Math.max,Gr=Math.min,Wr=k([].concat),Ur=k([].push),qr=k("".indexOf),Kr=k("".slice),Xr="$0"==="a".replace(/./,"$0"),Yr=!!/./[Br]&&""===/./[Br]("a","$0");function Jr(t){return void 0===t&&(t="r"),t+"-"+o.nanoid()}!function(t,e,n,r){var o=It(t),i=!b((function(){var e={};return e[o]=function(){return 7},7!=""[t](e)})),u=i&&!b((function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[Or]=function(){return n},n.flags="",n[o]=/./[o]),n.exec=function(){return e=!0,null},n[o](""),!e}));if(!i||!u||n){var a=k(/./[o]),c=e(o,""[t],(function(t,e,n,r,o){var u=k(t),c=e.exec;return c===mr||c===Ir.exec?i&&!o?{done:!0,value:a(e,n,r)}:{done:!0,value:u(n,e,r)}:{done:!1}}));de(String.prototype,t,c[0]),de(Ir,o,c[1])}r&&Bt(Ir[o],"sham",!0)}("replace",(function(t,e,n){var r=Yr?"$":"$0";return[function(t,n){var r=F(this),o=null==t?void 0:ut(t,Br);return o?x(o,t,r,n):x(e,Je(r),t,n)},function(t,o){var i=zt(this),u=Je(t);if("string"==typeof o&&-1===qr(o,r)&&-1===qr(o,"$<")){var a=n(e,i,u,o);if(a.done)return a.value}var c=_(o);c||(o=Je(o));var s=i.global;if(s){var f=i.unicode;i.lastIndex=0}for(var l=[];;){var d=_r(i,u);if(null===d)break;if(Ur(l,d),!s)break;""===Je(d[0])&&(i.lastIndex=Nr(u,we(i.lastIndex),f))}for(var p,v="",h=0,y=0;y<l.length;y++){for(var g=Je((d=l[y])[0]),m=Hr(Gr(he(d.index),u.length),0),b=[],w=1;w<d.length;w++)Ur(b,void 0===(p=d[w])?p:String(p));var S=d.groups;if(c){var x=Wr([g],b,m,u);void 0!==S&&Ur(x,S);var E=Je(Er(o,void 0,x))}else E=Fr(g,u,m,b,S,o);m>=h&&(v+=Kr(u,h,m)+E,h=m+g.length)}return v+Kr(u,h)}]}),!!b((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")}))||!Xr||Yr);var Qr=m.Promise,Zr=function(t,e,n){for(var r in e)de(t,r,e[r],n);return t},to=m.String,eo=m.TypeError,no=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=k(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return zt(n),function(t){if("object"==typeof t||_(t))return t;throw eo("Can't set "+to(t)+" as a prototype")}(r),e?t(n,r):n.__proto__=r,n}}():void 0),ro=_t.f,oo=It("toStringTag"),io=function(t,e,n){t&&!yt(t=n?t:t.prototype,oo)&&ro(t,oo,{configurable:!0,value:e})},uo=It("species"),ao=m.TypeError,co=function(t,e){if(W(e,t))return t;throw ao("Incorrect invocation")},so={},fo=It("iterator"),lo=Array.prototype,po=It("iterator"),vo=function(t){if(null!=t)return ut(t,po)||ut(t,"@@iterator")||so[Xe(t)]},ho=m.TypeError,yo=function(t,e,n){var r,o;zt(t);try{if(!(r=ut(t,"return"))){if("throw"===e)throw n;return n}r=x(r,t)}catch(t){o=!0,r=t}if("throw"===e)throw n;if(o)throw r;return zt(r),n},go=m.TypeError,mo=function(t,e){this.stopped=t,this.result=e},bo=mo.prototype,wo=function(t,e,n){var r,o,i,u,a,c,s,f,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),p=!(!n||!n.IS_ITERATOR),v=!(!n||!n.INTERRUPTED),h=Pn(e,l),y=function(t){return r&&yo(r,"normal",t),new mo(!0,t)},g=function(t){return d?(zt(t),v?h(t[0],t[1],y):h(t[0],t[1])):v?h(t,y):h(t)};if(p)r=t;else{if(!(o=vo(t)))throw go(rt(t)+" is not iterable");if(void 0!==(f=o)&&(so.Array===f||lo[fo]===f)){for(i=0,u=Se(t);u>i;i++)if((a=g(t[i]))&&W(bo,a))return a;return new mo(!1)}r=function(t,e){var n=arguments.length<2?vo(t):e;if(it(n))return zt(x(n,t));throw ho(rt(t)+" is not iterable")}(t,o)}for(c=r.next;!(s=x(c,r)).done;){try{a=g(s.value)}catch(t){yo(r,"throw",t)}if("object"==typeof a&&a&&W(bo,a))return a}return new mo(!1)},So=It("iterator"),xo=!1;try{var Eo=0,Oo={next:function(){return{done:!!Eo++}},return:function(){xo=!0}};Oo[So]=function(){return this},Array.from(Oo,(function(){throw 2}))}catch(t){}var Io,jo,Mo,Po,To=function(t,e){if(!e&&!xo)return!1;var n=!1;try{var r={};r[So]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},Ao=m.TypeError,ko=It("species"),No=function(t,e){var n,r=zt(t).constructor;return void 0===r||null==(n=zt(r)[ko])?e:function(t){if(Dn(t))return t;throw Ao(rt(t)+" is not a constructor")}(n)},Ro=k([].slice),Co=/(?:ipad|iphone|ipod).*applewebkit/i.test(U),Vo="process"==C(m.process),Lo=m.setImmediate,Do=m.clearImmediate,zo=m.process,Fo=m.Dispatch,$o=m.Function,_o=m.MessageChannel,Bo=m.String,Ho=0,Go={},Wo="onreadystatechange";try{Io=m.location}catch(t){}var Uo=function(t){if(yt(Go,t)){var e=Go[t];delete Go[t],e()}},qo=function(t){return function(){Uo(t)}},Ko=function(t){Uo(t.data)},Xo=function(t){m.postMessage(Bo(t),Io.protocol+"//"+Io.host)};Lo&&Do||(Lo=function(t){var e=Ro(arguments,1);return Go[++Ho]=function(){Er(_(t)?t:$o(t),void 0,e)},jo(Ho),Ho},Do=function(t){delete Go[t]},Vo?jo=function(t){zo.nextTick(qo(t))}:Fo&&Fo.now?jo=function(t){Fo.now(qo(t))}:_o&&!Co?(Po=(Mo=new _o).port2,Mo.port1.onmessage=Ko,jo=Pn(Po.postMessage,Po)):m.addEventListener&&_(m.postMessage)&&!m.importScripts&&Io&&"file:"!==Io.protocol&&!b(Xo)?(jo=Xo,m.addEventListener("message",Ko,!1)):jo=Wo in Nt("script")?function(t){hn.appendChild(Nt("script")).onreadystatechange=function(){hn.removeChild(this),Uo(t)}}:function(t){setTimeout(qo(t),0)});var Yo,Jo,Qo,Zo,ti,ei,ni,ri,oi={set:Lo,clear:Do},ii=/ipad|iphone|ipod/i.test(U)&&void 0!==m.Pebble,ui=/web0s(?!.*chrome)/i.test(U),ai=Vt.f,ci=oi.set,si=m.MutationObserver||m.WebKitMutationObserver,fi=m.document,li=m.process,di=m.Promise,pi=ai(m,"queueMicrotask"),vi=pi&&pi.value;vi||(Yo=function(){var t,e;for(Vo&&(t=li.domain)&&t.exit();Jo;){e=Jo.fn,Jo=Jo.next;try{e()}catch(t){throw Jo?Zo():Qo=void 0,t}}Qo=void 0,t&&t.enter()},Co||Vo||ui||!si||!fi?!ii&&di&&di.resolve?((ni=di.resolve(void 0)).constructor=di,ri=Pn(ni.then,ni),Zo=function(){ri(Yo)}):Vo?Zo=function(){li.nextTick(Yo)}:(ci=Pn(ci,m),Zo=function(){ci(Yo)}):(ti=!0,ei=fi.createTextNode(""),new si(Yo).observe(ei,{characterData:!0}),Zo=function(){ei.data=ti=!ti}));var hi,yi,gi,mi,bi=vi||function(t){var e={fn:t,next:void 0};Qo&&(Qo.next=e),Jo||(Jo=e,Zo()),Qo=e},wi=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=it(e),this.reject=it(n)},Si={f:function(t){return new wi(t)}},xi=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Ei="object"==typeof window,Oi=oi.set,Ii=It("species"),ji="Promise",Mi=ae.getterFor(ji),Pi=ae.set,Ti=ae.getterFor(ji),Ai=Qr&&Qr.prototype,ki=Qr,Ni=Ai,Ri=m.TypeError,Ci=m.document,Vi=m.process,Li=Si.f,Di=Li,zi=!!(Ci&&Ci.createEvent&&m.dispatchEvent),Fi=_(m.PromiseRejectionEvent),$i="unhandledrejection",_i=!1,Bi=$e(ji,(function(){var t=qt(ki),e=t!==String(ki);if(!e&&66===J)return!0;if(J>=51&&/native code/.test(t))return!1;var n=new ki((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[Ii]=r,!(_i=n.then((function(){}))instanceof r)||!e&&Ei&&!Fi})),Hi=Bi||!To((function(t){ki.all(t).catch((function(){}))})),Gi=function(t){var e;return!(!B(t)||!_(e=t.then))&&e},Wi=function(t,e){if(!t.notified){t.notified=!0;var n=t.reactions;bi((function(){for(var r=t.value,o=1==t.state,i=0;n.length>i;){var u,a,c,s=n[i++],f=o?s.ok:s.fail,l=s.resolve,d=s.reject,p=s.domain;try{f?(o||(2===t.rejection&&Xi(t),t.rejection=1),!0===f?u=r:(p&&p.enter(),u=f(r),p&&(p.exit(),c=!0)),u===s.promise?d(Ri("Promise-chain cycle")):(a=Gi(u))?x(a,u,l,d):l(u)):d(r)}catch(t){p&&!c&&p.exit(),d(t)}}t.reactions=[],t.notified=!1,e&&!t.rejection&&qi(t)}))}},Ui=function(t,e,n){var r,o;zi?((r=Ci.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),m.dispatchEvent(r)):r={promise:e,reason:n},!Fi&&(o=m["on"+t])?o(r):t===$i&&function(t,e){var n=m.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))}("Unhandled promise rejection",n)},qi=function(t){x(Oi,m,(function(){var e,n=t.facade,r=t.value;if(Ki(t)&&(e=xi((function(){Vo?Vi.emit("unhandledRejection",r,n):Ui($i,n,r)})),t.rejection=Vo||Ki(t)?2:1,e.error))throw e.value}))},Ki=function(t){return 1!==t.rejection&&!t.parent},Xi=function(t){x(Oi,m,(function(){var e=t.facade;Vo?Vi.emit("rejectionHandled",e):Ui("rejectionhandled",e,t.value)}))},Yi=function(t,e,n){return function(r){t(e,r,n)}},Ji=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,Wi(t,!0))},Qi=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw Ri("Promise can't be resolved itself");var r=Gi(e);r?bi((function(){var n={done:!1};try{x(r,e,Yi(Qi,n,t),Yi(Ji,n,t))}catch(e){Ji(n,e,t)}})):(t.value=e,t.state=1,Wi(t,!1))}catch(e){Ji({done:!1},e,t)}}};if(Bi&&(Ni=(ki=function(t){co(this,Ni),it(t),x(hi,this);var e=Mi(this);try{t(Yi(Qi,e),Yi(Ji,e))}catch(t){Ji(e,t)}}).prototype,(hi=function(t){Pi(this,{type:ji,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=Zr(Ni,{then:function(t,e){var n=Ti(this),r=n.reactions,o=Li(No(this,ki));return o.ok=!_(t)||t,o.fail=_(e)&&e,o.domain=Vo?Vi.domain:void 0,n.parent=!0,r[r.length]=o,0!=n.state&&Wi(n,!1),o.promise},catch:function(t){return this.then(void 0,t)}}),yi=function(){var t=new hi,e=Mi(t);this.promise=t,this.resolve=Yi(Qi,e),this.reject=Yi(Ji,e)},Si.f=Li=function(t){return t===ki||t===gi?new yi(t):Di(t)},_(Qr)&&Ai!==Object.prototype)){mi=Ai.then,_i||(de(Ai,"then",(function(t,e){var n=this;return new ki((function(t,e){x(mi,n,t,e)})).then(t,e)}),{unsafe:!0}),de(Ai,"catch",Ni.catch,{unsafe:!0}));try{delete Ai.constructor}catch(t){}no&&no(Ai,Ni)}function Zi(n,r,o,i,u){return void 0===o&&(o=""),void 0===i&&(i=""),void 0===u&&(u=""),c(this,void 0,void 0,(function(){var a,c,f,l,d,p,v;return s(this,(function(s){switch(s.label){case 0:return r?(n.restoreSelection(),a=n.getMenuConfig("insertVideo"),c=a.onInsertedVideo,f=a.checkVideo,l=a.parseVideoSrc,[4,f(r,o)]):[2];case 1:return"string"==typeof(d=s.sent())?(n.alert(d,"error"),[2]):null==d?[2]:[4,l(r)];case 2:return 0!==(p=s.sent()).trim().indexOf("<iframe ")&&(p=p.replace(/</g,"&lt;").replace(/>/g,"&gt;")),t.DomEditor.isSelectedEmptyParagraph(n)&&e.Transforms.removeNodes(n,{mode:"highest"}),v={type:"video",src:p,poster:o,children:[{text:""}],style:{width:i,height:u}},Promise.resolve().then((function(){e.Transforms.insertNodes(n,v)})),c(v),[2]}}))}))}function tu(){return Jr("w-e-insert-video")}Be({global:!0,wrap:!0,forced:Bi},{Promise:ki}),io(ki,ji,!1),function(t){var e=G(t),n=_t.f;w&&e&&!e[uo]&&n(e,uo,{configurable:!0,get:function(){return this}})}(ji),gi=G(ji),Be({target:ji,stat:!0,forced:Bi},{reject:function(t){var e=Li(this);return x(e.reject,void 0,t),e.promise}}),Be({target:ji,stat:!0,forced:Bi},{resolve:function(t){return function(t,e){if(zt(t),B(e)&&e.constructor===t)return e;var n=Si.f(t);return(0,n.resolve)(e),n.promise}(this,t)}}),Be({target:ji,stat:!0,forced:Hi},{all:function(t){var e=this,n=Li(e),r=n.resolve,o=n.reject,i=xi((function(){var n=it(e.resolve),i=[],u=0,a=1;wo(t,(function(t){var c=u++,s=!1;a++,x(n,e,t).then((function(t){s||(s=!0,i[c]=t,--a||r(i))}),o)})),--a||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=Li(e),r=n.reject,o=xi((function(){var o=it(e.resolve);wo(t,(function(t){x(o,e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}});var eu=function(){function n(){this.title=t.t("videoModule.insertVideo"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=320,this.$content=null,this.srcInputId=tu(),this.posterInputId=tu(),this.buttonId=tu()}return n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){},n.prototype.isDisabled=function(n){var r=n.selection;return null==r||(!e.Range.isCollapsed(r)||!!t.DomEditor.getSelectedElems(n).some((function(e){var r=t.DomEditor.getNodeType(e);return"pre"===r||("list-item"===r||!!n.isVoid(e))})))},n.prototype.getModalPositionNode=function(t){return null},n.prototype.getModalContentElem=function(e){var n=this,r=this,o=r.srcInputId,i=r.posterInputId,a=r.buttonId,f=l(t.genModalInputElems(t.t("videoModule.videoSrc"),o,t.t("videoModule.videoSrcPlaceHolder")),2),d=f[0],p=f[1],v=l(t.genModalInputElems(t.t("videoModule.videoPoster"),i,t.t("videoModule.videoPosterPlaceHolder")),2),h=v[0],y=v[1],g=u.default(p),m=u.default(y),b=l(t.genModalButtonElems(a,t.t("videoModule.ok")),1)[0];if(null==this.$content){var w=u.default("<div></div>");w.on("click","#"+a,(function(t){return c(n,void 0,void 0,(function(){var n,r;return s(this,(function(u){switch(u.label){case 0:return t.preventDefault(),n=w.find("#"+o).val().trim(),r=w.find("#"+i).val().trim(),[4,Zi(e,n,r)];case 1:return u.sent(),e.hidePanelOrModal(),[2]}}))}))})),this.$content=w}var S=this.$content;return S.empty(),S.append(d),S.append(h),S.append(b),g.val(""),m.val(""),setTimeout((function(){g.focus()})),S[0]},n}(),nu=k([].join),ru=D!=Object,ou=function(t,e){var n=[][t];return!!n&&b((function(){n.call(null,e||function(){throw 1},1)}))}("join",",");Be({target:"Array",proto:!0,forced:ru||!ou},{join:function(t){return nu($(this),void 0===t?",":t)}});var iu,uu,au,cu=!b((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),su=Jt("IE_PROTO"),fu=m.Object,lu=fu.prototype,du=cu?fu.getPrototypeOf:function(t){var e=vt(t);if(yt(e,su))return e[su];var n=e.constructor;return _(n)&&e instanceof n?n.prototype:e instanceof fu?lu:null},pu=It("iterator"),vu=!1;[].keys&&("next"in(au=[].keys())?(uu=du(du(au)))!==Object.prototype&&(iu=uu):vu=!0);var hu=null==iu||b((function(){var t={};return iu[pu].call(t)!==t}));hu&&(iu={}),_(iu[pu])||de(iu,pu,(function(){return this}));var yu={IteratorPrototype:iu,BUGGY_SAFARI_ITERATORS:vu},gu=yu.IteratorPrototype,mu=function(){return this},bu=le.PROPER,wu=le.CONFIGURABLE,Su=yu.IteratorPrototype,xu=yu.BUGGY_SAFARI_ITERATORS,Eu=It("iterator"),Ou="keys",Iu="values",ju="entries",Mu=function(){return this},Pu=function(t,e,n,r,o,i,u){!function(t,e,n,r){var o=e+" Iterator";t.prototype=Sn(gu,{next:j(+!r,n)}),io(t,o,!1),so[o]=mu}(n,e,r);var a,c,s,f=function(t){if(t===o&&h)return h;if(!xu&&t in p)return p[t];switch(t){case Ou:case Iu:case ju:return function(){return new n(this,t)}}return function(){return new n(this)}},l=e+" Iterator",d=!1,p=t.prototype,v=p[Eu]||p["@@iterator"]||o&&p[o],h=!xu&&v||f(o),y="Array"==e&&p.entries||v;if(y&&(a=du(y.call(new t)))!==Object.prototype&&a.next&&(du(a)!==Su&&(no?no(a,Su):_(a[Eu])||de(a,Eu,Mu)),io(a,l,!0)),bu&&o==Iu&&v&&v.name!==Iu&&(wu?Bt(p,"name",Iu):(d=!0,h=function(){return x(v,this)})),o)if(c={values:f(Iu),keys:i?h:f(Ou),entries:f(ju)},u)for(s in c)(xu||d||!(s in p))&&de(p,s,c[s]);else Be({target:e,proto:!0,forced:xu||d},c);return p[Eu]!==h&&de(p,Eu,h,{name:o}),so[e]=h,c},Tu="Array Iterator",Au=ae.set,ku=ae.getterFor(Tu),Nu=Pu(Array,"Array",(function(t,e){Au(this,{type:Tu,target:$(t),index:0,kind:e})}),(function(){var t=ku(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}}),"values");so.Arguments=so.Array,On("keys"),On("values"),On("entries");var Ru=Ar.charAt,Cu="String Iterator",Vu=ae.set,Lu=ae.getterFor(Cu);Pu(String,"String",(function(t){Vu(this,{type:Cu,string:Je(t),index:0})}),(function(){var t,e=Lu(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=Ru(n,r),e.index+=t.length,{value:t,done:!1})}));var Du=function(t,e,n){var r=Tt(e);r in t?_t.f(t,r,j(0,n)):t[r]=n},zu=m.Array,Fu=Math.max,$u=Te.f,_u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Bu=function(t){try{return $u(t)}catch(t){return function(t,e,n){for(var r=Se(t),o=me(e,r),i=me(void 0===n?r:n,r),u=zu(Fu(i-o,0)),a=0;o<i;o++,a++)Du(u,a,t[o]);return u.length=a,u}(_u)}},Hu={f:function(t){return _u&&"Window"==C(t)?Bu(t):$u($(t))}},Gu=b((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),Wu=Object.isExtensible,Uu=b((function(){Wu(1)}))||Gu?function(t){return!!B(t)&&((!Gu||"ArrayBuffer"!=C(t))&&(!Wu||Wu(t)))}:Wu,qu=!b((function(){return Object.isExtensible(Object.preventExtensions({}))})),Ku=v((function(t){var e=_t.f,n=!1,r=wt("meta"),o=0,i=function(t){e(t,r,{value:{objectID:"O"+o++,weakData:{}}})},u=t.exports={enable:function(){u.enable=function(){},n=!0;var t=Te.f,e=k([].splice),o={};o[r]=1,t(o).length&&(Te.f=function(n){for(var o=t(n),i=0,u=o.length;i<u;i++)if(o[i]===r){e(o,i,1);break}return o},Be({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Hu.f}))},fastKey:function(t,e){if(!B(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!yt(t,r)){if(!Uu(t))return"F";if(!e)return"E";i(t)}return t[r].objectID},getWeakData:function(t,e){if(!yt(t,r)){if(!Uu(t))return!0;if(!e)return!1;i(t)}return t[r].weakData},onFreeze:function(t){return qu&&n&&Uu(t)&&!yt(t,r)&&i(t),t}};Qt[r]=!0})),Xu=Ku.getWeakData,Yu=ae.set,Ju=ae.getterFor,Qu=Hn.find,Zu=Hn.findIndex,ta=k([].splice),ea=0,na=function(t){return t.frozen||(t.frozen=new ra)},ra=function(){this.entries=[]},oa=function(t,e){return Qu(t.entries,(function(t){return t[0]===e}))};ra.prototype={get:function(t){var e=oa(this,t);if(e)return e[1]},has:function(t){return!!oa(this,t)},set:function(t,e){var n=oa(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=Zu(this.entries,(function(e){return e[0]===t}));return~e&&ta(this.entries,e,1),!!~e}};var ia,ua={getConstructor:function(t,e,n,r){var o=t((function(t,o){co(t,i),Yu(t,{type:e,id:ea++,frozen:void 0}),null!=o&&wo(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,u=Ju(e),a=function(t,e,n){var r=u(t),o=Xu(zt(e),!0);return!0===o?na(r).set(e,n):o[r.id]=n,t};return Zr(i,{delete:function(t){var e=u(this);if(!B(t))return!1;var n=Xu(t);return!0===n?na(e).delete(t):n&&yt(n,e.id)&&delete n[e.id]},has:function(t){var e=u(this);if(!B(t))return!1;var n=Xu(t);return!0===n?na(e).has(t):n&&yt(n,e.id)}}),Zr(i,n?{get:function(t){var e=u(this);if(B(t)){var n=Xu(t);return!0===n?na(e).get(t):n?n[e.id]:void 0}},set:function(t,e){return a(this,t,e)}}:{add:function(t){return a(this,t,!0)}}),o}},aa=ae.enforce,ca=!m.ActiveXObject&&"ActiveXObject"in m,sa=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},fa=function(t,e,n){var r=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=r?"set":"add",u=m[t],a=u&&u.prototype,c=u,s={},f=function(t){var e=k(a[t]);de(a,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!B(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return o&&!B(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!B(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if($e(t,!_(u)||!(o||a.forEach&&!b((function(){(new u).entries().next()})))))c=n.getConstructor(e,t,r,i),Ku.enable();else if($e(t,!0)){var l=new c,d=l[i](o?{}:-0,1)!=l,p=b((function(){l.has(1)})),v=To((function(t){new u(t)})),h=!o&&b((function(){for(var t=new u,e=5;e--;)t[i](e,e);return!t.has(-0)}));v||((c=e((function(t,e){co(t,a);var n=function(t,e,n){var r,o;return no&&_(r=e.constructor)&&r!==n&&B(o=r.prototype)&&o!==n.prototype&&no(t,o),t}(new u,t,c);return null!=e&&wo(e,n[i],{that:n,AS_ENTRIES:r}),n}))).prototype=a,a.constructor=c),(p||h)&&(f("delete"),f("has"),r&&f("get")),(h||d)&&f(i),o&&a.clear&&delete a.clear}return s[t]=c,Be({global:!0,forced:c!=u},s),io(c,t),o||n.setStrong(c,t,r),c}("WeakMap",sa,ua);if(Xt&&ca){ia=ua.getConstructor(sa,"WeakMap",!0),Ku.enable();var la=fa.prototype,da=k(la.delete),pa=k(la.has),va=k(la.get),ha=k(la.set);Zr(la,{delete:function(t){if(B(t)&&!Uu(t)){var e=aa(this);return e.frozen||(e.frozen=new ia),da(this,t)||e.frozen.delete(t)}return da(this,t)},has:function(t){if(B(t)&&!Uu(t)){var e=aa(this);return e.frozen||(e.frozen=new ia),pa(this,t)||e.frozen.has(t)}return pa(this,t)},get:function(t){if(B(t)&&!Uu(t)){var e=aa(this);return e.frozen||(e.frozen=new ia),pa(this,t)?va(this,t):e.frozen.get(t)}return va(this,t)},set:function(t,e){if(B(t)&&!Uu(t)){var n=aa(this);n.frozen||(n.frozen=new ia),pa(this,t)?ha(this,t,e):n.frozen.set(t,e)}else ha(this,t,e);return this}})}var ya={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},ga=Nt("span").classList,ma=ga&&ga.constructor&&ga.constructor.prototype,ba=ma===Object.prototype?void 0:ma,wa=It("iterator"),Sa=It("toStringTag"),xa=Nu.values,Ea=function(t,e){if(t){if(t[wa]!==xa)try{Bt(t,wa,xa)}catch(e){t[wa]=xa}if(t[Sa]||Bt(t,Sa,e),ya[e])for(var n in Nu)if(t[n]!==Nu[n])try{Bt(t,n,Nu[n])}catch(e){t[n]=Nu[n]}}};for(var Oa in ya)Ea(m[Oa]&&m[Oa].prototype,Oa);Ea(ba,"DOMTokenList");var Ia=le.EXISTS,ja=_t.f,Ma=Function.prototype,Pa=k(Ma.toString),Ta=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Aa=k(Ta.exec);w&&!Ia&&ja(Ma,"name",{configurable:!0,get:function(){try{return Aa(Ta,Pa(this))[1]}catch(t){return""}}});var ka=It("species"),Na=function(t){return J>=51||!b((function(){var e=[];return(e.constructor={})[ka]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}("slice"),Ra=It("species"),Ca=m.Array,Va=Math.max;function La(t){return t.getMenuConfig("uploadVideo")}Be({target:"Array",proto:!0,forced:!Na},{slice:function(t,e){var n,r,o,i=$(this),u=Se(i),a=me(t,u),c=me(void 0===e?u:e,u);if(Tn(i)&&(n=i.constructor,(Dn(n)&&(n===Ca||Tn(n.prototype))||B(n)&&null===(n=n[Ra]))&&(n=void 0),n===Ca||void 0===n))return Ro(i,a,c);for(r=new(void 0===n?Ca:n)(Va(c-a,0)),o=0;a<c;a++,o++)a in i&&Du(r,o,i[a]);return r.length=o,r}});var Da=new WeakMap;function za(e,n){return c(this,void 0,void 0,(function(){var r,o,i,u;return s(this,(function(c){switch(c.label){case 0:return r=function(e){var n=Da.get(e);if(null!=n)return n;var r=La(e),o=r.onSuccess,i=r.onProgress,u=r.onFailed,c=r.customInsert,s=r.onError;return n=t.createUploader(a(a({},r),{onProgress:function(t){e.showProgressBar(t),i&&i(t)},onSuccess:function(t,n){if(c)return c(n,(function(t,n){return Zi(e,t,n)})),void o(t,n);var r=n.errno,i=void 0===r?1:r,a=n.data,s=void 0===a?{}:a;if(0===i){var f=s.url,l=void 0===f?"":f,d=s.poster;Zi(e,l,void 0===d?"":d),o(t,n)}else u(t,n)},onError:function(t,e,n){s(t,e,n)}})),Da.set(e,n),n}(e),o=n.name,i=n.type,u=n.size,r.addFile({name:o,type:i,size:u,data:n}),[4,r.upload()];case 1:return c.sent(),[2]}}))}))}var Fa=function(){function n(){this.title=t.t("videoModule.uploadVideo"),this.iconSvg='<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.819882a251.441452 251.441452 0 0 0-251.011972 246.600033 251.051015 251.051015 0 1 0 502.023944 8.823877 253.237463 253.237463 0 0 0-251.011972-255.42391z m59.463561 240.001647v129.898403h-116.701631v-129.898403h-44.041298l101.279368-103.504859 101.279368 103.504859z" p-id="6802"></path><path d="M788.254507 0.000781H99.094092A98.663439 98.663439 0 0 0 0.001171 99.093701v590.067495a98.663439 98.663439 0 0 0 99.092921 99.092921h411.7549a266.434235 266.434235 0 0 1-2.186448-41.815807 275.843767 275.843767 0 0 1 275.180024-270.729042 270.650955 270.650955 0 0 1 103.504859 19.834201V99.093701A101.51363 101.51363 0 0 0 788.254507 0.000781zM295.054441 640.747004V147.507894l394.146189 246.600033z"></path></svg>',this.tag="button"}return n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){var n=this.getMenuConfig(t),r=n.allowedFileTypes,o=void 0===r?[]:r,i=n.customBrowseAndUpload;if(i)i((function(e,n){return Zi(t,e,n)}));else{var a="";o.length>0&&(a='accept="'+o.join(", ")+'"');var f=u.default("body"),l=u.default('<input type="file" '+a+" multiple/>");l.hide(),f.append(l),l.click(),l.on("change",(function(){var e=l[0].files;!function(t,e){var n,r;c(this,void 0,void 0,(function(){var o,i,u,a,c,f;return s(this,(function(s){switch(s.label){case 0:if(null==e)return[2];o=Array.prototype.slice.call(e),i=La(t).customUpload,s.label=1;case 1:s.trys.push([1,9,10,15]),u=d(o),s.label=2;case 2:return[4,u.next()];case 3:return(a=s.sent()).done?[3,8]:(c=a.value,i?[4,i(c,(function(e,n){return Zi(t,e,n)}))]:[3,5]);case 4:return s.sent(),[3,7];case 5:return[4,za(t,c)];case 6:s.sent(),s.label=7;case 7:return[3,2];case 8:return[3,15];case 9:return f=s.sent(),n={error:f},[3,15];case 10:return s.trys.push([10,,13,14]),a&&!a.done&&(r=u.return)?[4,r.call(u)]:[3,12];case 11:s.sent(),s.label=12;case 12:return[3,14];case 13:if(n)throw n.error;return[7];case 14:return[7];case 15:return[2]}}))}))}(t,e)}))}},n.prototype.isDisabled=function(n){var r=n.selection;return null==r||(!e.Range.isCollapsed(r)||!!t.DomEditor.getSelectedElems(n).some((function(e){var r=t.DomEditor.getNodeType(e);return"pre"===r||("list-item"===r||!!n.isVoid(e))})))},n.prototype.getMenuConfig=function(t){return t.getMenuConfig("uploadVideo")},n}();function $a(){return Jr("w-e-insert-video")}var _a=function(){function n(){this.title=t.t("videoModule.editSize"),this.tag="button",this.showModal=!0,this.modalWidth=320,this.$content=null,this.widthInputId=$a(),this.heightInputId=$a(),this.buttonId=$a()}return n.prototype.getSelectedVideoNode=function(e){return t.DomEditor.getSelectedNodeByType(e,"video")},n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){},n.prototype.isDisabled=function(t){return null==t.selection||null==this.getSelectedVideoNode(t)},n.prototype.getModalPositionNode=function(t){return this.getSelectedVideoNode(t)},n.prototype.getModalContentElem=function(n){var r=this,o=r.widthInputId,i=r.heightInputId,c=r.buttonId,s=l(t.genModalInputElems(t.t("videoModule.width"),o,"auto"),2),f=s[0],d=s[1],p=u.default(d),v=l(t.genModalInputElems(t.t("videoModule.height"),i,"auto"),2),h=v[0],y=v[1],g=u.default(y),m=l(t.genModalButtonElems(c,t.t("videoModule.ok")),1)[0];if(null==this.$content){var b=u.default("<div></div>");b.on("click","#"+c,(function(r){r.preventDefault();var u=b.find("#"+o).val().trim(),c=b.find("#"+i).val().trim(),s=function(t){return/^\d+(\.\d+)?%$/.test(t)},f=function(t){return/^\d+(\.\d+)?$/.test(t)},l="auto",d="auto";s(u)?l=u:f(u)&&(l=parseInt(u)+"px"),s(c)?d=c:f(c)&&(d=parseInt(c)+"px");var p=S.style,v=void 0===p?{}:p;n.restoreSelection();var h=a(a({},v),{style:{width:l,height:d}});e.Transforms.setNodes(n,h,{match:function(e){return t.DomEditor.checkNodeType(e,"video")}}),n.hidePanelOrModal()})),this.$content=b}var w=this.$content;w.empty(),w.append(f),w.append(h),w.append(m);var S=this.getSelectedVideoNode(n);if(null==S)return w[0];var x=S.style,E=void 0===x?{}:x,O=E.width,I=void 0===O?"":O,j=E.height,M=void 0===j?"":j;return p.val(I),g.val(M),setTimeout((function(){p.focus()})),w[0]},n}();function Ba(){return Jr("w-e-edit-video")}var Ha=function(){function n(){this.title=t.t("videoModule.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.srcInputId=Ba(),this.posterInputId=Ba(),this.buttonId=Ba()}return n.prototype.getSelectedVideoNode=function(e){return t.DomEditor.getSelectedNodeByType(e,"video")},n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){},n.prototype.isDisabled=function(t){return null==t.selection||null==this.getSelectedVideoNode(t)},n.prototype.getModalPositionNode=function(t){return this.getSelectedVideoNode(t)},n.prototype.getModalContentElem=function(n){var r=this,o=this,i=o.srcInputId,a=o.posterInputId,f=o.buttonId,d=l(t.genModalInputElems(t.t("videoModule.videoSrc"),i,t.t("videoModule.videoSrcPlaceHolder")),2),p=d[0],v=d[1],h=l(t.genModalInputElems(t.t("videoModule.videoPoster"),a,t.t("videoModule.videoPosterPlaceHolder")),2),y=h[0],g=h[1],m=u.default(v),b=u.default(g),w=l(t.genModalButtonElems(f,t.t("videoModule.ok")),1)[0];if(null==this.$content){var S=u.default("<div></div>");S.on("click","#"+f,(function(o){return c(r,void 0,void 0,(function(){var r,u,c,f;return s(this,(function(s){return o.preventDefault(),r=S.find("#"+i).val().trim(),u=S.find("#"+a).val().trim(),c=Jr("video-"),f={src:r,poster:u,key:c},n.restoreSelection(),e.Transforms.setNodes(n,f,{match:function(e){return t.DomEditor.checkNodeType(e,"video")}}),n.hidePanelOrModal(),[2]}))}))})),this.$content=S}var x=this.$content;x.empty(),x.append(p),x.append(y),x.append(w);var E=this.getSelectedVideoNode(n);if(null==E)return x[0];var O=E.src,I=void 0===O?"":O,j=E.poster,M=void 0===j?"":j;return m.val(I),b.val(M),setTimeout((function(){m.focus()})),x[0]},n}();var Ga={renderElems:[fn],elemsToHtml:[dn],preParseHtml:[jn],parseElemsHtml:[Jn],menus:[{key:"insertVideo",factory:function(){return new eu},config:{onInsertedVideo:function(t){},checkVideo:function(t,e){return!0},parseVideoSrc:function(t){return t}}},{key:"uploadVideo",factory:function(){return new Fa},config:{server:"",fieldName:"wangeditor-uploaded-video",maxFileSize:10485760,maxNumberOfFiles:5,allowedFileTypes:["video/*"],meta:{},metaWithUrl:!1,withCredentials:!1,timeout:3e4,onBeforeUpload:function(t){return t},onProgress:function(t){},onSuccess:function(t,e){},onFailed:function(t,e){console.error("'"+t.name+"' upload failed",e)},onError:function(t,e,n){console.error("'"+t.name+" upload error",e,n)}}},{key:"editVideoSize",factory:function(){return new _a}},{key:"editVideoSrc",factory:function(){return new Ha}}],editorPlugin:function(n){var r=n.isVoid,o=n.normalizeNode,i=n;return i.isVoid=function(t){return"video"===t.type||r(t)},i.normalizeNode=function(n){var r=l(n,2),u=r[0],a=r[1];"video"===t.DomEditor.getNodeType(u)&&(t.DomEditor.isLastNode(i,u)&&e.Transforms.insertNodes(i,t.DomEditor.genEmptyParagraph(),{at:[a[0]+1]}));return o([u,a])},i}};return Ga}));
2
- //# sourceMappingURL=index.js.map
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@wangeditor-next/core'), require('slate'), require('snabbdom'), require('dom7'), require('nanoid')) :
3
+ typeof define === 'function' && define.amd ? define(['@wangeditor-next/core', 'slate', 'snabbdom', 'dom7', 'nanoid'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.WangEditorVideoModule = factory(global.core, global.slate, global.snabbdom, global.$, global.nanoid));
5
+ })(this, (function (core, slate, snabbdom, $, nanoid) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var $__default = /*#__PURE__*/_interopDefaultLegacy($);
10
+
11
+ /**
12
+ * @description i18n en
13
+ * @author wangfupeng
14
+ */
15
+ var enResources = {
16
+ videoModule: {
17
+ delete: 'Delete',
18
+ uploadVideo: 'Upload video',
19
+ insertVideo: 'Insert video',
20
+ videoSrc: 'Video source',
21
+ videoSrcPlaceHolder: 'Video file url, or third-party <iframe>',
22
+ videoPoster: 'Video poster',
23
+ videoPosterPlaceHolder: 'Poster image url',
24
+ ok: 'Ok',
25
+ editSize: 'Edit size',
26
+ edit: 'Edit video',
27
+ width: 'Width',
28
+ height: 'Height',
29
+ },
30
+ };
31
+
32
+ /**
33
+ * @description i18n zh-CN
34
+ * @author wangfupeng
35
+ */
36
+ var zhResources = {
37
+ videoModule: {
38
+ delete: '删除视频',
39
+ uploadVideo: '上传视频',
40
+ insertVideo: '插入视频',
41
+ videoSrc: '视频地址',
42
+ videoSrcPlaceHolder: '视频文件 url 或第三方 <iframe>',
43
+ videoPoster: '视频封面',
44
+ videoPosterPlaceHolder: '封面图片 url',
45
+ ok: '确定',
46
+ editSize: '修改尺寸',
47
+ edit: '编辑视频',
48
+ width: '宽度',
49
+ height: '高度',
50
+ },
51
+ };
52
+
53
+ /**
54
+ * @description i18n entry
55
+ * @author wangfupeng
56
+ */
57
+ core.i18nAddResources('en', enResources);
58
+ core.i18nAddResources('zh-CN', zhResources);
59
+
60
+ /******************************************************************************
61
+ Copyright (c) Microsoft Corporation.
62
+
63
+ Permission to use, copy, modify, and/or distribute this software for any
64
+ purpose with or without fee is hereby granted.
65
+
66
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
67
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
68
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
69
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
70
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
71
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
72
+ PERFORMANCE OF THIS SOFTWARE.
73
+ ***************************************************************************** */
74
+
75
+ var __assign = function() {
76
+ __assign = Object.assign || function __assign(t) {
77
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
78
+ s = arguments[i];
79
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
80
+ }
81
+ return t;
82
+ };
83
+ return __assign.apply(this, arguments);
84
+ };
85
+
86
+ function __awaiter(thisArg, _arguments, P, generator) {
87
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
88
+ return new (P || (P = Promise))(function (resolve, reject) {
89
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
90
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
91
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
92
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
93
+ });
94
+ }
95
+
96
+ function __generator(thisArg, body) {
97
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
98
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
99
+ function verb(n) { return function (v) { return step([n, v]); }; }
100
+ function step(op) {
101
+ if (f) throw new TypeError("Generator is already executing.");
102
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
103
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
104
+ if (y = 0, t) op = [op[0] & 2, t.value];
105
+ switch (op[0]) {
106
+ case 0: case 1: t = op; break;
107
+ case 4: _.label++; return { value: op[1], done: false };
108
+ case 5: _.label++; y = op[1]; op = [0]; continue;
109
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
110
+ default:
111
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
112
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
113
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
114
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
115
+ if (t[2]) _.ops.pop();
116
+ _.trys.pop(); continue;
117
+ }
118
+ op = body.call(thisArg, _);
119
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
120
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
121
+ }
122
+ }
123
+
124
+ function __values(o) {
125
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
126
+ if (m) return m.call(o);
127
+ if (o && typeof o.length === "number") return {
128
+ next: function () {
129
+ if (o && i >= o.length) o = void 0;
130
+ return { value: o && o[i++], done: !o };
131
+ }
132
+ };
133
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
134
+ }
135
+
136
+ function __read(o, n) {
137
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
138
+ if (!m) return o;
139
+ var i = m.call(o), r, ar = [], e;
140
+ try {
141
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
142
+ }
143
+ catch (error) { e = { error: error }; }
144
+ finally {
145
+ try {
146
+ if (r && !r.done && (m = i["return"])) m.call(i);
147
+ }
148
+ finally { if (e) throw e.error; }
149
+ }
150
+ return ar;
151
+ }
152
+
153
+ function __asyncValues(o) {
154
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
155
+ var m = o[Symbol.asyncIterator], i;
156
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
157
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
158
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
159
+ }
160
+
161
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
162
+ var e = new Error(message);
163
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
164
+ };
165
+
166
+ /**
167
+ * @description editor 插件,重写 editor API
168
+ * @author wangfupeng
169
+ */
170
+ function withVideo(editor) {
171
+ var isVoid = editor.isVoid, normalizeNode = editor.normalizeNode;
172
+ var newEditor = editor;
173
+ // 重写 isVoid
174
+ newEditor.isVoid = function (elem) {
175
+ var type = elem.type;
176
+ if (type === 'video') {
177
+ return true;
178
+ }
179
+ return isVoid(elem);
180
+ };
181
+ // 重写 normalizeNode
182
+ newEditor.normalizeNode = function (_a) {
183
+ var _b = __read(_a, 2), node = _b[0], path = _b[1];
184
+ var type = core.DomEditor.getNodeType(node);
185
+ // ----------------- video 后面必须跟一个 p header blockquote -----------------
186
+ if (type === 'video') {
187
+ // -------------- video 是 editor 最后一个节点,需要后面插入 p --------------
188
+ var isLast = core.DomEditor.isLastNode(newEditor, node);
189
+ if (isLast) {
190
+ slate.Transforms.insertNodes(newEditor, core.DomEditor.genEmptyParagraph(), { at: [path[0] + 1] });
191
+ }
192
+ }
193
+ // 执行默认的 normalizeNode ,重要!!!
194
+ return normalizeNode([node, path]);
195
+ };
196
+ // 返回 editor ,重要!
197
+ return newEditor;
198
+ }
199
+
200
+ /**
201
+ * @description DOM 操作
202
+ * @author wangfupeng
203
+ */
204
+ if ($.append)
205
+ $__default["default"].fn.append = $.append;
206
+ if ($.on)
207
+ $__default["default"].fn.on = $.on;
208
+ if ($.focus)
209
+ $__default["default"].fn.focus = $.focus;
210
+ if ($.attr)
211
+ $__default["default"].fn.attr = $.attr;
212
+ if ($.val)
213
+ $__default["default"].fn.val = $.val;
214
+ if ($.html)
215
+ $__default["default"].fn.html = $.html;
216
+ if ($.parent)
217
+ $__default["default"].fn.parent = $.parent;
218
+ if ($.hasClass)
219
+ $__default["default"].fn.hasClass = $.hasClass;
220
+ if ($.empty)
221
+ $__default["default"].fn.empty = $.empty;
222
+ /**
223
+ * 获取 tagName lower-case
224
+ * @param $elem $elem
225
+ */
226
+ function getTagName($elem) {
227
+ if ($elem.length)
228
+ return $elem[0].tagName.toLowerCase();
229
+ return '';
230
+ }
231
+ /**
232
+ * 生成带 size 样式的 iframe html
233
+ * @param iframeHtml iframe html string
234
+ * @param width width
235
+ * @param height height
236
+ * @returns iframe html string with size style
237
+ */
238
+ function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
239
+ if (width === void 0) { width = 'auto'; }
240
+ if (height === void 0) { height = 'auto'; }
241
+ if (style === void 0) { style = {}; }
242
+ var $iframe = $__default["default"](iframeHtml);
243
+ var _a = style.width, styleWidth = _a === void 0 ? '' : _a, _b = style.height, styleHeight = _b === void 0 ? '' : _b;
244
+ var styleStr = '';
245
+ if (styleWidth)
246
+ styleStr += "width: " + styleWidth + ";";
247
+ if (styleHeight)
248
+ styleStr += "height: " + styleHeight + ";";
249
+ $iframe.attr('width', width);
250
+ $iframe.attr('height', height);
251
+ $iframe.attr('style', styleStr);
252
+ return $iframe[0].outerHTML;
253
+ }
254
+
255
+ /**
256
+ * @description video render elem
257
+ * @author wangfupeng
258
+ */
259
+ function renderVideo(elemNode, children, editor) {
260
+ var _a = elemNode, _b = _a.src, src = _b === void 0 ? '' : _b, _c = _a.poster, poster = _c === void 0 ? '' : _c, _d = _a.key, key = _d === void 0 ? '' : _d, _e = _a.width, width = _e === void 0 ? 'auto' : _e, _f = _a.height, height = _f === void 0 ? 'auto' : _f, _g = _a.style, style = _g === void 0 ? {} : _g, _h = _a.textAlign, textAlign = _h === void 0 ? 'center' : _h;
261
+ // 是否选中
262
+ var selected = core.DomEditor.isNodeSelected(editor, elemNode);
263
+ var vnode;
264
+ if (src.trim().indexOf('<iframe ') === 0) {
265
+ // 增加尺寸样式
266
+ var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
267
+ // iframe 形式,第三方视频
268
+ vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', style: { textAlign: textAlign }, innerHTML: iframeHtml }));
269
+ }
270
+ else {
271
+ // 其他,mp4 格式
272
+ var videoVnode = (snabbdom.jsx("video", { key: key, poster: poster, controls: true, style: style },
273
+ snabbdom.jsx("source", { src: src, type: "video/mp4" }), "Sorry, your browser doesn't support embedded videos.\n \u62B1\u6B49\uFF0C\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 video \u89C6\u9891"));
274
+ // @ts-ignore 添加尺寸
275
+ if (width !== 'auto')
276
+ videoVnode.data.width = width;
277
+ // @ts-ignore
278
+ if (height !== 'auto')
279
+ videoVnode.data.height = height;
280
+ vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', style: { textAlign: textAlign } }, videoVnode));
281
+ }
282
+ // 【注意】void node 中,renderElem 不用处理 children 。core 会统一处理。
283
+ var containerVnode = snabbdom.h('div', {
284
+ props: {
285
+ contentEditable: false,
286
+ },
287
+ on: {
288
+ mousedown: function (e) { return e.preventDefault(); },
289
+ },
290
+ }, vnode);
291
+ return containerVnode;
292
+ }
293
+ var renderVideoConf = {
294
+ type: 'video',
295
+ renderElem: renderVideo,
296
+ };
297
+
298
+ /**
299
+ * @description to html
300
+ * @author wangfupeng
301
+ */
302
+ function videoToHtml(elemNode, childrenHtml) {
303
+ var _a = elemNode, _b = _a.src, src = _b === void 0 ? '' : _b, _c = _a.poster, poster = _c === void 0 ? '' : _c, _d = _a.width, width = _d === void 0 ? 'auto' : _d, _e = _a.height, height = _e === void 0 ? 'auto' : _e, _f = _a.style, style = _f === void 0 ? {} : _f, _g = _a.textAlign, textAlign = _g === void 0 ? 'center' : _g;
304
+ var res = "<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: " + textAlign + ";\">\n";
305
+ if (src.trim().indexOf('<iframe ') === 0) {
306
+ // iframe 形式
307
+ var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
308
+ res += iframeHtml;
309
+ }
310
+ else {
311
+ // 其他,mp4 等 url 格式
312
+ var _h = style.width, styleWidth = _h === void 0 ? '' : _h, _j = style.height, styleHeight = _j === void 0 ? '' : _j;
313
+ var styleStr = '';
314
+ if (styleWidth)
315
+ styleStr += "width: " + styleWidth + ";";
316
+ if (styleHeight)
317
+ styleStr += "height: " + styleHeight + ";";
318
+ res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\" style=\"" + styleStr + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
319
+ }
320
+ res += '\n</div>';
321
+ return res;
322
+ }
323
+ var videoToHtmlConf = {
324
+ type: 'video',
325
+ elemToHtml: videoToHtml,
326
+ };
327
+
328
+ /**
329
+ * @description pre parse html
330
+ * @author wangfupeng
331
+ */
332
+ /**
333
+ * pre-prase video ,兼容 V4
334
+ * @param elem elem
335
+ */
336
+ function preParse(elem) {
337
+ var $elem = $__default["default"](elem);
338
+ var $video = $elem;
339
+ var elemTagName = getTagName($elem);
340
+ if (elemTagName === 'p') {
341
+ // v4 的 video 或 iframe 是被 p 包裹的
342
+ var children = $elem.children();
343
+ if (children.length === 1) {
344
+ var firstChild = children[0];
345
+ var firstChildTagName = firstChild.tagName.toLowerCase();
346
+ if (['iframe', 'video'].includes(firstChildTagName)) {
347
+ // p 下面包含 iframe 或 video
348
+ $video = $__default["default"](firstChild);
349
+ }
350
+ }
351
+ }
352
+ var videoTagName = getTagName($video);
353
+ if (videoTagName !== 'iframe' && videoTagName !== 'video')
354
+ return $video[0];
355
+ // 已经符合 V5 格式
356
+ var $parent = $video.parent();
357
+ if ($parent.attr('data-w-e-type') === 'video')
358
+ return $video[0];
359
+ var $container = $__default["default"]("<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: center;\"></div>");
360
+ $container.append($video);
361
+ return $container[0];
362
+ }
363
+ var preParseHtmlConf = {
364
+ selector: 'iframe,video,p',
365
+ preParseHtml: preParse,
366
+ };
367
+
368
+ /**
369
+ * @description 工具函数
370
+ * @author wangfupeng
371
+ */
372
+ /**
373
+ * 获取随机数字符串
374
+ * @param prefix 前缀
375
+ * @returns 随机数字符串
376
+ */
377
+ function genRandomStr(prefix) {
378
+ if (prefix === void 0) { prefix = 'r'; }
379
+ return prefix + "-" + nanoid.nanoid();
380
+ }
381
+ function replaceSymbols(str) {
382
+ return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
383
+ }
384
+ function styleStringToObject(styleString) {
385
+ var styleObject = {};
386
+ // 去掉字符串两端的空格,然后按分号分割
387
+ var styles = styleString.trim().split(';');
388
+ // 迭代每一个样式属性对
389
+ styles.forEach(function (style) {
390
+ if (style) {
391
+ // 忽略空字符串
392
+ var _a = __read(style.split(':'), 2), property = _a[0], value = _a[1];
393
+ if (property && value) {
394
+ // 去掉两端的空格并将结果存储在对象中
395
+ styleObject[property.trim()] = value.trim();
396
+ }
397
+ }
398
+ });
399
+ return styleObject;
400
+ }
401
+
402
+ /**
403
+ * @description parse html
404
+ * @author wangfupeng
405
+ */
406
+ function genVideoElem(src, poster, width, height, style) {
407
+ if (poster === void 0) { poster = ''; }
408
+ if (width === void 0) { width = 'auto'; }
409
+ if (height === void 0) { height = 'auto'; }
410
+ if (style === void 0) { style = {}; }
411
+ return {
412
+ type: 'video',
413
+ src: src,
414
+ poster: poster,
415
+ width: width,
416
+ height: height,
417
+ style: style,
418
+ children: [{ text: '' }], // void 元素有一个空 text
419
+ };
420
+ }
421
+ function parseHtml(elem, children, editor) {
422
+ var $elem = $__default["default"](elem);
423
+ var src = '';
424
+ var poster = '';
425
+ var width = 'auto';
426
+ var height = 'auto';
427
+ var style = {};
428
+ // <iframe> 形式
429
+ var $iframe = $elem.find('iframe');
430
+ if ($iframe.length > 0) {
431
+ width = $iframe.attr('width') || 'auto';
432
+ height = $iframe.attr('height') || 'auto';
433
+ style = $iframe.attr('style') || '';
434
+ style = styleStringToObject(style);
435
+ src = $iframe[0].outerHTML;
436
+ return genVideoElem(src, poster, width, height, style);
437
+ }
438
+ // <video> 形式
439
+ var $video = $elem.find('video');
440
+ src = $video.attr('src') || '';
441
+ if (!src) {
442
+ if ($video.length > 0) {
443
+ var $source = $video.find('source');
444
+ src = $source.attr('src') || '';
445
+ }
446
+ }
447
+ width = $video.attr('width') || 'auto';
448
+ height = $video.attr('height') || 'auto';
449
+ poster = $video.attr('poster') || '';
450
+ style = $video.attr('style') || '';
451
+ style = styleStringToObject(style);
452
+ return genVideoElem(src, poster, width, height, style);
453
+ }
454
+ var parseHtmlConf = {
455
+ selector: 'div[data-w-e-type="video"]',
456
+ parseElemHtml: parseHtml,
457
+ };
458
+
459
+ /**
460
+ * @description icon svg
461
+ * @author wangfupeng
462
+ */
463
+ /**
464
+ * 【注意】svg 字符串的长度 ,否则会导致代码体积过大
465
+ * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293
466
+ * 找不到再从 iconfont.com 搜索
467
+ */
468
+ // 视频
469
+ var VIDEO_SVG = '<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>';
470
+ // 上传视频
471
+ var UPLOAD_VIDEO_SVG = '<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.819882a251.441452 251.441452 0 0 0-251.011972 246.600033 251.051015 251.051015 0 1 0 502.023944 8.823877 253.237463 253.237463 0 0 0-251.011972-255.42391z m59.463561 240.001647v129.898403h-116.701631v-129.898403h-44.041298l101.279368-103.504859 101.279368 103.504859z" p-id="6802"></path><path d="M788.254507 0.000781H99.094092A98.663439 98.663439 0 0 0 0.001171 99.093701v590.067495a98.663439 98.663439 0 0 0 99.092921 99.092921h411.7549a266.434235 266.434235 0 0 1-2.186448-41.815807 275.843767 275.843767 0 0 1 275.180024-270.729042 270.650955 270.650955 0 0 1 103.504859 19.834201V99.093701A101.51363 101.51363 0 0 0 788.254507 0.000781zM295.054441 640.747004V147.507894l394.146189 246.600033z"></path></svg>';
472
+ // 编辑
473
+ var PENCIL_SVG = '<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>';
474
+ // // 垃圾桶(删除)
475
+ // export const TRASH_SVG =
476
+ // '<svg viewBox="0 0 1024 1024"><path d="M826.8032 356.5312c-19.328 0-36.3776 15.6928-36.3776 35.0464v524.2624c0 19.328-16 34.56-35.328 34.56H264.9344c-19.328 0-35.5072-15.3088-35.5072-34.56V390.0416c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.6928-33.5104 35.0464V915.712c0 57.9328 44.6208 108.288 102.528 108.288H755.2c57.9328 0 108.0832-50.4576 108.0832-108.288V391.4752c-0.1024-19.2512-17.1264-34.944-36.48-34.944z" p-id="9577"></path><path d="M437.1712 775.7568V390.6048c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.616-33.5104 35.0464v385.152c0 19.328 14.1568 35.0464 33.5104 35.0464s33.5104-15.7184 33.5104-35.0464zM649.7024 775.7568V390.6048c0-19.328-17.0496-35.0464-36.3776-35.0464s-36.3776 15.616-36.3776 35.0464v385.152c0 19.328 17.0496 35.0464 36.3776 35.0464s36.3776-15.7184 36.3776-35.0464zM965.0432 217.0368h-174.6176V145.5104c0-57.9328-47.2064-101.76-104.6528-101.76h-350.976c-57.8304 0-105.3952 43.8528-105.3952 101.76v71.5264H54.784c-19.4304 0-35.0464 14.1568-35.0464 33.5104 0 19.328 15.616 33.5104 35.0464 33.5104h910.3616c19.328 0 35.0464-14.1568 35.0464-33.5104 0-19.3536-15.6928-33.5104-35.1488-33.5104z m-247.3728 0H297.3952V145.5104c0-19.328 18.2016-34.7648 37.4272-34.7648h350.976c19.1488 0 31.872 15.1296 31.872 34.7648v71.5264z"></path></svg>'
477
+
478
+ /**
479
+ * @description insert video
480
+ * @author wangfupeng
481
+ */
482
+ /**
483
+ * 插入视频
484
+ * @param editor editor
485
+ * @param src video src
486
+ * @param poster video poster
487
+ */
488
+ function insertVideo (editor, src, poster, width, height) {
489
+ if (poster === void 0) { poster = ''; }
490
+ if (width === void 0) { width = ''; }
491
+ if (height === void 0) { height = ''; }
492
+ return __awaiter(this, void 0, void 0, function () {
493
+ var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
494
+ return __generator(this, function (_b) {
495
+ switch (_b.label) {
496
+ case 0:
497
+ if (!src)
498
+ return [2 /*return*/];
499
+ // 还原选区
500
+ editor.restoreSelection();
501
+ _a = editor.getMenuConfig('insertVideo'), onInsertedVideo = _a.onInsertedVideo, checkVideo = _a.checkVideo, parseVideoSrc = _a.parseVideoSrc;
502
+ return [4 /*yield*/, checkVideo(src, poster)];
503
+ case 1:
504
+ checkRes = _b.sent();
505
+ if (typeof checkRes === 'string') {
506
+ // 校验失败,给出提示
507
+ editor.alert(checkRes, 'error');
508
+ return [2 /*return*/];
509
+ }
510
+ if (checkRes == null) {
511
+ // 校验失败,不给提示
512
+ return [2 /*return*/];
513
+ }
514
+ return [4 /*yield*/, parseVideoSrc(src)];
515
+ case 2:
516
+ parsedSrc = _b.sent();
517
+ if (parsedSrc.trim().indexOf('<iframe ') !== 0) {
518
+ parsedSrc = replaceSymbols(parsedSrc);
519
+ }
520
+ if (core.DomEditor.isSelectedEmptyParagraph(editor)) {
521
+ slate.Transforms.removeNodes(editor, { mode: 'highest' });
522
+ }
523
+ video = {
524
+ type: 'video',
525
+ src: parsedSrc,
526
+ poster: poster,
527
+ children: [{ text: '' }],
528
+ style: {
529
+ width: width,
530
+ height: height,
531
+ },
532
+ };
533
+ // 插入视频
534
+ // 不使用此方式会比正常的选区选取先执行
535
+ Promise.resolve().then(function () {
536
+ slate.Transforms.insertNodes(editor, video);
537
+ });
538
+ // 调用 callback
539
+ onInsertedVideo(video);
540
+ return [2 /*return*/];
541
+ }
542
+ });
543
+ });
544
+ }
545
+
546
+ /**
547
+ * @description insert video menu
548
+ * @author wangfupeng
549
+ */
550
+ /**
551
+ * 生成唯一的 DOM ID
552
+ */
553
+ function genDomID$2() {
554
+ return genRandomStr('w-e-insert-video');
555
+ }
556
+ var InsertVideoMenu = /** @class */ (function () {
557
+ function InsertVideoMenu() {
558
+ this.title = core.t('videoModule.insertVideo');
559
+ this.iconSvg = VIDEO_SVG;
560
+ this.tag = 'button';
561
+ this.showModal = true; // 点击 button 时显示 modal
562
+ this.modalWidth = 320;
563
+ this.$content = null;
564
+ this.srcInputId = genDomID$2();
565
+ this.posterInputId = genDomID$2();
566
+ this.buttonId = genDomID$2();
567
+ }
568
+ InsertVideoMenu.prototype.getValue = function (editor) {
569
+ // 插入菜单,不需要 value
570
+ return '';
571
+ };
572
+ InsertVideoMenu.prototype.isActive = function (editor) {
573
+ // 任何时候,都不用激活 menu
574
+ return false;
575
+ };
576
+ InsertVideoMenu.prototype.exec = function (editor, value) {
577
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
578
+ // 此处空着即可
579
+ };
580
+ InsertVideoMenu.prototype.isDisabled = function (editor) {
581
+ var selection = editor.selection;
582
+ if (selection == null)
583
+ return true;
584
+ if (!slate.Range.isCollapsed(selection))
585
+ return true; // 选区非折叠,禁用
586
+ var selectedElems = core.DomEditor.getSelectedElems(editor);
587
+ var hasVoidOrPre = selectedElems.some(function (elem) {
588
+ var type = core.DomEditor.getNodeType(elem);
589
+ if (type === 'pre')
590
+ return true;
591
+ if (type === 'list-item')
592
+ return true;
593
+ if (editor.isVoid(elem))
594
+ return true;
595
+ return false;
596
+ });
597
+ if (hasVoidOrPre)
598
+ return true; // void 或 pre ,禁用
599
+ return false;
600
+ };
601
+ InsertVideoMenu.prototype.getModalPositionNode = function (editor) {
602
+ return null; // modal 依据选区定位
603
+ };
604
+ InsertVideoMenu.prototype.getModalContentElem = function (editor) {
605
+ var _this = this;
606
+ var _a = this, srcInputId = _a.srcInputId, posterInputId = _a.posterInputId, buttonId = _a.buttonId;
607
+ // 获取 input button elem
608
+ var _b = __read(core.genModalInputElems(core.t('videoModule.videoSrc'), srcInputId, core.t('videoModule.videoSrcPlaceHolder')), 2), srcContainerElem = _b[0], inputSrcElem = _b[1];
609
+ var _c = __read(core.genModalInputElems(core.t('videoModule.videoPoster'), posterInputId, core.t('videoModule.videoPosterPlaceHolder')), 2), posterContainerElem = _c[0], inputPosterElem = _c[1];
610
+ var $inputSrc = $__default["default"](inputSrcElem);
611
+ var $inputPoster = $__default["default"](inputPosterElem);
612
+ var _d = __read(core.genModalButtonElems(buttonId, core.t('videoModule.ok')), 1), buttonContainerElem = _d[0];
613
+ if (this.$content == null) {
614
+ // 第一次渲染
615
+ var $content_1 = $__default["default"]('<div></div>');
616
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
617
+ $content_1.on('click', "#" + buttonId, function (e) { return __awaiter(_this, void 0, void 0, function () {
618
+ var src, poster;
619
+ return __generator(this, function (_a) {
620
+ switch (_a.label) {
621
+ case 0:
622
+ e.preventDefault();
623
+ src = $content_1.find("#" + srcInputId).val().trim();
624
+ poster = $content_1.find("#" + posterInputId).val().trim();
625
+ return [4 /*yield*/, insertVideo(editor, src, poster)];
626
+ case 1:
627
+ _a.sent();
628
+ editor.hidePanelOrModal(); // 隐藏 modal
629
+ return [2 /*return*/];
630
+ }
631
+ });
632
+ }); });
633
+ // 记录属性,重要
634
+ this.$content = $content_1;
635
+ }
636
+ var $content = this.$content;
637
+ $content.empty(); // 先清空内容
638
+ // append inputs and button
639
+ $content.append(srcContainerElem);
640
+ $content.append(posterContainerElem);
641
+ $content.append(buttonContainerElem);
642
+ // 设置 input val
643
+ $inputSrc.val('');
644
+ $inputPoster.val('');
645
+ // focus 一个 input(异步,此时 DOM 尚未渲染)
646
+ setTimeout(function () {
647
+ $inputSrc.focus();
648
+ });
649
+ return $content[0];
650
+ };
651
+ return InsertVideoMenu;
652
+ }());
653
+
654
+ /**
655
+ * @description upload video
656
+ * @author wangfupeng
657
+ */
658
+ function getMenuConfig(editor) {
659
+ // 获取配置,见 `./config.js`
660
+ return editor.getMenuConfig('uploadVideo');
661
+ }
662
+ // 存储 editor uppy 的关系 - 缓存 uppy ,不重复创建
663
+ var EDITOR_TO_UPPY_MAP = new WeakMap();
664
+ /**
665
+ * 获取 uppy 实例(并通过 editor 缓存)
666
+ * @param editor editor
667
+ */
668
+ function getUppy(editor) {
669
+ // 从缓存中获取
670
+ var uppy = EDITOR_TO_UPPY_MAP.get(editor);
671
+ if (uppy != null)
672
+ return uppy;
673
+ var menuConfig = getMenuConfig(editor);
674
+ var onSuccess = menuConfig.onSuccess, onProgress = menuConfig.onProgress, onFailed = menuConfig.onFailed, customInsert = menuConfig.customInsert, onError = menuConfig.onError;
675
+ // 上传完成之后
676
+ var successHandler = function (file, res) {
677
+ // 预期 res 格式:
678
+ // 成功:{ errno: 0, data: { url, poster } }
679
+ // 失败:{ errno: !0, message: '失败信息' }
680
+ if (customInsert) {
681
+ // 用户自定义插入视频,此时 res 格式可能不符合预期
682
+ customInsert(res, function (src, poster) { return insertVideo(editor, src, poster); });
683
+ // success 回调
684
+ onSuccess(file, res);
685
+ return;
686
+ }
687
+ var _a = res.errno, errno = _a === void 0 ? 1 : _a, _b = res.data, data = _b === void 0 ? {} : _b;
688
+ if (errno !== 0) {
689
+ // failed 回调
690
+ onFailed(file, res);
691
+ return;
692
+ }
693
+ var _c = data.url, url = _c === void 0 ? '' : _c, _d = data.poster, poster = _d === void 0 ? '' : _d;
694
+ insertVideo(editor, url, poster);
695
+ // success 回调
696
+ onSuccess(file, res);
697
+ };
698
+ // progress 显示进度条
699
+ var progressHandler = function (progress) {
700
+ editor.showProgressBar(progress);
701
+ // 回调函数
702
+ onProgress && onProgress(progress);
703
+ };
704
+ // onError 提示错误
705
+ var errorHandler = function (file, err, res) {
706
+ onError(file, err, res);
707
+ };
708
+ // 创建 uppy
709
+ uppy = core.createUploader(__assign(__assign({}, menuConfig), { onProgress: progressHandler, onSuccess: successHandler, onError: errorHandler }));
710
+ // 缓存 uppy
711
+ EDITOR_TO_UPPY_MAP.set(editor, uppy);
712
+ return uppy;
713
+ }
714
+ /**
715
+ * 上传视频文件
716
+ * @param editor editor
717
+ * @param file file
718
+ */
719
+ function uploadFile(editor, file) {
720
+ return __awaiter(this, void 0, void 0, function () {
721
+ var uppy, name, type, size;
722
+ return __generator(this, function (_a) {
723
+ switch (_a.label) {
724
+ case 0:
725
+ uppy = getUppy(editor);
726
+ name = file.name, type = file.type, size = file.size;
727
+ uppy.addFile({
728
+ name: name,
729
+ type: type,
730
+ size: size,
731
+ data: file,
732
+ });
733
+ return [4 /*yield*/, uppy.upload()];
734
+ case 1:
735
+ _a.sent();
736
+ return [2 /*return*/];
737
+ }
738
+ });
739
+ });
740
+ }
741
+ function uploadVideos (editor, files) {
742
+ var e_1, _a;
743
+ return __awaiter(this, void 0, void 0, function () {
744
+ var fileList, customUpload, fileList_1, fileList_1_1, file, e_1_1;
745
+ return __generator(this, function (_b) {
746
+ switch (_b.label) {
747
+ case 0:
748
+ if (files == null)
749
+ return [2 /*return*/];
750
+ fileList = Array.prototype.slice.call(files);
751
+ customUpload = getMenuConfig(editor).customUpload;
752
+ _b.label = 1;
753
+ case 1:
754
+ _b.trys.push([1, 9, 10, 15]);
755
+ fileList_1 = __asyncValues(fileList);
756
+ _b.label = 2;
757
+ case 2: return [4 /*yield*/, fileList_1.next()];
758
+ case 3:
759
+ if (!(fileList_1_1 = _b.sent(), !fileList_1_1.done)) return [3 /*break*/, 8];
760
+ file = fileList_1_1.value;
761
+ if (!customUpload) return [3 /*break*/, 5];
762
+ // 自定义上传
763
+ return [4 /*yield*/, customUpload(file, function (src, poster) { return insertVideo(editor, src, poster); })];
764
+ case 4:
765
+ // 自定义上传
766
+ _b.sent();
767
+ return [3 /*break*/, 7];
768
+ case 5:
769
+ // 默认上传
770
+ return [4 /*yield*/, uploadFile(editor, file)];
771
+ case 6:
772
+ // 默认上传
773
+ _b.sent();
774
+ _b.label = 7;
775
+ case 7: return [3 /*break*/, 2];
776
+ case 8: return [3 /*break*/, 15];
777
+ case 9:
778
+ e_1_1 = _b.sent();
779
+ e_1 = { error: e_1_1 };
780
+ return [3 /*break*/, 15];
781
+ case 10:
782
+ _b.trys.push([10, , 13, 14]);
783
+ if (!(fileList_1_1 && !fileList_1_1.done && (_a = fileList_1.return))) return [3 /*break*/, 12];
784
+ return [4 /*yield*/, _a.call(fileList_1)];
785
+ case 11:
786
+ _b.sent();
787
+ _b.label = 12;
788
+ case 12: return [3 /*break*/, 14];
789
+ case 13:
790
+ if (e_1) throw e_1.error;
791
+ return [7 /*endfinally*/];
792
+ case 14: return [7 /*endfinally*/];
793
+ case 15: return [2 /*return*/];
794
+ }
795
+ });
796
+ });
797
+ }
798
+
799
+ /**
800
+ * @description upload video menu
801
+ * @author wangfupeng
802
+ */
803
+ var UploadVideoMenu = /** @class */ (function () {
804
+ function UploadVideoMenu() {
805
+ this.title = core.t('videoModule.uploadVideo');
806
+ this.iconSvg = UPLOAD_VIDEO_SVG;
807
+ this.tag = 'button';
808
+ }
809
+ UploadVideoMenu.prototype.getValue = function (editor) {
810
+ // 无需获取 val
811
+ return '';
812
+ };
813
+ UploadVideoMenu.prototype.isActive = function (editor) {
814
+ // 任何时候,都不用激活 menu
815
+ return false;
816
+ };
817
+ UploadVideoMenu.prototype.exec = function (editor, value) {
818
+ var _a = this.getMenuConfig(editor), _b = _a.allowedFileTypes, allowedFileTypes = _b === void 0 ? [] : _b, customBrowseAndUpload = _a.customBrowseAndUpload;
819
+ // 自定义选择图片,并上传,如图床
820
+ if (customBrowseAndUpload) {
821
+ customBrowseAndUpload(function (src, poster) { return insertVideo(editor, src, poster); });
822
+ return;
823
+ }
824
+ // 设置选择文件的类型
825
+ var acceptAttr = '';
826
+ if (allowedFileTypes.length > 0) {
827
+ acceptAttr = "accept=\"" + allowedFileTypes.join(', ') + "\"";
828
+ }
829
+ // 添加 file input(每次重新创建 input)
830
+ var $body = $__default["default"]('body');
831
+ var $inputFile = $__default["default"]("<input type=\"file\" " + acceptAttr + " multiple/>");
832
+ $inputFile.hide();
833
+ $body.append($inputFile);
834
+ $inputFile.click();
835
+ // 选中文件
836
+ $inputFile.on('change', function () {
837
+ var files = $inputFile[0].files;
838
+ uploadVideos(editor, files); // 上传文件
839
+ });
840
+ };
841
+ UploadVideoMenu.prototype.isDisabled = function (editor) {
842
+ var selection = editor.selection;
843
+ if (selection == null)
844
+ return true;
845
+ if (!slate.Range.isCollapsed(selection))
846
+ return true; // 选区非折叠,禁用
847
+ var selectedElems = core.DomEditor.getSelectedElems(editor);
848
+ var hasVoidOrPre = selectedElems.some(function (elem) {
849
+ var type = core.DomEditor.getNodeType(elem);
850
+ if (type === 'pre')
851
+ return true;
852
+ if (type === 'list-item')
853
+ return true;
854
+ if (editor.isVoid(elem))
855
+ return true;
856
+ return false;
857
+ });
858
+ if (hasVoidOrPre)
859
+ return true; // void 或 pre ,禁用
860
+ return false;
861
+ };
862
+ UploadVideoMenu.prototype.getMenuConfig = function (editor) {
863
+ // 获取配置,见 `./config.js`
864
+ return editor.getMenuConfig('uploadVideo');
865
+ };
866
+ return UploadVideoMenu;
867
+ }());
868
+
869
+ /**
870
+ * @description 修改视频尺寸
871
+ * @author wangfupeng
872
+ */
873
+ /**
874
+ * 生成唯一的 DOM ID
875
+ */
876
+ function genDomID$1() {
877
+ return genRandomStr('w-e-insert-video');
878
+ }
879
+ var EditorVideoSizeMenu = /** @class */ (function () {
880
+ function EditorVideoSizeMenu() {
881
+ this.title = core.t('videoModule.editSize');
882
+ this.tag = 'button';
883
+ this.showModal = true; // 点击 button 时显示 modal
884
+ this.modalWidth = 320;
885
+ this.$content = null;
886
+ this.widthInputId = genDomID$1();
887
+ this.heightInputId = genDomID$1();
888
+ this.buttonId = genDomID$1();
889
+ }
890
+ EditorVideoSizeMenu.prototype.getSelectedVideoNode = function (editor) {
891
+ return core.DomEditor.getSelectedNodeByType(editor, 'video');
892
+ };
893
+ EditorVideoSizeMenu.prototype.getValue = function (editor) {
894
+ // 插入菜单,不需要 value
895
+ return '';
896
+ };
897
+ EditorVideoSizeMenu.prototype.isActive = function (editor) {
898
+ // 任何时候,都不用激活 menu
899
+ return false;
900
+ };
901
+ EditorVideoSizeMenu.prototype.exec = function (editor, value) {
902
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
903
+ // 此处空着即可
904
+ };
905
+ EditorVideoSizeMenu.prototype.isDisabled = function (editor) {
906
+ if (editor.selection == null)
907
+ return true;
908
+ var videoNode = this.getSelectedVideoNode(editor);
909
+ if (videoNode == null) {
910
+ // 选区未处于 video node ,则禁用
911
+ return true;
912
+ }
913
+ return false;
914
+ };
915
+ EditorVideoSizeMenu.prototype.getModalPositionNode = function (editor) {
916
+ return this.getSelectedVideoNode(editor);
917
+ };
918
+ EditorVideoSizeMenu.prototype.getModalContentElem = function (editor) {
919
+ var _a = this, widthInputId = _a.widthInputId, heightInputId = _a.heightInputId, buttonId = _a.buttonId;
920
+ var _b = __read(core.genModalInputElems(core.t('videoModule.width'), widthInputId, 'auto'), 2), widthContainerElem = _b[0], inputWidthElem = _b[1];
921
+ var $inputWidth = $__default["default"](inputWidthElem);
922
+ var _c = __read(core.genModalInputElems(core.t('videoModule.height'), heightInputId, 'auto'), 2), heightContainerElem = _c[0], inputHeightElem = _c[1];
923
+ var $inputHeight = $__default["default"](inputHeightElem);
924
+ var _d = __read(core.genModalButtonElems(buttonId, core.t('videoModule.ok')), 1), buttonContainerElem = _d[0];
925
+ if (this.$content == null) {
926
+ // 第一次渲染
927
+ var $content_1 = $__default["default"]('<div></div>');
928
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
929
+ $content_1.on('click', "#" + buttonId, function (e) {
930
+ e.preventDefault();
931
+ var rawWidth = $content_1.find("#" + widthInputId).val().trim();
932
+ var rawHeight = $content_1.find("#" + heightInputId).val().trim();
933
+ var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
934
+ var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
935
+ var width = 'auto';
936
+ var height = 'auto';
937
+ if (isPercentage(rawWidth)) {
938
+ width = rawWidth;
939
+ }
940
+ else if (isNumeric(rawWidth)) {
941
+ width = parseInt(rawWidth) + 'px';
942
+ }
943
+ if (isPercentage(rawHeight)) {
944
+ height = rawHeight;
945
+ }
946
+ else if (isNumeric(rawHeight)) {
947
+ height = parseInt(rawHeight) + 'px';
948
+ }
949
+ var _a = videoNode.style, style = _a === void 0 ? {} : _a;
950
+ editor.restoreSelection();
951
+ var props = {
952
+ style: __assign(__assign({}, style), { width: width, height: height }),
953
+ };
954
+ // 修改尺寸
955
+ slate.Transforms.setNodes(editor, props, {
956
+ match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
957
+ });
958
+ editor.hidePanelOrModal(); // 隐藏 modal
959
+ });
960
+ this.$content = $content_1;
961
+ }
962
+ var $content = this.$content;
963
+ // 先清空,再重新添加 DOM 内容
964
+ $content.empty();
965
+ $content.append(widthContainerElem);
966
+ $content.append(heightContainerElem);
967
+ $content.append(buttonContainerElem);
968
+ var videoNode = this.getSelectedVideoNode(editor);
969
+ if (videoNode == null)
970
+ return $content[0];
971
+ // 初始化 input 值
972
+ var _e = videoNode.style, style = _e === void 0 ? {} : _e;
973
+ var _f = style.width, width = _f === void 0 ? '' : _f, _g = style.height, height = _g === void 0 ? '' : _g;
974
+ $inputWidth.val(width);
975
+ $inputHeight.val(height);
976
+ setTimeout(function () {
977
+ $inputWidth.focus();
978
+ });
979
+ return $content[0];
980
+ };
981
+ return EditorVideoSizeMenu;
982
+ }());
983
+
984
+ /**
985
+ * @description editor video menu
986
+ * @author
987
+ */
988
+ /**
989
+ * 生成唯一的 DOM ID
990
+ */
991
+ function genDomID() {
992
+ return genRandomStr('w-e-edit-video');
993
+ }
994
+ var Editvideo = /** @class */ (function () {
995
+ function Editvideo() {
996
+ this.title = core.t('videoModule.edit');
997
+ this.iconSvg = PENCIL_SVG;
998
+ this.tag = 'button';
999
+ this.showModal = true; // 点击 button 时显示 modal
1000
+ this.modalWidth = 300;
1001
+ this.$content = null;
1002
+ this.srcInputId = genDomID();
1003
+ this.posterInputId = genDomID();
1004
+ this.buttonId = genDomID();
1005
+ }
1006
+ Editvideo.prototype.getSelectedVideoNode = function (editor) {
1007
+ return core.DomEditor.getSelectedNodeByType(editor, 'video');
1008
+ };
1009
+ Editvideo.prototype.getValue = function (editor) {
1010
+ // 编辑视频,用不到 getValue
1011
+ return '';
1012
+ };
1013
+ Editvideo.prototype.isActive = function (editor) {
1014
+ // 无需 active
1015
+ return false;
1016
+ };
1017
+ Editvideo.prototype.exec = function (editor, value) {
1018
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
1019
+ // 此处空着即可
1020
+ };
1021
+ Editvideo.prototype.isDisabled = function (editor) {
1022
+ if (editor.selection == null)
1023
+ return true;
1024
+ var videoNode = this.getSelectedVideoNode(editor);
1025
+ if (videoNode == null) {
1026
+ // 选区未处于 video node ,则禁用
1027
+ return true;
1028
+ }
1029
+ return false;
1030
+ };
1031
+ Editvideo.prototype.getModalPositionNode = function (editor) {
1032
+ return this.getSelectedVideoNode(editor);
1033
+ };
1034
+ Editvideo.prototype.getModalContentElem = function (editor) {
1035
+ var _this = this;
1036
+ var _a = this, srcInputId = _a.srcInputId, posterInputId = _a.posterInputId, buttonId = _a.buttonId;
1037
+ // 获取 input button elem
1038
+ var _b = __read(core.genModalInputElems(core.t('videoModule.videoSrc'), srcInputId, core.t('videoModule.videoSrcPlaceHolder')), 2), srcContainerElem = _b[0], inputSrcElem = _b[1];
1039
+ var _c = __read(core.genModalInputElems(core.t('videoModule.videoPoster'), posterInputId, core.t('videoModule.videoPosterPlaceHolder')), 2), posterContainerElem = _c[0], inputPosterElem = _c[1];
1040
+ var $inputSrc = $__default["default"](inputSrcElem);
1041
+ var $inputPoster = $__default["default"](inputPosterElem);
1042
+ var _d = __read(core.genModalButtonElems(buttonId, core.t('videoModule.ok')), 1), buttonContainerElem = _d[0];
1043
+ if (this.$content == null) {
1044
+ // 第一次渲染
1045
+ var $content_1 = $__default["default"]('<div></div>');
1046
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
1047
+ $content_1.on('click', "#" + buttonId, function (e) { return __awaiter(_this, void 0, void 0, function () {
1048
+ var src, poster, videoId, props;
1049
+ return __generator(this, function (_a) {
1050
+ e.preventDefault();
1051
+ src = $content_1.find("#" + srcInputId).val().trim();
1052
+ poster = $content_1.find("#" + posterInputId).val().trim();
1053
+ videoId = genRandomStr('video-');
1054
+ props = {
1055
+ src: src,
1056
+ poster: poster,
1057
+ key: videoId,
1058
+ };
1059
+ editor.restoreSelection();
1060
+ // 修改尺寸
1061
+ slate.Transforms.setNodes(editor, props, {
1062
+ match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
1063
+ });
1064
+ editor.hidePanelOrModal(); // 隐藏 modal
1065
+ return [2 /*return*/];
1066
+ });
1067
+ }); });
1068
+ // 记录属性,重要
1069
+ this.$content = $content_1;
1070
+ }
1071
+ var $content = this.$content;
1072
+ $content.empty(); // 先清空内容
1073
+ // append inputs and button
1074
+ $content.append(srcContainerElem);
1075
+ $content.append(posterContainerElem);
1076
+ $content.append(buttonContainerElem);
1077
+ var videoNode = this.getSelectedVideoNode(editor);
1078
+ if (videoNode == null)
1079
+ return $content[0];
1080
+ // 初始化 input 值
1081
+ var _e = videoNode.src, src = _e === void 0 ? '' : _e, _f = videoNode.poster, poster = _f === void 0 ? '' : _f;
1082
+ $inputSrc.val(src);
1083
+ $inputPoster.val(poster);
1084
+ // focus 一个 input(异步,此时 DOM 尚未渲染)
1085
+ setTimeout(function () {
1086
+ $inputSrc.focus();
1087
+ });
1088
+ return $content[0];
1089
+ };
1090
+ return Editvideo;
1091
+ }());
1092
+
1093
+ /**
1094
+ * @description video menu config
1095
+ * @author wangfupeng
1096
+ */
1097
+ function genUploadVideoMenuConfig() {
1098
+ return {
1099
+ server: '',
1100
+ fieldName: 'wangeditor-uploaded-video',
1101
+ maxFileSize: 10 * 1024 * 1024,
1102
+ maxNumberOfFiles: 5,
1103
+ allowedFileTypes: ['video/*'],
1104
+ meta: {
1105
+ // 自定义上传参数,例如传递验证的 token 等。参数会被添加到 formData 中,一起上传到服务端。
1106
+ // 例如:token: 'xxxxx', x: 100
1107
+ },
1108
+ metaWithUrl: false,
1109
+ // headers: {
1110
+ // // 自定义 http headers
1111
+ // // 例如:Accept: 'text/x-json', a: 100,
1112
+ // },
1113
+ withCredentials: false,
1114
+ timeout: 30 * 1000,
1115
+ onBeforeUpload: function (files) { return files; },
1116
+ onProgress: function (progress) {
1117
+ /* on progress */
1118
+ },
1119
+ onSuccess: function (file, res) {
1120
+ /* on success */
1121
+ },
1122
+ onFailed: function (file, res) {
1123
+ /* on failed */
1124
+ console.error("'" + file.name + "' upload failed", res);
1125
+ },
1126
+ onError: function (file, err, res) {
1127
+ /* on error */
1128
+ /* on timeout */
1129
+ console.error("'" + file.name + " upload error", err, res);
1130
+ },
1131
+ // 自定义插入视频,用户配置
1132
+ // customInsert: (res, insertFn) => {},
1133
+ // 自定义上传视频,用户配置
1134
+ // customUpload: (file, insertFn) => {},
1135
+ // 自定义选择,并上传视频,如:图床 (用户配置)
1136
+ // customBrowseAndUpload: insertFn => {},
1137
+ };
1138
+ }
1139
+ /**
1140
+ * 生成插入网络视频的配置
1141
+ */
1142
+ function genInsertVideoMenuConfig() {
1143
+ return {
1144
+ onInsertedVideo: function (node) {
1145
+ // 插入视频之后的 callback
1146
+ },
1147
+ /**
1148
+ * 检查 video ,支持 async
1149
+ * @param src src
1150
+ * @param poster poster
1151
+ */
1152
+ checkVideo: function (src, poster) {
1153
+ // 1. 返回 true ,说明检查通过
1154
+ // 2. 返回一个字符串,说明检查未通过,编辑器会阻止插入。会 alert 出错误信息(即返回的字符串)
1155
+ // 3. 返回 undefined(即没有任何返回),说明检查未通过,编辑器会阻止插入
1156
+ return true;
1157
+ },
1158
+ /**
1159
+ * 转换 video src
1160
+ * @param src src
1161
+ * @returns new src
1162
+ */
1163
+ parseVideoSrc: function (src) {
1164
+ return src;
1165
+ },
1166
+ };
1167
+ }
1168
+
1169
+ /**
1170
+ * @description video menu
1171
+ * @author wangfupeng
1172
+ */
1173
+ var insertVideoMenuConf = {
1174
+ key: 'insertVideo',
1175
+ factory: function () {
1176
+ return new InsertVideoMenu();
1177
+ },
1178
+ // 默认的菜单菜单配置,将存储在 editorConfig.MENU_CONF[key] 中
1179
+ // 创建编辑器时,可通过 editorConfig.MENU_CONF[key] = {...} 来修改
1180
+ config: genInsertVideoMenuConfig(),
1181
+ };
1182
+ var uploadVideoMenuConf = {
1183
+ key: 'uploadVideo',
1184
+ factory: function () {
1185
+ return new UploadVideoMenu();
1186
+ },
1187
+ // 默认的菜单菜单配置,将存储在 editorConfig.MENU_CONF[key] 中
1188
+ // 创建编辑器时,可通过 editorConfig.MENU_CONF[key] = {...} 来修改
1189
+ config: genUploadVideoMenuConfig(),
1190
+ };
1191
+ var editorVideoSizeMenuConf = {
1192
+ key: 'editVideoSize',
1193
+ factory: function () {
1194
+ return new EditorVideoSizeMenu();
1195
+ },
1196
+ };
1197
+ var editorVideoSrcMenuConf = {
1198
+ key: 'editVideoSrc',
1199
+ factory: function () {
1200
+ return new Editvideo();
1201
+ },
1202
+ };
1203
+ // export const deleteVideoMenuConf = {
1204
+ // key: 'deleteVideo',
1205
+ // factory() {
1206
+ // return new DeleteVideoMenu()
1207
+ // },
1208
+ // }
1209
+ // 键盘能删除 video 了,注释掉这个菜单 wangfupeng 22.02.23
1210
+
1211
+ /**
1212
+ * @description video module
1213
+ * @author wangfupeng
1214
+ */
1215
+ var video = {
1216
+ renderElems: [renderVideoConf],
1217
+ elemsToHtml: [videoToHtmlConf],
1218
+ preParseHtml: [preParseHtmlConf],
1219
+ parseElemsHtml: [parseHtmlConf],
1220
+ menus: [
1221
+ insertVideoMenuConf,
1222
+ uploadVideoMenuConf,
1223
+ editorVideoSizeMenuConf,
1224
+ editorVideoSrcMenuConf,
1225
+ ],
1226
+ editorPlugin: withVideo,
1227
+ };
1228
+
1229
+ /**
1230
+ * @description video module
1231
+ * @author wangfupeng
1232
+ */
1233
+
1234
+ return video;
1235
+
1236
+ }));