@ckeditor/ckeditor5-watchdog 48.2.0-alpha.5 → 48.2.0-alpha.6
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/dist/editorwatchdog.d.ts +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/editorwatchdog.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -505,6 +505,16 @@ function isObject(structure) {
|
|
|
505
505
|
const rootConfig = updatedConfig.roots[rootName] || Object.create(null);
|
|
506
506
|
// Delete `initialData` as it is not needed. Data will be set by the watchdog based on `_watchdogInitialData`.
|
|
507
507
|
rootConfig.initialData = '';
|
|
508
|
+
// Copy root element name as it is created in the editor constructor.
|
|
509
|
+
rootConfig.modelElement = rootData.modelElement;
|
|
510
|
+
// Reuse previous DOM editable.
|
|
511
|
+
if (this._isUsingConfigBasedCreator) {
|
|
512
|
+
if (this._editables[rootName]?.isConnected) {
|
|
513
|
+
rootConfig.element = this._editables[rootName];
|
|
514
|
+
} else if (rootData.isLoaded && !rootConfig.element) {
|
|
515
|
+
Object.assign(rootConfig, getSavedRootEditableOptions(rootData.attributes));
|
|
516
|
+
}
|
|
517
|
+
}
|
|
508
518
|
if (rootData.isLoaded) {
|
|
509
519
|
rootConfig.lazyLoad = false;
|
|
510
520
|
} else {
|
|
@@ -646,6 +656,7 @@ function isObject(structure) {
|
|
|
646
656
|
data.roots[root.rootName] = {
|
|
647
657
|
content: JSON.stringify(Array.from(root.getChildren())),
|
|
648
658
|
attributes: JSON.stringify(Array.from(root.getAttributes())),
|
|
659
|
+
modelElement: root.name,
|
|
649
660
|
isLoaded: root._isLoaded
|
|
650
661
|
};
|
|
651
662
|
});
|
|
@@ -849,6 +860,34 @@ function isObject(structure) {
|
|
|
849
860
|
*/ function isElement(value) {
|
|
850
861
|
return isElement$2(value);
|
|
851
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* Reads the editable options persisted in the root's `$rootEditableOptions` model attribute and returns them as a
|
|
865
|
+
* {@link module:core/editor/editorconfig~RootConfig} partial. It is used to recreate a detached editable when the
|
|
866
|
+
* editor is restarted in the config-based creator mode.
|
|
867
|
+
*
|
|
868
|
+
* Only the known `placeholder`, `label` and `element` fields with a value are copied; their values are validated and
|
|
869
|
+
* normalized later by the editor constructor. Fields are returned only when set, so merging the result does not
|
|
870
|
+
* overwrite the existing restart config with `undefined`. A missing or tampered (non-object) value is dropped so it
|
|
871
|
+
* cannot break the restart.
|
|
872
|
+
*
|
|
873
|
+
* @param serializedAttributes The root attributes serialized as a JSON string of `[ key, value ]` entries.
|
|
874
|
+
*/ function getSavedRootEditableOptions(serializedAttributes) {
|
|
875
|
+
const { $rootEditableOptions: options } = Object.fromEntries(JSON.parse(serializedAttributes));
|
|
876
|
+
if (!options || typeof options != 'object') {
|
|
877
|
+
return {};
|
|
878
|
+
}
|
|
879
|
+
return {
|
|
880
|
+
...options.placeholder && {
|
|
881
|
+
placeholder: options.placeholder
|
|
882
|
+
},
|
|
883
|
+
...options.label && {
|
|
884
|
+
label: options.label
|
|
885
|
+
},
|
|
886
|
+
...options.element && {
|
|
887
|
+
element: options.element
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
}
|
|
852
891
|
|
|
853
892
|
const mainQueueId = Symbol('MainQueueId');
|
|
854
893
|
/**
|