@ckeditor/ckeditor5-editor-decoupled 41.3.0-alpha.3 → 41.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md.
4
- */(()=>{var t={782:(t,e,o)=>{t.exports=o(237)("./src/core.js")},783:(t,e,o)=>{t.exports=o(237)("./src/engine.js")},311:(t,e,o)=>{t.exports=o(237)("./src/ui.js")},584:(t,e,o)=>{t.exports=o(237)("./src/utils.js")},602:(t,e,o)=>{t.exports=o(237)("./src/watchdog.js")},237:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function o(r){var i=e[r];if(void 0!==i)return i.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,o),n.exports}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 r={};(()=>{"use strict";o.r(r),o.d(r,{DecoupledEditor:()=>W});var t=o(782),e=o(584),i=o(602),n=o(311),s=o(783);class c extends n.EditorUI{constructor(t,e){super(t),this.view=e}init(){const t=this.editor,e=this.view,o=t.editing.view,r=e.editable,i=o.document.getRoot();r.name=i.rootName,e.render();const n=r.element;this.setEditableElement(r.name,n),e.editable.bind("isFocused").to(this.focusTracker),o.attachDomRoot(n),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const t=this.view;this.editor.editing.view.detachDomRoot(t.editable.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=e.document.getRoot(),r=t.config.get("placeholder");if(r){const t="string"==typeof r?r:r[o.rootName];t&&(o.placeholder=t)}(0,s.enablePlaceholder)({view:e,element:o,isDirectHost:!1,keepOnFocus:!0})}}class l extends n.EditorUIView{constructor(t,e,o={}){super(t);const r=t.t;this.toolbar=new n.ToolbarView(t,{shouldGroupWhenFull:o.shouldToolbarGroupWhenFull}),this.editable=new n.InlineEditableUIView(t,e,o.editableElement,{label:t=>r("Rich Text Editor. Editing area: %0",t.name)}),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.toolbar,this.editable])}}const a=function(t){return null!=t&&"object"==typeof t};const d="object"==typeof global&&global&&global.Object===Object&&global;var u="object"==typeof self&&self&&self.Object===Object&&self;const h=(d||u||Function("return this")()).Symbol;var b=Object.prototype,p=b.hasOwnProperty,g=b.toString,f=h?h.toStringTag:void 0;const m=function(t){var e=p.call(t,f),o=t[f];try{t[f]=void 0;var r=!0}catch(t){}var i=g.call(t);return r&&(e?t[f]=o:delete t[f]),i};var v=Object.prototype.toString;const y=function(t){return v.call(t)};var w=h?h.toStringTag:void 0;const E=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":w&&w in Object(t)?m(t):y(t)};const j=function(t,e){return function(o){return t(e(o))}}(Object.getPrototypeOf,Object);var O=Function.prototype,x=Object.prototype,T=O.toString,S=x.hasOwnProperty,D=T.call(Object);const P=function(t){if(!a(t)||"[object Object]"!=E(t))return!1;var e=j(t);if(null===e)return!0;var o=S.call(e,"constructor")&&e.constructor;return"function"==typeof o&&o instanceof o&&T.call(o)==D};const C=function(t){return a(t)&&1===t.nodeType&&!P(t)};class F extends((0,t.ElementApiMixin)(t.Editor)){constructor(o,r={}){if(!R(o)&&void 0!==r.initialData)throw new e.CKEditorError("editor-create-initial-data",null);super(r),void 0===this.config.get("initialData")&&this.config.set("initialData",function(t){return R(t)?(0,e.getDataFromElement)(t):t}(o)),R(o)&&(this.sourceElement=o,(0,t.secureSourceElement)(this,o)),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new l(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:i});this.ui=new c(this,n)}destroy(){const t=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&this.updateSourceElement(t)}))}static create(t,o={}){return new Promise((r=>{if(R(t)&&"TEXTAREA"===t.tagName)throw new e.CKEditorError("editor-wrong-element",null);const i=new this(t,o);r(i.initPlugins().then((()=>i.ui.init())).then((()=>i.data.init(i.config.get("initialData")))).then((()=>i.fire("ready"))).then((()=>i)))}))}}F.Context=t.Context,F.EditorWatchdog=i.EditorWatchdog,F.ContextWatchdog=i.ContextWatchdog;const W=F;function R(t){return C(t)}})(),(window.CKEditor5=window.CKEditor5||{}).editorDecoupled=r})();
4
+ */(()=>{var t={782:(t,e,o)=>{t.exports=o(237)("./src/core.js")},783:(t,e,o)=>{t.exports=o(237)("./src/engine.js")},311:(t,e,o)=>{t.exports=o(237)("./src/ui.js")},584:(t,e,o)=>{t.exports=o(237)("./src/utils.js")},602:(t,e,o)=>{t.exports=o(237)("./src/watchdog.js")},237: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,{DecoupledEditor:()=>P});var t=o(782),e=o(584),r=o(602),n=o(311),s=o(783);class c extends n.EditorUI{constructor(t,e){super(t),this.view=e}init(){const t=this.editor,e=this.view,o=t.editing.view,i=e.editable,r=o.document.getRoot();i.name=r.rootName,e.render();const n=i.element;this.setEditableElement(i.name,n),e.editable.bind("isFocused").to(this.focusTracker),o.attachDomRoot(n),this._initPlaceholder(),this._initToolbar(),this._initMenuBar(),this.fire("ready")}destroy(){super.destroy();const t=this.view;this.editor.editing.view.detachDomRoot(t.editable.name),t.destroy()}_initToolbar(){const t=this.editor,e=this.view;e.toolbar.fillFromConfig(t.config.get("toolbar"),this.componentFactory),this.addToolbar(e.toolbar)}_initMenuBar(){const t=this.editor,e=this.view.menuBarView.element,o=this.view;this.focusTracker.add(e),t.keystrokes.listenTo(e);const i=(0,n.normalizeMenuBarConfig)(t.config.get("menuBar")||{});o.menuBarView.fillFromConfig(i,this.componentFactory),t.keystrokes.set("Esc",((o,i)=>{e.contains(this.focusTracker.focusedElement)&&(t.editing.view.focus(),i())})),t.keystrokes.set("Alt+F9",((t,o)=>{e.contains(this.focusTracker.focusedElement)||(this.view.menuBarView.focus(),o())}))}_initPlaceholder(){const t=this.editor,e=t.editing.view,o=e.document.getRoot(),i=t.config.get("placeholder");if(i){const t="string"==typeof i?i:i[o.rootName];t&&(o.placeholder=t)}(0,s.enablePlaceholder)({view:e,element:o,isDirectHost:!1,keepOnFocus:!0})}}class a extends n.EditorUIView{constructor(t,e,o={}){super(t);const i=t.t;this.toolbar=new n.ToolbarView(t,{shouldGroupWhenFull:o.shouldToolbarGroupWhenFull}),this.menuBarView=new n.MenuBarView(t),this.editable=new n.InlineEditableUIView(t,e,o.editableElement,{label:t=>i("Rich Text Editor. Editing area: %0",t.name)}),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}}),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.menuBarView,this.toolbar,this.editable])}}const l=function(t){return null!=t&&"object"==typeof t};const u="object"==typeof global&&global&&global.Object===Object&&global;var d="object"==typeof self&&self&&self.Object===Object&&self;const h=(u||d||Function("return this")()).Symbol;var b=Object.prototype,f=b.hasOwnProperty,g=b.toString,p=h?h.toStringTag:void 0;const m=function(t){var e=f.call(t,p),o=t[p];try{t[p]=void 0;var i=!0}catch(t){}var r=g.call(t);return i&&(e?t[p]=o:delete t[p]),r};var w=Object.prototype.toString;const v=function(t){return w.call(t)};var y=h?h.toStringTag:void 0;const E=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":y&&y in Object(t)?m(t):v(t)};const j=function(t,e){return function(o){return t(e(o))}}(Object.getPrototypeOf,Object);var x=Function.prototype,O=Object.prototype,T=x.toString,k=O.hasOwnProperty,F=T.call(Object);const C=function(t){if(!l(t)||"[object Object]"!=E(t))return!1;var e=j(t);if(null===e)return!0;var o=k.call(e,"constructor")&&e.constructor;return"function"==typeof o&&o instanceof o&&T.call(o)==F};const D=function(t){return l(t)&&1===t.nodeType&&!C(t)};class S extends((0,t.ElementApiMixin)(t.Editor)){constructor(o,i={}){if(!B(o)&&void 0!==i.initialData)throw new e.CKEditorError("editor-create-initial-data",null);super(i),void 0===this.config.get("initialData")&&this.config.set("initialData",function(t){return B(t)?(0,e.getDataFromElement)(t):t}(o)),B(o)&&(this.sourceElement=o,(0,t.secureSourceElement)(this,o)),this.model.document.createRoot();const r=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new a(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:r});this.ui=new c(this,n)}destroy(){const t=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&this.updateSourceElement(t)}))}static create(t,o={}){return new Promise((i=>{if(B(t)&&"TEXTAREA"===t.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)))}))}}S.Context=t.Context,S.EditorWatchdog=r.EditorWatchdog,S.ContextWatchdog=r.ContextWatchdog;const P=S;function B(t){return D(t)}})(),(window.CKEditor5=window.CKEditor5||{}).editorDecoupled=i})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-editor-decoupled",
3
- "version": "41.3.0-alpha.3",
3
+ "version": "41.3.0",
4
4
  "description": "Decoupled editor implementation for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,7 +12,7 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "41.3.0-alpha.3",
