@ckeditor/ckeditor5-watchdog 36.0.1 → 37.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/watchdog.js +1 -1
- package/package.json +16 -11
- package/src/contextwatchdog.d.ts +333 -0
- package/src/contextwatchdog.js +389 -547
- package/src/editorwatchdog.d.ts +155 -0
- package/src/editorwatchdog.js +203 -313
- package/src/index.d.ts +10 -0
- package/src/index.js +0 -2
- package/src/utils/areconnectedthroughproperties.d.ts +8 -0
- package/src/utils/areconnectedthroughproperties.js +41 -64
- package/src/utils/getsubnodes.d.ts +8 -0
- package/src/utils/getsubnodes.js +68 -87
- package/src/watchdog.d.ts +229 -0
- package/src/watchdog.js +173 -347
package/build/watchdog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
|
-
*/(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ContextWatchdog:()=>Fn,EditorWatchdog:()=>Dn,Watchdog:()=>r});class r{constructor(t){if(this.crashes=[],this.state="initializing",this._crashNumberLimit="number"==typeof t.crashNumberLimit?t.crashNumberLimit:3,this._now=Date.now,this._minimumNonErrorTimePeriod="number"==typeof t.minimumNonErrorTimePeriod?t.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=t=>{const e=t.error||t.reason;e instanceof Error&&this._handleError(e,t)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}setCreator(t){this._creator=t}setDestructor(t){this._destructor=t}destroy(){this._stopErrorHandling(),this._listeners={}}on(t,e){this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e)}off(t,e){this._listeners[t]=this._listeners[t].filter((t=>t!==e))}_fire(t,...e){const r=this._listeners[t]||[];for(const t of r)t.apply(this,[null,...e])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(t,e){if(this._shouldReactToError(t)){this.crashes.push({message:t.message,stack:t.stack,filename:e.filename,lineno:e.lineno,colno:e.colno,date:this._now()});const r=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:t,causesRestart:r}),r?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(t){return t.is&&t.is("CKEditorError")&&void 0!==t.context&&null!==t.context&&"ready"===this.state&&this._isErrorComingFromThisItem(t)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;return(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}const n=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const o="object"==typeof global&&global&&global.Object===Object&&global;var s="object"==typeof self&&self&&self.Object===Object&&self;const i=o||s||Function("return this")();const c=function(){return i.Date.now()};var a=/\s/;const u=function(t){for(var e=t.length;e--&&a.test(t.charAt(e)););return e};var h=/^\s+/;const l=function(t){return t?t.slice(0,u(t)+1).replace(h,""):t};const f=i.Symbol;var d=Object.prototype,_=d.hasOwnProperty,p=d.toString,y=f?f.toStringTag:void 0;const v=function(t){var e=_.call(t,y),r=t[y];try{t[y]=void 0;var n=!0}catch(t){}var o=p.call(t);return n&&(e?t[y]=r:delete t[y]),o};var b=Object.prototype.toString;const g=function(t){return b.call(t)};var m="[object Null]",j="[object Undefined]",w=f?f.toStringTag:void 0;const E=function(t){return null==t?void 0===t?j:m:w&&w in Object(t)?v(t):g(t)};const x=function(t){return null!=t&&"object"==typeof t};var O="[object Symbol]";const A=function(t){return"symbol"==typeof t||x(t)&&E(t)==O};var P=NaN,S=/^[-+]0x[0-9a-f]+$/i,C=/^0b[01]+$/i,T=/^0o[0-7]+$/i,I=parseInt;const z=function(t){if("number"==typeof t)return t;if(A(t))return P;if(n(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=n(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=l(t);var r=C.test(t);return r||T.test(t)?I(t.slice(2),r?2:8):S.test(t)?P:+t};var D="Expected a function",W=Math.max,F=Math.min;const M=function(t,e,r){var o,s,i,a,u,h,l=0,f=!1,d=!1,_=!0;if("function"!=typeof t)throw new TypeError(D);function p(e){var r=o,n=s;return o=s=void 0,l=e,a=t.apply(n,r)}function y(t){var r=t-h;return void 0===h||r>=e||r<0||d&&t-l>=i}function v(){var t=c();if(y(t))return b(t);u=setTimeout(v,function(t){var r=e-(t-h);return d?F(r,i-(t-l)):r}(t))}function b(t){return u=void 0,_&&o?p(t):(o=s=void 0,a)}function g(){var t=c(),r=y(t);if(o=arguments,s=this,h=t,r){if(void 0===u)return function(t){return l=t,u=setTimeout(v,e),f?p(t):a}(h);if(d)return clearTimeout(u),u=setTimeout(v,e),p(h)}return void 0===u&&(u=setTimeout(v,e)),a}return e=z(e)||0,n(r)&&(f=!!r.leading,i=(d="maxWait"in r)?W(z(r.maxWait)||0,e):i,_="trailing"in r?!!r.trailing:_),g.cancel=function(){void 0!==u&&clearTimeout(u),l=0,o=h=s=u=void 0},g.flush=function(){return void 0===u?a:b(c())},g};var N="Expected a function";const q=function(t,e,r){var o=!0,s=!0;if("function"!=typeof t)throw new TypeError(N);return n(r)&&(o="leading"in r?!!r.leading:o,s="trailing"in r?!!r.trailing:s),M(t,e,{leading:o,maxWait:e,trailing:s})};const U=function(){this.__data__=[],this.size=0};const R=function(t,e){return t===e||t!=t&&e!=e};const $=function(t,e){for(var r=t.length;r--;)if(R(t[r][0],e))return r;return-1};var k=Array.prototype.splice;const L=function(t){var e=this.__data__,r=$(e,t);return!(r<0)&&(r==e.length-1?e.pop():k.call(e,r,1),--this.size,!0)};const H=function(t){var e=this.__data__,r=$(e,t);return r<0?void 0:e[r][1]};const B=function(t){return $(this.__data__,t)>-1};const Q=function(t,e){var r=this.__data__,n=$(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function V(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}V.prototype.clear=U,V.prototype.delete=L,V.prototype.get=H,V.prototype.has=B,V.prototype.set=Q;const K=V;const G=function(){this.__data__=new K,this.size=0};const Y=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r};const J=function(t){return this.__data__.get(t)};const X=function(t){return this.__data__.has(t)};var Z="[object AsyncFunction]",tt="[object Function]",et="[object GeneratorFunction]",rt="[object Proxy]";const nt=function(t){if(!n(t))return!1;var e=E(t);return e==tt||e==et||e==Z||e==rt};const ot=i["__core-js_shared__"];var st,it=(st=/[^.]+$/.exec(ot&&ot.keys&&ot.keys.IE_PROTO||""))?"Symbol(src)_1."+st:"";const ct=function(t){return!!it&&it in t};var at=Function.prototype.toString;const ut=function(t){if(null!=t){try{return at.call(t)}catch(t){}try{return t+""}catch(t){}}return""};var ht=/^\[object .+?Constructor\]$/,lt=Function.prototype,ft=Object.prototype,dt=lt.toString,_t=ft.hasOwnProperty,pt=RegExp("^"+dt.call(_t).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const yt=function(t){return!(!n(t)||ct(t))&&(nt(t)?pt:ht).test(ut(t))};const vt=function(t,e){return null==t?void 0:t[e]};const bt=function(t,e){var r=vt(t,e);return yt(r)?r:void 0};const gt=bt(i,"Map");const mt=bt(Object,"create");const jt=function(){this.__data__=mt?mt(null):{},this.size=0};const wt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e};var Et="__lodash_hash_undefined__",xt=Object.prototype.hasOwnProperty;const Ot=function(t){var e=this.__data__;if(mt){var r=e[t];return r===Et?void 0:r}return xt.call(e,t)?e[t]:void 0};var At=Object.prototype.hasOwnProperty;const Pt=function(t){var e=this.__data__;return mt?void 0!==e[t]:At.call(e,t)};var St="__lodash_hash_undefined__";const Ct=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=mt&&void 0===e?St:e,this};function Tt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Tt.prototype.clear=jt,Tt.prototype.delete=wt,Tt.prototype.get=Ot,Tt.prototype.has=Pt,Tt.prototype.set=Ct;const It=Tt;const zt=function(){this.size=0,this.__data__={hash:new It,map:new(gt||K),string:new It}};const Dt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};const Wt=function(t,e){var r=t.__data__;return Dt(e)?r["string"==typeof e?"string":"hash"]:r.map};const Ft=function(t){var e=Wt(this,t).delete(t);return this.size-=e?1:0,e};const Mt=function(t){return Wt(this,t).get(t)};const Nt=function(t){return Wt(this,t).has(t)};const qt=function(t,e){var r=Wt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Ut(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Ut.prototype.clear=zt,Ut.prototype.delete=Ft,Ut.prototype.get=Mt,Ut.prototype.has=Nt,Ut.prototype.set=qt;const Rt=Ut;var $t=200;const kt=function(t,e){var r=this.__data__;if(r instanceof K){var n=r.__data__;if(!gt||n.length<$t-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Rt(n)}return r.set(t,e),this.size=r.size,this};function Lt(t){var e=this.__data__=new K(t);this.size=e.size}Lt.prototype.clear=G,Lt.prototype.delete=Y,Lt.prototype.get=J,Lt.prototype.has=X,Lt.prototype.set=kt;const Ht=Lt;const Bt=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t};const Qt=function(){try{var t=bt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();const Vt=function(t,e,r){"__proto__"==e&&Qt?Qt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r};var Kt=Object.prototype.hasOwnProperty;const Gt=function(t,e,r){var n=t[e];Kt.call(t,e)&&R(n,r)&&(void 0!==r||e in t)||Vt(t,e,r)};const Yt=function(t,e,r,n){var o=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var c=e[s],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?Vt(r,c,a):Gt(r,c,a)}return r};const Jt=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n};var Xt="[object Arguments]";const Zt=function(t){return x(t)&&E(t)==Xt};var te=Object.prototype,ee=te.hasOwnProperty,re=te.propertyIsEnumerable;const ne=Zt(function(){return arguments}())?Zt:function(t){return x(t)&&ee.call(t,"callee")&&!re.call(t,"callee")};const oe=Array.isArray;const se=function(){return!1};var ie="object"==typeof exports&&exports&&!exports.nodeType&&exports,ce=ie&&"object"==typeof module&&module&&!module.nodeType&&module,ae=ce&&ce.exports===ie?i.Buffer:void 0;const ue=(ae?ae.isBuffer:void 0)||se;var he=9007199254740991,le=/^(?:0|[1-9]\d*)$/;const fe=function(t,e){var r=typeof t;return!!(e=null==e?he:e)&&("number"==r||"symbol"!=r&&le.test(t))&&t>-1&&t%1==0&&t<e};var de=9007199254740991;const _e=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=de};var pe={};pe["[object Float32Array]"]=pe["[object Float64Array]"]=pe["[object Int8Array]"]=pe["[object Int16Array]"]=pe["[object Int32Array]"]=pe["[object Uint8Array]"]=pe["[object Uint8ClampedArray]"]=pe["[object Uint16Array]"]=pe["[object Uint32Array]"]=!0,pe["[object Arguments]"]=pe["[object Array]"]=pe["[object ArrayBuffer]"]=pe["[object Boolean]"]=pe["[object DataView]"]=pe["[object Date]"]=pe["[object Error]"]=pe["[object Function]"]=pe["[object Map]"]=pe["[object Number]"]=pe["[object Object]"]=pe["[object RegExp]"]=pe["[object Set]"]=pe["[object String]"]=pe["[object WeakMap]"]=!1;const ye=function(t){return x(t)&&_e(t.length)&&!!pe[E(t)]};const ve=function(t){return function(e){return t(e)}};var be="object"==typeof exports&&exports&&!exports.nodeType&&exports,ge=be&&"object"==typeof module&&module&&!module.nodeType&&module,me=ge&&ge.exports===be&&o.process;const je=function(){try{var t=ge&&ge.require&&ge.require("util").types;return t||me&&me.binding&&me.binding("util")}catch(t){}}();var we=je&&je.isTypedArray;const Ee=we?ve(we):ye;var xe=Object.prototype.hasOwnProperty;const Oe=function(t,e){var r=oe(t),n=!r&&ne(t),o=!r&&!n&&ue(t),s=!r&&!n&&!o&&Ee(t),i=r||n||o||s,c=i?Jt(t.length,String):[],a=c.length;for(var u in t)!e&&!xe.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||fe(u,a))||c.push(u);return c};var Ae=Object.prototype;const Pe=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ae)};const Se=function(t,e){return function(r){return t(e(r))}};const Ce=Se(Object.keys,Object);var Te=Object.prototype.hasOwnProperty;const Ie=function(t){if(!Pe(t))return Ce(t);var e=[];for(var r in Object(t))Te.call(t,r)&&"constructor"!=r&&e.push(r);return e};const ze=function(t){return null!=t&&_e(t.length)&&!nt(t)};const De=function(t){return ze(t)?Oe(t):Ie(t)};const We=function(t,e){return t&&Yt(e,De(e),t)};const Fe=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e};var Me=Object.prototype.hasOwnProperty;const Ne=function(t){if(!n(t))return Fe(t);var e=Pe(t),r=[];for(var o in t)("constructor"!=o||!e&&Me.call(t,o))&&r.push(o);return r};const qe=function(t){return ze(t)?Oe(t,!0):Ne(t)};const Ue=function(t,e){return t&&Yt(e,qe(e),t)};var Re="object"==typeof exports&&exports&&!exports.nodeType&&exports,$e=Re&&"object"==typeof module&&module&&!module.nodeType&&module,ke=$e&&$e.exports===Re?i.Buffer:void 0,Le=ke?ke.allocUnsafe:void 0;const He=function(t,e){if(e)return t.slice();var r=t.length,n=Le?Le(r):new t.constructor(r);return t.copy(n),n};const Be=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e};const Qe=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,s=[];++r<n;){var i=t[r];e(i,r,t)&&(s[o++]=i)}return s};const Ve=function(){return[]};var Ke=Object.prototype.propertyIsEnumerable,Ge=Object.getOwnPropertySymbols;const Ye=Ge?function(t){return null==t?[]:(t=Object(t),Qe(Ge(t),(function(e){return Ke.call(t,e)})))}:Ve;const Je=function(t,e){return Yt(t,Ye(t),e)};const Xe=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t};const Ze=Se(Object.getPrototypeOf,Object);const tr=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Xe(e,Ye(t)),t=Ze(t);return e}:Ve;const er=function(t,e){return Yt(t,tr(t),e)};const rr=function(t,e,r){var n=e(t);return oe(t)?n:Xe(n,r(t))};const nr=function(t){return rr(t,De,Ye)};const or=function(t){return rr(t,qe,tr)};const sr=bt(i,"DataView");const ir=bt(i,"Promise");const cr=bt(i,"Set");const ar=bt(i,"WeakMap");var ur="[object Map]",hr="[object Promise]",lr="[object Set]",fr="[object WeakMap]",dr="[object DataView]",_r=ut(sr),pr=ut(gt),yr=ut(ir),vr=ut(cr),br=ut(ar),gr=E;(sr&&gr(new sr(new ArrayBuffer(1)))!=dr||gt&&gr(new gt)!=ur||ir&&gr(ir.resolve())!=hr||cr&&gr(new cr)!=lr||ar&&gr(new ar)!=fr)&&(gr=function(t){var e=E(t),r="[object Object]"==e?t.constructor:void 0,n=r?ut(r):"";if(n)switch(n){case _r:return dr;case pr:return ur;case yr:return hr;case vr:return lr;case br:return fr}return e});const mr=gr;var jr=Object.prototype.hasOwnProperty;const wr=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&jr.call(t,"index")&&(r.index=t.index,r.input=t.input),r};const Er=i.Uint8Array;const xr=function(t){var e=new t.constructor(t.byteLength);return new Er(e).set(new Er(t)),e};const Or=function(t,e){var r=e?xr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)};var Ar=/\w*$/;const Pr=function(t){var e=new t.constructor(t.source,Ar.exec(t));return e.lastIndex=t.lastIndex,e};var Sr=f?f.prototype:void 0,Cr=Sr?Sr.valueOf:void 0;const Tr=function(t){return Cr?Object(Cr.call(t)):{}};const Ir=function(t,e){var r=e?xr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};var zr="[object Boolean]",Dr="[object Date]",Wr="[object Map]",Fr="[object Number]",Mr="[object RegExp]",Nr="[object Set]",qr="[object String]",Ur="[object Symbol]",Rr="[object ArrayBuffer]",$r="[object DataView]",kr="[object Float32Array]",Lr="[object Float64Array]",Hr="[object Int8Array]",Br="[object Int16Array]",Qr="[object Int32Array]",Vr="[object Uint8Array]",Kr="[object Uint8ClampedArray]",Gr="[object Uint16Array]",Yr="[object Uint32Array]";const Jr=function(t,e,r){var n=t.constructor;switch(e){case Rr:return xr(t);case zr:case Dr:return new n(+t);case $r:return Or(t,r);case kr:case Lr:case Hr:case Br:case Qr:case Vr:case Kr:case Gr:case Yr:return Ir(t,r);case Wr:return new n;case Fr:case qr:return new n(t);case Mr:return Pr(t);case Nr:return new n;case Ur:return Tr(t)}};var Xr=Object.create;const Zr=function(){function t(){}return function(e){if(!n(e))return{};if(Xr)return Xr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const tn=function(t){return"function"!=typeof t.constructor||Pe(t)?{}:Zr(Ze(t))};var en="[object Map]";const rn=function(t){return x(t)&&mr(t)==en};var nn=je&&je.isMap;const on=nn?ve(nn):rn;var sn="[object Set]";const cn=function(t){return x(t)&&mr(t)==sn};var an=je&&je.isSet;const un=an?ve(an):cn;var hn=1,ln=2,fn=4,dn="[object Arguments]",_n="[object Function]",pn="[object GeneratorFunction]",yn="[object Object]",vn={};vn[dn]=vn["[object Array]"]=vn["[object ArrayBuffer]"]=vn["[object DataView]"]=vn["[object Boolean]"]=vn["[object Date]"]=vn["[object Float32Array]"]=vn["[object Float64Array]"]=vn["[object Int8Array]"]=vn["[object Int16Array]"]=vn["[object Int32Array]"]=vn["[object Map]"]=vn["[object Number]"]=vn[yn]=vn["[object RegExp]"]=vn["[object Set]"]=vn["[object String]"]=vn["[object Symbol]"]=vn["[object Uint8Array]"]=vn["[object Uint8ClampedArray]"]=vn["[object Uint16Array]"]=vn["[object Uint32Array]"]=!0,vn["[object Error]"]=vn[_n]=vn["[object WeakMap]"]=!1;const bn=function t(e,r,o,s,i,c){var a,u=r&hn,h=r&ln,l=r&fn;if(o&&(a=i?o(e,s,i,c):o(e)),void 0!==a)return a;if(!n(e))return e;var f=oe(e);if(f){if(a=wr(e),!u)return Be(e,a)}else{var d=mr(e),_=d==_n||d==pn;if(ue(e))return He(e,u);if(d==yn||d==dn||_&&!i){if(a=h||_?{}:tn(e),!u)return h?er(e,Ue(a,e)):Je(e,We(a,e))}else{if(!vn[d])return i?e:{};a=Jr(e,d,u)}}c||(c=new Ht);var p=c.get(e);if(p)return p;c.set(e,a),un(e)?e.forEach((function(n){a.add(t(n,r,o,n,e,c))})):on(e)&&e.forEach((function(n,s){a.set(s,t(n,r,o,s,e,c))}));var y=f?void 0:(l?h?or:nr:h?qe:De)(e);return Bt(y||e,(function(n,s){y&&(n=e[s=n]),Gt(a,s,t(n,r,o,s,e,c))})),a};var gn=1,mn=4;const jn=function(t,e){return bn(t,gn|mn,e="function"==typeof e?e:void 0)};var wn="[object Object]",En=Function.prototype,xn=Object.prototype,On=En.toString,An=xn.hasOwnProperty,Pn=On.call(Object);const Sn=function(t){if(!x(t)||E(t)!=wn)return!1;var e=Ze(t);if(null===e)return!0;var r=An.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&On.call(r)==Pn};const Cn=function(t){return x(t)&&1===t.nodeType&&!Sn(t)};function Tn(t,e=new Set){const r=[t],n=new Set;let o=0;for(;r.length>o;){const t=r[o++];if(!(n.has(t)||In(t)||e.has(t)))if(n.add(t),t[Symbol.iterator])try{for(const e of t)r.push(e)}catch(t){}else for(const e in t)"defaultValue"!==e&&r.push(t[e])}return n}function In(t){const e=Object.prototype.toString.call(t),r=typeof t;return"number"===r||"boolean"===r||"string"===r||"symbol"===r||"function"===r||"[object Date]"===e||"[object RegExp]"===e||"[object Module]"===e||null==t||!0===t._watchdogExcluded||t instanceof EventTarget||t instanceof Event}function zn(t,e,r=new Set){if(t===e&&("object"==typeof(n=t)&&null!==n))return!0;var n;const o=Tn(t,r),s=Tn(e,r);for(const t of o)if(s.has(t))return!0;return!1}class Dn extends r{constructor(t,e={}){super(e),this._editor=null,this._throttledSave=q(this._save.bind(this),"number"==typeof e.saveInterval?e.saveInterval:5e3),this._creator=(e,r)=>t.create(e,r),this._destructor=t=>t.destroy()}get editor(){return this._editor}get _item(){return this._editor}_restart(){return Promise.resolve().then((()=>(this.state="initializing",this._fire("stateChange"),this._destroy()))).catch((t=>{console.error("An error happened during the editor destroying.",t)})).then((()=>{if("string"==typeof this._elementOrData)return this.create(this._data,this._config,this._config.context);{const t=Object.assign({},this._config,{initialData:this._data});return this.create(this._elementOrData,t,t.context)}})).then((()=>{this._fire("restart")}))}create(t=this._elementOrData,e=this._config,r){return Promise.resolve().then((()=>(super._startErrorHandling(),this._elementOrData=t,this._config=this._cloneEditorConfiguration(e)||{},this._config.context=r,this._creator(t,this._config)))).then((t=>{this._editor=t,t.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=t.model.document.version,this._data=this._getData(),this.state="ready",this._fire("stateChange")}))}destroy(){return Promise.resolve().then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.flush();const t=this._editor;return this._editor=null,t.model.document.off("change:data",this._throttledSave),this._destructor(t)}))}_save(){const t=this._editor.model.document.version;try{this._data=this._getData(),this._lastDocumentVersion=t}catch(t){console.error(t,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(t){this._excludedProps=t}_getData(){const t={};for(const e of this._editor.model.document.getRootNames())t[e]=this._editor.data.get({rootName:e});return t}_isErrorComingFromThisItem(t){return zn(this._editor,t.context,this._excludedProps)}_cloneEditorConfiguration(t){return jn(t,((t,e)=>Cn(t)||"context"===e?t:void 0))}}const Wn=Symbol("MainQueueId");class Fn extends r{constructor(t,e={}){super(e),this._watchdogs=new Map,this._watchdogConfig=e,this._context=null,this._contextProps=new Set,this._actionQueues=new Mn,this._creator=e=>t.create(e),this._destructor=t=>t.destroy(),this._actionQueues.onEmpty((()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))}))}get context(){return this._context}create(t={}){return this._actionQueues.enqueue(Wn,(()=>(this._contextConfig=t,this._create())))}getItem(t){return this._getWatchdog(t)._item}getItemState(t){return this._getWatchdog(t).state}add(t){const e=Nn(t);return Promise.all(e.map((t=>this._actionQueues.enqueue(t.id,(()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let e;if(this._watchdogs.has(t.id))throw new Error(`Item with the given id is already added: '${t.id}'.`);if("editor"===t.type)return e=new Dn(this._watchdogConfig),e.setCreator(t.creator),e._setExcludedProperties(this._contextProps),t.destructor&&e.setDestructor(t.destructor),this._watchdogs.set(t.id,e),e.on("error",((r,{error:n,causesRestart:o})=>{this._fire("itemError",{itemId:t.id,error:n}),o&&this._actionQueues.enqueue(t.id,(()=>new Promise((r=>{e.on("restart",function n(){e.off("restart",n),this._fire("itemRestart",{itemId:t.id}),r()}.bind(this))}))))})),e.create(t.sourceElementOrData,t.config,this._context);throw new Error(`Not supported item type: '${t.type}'.`)})))))}remove(t){const e=Nn(t);return Promise.all(e.map((t=>this._actionQueues.enqueue(t,(()=>{const e=this._getWatchdog(t);return this._watchdogs.delete(t),e.destroy()})))))}destroy(){return this._actionQueues.enqueue(Wn,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Wn,(()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch((t=>{console.error("An error happened during destroying the context or items.",t)})).then((()=>this._create())).then((()=>this._fire("restart"))))))}_create(){return Promise.resolve().then((()=>(this._startErrorHandling(),this._creator(this._contextConfig)))).then((t=>(this._context=t,this._contextProps=Tn(this._context),Promise.all(Array.from(this._watchdogs.values()).map((t=>(t._setExcludedProperties(this._contextProps),t.create(void 0,void 0,this._context))))))))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling();const t=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map((t=>t.destroy()))).then((()=>this._destructor(t)))}))}_getWatchdog(t){const e=this._watchdogs.get(t);if(!e)throw new Error(`Item with the given id was not registered: ${t}.`);return e}_isErrorComingFromThisItem(t){for(const e of this._watchdogs.values())if(e._isErrorComingFromThisItem(t))return!1;return zn(this._context,t.context)}}class Mn{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._actions=new WeakMap,this._lastActionId=0,this._activeActions=0}onEmpty(t){this._onEmptyCallbacks.push(t)}enqueue(t,e){const r=t===Wn;this._activeActions++,this._queues.get(t)||this._queues.set(t,Promise.resolve());const n=(r?Promise.all(this._queues.values()):Promise.all([this._queues.get(Wn),this._queues.get(t)])).then(e),o=n.catch((()=>{}));return this._queues.set(t,o),n.finally((()=>{this._activeActions--,this._queues.get(t)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((t=>t()))}))}}function Nn(t){return Array.isArray(t)?t:[t]}(window.CKEditor5=window.CKEditor5||{}).watchdog=e})();
|
|
4
|
+
*/(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ContextWatchdog:()=>Wn,EditorWatchdog:()=>zn,Watchdog:()=>r});class r{constructor(t){if(this.crashes=[],this.state="initializing",this._now=Date.now,this.crashes=[],this._crashNumberLimit="number"==typeof t.crashNumberLimit?t.crashNumberLimit:3,this._minimumNonErrorTimePeriod="number"==typeof t.minimumNonErrorTimePeriod?t.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=t=>{const e="error"in t?t.error:t.reason;e instanceof Error&&this._handleError(e,t)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(t,e){this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(e)}off(t,e){this._listeners[t]=this._listeners[t].filter((t=>t!==e))}_fire(t,...e){const r=this._listeners[t]||[];for(const t of r)t.apply(this,[null,...e])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(t,e){if(this._shouldReactToError(t)){this.crashes.push({message:t.message,stack:t.stack,filename:e instanceof ErrorEvent?e.filename:void 0,lineno:e instanceof ErrorEvent?e.lineno:void 0,colno:e instanceof ErrorEvent?e.colno:void 0,date:this._now()});const r=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:t,causesRestart:r}),r?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(t){return t.is&&t.is("CKEditorError")&&void 0!==t.context&&null!==t.context&&"ready"===this.state&&this._isErrorComingFromThisItem(t)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;return(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function n(t,e=new Set){const r=[t],n=new Set;let s=0;for(;r.length>s;){const t=r[s++];if(!n.has(t)&&o(t)&&!e.has(t))if(n.add(t),Symbol.iterator in t)try{for(const e of t)r.push(e)}catch(t){}else for(const e in t)"defaultValue"!==e&&r.push(t[e])}return n}function o(t){const e=Object.prototype.toString.call(t),r=typeof t;return!("number"===r||"boolean"===r||"string"===r||"symbol"===r||"function"===r||"[object Date]"===e||"[object RegExp]"===e||"[object Module]"===e||null==t||t._watchdogExcluded||t instanceof EventTarget||t instanceof Event)}function s(t,e,r=new Set){if(t===e&&("object"==typeof(o=t)&&null!==o))return!0;var o;const s=n(t,r),i=n(e,r);for(const t of s)if(i.has(t))return!0;return!1}const i=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const c="object"==typeof global&&global&&global.Object===Object&&global;var a="object"==typeof self&&self&&self.Object===Object&&self;const u=c||a||Function("return this")();const h=function(){return u.Date.now()};var l=/\s/;const f=function(t){for(var e=t.length;e--&&l.test(t.charAt(e)););return e};var d=/^\s+/;const _=function(t){return t?t.slice(0,f(t)+1).replace(d,""):t};const p=u.Symbol;var y=Object.prototype,v=y.hasOwnProperty,b=y.toString,g=p?p.toStringTag:void 0;const m=function(t){var e=v.call(t,g),r=t[g];try{t[g]=void 0;var n=!0}catch(t){}var o=b.call(t);return n&&(e?t[g]=r:delete t[g]),o};var j=Object.prototype.toString;const w=function(t){return j.call(t)};var E="[object Null]",x="[object Undefined]",O=p?p.toStringTag:void 0;const A=function(t){return null==t?void 0===t?x:E:O&&O in Object(t)?m(t):w(t)};const P=function(t){return null!=t&&"object"==typeof t};var S="[object Symbol]";const C=function(t){return"symbol"==typeof t||P(t)&&A(t)==S};var T=NaN,I=/^[-+]0x[0-9a-f]+$/i,D=/^0b[01]+$/i,z=/^0o[0-7]+$/i,F=parseInt;const W=function(t){if("number"==typeof t)return t;if(C(t))return T;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=_(t);var r=D.test(t);return r||z.test(t)?F(t.slice(2),r?2:8):I.test(t)?T:+t};var M="Expected a function",N=Math.max,q=Math.min;const U=function(t,e,r){var n,o,s,c,a,u,l=0,f=!1,d=!1,_=!0;if("function"!=typeof t)throw new TypeError(M);function p(e){var r=n,s=o;return n=o=void 0,l=e,c=t.apply(s,r)}function y(t){var r=t-u;return void 0===u||r>=e||r<0||d&&t-l>=s}function v(){var t=h();if(y(t))return b(t);a=setTimeout(v,function(t){var r=e-(t-u);return d?q(r,s-(t-l)):r}(t))}function b(t){return a=void 0,_&&n?p(t):(n=o=void 0,c)}function g(){var t=h(),r=y(t);if(n=arguments,o=this,u=t,r){if(void 0===a)return function(t){return l=t,a=setTimeout(v,e),f?p(t):c}(u);if(d)return clearTimeout(a),a=setTimeout(v,e),p(u)}return void 0===a&&(a=setTimeout(v,e)),c}return e=W(e)||0,i(r)&&(f=!!r.leading,s=(d="maxWait"in r)?N(W(r.maxWait)||0,e):s,_="trailing"in r?!!r.trailing:_),g.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=u=o=a=void 0},g.flush=function(){return void 0===a?c:b(h())},g};var R="Expected a function";const $=function(t,e,r){var n=!0,o=!0;if("function"!=typeof t)throw new TypeError(R);return i(r)&&(n="leading"in r?!!r.leading:n,o="trailing"in r?!!r.trailing:o),U(t,e,{leading:n,maxWait:e,trailing:o})};const L=function(){this.__data__=[],this.size=0};const k=function(t,e){return t===e||t!=t&&e!=e};const H=function(t,e){for(var r=t.length;r--;)if(k(t[r][0],e))return r;return-1};var B=Array.prototype.splice;const Q=function(t){var e=this.__data__,r=H(e,t);return!(r<0)&&(r==e.length-1?e.pop():B.call(e,r,1),--this.size,!0)};const V=function(t){var e=this.__data__,r=H(e,t);return r<0?void 0:e[r][1]};const K=function(t){return H(this.__data__,t)>-1};const G=function(t,e){var r=this.__data__,n=H(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function Y(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Y.prototype.clear=L,Y.prototype.delete=Q,Y.prototype.get=V,Y.prototype.has=K,Y.prototype.set=G;const J=Y;const X=function(){this.__data__=new J,this.size=0};const Z=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r};const tt=function(t){return this.__data__.get(t)};const et=function(t){return this.__data__.has(t)};var rt="[object AsyncFunction]",nt="[object Function]",ot="[object GeneratorFunction]",st="[object Proxy]";const it=function(t){if(!i(t))return!1;var e=A(t);return e==nt||e==ot||e==rt||e==st};const ct=u["__core-js_shared__"];var at,ut=(at=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||""))?"Symbol(src)_1."+at:"";const ht=function(t){return!!ut&&ut in t};var lt=Function.prototype.toString;const ft=function(t){if(null!=t){try{return lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""};var dt=/^\[object .+?Constructor\]$/,_t=Function.prototype,pt=Object.prototype,yt=_t.toString,vt=pt.hasOwnProperty,bt=RegExp("^"+yt.call(vt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const gt=function(t){return!(!i(t)||ht(t))&&(it(t)?bt:dt).test(ft(t))};const mt=function(t,e){return null==t?void 0:t[e]};const jt=function(t,e){var r=mt(t,e);return gt(r)?r:void 0};const wt=jt(u,"Map");const Et=jt(Object,"create");const xt=function(){this.__data__=Et?Et(null):{},this.size=0};const Ot=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e};var At="__lodash_hash_undefined__",Pt=Object.prototype.hasOwnProperty;const St=function(t){var e=this.__data__;if(Et){var r=e[t];return r===At?void 0:r}return Pt.call(e,t)?e[t]:void 0};var Ct=Object.prototype.hasOwnProperty;const Tt=function(t){var e=this.__data__;return Et?void 0!==e[t]:Ct.call(e,t)};var It="__lodash_hash_undefined__";const Dt=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Et&&void 0===e?It:e,this};function zt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}zt.prototype.clear=xt,zt.prototype.delete=Ot,zt.prototype.get=St,zt.prototype.has=Tt,zt.prototype.set=Dt;const Ft=zt;const Wt=function(){this.size=0,this.__data__={hash:new Ft,map:new(wt||J),string:new Ft}};const Mt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};const Nt=function(t,e){var r=t.__data__;return Mt(e)?r["string"==typeof e?"string":"hash"]:r.map};const qt=function(t){var e=Nt(this,t).delete(t);return this.size-=e?1:0,e};const Ut=function(t){return Nt(this,t).get(t)};const Rt=function(t){return Nt(this,t).has(t)};const $t=function(t,e){var r=Nt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Lt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Lt.prototype.clear=Wt,Lt.prototype.delete=qt,Lt.prototype.get=Ut,Lt.prototype.has=Rt,Lt.prototype.set=$t;const kt=Lt;var Ht=200;const Bt=function(t,e){var r=this.__data__;if(r instanceof J){var n=r.__data__;if(!wt||n.length<Ht-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new kt(n)}return r.set(t,e),this.size=r.size,this};function Qt(t){var e=this.__data__=new J(t);this.size=e.size}Qt.prototype.clear=X,Qt.prototype.delete=Z,Qt.prototype.get=tt,Qt.prototype.has=et,Qt.prototype.set=Bt;const Vt=Qt;const Kt=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t};const Gt=function(){try{var t=jt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();const Yt=function(t,e,r){"__proto__"==e&&Gt?Gt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r};var Jt=Object.prototype.hasOwnProperty;const Xt=function(t,e,r){var n=t[e];Jt.call(t,e)&&k(n,r)&&(void 0!==r||e in t)||Yt(t,e,r)};const Zt=function(t,e,r,n){var o=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var c=e[s],a=n?n(r[c],t[c],c,r,t):void 0;void 0===a&&(a=t[c]),o?Yt(r,c,a):Xt(r,c,a)}return r};const te=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n};var ee="[object Arguments]";const re=function(t){return P(t)&&A(t)==ee};var ne=Object.prototype,oe=ne.hasOwnProperty,se=ne.propertyIsEnumerable;const ie=re(function(){return arguments}())?re:function(t){return P(t)&&oe.call(t,"callee")&&!se.call(t,"callee")};const ce=Array.isArray;const ae=function(){return!1};var ue="object"==typeof exports&&exports&&!exports.nodeType&&exports,he=ue&&"object"==typeof module&&module&&!module.nodeType&&module,le=he&&he.exports===ue?u.Buffer:void 0;const fe=(le?le.isBuffer:void 0)||ae;var de=9007199254740991,_e=/^(?:0|[1-9]\d*)$/;const pe=function(t,e){var r=typeof t;return!!(e=null==e?de:e)&&("number"==r||"symbol"!=r&&_e.test(t))&&t>-1&&t%1==0&&t<e};var ye=9007199254740991;const ve=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=ye};var be={};be["[object Float32Array]"]=be["[object Float64Array]"]=be["[object Int8Array]"]=be["[object Int16Array]"]=be["[object Int32Array]"]=be["[object Uint8Array]"]=be["[object Uint8ClampedArray]"]=be["[object Uint16Array]"]=be["[object Uint32Array]"]=!0,be["[object Arguments]"]=be["[object Array]"]=be["[object ArrayBuffer]"]=be["[object Boolean]"]=be["[object DataView]"]=be["[object Date]"]=be["[object Error]"]=be["[object Function]"]=be["[object Map]"]=be["[object Number]"]=be["[object Object]"]=be["[object RegExp]"]=be["[object Set]"]=be["[object String]"]=be["[object WeakMap]"]=!1;const ge=function(t){return P(t)&&ve(t.length)&&!!be[A(t)]};const me=function(t){return function(e){return t(e)}};var je="object"==typeof exports&&exports&&!exports.nodeType&&exports,we=je&&"object"==typeof module&&module&&!module.nodeType&&module,Ee=we&&we.exports===je&&c.process;const xe=function(){try{var t=we&&we.require&&we.require("util").types;return t||Ee&&Ee.binding&&Ee.binding("util")}catch(t){}}();var Oe=xe&&xe.isTypedArray;const Ae=Oe?me(Oe):ge;var Pe=Object.prototype.hasOwnProperty;const Se=function(t,e){var r=ce(t),n=!r&&ie(t),o=!r&&!n&&fe(t),s=!r&&!n&&!o&&Ae(t),i=r||n||o||s,c=i?te(t.length,String):[],a=c.length;for(var u in t)!e&&!Pe.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||pe(u,a))||c.push(u);return c};var Ce=Object.prototype;const Te=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ce)};const Ie=function(t,e){return function(r){return t(e(r))}};const De=Ie(Object.keys,Object);var ze=Object.prototype.hasOwnProperty;const Fe=function(t){if(!Te(t))return De(t);var e=[];for(var r in Object(t))ze.call(t,r)&&"constructor"!=r&&e.push(r);return e};const We=function(t){return null!=t&&ve(t.length)&&!it(t)};const Me=function(t){return We(t)?Se(t):Fe(t)};const Ne=function(t,e){return t&&Zt(e,Me(e),t)};const qe=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e};var Ue=Object.prototype.hasOwnProperty;const Re=function(t){if(!i(t))return qe(t);var e=Te(t),r=[];for(var n in t)("constructor"!=n||!e&&Ue.call(t,n))&&r.push(n);return r};const $e=function(t){return We(t)?Se(t,!0):Re(t)};const Le=function(t,e){return t&&Zt(e,$e(e),t)};var ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,He=ke&&"object"==typeof module&&module&&!module.nodeType&&module,Be=He&&He.exports===ke?u.Buffer:void 0,Qe=Be?Be.allocUnsafe:void 0;const Ve=function(t,e){if(e)return t.slice();var r=t.length,n=Qe?Qe(r):new t.constructor(r);return t.copy(n),n};const Ke=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e};const Ge=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,s=[];++r<n;){var i=t[r];e(i,r,t)&&(s[o++]=i)}return s};const Ye=function(){return[]};var Je=Object.prototype.propertyIsEnumerable,Xe=Object.getOwnPropertySymbols;const Ze=Xe?function(t){return null==t?[]:(t=Object(t),Ge(Xe(t),(function(e){return Je.call(t,e)})))}:Ye;const tr=function(t,e){return Zt(t,Ze(t),e)};const er=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t};const rr=Ie(Object.getPrototypeOf,Object);const nr=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)er(e,Ze(t)),t=rr(t);return e}:Ye;const or=function(t,e){return Zt(t,nr(t),e)};const sr=function(t,e,r){var n=e(t);return ce(t)?n:er(n,r(t))};const ir=function(t){return sr(t,Me,Ze)};const cr=function(t){return sr(t,$e,nr)};const ar=jt(u,"DataView");const ur=jt(u,"Promise");const hr=jt(u,"Set");const lr=jt(u,"WeakMap");var fr="[object Map]",dr="[object Promise]",_r="[object Set]",pr="[object WeakMap]",yr="[object DataView]",vr=ft(ar),br=ft(wt),gr=ft(ur),mr=ft(hr),jr=ft(lr),wr=A;(ar&&wr(new ar(new ArrayBuffer(1)))!=yr||wt&&wr(new wt)!=fr||ur&&wr(ur.resolve())!=dr||hr&&wr(new hr)!=_r||lr&&wr(new lr)!=pr)&&(wr=function(t){var e=A(t),r="[object Object]"==e?t.constructor:void 0,n=r?ft(r):"";if(n)switch(n){case vr:return yr;case br:return fr;case gr:return dr;case mr:return _r;case jr:return pr}return e});const Er=wr;var xr=Object.prototype.hasOwnProperty;const Or=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&xr.call(t,"index")&&(r.index=t.index,r.input=t.input),r};const Ar=u.Uint8Array;const Pr=function(t){var e=new t.constructor(t.byteLength);return new Ar(e).set(new Ar(t)),e};const Sr=function(t,e){var r=e?Pr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)};var Cr=/\w*$/;const Tr=function(t){var e=new t.constructor(t.source,Cr.exec(t));return e.lastIndex=t.lastIndex,e};var Ir=p?p.prototype:void 0,Dr=Ir?Ir.valueOf:void 0;const zr=function(t){return Dr?Object(Dr.call(t)):{}};const Fr=function(t,e){var r=e?Pr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};var Wr="[object Boolean]",Mr="[object Date]",Nr="[object Map]",qr="[object Number]",Ur="[object RegExp]",Rr="[object Set]",$r="[object String]",Lr="[object Symbol]",kr="[object ArrayBuffer]",Hr="[object DataView]",Br="[object Float32Array]",Qr="[object Float64Array]",Vr="[object Int8Array]",Kr="[object Int16Array]",Gr="[object Int32Array]",Yr="[object Uint8Array]",Jr="[object Uint8ClampedArray]",Xr="[object Uint16Array]",Zr="[object Uint32Array]";const tn=function(t,e,r){var n=t.constructor;switch(e){case kr:return Pr(t);case Wr:case Mr:return new n(+t);case Hr:return Sr(t,r);case Br:case Qr:case Vr:case Kr:case Gr:case Yr:case Jr:case Xr:case Zr:return Fr(t,r);case Nr:return new n;case qr:case $r:return new n(t);case Ur:return Tr(t);case Rr:return new n;case Lr:return zr(t)}};var en=Object.create;const rn=function(){function t(){}return function(e){if(!i(e))return{};if(en)return en(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const nn=function(t){return"function"!=typeof t.constructor||Te(t)?{}:rn(rr(t))};var on="[object Map]";const sn=function(t){return P(t)&&Er(t)==on};var cn=xe&&xe.isMap;const an=cn?me(cn):sn;var un="[object Set]";const hn=function(t){return P(t)&&Er(t)==un};var ln=xe&&xe.isSet;const fn=ln?me(ln):hn;var dn=1,_n=2,pn=4,yn="[object Arguments]",vn="[object Function]",bn="[object GeneratorFunction]",gn="[object Object]",mn={};mn[yn]=mn["[object Array]"]=mn["[object ArrayBuffer]"]=mn["[object DataView]"]=mn["[object Boolean]"]=mn["[object Date]"]=mn["[object Float32Array]"]=mn["[object Float64Array]"]=mn["[object Int8Array]"]=mn["[object Int16Array]"]=mn["[object Int32Array]"]=mn["[object Map]"]=mn["[object Number]"]=mn[gn]=mn["[object RegExp]"]=mn["[object Set]"]=mn["[object String]"]=mn["[object Symbol]"]=mn["[object Uint8Array]"]=mn["[object Uint8ClampedArray]"]=mn["[object Uint16Array]"]=mn["[object Uint32Array]"]=!0,mn["[object Error]"]=mn[vn]=mn["[object WeakMap]"]=!1;const jn=function t(e,r,n,o,s,c){var a,u=r&dn,h=r&_n,l=r&pn;if(n&&(a=s?n(e,o,s,c):n(e)),void 0!==a)return a;if(!i(e))return e;var f=ce(e);if(f){if(a=Or(e),!u)return Ke(e,a)}else{var d=Er(e),_=d==vn||d==bn;if(fe(e))return Ve(e,u);if(d==gn||d==yn||_&&!s){if(a=h||_?{}:nn(e),!u)return h?or(e,Le(a,e)):tr(e,Ne(a,e))}else{if(!mn[d])return s?e:{};a=tn(e,d,u)}}c||(c=new Vt);var p=c.get(e);if(p)return p;c.set(e,a),fn(e)?e.forEach((function(o){a.add(t(o,r,n,o,e,c))})):an(e)&&e.forEach((function(o,s){a.set(s,t(o,r,n,s,e,c))}));var y=f?void 0:(l?h?cr:ir:h?$e:Me)(e);return Kt(y||e,(function(o,s){y&&(o=e[s=o]),Xt(a,s,t(o,r,n,s,e,c))})),a};var wn=1,En=4;const xn=function(t,e){return jn(t,wn|En,e="function"==typeof e?e:void 0)};var On="[object Object]",An=Function.prototype,Pn=Object.prototype,Sn=An.toString,Cn=Pn.hasOwnProperty,Tn=Sn.call(Object);const In=function(t){if(!P(t)||A(t)!=On)return!1;var e=rr(t);if(null===e)return!0;var r=Cn.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Sn.call(r)==Tn};const Dn=function(t){return P(t)&&1===t.nodeType&&!In(t)};class zn extends r{constructor(t,e={}){super(e),this._editor=null,this._throttledSave=$(this._save.bind(this),"number"==typeof e.saveInterval?e.saveInterval:5e3),t&&(this._creator=(e,r)=>t.create(e,r)),this._destructor=t=>t.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(t){this._creator=t}setDestructor(t){this._destructor=t}_restart(){return Promise.resolve().then((()=>(this.state="initializing",this._fire("stateChange"),this._destroy()))).catch((t=>{console.error("An error happened during the editor destroying.",t)})).then((()=>{if("string"==typeof this._elementOrData)return this.create(this._data,this._config,this._config.context);{const t=Object.assign({},this._config,{initialData:this._data});return this.create(this._elementOrData,t,t.context)}})).then((()=>{this._fire("restart")}))}create(t=this._elementOrData,e=this._config,r){return Promise.resolve().then((()=>(super._startErrorHandling(),this._elementOrData=t,this._config=this._cloneEditorConfiguration(e)||{},this._config.context=r,this._creator(t,this._config)))).then((t=>{this._editor=t,t.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=t.model.document.version,this._data=this._getData(),this.state="ready",this._fire("stateChange")}))}destroy(){return Promise.resolve().then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.flush();const t=this._editor;return this._editor=null,t.model.document.off("change:data",this._throttledSave),this._destructor(t)}))}_save(){const t=this._editor.model.document.version;try{this._data=this._getData(),this._lastDocumentVersion=t}catch(t){console.error(t,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(t){this._excludedProps=t}_getData(){const t={};for(const e of this._editor.model.document.getRootNames())t[e]=this._editor.data.get({rootName:e});return t}_isErrorComingFromThisItem(t){return s(this._editor,t.context,this._excludedProps)}_cloneEditorConfiguration(t){return xn(t,((t,e)=>Dn(t)||"context"===e?t:void 0))}}const Fn=Symbol("MainQueueId");class Wn extends r{constructor(t,e={}){super(e),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new Mn,this._watchdogConfig=e,this._creator=e=>t.create(e),this._destructor=t=>t.destroy(),this._actionQueues.onEmpty((()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))}))}setCreator(t){this._creator=t}setDestructor(t){this._destructor=t}get context(){return this._context}create(t={}){return this._actionQueues.enqueue(Fn,(()=>(this._contextConfig=t,this._create())))}getItem(t){return this._getWatchdog(t)._item}getItemState(t){return this._getWatchdog(t).state}add(t){const e=Nn(t);return Promise.all(e.map((t=>this._actionQueues.enqueue(t.id,(()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let e;if(this._watchdogs.has(t.id))throw new Error(`Item with the given id is already added: '${t.id}'.`);if("editor"===t.type)return e=new zn(null,this._watchdogConfig),e.setCreator(t.creator),e._setExcludedProperties(this._contextProps),t.destructor&&e.setDestructor(t.destructor),this._watchdogs.set(t.id,e),e.on("error",((r,{error:n,causesRestart:o})=>{this._fire("itemError",{itemId:t.id,error:n}),o&&this._actionQueues.enqueue(t.id,(()=>new Promise((r=>{const n=()=>{e.off("restart",n),this._fire("itemRestart",{itemId:t.id}),r()};e.on("restart",n)}))))})),e.create(t.sourceElementOrData,t.config,this._context);throw new Error(`Not supported item type: '${t.type}'.`)})))))}remove(t){const e=Nn(t);return Promise.all(e.map((t=>this._actionQueues.enqueue(t,(()=>{const e=this._getWatchdog(t);return this._watchdogs.delete(t),e.destroy()})))))}destroy(){return this._actionQueues.enqueue(Fn,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Fn,(()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch((t=>{console.error("An error happened during destroying the context or items.",t)})).then((()=>this._create())).then((()=>this._fire("restart"))))))}_create(){return Promise.resolve().then((()=>(this._startErrorHandling(),this._creator(this._contextConfig)))).then((t=>(this._context=t,this._contextProps=n(this._context),Promise.all(Array.from(this._watchdogs.values()).map((t=>(t._setExcludedProperties(this._contextProps),t.create(void 0,void 0,this._context))))))))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling();const t=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map((t=>t.destroy()))).then((()=>this._destructor(t)))}))}_getWatchdog(t){const e=this._watchdogs.get(t);if(!e)throw new Error(`Item with the given id was not registered: ${t}.`);return e}_isErrorComingFromThisItem(t){for(const e of this._watchdogs.values())if(e._isErrorComingFromThisItem(t))return!1;return s(this._context,t.context)}}class Mn{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(t){this._onEmptyCallbacks.push(t)}enqueue(t,e){const r=t===Fn;this._activeActions++,this._queues.get(t)||this._queues.set(t,Promise.resolve());const n=(r?Promise.all(this._queues.values()):Promise.all([this._queues.get(Fn),this._queues.get(t)])).then(e),o=n.catch((()=>{}));return this._queues.set(t,o),n.finally((()=>{this._activeActions--,this._queues.get(t)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((t=>t()))}))}}function Nn(t){return Array.isArray(t)?t:[t]}(window.CKEditor5=window.CKEditor5||{}).watchdog=e})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-watchdog",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0-alpha.1",
|
|
4
4
|
"description": "A watchdog feature for CKEditor 5 editors. It keeps a CKEditor 5 editor instance running.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
"lodash-es": "^4.17.15"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@ckeditor/ckeditor5-core": "^
|
|
18
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
19
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
20
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
21
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
22
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
23
|
-
"ckeditor5": "^
|
|
17
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.1",
|
|
18
|
+
"@ckeditor/ckeditor5-dev-utils": "^35.0.0",
|
|
19
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.1",
|
|
20
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.1",
|
|
21
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.1",
|
|
22
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.1",
|
|
23
|
+
"ckeditor5": "^37.0.0-alpha.1",
|
|
24
|
+
"typescript": "^4.8.4",
|
|
24
25
|
"webpack": "^5.58.1",
|
|
25
26
|
"webpack-cli": "^4.9.0"
|
|
26
27
|
},
|
|
@@ -39,13 +40,17 @@
|
|
|
39
40
|
},
|
|
40
41
|
"files": [
|
|
41
42
|
"lang",
|
|
42
|
-
"src",
|
|
43
|
+
"src/**/*.js",
|
|
44
|
+
"src/**/*.d.ts",
|
|
43
45
|
"theme",
|
|
44
46
|
"build",
|
|
45
47
|
"ckeditor5-metadata.json",
|
|
46
48
|
"CHANGELOG.md"
|
|
47
49
|
],
|
|
48
50
|
"scripts": {
|
|
49
|
-
"dll:build": "webpack"
|
|
50
|
-
|
|
51
|
+
"dll:build": "webpack",
|
|
52
|
+
"build": "tsc -p ./tsconfig.json",
|
|
53
|
+
"postversion": "npm run build"
|
|
54
|
+
},
|
|
55
|
+
"types": "src/index.d.ts"
|
|
51
56
|
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module watchdog/contextwatchdog
|
|
7
|
+
*/
|
|
8
|
+
import type { Context, Editor, EditorConfig, ContextConfig } from 'ckeditor5/src/core';
|
|
9
|
+
import type { ArrayOrItem, CKEditorError } from 'ckeditor5/src/utils';
|
|
10
|
+
import Watchdog, { type WatchdogConfig, type WatchdogState } from './watchdog';
|
|
11
|
+
import EditorWatchdog, { type EditorCreatorFunction } from './editorwatchdog';
|
|
12
|
+
/**
|
|
13
|
+
* A watchdog for the {@link module:core/context~Context} class.
|
|
14
|
+
*
|
|
15
|
+
* See the {@glink features/watchdog Watchdog feature guide} to learn the rationale behind it and
|
|
16
|
+
* how to use it.
|
|
17
|
+
*/
|
|
18
|
+
export default class ContextWatchdog<TContext extends Context = Context> extends Watchdog {
|
|
19
|
+
/**
|
|
20
|
+
* A map of internal watchdogs for added items.
|
|
21
|
+
*/
|
|
22
|
+
protected _watchdogs: Map<string, EditorWatchdog<Editor>>;
|
|
23
|
+
/**
|
|
24
|
+
* The watchdog configuration.
|
|
25
|
+
*/
|
|
26
|
+
private readonly _watchdogConfig;
|
|
27
|
+
/**
|
|
28
|
+
* The current context instance.
|
|
29
|
+
*/
|
|
30
|
+
private _context;
|
|
31
|
+
/**
|
|
32
|
+
* Context properties (nodes/references) that are gathered during the initial context creation
|
|
33
|
+
* and are used to distinguish the origin of an error.
|
|
34
|
+
*/
|
|
35
|
+
private _contextProps;
|
|
36
|
+
/**
|
|
37
|
+
* An action queue, which is used to handle async functions queuing.
|
|
38
|
+
*/
|
|
39
|
+
private _actionQueues;
|
|
40
|
+
/**
|
|
41
|
+
* The configuration for the {@link module:core/context~Context}.
|
|
42
|
+
*/
|
|
43
|
+
private _contextConfig?;
|
|
44
|
+
/**
|
|
45
|
+
* The creation method.
|
|
46
|
+
*
|
|
47
|
+
* @see #setCreator
|
|
48
|
+
*/
|
|
49
|
+
protected _creator: (config: ContextConfig) => Promise<TContext>;
|
|
50
|
+
/**
|
|
51
|
+
* The destruction method.
|
|
52
|
+
*
|
|
53
|
+
* @see #setDestructor
|
|
54
|
+
*/
|
|
55
|
+
protected _destructor: (context: Context) => Promise<unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* The watched item.
|
|
58
|
+
*/
|
|
59
|
+
_item: unknown;
|
|
60
|
+
/**
|
|
61
|
+
* The context watchdog class constructor.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* const watchdog = new ContextWatchdog( Context );
|
|
65
|
+
*
|
|
66
|
+
* await watchdog.create( contextConfiguration );
|
|
67
|
+
*
|
|
68
|
+
* await watchdog.add( item );
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* See the {@glink features/watchdog Watchdog feature guide} to learn more how to use this feature.
|
|
72
|
+
*
|
|
73
|
+
* @param Context The {@link module:core/context~Context} class.
|
|
74
|
+
* @param watchdogConfig The watchdog configuration.
|
|
75
|
+
*/
|
|
76
|
+
constructor(Context: {
|
|
77
|
+
create(...args: any): Promise<TContext>;
|
|
78
|
+
}, watchdogConfig?: WatchdogConfig);
|
|
79
|
+
/**
|
|
80
|
+
* Sets the function that is responsible for the context creation.
|
|
81
|
+
* It expects a function that should return a promise (or `undefined`).
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* watchdog.setCreator( config => Context.create( config ) );
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
setCreator(creator: (config: ContextConfig) => Promise<TContext>): void;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the function that is responsible for the context destruction.
|
|
90
|
+
* Overrides the default destruction function, which destroys only the context instance.
|
|
91
|
+
* It expects a function that should return a promise (or `undefined`).
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* watchdog.setDestructor( context => {
|
|
95
|
+
* // Do something before the context is destroyed.
|
|
96
|
+
*
|
|
97
|
+
* return context
|
|
98
|
+
* .destroy()
|
|
99
|
+
* .then( () => {
|
|
100
|
+
* // Do something after the context is destroyed.
|
|
101
|
+
* } );
|
|
102
|
+
* } );
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
setDestructor(destructor: (context: Context) => Promise<unknown>): void;
|
|
106
|
+
/**
|
|
107
|
+
* The context instance. Keep in mind that this property might be changed when the context watchdog restarts,
|
|
108
|
+
* so do not keep this instance internally. Always operate on the `ContextWatchdog#context` property.
|
|
109
|
+
*/
|
|
110
|
+
get context(): Context | null;
|
|
111
|
+
/**
|
|
112
|
+
* Initializes the context watchdog. Once it is created, the watchdog takes care about
|
|
113
|
+
* recreating the context and the provided items, and starts the error handling mechanism.
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* await watchdog.create( {
|
|
117
|
+
* plugins: []
|
|
118
|
+
* } );
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param contextConfig The context configuration. See {@link module:core/context~Context}.
|
|
122
|
+
*/
|
|
123
|
+
create(contextConfig?: ContextConfig): Promise<unknown>;
|
|
124
|
+
/**
|
|
125
|
+
* Returns an item instance with the given `itemId`.
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* const editor1 = watchdog.getItem( 'editor1' );
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param itemId The item ID.
|
|
132
|
+
* @returns The item instance or `undefined` if an item with a given ID has not been found.
|
|
133
|
+
*/
|
|
134
|
+
getItem(itemId: string): unknown;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the state of the given item. See {@link #state} for a list of available states.
|
|
137
|
+
*
|
|
138
|
+
* ```ts
|
|
139
|
+
* const editor1State = watchdog.getItemState( 'editor1' );
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @param itemId Item ID.
|
|
143
|
+
* @returns The state of the item.
|
|
144
|
+
*/
|
|
145
|
+
getItemState(itemId: string): WatchdogState;
|
|
146
|
+
/**
|
|
147
|
+
* Adds items to the watchdog. Once created, instances of these items will be available using the {@link #getItem} method.
|
|
148
|
+
*
|
|
149
|
+
* Items can be passed together as an array of objects:
|
|
150
|
+
*
|
|
151
|
+
* ```ts
|
|
152
|
+
* await watchdog.add( [ {
|
|
153
|
+
* id: 'editor1',
|
|
154
|
+
* type: 'editor',
|
|
155
|
+
* sourceElementOrData: document.querySelector( '#editor' ),
|
|
156
|
+
* config: {
|
|
157
|
+
* plugins: [ Essentials, Paragraph, Bold, Italic ],
|
|
158
|
+
* toolbar: [ 'bold', 'italic', 'alignment' ]
|
|
159
|
+
* },
|
|
160
|
+
* creator: ( element, config ) => ClassicEditor.create( element, config )
|
|
161
|
+
* } ] );
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* Or one by one as objects:
|
|
165
|
+
*
|
|
166
|
+
* ```ts
|
|
167
|
+
* await watchdog.add( {
|
|
168
|
+
* id: 'editor1',
|
|
169
|
+
* type: 'editor',
|
|
170
|
+
* sourceElementOrData: document.querySelector( '#editor' ),
|
|
171
|
+
* config: {
|
|
172
|
+
* plugins: [ Essentials, Paragraph, Bold, Italic ],
|
|
173
|
+
* toolbar: [ 'bold', 'italic', 'alignment' ]
|
|
174
|
+
* },
|
|
175
|
+
* creator: ( element, config ) => ClassicEditor.create( element, config )
|
|
176
|
+
* ] );
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* Then an instance can be retrieved using the {@link #getItem} method:
|
|
180
|
+
*
|
|
181
|
+
* ```ts
|
|
182
|
+
* const editor1 = watchdog.getItem( 'editor1' );
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* Note that this method can be called multiple times, but for performance reasons it is better
|
|
186
|
+
* to pass all items together.
|
|
187
|
+
*
|
|
188
|
+
* @param itemConfigurationOrItemConfigurations An item configuration object or an array of item configurations.
|
|
189
|
+
*/
|
|
190
|
+
add(itemConfigurationOrItemConfigurations: ArrayOrItem<WatchdogItemConfiguration>): Promise<unknown>;
|
|
191
|
+
/**
|
|
192
|
+
* Removes and destroys item(s) with given ID(s).
|
|
193
|
+
*
|
|
194
|
+
* ```ts
|
|
195
|
+
* await watchdog.remove( 'editor1' );
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* Or
|
|
199
|
+
*
|
|
200
|
+
* ```ts
|
|
201
|
+
* await watchdog.remove( [ 'editor1', 'editor2' ] );
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @param itemIdOrItemIds Item ID or an array of item IDs.
|
|
205
|
+
*/
|
|
206
|
+
remove(itemIdOrItemIds: ArrayOrItem<string>): Promise<unknown>;
|
|
207
|
+
/**
|
|
208
|
+
* Destroys the context watchdog and all added items.
|
|
209
|
+
* Once the context watchdog is destroyed, new items cannot be added.
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* await watchdog.destroy();
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
destroy(): Promise<unknown>;
|
|
216
|
+
/**
|
|
217
|
+
* Restarts the context watchdog.
|
|
218
|
+
*/
|
|
219
|
+
protected _restart(): Promise<unknown>;
|
|
220
|
+
/**
|
|
221
|
+
* Initializes the context watchdog.
|
|
222
|
+
*/
|
|
223
|
+
private _create;
|
|
224
|
+
/**
|
|
225
|
+
* Destroys the context instance and all added items.
|
|
226
|
+
*/
|
|
227
|
+
private _destroy;
|
|
228
|
+
/**
|
|
229
|
+
* Returns the watchdog for a given item ID.
|
|
230
|
+
*
|
|
231
|
+
* @param itemId Item ID.
|
|
232
|
+
*/
|
|
233
|
+
protected _getWatchdog(itemId: string): Watchdog;
|
|
234
|
+
/**
|
|
235
|
+
* Checks whether an error comes from the context instance and not from the item instances.
|
|
236
|
+
*
|
|
237
|
+
* @internal
|
|
238
|
+
*/
|
|
239
|
+
_isErrorComingFromThisItem(error: CKEditorError): boolean;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Fired after the watchdog restarts the context and the added items because of a crash.
|
|
243
|
+
*
|
|
244
|
+
* ```ts
|
|
245
|
+
* watchdog.on( 'restart', () => {
|
|
246
|
+
* console.log( 'The context has been restarted.' );
|
|
247
|
+
* } );
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @eventName ~ContextWatchdog#restart
|
|
251
|
+
*/
|
|
252
|
+
export type ContextWatchdogRestartEvent = {
|
|
253
|
+
name: 'restart';
|
|
254
|
+
args: [];
|
|
255
|
+
return: undefined;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Fired when a new error occurred in one of the added items.
|
|
259
|
+
*
|
|
260
|
+
* ```ts
|
|
261
|
+
* watchdog.on( 'itemError', ( evt, { error, itemId } ) => {
|
|
262
|
+
* console.log( `An error occurred in an item with the '${ itemId }' ID.` );
|
|
263
|
+
* } );
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* @eventName ~ContextWatchdog#itemError
|
|
267
|
+
*/
|
|
268
|
+
export type ContextWatchdogItemErrorEvent = {
|
|
269
|
+
name: 'itemError';
|
|
270
|
+
args: [ContextWatchdogItemErrorEventData];
|
|
271
|
+
return: undefined;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* The `itemError` event data.
|
|
275
|
+
*/
|
|
276
|
+
export type ContextWatchdogItemErrorEventData = {
|
|
277
|
+
itemId: string;
|
|
278
|
+
error: Error;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Fired after an item has been restarted.
|
|
282
|
+
*
|
|
283
|
+
* ```ts
|
|
284
|
+
* watchdog.on( 'itemRestart', ( evt, { itemId } ) => {
|
|
285
|
+
* console.log( 'An item with with the '${ itemId }' ID has been restarted.' );
|
|
286
|
+
* } );
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @eventName ~ContextWatchdog#itemRestart
|
|
290
|
+
*/
|
|
291
|
+
export type ContextWatchdogItemRestartEvent = {
|
|
292
|
+
name: 'itemRestart';
|
|
293
|
+
args: [ContextWatchdogItemRestartEventData];
|
|
294
|
+
return: undefined;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* The `itemRestart` event data.
|
|
298
|
+
*/
|
|
299
|
+
export type ContextWatchdogItemRestartEventData = {
|
|
300
|
+
itemId: string;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* The watchdog item configuration interface.
|
|
304
|
+
*/
|
|
305
|
+
export interface WatchdogItemConfiguration {
|
|
306
|
+
/**
|
|
307
|
+
* id A unique item identificator.
|
|
308
|
+
*/
|
|
309
|
+
id: string;
|
|
310
|
+
/**
|
|
311
|
+
* The type of the item to create. At the moment, only `'editor'` is supported.
|
|
312
|
+
*/
|
|
313
|
+
type: 'editor';
|
|
314
|
+
/**
|
|
315
|
+
* A function that initializes the item (the editor). The function takes editor initialization arguments
|
|
316
|
+
* and should return a promise. For example: `( el, config ) => ClassicEditor.create( el, config )`.
|
|
317
|
+
*/
|
|
318
|
+
creator: EditorCreatorFunction;
|
|
319
|
+
/**
|
|
320
|
+
* A function that destroys the item instance (the editor). The function
|
|
321
|
+
* takes an item and should return a promise. For example: `editor => editor.destroy()`
|
|
322
|
+
*/
|
|
323
|
+
destructor?: (editor: Editor) => Promise<unknown>;
|
|
324
|
+
/**
|
|
325
|
+
* The source element or data that will be passed
|
|
326
|
+
* as the first argument to the `Editor.create()` method.
|
|
327
|
+
*/
|
|
328
|
+
sourceElementOrData: string | HTMLElement;
|
|
329
|
+
/**
|
|
330
|
+
* An editor configuration.
|
|
331
|
+
*/
|
|
332
|
+
config: EditorConfig;
|
|
333
|
+
}
|