@ckeditor/ckeditor5-editor-inline 47.6.1 → 48.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,26 +1,9 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-editor-inline",
3
- "version": "47.6.1",
3
+ "version": "48.0.0-alpha.1",
4
4
  "description": "Inline editor implementation for CKEditor 5.",
5
- "keywords": [
6
- "ckeditor",
7
- "ckeditor5",
8
- "ckeditor 5",
9
- "ckeditor5-editor",
10
- "ckeditor5-dll"
11
- ],
12
- "type": "module",
13
- "main": "src/index.js",
14
- "dependencies": {
15
- "@ckeditor/ckeditor5-core": "47.6.1",
16
- "@ckeditor/ckeditor5-engine": "47.6.1",
17
- "@ckeditor/ckeditor5-ui": "47.6.1",
18
- "@ckeditor/ckeditor5-utils": "47.6.1",
19
- "ckeditor5": "47.6.1",
20
- "es-toolkit": "1.39.5"
21
- },
22
- "author": "CKSource (http://cksource.com/)",
23
5
  "license": "SEE LICENSE IN LICENSE.md",
6
+ "author": "CKSource (http://cksource.com/)",
24
7
  "homepage": "https://ckeditor.com/ckeditor-5",
25
8
  "bugs": "https://github.com/ckeditor/ckeditor5/issues",
26
9
  "repository": {
@@ -28,34 +11,29 @@
28
11
  "url": "https://github.com/ckeditor/ckeditor5.git",
29
12
  "directory": "packages/ckeditor5-editor-inline"
30
13
  },
14
+ "keywords": [
15
+ "ckeditor",
16
+ "ckeditor5",
17
+ "ckeditor 5",
18
+ "ckeditor5-editor"
19
+ ],
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "exports": {
23
+ ".": "./dist/index.js",
24
+ "./dist/*": "./dist/*",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "dependencies": {
28
+ "@ckeditor/ckeditor5-core": "48.0.0-alpha.1",
29
+ "@ckeditor/ckeditor5-engine": "48.0.0-alpha.1",
30
+ "@ckeditor/ckeditor5-ui": "48.0.0-alpha.1",
31
+ "@ckeditor/ckeditor5-utils": "48.0.0-alpha.1",
32
+ "es-toolkit": "1.45.1"
33
+ },
31
34
  "files": [
32
35
  "dist",
33
- "lang",
34
- "src/**/*.js",
35
- "src/**/*.d.ts",
36
- "theme",
37
- "build",
38
36
  "CHANGELOG.md"
39
37
  ],
40
- "types": "src/index.d.ts",
41
- "exports": {
42
- ".": {
43
- "types": "./src/index.d.ts",
44
- "import": "./src/index.js",
45
- "default": "./src/index.js"
46
- },
47
- "./dist/*": {
48
- "types": "./src/index.d.ts",
49
- "import": "./dist/*",
50
- "default": "./dist/*"
51
- },
52
- "./src/*": {
53
- "types": "./src/*.d.ts",
54
- "import": "./src/*",
55
- "default": "./src/*"
56
- },
57
- "./build/*": "./build/*",
58
- "./theme/*": "./theme/*",
59
- "./package.json": "./package.json"
60
- }
38
+ "types": "./dist/index.d.ts"
61
39
  }
