@lobehub/editor 4.29.1 → 5.0.0-beta.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/README.md +86 -0
- package/es/codemirror/components/CopyButton.js +1 -1
- package/es/codemirror/components/LanguageSelect.js +1 -3
- package/es/codemirror/components/MoreOptions.js +1 -2
- package/es/codemirror/components/Toolbar.js +1 -2
- package/es/codemirror/components/style.js +1 -1
- package/es/codemirror/style.js +1 -1
- package/es/codemirror/theme.js +1 -1
- package/es/editor-kernel/index.d.ts +2 -2
- package/es/editor-kernel/index.js +2 -2
- package/es/editor-kernel/react/useAnchor.js +1 -1
- package/es/headless/index.d.ts +5 -2
- package/es/headless/index.js +20 -22
- package/es/headless.d.ts +6 -507
- package/es/headless.js +903 -408
- package/es/i-node-identity-service-BBC_bg97.d.ts +522 -0
- package/es/index.d.ts +4 -2
- package/es/index.js +5 -2
- package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.js +1 -1
- package/es/plugins/auto-complete/react/style.js +1 -1
- package/es/plugins/block/react/ReactBlockPlugin.js +2 -7
- package/es/plugins/block/react/style.js +1 -1
- package/es/plugins/code/react/CodeReactPlugin.js +1 -1
- package/es/plugins/code/react/style.js +1 -1
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +1 -1
- package/es/plugins/codeblock/react/style.js +1 -1
- package/es/plugins/codemirror-block/react/CodemirrorNode.js +1 -3
- package/es/plugins/codemirror-block/react/MermaidPreview.js +1 -2
- package/es/plugins/collapsible/react/ReactCollapsiblePlugin.js +1 -1
- package/es/plugins/collapsible/react/style.js +74 -64
- package/es/plugins/common/data-source/json-data-source.js +33 -25
- package/es/plugins/common/data-source/text-data-source.js +6 -1
- package/es/plugins/common/index.d.ts +3 -1
- package/es/plugins/common/node/node-id.d.ts +7 -0
- package/es/plugins/common/node/node-id.js +484 -0
- package/es/plugins/common/node/node-identity-policy.d.ts +26 -0
- package/es/plugins/common/node/node-identity-policy.js +68 -0
- package/es/plugins/common/plugin/index.js +28 -2
- package/es/plugins/common/react/Placeholder/style.js +1 -1
- package/es/plugins/common/react/ReactPlainText.js +1 -1
- package/es/plugins/common/react/style.js +1 -1
- package/es/plugins/common/service/i-node-identity-service.d.ts +19 -0
- package/es/plugins/common/service/i-node-identity-service.js +4 -0
- package/es/plugins/common/service/node-identity-service.js +87 -0
- package/es/plugins/common/utils/index.js +3 -1
- package/es/plugins/file/react/components/ReactFile.js +1 -1
- package/es/plugins/file/react/style.js +1 -1
- package/es/plugins/hr/react/components/HRNode.js +1 -1
- package/es/plugins/hr/react/style.js +1 -1
- package/es/plugins/image/react/components/Image.js +1 -3
- package/es/plugins/image/react/components/ImageEditPopover.js +1 -3
- package/es/plugins/image/react/components/LazyImage.js +1 -1
- package/es/plugins/image/react/components/ResizeHandle.js +1 -1
- package/es/plugins/image/react/components/style.js +1 -1
- package/es/plugins/image/react/style.js +1 -1
- package/es/plugins/link/react/ReactLinkPlugin.js +1 -1
- package/es/plugins/link/react/components/LinkEdit.js +1 -3
- package/es/plugins/link/react/components/LinkToolbar.js +1 -1
- package/es/plugins/link/react/style.js +1 -1
- package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.js +1 -1
- package/es/plugins/link-highlight/react/style.js +1 -1
- package/es/plugins/list/plugin/index.js +7 -1
- package/es/plugins/list/react/style.js +1 -1
- package/es/plugins/litexml/command/index.d.ts +2 -2
- package/es/plugins/litexml/command/index.js +464 -292
- package/es/plugins/litexml/command/symbols.d.ts +18 -7
- package/es/plugins/litexml/command/symbols.js +2 -1
- package/es/plugins/litexml/data-source/litexml-data-source.js +34 -31
- package/es/plugins/litexml/diff-validation.js +68 -14
- package/es/plugins/litexml/index.d.ts +2 -2
- package/es/plugins/litexml/node/identity-policy.js +91 -0
- package/es/plugins/litexml/plugin/index.js +6 -0
- package/es/plugins/litexml/react/DiffNodeToolbar/index.js +1 -3
- package/es/plugins/litexml/react/DiffNodeToolbar/style.js +1 -1
- package/es/plugins/litexml/react/TableRowDiffToolbar.js +1 -3
- package/es/plugins/litexml/react/style.js +1 -1
- package/es/plugins/litexml/table-cell-diff.js +4 -0
- package/es/plugins/litexml/table-row-diff.js +4 -0
- package/es/plugins/litexml/utils/index.js +10 -23
- package/es/plugins/markdown/command/index.js +77 -4
- package/es/plugins/markdown/data-source/markdown-data-source.js +6 -1
- package/es/plugins/markdown/react/index.js +1 -1
- package/es/plugins/math/react/components/MathEditorContainer.js +1 -1
- package/es/plugins/math/react/components/MathEditorContent.js +1 -2
- package/es/plugins/math/react/components/Placeholder.js +1 -3
- package/es/plugins/math/react/style.js +1 -1
- package/es/plugins/mention/react/components/Mention.js +1 -1
- package/es/plugins/mention/react/style.js +1 -1
- package/es/plugins/slash/react/components/DefaultSlashMenu.js +1 -2
- package/es/plugins/slash/service/i-slash-service.d.ts +2 -2
- package/es/plugins/table/react/TableActionMenu/ActionMenu.js +1 -1
- package/es/plugins/table/react/TableActionMenu/index.js +1 -1
- package/es/plugins/table/react/TableActionMenu/style.js +1 -1
- package/es/plugins/table/react/TableColController.js +1 -1
- package/es/plugins/table/react/TableController/style.js +1 -1
- package/es/plugins/table/react/TableControllerButton.js +2 -2
- package/es/plugins/table/react/TableControllerMenu.js +2 -2
- package/es/plugins/table/react/TableHoverActions/index.js +1 -2
- package/es/plugins/table/react/TableHoverActions/style.js +1 -1
- package/es/plugins/table/react/TableResize/index.js +2 -2
- package/es/plugins/table/react/TableResize/style.js +1 -1
- package/es/plugins/table/react/TableRowController.js +1 -1
- package/es/plugins/table/react/index.js +1 -1
- package/es/plugins/table/react/style.js +1 -1
- package/es/plugins/toolbar/react/index.js +1 -2
- package/es/plugins/toolbar/react/style.js +1 -1
- package/es/plugins/yjs/plugin/index.js +5 -3
- package/es/plugins/yjs/plugin/utils/editor-state.js +8 -1
- package/es/plugins/yjs/plugin/utils/node-identity.js +106 -0
- package/es/plugins/yjs/service/index.js +38 -4
- package/es/react/ChatInput/ChatInput.js +1 -2
- package/es/react/ChatInput/style.js +1 -1
- package/es/react/ChatInput/type.d.ts +1 -1
- package/es/react/ChatInputActionBar/ChatInputActionBar.js +1 -2
- package/es/react/ChatInputActionBar/style.js +1 -1
- package/es/react/ChatInputActionBar/type.d.ts +1 -1
- package/es/react/ChatInputActions/ChatInputActions.js +1 -2
- package/es/react/ChatInputActions/components/ActionItem.js +1 -1
- package/es/react/ChatInputActions/components/ActionRender.js +1 -1
- package/es/react/ChatInputActions/components/CollapsedActions.js +1 -2
- package/es/react/ChatInputActions/style.js +1 -1
- package/es/react/ChatInputActions/type.d.ts +4 -4
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +1 -3
- package/es/react/CodeLanguageSelect/style.js +1 -1
- package/es/react/CodeLanguageSelect/type.d.ts +1 -1
- package/es/react/FloatActions/FloatActions.js +1 -2
- package/es/react/FloatActions/components/ActionItem.js +1 -1
- package/es/react/FloatActions/components/ActionRender.js +1 -1
- package/es/react/FloatActions/components/CollapsedActions.js +1 -2
- package/es/react/FloatActions/style.js +1 -1
- package/es/react/FloatActions/type.d.ts +4 -4
- package/es/react/SendButton/SendButton.js +1 -2
- package/es/react/SendButton/components/SendIcon.js +1 -1
- package/es/react/SendButton/components/StopIcon.js +1 -1
- package/es/react/SendButton/style.js +1 -1
- package/es/react/SendButton/type.d.ts +1 -1
- package/es/renderer/LexicalDiff.js +1 -1
- package/es/renderer/LexicalRenderer.js +1 -1
- package/es/renderer/diff/compute.js +2 -2
- package/es/renderer/diff/style.js +1 -1
- package/es/renderer/engine/render-builtin-node.js +2 -2
- package/es/renderer/renderers/codeblock.js +1 -1
- package/es/renderer/renderers/horizontalrule.js +1 -1
- package/es/renderer/renderers/mermaid.js +1 -1
- package/es/renderer/style.js +1 -1
- package/es/{symbols-Do7jD4Tt.d.ts → symbols-Dyr9yyS0.d.ts} +18 -7
- package/package.json +6 -8
- package/scripts/postinstall-lexical-patch.cjs +0 -21
- package/patches/lexical@0.42.0.patch +0 -82
|
@@ -3,8 +3,8 @@ import { useLexicalComposerContext } from "../../../editor-kernel/react/react-co
|
|
|
3
3
|
import { MarkdownPlugin } from "../../markdown/plugin/index.js";
|
|
4
4
|
import { CodePlugin } from "../plugin/index.js";
|
|
5
5
|
import { styles } from "./style.js";
|
|
6
|
+
import { cx } from "@lobehub/ui";
|
|
6
7
|
import { useLayoutEffect } from "react";
|
|
7
|
-
import { cx } from "antd-style";
|
|
8
8
|
//#region src/plugins/code/react/CodeReactPlugin.tsx
|
|
9
9
|
const ReactCodePlugin = ({ className, enableHotkey = true }) => {
|
|
10
10
|
const [editor] = useLexicalComposerContext();
|
|
@@ -3,8 +3,8 @@ import { useLexicalComposerContext } from "../../../editor-kernel/react/react-co
|
|
|
3
3
|
import { MarkdownPlugin } from "../../markdown/plugin/index.js";
|
|
4
4
|
import { CodeblockPlugin } from "../plugin/index.js";
|
|
5
5
|
import { styles } from "./style.js";
|
|
6
|
+
import { cx } from "@lobehub/ui";
|
|
6
7
|
import { useLayoutEffect } from "react";
|
|
7
|
-
import { cx } from "antd-style";
|
|
8
8
|
//#region src/plugins/codeblock/react/ReactCodeblockPlugin.tsx
|
|
9
9
|
const ReactCodeblockPlugin = ({ theme, shikiTheme }) => {
|
|
10
10
|
const [editor] = useLexicalComposerContext();
|
|
@@ -8,12 +8,10 @@ import { SELECT_AFTER_CODEMIRROR_COMMAND, SELECT_BEFORE_CODEMIRROR_COMMAND } fro
|
|
|
8
8
|
import { useLexicalNodeSelection } from "../../../editor-kernel/react/useLexicalNodeSelection.js";
|
|
9
9
|
import MermaidPreview from "./MermaidPreview.js";
|
|
10
10
|
import { useCodemirrorEditLock } from "./useCodemirrorEditLock.js";
|
|
11
|
-
import { ActionIcon } from "@lobehub/ui
|
|
11
|
+
import { ActionIcon, Block, cx } from "@lobehub/ui";
|
|
12
12
|
import { CodeXml, Eye } from "lucide-react";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
import { Block } from "@lobehub/ui";
|
|
16
|
-
import { cx } from "antd-style";
|
|
17
15
|
import { debounce } from "es-toolkit/compat";
|
|
18
16
|
import { $getSelection, $setSelection, COMMAND_PRIORITY_CRITICAL, KEY_DOWN_COMMAND } from "lexical";
|
|
19
17
|
import { mergeRegister } from "@lexical/utils";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { Mermaid, cssVar } from "@lobehub/ui";
|
|
2
3
|
import { useEffect, useState } from "react";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { Mermaid } from "@lobehub/ui";
|
|
5
|
-
import { cssVar } from "antd-style";
|
|
6
5
|
//#region src/plugins/codemirror-block/react/MermaidPreview.tsx
|
|
7
6
|
const MermaidPreview = ({ code }) => {
|
|
8
7
|
const [error, setError] = useState(null);
|
|
@@ -3,8 +3,8 @@ import { useLexicalComposerContext } from "../../../editor-kernel/react/react-co
|
|
|
3
3
|
import { MarkdownPlugin } from "../../markdown/plugin/index.js";
|
|
4
4
|
import { CollapsiblePlugin } from "../plugin/index.js";
|
|
5
5
|
import { styles } from "./style.js";
|
|
6
|
+
import { cx } from "@lobehub/ui";
|
|
6
7
|
import { useLayoutEffect } from "react";
|
|
7
|
-
import { cx } from "antd-style";
|
|
8
8
|
//#region src/plugins/collapsible/react/ReactCollapsiblePlugin.tsx
|
|
9
9
|
const ReactCollapsiblePlugin = ({ className }) => {
|
|
10
10
|
const [editor] = useLexicalComposerContext();
|
|
@@ -1,67 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createStaticStyles } from "@lobehub/ui";
|
|
2
2
|
//#region src/plugins/collapsible/react/style.ts
|
|
3
|
-
const styles = css`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
3
|
+
const styles = createStaticStyles(({ css }) => css`
|
|
4
|
+
position: relative;
|
|
5
|
+
|
|
6
|
+
margin-block: 12px;
|
|
7
|
+
margin-inline: 0;
|
|
8
|
+
padding-block: 14px;
|
|
9
|
+
padding-inline: 42px 16px;
|
|
10
|
+
border: 1px solid rgb(51 103 153 / 72%);
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
|
|
13
|
+
&[data-collapsible-collapsed='true'] {
|
|
14
|
+
padding-block: 10px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-collapsible-toggle='true'] {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
|
|
20
|
+
position: absolute;
|
|
21
|
+
inset-block-start: 20px;
|
|
22
|
+
inset-inline-start: 16px;
|
|
23
|
+
|
|
24
|
+
width: 14px;
|
|
25
|
+
height: 14px;
|
|
26
|
+
padding: 0;
|
|
27
|
+
border: 0;
|
|
28
|
+
|
|
29
|
+
color: currentcolor;
|
|
30
|
+
|
|
31
|
+
background: transparent;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&[data-collapsible-collapsed='true'] > [data-collapsible-toggle='true'] {
|
|
35
|
+
inset-block-start: 15px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-collapsible-toggle='true']::before {
|
|
39
|
+
content: '';
|
|
40
|
+
|
|
41
|
+
display: block;
|
|
42
|
+
|
|
43
|
+
width: 0;
|
|
44
|
+
height: 0;
|
|
45
|
+
margin-block: 3px 0;
|
|
46
|
+
margin-inline: 2px 0;
|
|
47
|
+
border-style: solid;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&[data-collapsible-collapsed='false'] > [data-collapsible-toggle='true']::before {
|
|
51
|
+
border-color: currentcolor transparent transparent;
|
|
52
|
+
border-width: 7px 5px 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&[data-collapsible-collapsed='true'] > [data-collapsible-toggle='true']::before {
|
|
56
|
+
border-color: transparent transparent transparent currentcolor;
|
|
57
|
+
border-width: 5px 0 5px 7px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[data-collapsible-content='true'] > *:first-child {
|
|
61
|
+
margin-block-start: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[data-collapsible-content='true'] > *:last-child {
|
|
65
|
+
margin-block-end: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&[data-collapsible-collapsed='true'] > [data-collapsible-content='true'] > *:first-child {
|
|
69
|
+
margin-block-end: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&[data-collapsible-collapsed='true'] > [data-collapsible-content='true'] > *:not(:first-child) {
|
|
73
|
+
display: none !important;
|
|
74
|
+
}
|
|
75
|
+
`);
|
|
66
76
|
//#endregion
|
|
67
77
|
export { styles };
|
|
@@ -1,18 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $normalizeNodeIds, init_node_id, migrateSerializedNodeIds } from "../node/node-id.js";
|
|
2
2
|
import { exportNodeToJSON, init_utils } from "../utils/index.js";
|
|
3
3
|
import DataSource from "../../../editor-kernel/data-source.js";
|
|
4
4
|
import { cursorNodeSerialized } from "../node/cursor.js";
|
|
5
|
-
import { $parseSerializedNodeImpl } from "../../litexml/utils/index.js";
|
|
6
5
|
import { $isTableSelection } from "@lexical/table";
|
|
7
|
-
import { $getCharacterOffsets, $getNodeByKey, $getRoot, $getSelection, $isElementNode, $isRangeSelection, $isTextNode, IS_CODE
|
|
6
|
+
import { $getCharacterOffsets, $getNodeByKey, $getRoot, $getSelection, $isElementNode, $isRangeSelection, $isTextNode, IS_CODE } from "lexical";
|
|
8
7
|
//#region src/plugins/common/data-source/json-data-source.ts
|
|
9
|
-
|
|
8
|
+
init_node_id();
|
|
10
9
|
init_utils();
|
|
11
10
|
var JSONDataSource = class extends DataSource {
|
|
12
11
|
read(editor, data, options = {}) {
|
|
13
|
-
let
|
|
14
|
-
if (typeof data === "string")
|
|
15
|
-
else
|
|
12
|
+
let inputData;
|
|
13
|
+
if (typeof data === "string") inputData = JSON.parse(data);
|
|
14
|
+
else inputData = data;
|
|
15
|
+
const dataObj = structuredClone(inputData);
|
|
16
|
+
if (!(options.keepId ?? dataObj.keepId ?? false)) {
|
|
17
|
+
const stripNodeIds = (node) => {
|
|
18
|
+
delete node.id;
|
|
19
|
+
const state = node.$;
|
|
20
|
+
if (state && typeof state === "object" && state.properties) {
|
|
21
|
+
const properties = { ...state.properties };
|
|
22
|
+
delete properties.nodeId;
|
|
23
|
+
if (Object.keys(properties).length > 0) node.$ = {
|
|
24
|
+
...state,
|
|
25
|
+
properties
|
|
26
|
+
};
|
|
27
|
+
else {
|
|
28
|
+
const nextState = { ...state };
|
|
29
|
+
delete nextState.properties;
|
|
30
|
+
if (Object.keys(nextState).length > 0) node.$ = nextState;
|
|
31
|
+
else delete node.$;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(node.children)) node.children.forEach((child) => stripNodeIds(child));
|
|
35
|
+
};
|
|
36
|
+
stripNodeIds(dataObj.root);
|
|
37
|
+
} else migrateSerializedNodeIds(dataObj.root);
|
|
16
38
|
const process = (node) => {
|
|
17
39
|
for (let i = 0; i < node.children.length; i++) {
|
|
18
40
|
const child = node.children[i];
|
|
@@ -34,24 +56,10 @@ var JSONDataSource = class extends DataSource {
|
|
|
34
56
|
}
|
|
35
57
|
};
|
|
36
58
|
process(dataObj.root);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let maxId = -1;
|
|
42
|
-
Array.from(state._nodeMap.keys()).forEach((key) => {
|
|
43
|
-
if (key === "root") return;
|
|
44
|
-
const numericKey = Number(key);
|
|
45
|
-
if (Number.isInteger(numericKey) && numericKey >= 0) maxId = Math.max(maxId, numericKey);
|
|
46
|
-
});
|
|
47
|
-
resetRandomKey(maxId + 1);
|
|
48
|
-
state._nodeMap.set(root.getKey(), root);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error(error);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
editor.setEditorState(state);
|
|
54
|
-
} else editor.setEditorState(editor.parseEditorState({ root: dataObj.root }));
|
|
59
|
+
const editorState = editor.parseEditorState({ root: dataObj.root }, () => {
|
|
60
|
+
$normalizeNodeIds($getRoot());
|
|
61
|
+
});
|
|
62
|
+
editor.setEditorState(editorState);
|
|
55
63
|
}
|
|
56
64
|
write(editor, options) {
|
|
57
65
|
if (options?.selection) return editor.getEditorState().read(() => {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { INodeHelper, init_helper } from "../../../editor-kernel/inode/helper.js";
|
|
2
|
+
import { $normalizeNodeIds, init_node_id } from "../node/node-id.js";
|
|
2
3
|
import DataSource from "../../../editor-kernel/data-source.js";
|
|
3
4
|
import { $getRoot, $getSelection } from "lexical";
|
|
4
5
|
//#region src/plugins/common/data-source/text-data-source.ts
|
|
5
6
|
init_helper();
|
|
7
|
+
init_node_id();
|
|
6
8
|
var TextDataSource = class extends DataSource {
|
|
7
9
|
read(editor, data) {
|
|
8
10
|
if (typeof data !== "string") throw new Error("Invalid data type " + typeof data);
|
|
@@ -16,7 +18,10 @@ var TextDataSource = class extends DataSource {
|
|
|
16
18
|
}
|
|
17
19
|
INodeHelper.appendChild(rootNode, paragraph);
|
|
18
20
|
});
|
|
19
|
-
editor.
|
|
21
|
+
const editorState = editor.parseEditorState({ root: rootNode }, () => {
|
|
22
|
+
$normalizeNodeIds($getRoot());
|
|
23
|
+
});
|
|
24
|
+
editor.setEditorState(editorState);
|
|
20
25
|
}
|
|
21
26
|
write(editor, options) {
|
|
22
27
|
if (options?.selection) return editor.getEditorState().read(() => {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { $getNodeById, $getNodeId } from "./node/node-id.js";
|
|
2
|
+
import { INodeIdentityService, NodeIdentitySnapshot } from "./service/i-node-identity-service.js";
|
|
1
3
|
import { INSERT_HEADING_COMMAND, INSERT_QUOTE_COMMAND } from "./command/index.js";
|
|
2
4
|
import { $createCursorNode, $isCardLikeElementNode, $isCursorNode, CardLikeElementNode, cursorNodeSerialized } from "./node/cursor.js";
|
|
3
5
|
import { CommonPlugin, CommonPluginOptions } from "./plugin/index.js";
|
|
@@ -5,4 +7,4 @@ import { ReactEditorContentProps, ReactPlainTextProps } from "./react/type.js";
|
|
|
5
7
|
import ReactEditorContent from "./react/ReactEditorContent.js";
|
|
6
8
|
import ReactPlainText from "./react/ReactPlainText.js";
|
|
7
9
|
import "./react/index.js";
|
|
8
|
-
export { $createCursorNode, $isCardLikeElementNode, $isCursorNode, CardLikeElementNode, CommonPlugin, CommonPluginOptions, INSERT_HEADING_COMMAND, INSERT_QUOTE_COMMAND, ReactEditorContent, ReactEditorContentProps, ReactPlainText, ReactPlainTextProps, cursorNodeSerialized };
|
|
10
|
+
export { $createCursorNode, $getNodeById, $getNodeId, $isCardLikeElementNode, $isCursorNode, CardLikeElementNode, CommonPlugin, CommonPluginOptions, INSERT_HEADING_COMMAND, INSERT_QUOTE_COMMAND, INodeIdentityService, type NodeIdentitySnapshot, ReactEditorContent, ReactEditorContentProps, ReactPlainText, ReactPlainTextProps, cursorNodeSerialized };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EditorState, LexicalEditor, LexicalNode } from "lexical";
|
|
2
|
+
//#region src/plugins/common/node/node-id.d.ts
|
|
3
|
+
declare function $getNodeId(node: LexicalNode): string | undefined;
|
|
4
|
+
/** Find the active representation of a logical ID in a Lexical read/update context. */
|
|
5
|
+
declare function $getNodeById(nodeId: string, root?: LexicalNode): LexicalNode | null;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { $getNodeById, $getNodeId };
|