@ckeditor/ckeditor5-editor-multi-root 37.0.0-alpha.1 → 37.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md.
4
- */(()=>{var t={704:(t,e,o)=>{t.exports=o(79)("./src/core.js")},492:(t,e,o)=>{t.exports=o(79)("./src/engine.js")},273:(t,e,o)=>{t.exports=o(79)("./src/ui.js")},209:(t,e,o)=>{t.exports=o(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function o(i){var r=e[i];if(void 0!==r)return r.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,{MultiRootEditor:()=>R});var t=o(704),e=o(209),r=o(273),n=o(492);class s extends r.EditorUI{constructor(t,e){super(t),this.view=e}init(){const t=this.view,e=this.editor.editing.view;let o;for(const e of Object.keys(t.editables))t.editables[e].name=e;t.render(),this.focusTracker.on("change:focusedElement",((t,e,i)=>{for(const t of Object.values(this.view.editables))i===t.element&&(o=t.element)})),this.focusTracker.on("change:isFocused",((t,e,i)=>{i||(o=null)}));for(const t of Object.values(this.view.editables)){const i=t.element;this.setEditableElement(t.name,i),t.bind("isFocused").to(this.focusTracker,"isFocused",this.focusTracker,"focusedElement",((t,e)=>!!t&&(e===i||o===i))),e.attachDomRoot(i,t.name)}this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const t=this.view,e=this.editor.editing.view;for(const t of Object.values(this.view.editables))e.detachDomRoot(t.name);t.destroy()}_initToolbar(){const t=this.editor,e=this.view;e.toolbar.fillFromConfig(t.config.get("toolbar"),this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const t=this.editor,e=t.editing.view,o=t.config.get("placeholder");if(o)for(const t of Object.values(this.view.editables)){const i=e.document.getRoot(t.name),r="string"==typeof o?o:null==o?void 0:o[t.name];r&&(0,n.enablePlaceholder)({view:e,element:i,text:r,isDirectHost:!1,keepOnFocus:!0})}}}class c extends r.EditorUIView{constructor(t,e,o,i={}){var n;super(t);const s=t.t;this.toolbar=new r.ToolbarView(t,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editables={};for(const c of o){const o=new r.InlineEditableUIView(t,e,null===(n=i.editableElements)||void 0===n?void 0:n[c],{label:t=>s("Rich Text Editor. Editing area: %0",t.name)});this.editables[c]=o}this.editable=Object.values(this.editables)[0],this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}render(){super.render(),this.registerChild(Object.values(this.editables)),this.registerChild([this.toolbar])}}const l=function(t){return null!=t&&"object"==typeof t};const a="object"==typeof global&&global&&global.Object===Object&&global;var u="object"==typeof self&&self&&self.Object===Object&&self;const d=(a||u||Function("return this")()).Symbol;var h=Object.prototype,f=h.hasOwnProperty,b=h.toString,g=d?d.toStringTag:void 0;const v=function(t){var e=f.call(t,g),o=t[g];try{t[g]=void 0;var i=!0}catch(t){}var r=b.call(t);return i&&(e?t[g]=o:delete t[g]),r};var p=Object.prototype.toString;const m=function(t){return p.call(t)};var y="[object Null]",j="[object Undefined]",w=d?d.toStringTag:void 0;const O=function(t){return null==t?void 0===t?j:y:w&&w in Object(t)?v(t):m(t)};const E=function(t,e){return function(o){return t(e(o))}}(Object.getPrototypeOf,Object);var T="[object Object]",x=Function.prototype,D=Object.prototype,F=x.toString,S=D.hasOwnProperty,P=F.call(Object);const k=function(t){if(!l(t)||O(t)!=T)return!1;var e=E(t);if(null===e)return!0;var o=S.call(e,"constructor")&&e.constructor;return"function"==typeof o&&o instanceof o&&F.call(o)==P};const C=function(t){return l(t)&&1===t.nodeType&&!k(t)};class R extends((0,t.DataApiMixin)(t.Editor)){constructor(o,i={}){const r=Object.keys(o),n=0===r.length||"string"==typeof o[r[0]];if(n&&void 0!==i.initialData)throw new e.CKEditorError("editor-create-initial-data",null);if(super(i),n||(this.sourceElements=o),void 0===this.config.get("initialData")){const t={};for(const i of r)t[i]=_(l=o[i])?(0,e.getDataFromElement)(l):l;this.config.set("initialData",t)}var l;if(!n)for(const e of r)(0,t.secureSourceElement)(this,o[e]);for(const t of r)this.model.document.createRoot("$root",t);const a={shouldToolbarGroupWhenFull:!this.config.get("toolbar.shouldNotGroupWhenFull"),editableElements:n?void 0:o},u=new c(this.locale,this.editing.view,r,a);this.ui=new s(this,u)}destroy(){const t=this.config.get("updateSourceElementOnDestroy"),o={};if(this.sourceElements)for(const e of Object.keys(this.sourceElements))o[e]=t?this.getData({rootName:e}):"";return this.ui.destroy(),super.destroy().then((()=>{if(this.sourceElements)for(const t of Object.keys(this.sourceElements))(0,e.setDataInElement)(this.sourceElements[t],o[t])}))}static create(t,o={}){return new Promise((i=>{for(const o of Object.values(t))if(_(o)&&"TEXTAREA"===o.tagName)throw new e.CKEditorError("editor-wrong-element",null);const r=new this(t,o);i(r.initPlugins().then((()=>r.ui.init())).then((()=>r.data.init(r.config.get("initialData")))).then((()=>r.fire("ready"))).then((()=>r)))}))}}function _(t){return C(t)}})(),(window.CKEditor5=window.CKEditor5||{}).editorMultiRoot=i})();
4
+ */(()=>{var t={704:(t,e,o)=>{t.exports=o(79)("./src/core.js")},492:(t,e,o)=>{t.exports=o(79)("./src/engine.js")},273:(t,e,o)=>{t.exports=o(79)("./src/ui.js")},209:(t,e,o)=>{t.exports=o(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function o(i){var r=e[i];if(void 0!==r)return r.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,{MultiRootEditor:()=>R});var t=o(704),e=o(209),r=o(273),n=o(492);class s extends r.EditorUI{constructor(t,e){super(t),this.view=e}init(){const t=this.view,e=this.editor.editing.view;let o;for(const e of Object.keys(t.editables))t.editables[e].name=e;t.render(),this.focusTracker.on("change:focusedElement",((t,e,i)=>{for(const t of Object.values(this.view.editables))i===t.element&&(o=t.element)})),this.focusTracker.on("change:isFocused",((t,e,i)=>{i||(o=null)}));for(const t of Object.values(this.view.editables)){const i=t.element;this.setEditableElement(t.name,i),t.bind("isFocused").to(this.focusTracker,"isFocused",this.focusTracker,"focusedElement",((t,e)=>!!t&&(e===i||o===i))),e.attachDomRoot(i,t.name)}this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const t=this.view,e=this.editor.editing.view;for(const t of Object.values(this.view.editables))e.detachDomRoot(t.name);t.destroy()}_initToolbar(){const t=this.editor,e=this.view;e.toolbar.fillFromConfig(t.config.get("toolbar"),this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const t=this.editor,e=t.editing.view,o=t.config.get("placeholder");if(o)for(const t of Object.values(this.view.editables)){const i=e.document.getRoot(t.name),r="string"==typeof o?o:o[t.name];r&&(0,n.enablePlaceholder)({view:e,element:i,text:r,isDirectHost:!1,keepOnFocus:!0})}}}class c extends r.EditorUIView{constructor(t,e,o,i={}){super(t);const n=t.t;this.toolbar=new r.ToolbarView(t,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editables={};for(const s of o){const o=new r.InlineEditableUIView(t,e,i.editableElements?i.editableElements[s]:void 0,{label:t=>n("Rich Text Editor. Editing area: %0",t.name)});this.editables[s]=o}this.editable=Object.values(this.editables)[0],this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}render(){super.render(),this.registerChild(Object.values(this.editables)),this.registerChild([this.toolbar])}}const l=function(t){return null!=t&&"object"==typeof t};const a="object"==typeof global&&global&&global.Object===Object&&global;var u="object"==typeof self&&self&&self.Object===Object&&self;const d=(a||u||Function("return this")()).Symbol;var h=Object.prototype,f=h.hasOwnProperty,b=h.toString,g=d?d.toStringTag:void 0;const p=function(t){var e=f.call(t,g),o=t[g];try{t[g]=void 0;var i=!0}catch(t){}var r=b.call(t);return i&&(e?t[g]=o:delete t[g]),r};var v=Object.prototype.toString;const m=function(t){return v.call(t)};var y="[object Null]",j="[object Undefined]",w=d?d.toStringTag:void 0;const E=function(t){return null==t?void 0===t?j:y:w&&w in Object(t)?p(t):m(t)};const O=function(t,e){return function(o){return t(e(o))}}(Object.getPrototypeOf,Object);var T="[object Object]",x=Function.prototype,D=Object.prototype,F=x.toString,S=D.hasOwnProperty,P=F.call(Object);const k=function(t){if(!l(t)||E(t)!=T)return!1;var e=O(t);if(null===e)return!0;var o=S.call(e,"constructor")&&e.constructor;return"function"==typeof o&&o instanceof o&&F.call(o)==P};const C=function(t){return l(t)&&1===t.nodeType&&!k(t)};class R extends((0,t.DataApiMixin)(t.Editor)){constructor(o,i={}){const r=Object.keys(o),n=0===r.length||"string"==typeof o[r[0]];if(n&&void 0!==i.initialData)throw new e.CKEditorError("editor-create-initial-data",null);if(super(i),n||(this.sourceElements=o),void 0===this.config.get("initialData")){const t={};for(const i of r)t[i]=_(l=o[i])?(0,e.getDataFromElement)(l):l;this.config.set("initialData",t)}var l;if(!n)for(const e of r)(0,t.secureSourceElement)(this,o[e]);for(const t of r)this.model.document.createRoot("$root",t);const a={shouldToolbarGroupWhenFull:!this.config.get("toolbar.shouldNotGroupWhenFull"),editableElements:n?void 0:o},u=new c(this.locale,this.editing.view,r,a);this.ui=new s(this,u)}destroy(){const t=this.config.get("updateSourceElementOnDestroy"),o={};if(this.sourceElements)for(const e of Object.keys(this.sourceElements))o[e]=t?this.getData({rootName:e}):"";return this.ui.destroy(),super.destroy().then((()=>{if(this.sourceElements)for(const t of Object.keys(this.sourceElements))(0,e.setDataInElement)(this.sourceElements[t],o[t])}))}static create(t,o={}){return new Promise((i=>{for(const o of Object.values(t))if(_(o)&&"TEXTAREA"===o.tagName)throw new e.CKEditorError("editor-wrong-element",null);const r=new this(t,o);i(r.initPlugins().then((()=>r.ui.init())).then((()=>r.data.init(r.config.get("initialData")))).then((()=>r.fire("ready"))).then((()=>r)))}))}}function _(t){return C(t)}})(),(window.CKEditor5=window.CKEditor5||{}).editorMultiRoot=i})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-editor-multi-root",
3
- "version": "37.0.0-alpha.1",
3
+ "version": "37.0.0-alpha.2",
4
4
  "description": "Multi-root editor implementation for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -11,22 +11,22 @@
11
11
  ],
12
12
  "main": "src/index.js",
13
13
  "dependencies": {
14
- "ckeditor5": "^37.0.0-alpha.1",
14
+ "ckeditor5": "^37.0.0-alpha.2",
15
15
  "lodash-es": "^4.17.15"
16
16
  },
17
17
  "devDependencies": {
18
- "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.1",
19
- "@ckeditor/ckeditor5-core": "^37.0.0-alpha.1",
18
+ "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.2",
19
+ "@ckeditor/ckeditor5-core": "^37.0.0-alpha.2",
20
20
  "@ckeditor/ckeditor5-dev-utils": "^35.0.0",
21
- "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.1",
22
- "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.1",
23
- "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.1",
24
- "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.1",
25
- "@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.1",
26
- "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.1",
27
- "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.1",
28
- "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.1",
29
- "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.1",
21
+ "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.2",
22
+ "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.2",
23
+ "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.2",
24
+ "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.2",
25
+ "@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.2",
26
+ "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.2",
27
+ "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.2",
28
+ "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.2",
29
+ "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.2",
30
30
  "typescript": "^4.8.4",
31
31
  "webpack": "^5.58.1",
32
32
  "webpack-cli": "^4.9.0"
@@ -128,7 +128,7 @@ export default class MultiRootEditorUI extends EditorUI {
128
128
  }
129
129
  for (const editable of Object.values(this.view.editables)) {
130
130
  const editingRoot = editingView.document.getRoot(editable.name);
131
- const placeholderText = typeof placeholder === 'string' ? placeholder : placeholder === null || placeholder === void 0 ? void 0 : placeholder[editable.name];
131
+ const placeholderText = typeof placeholder === 'string' ? placeholder : placeholder[editable.name];
132
132
  if (placeholderText) {
133
133
  enablePlaceholder({
134
134
  view: editingView,
@@ -32,7 +32,6 @@ export default class MultiRootEditorUIView extends EditorUIView {
32
32
  * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
33
33
  */
34
34
  constructor(locale, editingView, editableNames, options = {}) {
35
- var _a;
36
35
  super(locale);
37
36
  const t = locale.t;
38
37
  this.toolbar = new ToolbarView(locale, {
@@ -41,7 +40,7 @@ export default class MultiRootEditorUIView extends EditorUIView {
41
40
  this.editables = {};
42
41
  // Create `InlineEditableUIView` instance for each editable.
43
42
  for (const editableName of editableNames) {
44
- const editable = new InlineEditableUIView(locale, editingView, (_a = options.editableElements) === null || _a === void 0 ? void 0 : _a[editableName], {
43
+ const editable = new InlineEditableUIView(locale, editingView, options.editableElements ? options.editableElements[editableName] : undefined, {
45
44
  label: editable => {
46
45
  return t('Rich Text Editor. Editing area: %0', editable.name);
47
46
  }