15
+ "ckeditor5": "41.3.0",
16
16
  "lodash-es": "4.17.21"
17
17
  },
18
18
  "author": "CKSource (http://cksource.com/)",
@@ -25,7 +25,6 @@
25
25
  "directory": "packages/ckeditor5-editor-decoupled"
26
26
  },
27
27
  "files": [
28
- "dist",
29
28
  "lang",
30
29
  "src/**/*.js",
31
30
  "src/**/*.d.ts",
@@ -23,7 +23,8 @@ declare const DecoupledEditor_base: import("ckeditor5/src/utils.js").Mixed<typeo
23
23
  * In order to create a decoupled editor instance, use the static
24
24
  * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
25
25
  *
26
- * Note that you will need to attach the editor toolbar to your web page manually, in a desired place, after the editor is initialized.
26
+ * Note that you will need to attach the editor toolbar and menu bar to your web page manually, in a desired place,
27
+ * after the editor is initialized.
27
28
  *
28
29
  * # Decoupled editor and document editor build
29
30
  *
@@ -25,7 +25,8 @@ import { isElement as _isElement } from 'lodash-es';
25
25
  * In order to create a decoupled editor instance, use the static
26
26
  * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
27
27
  *
28
- * Note that you will need to attach the editor toolbar to your web page manually, in a desired place, after the editor is initialized.
28
+ * Note that you will need to attach the editor toolbar and menu bar to your web page manually, in a desired place,
29
+ * after the editor is initialized.
29
30
  *
30
31
  * # Decoupled editor and document editor build
31
32
  *
@@ -35,6 +35,10 @@ export default class DecoupledEditorUI extends EditorUI {
35
35
  * Initializes the inline editor toolbar and its panel.
36
36
  */
37
37
  private _initToolbar;
38
+ /**
39
+ * Initializes the editor menu bar.
40
+ */
41
+ private _initMenuBar;
38
42
  /**
39
43
  * Enable the placeholder text on the editing root.
40
44
  */
@@ -2,7 +2,7 @@
2
2
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import { EditorUI } from 'ckeditor5/src/ui.js';
5
+ import { EditorUI, normalizeMenuBarConfig } from 'ckeditor5/src/ui.js';
6
6
  import { enablePlaceholder } from 'ckeditor5/src/engine.js';
7
7
  /**
8
8
  * The decoupled editor UI class.
@@ -50,6 +50,7 @@ export default class DecoupledEditorUI extends EditorUI {
50
50
  editingView.attachDomRoot(editableElement);
51
51
  this._initPlaceholder();
52
52
  this._initToolbar();
53
+ this._initMenuBar();
53
54
  this.fire('ready');
54
55
  }
55
56
  /**
@@ -73,6 +74,30 @@ export default class DecoupledEditorUI extends EditorUI {
73
74
  // Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
74
75
  this.addToolbar(view.toolbar);
75
76
  }
77
+ /**
78
+ * Initializes the editor menu bar.
79
+ */
80
+ _initMenuBar() {
81
+ const editor = this.editor;
82
+ const menuBarViewElement = this.view.menuBarView.element;
83
+ const view = this.view;
84
+ this.focusTracker.add(menuBarViewElement);
85
+ editor.keystrokes.listenTo(menuBarViewElement);
86
+ const normalizedMenuBarConfig = normalizeMenuBarConfig(editor.config.get('menuBar') || {});
87
+ view.menuBarView.fillFromConfig(normalizedMenuBarConfig, this.componentFactory);
88
+ editor.keystrokes.set('Esc', (data, cancel) => {
89
+ if (menuBarViewElement.contains(this.focusTracker.focusedElement)) {
90
+ editor.editing.view.focus();
91
+ cancel();
92
+ }
93
+ });
94
+ editor.keystrokes.set('Alt+F9', (data, cancel) => {
95
+ if (!menuBarViewElement.contains(this.focusTracker.focusedElement)) {
96
+ this.view.menuBarView.focus();
97
+ cancel();
98
+ }
99
+ });
100
+ }
76
101
  /**
77
102
  * Enable the placeholder text on the editing root.
78
103
  */
@@ -5,13 +5,14 @@
5
5
  /**
6
6
  * @module editor-decoupled/decouplededitoruiview
7
7
  */
8
- import { EditorUIView, InlineEditableUIView, ToolbarView } from 'ckeditor5/src/ui.js';
8
+ import { EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from 'ckeditor5/src/ui.js';
9
9
  import type { Locale } from 'ckeditor5/src/utils.js';
10
10
  import type { EditingView } from 'ckeditor5/src/engine.js';
11
11
  /**
12
12
  * The decoupled editor UI view. It is a virtual view providing an inline
13
- * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#editable} and a
14
- * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar}, but without any
13
+ * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#editable},
14
+ * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar}, and a
15
+ * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#menuBarView} but without any
15
16
  * specific arrangement of the components in the DOM.
16
17
  *
17
18
  * See {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
@@ -22,6 +23,10 @@ export default class DecoupledEditorUIView extends EditorUIView {
22
23
  * The main toolbar of the decoupled editor UI.
23
24
  */
24
25
  readonly toolbar: ToolbarView;
26
+ /**
27
+ * Menu bar view instance.
28
+ */
29
+ readonly menuBarView: MenuBarView;
25
30
  /**
26
31
  * The editable of the decoupled editor UI.
27
32
  */
@@ -5,11 +5,12 @@
5
5
  /**
6
6
  * @module editor-decoupled/decouplededitoruiview
7
7
  */
8
- import { EditorUIView, InlineEditableUIView, ToolbarView } from 'ckeditor5/src/ui.js';
8
+ import { EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from 'ckeditor5/src/ui.js';
9
9
  /**
10
10
  * The decoupled editor UI view. It is a virtual view providing an inline
11
- * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#editable} and a
12
- * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar}, but without any
11
+ * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#editable},
12
+ * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar}, and a
13
+ * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#menuBarView} but without any
13
14
  * specific arrangement of the components in the DOM.
14
15
  *
15
16
  * See {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
@@ -34,6 +35,7 @@ export default class DecoupledEditorUIView extends EditorUIView {
34
35
  this.toolbar = new ToolbarView(locale, {
35
36
  shouldGroupWhenFull: options.shouldToolbarGroupWhenFull
36
37
  });
38
+ this.menuBarView = new MenuBarView(locale);
37
39
  this.editable = new InlineEditableUIView(locale, editingView, options.editableElement, {
38
40
  label: editableView => {
39
41
  return t('Rich Text Editor. Editing area: %0', editableView.name);
@@ -52,12 +54,21 @@ export default class DecoupledEditorUIView extends EditorUIView {
52
54
  dir: locale.uiLanguageDirection
53
55
  }
54
56
  });
57
+ this.menuBarView.extendTemplate({
58
+ attributes: {
59
+ class: [
60
+ 'ck-reset_all',
61
+ 'ck-rounded-corners'
62
+ ],
63
+ dir: locale.uiLanguageDirection
64
+ }
65
+ });
55
66
  }
56
67
  /**
57
68
  * @inheritDoc
58
69
  */
59
70
  render() {
60
71
  super.render();
61
- this.registerChild([this.toolbar, this.editable]);
72
+ this.registerChild([this.menuBarView, this.toolbar, this.editable]);
62
73
  }
63
74
  }
@@ -1,4 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
@@ -1,4 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
package/dist/index.css DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
@@ -1,219 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module editor-decoupled/decouplededitor
11
- */
12
- import { Editor, Context, type EditorConfig } from 'ckeditor5/src/core.js';
13
- import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog.js';
14
- import DecoupledEditorUI from './decouplededitorui.js';
15
- declare const DecoupledEditor_base: import("ckeditor5/src/utils.js").Mixed<typeof Editor, import("ckeditor5/src/core.js").ElementApi>;
16
- /**
17
- * The {@glink installation/getting-started/predefined-builds#document-editor decoupled editor} implementation.
18
- * It provides an inline editable and a toolbar. However, unlike other editors,
19
- * it does not render these components anywhere in the DOM unless configured.
20
- *
21
- * This type of an editor is dedicated to integrations which require a customized UI with an open
22
- * structure, allowing developers to specify the exact location of the interface.
23
- *
24
- * See the document editor {@glink examples/builds/document-editor demo} to learn about possible use cases
25
- * for the decoupled editor.
26
- *
27
- * In order to create a decoupled editor instance, use the static
28
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
29
- *
30
- * Note that you will need to attach the editor toolbar to your web page manually, in a desired place, after the editor is initialized.
31
- *
32
- * # Decoupled editor and document editor build
33
- *
34
- * The decoupled editor can be used directly from source (if you installed the
35
- * [`@ckeditor/ckeditor5-editor-decoupled`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled) package)
36
- * but it is also available in the
37
- * {@glink installation/getting-started/predefined-builds#document-editor document editor build}.
38
- *
39
- * {@glink installation/getting-started/predefined-builds Builds}
40
- * are ready-to-use editors with plugins bundled in. When using the editor from
41
- * source you need to take care of loading all plugins by yourself
42
- * (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
43
- * Using the editor from source gives much better flexibility and allows for easier customization.
44
- *
45
- * Read more about initializing the editor from source or as a build in
46
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}.
47
- */
48
- export default class DecoupledEditor extends DecoupledEditor_base {
49
- /**
50
- * @inheritDoc
51
- */
52
- readonly ui: DecoupledEditorUI;
53
- /**
54
- * Creates an instance of the decoupled editor.
55
- *
56
- * **Note:** Do not use the constructor to create editor instances. Use the static
57
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method instead.
58
- *
59
- * @param sourceElementOrData The DOM element that will be the source for the created editor
60
- * (on which the editor will be initialized) or initial data for the editor. For more information see
61
- * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}.
62
- * @param config The editor configuration.
63
- */
64
- protected constructor(sourceElementOrData: HTMLElement | string, config?: EditorConfig);
65
- /**
66
- * Destroys the editor instance, releasing all resources used by it.
67
- *
68
- * Updates the original editor element with the data if the
69
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
70
- * configuration option is set to `true`.
71
- *
72
- * **Note**: The decoupled editor does not remove the toolbar and editable when destroyed. You can
73
- * do that yourself in the destruction chain:
74
- *
75
- * ```ts
76
- * editor.destroy()
77
- * .then( () => {
78
- * // Remove the toolbar from DOM.
79
- * editor.ui.view.toolbar.element.remove();
80
- *
81
- * // Remove the editable from DOM.
82
- * editor.ui.view.editable.element.remove();
83
- *
84
- * console.log( 'Editor was destroyed' );
85
- * } );
86
- * ```
87
- */
88
- destroy(): Promise<unknown>;
89
- /**
90
- * Creates a new decoupled editor instance.
91
- *
92
- * **Note:** remember that `DecoupledEditor` does not append the toolbar element to your web page, so you have to do it manually
93
- * after the editor has been initialized.
94
- *
95
- * There are two ways how the editor can be initialized.
96
- *
97
- * # Using an existing DOM element (and loading data from it)
98
- *
99
- * You can initialize the editor using an existing DOM element:
100
- *
101
- * ```ts
102
- * DecoupledEditor
103
- * .create( document.querySelector( '#editor' ) )
104
- * .then( editor => {
105
- * console.log( 'Editor was initialized', editor );
106
- *
107
- * // Append the toolbar to the <body> element.
108
- * document.body.appendChild( editor.ui.view.toolbar.element );
109
- * } )
110
- * .catch( err => {
111
- * console.error( err.stack );
112
- * } );
113
- * ```
114
- *
115
- * The element's content will be used as the editor data and the element will become the editable element.
116
- *
117
- * # Creating a detached editor
118
- *
119
- * Alternatively, you can initialize the editor by passing the initial data directly as a string.
120
- * In this case, you will have to manually append both the toolbar element and the editable element to your web page.
121
- *
122
- * ```ts
123
- * DecoupledEditor
124
- * .create( '<p>Hello world!</p>' )
125
- * .then( editor => {
126
- * console.log( 'Editor was initialized', editor );
127
- *
128
- * // Append the toolbar to the <body> element.
129
- * document.body.appendChild( editor.ui.view.toolbar.element );
130
- *
131
- * // Initial data was provided so the editor UI element needs to be added manually to the DOM.
132
- * document.body.appendChild( editor.ui.getEditableElement() );
133
- * } )
134
- * .catch( err => {
135
- * console.error( err.stack );
136
- * } );
137
- * ```
138
- *
139
- * This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
140
- * web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
141
- *
142
- * # Using an existing DOM element (and data provided in `config.initialData`)
143
- *
144
- * You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
145
- *
146
- * ```ts
147
- * DecoupledEditor
148
- * .create( document.querySelector( '#editor' ), {
149
- * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
150
- * } )
151
- * .then( editor => {
152
- * console.log( 'Editor was initialized', editor );
153
- *
154
- * // Append the toolbar to the <body> element.
155
- * document.body.appendChild( editor.ui.view.toolbar.element );
156
- * } )
157
- * .catch( err => {
158
- * console.error( err.stack );
159
- * } );
160
- * ```
161
- *
162
- * This method can be used to initialize the editor on an existing element with the specified content in case if your integration
163
- * makes it difficult to set the content of the source element.
164
- *
165
- * Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
166
- *
167
- * # Configuring the editor
168
- *
169
- * See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
170
- * customizing plugins, toolbar and more.
171
- *
172
- * # Using the editor from source
173
- *
174
- * The code samples listed in the previous sections of this documentation assume that you are using an
175
- * {@glink installation/getting-started/predefined-builds editor build}
176
- * (for example – `@ckeditor/ckeditor5-build-decoupled`).
177
- *
178
- * If you want to use the decoupled editor from source (`@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor`),
179
- * you need to define the list of
180
- * {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
181
- * {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
182
- * source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
183
- *
184
- * @param sourceElementOrData The DOM element that will be the source for the created editor
185
- * or the editor's initial data.
186
- *
187
- * If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
188
- * The editor data will be set back to the original element once the editor is destroyed only if the
189
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
190
- * option is set to `true`.
191
- *
192
- * If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
193
- * It is available via
194
- * {@link module:editor-decoupled/decouplededitorui~DecoupledEditorUI#getEditableElement `editor.ui.getEditableElement()`}.
195
- *
196
- * @param config The editor configuration.
197
- * @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
198
- */
199
- static create(sourceElementOrData: HTMLElement | string, config?: EditorConfig): Promise<DecoupledEditor>;
200
- /**
201
- * The {@link module:core/context~Context} class.
202
- *
203
- * Exposed as static editor field for easier access in editor builds.
204
- */
205
- static Context: typeof Context;
206
- /**
207
- * The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
208
- *
209
- * Exposed as static editor field for easier access in editor builds.
210
- */
211
- static EditorWatchdog: typeof EditorWatchdog;
212
- /**
213
- * The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
214
- *
215
- * Exposed as static editor field for easier access in editor builds.
216
- */
217
- static ContextWatchdog: typeof ContextWatchdog;
218
- }
219
- export {};
@@ -1,46 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module editor-decoupled/decouplededitorui
11
- */
12
- import { type Editor } from 'ckeditor5/src/core.js';
13
- import { EditorUI } from 'ckeditor5/src/ui.js';
14
- import type DecoupledEditorUIView from './decouplededitoruiview.js';
15
- /**
16
- * The decoupled editor UI class.
17
- */
18
- export default class DecoupledEditorUI extends EditorUI {
19
- /**
20
- * The main (top–most) view of the editor UI.
21
- */
22
- readonly view: DecoupledEditorUIView;
23
- /**
24
- * Creates an instance of the decoupled editor UI class.
25
- *
26
- * @param editor The editor instance.
27
- * @param view The view of the UI.
28
- */
29
- constructor(editor: Editor, view: DecoupledEditorUIView);
30
- /**
31
- * Initializes the UI.
32
- */
33
- init(): void;
34
- /**
35
- * @inheritDoc
36
- */
37
- destroy(): void;
38
- /**
39
- * Initializes the inline editor toolbar and its panel.
40
- */
41
- private _initToolbar;
42
- /**
43
- * Enable the placeholder text on the editing root.
44
- */
45
- private _initPlaceholder;
46
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module editor-decoupled/decouplededitoruiview
11
- */
12
- import { EditorUIView, InlineEditableUIView, ToolbarView } from 'ckeditor5/src/ui.js';
13
- import type { Locale } from 'ckeditor5/src/utils.js';
14
- import type { EditingView } from 'ckeditor5/src/engine.js';
15
- /**
16
- * The decoupled editor UI view. It is a virtual view providing an inline
17
- * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#editable} and a
18
- * {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar}, but without any
19
- * specific arrangement of the components in the DOM.
20
- *
21
- * See {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
22
- * to learn more about this view.
23
- */
24
- export default class DecoupledEditorUIView extends EditorUIView {
25
- /**
26
- * The main toolbar of the decoupled editor UI.
27
- */
28
- readonly toolbar: ToolbarView;
29
- /**
30
- * The editable of the decoupled editor UI.
31
- */
32
- readonly editable: InlineEditableUIView;
33
- /**
34
- * Creates an instance of the decoupled editor UI view.
35
- *
36
- * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
37
- * @param editingView The editing view instance this view is related to.
38
- * @param options Configuration options for the view instance.
39
- * @param options.editableElement The editable element. If not specified, it will be automatically created by
40
- * {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
41
- * @param options.shouldToolbarGroupWhenFull When set `true` enables automatic items grouping
42
- * in the main {@link module:editor-decoupled/decouplededitoruiview~DecoupledEditorUIView#toolbar toolbar}.
43
- * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
44
- */
45
- constructor(locale: Locale, editingView: EditingView, options?: {
46
- editableElement?: HTMLElement;
47
- shouldToolbarGroupWhenFull?: boolean;
48
- });
49
- /**
50
- * @inheritDoc
51
- */
52
- render(): void;
53
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module editor-decoupled
11
- */
12
- export { default as DecoupledEditor } from './decouplededitor.js';