@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
|
@@ -6,9 +6,9 @@ import { CommonPlugin } from "../plugin/index.js";
|
|
|
6
6
|
import { useDecorators } from "../../../editor-kernel/react/useDecorators.js";
|
|
7
7
|
import Placeholder from "./Placeholder/index.js";
|
|
8
8
|
import { styles, themeStyles } from "./style.js";
|
|
9
|
+
import { cx } from "@lobehub/ui";
|
|
9
10
|
import { Children, memo, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { cx } from "antd-style";
|
|
12
12
|
import { COMMAND_PRIORITY_EDITOR, KEY_DOWN_COMMAND } from "lexical";
|
|
13
13
|
//#region src/plugins/common/react/ReactPlainText.tsx
|
|
14
14
|
const ReactPlainText = memo(({ style, children, theme = {}, onChange, editable, className, variant, enableHotkey = true, enablePasteMarkdown = true, autoFormatMarkdown = true, markdownOption = true, pasteAsPlainText = false, pasteMarkdownAutoConvertThreshold, pasteVSCodeAsCodeBlock = true, onKeyDown, onFocus, onBlur, autoFocus, onPressEnter, onCompositionStart, onCompositionEnd, onContextMenu, onTextChange }) => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IServiceID } from "../../../types/kernel.js";
|
|
2
|
+
import "../../../types/index.js";
|
|
3
|
+
//#region src/plugins/common/service/i-node-identity-service.d.ts
|
|
4
|
+
/** A detached, immutable description of the currently active logical node. */
|
|
5
|
+
interface NodeIdentitySnapshot {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** Native Lexical text; a review container can include both pending sides. */
|
|
8
|
+
readonly textContent: string;
|
|
9
|
+
readonly type: string;
|
|
10
|
+
}
|
|
11
|
+
interface INodeIdentityService {
|
|
12
|
+
/** Read the last committed editor state without retaining a LexicalNode. */
|
|
13
|
+
getNodeById(nodeId: string): Readonly<NodeIdentitySnapshot> | null;
|
|
14
|
+
/** Subscribe to committed updates; query the service in the callback. */
|
|
15
|
+
subscribe(listener: () => void): () => void;
|
|
16
|
+
}
|
|
17
|
+
declare const INodeIdentityService: IServiceID<INodeIdentityService>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { INodeIdentityService, NodeIdentitySnapshot };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createDebugLogger, init_debug } from "../../../utils/debug.js";
|
|
2
|
+
import { getNodeIdentityPolicyRevision, init_node_identity_policy, subscribeNodeIdentityPolicy } from "../node/node-identity-policy.js";
|
|
3
|
+
import { $getActiveNodeIdKeys, $getNodeId, init_node_id } from "../node/node-id.js";
|
|
4
|
+
import { $getNodeByKey } from "lexical";
|
|
5
|
+
//#region src/plugins/common/service/node-identity-service.ts
|
|
6
|
+
init_node_id();
|
|
7
|
+
init_node_identity_policy();
|
|
8
|
+
init_debug();
|
|
9
|
+
const logger = createDebugLogger("service", "node-identity");
|
|
10
|
+
/** Implementation owned by CommonPlugin; external callers use INodeIdentityService. */
|
|
11
|
+
var NodeIdentityService = class {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.editor = null;
|
|
14
|
+
this.indexes = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
16
|
+
this.bindingToken = null;
|
|
17
|
+
this.unregisterBinding = null;
|
|
18
|
+
}
|
|
19
|
+
bindEditor(editor) {
|
|
20
|
+
this.unregisterBinding?.();
|
|
21
|
+
const bindingToken = {};
|
|
22
|
+
this.bindingToken = bindingToken;
|
|
23
|
+
this.indexes = /* @__PURE__ */ new WeakMap();
|
|
24
|
+
this.editor = editor;
|
|
25
|
+
const unregisterUpdate = editor.registerUpdateListener(({ editorState, prevEditorState }) => {
|
|
26
|
+
if (editorState !== prevEditorState) this.notify();
|
|
27
|
+
});
|
|
28
|
+
const unregisterPolicy = subscribeNodeIdentityPolicy(editor, () => this.notify());
|
|
29
|
+
let active = true;
|
|
30
|
+
const unregister = () => {
|
|
31
|
+
if (!active) return;
|
|
32
|
+
active = false;
|
|
33
|
+
unregisterUpdate();
|
|
34
|
+
unregisterPolicy();
|
|
35
|
+
};
|
|
36
|
+
this.unregisterBinding = unregister;
|
|
37
|
+
return () => {
|
|
38
|
+
unregister();
|
|
39
|
+
if (this.bindingToken !== bindingToken) return;
|
|
40
|
+
this.bindingToken = null;
|
|
41
|
+
this.unregisterBinding = null;
|
|
42
|
+
this.editor = null;
|
|
43
|
+
this.indexes = /* @__PURE__ */ new WeakMap();
|
|
44
|
+
this.listeners.clear();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
getNodeById(nodeId) {
|
|
48
|
+
if (typeof nodeId !== "string" || !nodeId.trim()) return null;
|
|
49
|
+
const editor = this.editor;
|
|
50
|
+
if (!editor) return null;
|
|
51
|
+
const editorState = editor.getEditorState();
|
|
52
|
+
const revision = getNodeIdentityPolicyRevision(editor);
|
|
53
|
+
let index = this.indexes.get(editorState);
|
|
54
|
+
if (!index || index.revision !== revision) {
|
|
55
|
+
index = {
|
|
56
|
+
keys: editorState.read(() => $getActiveNodeIdKeys(), { editor }),
|
|
57
|
+
revision
|
|
58
|
+
};
|
|
59
|
+
this.indexes.set(editorState, index);
|
|
60
|
+
}
|
|
61
|
+
const key = index.keys.get(nodeId);
|
|
62
|
+
if (!key) return null;
|
|
63
|
+
return editorState.read(() => {
|
|
64
|
+
const node = $getNodeByKey(key);
|
|
65
|
+
const id = node && $getNodeId(node);
|
|
66
|
+
return node && id === nodeId ? Object.freeze({
|
|
67
|
+
id,
|
|
68
|
+
textContent: node.getTextContent(),
|
|
69
|
+
type: node.getType()
|
|
70
|
+
}) : null;
|
|
71
|
+
}, { editor });
|
|
72
|
+
}
|
|
73
|
+
subscribe(listener) {
|
|
74
|
+
this.listeners.add(listener);
|
|
75
|
+
return () => this.listeners.delete(listener);
|
|
76
|
+
}
|
|
77
|
+
notify() {
|
|
78
|
+
const listeners = Array.from(this.listeners);
|
|
79
|
+
for (const listener of listeners) try {
|
|
80
|
+
listener();
|
|
81
|
+
} catch (error) {
|
|
82
|
+
logger.error("Node identity subscriber failed:", error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { NodeIdentityService };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { INodeHelper, init_helper } from "../../../editor-kernel/inode/helper.js";
|
|
3
|
+
import { $getNodeId, init_node_id } from "../node/node-id.js";
|
|
3
4
|
import { $isTableCellNode, $isTableNode } from "@lexical/table";
|
|
4
5
|
import { $getRoot, $isDecoratorNode, $isElementNode, $isParagraphNode, $isRangeSelection, $isTextNode } from "lexical";
|
|
5
6
|
import { $isQuoteNode } from "@lexical/rich-text";
|
|
@@ -99,7 +100,7 @@ function $isCursorInQuote(selection) {
|
|
|
99
100
|
function exportNodeToJSON(node) {
|
|
100
101
|
const serializedNode = node.exportJSON();
|
|
101
102
|
const nodeClass = node.constructor;
|
|
102
|
-
serializedNode.id = node
|
|
103
|
+
serializedNode.id = $getNodeId(node);
|
|
103
104
|
if (serializedNode.type !== nodeClass.getType()) throw new Error(`LexicalNode: Node ${nodeClass.name} does not match the serialized type. Check if .exportJSON() is implemented and it is returning the correct type.`);
|
|
104
105
|
if ($isElementNode(node)) {
|
|
105
106
|
const serializedChildren = serializedNode.children;
|
|
@@ -115,6 +116,7 @@ function exportNodeToJSON(node) {
|
|
|
115
116
|
var sampleReader, createBlockNode;
|
|
116
117
|
var init_utils = __esmMin((() => {
|
|
117
118
|
init_helper();
|
|
119
|
+
init_node_id();
|
|
118
120
|
sampleReader = (format, xmlElement, children) => {
|
|
119
121
|
children.forEach((child) => {
|
|
120
122
|
if (INodeHelper.isTextNode(child)) child.format = (child.format || 0) | format;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
2
2
|
import { useLexicalNodeSelection } from "../../../../editor-kernel/react/useLexicalNodeSelection.js";
|
|
3
|
+
import { Center, MaterialFileTypeIcon } from "@lobehub/ui";
|
|
3
4
|
import { useCallback, useEffect, useRef } from "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { Center, MaterialFileTypeIcon } from "@lobehub/ui";
|
|
6
6
|
import { CLICK_COMMAND, COMMAND_PRIORITY_LOW } from "lexical";
|
|
7
7
|
//#region src/plugins/file/react/components/ReactFile.tsx
|
|
8
8
|
const ReactFile = ({ className, editor, node }) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLexicalNodeSelection } from "../../../../editor-kernel/react/useLexicalNodeSelection.js";
|
|
3
3
|
import { styles } from "../style.js";
|
|
4
|
+
import { cx } from "@lobehub/ui";
|
|
4
5
|
import { useEffect } from "react";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { cx } from "antd-style";
|
|
7
7
|
import { CLICK_COMMAND, COMMAND_PRIORITY_LOW } from "lexical";
|
|
8
8
|
import { mergeRegister } from "@lexical/utils";
|
|
9
9
|
//#region src/plugins/hr/react/components/HRNode.tsx
|
|
@@ -7,12 +7,10 @@ import BrokenImage from "./BrokenImage.js";
|
|
|
7
7
|
import ImageEditPopover from "./ImageEditPopover.js";
|
|
8
8
|
import LazyImage from "./LazyImage.js";
|
|
9
9
|
import { ResizeHandle } from "./ResizeHandle.js";
|
|
10
|
-
import { ActionIcon } from "@lobehub/ui
|
|
10
|
+
import { ActionIcon, Icon, cx, useImagePreview } from "@lobehub/ui";
|
|
11
11
|
import { LoaderCircleIcon, ZoomInIcon } from "lucide-react";
|
|
12
12
|
import { Suspense, memo, useCallback, useMemo, useRef, useState } from "react";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { Icon, useImagePreview } from "@lobehub/ui";
|
|
15
|
-
import { cx } from "antd-style";
|
|
16
14
|
import { COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND } from "lexical";
|
|
17
15
|
//#region src/plugins/image/react/components/Image.tsx
|
|
18
16
|
function getResizedImageWidth(startWidth, deltaX, maxWidth) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { useLexicalEditor } from "../../../../editor-kernel/react/useLexicalEditor.js";
|
|
2
2
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
3
3
|
import { useEditable } from "../../../../editor-kernel/react/useEditable.js";
|
|
4
|
-
import { Button, Input } from "@lobehub/ui
|
|
4
|
+
import { Button, Flexbox, Icon, Input, Popover, cssVar } from "@lobehub/ui";
|
|
5
5
|
import { LinkIcon, UploadIcon } from "lucide-react";
|
|
6
6
|
import { memo, useCallback, useRef, useState } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { Flexbox, Icon, Popover } from "@lobehub/ui";
|
|
9
|
-
import { cssVar } from "antd-style";
|
|
10
8
|
//#region src/plugins/image/react/components/ImageEditPopover.tsx
|
|
11
9
|
const ImageEditPopover = memo(({ children, node, handleUpload, onPickFile }) => {
|
|
12
10
|
const [open, setOpen] = useState(false);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { styles } from "./style.js";
|
|
2
2
|
import BrokenImage from "./BrokenImage.js";
|
|
3
3
|
import { useSuspenseImage } from "./useSupenseImage.js";
|
|
4
|
+
import { cx } from "@lobehub/ui";
|
|
4
5
|
import { useEffect, useState } from "react";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { cx } from "antd-style";
|
|
7
7
|
//#region src/plugins/image/react/components/LazyImage.tsx
|
|
8
8
|
function isSVG(src) {
|
|
9
9
|
return src.toLowerCase().endsWith(".svg");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styles } from "./style.js";
|
|
2
|
+
import { cx } from "@lobehub/ui";
|
|
2
3
|
import { useCallback, useRef } from "react";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { cx } from "antd-style";
|
|
5
5
|
//#region src/plugins/image/react/components/ResizeHandle.tsx
|
|
6
6
|
const ResizeHandle = ({ imageRef, isBlock, onResize, onResizeEnd, onResizeStart, position }) => {
|
|
7
7
|
const startWidthRef = useRef(0);
|
|
@@ -15,7 +15,7 @@ import LinkIframe from "./components/LinkIframe.js";
|
|
|
15
15
|
import LinkToolbar from "./components/LinkToolbar.js";
|
|
16
16
|
import SchemaLink from "./components/SchemaLink.js";
|
|
17
17
|
import { LinkReactRendererRegistry, splitReactSchemaRules } from "./renderer-registry.js";
|
|
18
|
-
import { toast } from "@lobehub/ui
|
|
18
|
+
import { toast } from "@lobehub/ui";
|
|
19
19
|
import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
20
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
21
|
//#region src/plugins/link/react/ReactLinkPlugin.tsx
|
|
@@ -4,12 +4,10 @@ import { UPDATE_LINK_TEXT_COMMAND } from "../../command/index.js";
|
|
|
4
4
|
import { EDIT_LINK_CARD_COMMAND } from "../../node/LinkCardNode.js";
|
|
5
5
|
import { cleanPosition, updatePosition } from "../../../../utils/updatePosition.js";
|
|
6
6
|
import { styles } from "../style.js";
|
|
7
|
-
import { Button, Input, Text } from "@lobehub/ui
|
|
7
|
+
import { Block, Button, Flexbox, Hotkey, Icon, Input, Text, cssVar } from "@lobehub/ui";
|
|
8
8
|
import { BaselineIcon, LinkIcon } from "lucide-react";
|
|
9
9
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { Block, Flexbox, Hotkey, Icon } from "@lobehub/ui";
|
|
12
|
-
import { cssVar } from "antd-style";
|
|
13
11
|
import { COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_NORMAL, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, createCommand } from "lexical";
|
|
14
12
|
import { mergeRegister } from "@lexical/utils";
|
|
15
13
|
//#region src/plugins/link/react/components/LinkEdit.tsx
|
|
@@ -8,10 +8,10 @@ import { useEditable } from "../../../../editor-kernel/react/useEditable.js";
|
|
|
8
8
|
import { cleanPosition, updatePosition } from "../../../../utils/updatePosition.js";
|
|
9
9
|
import { styles } from "../style.js";
|
|
10
10
|
import { $isLinkToolbarNode, convertLinkNodeByKeyToSchema, convertLinkToolbarNodeByKeyToLink, getLinkToolbarCapabilities, replaceNodeByKeyWithBlockCardNode, replaceNodeByKeyWithCardNode, replaceNodeByKeyWithIframeNode } from "../../conversion/index.js";
|
|
11
|
+
import { Flexbox, Icon } from "@lobehub/ui";
|
|
11
12
|
import { CopyIcon, EditIcon, ExternalLinkIcon, GalleryHorizontalEndIcon, LinkIcon, PanelTopOpenIcon, PanelsTopLeftIcon, UnlinkIcon } from "lucide-react";
|
|
12
13
|
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
13
14
|
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
import { Flexbox, Icon } from "@lobehub/ui";
|
|
15
15
|
import { $getNodeByKey, $getSelection, $isRangeSelection, COMMAND_PRIORITY_NORMAL } from "lexical";
|
|
16
16
|
import { mergeRegister } from "@lexical/utils";
|
|
17
17
|
//#region src/plugins/link/react/components/LinkToolbar.tsx
|
|
@@ -2,8 +2,8 @@ import { useLexicalComposerContext } from "../../../editor-kernel/react/react-co
|
|
|
2
2
|
import { MarkdownPlugin } from "../../markdown/plugin/index.js";
|
|
3
3
|
import { LinkHighlightPlugin } from "../plugin/index.js";
|
|
4
4
|
import { styles } from "./style.js";
|
|
5
|
+
import { cx } from "@lobehub/ui";
|
|
5
6
|
import { useLayoutEffect } from "react";
|
|
6
|
-
import { cx } from "antd-style";
|
|
7
7
|
//#region src/plugins/link-highlight/react/ReactLinkHighlightPlugin.tsx
|
|
8
8
|
const ReactLinkHighlightPlugin = ({ className, enableHotkey = true, enablePasteAutoHighlight = true }) => {
|
|
9
9
|
const [editor] = useLexicalComposerContext();
|
|
@@ -62,7 +62,11 @@ const ListPlugin = class extends KernelPlugin {
|
|
|
62
62
|
return false;
|
|
63
63
|
});
|
|
64
64
|
litexmlService.registerXMLWriter(ListItemNode.getType(), (node, ctx) => {
|
|
65
|
-
if ($isListItemNode(node))
|
|
65
|
+
if ($isListItemNode(node)) {
|
|
66
|
+
const child = node.getFirstChild();
|
|
67
|
+
if (child?.getType() === "diff" && "diffType" in child && child.diffType === "listItemRemove") return { lines: [] };
|
|
68
|
+
return ctx.createXmlNode("li");
|
|
69
|
+
}
|
|
66
70
|
return false;
|
|
67
71
|
});
|
|
68
72
|
litexmlService.registerXMLReader("ol", (xmlNode, children) => {
|
|
@@ -136,6 +140,8 @@ const ListPlugin = class extends KernelPlugin {
|
|
|
136
140
|
markdownService.registerMarkdownWriter(ListItemNode.getType(), (ctx, node) => {
|
|
137
141
|
const parent = node.getParent();
|
|
138
142
|
if ($isListItemNode(node) && $isListNode(parent)) {
|
|
143
|
+
const child = node.getFirstChild();
|
|
144
|
+
if (child?.getType() === "diff" && "diffType" in child && child.diffType === "listItemRemove") return true;
|
|
139
145
|
if ($isListNode(node.getFirstChild())) return;
|
|
140
146
|
const level = getLevel(parent);
|
|
141
147
|
const prefix = " ".repeat(level);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../data-source/litexml-data-source.js";
|
|
2
|
-
import { LITEXML_APPLY_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_REMOVE_COMMAND } from "./symbols.js";
|
|
2
|
+
import { LITEXML_APPLY_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_MODIFY_WITH_RESULTS_COMMAND, LITEXML_REMOVE_COMMAND, LiteXmlModifyOperation, LiteXmlOperationResult } from "./symbols.js";
|
|
3
3
|
import { LexicalEditor } from "lexical";
|
|
4
|
-
export { LITEXML_APPLY_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_REMOVE_COMMAND };
|
|
4
|
+
export { LITEXML_APPLY_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_MODIFY_WITH_RESULTS_COMMAND, LITEXML_REMOVE_COMMAND, type LiteXmlModifyOperation, type LiteXmlOperationResult };
|