ckeditor5 1.31.8 → 1.32.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.
- checksums.yaml +4 -4
- data/README.md +15 -4
- data/lib/ckeditor5/rails/assets/webcomponent_bundle.rb +2 -21
- data/lib/ckeditor5/rails/version.rb +1 -1
- data/npm_package/dist/index.cjs +2 -0
- data/npm_package/dist/index.cjs.map +1 -0
- data/npm_package/dist/index.d.ts +1 -0
- data/npm_package/dist/index.mjs +723 -0
- data/npm_package/dist/index.mjs.map +1 -0
- data/npm_package/dist/src/components/context.d.ts +24 -0
- data/npm_package/dist/src/components/context.d.ts.map +1 -0
- data/npm_package/dist/src/components/editable.d.ts +34 -0
- data/npm_package/dist/src/components/editable.d.ts.map +1 -0
- data/npm_package/dist/src/components/editor/editor.d.ts +79 -0
- data/npm_package/dist/src/components/editor/editor.d.ts.map +1 -0
- data/npm_package/dist/src/components/editor/index.d.ts +3 -0
- data/npm_package/dist/src/components/editor/index.d.ts.map +1 -0
- data/npm_package/dist/src/components/editor/multiroot-editables-tracker.d.ts +36 -0
- data/npm_package/dist/src/components/editor/multiroot-editables-tracker.d.ts.map +1 -0
- data/npm_package/dist/src/components/index.d.ts +5 -0
- data/npm_package/dist/src/components/index.d.ts.map +1 -0
- data/npm_package/dist/src/components/ui-part.d.ts +2 -0
- data/npm_package/dist/src/components/ui-part.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/exec-if-dom-ready.d.ts +7 -0
- data/npm_package/dist/src/helpers/exec-if-dom-ready.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/index.d.ts +8 -0
- data/npm_package/dist/src/helpers/index.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/inject-script.d.ts +8 -0
- data/npm_package/dist/src/helpers/inject-script.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/is-safe-key.d.ts +8 -0
- data/npm_package/dist/src/helpers/is-safe-key.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/load-async-css.d.ts +9 -0
- data/npm_package/dist/src/helpers/load-async-css.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/load-async-imports.d.ts +25 -0
- data/npm_package/dist/src/helpers/load-async-imports.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/resolve-config-element-references.d.ts +9 -0
- data/npm_package/dist/src/helpers/resolve-config-element-references.d.ts.map +1 -0
- data/npm_package/dist/src/helpers/uid.d.ts +7 -0
- data/npm_package/dist/src/helpers/uid.d.ts.map +1 -0
- data/npm_package/dist/src/index.d.ts +1 -0
- data/npm_package/dist/src/index.d.ts.map +1 -0
- data/npm_package/dist/vite.config.d.ts +3 -0
- data/npm_package/dist/vite.config.d.ts.map +1 -0
- data/npm_package/package.json +37 -0
- metadata +41 -6
- data/lib/ckeditor5/rails/assets/webcomponents/components/context.mjs +0 -123
- data/lib/ckeditor5/rails/assets/webcomponents/components/editable.mjs +0 -113
- data/lib/ckeditor5/rails/assets/webcomponents/components/editor.mjs +0 -778
- data/lib/ckeditor5/rails/assets/webcomponents/components/ui-part.mjs +0 -26
- data/lib/ckeditor5/rails/assets/webcomponents/utils.mjs +0 -235
@@ -1,123 +0,0 @@
|
|
1
|
-
class CKEditorContextComponent extends HTMLElement {
|
2
|
-
static get observedAttributes() {
|
3
|
-
return ['plugins', 'config'];
|
4
|
-
}
|
5
|
-
|
6
|
-
/** @type {import('ckeditor5').Context|null} */
|
7
|
-
instance = null;
|
8
|
-
|
9
|
-
/** @type {Promise<import('ckeditor5').Context>} */
|
10
|
-
instancePromise = Promise.withResolvers();
|
11
|
-
|
12
|
-
/** @type {Set<CKEditorComponent>} */
|
13
|
-
#connectedEditors = new Set();
|
14
|
-
|
15
|
-
async connectedCallback() {
|
16
|
-
try {
|
17
|
-
execIfDOMReady(() => this.#initializeContext());
|
18
|
-
} catch (error) {
|
19
|
-
console.error('Failed to initialize context:', error);
|
20
|
-
this.dispatchEvent(new CustomEvent('context-error', { detail: error }));
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
async attributeChangedCallback(name, oldValue, newValue) {
|
25
|
-
if (oldValue !== null && oldValue !== newValue) {
|
26
|
-
await this.#initializeContext();
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
async disconnectedCallback() {
|
31
|
-
if (this.instance) {
|
32
|
-
await this.instance.destroy();
|
33
|
-
this.instance = null;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Register editor component with this context
|
39
|
-
*
|
40
|
-
* @param {CKEditorComponent} editor
|
41
|
-
*/
|
42
|
-
registerEditor(editor) {
|
43
|
-
this.#connectedEditors.add(editor);
|
44
|
-
}
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Unregister editor component from this context
|
48
|
-
*
|
49
|
-
* @param {CKEditorComponent} editor
|
50
|
-
*/
|
51
|
-
unregisterEditor(editor) {
|
52
|
-
this.#connectedEditors.delete(editor);
|
53
|
-
}
|
54
|
-
|
55
|
-
/**
|
56
|
-
* Initialize CKEditor context with shared configuration
|
57
|
-
*
|
58
|
-
* @private
|
59
|
-
*/
|
60
|
-
async #initializeContext() {
|
61
|
-
if (this.instance) {
|
62
|
-
this.instancePromise = Promise.withResolvers();
|
63
|
-
|
64
|
-
await this.instance.destroy();
|
65
|
-
|
66
|
-
this.instance = null;
|
67
|
-
}
|
68
|
-
|
69
|
-
// Broadcast context initialization event
|
70
|
-
window.dispatchEvent(
|
71
|
-
new CustomEvent('ckeditor:context:attach:before', { detail: { element: this } })
|
72
|
-
);
|
73
|
-
|
74
|
-
const { Context, ContextWatchdog } = await import('ckeditor5');
|
75
|
-
const plugins = await this.#getPlugins();
|
76
|
-
const config = this.#getConfig();
|
77
|
-
|
78
|
-
// Broadcast context mounting event with configuration
|
79
|
-
window.dispatchEvent(
|
80
|
-
new CustomEvent('ckeditor:context:attach', { detail: { config, element: this } })
|
81
|
-
);
|
82
|
-
|
83
|
-
this.instance = new ContextWatchdog(Context, {
|
84
|
-
crashNumberLimit: 10
|
85
|
-
});
|
86
|
-
|
87
|
-
await this.instance.create({
|
88
|
-
...config,
|
89
|
-
plugins
|
90
|
-
});
|
91
|
-
|
92
|
-
this.instance.on('itemError', (...args) => {
|
93
|
-
console.error('Context item error:', ...args);
|
94
|
-
});
|
95
|
-
|
96
|
-
this.instancePromise.resolve(this.instance);
|
97
|
-
this.dispatchEvent(new CustomEvent('context-ready', { detail: this.instance }));
|
98
|
-
|
99
|
-
// Reinitialize connected editors.
|
100
|
-
await Promise.all(
|
101
|
-
[...this.#connectedEditors].map(editor => editor.reinitializeEditor())
|
102
|
-
);
|
103
|
-
}
|
104
|
-
|
105
|
-
async #getPlugins() {
|
106
|
-
const raw = this.getAttribute('plugins');
|
107
|
-
|
108
|
-
return loadAsyncImports(raw ? JSON.parse(raw) : []);
|
109
|
-
}
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Gets context configuration with resolved element references.
|
113
|
-
*
|
114
|
-
* @private
|
115
|
-
*/
|
116
|
-
#getConfig() {
|
117
|
-
const config = JSON.parse(this.getAttribute('config') || '{}');
|
118
|
-
|
119
|
-
return resolveElementReferences(config);
|
120
|
-
}
|
121
|
-
}
|
122
|
-
|
123
|
-
customElements.define('ckeditor-context-component', CKEditorContextComponent);
|
@@ -1,113 +0,0 @@
|
|
1
|
-
class CKEditorEditableComponent extends HTMLElement {
|
2
|
-
/**
|
3
|
-
* List of attributes that trigger updates when changed
|
4
|
-
*
|
5
|
-
* @static
|
6
|
-
* @returns {string[]} Array of attribute names to observe
|
7
|
-
*/
|
8
|
-
static get observedAttributes() {
|
9
|
-
return ['name'];
|
10
|
-
}
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Gets the name of this editable region
|
14
|
-
*
|
15
|
-
* @returns {string} The name attribute value
|
16
|
-
*/
|
17
|
-
get name() {
|
18
|
-
// The default value is set mainly for decoupled editors where the name is not required.
|
19
|
-
return this.getAttribute('name') || 'editable';
|
20
|
-
}
|
21
|
-
|
22
|
-
/**
|
23
|
-
* Gets the actual editable DOM element
|
24
|
-
* @returns {HTMLDivElement|null} The div element containing editable content
|
25
|
-
*/
|
26
|
-
get editableElement() {
|
27
|
-
return this.querySelector('div');
|
28
|
-
}
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Lifecycle callback when element is added to DOM
|
32
|
-
* Sets up the editable element and registers it with the parent editor
|
33
|
-
*
|
34
|
-
* @throws {Error} If not used as child of ckeditor-component
|
35
|
-
*/
|
36
|
-
connectedCallback() {
|
37
|
-
execIfDOMReady(() => {
|
38
|
-
const editorComponent = this.#queryEditorElement();
|
39
|
-
|
40
|
-
if (!editorComponent ) {
|
41
|
-
throw new Error('ckeditor-editable-component must be a child of ckeditor-component');
|
42
|
-
}
|
43
|
-
|
44
|
-
this.innerHTML = `<div>${this.innerHTML}</div>`;
|
45
|
-
this.style.display = 'block';
|
46
|
-
|
47
|
-
if (editorComponent.isDecoupled()) {
|
48
|
-
editorComponent.runAfterEditorReady(editor => {
|
49
|
-
this.appendChild(editor.ui.view[this.name].element);
|
50
|
-
});
|
51
|
-
} else {
|
52
|
-
if (!this.name) {
|
53
|
-
throw new Error('Editable component missing required "name" attribute');
|
54
|
-
}
|
55
|
-
|
56
|
-
editorComponent.editables[this.name] = this;
|
57
|
-
}
|
58
|
-
});
|
59
|
-
}
|
60
|
-
|
61
|
-
/**
|
62
|
-
* Lifecycle callback for attribute changes
|
63
|
-
* Handles name changes and propagates other attributes to editable element
|
64
|
-
*
|
65
|
-
* @param {string} name - Name of changed attribute
|
66
|
-
* @param {string|null} oldValue - Previous value
|
67
|
-
* @param {string|null} newValue - New value
|
68
|
-
*/
|
69
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
70
|
-
if (oldValue === newValue) {
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
|
74
|
-
if (name === 'name') {
|
75
|
-
if (!oldValue) {
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
|
79
|
-
const editorComponent = this.#queryEditorElement();
|
80
|
-
|
81
|
-
if (editorComponent) {
|
82
|
-
editorComponent.editables[newValue] = editorComponent.editables[oldValue];
|
83
|
-
delete editorComponent.editables[oldValue];
|
84
|
-
}
|
85
|
-
} else {
|
86
|
-
this.editableElement.setAttribute(name, newValue);
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Lifecycle callback when element is removed
|
92
|
-
* Un-registers this editable from the parent editor
|
93
|
-
*/
|
94
|
-
disconnectedCallback() {
|
95
|
-
const editorComponent = this.#queryEditorElement();
|
96
|
-
|
97
|
-
if (editorComponent) {
|
98
|
-
delete editorComponent.editables[this.name];
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
/**
|
103
|
-
* Finds the parent editor component
|
104
|
-
*
|
105
|
-
* @private
|
106
|
-
* @returns {CKEditorComponent|null} Parent editor component or null if not found
|
107
|
-
*/
|
108
|
-
#queryEditorElement() {
|
109
|
-
return this.closest('ckeditor-component') || document.body.querySelector('ckeditor-component');
|
110
|
-
}
|
111
|
-
}
|
112
|
-
|
113
|
-
customElements.define('ckeditor-editable-component', CKEditorEditableComponent);
|