@@ -1,4 +0,0 @@
1
- /*!
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md.
4
- */(()=>{var e={163:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},237:e=>{"use strict";e.exports=CKEditor5.dll},305:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var o="",i=void 0!==t[5];return t[4]&&(o+="@supports (".concat(t[4],") {")),t[2]&&(o+="@media ".concat(t[2]," {")),i&&(o+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),o+=e(t),i&&(o+="}"),t[2]&&(o+="}"),t[4]&&(o+="}"),o}).join("")},t.i=function(e,o,i,r,n){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);i&&s[u[0]]||(void 0!==n&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=n),o&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=o):u[2]=o),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),t.push(u))}},t}},311:(e,t,o)=>{e.exports=o(237)("./src/ui.js")},424:e=>{"use strict";var t={};e.exports=function(e,o){var i=function(e){if(void 0===t[e]){var o=document.querySelector(e);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}t[e]=o}return t[e]}(e);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(o)}},435:(e,t,o)=>{"use strict";o.d(t,{A:()=>a});var i=o(792),r=o.n(i),n=o(305),s=o.n(n)()(r());s.push([e.id,".ck.ck-menu-bar{border:none;border-bottom:1px solid var(--ck-color-toolbar-border)}",""]);const a=s},517:e=>{"use strict";e.exports=function(e,t){Object.keys(t).forEach(function(o){e.setAttribute(o,t[o])})}},584:(e,t,o)=>{e.exports=o(237)("./src/utils.js")},719:e=>{"use strict";var t=[];function o(e){for(var o=-1,i=0;i<t.length;i++)if(t[i].identifier===e){o=i;break}return o}function i(e,i){for(var n={},s=[],a=0;a<e.length;a++){var l=e[a],c=i.base?l[0]+i.base:l[0],u=n[c]||0,d="".concat(c," ").concat(u);n[c]=u+1;var h=o(d),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==h)t[h].references++,t[h].updater(p);else{var f=r(p,i);i.byIndex=a,t.splice(a,0,{identifier:d,updater:f,references:1})}s.push(d)}return s}function r(e,t){var o=t.domAPI(t);o.update(e);return function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;o.update(e=t)}else o.remove()}}e.exports=function(e,r){var n=i(e=e||[],r=r||{});return function(e){e=e||[];for(var s=0;s<n.length;s++){var a=o(n[s]);t[a].references--}for(var l=i(e,r),c=0;c<n.length;c++){var u=o(n[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}n=l}}},782:(e,t,o)=>{e.exports=o(237)("./src/core.js")},783:(e,t,o)=>{e.exports=o(237)("./src/engine.js")},792:e=>{"use strict";e.exports=function(e){return e[1]}},863:e=>{"use strict";var t,o=(t=[],function(e,o){return t[e]=o,t.filter(Boolean).join("\n")});function i(e,t,i,r){var n;if(i)n="";else{n="",r.supports&&(n+="@supports (".concat(r.supports,") {")),r.media&&(n+="@media ".concat(r.media," {"));var s=void 0!==r.layer;s&&(n+="@layer".concat(r.layer.length>0?" ".concat(r.layer):""," {")),n+=r.css,s&&(n+="}"),r.media&&(n+="}"),r.supports&&(n+="}")}if(e.styleSheet)e.styleSheet.cssText=o(t,n);else{var a=document.createTextNode(n),l=e.childNodes;l[t]&&e.removeChild(l[t]),l.length?e.insertBefore(a,l[t]):e.appendChild(a)}}var r={singleton:null,singletonCounter:0};e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=r.singletonCounter++,o=r.singleton||(r.singleton=e.insertStyleElement(e));return{update:function(e){i(o,t,!1,e)},remove:function(e){i(o,t,!0,e)}}}}},t={};function o(i){var r=t[i];if(void 0!==r)return r.exports;var n=t[i]={id:i,exports:{}};return e[i](n,n.exports,o),n.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{"use strict";o.r(i),o.d(i,{InlineEditor:()=>T,InlineEditorUI:()=>s,InlineEditorUIView:()=>y});var e=o(782),t=o(584),r=o(311),n=o(783);class s extends r.EditorUI{view;_toolbarConfig;constructor(e,t){super(e),this.view=t,this._toolbarConfig=(0,r.normalizeToolbarConfig)(e.config.get("toolbar"))}get element(){return this.view.editable.element}init(){const e=this.editor,t=this.view,o=e.editing.view,i=t.editable,r=o.document.getRoot();i.name=r.rootName,t.render();const n=i.element;this.setEditableElement(i.name,n),i.bind("isFocused").to(this.focusTracker),o.attachDomRoot(n),this._initPlaceholder(),this._initToolbar(),t.menuBarView&&this.initMenuBar(t.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.editor,t=this.view,o=t.editable.element,i=t.toolbar;t.panel.bind("isVisible").to(this.focusTracker,"isFocused"),t.bind("viewportTopOffset").to(this,"viewportOffset",({visualTop:e})=>e||0),t.listenTo(e.ui,"update",()=>{t.panel.isVisible&&t.panel.pin({target:o,positions:t.panelPositions})}),i.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(i)}_initPlaceholder(){const e=this.editor,t=e.editing.view,o=t.document.getRoot(),i=e.config.get("placeholder");if(i){const e="string"==typeof i?i:i[o.rootName];e&&(o.placeholder=e)}(0,n.enableViewPlaceholder)({view:t,element:o,isDirectHost:!1,keepOnFocus:!0})}}var a=o(719),l=o.n(a),c=o(863),u=o.n(c),d=o(424),h=o.n(d),p=o(517),f=o.n(p),b=o(163),m=o.n(b),g=o(435),v={attributes:{"data-cke":!0}};v.setAttributes=f(),v.insert=h().bind(null,"head"),v.domAPI=u(),v.insertStyleElement=m();l()(g.A,v);g.A&&g.A.locals&&g.A.locals;const w=(0,t.toUnit)("px");class y extends r.EditorUIView{toolbar;panel;panelPositions;editable;_resizeObserver;constructor(e,t,o,i={}){super(e),this.toolbar=new r.ToolbarView(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull,isFloating:!0}),i.useMenuBar&&(this.menuBarView=new r.MenuBarView(e)),this.set("viewportTopOffset",0),this.panel=new r.BalloonPanelView(e),this.panelPositions=this._getPanelPositions(),this.panel.extendTemplate({attributes:{class:"ck-toolbar-container"}}),this.editable=new r.InlineEditableUIView(e,t,o,{label:i.label}),this._resizeObserver=null}render(){super.render(),this.body.add(this.panel),this.registerChild(this.editable),this.menuBarView?this.panel.content.addMany([this.menuBarView,this.toolbar]):this.panel.content.add(this.toolbar);if(this.toolbar.options.shouldGroupWhenFull){const e=this.editable.element;this._resizeObserver=new t.ResizeObserver(e,()=>{this.toolbar.maxWidth=w(new t.Rect(e).width)})}}destroy(){super.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getPanelPositionTop(e,t){let o;return o=e.top>t.height+this.viewportTopOffset?e.top-t.height:e.bottom>t.height+this.viewportTopOffset+50?this.viewportTopOffset:e.bottom,o}_getPanelPositions(){const e=[(e,t)=>({top:this._getPanelPositionTop(e,t),left:e.left,name:"toolbar_west",config:{withArrow:!1}}),(e,t)=>({top:this._getPanelPositionTop(e,t),left:e.left+e.width-t.width,name:"toolbar_east",config:{withArrow:!1}})];return"ltr"===this.locale.uiLanguageDirection?e:e.reverse()}}function E(e){return function(e){return"object"==typeof e&&null!==e}(e)&&1===e.nodeType&&!function(e){if("object"!=typeof e)return!1;if(null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return null!=t&&(!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`)}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e)}class T extends((0,e.ElementApiMixin)(e.Editor)){static get editorName(){return"InlineEditor"}ui;constructor(o,i={}){if(!O(o)&&void 0!==i.initialData)throw new t.CKEditorError("editor-create-initial-data",null);super(i),this.config.define("menuBar.isVisible",!1),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return O(e)?(0,t.getDataFromElement)(e):e}(o)),this.model.document.createRoot(),O(o)&&(this.sourceElement=o,(0,e.secureSourceElement)(this,o));const r=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=this.config.get("menuBar"),a=new y(this.locale,this.editing.view,this.sourceElement,{shouldToolbarGroupWhenFull:r,useMenuBar:n.isVisible,label:this.config.get("label")});this.ui=new s(this,a),(0,e.attachToForm)(this)}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,o={}){return new Promise(i=>{if(O(e)&&"TEXTAREA"===e.tagName)throw new t.CKEditorError("editor-wrong-element",null);const r=new this(e,o);i(r.initPlugins().then(()=>r.ui.init()).then(()=>r.data.init(r.config.get("initialData"))).then(()=>r.fire("ready")).then(()=>r))})}}function O(e){return E(e)}})(),(window.CKEditor5=window.CKEditor5||{}).editorInline=i})();
package/src/index.js DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module editor-inline
7
- */
8
- export { InlineEditor } from './inlineeditor.js';
9
- export { InlineEditorUI } from './inlineeditorui.js';
10
- export { InlineEditorUIView } from './inlineeditoruiview.js';
@@ -1,194 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module editor-inline/inlineeditor
7
- */
8
- import { Editor, ElementApiMixin, attachToForm, secureSourceElement } from 'ckeditor5/src/core.js';
9
- import { getDataFromElement, CKEditorError } from 'ckeditor5/src/utils.js';
10
- import { InlineEditorUI } from './inlineeditorui.js';
11
- import { InlineEditorUIView } from './inlineeditoruiview.js';
12
- import { isElement as _isElement } from 'es-toolkit/compat';
13
- /**
14
- * The inline editor implementation. It uses an inline editable and a floating toolbar.
15
- * See the {@glink examples/builds/inline-editor demo}.
16
- *
17
- * In order to create a inline editor instance, use the static
18
- * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`} method.
19
- */
20
- export class InlineEditor extends /* #__PURE__ */ ElementApiMixin(Editor) {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get editorName() {
25
- return 'InlineEditor';
26
- }
27
- /**
28
- * @inheritDoc
29
- */
30
- ui;
31
- /**
32
- * Creates an instance of the inline editor.
33
- *
34
- * **Note:** Do not use the constructor to create editor instances. Use the static
35
- * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`} method instead.
36
- *
37
- * @param sourceElementOrData The DOM element that will be the source for the created editor
38
- * (on which the editor will be initialized) or initial data for the editor. For more information see
39
- * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}.
40
- * @param config The editor configuration.
41
- */
42
- constructor(sourceElementOrData, config = {}) {
43
- // If both `config.initialData` and initial data parameter in `create()` are set, then throw.
44
- if (!isElement(sourceElementOrData) && config.initialData !== undefined) {
45
- // Documented in core/editor/editorconfig.jsdoc.
46
- // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
47
- throw new CKEditorError('editor-create-initial-data', null);
48
- }
49
- super(config);
50
- this.config.define('menuBar.isVisible', false);
51
- if (this.config.get('initialData') === undefined) {
52
- this.config.set('initialData', getInitialData(sourceElementOrData));
53
- }
54
- this.model.document.createRoot();
55
- if (isElement(sourceElementOrData)) {
56
- this.sourceElement = sourceElementOrData;
57
- secureSourceElement(this, sourceElementOrData);
58
- }
59
- const shouldToolbarGroupWhenFull = !this.config.get('toolbar.shouldNotGroupWhenFull');
60
- const menuBarConfig = this.config.get('menuBar');
61
- const view = new InlineEditorUIView(this.locale, this.editing.view, this.sourceElement, {
62
- shouldToolbarGroupWhenFull,
63
- useMenuBar: menuBarConfig.isVisible,
64
- label: this.config.get('label')
65
- });
66
- this.ui = new InlineEditorUI(this, view);
67
- attachToForm(this);
68
- }
69
- /**
70
- * Destroys the editor instance, releasing all resources used by it.
71
- *
72
- * Updates the original editor element with the data if the
73
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
74
- * configuration option is set to `true`.
75
- */
76
- destroy() {
77
- // Cache the data, then destroy.
78
- // It's safe to assume that the model->view conversion will not work after super.destroy().
79
- const data = this.getData();
80
- this.ui.destroy();
81
- return super.destroy()
82
- .then(() => {
83
- if (this.sourceElement) {
84
- this.updateSourceElement(data);
85
- }
86
- });
87
- }
88
- /**
89
- * Creates a new inline editor instance.
90
- *
91
- * There are three general ways how the editor can be initialized.
92
- *
93
- * # Using an existing DOM element (and loading data from it)
94
- *
95
- * You can initialize the editor using an existing DOM element:
96
- *
97
- * ```ts
98
- * InlineEditor
99
- * .create( document.querySelector( '#editor' ) )
100
- * .then( editor => {
101
- * console.log( 'Editor was initialized', editor );
102
- * } )
103
- * .catch( err => {
104
- * console.error( err.stack );
105
- * } );
106
- * ```
107
- *
108
- * The element's content will be used as the editor data and the element will become the editable element.
109
- *
110
- * # Creating a detached editor
111
- *
112
- * Alternatively, you can initialize the editor by passing the initial data directly as a `String`.
113
- * In this case, the editor will render an element that must be inserted into the DOM for the editor to work properly:
114
- *
115
- * ```ts
116
- * InlineEditor
117
- * .create( '<p>Hello world!</p>' )
118
- * .then( editor => {
119
- * console.log( 'Editor was initialized', editor );
120
- *
121
- * // Initial data was provided so the editor UI element needs to be added manually to the DOM.
122
- * document.body.appendChild( editor.ui.element );
123
- * } )
124
- * .catch( err => {
125
- * console.error( err.stack );
126
- * } );
127
- * ```
128
- *
129
- * This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
130
- * web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
131
- *
132
- * # Using an existing DOM element (and data provided in `config.initialData`)
133
- *
134
- * You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
135
- *
136
- * ```ts
137
- * InlineEditor
138
- * .create( document.querySelector( '#editor' ), {
139
- * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
140
- * } )
141
- * .then( editor => {
142
- * console.log( 'Editor was initialized', editor );
143
- * } )
144
- * .catch( err => {
145
- * console.error( err.stack );
146
- * } );
147
- * ```
148
- *
149
- * This method can be used to initialize the editor on an existing element with the specified content in case if your integration
150
- * makes it difficult to set the content of the source element.
151
- *
152
- * Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
153
- *
154
- * # Configuring the editor
155
- *
156
- * See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
157
- * customizing plugins, toolbar and more.
158
- *
159
- * @param sourceElementOrData The DOM element that will be the source for the created editor
160
- * or the editor's initial data.
161
- *
162
- * If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
163
- * The editor data will be set back to the original element once the editor is destroyed only if the
164
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
165
- * option is set to `true`.
166
- *
167
- * If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
168
- * It is available under the {@link module:editor-inline/inlineeditorui~InlineEditorUI#element `editor.ui.element`} property.
169
- *
170
- * @param config The editor configuration.
171
- * @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
172
- */
173
- static create(sourceElementOrData, config = {}) {
174
- return new Promise(resolve => {
175
- if (isElement(sourceElementOrData) && sourceElementOrData.tagName === 'TEXTAREA') {
176
- // Documented in core/editor/editor.js
177
- // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
178
- throw new CKEditorError('editor-wrong-element', null);
179
- }
180
- const editor = new this(sourceElementOrData, config);
181
- resolve(editor.initPlugins()
182
- .then(() => editor.ui.init())
183
- .then(() => editor.data.init(editor.config.get('initialData')))
184
- .then(() => editor.fire('ready'))
185
- .then(() => editor));
186
- });
187
- }
188
- }
189
- function getInitialData(sourceElementOrData) {
190
- return isElement(sourceElementOrData) ? getDataFromElement(sourceElementOrData) : sourceElementOrData;
191
- }
192
- function isElement(value) {
193
- return _isElement(value);
194
- }
@@ -1,134 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- import { EditorUI, normalizeToolbarConfig } from 'ckeditor5/src/ui.js';
6
- import { enableViewPlaceholder } from 'ckeditor5/src/engine.js';
7
- /**
8
- * The inline editor UI class.
9
- *
10
- * @extends module:ui/editorui/editorui~EditorUI
11
- */
12
- export class InlineEditorUI extends EditorUI {
13
- /**
14
- * The main (top–most) view of the editor UI.
15
- */
16
- view;
17
- /**
18
- * A normalized `config.toolbar` object.
19
- */
20
- _toolbarConfig;
21
- /**
22
- * Creates an instance of the inline editor UI class.
23
- *
24
- * @param editor The editor instance.
25
- * @param view The view of the UI.
26
- */
27
- constructor(editor, view) {
28
- super(editor);
29
- this.view = view;
30
- this._toolbarConfig = normalizeToolbarConfig(editor.config.get('toolbar'));
31
- }
32
- /**
33
- * @inheritDoc
34
- */
35
- get element() {
36
- return this.view.editable.element;
37
- }
38
- /**
39
- * Initializes the UI.
40
- */
41
- init() {
42
- const editor = this.editor;
43
- const view = this.view;
44
- const editingView = editor.editing.view;
45
- const editable = view.editable;
46
- const editingRoot = editingView.document.getRoot();
47
- // The editable UI and editing root should share the same name. Then name is used
48
- // to recognize the particular editable, for instance in ARIA attributes.
49
- editable.name = editingRoot.rootName;
50
- view.render();
51
- // The editable UI element in DOM is available for sure only after the editor UI view has been rendered.
52
- // But it can be available earlier if a DOM element has been passed to InlineEditor.create().
53
- const editableElement = editable.element;
54
- // Register the editable UI view in the editor. A single editor instance can aggregate multiple
55
- // editable areas (roots) but the inline editor has only one.
56
- this.setEditableElement(editable.name, editableElement);
57
- // Let the editable UI element respond to the changes in the global editor focus
58
- // tracker. It has been added to the same tracker a few lines above but, in reality, there are
59
- // many focusable areas in the editor, like balloons, toolbars or dropdowns and as long
60
- // as they have focus, the editable should act like it is focused too (although technically
61
- // it isn't), e.g. by setting the proper CSS class, visually announcing focus to the user.
62
- // Doing otherwise will result in editable focus styles disappearing, once e.g. the
63
- // toolbar gets focused.
64
- editable.bind('isFocused').to(this.focusTracker);
65
- // Bind the editable UI element to the editing view, making it an end– and entry–point
66
- // of the editor's engine. This is where the engine meets the UI.
67
- editingView.attachDomRoot(editableElement);
68
- this._initPlaceholder();
69
- this._initToolbar();
70
- if (view.menuBarView) {
71
- this.initMenuBar(view.menuBarView);
72
- }
73
- this.fire('ready');
74
- }
75
- /**
76
- * @inheritDoc
77
- */
78
- destroy() {
79
- super.destroy();
80
- const view = this.view;
81
- const editingView = this.editor.editing.view;
82
- if (editingView.getDomRoot(view.editable.name)) {
83
- editingView.detachDomRoot(view.editable.name);
84
- }
85
- view.destroy();
86
- }
87
- /**
88
- * Initializes the inline editor toolbar and its panel.
89
- */
90
- _initToolbar() {
91
- const editor = this.editor;
92
- const view = this.view;
93
- const editableElement = view.editable.element;
94
- const toolbar = view.toolbar;
95
- // Set–up the view#panel.
96
- view.panel.bind('isVisible').to(this.focusTracker, 'isFocused');
97
- view.bind('viewportTopOffset').to(this, 'viewportOffset', ({ visualTop }) => visualTop || 0);
98
- // https://github.com/ckeditor/ckeditor5-editor-inline/issues/4
99
- view.listenTo(editor.ui, 'update', () => {
100
- // Don't pin if the panel is not already visible. It prevents the panel
101
- // showing up when there's no focus in the UI.
102
- if (view.panel.isVisible) {
103
- view.panel.pin({
104
- target: editableElement,
105
- positions: view.panelPositions
106
- });
107
- }
108
- });
109
- toolbar.fillFromConfig(this._toolbarConfig, this.componentFactory);
110
- // Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
111
- this.addToolbar(toolbar);
112
- }
113
- /**
114
- * Enable the placeholder text on the editing root.
115
- */
116
- _initPlaceholder() {
117
- const editor = this.editor;
118
- const editingView = editor.editing.view;
119
- const editingRoot = editingView.document.getRoot();
120
- const placeholder = editor.config.get('placeholder');
121
- if (placeholder) {
122
- const placeholderText = typeof placeholder === 'string' ? placeholder : placeholder[editingRoot.rootName];
123
- if (placeholderText) {
124
- editingRoot.placeholder = placeholderText;
125
- }
126
- }
127
- enableViewPlaceholder({
128
- view: editingView,
129
- element: editingRoot,
130
- isDirectHost: false,
131
- keepOnFocus: true
132
- });
133
- }
134
- }
@@ -1,207 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module editor-inline/inlineeditoruiview
7
- */
8
- import { BalloonPanelView, EditorUIView, InlineEditableUIView, MenuBarView, ToolbarView } from 'ckeditor5/src/ui.js';
9
- import { Rect, ResizeObserver, toUnit } from 'ckeditor5/src/utils.js';
10
- import '../theme/inlineeditor.css';
11
- const toPx = /* #__PURE__ */ toUnit('px');
12
- /**
13
- * Inline editor UI view. Uses an nline editable and a floating toolbar.
14
- */
15
- export class InlineEditorUIView extends EditorUIView {
16
- /**
17
- * A floating toolbar view instance.
18
- */
19
- toolbar;
20
- /**
21
- * A balloon panel view instance.
22
- */
23
- panel;
24
- /**
25
- * A set of positioning functions used by the {@link #panel} to float around
26
- * {@link #element editableElement}.
27
- *
28
- * The positioning functions are as follows:
29
- *
30
- * * West:
31
- *
32
- * ```
33
- * [ Panel ]
34
- * +------------------+
35
- * | #editableElement |
36
- * +------------------+
37
- *
38
- * +------------------+
39
- * | #editableElement |
40
- * |[ Panel ] |
41
- * | |
42
- * +------------------+
43
- *
44
- * +------------------+
45
- * | #editableElement |
46
- * +------------------+
47
- * [ Panel ]
48
- * ```
49
- *
50
- * * East:
51
- *
52
- * ```
53
- * [ Panel ]
54
- * +------------------+
55
- * | #editableElement |
56
- * +------------------+
57
- *
58
- * +------------------+
59
- * | #editableElement |
60
- * | [ Panel ]|
61
- * | |
62
- * +------------------+
63
- *
64
- * +------------------+
65
- * | #editableElement |
66
- * +------------------+
67
- * [ Panel ]
68
- * ```
69
- *
70
- * See: {@link module:utils/dom/position~DomOptimalPositionOptions#positions}.
71
- */
72
- panelPositions;
73
- /**
74
- * Editable UI view.
75
- */
76
- editable;
77
- /**
78
- * An instance of the resize observer that helps dynamically determine the geometry of the toolbar
79
- * and manage items that do not fit into a single row.
80
- *
81
- * **Note:** Created in {@link #render}.
82
- */
83
- _resizeObserver;
84
- /**
85
- * Creates an instance of the inline editor UI view.
86
- *
87
- * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
88
- * @param editingView The editing view instance this view is related to.
89
- * @param editableElement The editable element. If not specified, it will be automatically created by
90
- * {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
91
- * @param options Configuration options for the view instance.
92
- * @param options.shouldToolbarGroupWhenFull When set `true` enables automatic items grouping
93
- * in the main {@link module:editor-inline/inlineeditoruiview~InlineEditorUIView#toolbar toolbar}.
94
- * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
95
- * @param options.label When set, this value will be used as an accessible `aria-label` of the
96
- * {@link module:ui/editableui/editableuiview~EditableUIView editable view}.
97
- */
98
- constructor(locale, editingView, editableElement, options = {}) {
99
- super(locale);
100
- this.toolbar = new ToolbarView(locale, {
101
- shouldGroupWhenFull: options.shouldToolbarGroupWhenFull,
102
- isFloating: true
103
- });
104
- if (options.useMenuBar) {
105
- this.menuBarView = new MenuBarView(locale);
106
- }
107
- this.set('viewportTopOffset', 0);
108
- this.panel = new BalloonPanelView(locale);
109
- this.panelPositions = this._getPanelPositions();
110
- this.panel.extendTemplate({
111
- attributes: {
112
- class: 'ck-toolbar-container'
113
- }
114
- });
115
- this.editable = new InlineEditableUIView(locale, editingView, editableElement, {
116
- label: options.label
117
- });
118
- this._resizeObserver = null;
119
- }
120
- /**
121
- * @inheritDoc
122
- */
123
- render() {
124
- super.render();
125
- this.body.add(this.panel);
126
- this.registerChild(this.editable);
127
- if (this.menuBarView) {
128
- // Set toolbar as a child of a stickyPanel and makes toolbar sticky.
129
- this.panel.content.addMany([this.menuBarView, this.toolbar]);
130
- }
131
- else {
132
- this.panel.content.add(this.toolbar);
133
- }
134
- const options = this.toolbar.options;
135
- // Set toolbar's max-width on the initialization and update it on the editable resize,
136
- // if 'shouldToolbarGroupWhenFull' in config is set to 'true'.
137
- if (options.shouldGroupWhenFull) {
138
- const editableElement = this.editable.element;
139
- this._resizeObserver = new ResizeObserver(editableElement, () => {
140
- this.toolbar.maxWidth = toPx(new Rect(editableElement).width);
141
- });
142
- }
143
- }
144
- /**
145
- * @inheritDoc
146
- */
147
- destroy() {
148
- super.destroy();
149
- if (this._resizeObserver) {
150
- this._resizeObserver.destroy();
151
- }
152
- }
153
- /**
154
- * Determines the panel top position of the {@link #panel} in {@link #panelPositions}.
155
- *
156
- * @param editableRect Rect of the {@link #element}.
157
- * @param panelRect Rect of the {@link #panel}.
158
- */
159
- _getPanelPositionTop(editableRect, panelRect) {
160
- let top;
161
- if (editableRect.top > panelRect.height + this.viewportTopOffset) {
162
- top = editableRect.top - panelRect.height;
163
- }
164
- else if (editableRect.bottom > panelRect.height + this.viewportTopOffset + 50) {
165
- top = this.viewportTopOffset;
166
- }
167
- else {
168
- top = editableRect.bottom;
169
- }
170
- return top;
171
- }
172
- /**
173
- * Returns the positions for {@link #panelPositions}.
174
- *
175
- * See: {@link module:utils/dom/position~DomOptimalPositionOptions#positions}.
176
- */
177
- _getPanelPositions() {
178
- const positions = [
179
- (editableRect, panelRect) => {
180
- return {
181
- top: this._getPanelPositionTop(editableRect, panelRect),
182
- left: editableRect.left,
183
- name: 'toolbar_west',
184
- config: {
185
- withArrow: false
186
- }
187
- };
188
- },
189
- (editableRect, panelRect) => {
190
- return {
191
- top: this._getPanelPositionTop(editableRect, panelRect),
192
- left: editableRect.left + editableRect.width - panelRect.width,
193
- name: 'toolbar_east',
194
- config: {
195
- withArrow: false
196
- }
197
- };
198
- }
199
- ];
200
- if (this.locale.uiLanguageDirection === 'ltr') {
201
- return positions;
202
- }
203
- else {
204
- return positions.reverse();
205
- }
206
- }
207
- }
@@ -1,9 +0,0 @@
1
- /*
2
- * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
-
6
- .ck.ck-menu-bar {
7
- border: none;
8
- border-bottom: 1px solid var(--ck-color-toolbar-border);
9
- }
File without changes