@lobehub/editor 4.23.1 โ 4.24.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.
- package/es/editor-kernel/index.js +1 -0
- package/es/editor-kernel/kernel.js +47 -40
- package/es/editor-kernel/react/useLexicalNodeSelection.js +4 -2
- package/es/headless.js +203 -177
- package/es/index.js +5 -2
- package/es/plugins/auto-complete/plugin/index.js +4 -2
- package/es/plugins/block/react/ReactBlockPlugin.js +5 -4
- package/es/plugins/codeblock/command/index.js +8 -6
- package/es/plugins/codeblock/plugin/index.js +4 -2
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +2 -1
- package/es/plugins/codemirror-block/command/index.js +8 -6
- package/es/plugins/common/data-source/json-data-source.js +5 -4
- package/es/plugins/common/plugin/index.js +1 -3
- package/es/plugins/common/plugin/paste-handler.js +2 -1
- package/es/plugins/hr/command/index.js +2 -1
- package/es/plugins/image/react/components/BrokenImage.js +2 -1
- package/es/plugins/image/react/components/Image.js +18 -15
- package/es/plugins/image/react/components/ImageEditPopover.js +42 -41
- package/es/plugins/image/react/components/ResizeHandle.js +1 -3
- package/es/plugins/link/node/LinkNode.js +4 -2
- package/es/plugins/link/plugin/registry.js +17 -12
- package/es/plugins/link/react/components/LinkEdit.js +9 -8
- package/es/plugins/list/plugin/index.js +1 -4
- package/es/plugins/list/utils/index.js +4 -2
- package/es/plugins/litexml/command/index.js +69 -62
- package/es/plugins/litexml/node/DiffNode.js +14 -10
- package/es/plugins/litexml/plugin/index.js +6 -12
- package/es/plugins/markdown/data-source/markdown-data-source.js +5 -4
- package/es/plugins/markdown/plugin/index.js +2 -1
- package/es/plugins/markdown/service/transformers.js +4 -2
- package/es/plugins/markdown/utils/index.js +10 -8
- package/es/plugins/math/command/index.js +4 -2
- package/es/plugins/math/plugin/index.d.ts +2 -0
- package/es/plugins/math/plugin/index.js +2 -2
- package/es/plugins/math/react/components/MathInline.js +14 -13
- package/es/plugins/math/react/index.js +4 -3
- package/es/plugins/math/react/type.d.ts +2 -0
- package/es/plugins/slash/plugin/index.js +13 -4
- package/es/plugins/slash/react/components/DefaultSlashMenu.js +2 -1
- package/es/plugins/slash/react/components/menuLoading.js +4 -0
- package/es/plugins/slash/service/i-slash-service.d.ts +6 -1
- package/es/plugins/slash/service/i-slash-service.js +16 -2
- package/es/plugins/slash/utils/utils.js +1 -1
- package/es/plugins/table/react/TableActionMenu/ActionMenu.js +69 -67
- package/es/plugins/table/react/TableColController.js +29 -26
- package/es/plugins/table/react/TableHoverActions/index.js +0 -2
- package/es/plugins/table/react/TableRowController.js +29 -26
- package/es/plugins/table/utils/index.js +4 -2
- package/es/react/Editor/Editor.js +24 -23
- package/es/react/hooks/useEditorState/index.js +28 -21
- package/es/react/hooks/useEditorState/utils.js +2 -1
- package/es/renderer/engine/render-builtin-node.js +26 -18
- package/es/renderer/engine/render-tree.js +4 -1
- package/es/renderer/renderers/mermaid.js +2 -1
- package/package.json +1 -1
|
@@ -384,17 +384,19 @@ var init_kernel = __esmMin((() => {
|
|
|
384
384
|
return datasource.write(this.editor, { selection: true });
|
|
385
385
|
}
|
|
386
386
|
registerDecorator(name, decorator) {
|
|
387
|
-
if (this.decorators[name])
|
|
388
|
-
this.
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
} else {
|
|
392
|
-
if (this.decorators[name] === decorator) {
|
|
393
|
-
this.logger.warn(`[Editor] Decorator "${name}" is already registered with the same function`);
|
|
387
|
+
if (this.decorators[name]) {
|
|
388
|
+
if (this.hotReloadMode) {
|
|
389
|
+
this.logger.warn(`๐ Hot reload: decorator "${name}"`);
|
|
390
|
+
this.decorators[name] = decorator;
|
|
394
391
|
return this;
|
|
392
|
+
} else {
|
|
393
|
+
if (this.decorators[name] === decorator) {
|
|
394
|
+
this.logger.warn(`[Editor] Decorator "${name}" is already registered with the same function`);
|
|
395
|
+
return this;
|
|
396
|
+
}
|
|
397
|
+
this.logger.error(`[Editor] Attempting to register duplicate decorator "${name}". Enable hot reload mode if this is intended.`);
|
|
398
|
+
throw new Error(`Decorator with name "${name}" is already registered.`);
|
|
395
399
|
}
|
|
396
|
-
this.logger.error(`[Editor] Attempting to register duplicate decorator "${name}". Enable hot reload mode if this is intended.`);
|
|
397
|
-
throw new Error(`Decorator with name "${name}" is already registered.`);
|
|
398
400
|
}
|
|
399
401
|
this.decorators[name] = decorator;
|
|
400
402
|
this.logger.debug(`๐ญ Decorator: ${name}`);
|
|
@@ -435,31 +437,34 @@ var init_kernel = __esmMin((() => {
|
|
|
435
437
|
}
|
|
436
438
|
registerPlugin(plugin, config) {
|
|
437
439
|
const findPlugin = this.plugins.find((p) => p.pluginName === plugin.pluginName);
|
|
438
|
-
if (findPlugin)
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
440
|
+
if (findPlugin) {
|
|
441
|
+
if (findPlugin !== plugin) {
|
|
442
|
+
if (this.hotReloadMode) {
|
|
443
|
+
this.logger.warn(`๐ Hot reload: plugin "${plugin.pluginName}"`);
|
|
444
|
+
const index = this.plugins.findIndex((p) => p.pluginName === plugin.pluginName);
|
|
445
|
+
if (index !== -1) {
|
|
446
|
+
this.plugins.splice(index, 1);
|
|
447
|
+
const instanceIndex = this.pluginsInstances.findIndex((instance) => {
|
|
448
|
+
return instance.constructor.pluginName === plugin.pluginName;
|
|
449
|
+
});
|
|
450
|
+
if (instanceIndex !== -1) {
|
|
451
|
+
const oldInstance = this.pluginsInstances[instanceIndex];
|
|
452
|
+
if (oldInstance instanceof KernelPlugin) {
|
|
453
|
+
const decoratorNames = oldInstance.getRegisteredDecorators();
|
|
454
|
+
for (const decoratorName of decoratorNames) {
|
|
455
|
+
this.unregisterDecorator(decoratorName);
|
|
456
|
+
this.logger.debug(`๐งจ Cleanup: decorator "${decoratorName}"`);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (oldInstance.destroy) oldInstance.destroy();
|
|
460
|
+
this.pluginsInstances.splice(instanceIndex, 1);
|
|
453
461
|
}
|
|
454
462
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
463
|
+
} else throw new Error(`Plugin with name "${plugin.pluginName}" is already registered with a different implementation.`);
|
|
464
|
+
} else {
|
|
465
|
+
if (config !== void 0) this.pluginsConfig.set(plugin, config);
|
|
466
|
+
return this;
|
|
458
467
|
}
|
|
459
|
-
} else throw new Error(`Plugin with name "${plugin.pluginName}" is already registered with a different implementation.`);
|
|
460
|
-
else {
|
|
461
|
-
if (config !== void 0) this.pluginsConfig.set(plugin, config);
|
|
462
|
-
return this;
|
|
463
468
|
}
|
|
464
469
|
this.pluginsConfig.set(plugin, config || {});
|
|
465
470
|
this.plugins.push(plugin);
|
|
@@ -526,17 +531,19 @@ var init_kernel = __esmMin((() => {
|
|
|
526
531
|
}
|
|
527
532
|
registerService(serviceId, service) {
|
|
528
533
|
const serviceIdString = serviceId.__serviceId;
|
|
529
|
-
if (this.serviceMap.has(serviceIdString))
|
|
530
|
-
this.
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
} else {
|
|
534
|
-
if (this.serviceMap.get(serviceIdString) === service) {
|
|
535
|
-
this.logger.warn(`[Editor] Service "${serviceIdString}" is already registered with the same instance`);
|
|
534
|
+
if (this.serviceMap.has(serviceIdString)) {
|
|
535
|
+
if (this.hotReloadMode) {
|
|
536
|
+
this.logger.warn(`๐ Hot reload: service "${serviceIdString}"`);
|
|
537
|
+
this.serviceMap.set(serviceIdString, service);
|
|
536
538
|
return;
|
|
539
|
+
} else {
|
|
540
|
+
if (this.serviceMap.get(serviceIdString) === service) {
|
|
541
|
+
this.logger.warn(`[Editor] Service "${serviceIdString}" is already registered with the same instance`);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
this.logger.error(`[Editor] Attempting to register duplicate service "${serviceIdString}". Enable hot reload mode if this is intended.`);
|
|
545
|
+
throw new Error(`Service with ID "${serviceIdString}" is already registered.`);
|
|
537
546
|
}
|
|
538
|
-
this.logger.error(`[Editor] Attempting to register duplicate service "${serviceIdString}". Enable hot reload mode if this is intended.`);
|
|
539
|
-
throw new Error(`Service with ID "${serviceIdString}" is already registered.`);
|
|
540
547
|
}
|
|
541
548
|
this.serviceMap.set(serviceIdString, service);
|
|
542
549
|
this.logger.debug(`๐ง Service: ${serviceIdString}`);
|
|
@@ -68,8 +68,10 @@ function useLexicalNodeSelection(key) {
|
|
|
68
68
|
selection = $createNodeSelection();
|
|
69
69
|
$setSelection(selection);
|
|
70
70
|
}
|
|
71
|
-
if ($isNodeSelection(selection))
|
|
72
|
-
|
|
71
|
+
if ($isNodeSelection(selection)) {
|
|
72
|
+
if (selected) selection.add(key);
|
|
73
|
+
else selection.delete(key);
|
|
74
|
+
}
|
|
73
75
|
});
|
|
74
76
|
}, [lexicalEditor, key]),
|
|
75
77
|
useCallback(() => {
|