@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/LICENSE.md +1 -1
- package/dist/index-editor.css +2 -2
- package/dist/index.css +2 -7
- package/dist/index.css.map +1 -1
- package/dist/index.js +26 -127
- package/dist/index.js.map +1 -1
- package/{src → dist}/inlineeditor.d.ts +107 -6
- package/{src → dist}/inlineeditorui.d.ts +2 -2
- package/{src → dist}/inlineeditoruiview.d.ts +3 -3
- package/package.json +23 -45
- package/build/editor-inline.js +0 -4
- package/src/index.js +0 -10
- package/src/inlineeditor.js +0 -194
- package/src/inlineeditorui.js +0 -134
- package/src/inlineeditoruiview.js +0 -207
- package/theme/inlineeditor.css +0 -9
- /package/{src → dist}/index.d.ts +0 -0
package/LICENSE.md
CHANGED
|
@@ -18,7 +18,7 @@ Where not otherwise indicated, all CKEditor 5 content is authored by CKSour
|
|
|
18
18
|
|
|
19
19
|
The following libraries are included in CKEditor 5 under the [MIT license](https://opensource.org/licenses/MIT):
|
|
20
20
|
|
|
21
|
-
* es-toolkit - Copyright (c) 2024 Viva Republica, Inc.
|
|
21
|
+
* es-toolkit - Copyright (c) 2024 Viva Republica, Inc and Copyright OpenJS Foundation and other contributors.
|
|
22
22
|
|
|
23
23
|
Trademarks
|
|
24
24
|
----------
|
package/dist/index-editor.css
CHANGED
package/dist/index.css
CHANGED
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
.ck.ck-menu-bar {
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
border: none;
|
|
7
|
+
border-bottom: 1px solid var(--ck-color-toolbar-border);
|
|
13
8
|
}
|
|
14
9
|
|
|
15
10
|
/*# sourceMappingURL=index.css.map */
|
package/dist/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../theme/inlineeditor.css","index.css"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../theme/inlineeditor.css","index.css"],"names":[],"mappings":";;;;AAKA,CAAA,EAAA,CAAA,EAAA,CAAA,IAAA,CAAA,GAAA,CAAA;ACJA,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI;AACd,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;AACzD;;AAEA,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","file":"index.css.map","sourcesContent":["/*\n * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n\n.ck.ck-menu-bar {\n\tborder: none;\n\tborder-bottom: 1px solid var(--ck-color-toolbar-border);\n}\n",".ck.ck-menu-bar {\n border: none;\n border-bottom: 1px solid var(--ck-color-toolbar-border);\n}\n\n/*# sourceMappingURL=index.css.map */"]}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import { ElementApiMixin, Editor, secureSourceElement, attachToForm } from '@ckeditor/ckeditor5-core/dist/index.js';
|
|
6
|
-
import { ResizeObserver, toUnit,
|
|
5
|
+
import { ElementApiMixin, Editor, normalizeSingleRootEditorConstructorParams, normalizeRootsConfig, secureSourceElement, attachToForm } from '@ckeditor/ckeditor5-core/dist/index.js';
|
|
6
|
+
import { ResizeObserver, Rect, toUnit, logWarning, CKEditorError } from '@ckeditor/ckeditor5-utils/dist/index.js';
|
|
7
7
|
import { EditorUI, normalizeToolbarConfig, EditorUIView, ToolbarView, MenuBarView, BalloonPanelView, InlineEditableUIView } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
|
8
8
|
import { enableViewPlaceholder } from '@ckeditor/ckeditor5-engine/dist/index.js';
|
|
9
9
|
import { isElement as isElement$1 } from 'es-toolkit/compat';
|
|
@@ -112,12 +112,9 @@ import { isElement as isElement$1 } from 'es-toolkit/compat';
|
|
|
112
112
|
const editor = this.editor;
|
|
113
113
|
const editingView = editor.editing.view;
|
|
114
114
|
const editingRoot = editingView.document.getRoot();
|
|
115
|
-
const placeholder = editor.config.get('
|
|
115
|
+
const placeholder = editor.config.get('roots')[editingRoot.rootName].placeholder;
|
|
116
116
|
if (placeholder) {
|
|
117
|
-
|
|
118
|
-
if (placeholderText) {
|
|
119
|
-
editingRoot.placeholder = placeholderText;
|
|
120
|
-
}
|
|
117
|
+
editingRoot.placeholder = placeholder;
|
|
121
118
|
}
|
|
122
119
|
enableViewPlaceholder({
|
|
123
120
|
view: editingView,
|
|
@@ -329,39 +326,33 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
329
326
|
/**
|
|
330
327
|
* @inheritDoc
|
|
331
328
|
*/ ui;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
* (on which the editor will be initialized) or initial data for the editor. For more information see
|
|
340
|
-
* {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}.
|
|
341
|
-
* @param config The editor configuration.
|
|
342
|
-
*/ constructor(sourceElementOrData, config = {}){
|
|
343
|
-
// If both `config.initialData` and initial data parameter in `create()` are set, then throw.
|
|
344
|
-
if (!isElement(sourceElementOrData) && config.initialData !== undefined) {
|
|
345
|
-
// Documented in core/editor/editorconfig.jsdoc.
|
|
346
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
|
|
347
|
-
throw new CKEditorError('editor-create-initial-data', null);
|
|
329
|
+
constructor(sourceElementOrDataOrConfig, config = {}){
|
|
330
|
+
const { sourceElementOrData, editorConfig } = normalizeSingleRootEditorConstructorParams(sourceElementOrDataOrConfig, config);
|
|
331
|
+
super(editorConfig);
|
|
332
|
+
normalizeRootsConfig(sourceElementOrData, this.config);
|
|
333
|
+
if (isElement(this.config.get('attachTo'))) {
|
|
334
|
+
// Documented in core/editor/editorconfig.ts.
|
|
335
|
+
logWarning('editor-create-attachto-ignored');
|
|
348
336
|
}
|
|
349
|
-
|
|
350
|
-
this.config.
|
|
351
|
-
if (
|
|
352
|
-
|
|
337
|
+
// From this point use only normalized `roots.main.element`.
|
|
338
|
+
const sourceElement = this.config.get('roots').main.element;
|
|
339
|
+
if (isElement(sourceElement)) {
|
|
340
|
+
if (sourceElement.tagName === 'TEXTAREA') {
|
|
341
|
+
// Documented in core/editor/editor.js
|
|
342
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
|
|
343
|
+
throw new CKEditorError('editor-wrong-element', null);
|
|
344
|
+
}
|
|
345
|
+
this.sourceElement = sourceElement;
|
|
346
|
+
secureSourceElement(this, sourceElement);
|
|
353
347
|
}
|
|
348
|
+
this.config.define('menuBar.isVisible', false);
|
|
354
349
|
this.model.document.createRoot();
|
|
355
|
-
if (isElement(sourceElementOrData)) {
|
|
356
|
-
this.sourceElement = sourceElementOrData;
|
|
357
|
-
secureSourceElement(this, sourceElementOrData);
|
|
358
|
-
}
|
|
359
350
|
const shouldToolbarGroupWhenFull = !this.config.get('toolbar.shouldNotGroupWhenFull');
|
|
360
351
|
const menuBarConfig = this.config.get('menuBar');
|
|
361
352
|
const view = new InlineEditorUIView(this.locale, this.editing.view, this.sourceElement, {
|
|
362
353
|
shouldToolbarGroupWhenFull,
|
|
363
354
|
useMenuBar: menuBarConfig.isVisible,
|
|
364
|
-
label: this.config.get('
|
|
355
|
+
label: this.config.get('roots').main.label
|
|
365
356
|
});
|
|
366
357
|
this.ui = new InlineEditorUI(this, view);
|
|
367
358
|
attachToForm(this);
|
|
@@ -383,105 +374,13 @@ const toPx = /* #__PURE__ */ toUnit('px');
|
|
|
383
374
|
}
|
|
384
375
|
});
|
|
385
376
|
}
|
|
386
|
-
|
|
387
|
-
* Creates a new inline editor instance.
|
|
388
|
-
*
|
|
389
|
-
* There are three general ways how the editor can be initialized.
|
|
390
|
-
*
|
|
391
|
-
* # Using an existing DOM element (and loading data from it)
|
|
392
|
-
*
|
|
393
|
-
* You can initialize the editor using an existing DOM element:
|
|
394
|
-
*
|
|
395
|
-
* ```ts
|
|
396
|
-
* InlineEditor
|
|
397
|
-
* .create( document.querySelector( '#editor' ) )
|
|
398
|
-
* .then( editor => {
|
|
399
|
-
* console.log( 'Editor was initialized', editor );
|
|
400
|
-
* } )
|
|
401
|
-
* .catch( err => {
|
|
402
|
-
* console.error( err.stack );
|
|
403
|
-
* } );
|
|
404
|
-
* ```
|
|
405
|
-
*
|
|
406
|
-
* The element's content will be used as the editor data and the element will become the editable element.
|
|
407
|
-
*
|
|
408
|
-
* # Creating a detached editor
|
|
409
|
-
*
|
|
410
|
-
* Alternatively, you can initialize the editor by passing the initial data directly as a `String`.
|
|
411
|
-
* In this case, the editor will render an element that must be inserted into the DOM for the editor to work properly:
|
|
412
|
-
*
|
|
413
|
-
* ```ts
|
|
414
|
-
* InlineEditor
|
|
415
|
-
* .create( '<p>Hello world!</p>' )
|
|
416
|
-
* .then( editor => {
|
|
417
|
-
* console.log( 'Editor was initialized', editor );
|
|
418
|
-
*
|
|
419
|
-
* // Initial data was provided so the editor UI element needs to be added manually to the DOM.
|
|
420
|
-
* document.body.appendChild( editor.ui.element );
|
|
421
|
-
* } )
|
|
422
|
-
* .catch( err => {
|
|
423
|
-
* console.error( err.stack );
|
|
424
|
-
* } );
|
|
425
|
-
* ```
|
|
426
|
-
*
|
|
427
|
-
* This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
|
|
428
|
-
* web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
|
|
429
|
-
*
|
|
430
|
-
* # Using an existing DOM element (and data provided in `config.initialData`)
|
|
431
|
-
*
|
|
432
|
-
* You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
|
|
433
|
-
*
|
|
434
|
-
* ```ts
|
|
435
|
-
* InlineEditor
|
|
436
|
-
* .create( document.querySelector( '#editor' ), {
|
|
437
|
-
* initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
|
|
438
|
-
* } )
|
|
439
|
-
* .then( editor => {
|
|
440
|
-
* console.log( 'Editor was initialized', editor );
|
|
441
|
-
* } )
|
|
442
|
-
* .catch( err => {
|
|
443
|
-
* console.error( err.stack );
|
|
444
|
-
* } );
|
|
445
|
-
* ```
|
|
446
|
-
*
|
|
447
|
-
* This method can be used to initialize the editor on an existing element with the specified content in case if your integration
|
|
448
|
-
* makes it difficult to set the content of the source element.
|
|
449
|
-
*
|
|
450
|
-
* Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
|
|
451
|
-
*
|
|
452
|
-
* # Configuring the editor
|
|
453
|
-
*
|
|
454
|
-
* See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
|
|
455
|
-
* customizing plugins, toolbar and more.
|
|
456
|
-
*
|
|
457
|
-
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
|
458
|
-
* or the editor's initial data.
|
|
459
|
-
*
|
|
460
|
-
* If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
|
|
461
|
-
* The editor data will be set back to the original element once the editor is destroyed only if the
|
|
462
|
-
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
|
|
463
|
-
* option is set to `true`.
|
|
464
|
-
*
|
|
465
|
-
* If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
|
|
466
|
-
* It is available under the {@link module:editor-inline/inlineeditorui~InlineEditorUI#element `editor.ui.element`} property.
|
|
467
|
-
*
|
|
468
|
-
* @param config The editor configuration.
|
|
469
|
-
* @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
|
|
470
|
-
*/ static create(sourceElementOrData, config = {}) {
|
|
377
|
+
static create(sourceElementOrDataOrConfig, config = {}) {
|
|
471
378
|
return new Promise((resolve)=>{
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
|
|
475
|
-
throw new CKEditorError('editor-wrong-element', null);
|
|
476
|
-
}
|
|
477
|
-
const editor = new this(sourceElementOrData, config);
|
|
478
|
-
resolve(editor.initPlugins().then(()=>editor.ui.init()).then(()=>editor.data.init(editor.config.get('initialData'))).then(()=>editor.fire('ready')).then(()=>editor));
|
|
379
|
+
const editor = new this(sourceElementOrDataOrConfig, config);
|
|
380
|
+
resolve(editor.initPlugins().then(()=>editor.ui.init()).then(()=>editor.data.init(editor.config.get('roots').main.initialData)).then(()=>editor.fire('ready')).then(()=>editor));
|
|
479
381
|
});
|
|
480
382
|
}
|
|
481
383
|
}
|
|
482
|
-
function getInitialData(sourceElementOrData) {
|
|
483
|
-
return isElement(sourceElementOrData) ? getDataFromElement(sourceElementOrData) : sourceElementOrData;
|
|
484
|
-
}
|
|
485
384
|
function isElement(value) {
|
|
486
385
|
return isElement$1(value);
|
|
487
386
|
}
|