Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-react

Package Overview
Dependencies
26
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.1.0 to 6.2.0

dist/useMultiRootEditor.d.ts

11

CHANGELOG.md
Changelog
=========
## [6.2.0](https://github.com/ckeditor/ckeditor5-react/compare/v6.1.0...v6.2.0) (2023-11-21)
### Features
* Introduced the integration with multi-root editor by providing `useMultiRootEditor` hook. See the new samples to learn more. Closes [#257](https://github.com/ckeditor/ckeditor5-react/issues/257). ([commit](https://github.com/ckeditor/ckeditor5-react/commit/a5878063ad6a59fbbfa2848b2b5b4532c0c66bb8))
### Other changes
* Updated the required version of Node.js to 18 when developing the repository. See [ckeditor/ckeditor5#14924](https://github.com/ckeditor/ckeditor5/issues/14924). ([commit](https://github.com/ckeditor/ckeditor5-react/commit/9998e47ac1c20d4a41df93d5343c6f1cd193638b))
## [6.1.0](https://github.com/ckeditor/ckeditor5-react/compare/v6.0.0...v6.1.0) (2023-06-27)

@@ -5,0 +16,0 @@

@@ -11,2 +11,3 @@ /**

import type { WatchdogConfig } from '@ckeditor/ckeditor5-watchdog/src/watchdog';
import type { EditorCreatorFunction } from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog';
export default class CKEditor<TEditor extends Editor> extends React.Component<Props<TEditor>, {}> {

@@ -121,2 +122,47 @@ /**

}
/**
* An adapter aligning the context watchdog API to the editor watchdog API for easier usage.
*/
export declare class EditorWatchdogAdapter<TEditor extends Editor> {
/**
* The context watchdog instance that will be wrapped into editor watchdog API.
*/
private readonly _contextWatchdog;
/**
* A unique id for the adapter to distinguish editor items when using the context watchdog API.
*/
private readonly _id;
/**
* A watchdog's editor creator function.
*/
private _creator?;
/**
* @param contextWatchdog The context watchdog instance that will be wrapped into editor watchdog API.
*/
constructor(contextWatchdog: ContextWatchdog);
/**
* @param creator A watchdog's editor creator function.
*/
setCreator(creator: EditorCreatorFunction): void;
/**
* Adds an editor configuration to the context watchdog registry. Creates an instance of it.
*
* @param sourceElementOrData A source element or data for the new editor.
* @param config CKEditor 5 editor config.
*/
create(sourceElementOrData: HTMLElement | string, config: EditorConfig): Promise<unknown>;
/**
* Creates a listener that is attached to context watchdog's item and run when the context watchdog fires.
* Currently works only for the `error` event.
*/
on(_: string, callback: (_: null, data: {
error: Error;
causesRestart?: boolean;
}) => void): void;
destroy(): Promise<unknown>;
/**
* An editor instance.
*/
get editor(): TEditor;
}
export {};

1

dist/index.d.ts

@@ -7,1 +7,2 @@ /**

export { default as CKEditorContext } from './ckeditorcontext';
export { default as useMultiRootEditor, type MultiRootHookProps, type MultiRootHookReturns } from './useMultiRootEditor';

2

dist/index.js

@@ -5,3 +5,3 @@ /*!

*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.CKEditor=e(require("react")):t.CKEditor=e(t.React)}(self,(t=>(()=>{var e={703:(t,e,r)=>{"use strict";var o=r(414);function n(){}function i(){}i.resetWarningCache=n,t.exports=function(){function t(t,e,r,n,i,s){if(s!==o){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function e(){return t}t.isRequired=t;var r={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:i,resetWarningCache:n};return r.PropTypes=r,r}},697:(t,e,r)=>{t.exports=r(703)()},414:t=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},787:e=>{"use strict";e.exports=t}},r={};function o(t){var n=r[t];if(void 0!==n)return n.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";o.r(n),o.d(n,{CKEditor:()=>to,CKEditorContext:()=>Xr});var t=o(787),e=o.n(t),r=o(697),i=o.n(r);const s=new Array(256).fill("").map(((t,e)=>("0"+e.toString(16)).slice(-2)));class a{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 c(t,e=new Set){const r=[t],o=new Set;let n=0;for(;r.length>n;){const t=r[n++];if(!o.has(t)&&u(t)&&!e.has(t))if(o.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 o}function u(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 h(t,e,r=new Set){if(t===e&&("object"==typeof(o=t)&&null!==o))return!0;var o;const n=c(t,r),i=c(e,r);for(const t of n)if(i.has(t))return!0;return!1}const d=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const l="object"==typeof global&&global&&global.Object===Object&&global;var p="object"==typeof self&&self&&self.Object===Object&&self;const f=l||p||Function("return this")();const _=function(){return f.Date.now()};var y=/\s/;const g=function(t){for(var e=t.length;e--&&y.test(t.charAt(e)););return e};var b=/^\s+/;const v=function(t){return t?t.slice(0,g(t)+1).replace(b,""):t};const m=f.Symbol;var j=Object.prototype,w=j.hasOwnProperty,x=j.toString,E=m?m.toStringTag:void 0;const O=function(t){var e=w.call(t,E),r=t[E];try{t[E]=void 0;var o=!0}catch(t){}var n=x.call(t);return o&&(e?t[E]=r:delete t[E]),n};var C=Object.prototype.toString;const P=function(t){return C.call(t)};var A=m?m.toStringTag:void 0;const W=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":A&&A in Object(t)?O(t):P(t)};const T=function(t){return null!=t&&"object"==typeof t};const S=function(t){return"symbol"==typeof t||T(t)&&"[object Symbol]"==W(t)};var R=/^[-+]0x[0-9a-f]+$/i,I=/^0b[01]+$/i,D=/^0o[0-7]+$/i,z=parseInt;const M=function(t){if("number"==typeof t)return t;if(S(t))return NaN;if(d(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=d(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=v(t);var r=I.test(t);return r||D.test(t)?z(t.slice(2),r?2:8):R.test(t)?NaN:+t};var U=Math.max,N=Math.min;const F=function(t,e,r){var o,n,i,s,a,c,u=0,h=!1,l=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var r=o,i=n;return o=n=void 0,u=e,s=t.apply(i,r)}function y(t){var r=t-c;return void 0===c||r>=e||r<0||l&&t-u>=i}function g(){var t=_();if(y(t))return b(t);a=setTimeout(g,function(t){var r=e-(t-c);return l?N(r,i-(t-u)):r}(t))}function b(t){return a=void 0,p&&o?f(t):(o=n=void 0,s)}function v(){var t=_(),r=y(t);if(o=arguments,n=this,c=t,r){if(void 0===a)return function(t){return u=t,a=setTimeout(g,e),h?f(t):s}(c);if(l)return clearTimeout(a),a=setTimeout(g,e),f(c)}return void 0===a&&(a=setTimeout(g,e)),s}return e=M(e)||0,d(r)&&(h=!!r.leading,i=(l="maxWait"in r)?U(M(r.maxWait)||0,e):i,p="trailing"in r?!!r.trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),u=0,o=c=n=a=void 0},v.flush=function(){return void 0===a?s:b(_())},v};const q=function(t,e,r){var o=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return d(r)&&(o="leading"in r?!!r.leading:o,n="trailing"in r?!!r.trailing:n),F(t,e,{leading:o,maxWait:e,trailing:n})};const L=function(){this.__data__=[],this.size=0};const k=function(t,e){return t===e||t!=t&&e!=e};const B=function(t,e){for(var r=t.length;r--;)if(k(t[r][0],e))return r;return-1};var $=Array.prototype.splice;const H=function(t){var e=this.__data__,r=B(e,t);return!(r<0)&&(r==e.length-1?e.pop():$.call(e,r,1),--this.size,!0)};const V=function(t){var e=this.__data__,r=B(e,t);return r<0?void 0:e[r][1]};const K=function(t){return B(this.__data__,t)>-1};const Q=function(t,e){var r=this.__data__,o=B(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this};function G(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}G.prototype.clear=L,G.prototype.delete=H,G.prototype.get=V,G.prototype.has=K,G.prototype.set=Q;const Y=G;const J=function(){this.__data__=new Y,this.size=0};const X=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r};const Z=function(t){return this.__data__.get(t)};const tt=function(t){return this.__data__.has(t)};const et=function(t){if(!d(t))return!1;var e=W(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e};const rt=f["__core-js_shared__"];var ot=function(){var t=/[^.]+$/.exec(rt&&rt.keys&&rt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();const nt=function(t){return!!ot&&ot in t};var it=Function.prototype.toString;const st=function(t){if(null!=t){try{return it.call(t)}catch(t){}try{return t+""}catch(t){}}return""};var at=/^\[object .+?Constructor\]$/,ct=Function.prototype,ut=Object.prototype,ht=ct.toString,dt=ut.hasOwnProperty,lt=RegExp("^"+ht.call(dt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const pt=function(t){return!(!d(t)||nt(t))&&(et(t)?lt:at).test(st(t))};const ft=function(t,e){return null==t?void 0:t[e]};const _t=function(t,e){var r=ft(t,e);return pt(r)?r:void 0};const yt=_t(f,"Map");const gt=_t(Object,"create");const bt=function(){this.__data__=gt?gt(null):{},this.size=0};const vt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e};var mt=Object.prototype.hasOwnProperty;const jt=function(t){var e=this.__data__;if(gt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return mt.call(e,t)?e[t]:void 0};var wt=Object.prototype.hasOwnProperty;const xt=function(t){var e=this.__data__;return gt?void 0!==e[t]:wt.call(e,t)};const Et=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=gt&&void 0===e?"__lodash_hash_undefined__":e,this};function Ot(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Ot.prototype.clear=bt,Ot.prototype.delete=vt,Ot.prototype.get=jt,Ot.prototype.has=xt,Ot.prototype.set=Et;const Ct=Ot;const Pt=function(){this.size=0,this.__data__={hash:new Ct,map:new(yt||Y),string:new Ct}};const At=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 At(e)?r["string"==typeof e?"string":"hash"]:r.map};const Tt=function(t){var e=Wt(this,t).delete(t);return this.size-=e?1:0,e};const St=function(t){return Wt(this,t).get(t)};const Rt=function(t){return Wt(this,t).has(t)};const It=function(t,e){var r=Wt(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this};function Dt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Dt.prototype.clear=Pt,Dt.prototype.delete=Tt,Dt.prototype.get=St,Dt.prototype.has=Rt,Dt.prototype.set=It;const zt=Dt;const Mt=function(t,e){var r=this.__data__;if(r instanceof Y){var o=r.__data__;if(!yt||o.length<199)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new zt(o)}return r.set(t,e),this.size=r.size,this};function Ut(t){var e=this.__data__=new Y(t);this.size=e.size}Ut.prototype.clear=J,Ut.prototype.delete=X,Ut.prototype.get=Z,Ut.prototype.has=tt,Ut.prototype.set=Mt;const Nt=Ut;const Ft=function(t,e){for(var r=-1,o=null==t?0:t.length;++r<o&&!1!==e(t[r],r,t););return t};const qt=function(){try{var t=_t(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();const Lt=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 Bt=function(t,e,r){var o=t[e];kt.call(t,e)&&k(o,r)&&(void 0!==r||e in t)||Lt(t,e,r)};const $t=function(t,e,r,o){var n=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],c=o?o(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),n?Lt(r,a,c):Bt(r,a,c)}return r};const Ht=function(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o};const Vt=function(t){return T(t)&&"[object Arguments]"==W(t)};var Kt=Object.prototype,Qt=Kt.hasOwnProperty,Gt=Kt.propertyIsEnumerable;const Yt=Vt(function(){return arguments}())?Vt:function(t){return T(t)&&Qt.call(t,"callee")&&!Gt.call(t,"callee")};const Jt=Array.isArray;const Xt=function(){return!1};var Zt="object"==typeof exports&&exports&&!exports.nodeType&&exports,te=Zt&&"object"==typeof module&&module&&!module.nodeType&&module,ee=te&&te.exports===Zt?f.Buffer:void 0;const re=(ee?ee.isBuffer:void 0)||Xt;var oe=/^(?:0|[1-9]\d*)$/;const ne=function(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&oe.test(t))&&t>-1&&t%1==0&&t<e};const ie=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991};var se={};se["[object Float32Array]"]=se["[object Float64Array]"]=se["[object Int8Array]"]=se["[object Int16Array]"]=se["[object Int32Array]"]=se["[object Uint8Array]"]=se["[object Uint8ClampedArray]"]=se["[object Uint16Array]"]=se["[object Uint32Array]"]=!0,se["[object Arguments]"]=se["[object Array]"]=se["[object ArrayBuffer]"]=se["[object Boolean]"]=se["[object DataView]"]=se["[object Date]"]=se["[object Error]"]=se["[object Function]"]=se["[object Map]"]=se["[object Number]"]=se["[object Object]"]=se["[object RegExp]"]=se["[object Set]"]=se["[object String]"]=se["[object WeakMap]"]=!1;const ae=function(t){return T(t)&&ie(t.length)&&!!se[W(t)]};const ce=function(t){return function(e){return t(e)}};var ue="object"==typeof exports&&exports&&!exports.nodeType&&exports,he=ue&&"object"==typeof module&&module&&!module.nodeType&&module,de=he&&he.exports===ue&&l.process;const le=function(){try{var t=he&&he.require&&he.require("util").types;return t||de&&de.binding&&de.binding("util")}catch(t){}}();var pe=le&&le.isTypedArray;const fe=pe?ce(pe):ae;var _e=Object.prototype.hasOwnProperty;const ye=function(t,e){var r=Jt(t),o=!r&&Yt(t),n=!r&&!o&&re(t),i=!r&&!o&&!n&&fe(t),s=r||o||n||i,a=s?Ht(t.length,String):[],c=a.length;for(var u in t)!e&&!_e.call(t,u)||s&&("length"==u||n&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ne(u,c))||a.push(u);return a};var ge=Object.prototype;const be=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ge)};const ve=function(t,e){return function(r){return t(e(r))}};const me=ve(Object.keys,Object);var je=Object.prototype.hasOwnProperty;const we=function(t){if(!be(t))return me(t);var e=[];for(var r in Object(t))je.call(t,r)&&"constructor"!=r&&e.push(r);return e};const xe=function(t){return null!=t&&ie(t.length)&&!et(t)};const Ee=function(t){return xe(t)?ye(t):we(t)};const Oe=function(t,e){return t&&$t(e,Ee(e),t)};const Ce=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e};var Pe=Object.prototype.hasOwnProperty;const Ae=function(t){if(!d(t))return Ce(t);var e=be(t),r=[];for(var o in t)("constructor"!=o||!e&&Pe.call(t,o))&&r.push(o);return r};const We=function(t){return xe(t)?ye(t,!0):Ae(t)};const Te=function(t,e){return t&&$t(e,We(e),t)};var Se="object"==typeof exports&&exports&&!exports.nodeType&&exports,Re=Se&&"object"==typeof module&&module&&!module.nodeType&&module,Ie=Re&&Re.exports===Se?f.Buffer:void 0,De=Ie?Ie.allocUnsafe:void 0;const ze=function(t,e){if(e)return t.slice();var r=t.length,o=De?De(r):new t.constructor(r);return t.copy(o),o};const Me=function(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e};const Ue=function(t,e){for(var r=-1,o=null==t?0:t.length,n=0,i=[];++r<o;){var s=t[r];e(s,r,t)&&(i[n++]=s)}return i};const Ne=function(){return[]};var Fe=Object.prototype.propertyIsEnumerable,qe=Object.getOwnPropertySymbols;const Le=qe?function(t){return null==t?[]:(t=Object(t),Ue(qe(t),(function(e){return Fe.call(t,e)})))}:Ne;const ke=function(t,e){return $t(t,Le(t),e)};const Be=function(t,e){for(var r=-1,o=e.length,n=t.length;++r<o;)t[n+r]=e[r];return t};const $e=ve(Object.getPrototypeOf,Object);const He=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Be(e,Le(t)),t=$e(t);return e}:Ne;const Ve=function(t,e){return $t(t,He(t),e)};const Ke=function(t,e,r){var o=e(t);return Jt(t)?o:Be(o,r(t))};const Qe=function(t){return Ke(t,Ee,Le)};const Ge=function(t){return Ke(t,We,He)};const Ye=_t(f,"DataView");const Je=_t(f,"Promise");const Xe=_t(f,"Set");const Ze=_t(f,"WeakMap");var tr="[object Map]",er="[object Promise]",rr="[object Set]",or="[object WeakMap]",nr="[object DataView]",ir=st(Ye),sr=st(yt),ar=st(Je),cr=st(Xe),ur=st(Ze),hr=W;(Ye&&hr(new Ye(new ArrayBuffer(1)))!=nr||yt&&hr(new yt)!=tr||Je&&hr(Je.resolve())!=er||Xe&&hr(new Xe)!=rr||Ze&&hr(new Ze)!=or)&&(hr=function(t){var e=W(t),r="[object Object]"==e?t.constructor:void 0,o=r?st(r):"";if(o)switch(o){case ir:return nr;case sr:return tr;case ar:return er;case cr:return rr;case ur:return or}return e});const dr=hr;var lr=Object.prototype.hasOwnProperty;const pr=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&lr.call(t,"index")&&(r.index=t.index,r.input=t.input),r};const fr=f.Uint8Array;const _r=function(t){var e=new t.constructor(t.byteLength);return new fr(e).set(new fr(t)),e};const yr=function(t,e){var r=e?_r(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)};var gr=/\w*$/;const br=function(t){var e=new t.constructor(t.source,gr.exec(t));return e.lastIndex=t.lastIndex,e};var vr=m?m.prototype:void 0,mr=vr?vr.valueOf:void 0;const jr=function(t){return mr?Object(mr.call(t)):{}};const wr=function(t,e){var r=e?_r(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};const xr=function(t,e,r){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return _r(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return yr(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return wr(t,r);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return br(t);case"[object Symbol]":return jr(t)}};var Er=Object.create;const Or=function(){function t(){}return function(e){if(!d(e))return{};if(Er)return Er(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const Cr=function(t){return"function"!=typeof t.constructor||be(t)?{}:Or($e(t))};const Pr=function(t){return T(t)&&"[object Map]"==dr(t)};var Ar=le&&le.isMap;const Wr=Ar?ce(Ar):Pr;const Tr=function(t){return T(t)&&"[object Set]"==dr(t)};var Sr=le&&le.isSet;const Rr=Sr?ce(Sr):Tr;var Ir="[object Arguments]",Dr="[object Function]",zr="[object Object]",Mr={};Mr[Ir]=Mr["[object Array]"]=Mr["[object ArrayBuffer]"]=Mr["[object DataView]"]=Mr["[object Boolean]"]=Mr["[object Date]"]=Mr["[object Float32Array]"]=Mr["[object Float64Array]"]=Mr["[object Int8Array]"]=Mr["[object Int16Array]"]=Mr["[object Int32Array]"]=Mr["[object Map]"]=Mr["[object Number]"]=Mr[zr]=Mr["[object RegExp]"]=Mr["[object Set]"]=Mr["[object String]"]=Mr["[object Symbol]"]=Mr["[object Uint8Array]"]=Mr["[object Uint8ClampedArray]"]=Mr["[object Uint16Array]"]=Mr["[object Uint32Array]"]=!0,Mr["[object Error]"]=Mr[Dr]=Mr["[object WeakMap]"]=!1;const Ur=function t(e,r,o,n,i,s){var a,c=1&r,u=2&r,h=4&r;if(o&&(a=i?o(e,n,i,s):o(e)),void 0!==a)return a;if(!d(e))return e;var l=Jt(e);if(l){if(a=pr(e),!c)return Me(e,a)}else{var p=dr(e),f=p==Dr||"[object GeneratorFunction]"==p;if(re(e))return ze(e,c);if(p==zr||p==Ir||f&&!i){if(a=u||f?{}:Cr(e),!c)return u?Ve(e,Te(a,e)):ke(e,Oe(a,e))}else{if(!Mr[p])return i?e:{};a=xr(e,p,c)}}s||(s=new Nt);var _=s.get(e);if(_)return _;s.set(e,a),Rr(e)?e.forEach((function(n){a.add(t(n,r,o,n,e,s))})):Wr(e)&&e.forEach((function(n,i){a.set(i,t(n,r,o,i,e,s))}));var y=l?void 0:(h?u?Ge:Qe:u?We:Ee)(e);return Ft(y||e,(function(n,i){y&&(n=e[i=n]),Bt(a,i,t(n,r,o,i,e,s))})),a};const Nr=function(t,e){return Ur(t,5,e="function"==typeof e?e:void 0)};var Fr=Function.prototype,qr=Object.prototype,Lr=Fr.toString,kr=qr.hasOwnProperty,Br=Lr.call(Object);const $r=function(t){if(!T(t)||"[object Object]"!=W(t))return!1;var e=$e(t);if(null===e)return!0;var r=kr.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Lr.call(r)==Br};const Hr=function(t){return T(t)&&1===t.nodeType&&!$r(t)};class Vr extends a{constructor(t,e={}){super(e),this._editor=null,this._throttledSave=q(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 h(this._editor,t.context,this._excludedProps)}_cloneEditorConfiguration(t){return Nr(t,((t,e)=>Hr(t)||"context"===e?t:void 0))}}const Kr=Symbol("MainQueueId");class Qr extends a{constructor(t,e={}){super(e),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new Gr,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(Kr,(()=>(this._contextConfig=t,this._create())))}getItem(t){return this._getWatchdog(t)._item}getItemState(t){return this._getWatchdog(t).state}add(t){const e=Yr(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 Vr(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:o,causesRestart:n})=>{this._fire("itemError",{itemId:t.id,error:o}),n&&this._actionQueues.enqueue(t.id,(()=>new Promise((r=>{const o=()=>{e.off("restart",o),this._fire("itemRestart",{itemId:t.id}),r()};e.on("restart",o)}))))})),e.create(t.sourceElementOrData,t.config,this._context);throw new Error(`Not supported item type: '${t.type}'.`)})))))}remove(t){const e=Yr(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(Kr,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Kr,(()=>(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=c(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 h(this._context,t.context)}}class Gr{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(t){this._onEmptyCallbacks.push(t)}enqueue(t,e){const r=t===Kr;this._activeActions++,this._queues.get(t)||this._queues.set(t,Promise.resolve());const o=(r?Promise.all(this._queues.values()):Promise.all([this._queues.get(Kr),this._queues.get(t)])).then(e),n=o.catch((()=>{}));return this._queues.set(t,n),o.finally((()=>{this._activeActions--,this._queues.get(t)===n&&0===this._activeActions&&this._onEmptyCallbacks.forEach((t=>t()))}))}}function Yr(t){return Array.isArray(t)?t:[t]}const Jr=e().createContext("contextWatchdog");class Xr extends e().Component{constructor(t,e){super(t,e),this.contextWatchdog=null,this.props.isLayoutReady&&this._initializeContextWatchdog(this.props.config)}shouldComponentUpdate(t){return this._shouldComponentUpdate(t)}async _shouldComponentUpdate(t){return t.id!==this.props.id&&(this.contextWatchdog&&await this.contextWatchdog.destroy(),await this._initializeContextWatchdog(t.config)),t.isLayoutReady&&!this.contextWatchdog?(await this._initializeContextWatchdog(t.config),!0):this.props.children!==t.children}render(){return e().createElement(Jr.Provider,{value:this.contextWatchdog},this.props.children)}componentWillUnmount(){this._destroyContext()}async _initializeContextWatchdog(t){this.contextWatchdog=new Qr(this.props.context,this.props.watchdogConfig),this.contextWatchdog.on("error",((t,e)=>{this.props.onError(e.error,{phase:"runtime",willContextRestart:e.causesRestart})})),this.contextWatchdog.on("stateChange",(()=>{"ready"===this.contextWatchdog.state&&this.props.onReady&&this.props.onReady(this.contextWatchdog.context)})),await this.contextWatchdog.create(t).catch((t=>{this.props.onError(t,{phase:"initialization",willContextRestart:!1})}))}async _destroyContext(){this.contextWatchdog&&(await this.contextWatchdog.destroy(),this.contextWatchdog=null)}}Xr.defaultProps={isLayoutReady:!0,onError:(t,e)=>console.error(t,e)},Xr.propTypes={id:i().string,isLayoutReady:i().bool,context:i().func,watchdogConfig:i().object,config:i().object,onReady:i().func,onError:i().func};const Zr="Lock from React integration (@ckeditor/ckeditor5-react)";class to extends e().Component{constructor(t){super(t),this.editorDestructionInProgress=null,this.domContainer=e().createRef(),this.watchdog=null;const{CKEDITOR_VERSION:r}=window;if(r){const[t]=r.split(".").map(Number);t<37&&console.warn("The <CKEditor> component requires using CKEditor 5 in version 37 or higher.")}else console.warn('Cannot find the "CKEDITOR_VERSION" in the "window" scope.')}get editor(){return this.props.disableWatchdog?this.instance:this.watchdog?this.watchdog.editor:null}shouldComponentUpdate(t){return!!this.editor&&(t.id!==this.props.id||(t.disableWatchdog!==this.props.disableWatchdog||(this._shouldUpdateEditor(t)&&this.editor.data.set(t.data),"disabled"in t&&(t.disabled?this.editor.enableReadOnlyMode(Zr):this.editor.disableReadOnlyMode(Zr)),!1)))}async componentDidMount(){await this._initializeEditor()}async componentDidUpdate(){await this._destroyEditor(),await this._initializeEditor()}async componentWillUnmount(){await this._destroyEditor()}render(){return e().createElement("div",{ref:this.domContainer})}async _initializeEditor(){await this.editorDestructionInProgress,this.props.disableWatchdog?this.instance=await this._createEditor(this.domContainer.current,this._getConfig()):this.watchdog||(this.context instanceof Qr?this.watchdog=new eo(this.context):this.watchdog=new to._EditorWatchdog(this.props.editor,this.props.watchdogConfig),this.watchdog.setCreator(((t,e)=>this._createEditor(t,e))),this.watchdog.on("error",((t,{error:e,causesRestart:r})=>{(this.props.onError||console.error)(e,{phase:"runtime",willEditorRestart:r})})),await this.watchdog.create(this.domContainer.current,this._getConfig()).catch((t=>{(this.props.onError||console.error)(t,{phase:"initialization",willEditorRestart:!1})})))}_createEditor(t,e){return this.props.editor.create(t,e).then((t=>{"disabled"in this.props&&this.props.disabled&&t.enableReadOnlyMode(Zr);const e=t.model.document,r=t.editing.view.document;return e.on("change:data",(e=>{this.props.onChange&&this.props.onChange(e,t)})),r.on("focus",(e=>{this.props.onFocus&&this.props.onFocus(e,t)})),r.on("blur",(e=>{this.props.onBlur&&this.props.onBlur(e,t)})),setTimeout((()=>{this.props.onReady&&this.props.onReady(t)})),t}))}async _destroyEditor(){this.editorDestructionInProgress=new Promise((t=>{setTimeout((async()=>this.watchdog?(await this.watchdog.destroy(),this.watchdog=null,t()):this.instance?(await this.instance.destroy(),this.instance=null,t()):void t()))}))}_shouldUpdateEditor(t){return this.props.data!==t.data&&this.editor.data.get()!==t.data}_getConfig(){const t=this.props.config||{};return this.props.data&&t.initialData&&console.warn("Editor data should be provided either using `config.initialData` or `data` properties. The config property is over the data value and the first one will be used when specified both."),{...t,initialData:t.initialData||this.props.data||""}}}to.contextType=Jr,to.propTypes={editor:i().func.isRequired,data:i().string,config:i().object,disableWatchdog:i().bool,watchdogConfig:i().object,onChange:i().func,onReady:i().func,onFocus:i().func,onBlur:i().func,onError:i().func,disabled:i().bool,id:i().any},to._EditorWatchdog=Vr;class eo{constructor(t){this._contextWatchdog=t,this._id=function(){const t=4294967296*Math.random()>>>0,e=4294967296*Math.random()>>>0,r=4294967296*Math.random()>>>0,o=4294967296*Math.random()>>>0;return"e"+s[t>>0&255]+s[t>>8&255]+s[t>>16&255]+s[t>>24&255]+s[e>>0&255]+s[e>>8&255]+s[e>>16&255]+s[e>>24&255]+s[r>>0&255]+s[r>>8&255]+s[r>>16&255]+s[r>>24&255]+s[o>>0&255]+s[o>>8&255]+s[o>>16&255]+s[o>>24&255]}()}setCreator(t){this._creator=t}create(t,e){return this._contextWatchdog.add({sourceElementOrData:t,config:e,creator:this._creator,id:this._id,type:"editor"})}on(t,e){this._contextWatchdog.on("itemError",((t,{itemId:r,error:o})=>{r===this._id&&e(null,{error:o,causesRestart:void 0})}))}destroy(){return"ready"===this._contextWatchdog.state?this._contextWatchdog.remove(this._id):Promise.resolve()}get editor(){return this._contextWatchdog.getItem(this._id)}}})(),n})()));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.CKEditor=e(require("react")):t.CKEditor=e(t.React)}(self,(t=>(()=>{var e={703:(t,e,r)=>{"use strict";var o=r(414);function n(){}function s(){}s.resetWarningCache=n,t.exports=function(){function t(t,e,r,n,s,i){if(i!==o){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function e(){return t}t.isRequired=t;var r={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:s,resetWarningCache:n};return r.PropTypes=r,r}},697:(t,e,r)=>{t.exports=r(703)()},414:t=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},787:e=>{"use strict";e.exports=t}},r={};function o(t){var n=r[t];if(void 0!==n)return n.exports;var s=r[t]={exports:{}};return e[t](s,s.exports,o),s.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";o.r(n),o.d(n,{CKEditor:()=>eo,CKEditorContext:()=>Zr,useMultiRootEditor:()=>no});var t=o(787),e=o.n(t),r=o(697),s=o.n(r);const i=new Array(256).fill("").map(((t,e)=>("0"+e.toString(16)).slice(-2)));class a{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 c(t,e=new Set){const r=[t],o=new Set;let n=0;for(;r.length>n;){const t=r[n++];if(!o.has(t)&&u(t)&&!e.has(t))if(o.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 o}function u(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 d(t,e,r=new Set){if(t===e&&("object"==typeof(o=t)&&null!==o))return!0;var o;const n=c(t,r),s=c(e,r);for(const t of n)if(s.has(t))return!0;return!1}const h=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};const l="object"==typeof global&&global&&global.Object===Object&&global;var f="object"==typeof self&&self&&self.Object===Object&&self;const p=l||f||Function("return this")();const g=function(){return p.Date.now()};var _=/\s/;const y=function(t){for(var e=t.length;e--&&_.test(t.charAt(e)););return e};var b=/^\s+/;const m=function(t){return t?t.slice(0,y(t)+1).replace(b,""):t};const v=p.Symbol;var w=Object.prototype,j=w.hasOwnProperty,E=w.toString,x=v?v.toStringTag:void 0;const O=function(t){var e=j.call(t,x),r=t[x];try{t[x]=void 0;var o=!0}catch(t){}var n=E.call(t);return o&&(e?t[x]=r:delete t[x]),n};var C=Object.prototype.toString;const R=function(t){return C.call(t)};var A=v?v.toStringTag:void 0;const S=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":A&&A in Object(t)?O(t):R(t)};const P=function(t){return null!=t&&"object"==typeof t};const T=function(t){return"symbol"==typeof t||P(t)&&"[object Symbol]"==S(t)};var D=/^[-+]0x[0-9a-f]+$/i,N=/^0b[01]+$/i,W=/^0o[0-7]+$/i,k=parseInt;const I=function(t){if("number"==typeof t)return t;if(T(t))return NaN;if(h(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=h(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=m(t);var r=N.test(t);return r||W.test(t)?k(t.slice(2),r?2:8):D.test(t)?NaN:+t};var z=Math.max,U=Math.min;const M=function(t,e,r){var o,n,s,i,a,c,u=0,d=!1,l=!1,f=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var r=o,s=n;return o=n=void 0,u=e,i=t.apply(s,r)}function _(t){var r=t-c;return void 0===c||r>=e||r<0||l&&t-u>=s}function y(){var t=g();if(_(t))return b(t);a=setTimeout(y,function(t){var r=e-(t-c);return l?U(r,s-(t-u)):r}(t))}function b(t){return a=void 0,f&&o?p(t):(o=n=void 0,i)}function m(){var t=g(),r=_(t);if(o=arguments,n=this,c=t,r){if(void 0===a)return function(t){return u=t,a=setTimeout(y,e),d?p(t):i}(c);if(l)return clearTimeout(a),a=setTimeout(y,e),p(c)}return void 0===a&&(a=setTimeout(y,e)),i}return e=I(e)||0,h(r)&&(d=!!r.leading,s=(l="maxWait"in r)?z(I(r.maxWait)||0,e):s,f="trailing"in r?!!r.trailing:f),m.cancel=function(){void 0!==a&&clearTimeout(a),u=0,o=c=n=a=void 0},m.flush=function(){return void 0===a?i:b(g())},m};const F=function(t,e,r){var o=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return h(r)&&(o="leading"in r?!!r.leading:o,n="trailing"in r?!!r.trailing:n),M(t,e,{leading:o,maxWait:e,trailing:n})};const L=function(t,e){return function(r){return t(e(r))}};const q=L(Object.getPrototypeOf,Object);var J=Function.prototype,B=Object.prototype,$=J.toString,H=B.hasOwnProperty,K=$.call(Object);const V=function(t){if(!P(t)||"[object Object]"!=S(t))return!1;var e=q(t);if(null===e)return!0;var r=H.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&$.call(r)==K};const Q=function(t){return P(t)&&1===t.nodeType&&!V(t)};const G=function(){this.__data__=[],this.size=0};const Y=function(t,e){return t===e||t!=t&&e!=e};const X=function(t,e){for(var r=t.length;r--;)if(Y(t[r][0],e))return r;return-1};var Z=Array.prototype.splice;const tt=function(t){var e=this.__data__,r=X(e,t);return!(r<0)&&(r==e.length-1?e.pop():Z.call(e,r,1),--this.size,!0)};const et=function(t){var e=this.__data__,r=X(e,t);return r<0?void 0:e[r][1]};const rt=function(t){return X(this.__data__,t)>-1};const ot=function(t,e){var r=this.__data__,o=X(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this};function nt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}nt.prototype.clear=G,nt.prototype.delete=tt,nt.prototype.get=et,nt.prototype.has=rt,nt.prototype.set=ot;const st=nt;const it=function(){this.__data__=new st,this.size=0};const at=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r};const ct=function(t){return this.__data__.get(t)};const ut=function(t){return this.__data__.has(t)};const dt=function(t){if(!h(t))return!1;var e=S(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e};const ht=p["__core-js_shared__"];var lt=function(){var t=/[^.]+$/.exec(ht&&ht.keys&&ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();const ft=function(t){return!!lt&&lt in t};var pt=Function.prototype.toString;const gt=function(t){if(null!=t){try{return pt.call(t)}catch(t){}try{return t+""}catch(t){}}return""};var _t=/^\[object .+?Constructor\]$/,yt=Function.prototype,bt=Object.prototype,mt=yt.toString,vt=bt.hasOwnProperty,wt=RegExp("^"+mt.call(vt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const jt=function(t){return!(!h(t)||ft(t))&&(dt(t)?wt:_t).test(gt(t))};const Et=function(t,e){return null==t?void 0:t[e]};const xt=function(t,e){var r=Et(t,e);return jt(r)?r:void 0};const Ot=xt(p,"Map");const Ct=xt(Object,"create");const Rt=function(){this.__data__=Ct?Ct(null):{},this.size=0};const At=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e};var St=Object.prototype.hasOwnProperty;const Pt=function(t){var e=this.__data__;if(Ct){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return St.call(e,t)?e[t]:void 0};var Tt=Object.prototype.hasOwnProperty;const Dt=function(t){var e=this.__data__;return Ct?void 0!==e[t]:Tt.call(e,t)};const Nt=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ct&&void 0===e?"__lodash_hash_undefined__":e,this};function Wt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Wt.prototype.clear=Rt,Wt.prototype.delete=At,Wt.prototype.get=Pt,Wt.prototype.has=Dt,Wt.prototype.set=Nt;const kt=Wt;const It=function(){this.size=0,this.__data__={hash:new kt,map:new(Ot||st),string:new kt}};const zt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};const Ut=function(t,e){var r=t.__data__;return zt(e)?r["string"==typeof e?"string":"hash"]:r.map};const Mt=function(t){var e=Ut(this,t).delete(t);return this.size-=e?1:0,e};const Ft=function(t){return Ut(this,t).get(t)};const Lt=function(t){return Ut(this,t).has(t)};const qt=function(t,e){var r=Ut(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this};function Jt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Jt.prototype.clear=It,Jt.prototype.delete=Mt,Jt.prototype.get=Ft,Jt.prototype.has=Lt,Jt.prototype.set=qt;const Bt=Jt;const $t=function(t,e){var r=this.__data__;if(r instanceof st){var o=r.__data__;if(!Ot||o.length<199)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new Bt(o)}return r.set(t,e),this.size=r.size,this};function Ht(t){var e=this.__data__=new st(t);this.size=e.size}Ht.prototype.clear=it,Ht.prototype.delete=at,Ht.prototype.get=ct,Ht.prototype.has=ut,Ht.prototype.set=$t;const Kt=Ht;const Vt=function(t,e){for(var r=-1,o=null==t?0:t.length;++r<o&&!1!==e(t[r],r,t););return t};const Qt=function(){try{var t=xt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();const Gt=function(t,e,r){"__proto__"==e&&Qt?Qt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r};var Yt=Object.prototype.hasOwnProperty;const Xt=function(t,e,r){var o=t[e];Yt.call(t,e)&&Y(o,r)&&(void 0!==r||e in t)||Gt(t,e,r)};const Zt=function(t,e,r,o){var n=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var a=e[s],c=o?o(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),n?Gt(r,a,c):Xt(r,a,c)}return r};const te=function(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o};const ee=function(t){return P(t)&&"[object Arguments]"==S(t)};var re=Object.prototype,oe=re.hasOwnProperty,ne=re.propertyIsEnumerable;const se=ee(function(){return arguments}())?ee:function(t){return P(t)&&oe.call(t,"callee")&&!ne.call(t,"callee")};const ie=Array.isArray;const ae=function(){return!1};var ce="object"==typeof exports&&exports&&!exports.nodeType&&exports,ue=ce&&"object"==typeof module&&module&&!module.nodeType&&module,de=ue&&ue.exports===ce?p.Buffer:void 0;const he=(de?de.isBuffer:void 0)||ae;var le=/^(?:0|[1-9]\d*)$/;const fe=function(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&le.test(t))&&t>-1&&t%1==0&&t<e};const pe=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991};var ge={};ge["[object Float32Array]"]=ge["[object Float64Array]"]=ge["[object Int8Array]"]=ge["[object Int16Array]"]=ge["[object Int32Array]"]=ge["[object Uint8Array]"]=ge["[object Uint8ClampedArray]"]=ge["[object Uint16Array]"]=ge["[object Uint32Array]"]=!0,ge["[object Arguments]"]=ge["[object Array]"]=ge["[object ArrayBuffer]"]=ge["[object Boolean]"]=ge["[object DataView]"]=ge["[object Date]"]=ge["[object Error]"]=ge["[object Function]"]=ge["[object Map]"]=ge["[object Number]"]=ge["[object Object]"]=ge["[object RegExp]"]=ge["[object Set]"]=ge["[object String]"]=ge["[object WeakMap]"]=!1;const _e=function(t){return P(t)&&pe(t.length)&&!!ge[S(t)]};const ye=function(t){return function(e){return t(e)}};var be="object"==typeof exports&&exports&&!exports.nodeType&&exports,me=be&&"object"==typeof module&&module&&!module.nodeType&&module,ve=me&&me.exports===be&&l.process;const we=function(){try{var t=me&&me.require&&me.require("util").types;return t||ve&&ve.binding&&ve.binding("util")}catch(t){}}();var je=we&&we.isTypedArray;const Ee=je?ye(je):_e;var xe=Object.prototype.hasOwnProperty;const Oe=function(t,e){var r=ie(t),o=!r&&se(t),n=!r&&!o&&he(t),s=!r&&!o&&!n&&Ee(t),i=r||o||n||s,a=i?te(t.length,String):[],c=a.length;for(var u in t)!e&&!xe.call(t,u)||i&&("length"==u||n&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||fe(u,c))||a.push(u);return a};var Ce=Object.prototype;const Re=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ce)};const Ae=L(Object.keys,Object);var Se=Object.prototype.hasOwnProperty;const Pe=function(t){if(!Re(t))return Ae(t);var e=[];for(var r in Object(t))Se.call(t,r)&&"constructor"!=r&&e.push(r);return e};const Te=function(t){return null!=t&&pe(t.length)&&!dt(t)};const De=function(t){return Te(t)?Oe(t):Pe(t)};const Ne=function(t,e){return t&&Zt(e,De(e),t)};const We=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e};var ke=Object.prototype.hasOwnProperty;const Ie=function(t){if(!h(t))return We(t);var e=Re(t),r=[];for(var o in t)("constructor"!=o||!e&&ke.call(t,o))&&r.push(o);return r};const ze=function(t){return Te(t)?Oe(t,!0):Ie(t)};const Ue=function(t,e){return t&&Zt(e,ze(e),t)};var Me="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fe=Me&&"object"==typeof module&&module&&!module.nodeType&&module,Le=Fe&&Fe.exports===Me?p.Buffer:void 0,qe=Le?Le.allocUnsafe:void 0;const Je=function(t,e){if(e)return t.slice();var r=t.length,o=qe?qe(r):new t.constructor(r);return t.copy(o),o};const Be=function(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e};const $e=function(t,e){for(var r=-1,o=null==t?0:t.length,n=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[n++]=i)}return s};const He=function(){return[]};var Ke=Object.prototype.propertyIsEnumerable,Ve=Object.getOwnPropertySymbols;const Qe=Ve?function(t){return null==t?[]:(t=Object(t),$e(Ve(t),(function(e){return Ke.call(t,e)})))}:He;const Ge=function(t,e){return Zt(t,Qe(t),e)};const Ye=function(t,e){for(var r=-1,o=e.length,n=t.length;++r<o;)t[n+r]=e[r];return t};const Xe=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Ye(e,Qe(t)),t=q(t);return e}:He;const Ze=function(t,e){return Zt(t,Xe(t),e)};const tr=function(t,e,r){var o=e(t);return ie(t)?o:Ye(o,r(t))};const er=function(t){return tr(t,De,Qe)};const rr=function(t){return tr(t,ze,Xe)};const or=xt(p,"DataView");const nr=xt(p,"Promise");const sr=xt(p,"Set");const ir=xt(p,"WeakMap");var ar="[object Map]",cr="[object Promise]",ur="[object Set]",dr="[object WeakMap]",hr="[object DataView]",lr=gt(or),fr=gt(Ot),pr=gt(nr),gr=gt(sr),_r=gt(ir),yr=S;(or&&yr(new or(new ArrayBuffer(1)))!=hr||Ot&&yr(new Ot)!=ar||nr&&yr(nr.resolve())!=cr||sr&&yr(new sr)!=ur||ir&&yr(new ir)!=dr)&&(yr=function(t){var e=S(t),r="[object Object]"==e?t.constructor:void 0,o=r?gt(r):"";if(o)switch(o){case lr:return hr;case fr:return ar;case pr:return cr;case gr:return ur;case _r:return dr}return e});const br=yr;var mr=Object.prototype.hasOwnProperty;const vr=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&mr.call(t,"index")&&(r.index=t.index,r.input=t.input),r};const wr=p.Uint8Array;const jr=function(t){var e=new t.constructor(t.byteLength);return new wr(e).set(new wr(t)),e};const Er=function(t,e){var r=e?jr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)};var xr=/\w*$/;const Or=function(t){var e=new t.constructor(t.source,xr.exec(t));return e.lastIndex=t.lastIndex,e};var Cr=v?v.prototype:void 0,Rr=Cr?Cr.valueOf:void 0;const Ar=function(t){return Rr?Object(Rr.call(t)):{}};const Sr=function(t,e){var r=e?jr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};const Pr=function(t,e,r){var o=t.constructor;switch(e){case"[object ArrayBuffer]":return jr(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return Er(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Sr(t,r);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return Or(t);case"[object Symbol]":return Ar(t)}};var Tr=Object.create;const Dr=function(){function t(){}return function(e){if(!h(e))return{};if(Tr)return Tr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();const Nr=function(t){return"function"!=typeof t.constructor||Re(t)?{}:Dr(q(t))};const Wr=function(t){return P(t)&&"[object Map]"==br(t)};var kr=we&&we.isMap;const Ir=kr?ye(kr):Wr;const zr=function(t){return P(t)&&"[object Set]"==br(t)};var Ur=we&&we.isSet;const Mr=Ur?ye(Ur):zr;var Fr="[object Arguments]",Lr="[object Function]",qr="[object Object]",Jr={};Jr[Fr]=Jr["[object Array]"]=Jr["[object ArrayBuffer]"]=Jr["[object DataView]"]=Jr["[object Boolean]"]=Jr["[object Date]"]=Jr["[object Float32Array]"]=Jr["[object Float64Array]"]=Jr["[object Int8Array]"]=Jr["[object Int16Array]"]=Jr["[object Int32Array]"]=Jr["[object Map]"]=Jr["[object Number]"]=Jr[qr]=Jr["[object RegExp]"]=Jr["[object Set]"]=Jr["[object String]"]=Jr["[object Symbol]"]=Jr["[object Uint8Array]"]=Jr["[object Uint8ClampedArray]"]=Jr["[object Uint16Array]"]=Jr["[object Uint32Array]"]=!0,Jr["[object Error]"]=Jr[Lr]=Jr["[object WeakMap]"]=!1;const Br=function t(e,r,o,n,s,i){var a,c=1&r,u=2&r,d=4&r;if(o&&(a=s?o(e,n,s,i):o(e)),void 0!==a)return a;if(!h(e))return e;var l=ie(e);if(l){if(a=vr(e),!c)return Be(e,a)}else{var f=br(e),p=f==Lr||"[object GeneratorFunction]"==f;if(he(e))return Je(e,c);if(f==qr||f==Fr||p&&!s){if(a=u||p?{}:Nr(e),!c)return u?Ze(e,Ue(a,e)):Ge(e,Ne(a,e))}else{if(!Jr[f])return s?e:{};a=Pr(e,f,c)}}i||(i=new Kt);var g=i.get(e);if(g)return g;i.set(e,a),Mr(e)?e.forEach((function(n){a.add(t(n,r,o,n,e,i))})):Ir(e)&&e.forEach((function(n,s){a.set(s,t(n,r,o,s,e,i))}));var _=l?void 0:(d?u?rr:er:u?ze:De)(e);return Vt(_||e,(function(n,s){_&&(n=e[s=n]),Xt(a,s,t(n,r,o,s,e,i))})),a};const $r=function(t,e){return Br(t,5,e="function"==typeof e?e:void 0)};class Hr extends a{constructor(t,e={}){super(e),this._editor=null,this._initUsingData=!0,this._editables={},this._throttledSave=F(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((()=>{const t={},e=[],r=this._config.rootsAttributes||{},o={};for(const[n,s]of Object.entries(this._data.roots))s.isLoaded?(t[n]="",o[n]=r[n]||{}):e.push(n);const n={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:e,rootsAttributes:o,_watchdogInitialData:this._data};return delete n.initialData,n.extraPlugins.push(Kr),this._initUsingData?this.create(t,n,n.context):Q(this._elementOrData)?this.create(this._elementOrData,n,n.context):this.create(this._editables,n,n.context)})).then((()=>{this._fire("restart")}))}create(t=this._elementOrData,e=this._config,r){return Promise.resolve().then((()=>(super._startErrorHandling(),this._elementOrData=t,this._initUsingData="string"==typeof t||Object.keys(t).length>0&&"string"==typeof Object.values(t)[0],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._initUsingData||(this._editables=this._getEditables()),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.cancel();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._initUsingData||(this._editables=this._getEditables()),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=this._editor,e=t.model.document.roots.filter((t=>t.isAttached()&&"$graveyard"!=t.rootName)),{plugins:r}=t,o=r.has("CommentsRepository")&&r.get("CommentsRepository"),n=r.has("TrackChanges")&&r.get("TrackChanges"),s={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};e.forEach((t=>{s.roots[t.rootName]={content:JSON.stringify(Array.from(t.getChildren())),attributes:JSON.stringify(Array.from(t.getAttributes())),isLoaded:t._isLoaded}}));for(const e of t.model.markers)e._affectsData&&(s.markers[e.name]={rangeJSON:e.getRange().toJSON(),usingOperation:e._managedUsingOperations,affectsData:e._affectsData});return o&&(s.commentThreads=JSON.stringify(o.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),n&&(s.suggestions=JSON.stringify(n.getSuggestions({toJSON:!0,skipNotAttached:!0}))),s}_getEditables(){const t={};for(const e of this.editor.model.document.getRootNames()){const r=this.editor.ui.getEditableElement(e);r&&(t[e]=r)}return t}_isErrorComingFromThisItem(t){return d(this._editor,t.context,this._excludedProps)}_cloneEditorConfiguration(t){return $r(t,((t,e)=>Q(t)||"context"===e?t:void 0))}}class Kr{constructor(t){this.editor=t,this._data=t.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",(t=>{t.stop(),this.editor.model.enqueueChange({isUndoable:!1},(t=>{this._restoreCollaborationData(),this._restoreEditorData(t)})),this.editor.data.fire("ready")}),{priority:999})}_createNode(t,e){if("name"in e){const r=t.createElement(e.name,e.attributes);if(e.children)for(const o of e.children)r._appendChild(this._createNode(t,o));return r}return t.createText(e.data,e.attributes)}_restoreEditorData(t){const e=this.editor;Object.entries(this._data.roots).forEach((([r,{content:o,attributes:n}])=>{const s=JSON.parse(o),i=JSON.parse(n),a=e.model.document.getRoot(r);for(const[e,r]of i)t.setAttribute(e,r,a);for(const e of s){const r=this._createNode(t,e);t.insert(r,a,"end")}})),Object.entries(this._data.markers).forEach((([r,o])=>{const{document:n}=e.model,{rangeJSON:{start:s,end:i},...a}=o,c=n.getRoot(s.root),u=t.createPositionFromPath(c,s.path,s.stickiness),d=t.createPositionFromPath(c,i.path,i.stickiness),h=t.createRange(u,d);t.addMarker(r,{range:h,...a})}))}_restoreCollaborationData(){const t=JSON.parse(this._data.commentThreads),e=JSON.parse(this._data.suggestions);t.forEach((t=>{const e=this.editor.config.get("collaboration.channelId"),r=this.editor.plugins.get("CommentsRepository");if(r.hasCommentThread(t.threadId)){r.getCommentThread(t.threadId).remove()}r.addCommentThread({channelId:e,...t})})),e.forEach((t=>{const e=this.editor.plugins.get("TrackChangesEditing");if(e.hasSuggestion(t.id)){e.getSuggestion(t.id).attributes=t.attributes}else e.addSuggestionData(t)}))}}const Vr=Symbol("MainQueueId");class Qr extends a{constructor(t,e={}){super(e),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new Gr,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(Vr,(()=>(this._contextConfig=t,this._create())))}getItem(t){return this._getWatchdog(t)._item}getItemState(t){return this._getWatchdog(t).state}add(t){const e=Yr(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 Hr(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:o,causesRestart:n})=>{this._fire("itemError",{itemId:t.id,error:o}),n&&this._actionQueues.enqueue(t.id,(()=>new Promise((r=>{const o=()=>{e.off("restart",o),this._fire("itemRestart",{itemId:t.id}),r()};e.on("restart",o)}))))})),e.create(t.sourceElementOrData,t.config,this._context);throw new Error(`Not supported item type: '${t.type}'.`)})))))}remove(t){const e=Yr(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(Vr,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Vr,(()=>(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=c(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 d(this._context,t.context)}}class Gr{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(t){this._onEmptyCallbacks.push(t)}enqueue(t,e){const r=t===Vr;this._activeActions++,this._queues.get(t)||this._queues.set(t,Promise.resolve());const o=(r?Promise.all(this._queues.values()):Promise.all([this._queues.get(Vr),this._queues.get(t)])).then(e),n=o.catch((()=>{}));return this._queues.set(t,n),o.finally((()=>{this._activeActions--,this._queues.get(t)===n&&0===this._activeActions&&this._onEmptyCallbacks.forEach((t=>t()))}))}}function Yr(t){return Array.isArray(t)?t:[t]}const Xr=e().createContext("contextWatchdog");class Zr extends e().Component{constructor(t,e){super(t,e),this.contextWatchdog=null,this.props.isLayoutReady&&this._initializeContextWatchdog(this.props.config)}shouldComponentUpdate(t){return this._shouldComponentUpdate(t)}async _shouldComponentUpdate(t){return t.id!==this.props.id&&(this.contextWatchdog&&await this.contextWatchdog.destroy(),await this._initializeContextWatchdog(t.config)),t.isLayoutReady&&!this.contextWatchdog?(await this._initializeContextWatchdog(t.config),!0):this.props.children!==t.children}render(){return e().createElement(Xr.Provider,{value:this.contextWatchdog},this.props.children)}componentWillUnmount(){this._destroyContext()}async _initializeContextWatchdog(t){this.contextWatchdog=new Qr(this.props.context,this.props.watchdogConfig),this.contextWatchdog.on("error",((t,e)=>{this.props.onError(e.error,{phase:"runtime",willContextRestart:e.causesRestart})})),this.contextWatchdog.on("stateChange",(()=>{"ready"===this.contextWatchdog.state&&this.props.onReady&&this.props.onReady(this.contextWatchdog.context)})),await this.contextWatchdog.create(t).catch((t=>{this.props.onError(t,{phase:"initialization",willContextRestart:!1})}))}async _destroyContext(){this.contextWatchdog&&(await this.contextWatchdog.destroy(),this.contextWatchdog=null)}}Zr.defaultProps={isLayoutReady:!0,onError:(t,e)=>console.error(t,e)},Zr.propTypes={id:s().string,isLayoutReady:s().bool,context:s().func,watchdogConfig:s().object,config:s().object,onReady:s().func,onError:s().func};const to="Lock from React integration (@ckeditor/ckeditor5-react)";class eo extends e().Component{constructor(t){super(t),this.editorDestructionInProgress=null,this.domContainer=e().createRef(),this.watchdog=null;const{CKEDITOR_VERSION:r}=window;if(r){const[t]=r.split(".").map(Number);t<37&&console.warn("The <CKEditor> component requires using CKEditor 5 in version 37 or higher.")}else console.warn('Cannot find the "CKEDITOR_VERSION" in the "window" scope.')}get editor(){return this.props.disableWatchdog?this.instance:this.watchdog?this.watchdog.editor:null}shouldComponentUpdate(t){return!!this.editor&&(t.id!==this.props.id||(t.disableWatchdog!==this.props.disableWatchdog||(this._shouldUpdateEditor(t)&&this.editor.data.set(t.data),"disabled"in t&&(t.disabled?this.editor.enableReadOnlyMode(to):this.editor.disableReadOnlyMode(to)),!1)))}async componentDidMount(){await this._initializeEditor()}async componentDidUpdate(){await this._destroyEditor(),await this._initializeEditor()}async componentWillUnmount(){await this._destroyEditor()}render(){return e().createElement("div",{ref:this.domContainer})}async _initializeEditor(){await this.editorDestructionInProgress,this.props.disableWatchdog?this.instance=await this._createEditor(this.domContainer.current,this._getConfig()):this.watchdog||(this.context instanceof Qr?this.watchdog=new ro(this.context):this.watchdog=new eo._EditorWatchdog(this.props.editor,this.props.watchdogConfig),this.watchdog.setCreator(((t,e)=>this._createEditor(t,e))),this.watchdog.on("error",((t,{error:e,causesRestart:r})=>{(this.props.onError||console.error)(e,{phase:"runtime",willEditorRestart:r})})),await this.watchdog.create(this.domContainer.current,this._getConfig()).catch((t=>{(this.props.onError||console.error)(t,{phase:"initialization",willEditorRestart:!1})})))}_createEditor(t,e){return this.props.editor.create(t,e).then((t=>{"disabled"in this.props&&this.props.disabled&&t.enableReadOnlyMode(to);const e=t.model.document,r=t.editing.view.document;return e.on("change:data",(e=>{this.props.onChange&&this.props.onChange(e,t)})),r.on("focus",(e=>{this.props.onFocus&&this.props.onFocus(e,t)})),r.on("blur",(e=>{this.props.onBlur&&this.props.onBlur(e,t)})),setTimeout((()=>{this.props.onReady&&this.props.onReady(t)})),t}))}async _destroyEditor(){this.editorDestructionInProgress=new Promise((t=>{setTimeout((async()=>this.watchdog?(await this.watchdog.destroy(),this.watchdog=null,t()):this.instance?(await this.instance.destroy(),this.instance=null,t()):void t()))}))}_shouldUpdateEditor(t){return this.props.data!==t.data&&this.editor.data.get()!==t.data}_getConfig(){const t=this.props.config||{};return this.props.data&&t.initialData&&console.warn("Editor data should be provided either using `config.initialData` or `content` property. The config value takes precedence over `content` property and will be used when both are specified."),{...t,initialData:t.initialData||this.props.data||""}}}eo.contextType=Xr,eo.propTypes={editor:s().func.isRequired,data:s().string,config:s().object,disableWatchdog:s().bool,watchdogConfig:s().object,onChange:s().func,onReady:s().func,onFocus:s().func,onBlur:s().func,onError:s().func,disabled:s().bool,id:s().any},eo._EditorWatchdog=Hr;class ro{constructor(t){this._contextWatchdog=t,this._id=function(){const t=4294967296*Math.random()>>>0,e=4294967296*Math.random()>>>0,r=4294967296*Math.random()>>>0,o=4294967296*Math.random()>>>0;return"e"+i[t>>0&255]+i[t>>8&255]+i[t>>16&255]+i[t>>24&255]+i[e>>0&255]+i[e>>8&255]+i[e>>16&255]+i[e>>24&255]+i[r>>0&255]+i[r>>8&255]+i[r>>16&255]+i[r>>24&255]+i[o>>0&255]+i[o>>8&255]+i[o>>16&255]+i[o>>24&255]}()}setCreator(t){this._creator=t}create(t,e){return this._contextWatchdog.add({sourceElementOrData:t,config:e,creator:this._creator,id:this._id,type:"editor"})}on(t,e){this._contextWatchdog.on("itemError",((t,{itemId:r,error:o})=>{r===this._id&&e(null,{error:o,causesRestart:void 0})}))}destroy(){return"ready"===this._contextWatchdog.state?this._contextWatchdog.remove(this._id):Promise.resolve()}get editor(){return this._contextWatchdog.getItem(this._id)}}const oo="Lock from React integration (@ckeditor/ckeditor5-react)",no=r=>{let o=null;const n=(0,t.useRef)(null),s=(0,t.useContext)(Xr),[i,a]=(0,t.useState)(null),[c,u]=(0,t.useState)(r.data),[d,h]=(0,t.useState)(r.rootsAttributes||{}),[l,f]=(0,t.useState)([]),p=(0,t.useRef)(!0),g=(0,t.useRef)(null),_=e().createElement("div",{ref:g});(0,t.useEffect)((()=>((async()=>{await n.current,!1!==r.isLayoutReady&&w()})(),()=>{v().then((()=>{n.current=null}))})),[r.isLayoutReady]),(0,t.useEffect)((()=>{i&&(r.disabled?i.enableReadOnlyMode(oo):i.disableReadOnlyMode(oo))}),[r.disabled]),(0,t.useEffect)((()=>{const t=g.current;if(i&&!n.current){const e=i.getFullData();u({...e}),h({...i.getRootsAttributes()}),f([...Object.keys(e).map((t=>b(i,t)))]),t&&t.appendChild(i.ui.view.toolbar.element)}return()=>{t&&t.firstChild&&t.removeChild(t.firstChild)}}),[i&&i.id]);const y=()=>{const t=r.config||{};return r.data&&t.initialData&&console.warn("Editor data should be provided either using `config.initialData` or `data` property. The config value takes precedence over `data` property and will be used when both are specified."),{...t,rootsAttributes:d}},b=(t,r)=>e().createElement("div",{id:r,key:r,ref:e=>{if(e){const o=t.ui.view.createEditable(r,e);t.ui.addEditable(o),t.editing.view.forceRender()}}}),m=(t,e)=>r.editor.create(t,e).then((t=>{r.disabled&&r.disabled&&t.enableReadOnlyMode(oo);const e=t.model.document,o=t.editing.view.document;return e.on("change:data",(e=>((t,e)=>{const o=t.model.document,n={},s={};o.differ.getChanges().forEach((e=>{let r;if(r="insert"==e.type||"remove"==e.type?e.position.root:e.range.root,!r.isAttached())return;const{rootName:o}=r;n[o]=t.getData({rootName:o})})),o.differ.getChangedRoots().forEach((e=>{if(e.state)return void(void 0!==n[e.name]&&delete n[e.name]);const r=e.name;s[r]=t.getRootAttributes(r)})),Object.keys(n).length&&u((t=>({...t,...n}))),Object.keys(s).length&&h((t=>({...t,...s}))),r.onChange&&r.onChange(e,t)})(t,e))),t.on("addRoot",((e,r)=>((t,e,r)=>{const o=r.rootName,n=b(t,o);u((e=>({...e,[o]:t.getData({rootName:o})}))),h((e=>({...e,[o]:t.getRootAttributes(o)}))),f((t=>[...t,n]))})(t,0,r))),t.on("detachRoot",((e,r)=>((t,e,r)=>{const o=r.rootName;f((t=>t.filter((t=>t.props.id!==o)))),u((t=>{const{[o]:e,...r}=t;return{...r}})),h((t=>{const{[o]:e,...r}=t;return{...r}})),t.detachEditable(r)})(t,0,r))),o.on("focus",(e=>{r.onFocus&&r.onFocus(e,t)})),o.on("blur",(e=>{r.onBlur&&r.onBlur(e,t)})),a(t),r.onReady&&r.onReady(t),t})),v=async()=>{a(null),u({}),h({}),f([]),n.current=new Promise((t=>{setTimeout((async()=>o?(await o.destroy(),o=null,t()):i?(await i.destroy(),t()):void t()))}))},w=async()=>{r.disableWatchdog?await m(r.data,y()):o||(o=s instanceof Qr?new ro(s):new Hr(r.editor,r.watchdogConfig),o.setCreator(((t,e)=>m(t,e))),o.on("error",((t,{error:e,causesRestart:o})=>{(r.onError||console.error)(e,{phase:"runtime",willEditorRestart:o})})),await o.create(c,y()).catch((t=>{(r.onError||console.error)(t,{phase:"initialization",willEditorRestart:!1})})))};(0,t.useEffect)((()=>{if(i&&p.current){p.current=!1;const t=Object.keys(c),e=Object.keys(d);if(!t.every((t=>e.includes(t))))throw new Error("`data` and `attributes` objects must have the same keys (roots).");const r=i.getFullData(),o=i.getRootsAttributes(),{addedKeys:n,removedKeys:s}=j(r,c||{}),a=t.some((t=>void 0!==r[t]&&JSON.stringify(r[t])!==JSON.stringify(c[t]))),u=e.filter((t=>JSON.stringify(o[t])!==JSON.stringify(d[t])));i.model.change((t=>{E(n),x(s),a&&O(),u.length&&C(t,u)}))}}),[c,d]);const j=(t,e)=>{const r=Object.keys(t),o=Object.keys(e);return{addedKeys:o.filter((t=>!r.includes(t))),removedKeys:r.filter((t=>!o.includes(t)))}},E=t=>{t.forEach((t=>{i.addRoot(t,{data:c[t]||"",attributes:(null==d?void 0:d[t])||{},isUndoable:!0})}))},x=t=>{t.forEach((t=>{i.detachRoot(t,!0)}))},O=()=>{i.data.set(c,{suppressErrorInCollaboration:!0})},C=(t,e)=>{e.forEach((e=>{Object.keys(d[e]).forEach((t=>{i.registerRootAttribute(t)})),t.clearAttributes(i.model.document.getRoot(e)),t.setAttributes(d[e],i.model.document.getRoot(e))}))},R=(0,t.useCallback)((t=>{p.current=!0,u(t)}),[u]),A=(0,t.useCallback)((t=>{p.current=!0,h(t)}),[h]);return{editor:i,editableElements:l,toolbarElement:_,data:c,setData:R,attributes:d,setAttributes:A}}})(),n})()));
//# sourceMappingURL=index.js.map
{
"name": "@ckeditor/ckeditor5-react",
"version": "6.1.0",
"version": "6.2.0",
"main": "dist/index.js",

@@ -25,14 +25,15 @@ "types": "dist/index.d.ts",

"strip-ansi-cjs": "1.0.0",
"string-width": "^4.0.0"
"string-width": "^4.0.0",
"semver": "^7.0.0"
},
"peerDependencies": {
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
"@ckeditor/ckeditor5-core": ">=37.0.0",
"@ckeditor/ckeditor5-engine": ">=37.0.0",
"@ckeditor/ckeditor5-utils": ">=37.0.0",
"@ckeditor/ckeditor5-watchdog": ">=37.0.0"
"@ckeditor/ckeditor5-core": ">=40.1.0",
"@ckeditor/ckeditor5-editor-multi-root": ">=40.1.0",
"@ckeditor/ckeditor5-engine": ">=40.1.0",
"@ckeditor/ckeditor5-utils": ">=40.1.0",
"@ckeditor/ckeditor5-watchdog": ">=40.1.0",
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=5.7.1"
"node": ">=18.0.0"
},

@@ -39,0 +40,0 @@ "author": "CKSource (http://cksource.com/)",

# CKEditor 5 rich text editor component for React
[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-react.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-react)
[![Build Status](https://app.travis-ci.com/ckeditor/ckeditor5-react.svg?branch=master)](https://app.travis-ci.com/ckeditor/ckeditor5-react)
[![CircleCI](https://circleci.com/gh/ckeditor/ckeditor5-react.svg?style=shield)](https://app.circleci.com/pipelines/github/ckeditor/ckeditor5-react?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-react/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-react?branch=master)

@@ -6,0 +6,0 @@ ![Dependency Status](https://img.shields.io/librariesio/release/npm/@ckeditor/ckeditor5-react)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc