Verified Commit afe9e1b1 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

task: #3576995 Update CKEditor 5 to 47.6.0

By: longwave
By: quietone
parent 25c4571c
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
/*!
 * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
 * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */(()=>{var e={237:e=>{"use strict";e.exports=CKEditor5.dll},260:(e,t,r)=>{e.exports=r(237)("./src/upload.js")},782:(e,t,r)=>{e.exports=r(237)("./src/core.js")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,r),s.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{CKFinderUploadAdapter:()=>p,_getCKFinderCookie:()=>a,_getCKFinderCsrfToken:()=>d,_setCKFinderCookie:()=>l});var e=r(782),t=r(260);const n="ckCsrfToken",s=40,i="abcdefghijklmnopqrstuvwxyz0123456789";function d(){let e=a(n);return e&&e.length==s||(e=function(e){let t="";const r=new Uint8Array(e);window.crypto.getRandomValues(r);for(let e=0;e<r.length;e++){const o=i.charAt(r[e]%i.length);t+=Math.random()>.5?o.toUpperCase():o}return t}(s),l(n,e)),e}function a(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const r of t){const t=r.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}function l(e,t){document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+";path=/"}class p extends e.Plugin{static get requires(){return[t.FileRepository]}static get pluginName(){return"CKFinderUploadAdapter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(t.FileRepository).createUploadAdapter=t=>new u(t,e,this.editor.t))}}class u{loader;url;t;xhr;constructor(e,t,r){this.loader=e,this.url=t,this.t=r}upload(){return this.loader.file.then(e=>new Promise((t,r)=>{this._initRequest(),this._initListeners(t,r,e),this._sendRequest(e)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,r){const o=this.xhr,n=this.loader,s=(0,this.t)("Cannot upload file:")+` ${r.name}.`;o.addEventListener("error",()=>t(s)),o.addEventListener("abort",()=>t()),o.addEventListener("load",()=>{const r=o.response;if(!r||!r.uploaded)return t(r&&r.error&&r.error.message?r.error.message:s);e({default:r.url})}),o.upload&&o.upload.addEventListener("progress",e=>{e.lengthComputable&&(n.uploadTotal=e.total,n.uploaded=e.loaded)})}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",d()),this.xhr.send(t)}}})(),(window.CKEditor5=window.CKEditor5||{}).adapterCkfinder=o})();
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"Align center":"Align center","Align left":"Align left","Align right":"Align right",Justify:"Justify","Text alignment":"Text alignment","Text alignment toolbar":"Text alignment toolbar"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
/*!
 * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
 * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */(()=>{var e={237:e=>{"use strict";e.exports=CKEditor5.dll},311:(e,t,n)=>{e.exports=n(237)("./src/ui.js")},355:(e,t,n)=>{e.exports=n(237)("./src/icons.js")},584:(e,t,n)=>{e.exports=n(237)("./src/utils.js")},782:(e,t,n)=>{e.exports=n(237)("./src/core.js")}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{"use strict";n.r(i),n.d(i,{Alignment:()=>p,AlignmentCommand:()=>c,AlignmentEditing:()=>u,AlignmentUI:()=>f,_ALIGNMENT_SUPPORTED_OPTIONS:()=>o,_isAlignmentSupported:()=>a,_isDefaultAlignment:()=>r,_normalizeAlignmentOptions:()=>l});var e=n(782),t=n(584);const o=["left","right","center","justify"];function a(e){return o.includes(e)}function r(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function l(e){const n=e.map(e=>{let t;return t="string"==typeof e?{name:e}:e,t}).filter(e=>{const n=o.includes(e.name);return n||(0,t.logWarning)("alignment-config-name-not-recognized",{option:e}),n}),i=n.filter(e=>Boolean(e.className)).length;if(i&&i<n.length)throw new t.CKEditorError("alignment-config-classnames-are-missing",{configuredOptions:e});return n.forEach((n,i,o)=>{const a=o.slice(i+1);if(a.some(e=>e.name==n.name))throw new t.CKEditorError("alignment-config-name-already-defined",{option:n,configuredOptions:e});if(n.className){if(a.some(e=>e.className==n.className))throw new t.CKEditorError("alignment-config-classname-already-defined",{option:n,configuredOptions:e})}}),n}const s="alignment";class c extends e.Command{refresh(){const e=this.editor.locale,n=(0,t.first)(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(n)&&this._canBeAligned(n),this.isEnabled&&n.hasAttribute("alignment")?this.value=n.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,n=t.locale,i=t.model,o=i.document,a=e.value;i.change(e=>{const t=Array.from(o.selection.getSelectedBlocks()).filter(e=>this._canBeAligned(e)),i=t[0].getAttribute("alignment");r(a,n)||i===a||!a?function(e,t){for(const n of e)t.removeAttribute(s,n)}(t,e):function(e,t,n){for(const i of e)t.setAttribute(s,n,i)}(t,e,a)})}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,s)}}class u extends e.Plugin{static get pluginName(){return"AlignmentEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("alignment",{options:o.map(e=>({name:e}))})}init(){const e=this.editor,t=e.locale,n=e.model.schema,i=l(e.config.get("alignment.options")).filter(e=>a(e.name)&&!r(e.name,t)),o=i.some(e=>!!e.className);n.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),o?e.conversion.attributeToAttribute(function(e){const t={};for(const n of e)t[n.name]={key:"class",value:n.className};const n={model:{key:"alignment",values:e.map(e=>e.name)},view:t};return n}(i)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={};for(const{name:n}of e)t[n]={key:"style",value:{"text-align":n}};const n={model:{key:"alignment",values:e.map(e=>e.name)},view:t};return n}(i));const s=function(e){const t=[];for(const{name:n}of e)t.push({view:{key:"style",value:{"text-align":n}},model:{key:"alignment",value:n}});return t}(i);for(const t of s)e.conversion.for("upcast").attributeToAttribute(t);const u=function(e){const t=[];for(const{name:n}of e)t.push({view:{key:"align",value:n},model:{key:"alignment",value:n}});return t}(i);for(const t of u)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new c(e))}}var g=n(311),d=n(355);const m=(()=>new Map([["left",d.IconAlignLeft],["right",d.IconAlignRight],["center",d.IconAlignCenter],["justify",d.IconAlignJustify]]))();class f extends e.Plugin{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}static get isOfficialPlugin(){return!0}init(){const e=l(this.editor.config.get("alignment.options"));e.map(e=>e.name).filter(a).forEach(e=>this._addButton(e)),this._addToolbarDropdown(e),this._addMenuBarMenu(e)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,t=>this._createButton(t,e))}_createButton(e,t,n={}){const i=this.editor,o=i.commands.get("alignment"),a=new g.ButtonView(e);return a.set({label:this.localizedOptionTitles[t],icon:m.get(t),tooltip:!0,isToggleable:!0,...n}),a.bind("isEnabled").to(o),a.bind("isOn").to(o,"value",e=>e===t),this.listenTo(a,"execute",()=>{i.execute("alignment",{value:t}),i.editing.view.focus()}),a}_addToolbarDropdown(e){const t=this.editor;t.ui.componentFactory.add("alignment",n=>{const i=(0,g.createDropdown)(n),o="rtl"===n.uiLanguageDirection?"w":"e",a=n.t;(0,g.addToolbarToDropdown)(i,()=>e.map(e=>this._createButton(n,e.name,{tooltipPosition:o})),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:a("Text alignment toolbar")}),i.buttonView.set({label:a("Text alignment"),tooltip:!0}),i.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===n.contentLanguageDirection?m.get("right"):m.get("left"),l=t.commands.get("alignment");return i.buttonView.bind("icon").to(l,"value",e=>m.get(e)||r),i.bind("isEnabled").to(l,"isEnabled"),this.listenTo(i,"execute",()=>{t.editing.view.focus()}),i})}_addMenuBarMenu(e){const t=this.editor;t.ui.componentFactory.add("menuBar:alignment",n=>{const i=t.commands.get("alignment"),o=n.t,a=new g.MenuBarMenuView(n),r=new g.MenuBarMenuListView(n);a.bind("isEnabled").to(i),r.set({ariaLabel:o("Text alignment"),role:"menu"}),a.buttonView.set({label:o("Text alignment")});for(const o of e){const e=new g.MenuBarMenuListItemView(n,a),l=new g.MenuBarMenuListItemButtonView(n);l.delegate("execute").to(a),l.set({label:this.localizedOptionTitles[o.name],icon:m.get(o.name),role:"menuitemcheckbox",isToggleable:!0}),l.on("execute",()=>{t.execute("alignment",{value:o.name}),t.editing.view.focus()}),l.bind("isOn").to(i,"value",e=>e===o.name),l.bind("isEnabled").to(i,"isEnabled"),e.children.add(l),r.items.add(e)}return a.panelView.children.add(r),a})}}class p extends e.Plugin{static get requires(){return[u,f]}static get pluginName(){return"Alignment"}static get isOfficialPlugin(){return!0}}})(),(window.CKEditor5=window.CKEditor5||{}).alignment=i})();
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
!function(t){const e=t.en=t.en||{};e.dictionary=Object.assign(e.dictionary||{},{"Revert autoformatting action":"Revert autoformatting action"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
/*!
 * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
 * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */(()=>{var t={237:t=>{"use strict";t.exports=CKEditor5.dll},584:(t,e,o)=>{t.exports=o(237)("./src/utils.js")},782:(t,e,o)=>{t.exports=o(237)("./src/core.js")},783:(t,e,o)=>{t.exports=o(237)("./src/engine.js")},834:(t,e,o)=>{t.exports=o(237)("./src/typing.js")}},e={};function o(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},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 i={};(()=>{"use strict";o.r(i),o.d(i,{Autoformat:()=>c,blockAutoformatEditing:()=>r,inlineAutoformatEditing:()=>a});var t=o(782),e=o(834),s=o(783),n=o(584);function r(t,e,o,i){let r,a=null;"function"==typeof i?r=i:(a=t.commands.get(i),r=()=>{t.execute(i)}),t.model.document.on("change:data",(d,c)=>{if(a&&!a.isEnabled||!e.isEnabled)return;const l=(0,n.first)(t.model.document.selection.getRanges());if(!l.isCollapsed)return;if(c.isUndo||!c.isLocal)return;const u=Array.from(t.model.document.differ.getChanges()),g=u[0];if(1!=u.length||"insert"!==g.type||"$text"!=g.name||1!=g.length)return;const h=g.position.parent;if(h.is("element","codeBlock"))return;if(h.is("element","listItem")&&"function"!=typeof i&&!["numberedList","bulletedList","todoList"].includes(i))return;if(a&&!0===a.value)return;const m=h.getChild(0),f=t.model.createRangeOn(m);if(!f.containsRange(l)&&!l.end.isEqual(f.end))return;const p=o.exec(m.data.substr(0,l.end.offset));p&&t.model.enqueueChange(e=>{const o=t.model.document.selection,i=e.createPositionAt(h,0),n=e.createPositionAt(h,p[0].length),a=new s.ModelLiveRange(i,n);if(!1!==r({match:p})){const t=Array.from(o.getAttributes());e.remove(a);const i=o.getFirstRange(),n=e.createRangeIn(h);!h.isEmpty||n.isEqual(i)||n.containsRange(i,!0)||e.remove(h),function(t,e,o){const i=t.model.schema,n=e.getFirstPosition();let r=new s.ModelSchemaContext(n);i.checkChild(r,"$text")&&(r=r.push("$text"));for(const[e,s]of o)i.checkAttribute(r,e)&&t.setSelectionAttribute(e,s)}(e,o,t)}a.detach(),t.model.enqueueChange(()=>{t.plugins.get("Delete").requestUndoOnBackspace()})})})}function a(t,e,o,i){let s,n;o instanceof RegExp?s=o:n=o,n=n||(t=>{let e;const o=[],i=[];for(;null!==(e=s.exec(t))&&!(e&&e.length<4);){let{index:t,1:s,2:n,3:r}=e;const a=s+n+r;t+=e[0].length-a.length;const d=[t,t+s.length],c=[t+s.length+n.length,t+s.length+n.length+r.length];o.push(d),o.push(c),i.push([t+s.length,t+s.length+n.length])}return{remove:o,format:i}}),t.model.document.on("change:data",(o,s)=>{if(s.isUndo||!s.isLocal||!e.isEnabled)return;const r=t.model,a=r.document.selection;if(!a.isCollapsed)return;const c=Array.from(r.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const u=a.focus,g=u.parent,{text:h,range:m}=function(t,e){let o=t.start;const i=Array.from(t.getItems()).reduce((t,i)=>!i.is("$text")&&!i.is("$textProxy")||i.getAttribute("code")?(o=e.createPositionAfter(i),""):t+i.data,"");return{text:i,range:e.createRange(o,t.end)}}(r.createRange(r.createPositionAt(g,0),u),r),f=n(h),p=d(m.start,f.format,r),b=d(m.start,f.remove,r);p.length&&b.length&&r.enqueueChange(e=>{if(!1!==i(e,p)){for(const t of b.reverse())e.remove(t);r.enqueueChange(()=>{t.plugins.get("Delete").requestUndoOnBackspace()})}})})}function d(t,e,o){return e.filter(t=>void 0!==t[0]&&void 0!==t[1]).map(e=>o.createRange(t.getShiftedBy(e[0]),t.getShiftedBy(e[1])))}class c extends t.Plugin{static get requires(){return[e.Delete]}static get pluginName(){return"Autoformat"}static get isOfficialPlugin(){return!0}afterInit(){const t=this.editor,e=this.editor.t;this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats(),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Revert autoformatting action"),keystroke:"Backspace"}]})}_addListAutoformats(){const t=this.editor.commands;t.get("bulletedList")&&r(this.editor,this,/^[*-]\s$/,"bulletedList"),t.get("numberedList")&&r(this.editor,this,/^1[.|)]\s$/,"numberedList"),t.get("todoList")&&r(this.editor,this,/^\[\s?\]\s$/,"todoList"),t.get("checkTodoList")&&r(this.editor,this,/^\[\s?x\s?\]\s$/,()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")})}_addBasicStylesAutoformats(){const t=this.editor.commands;if(t.get("bold")){const t=l(this.editor,"bold");a(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),a(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(t.get("italic")){const t=l(this.editor,"italic");a(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),a(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(t.get("code")){const t=l(this.editor,"code");a(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(t.get("strikethrough")){const t=l(this.editor,"strikethrough");a(this.editor,this,/(~~)([^~]+)(~~)$/g,t)}}_addHeadingAutoformats(){const t=this.editor.commands.get("heading");t&&t.modelElements.filter(t=>t.match(/^heading[1-6]$/)).forEach(e=>{const o=e[7],i=new RegExp(`^(#{${o}})\\s$`);r(this.editor,this,i,()=>{if(!t.isEnabled||t.value===e)return!1;this.editor.execute("heading",{value:e})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&r(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const t=this.editor,e=t.model.document.selection;t.commands.get("codeBlock")&&r(t,this,/^```$/,()=>{if(e.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})})}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&r(this.editor,this,/^---$/,"horizontalLine")}}function l(t,e){return(o,i)=>{if(!t.commands.get(e).isEnabled)return!1;const s=t.model.schema.getValidRanges(i,e);for(const t of s)o.setAttribute(e,!0,t);o.removeSelectionAttribute(e)}}})(),(window.CKEditor5=window.CKEditor5||{}).autoformat=i})();
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
!function(t){const e=t.en=t.en||{};e.dictionary=Object.assign(e.dictionary||{},{"Saving changes":"Saving changes"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
/*!
 * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
 * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */(()=>{var t={203:(t,e,i)=>{t.exports=i(237)("./src/utils.js")},237:t=>{"use strict";t.exports=CKEditor5.dll},782:(t,e,i)=>{t.exports=i(237)("./src/core.js")}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var o=e[s]={exports:{}};return t[s](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};(()=>{"use strict";i.r(s),i.d(s,{Autosave:()=>o});var t=i(782),e=i(203);function n(t,e,{signal:i,edges:s}={}){let n,o=null;const a=null!=s&&s.includes("leading"),r=null==s||s.includes("trailing"),l=()=>{null!==o&&(t.apply(n,o),n=void 0,o=null)};let c=null;const d=()=>{null!=c&&clearTimeout(c),c=setTimeout(()=>{c=null,r&&l(),h()},e)},u=()=>{null!==c&&(clearTimeout(c),c=null)},h=()=>{u(),n=void 0,o=null},m=function(...t){if(i?.aborted)return;n=this,o=t;const e=null==c;d(),a&&e&&l()};return m.schedule=d,m.cancel=h,m.flush=()=>{u(),l()},i?.addEventListener("abort",h,{once:!0}),m}class o extends t.Plugin{adapter;_debouncedSave;_lastDocumentVersion;_savePromise;_domEmitter;_config;_pendingActions;_makeImmediateSave;_action=null;static get pluginName(){return"Autosave"}static get isOfficialPlugin(){return!0}static get requires(){return[t.PendingActions]}constructor(i){super(i);const s=i.config.get("autosave")||{},o=s.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=function(t,e=0,i={}){"object"!=typeof i&&(i={});const{leading:s=!1,trailing:o=!0,maxWait:a}=i,r=Array(2);let l;s&&(r[0]="leading"),o&&(r[1]="trailing");let c=null;const d=n(function(...e){l=t.apply(this,e),c=null},e,{edges:r}),u=function(...e){return null!=a&&(null===c&&(c=Date.now()),Date.now()-c>=a)?(l=t.apply(this,e),c=Date.now(),d.cancel(),d.schedule(),l):(d.apply(this,e),l)};return u.cancel=d.cancel,u.flush=()=>(d.flush(),l),u}(this._save.bind(this),o),this._lastDocumentVersion=i.model.document.version,this._savePromise=null,this._domEmitter=new((0,e.DomEmitterMixin)()),this._config=s,this._pendingActions=i.plugins.get(t.PendingActions),this._makeImmediateSave=!1}init(){const t=this.editor,e=t.model.document;this.listenTo(t,"ready",()=>{this.listenTo(e,"change:data",(t,e)=>{this._saveCallbacks.length&&e.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"waiting"===this.state&&this._debouncedSave())})}),this.listenTo(t,"destroy",()=>this._flush(),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",(t,e)=>{this._pendingActions.hasAny&&(e.returnValue=this._pendingActions.first.message)})}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){return this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){return this._savePromise?(this._makeImmediateSave=this.editor.model.document.version>this._lastDocumentVersion,this._savePromise):(this._setPendingAction(),this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,this._savePromise=Promise.resolve().then(()=>Promise.all(this._saveCallbacks.map(t=>t(this.editor)))).finally(()=>{this._savePromise=null}).then(()=>{if(this._makeImmediateSave)return this._makeImmediateSave=!1,this._save();this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)}).catch(t=>{throw this.state="error",this.state="saving",this._debouncedSave(),t}),this._savePromise)}_setPendingAction(){const t=this.editor.t;this._action||(this._action=this._pendingActions.add(t("Saving changes")))}get _saveCallbacks(){const t=[];return this.adapter&&this.adapter.save&&t.push(this.adapter.save),this._config.save&&t.push(this._config.save),t}}})(),(window.CKEditor5=window.CKEditor5||{}).autosave=s})();
 No newline at end of file
+2 −2

File changed.

Preview size limit exceeded, changes collapsed.

Loading