@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.
Files changed (149) hide show
  1. package/README.md +86 -0
  2. package/es/codemirror/components/CopyButton.js +1 -1
  3. package/es/codemirror/components/LanguageSelect.js +1 -3
  4. package/es/codemirror/components/MoreOptions.js +1 -2
  5. package/es/codemirror/components/Toolbar.js +1 -2
  6. package/es/codemirror/components/style.js +1 -1
  7. package/es/codemirror/style.js +1 -1
  8. package/es/codemirror/theme.js +1 -1
  9. package/es/editor-kernel/index.d.ts +2 -2
  10. package/es/editor-kernel/index.js +2 -2
  11. package/es/editor-kernel/react/useAnchor.js +1 -1
  12. package/es/headless/index.d.ts +5 -2
  13. package/es/headless/index.js +20 -22
  14. package/es/headless.d.ts +6 -507
  15. package/es/headless.js +903 -408
  16. package/es/i-node-identity-service-BBC_bg97.d.ts +522 -0
  17. package/es/index.d.ts +4 -2
  18. package/es/index.js +5 -2
  19. package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.js +1 -1
  20. package/es/plugins/auto-complete/react/style.js +1 -1
  21. package/es/plugins/block/react/ReactBlockPlugin.js +2 -7
  22. package/es/plugins/block/react/style.js +1 -1
  23. package/es/plugins/code/react/CodeReactPlugin.js +1 -1
  24. package/es/plugins/code/react/style.js +1 -1
  25. package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +1 -1
  26. package/es/plugins/codeblock/react/style.js +1 -1
  27. package/es/plugins/codemirror-block/react/CodemirrorNode.js +1 -3
  28. package/es/plugins/codemirror-block/react/MermaidPreview.js +1 -2
  29. package/es/plugins/collapsible/react/ReactCollapsiblePlugin.js +1 -1
  30. package/es/plugins/collapsible/react/style.js +74 -64
  31. package/es/plugins/common/data-source/json-data-source.js +33 -25
  32. package/es/plugins/common/data-source/text-data-source.js +6 -1
  33. package/es/plugins/common/index.d.ts +3 -1
  34. package/es/plugins/common/node/node-id.d.ts +7 -0
  35. package/es/plugins/common/node/node-id.js +484 -0
  36. package/es/plugins/common/node/node-identity-policy.d.ts +26 -0
  37. package/es/plugins/common/node/node-identity-policy.js +68 -0
  38. package/es/plugins/common/plugin/index.js +28 -2
  39. package/es/plugins/common/react/Placeholder/style.js +1 -1
  40. package/es/plugins/common/react/ReactPlainText.js +1 -1
  41. package/es/plugins/common/react/style.js +1 -1
  42. package/es/plugins/common/service/i-node-identity-service.d.ts +19 -0
  43. package/es/plugins/common/service/i-node-identity-service.js +4 -0
  44. package/es/plugins/common/service/node-identity-service.js +87 -0
  45. package/es/plugins/common/utils/index.js +3 -1
  46. package/es/plugins/file/react/components/ReactFile.js +1 -1
  47. package/es/plugins/file/react/style.js +1 -1
  48. package/es/plugins/hr/react/components/HRNode.js +1 -1
  49. package/es/plugins/hr/react/style.js +1 -1
  50. package/es/plugins/image/react/components/Image.js +1 -3
  51. package/es/plugins/image/react/components/ImageEditPopover.js +1 -3
  52. package/es/plugins/image/react/components/LazyImage.js +1 -1
  53. package/es/plugins/image/react/components/ResizeHandle.js +1 -1
  54. package/es/plugins/image/react/components/style.js +1 -1
  55. package/es/plugins/image/react/style.js +1 -1
  56. package/es/plugins/link/react/ReactLinkPlugin.js +1 -1
  57. package/es/plugins/link/react/components/LinkEdit.js +1 -3
  58. package/es/plugins/link/react/components/LinkToolbar.js +1 -1
  59. package/es/plugins/link/react/style.js +1 -1
  60. package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.js +1 -1
  61. package/es/plugins/link-highlight/react/style.js +1 -1
  62. package/es/plugins/list/plugin/index.js +7 -1
  63. package/es/plugins/list/react/style.js +1 -1
  64. package/es/plugins/litexml/command/index.d.ts +2 -2
  65. package/es/plugins/litexml/command/index.js +464 -292
  66. package/es/plugins/litexml/command/symbols.d.ts +18 -7
  67. package/es/plugins/litexml/command/symbols.js +2 -1
  68. package/es/plugins/litexml/data-source/litexml-data-source.js +34 -31
  69. package/es/plugins/litexml/diff-validation.js +68 -14
  70. package/es/plugins/litexml/index.d.ts +2 -2
  71. package/es/plugins/litexml/node/identity-policy.js +91 -0
  72. package/es/plugins/litexml/plugin/index.js +6 -0
  73. package/es/plugins/litexml/react/DiffNodeToolbar/index.js +1 -3
  74. package/es/plugins/litexml/react/DiffNodeToolbar/style.js +1 -1
  75. package/es/plugins/litexml/react/TableRowDiffToolbar.js +1 -3
  76. package/es/plugins/litexml/react/style.js +1 -1
  77. package/es/plugins/litexml/table-cell-diff.js +4 -0
  78. package/es/plugins/litexml/table-row-diff.js +4 -0
  79. package/es/plugins/litexml/utils/index.js +10 -23
  80. package/es/plugins/markdown/command/index.js +77 -4
  81. package/es/plugins/markdown/data-source/markdown-data-source.js +6 -1
  82. package/es/plugins/markdown/react/index.js +1 -1
  83. package/es/plugins/math/react/components/MathEditorContainer.js +1 -1
  84. package/es/plugins/math/react/components/MathEditorContent.js +1 -2
  85. package/es/plugins/math/react/components/Placeholder.js +1 -3
  86. package/es/plugins/math/react/style.js +1 -1
  87. package/es/plugins/mention/react/components/Mention.js +1 -1
  88. package/es/plugins/mention/react/style.js +1 -1
  89. package/es/plugins/slash/react/components/DefaultSlashMenu.js +1 -2
  90. package/es/plugins/slash/service/i-slash-service.d.ts +2 -2
  91. package/es/plugins/table/react/TableActionMenu/ActionMenu.js +1 -1
  92. package/es/plugins/table/react/TableActionMenu/index.js +1 -1
  93. package/es/plugins/table/react/TableActionMenu/style.js +1 -1
  94. package/es/plugins/table/react/TableColController.js +1 -1
  95. package/es/plugins/table/react/TableController/style.js +1 -1
  96. package/es/plugins/table/react/TableControllerButton.js +2 -2
  97. package/es/plugins/table/react/TableControllerMenu.js +2 -2
  98. package/es/plugins/table/react/TableHoverActions/index.js +1 -2
  99. package/es/plugins/table/react/TableHoverActions/style.js +1 -1
  100. package/es/plugins/table/react/TableResize/index.js +2 -2
  101. package/es/plugins/table/react/TableResize/style.js +1 -1
  102. package/es/plugins/table/react/TableRowController.js +1 -1
  103. package/es/plugins/table/react/index.js +1 -1
  104. package/es/plugins/table/react/style.js +1 -1
  105. package/es/plugins/toolbar/react/index.js +1 -2
  106. package/es/plugins/toolbar/react/style.js +1 -1
  107. package/es/plugins/yjs/plugin/index.js +5 -3
  108. package/es/plugins/yjs/plugin/utils/editor-state.js +8 -1
  109. package/es/plugins/yjs/plugin/utils/node-identity.js +106 -0
  110. package/es/plugins/yjs/service/index.js +38 -4
  111. package/es/react/ChatInput/ChatInput.js +1 -2
  112. package/es/react/ChatInput/style.js +1 -1
  113. package/es/react/ChatInput/type.d.ts +1 -1
  114. package/es/react/ChatInputActionBar/ChatInputActionBar.js +1 -2
  115. package/es/react/ChatInputActionBar/style.js +1 -1
  116. package/es/react/ChatInputActionBar/type.d.ts +1 -1
  117. package/es/react/ChatInputActions/ChatInputActions.js +1 -2
  118. package/es/react/ChatInputActions/components/ActionItem.js +1 -1
  119. package/es/react/ChatInputActions/components/ActionRender.js +1 -1
  120. package/es/react/ChatInputActions/components/CollapsedActions.js +1 -2
  121. package/es/react/ChatInputActions/style.js +1 -1
  122. package/es/react/ChatInputActions/type.d.ts +4 -4
  123. package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +1 -3
  124. package/es/react/CodeLanguageSelect/style.js +1 -1
  125. package/es/react/CodeLanguageSelect/type.d.ts +1 -1
  126. package/es/react/FloatActions/FloatActions.js +1 -2
  127. package/es/react/FloatActions/components/ActionItem.js +1 -1
  128. package/es/react/FloatActions/components/ActionRender.js +1 -1
  129. package/es/react/FloatActions/components/CollapsedActions.js +1 -2
  130. package/es/react/FloatActions/style.js +1 -1
  131. package/es/react/FloatActions/type.d.ts +4 -4
  132. package/es/react/SendButton/SendButton.js +1 -2
  133. package/es/react/SendButton/components/SendIcon.js +1 -1
  134. package/es/react/SendButton/components/StopIcon.js +1 -1
  135. package/es/react/SendButton/style.js +1 -1
  136. package/es/react/SendButton/type.d.ts +1 -1
  137. package/es/renderer/LexicalDiff.js +1 -1
  138. package/es/renderer/LexicalRenderer.js +1 -1
  139. package/es/renderer/diff/compute.js +2 -2
  140. package/es/renderer/diff/style.js +1 -1
  141. package/es/renderer/engine/render-builtin-node.js +2 -2
  142. package/es/renderer/renderers/codeblock.js +1 -1
  143. package/es/renderer/renderers/horizontalrule.js +1 -1
  144. package/es/renderer/renderers/mermaid.js +1 -1
  145. package/es/renderer/style.js +1 -1
  146. package/es/{symbols-Do7jD4Tt.d.ts → symbols-Dyr9yyS0.d.ts} +18 -7
  147. package/package.json +6 -8
  148. package/scripts/postinstall-lexical-patch.cjs +0 -21
  149. package/patches/lexical@0.42.0.patch +0 -82
@@ -1,12 +1,40 @@
1
+ import { $normalizeNodeIds, editorStateHasCompleteNodeIds, inheritMissingSerializedNodeIds, init_node_id, isValidContentNodeId, migrateSerializedNodeIds } from "../../common/node/node-id.js";
1
2
  import { createEmptyPreviousEditorState } from "../plugin/utils/editor-state.js";
2
3
  import { hydrateLexicalFromYjsState, syncCurrentEditorStateToYjs } from "../plugin/utils/sync.js";
3
- import { SKIP_COLLAB_TAG } from "lexical";
4
+ import { $getRoot, SKIP_COLLAB_TAG } from "lexical";
4
5
  //#region src/plugins/yjs/service/index.ts
6
+ init_node_id();
5
7
  const serializeComparableEditorState = (state) => {
6
- const serialized = state.toJSON();
8
+ const serialized = structuredClone(state.toJSON());
7
9
  if (serialized.root?.direction === "ltr") serialized.root.direction = null;
8
10
  return JSON.stringify(serialized);
9
11
  };
12
+ const serializeComparableStateForSnapshot = (state, snapshotRoot) => {
13
+ const serialized = structuredClone(state.toJSON());
14
+ if (serialized.root?.direction === "ltr") serialized.root.direction = null;
15
+ const stripMissingIds = (stateNode, snapshotNode) => {
16
+ if (!stateNode || typeof stateNode !== "object" || Array.isArray(stateNode) || !snapshotNode || typeof snapshotNode !== "object" || Array.isArray(snapshotNode)) return;
17
+ const stateRecord = stateNode;
18
+ const snapshotRecord = snapshotNode;
19
+ if (stateRecord.type === snapshotRecord.type) {
20
+ const properties = snapshotRecord.$?.properties;
21
+ if (!(snapshotRecord.type !== "root" && (isValidContentNodeId(snapshotRecord.id) || typeof snapshotRecord.id === "number" && Number.isFinite(snapshotRecord.id) || isValidContentNodeId(properties?.nodeId)))) {
22
+ delete stateRecord.id;
23
+ if (stateRecord.$?.properties) {
24
+ delete stateRecord.$.properties.nodeId;
25
+ if (Object.keys(stateRecord.$.properties).length === 0) delete stateRecord.$.properties;
26
+ if (Object.keys(stateRecord.$).length === 0) delete stateRecord.$;
27
+ }
28
+ }
29
+ if (Array.isArray(stateRecord.children) && Array.isArray(snapshotRecord.children)) {
30
+ const length = Math.min(stateRecord.children.length, snapshotRecord.children.length);
31
+ for (let index = 0; index < length; index++) stripMissingIds(stateRecord.children[index], snapshotRecord.children[index]);
32
+ }
33
+ }
34
+ };
35
+ stripMissingIds(serialized.root, snapshotRoot);
36
+ return JSON.stringify(serialized);
37
+ };
10
38
  var YjsService = class {
11
39
  constructor() {
12
40
  this.awarenessUsers = [];
@@ -40,9 +68,15 @@ var YjsService = class {
40
68
  const hasSharedState = !binding.root.isEmpty() || binding.root._xmlText._length > 0;
41
69
  if (hasSharedState && binding.root.isEmpty()) hydrateLexicalFromYjsState(binding, { discrete: true });
42
70
  const previousEditorState = binding.editor.getEditorState();
43
- const nextEditorState = binding.editor.parseEditorState(JSON.stringify(editorData));
71
+ const snapshot = structuredClone(editorData);
72
+ migrateSerializedNodeIds(snapshot.root);
73
+ inheritMissingSerializedNodeIds(previousEditorState.toJSON().root, snapshot.root);
74
+ const nextEditorState = binding.editor.parseEditorState(JSON.stringify(snapshot), () => {
75
+ $normalizeNodeIds($getRoot(), { stableDuplicateRepair: true });
76
+ });
44
77
  const isSameState = serializeComparableEditorState(previousEditorState) === serializeComparableEditorState(nextEditorState);
45
- if (hasSharedState && isSameState) return false;
78
+ const isSameStateIgnoringOmittedIds = hasSharedState && editorStateHasCompleteNodeIds(previousEditorState, binding.editor) && serializeComparableStateForSnapshot(previousEditorState, snapshot.root) === serializeComparableStateForSnapshot(nextEditorState, snapshot.root);
79
+ if (hasSharedState && (isSameState || isSameStateIgnoringOmittedIds)) return false;
46
80
  binding.editor.setEditorState(nextEditorState, { tag: SKIP_COLLAB_TAG });
47
81
  const replaceSharedState = () => {
48
82
  const collabRoot = binding.root;
@@ -1,10 +1,9 @@
1
1
  "use client";
2
2
  import { useHeight } from "../hooks/useSize.js";
3
3
  import { styles } from "./style.js";
4
+ import { Flexbox, cx, useThemeMode } from "@lobehub/ui";
4
5
  import { useCallback } from "react";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { Flexbox } from "@lobehub/ui";
7
- import { cx, useThemeMode } from "antd-style";
8
7
  import { Resizable } from "re-resizable";
9
8
  import useMergeState from "use-merge-value";
10
9
  //#region src/react/ChatInput/ChatInput.tsx
@@ -1,4 +1,4 @@
1
- import { createStaticStyles } from "antd-style";
1
+ import { createStaticStyles } from "@lobehub/ui";
2
2
  //#region src/react/ChatInput/style.ts
3
3
  const styles = createStaticStyles(({ css, cssVar }) => ({
4
4
  bodyEditor: css`
@@ -1,5 +1,5 @@
1
- import { CSSProperties, ReactNode, Ref } from "react";
2
1
  import { FlexboxProps } from "@lobehub/ui";
2
+ import { CSSProperties, ReactNode, Ref } from "react";
3
3
  //#region src/react/ChatInput/type.d.ts
4
4
  interface ChatInputProps extends Omit<FlexboxProps, 'height'> {
5
5
  classNames?: {
@@ -1,8 +1,7 @@
1
1
  "use client";
2
2
  import { styles } from "./style.js";
3
+ import { Flexbox, cx } from "@lobehub/ui";
3
4
  import { jsxs } from "react/jsx-runtime";
4
- import { Flexbox } from "@lobehub/ui";
5
- import { cx } from "antd-style";
6
5
  //#region src/react/ChatInputActionBar/ChatInputActionBar.tsx
7
6
  const ChatInputActionBar = ({ className, style, left, right, ...rest }) => {
8
7
  return /* @__PURE__ */ jsxs(Flexbox, {
@@ -1,4 +1,4 @@
1
- import { createStaticStyles } from "antd-style";
1
+ import { createStaticStyles } from "@lobehub/ui";
2
2
  //#region src/react/ChatInputActionBar/style.ts
3
3
  const styles = createStaticStyles(({ css }) => ({ container: css`
4
4
  overflow: hidden;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from "react";
2
1
  import { FlexboxProps } from "@lobehub/ui";
2
+ import { ReactNode } from "react";
3
3
  //#region src/react/ChatInputActionBar/type.d.ts
4
4
  interface ChatInputActionBarProps extends Omit<FlexboxProps, 'children'> {
5
5
  left?: ReactNode;
@@ -2,10 +2,9 @@
2
2
  import { styles } from "./style.js";
3
3
  import ActionItem from "./components/ActionItem.js";
4
4
  import { useDisplayActionCount } from "./components/useDisplayActionCount.js";
5
+ import { Flexbox, TooltipGroup, cx } from "@lobehub/ui";
5
6
  import { memo, useMemo } from "react";
6
7
  import { jsx } from "react/jsx-runtime";
7
- import { Flexbox, TooltipGroup } from "@lobehub/ui";
8
- import { cx } from "antd-style";
9
8
  import useMergeState from "use-merge-value";
10
9
  //#region src/react/ChatInputActions/ChatInputActions.tsx
11
10
  const ChatInputActions = memo(({ gap = 2, disabled, items = [], onActionClick, className, collapseOffset = 0, autoCollapse = true, defaultGroupCollapse = false, onGroupCollapseChange, groupCollapse, ...rest }) => {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import ActionRender from "./ActionRender.js";
3
3
  import CollapsedActions from "./CollapsedActions.js";
4
- import { ActionIcon, DropdownMenu } from "@lobehub/ui/base-ui";
4
+ import { ActionIcon, DropdownMenu } from "@lobehub/ui";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/react/ChatInputActions/components/ActionItem.tsx
7
7
  const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, collapsed, gap, setGroupCollapsed }) => {
@@ -1,5 +1,5 @@
1
1
  import { styles } from "../style.js";
2
- import { ActionIcon, Divider } from "@lobehub/ui/base-ui";
2
+ import { ActionIcon, Divider } from "@lobehub/ui";
3
3
  import { isValidElement } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/react/ChatInputActions/components/ActionRender.tsx
@@ -1,9 +1,8 @@
1
1
  "use client";
2
2
  import { styles } from "../style.js";
3
- import { ActionIcon } from "@lobehub/ui/base-ui";
3
+ import { ActionIcon, Flexbox, Popover, useMotionComponent } from "@lobehub/ui";
4
4
  import { CircleChevronLeftIcon, CircleChevronRightIcon, CircleChevronUpIcon } from "lucide-react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { Flexbox, Popover, useMotionComponent } from "@lobehub/ui";
7
6
  //#region src/react/ChatInputActions/components/CollapsedActions.tsx
8
7
  const CollapsedActions = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
9
8
  const Motion = useMotionComponent();
@@ -1,4 +1,4 @@
1
- import { createStaticStyles } from "antd-style";
1
+ import { createStaticStyles } from "@lobehub/ui";
2
2
  //#region src/react/ChatInputActions/style.ts
3
3
  const styles = createStaticStyles(({ css }) => ({
4
4
  collapsedContainer: css`
@@ -1,5 +1,5 @@
1
- import { ReactNode } from "react";
2
1
  import { FlexboxProps, MenuInfo, MenuItemType, TooltipProps } from "@lobehub/ui";
2
+ import { ReactNode } from "react";
3
3
  //#region src/react/ChatInputActions/type.d.ts
4
4
  type ChatInputActionEvent = Pick<MenuInfo, 'key' | 'keyPath' | 'domEvent'>;
5
5
  interface ActionItem extends MenuItemType {
@@ -16,11 +16,11 @@ type CollapseItem = {
16
16
  children: (ActionItem | DividerItem)[];
17
17
  type: 'collapse';
18
18
  };
19
- type DropdownItem = Omit<ActionItem, 'children' | 'type'> & {
19
+ type DropdownItem$1 = Omit<ActionItem, 'children' | 'type'> & {
20
20
  children: MenuItemType[];
21
21
  type: 'dropdown';
22
22
  };
23
- type ChatInputActionItem = ActionItem | DividerItem | CollapseItem | DropdownItem;
23
+ type ChatInputActionItem = ActionItem | DividerItem | CollapseItem | DropdownItem$1;
24
24
  interface ChatInputActionsProps extends Omit<FlexboxProps, 'children'> {
25
25
  autoCollapse?: boolean;
26
26
  collapseOffset?: number;
@@ -32,4 +32,4 @@ interface ChatInputActionsProps extends Omit<FlexboxProps, 'children'> {
32
32
  onGroupCollapseChange?: (collapse: boolean) => void;
33
33
  }
34
34
  //#endregion
35
- export { ActionItem, ChatInputActionEvent, ChatInputActionItem, ChatInputActionsProps, CollapseItem, DividerItem, DropdownItem };
35
+ export { ActionItem, ChatInputActionEvent, ChatInputActionItem, ChatInputActionsProps, CollapseItem, DividerItem, DropdownItem$1 as DropdownItem };
@@ -1,10 +1,8 @@
1
1
  "use client";
2
2
  import { styles } from "./style.js";
3
- import { Select, Text } from "@lobehub/ui/base-ui";
3
+ import { Flexbox, MaterialFileTypeIcon, Select, Text, cx } from "@lobehub/ui";
4
4
  import { useMemo } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { Flexbox, MaterialFileTypeIcon } from "@lobehub/ui";
7
- import { cx } from "antd-style";
8
6
  import { bundledLanguagesInfo } from "shiki";
9
7
  //#region src/react/CodeLanguageSelect/CodeLanguageSelect.tsx
10
8
  const CodeLanguageSelect = ({ className, ...rest }) => {
@@ -1,4 +1,4 @@
1
- import { createStaticStyles } from "antd-style";
1
+ import { createStaticStyles } from "@lobehub/ui";
2
2
  //#region src/react/CodeLanguageSelect/style.ts
3
3
  const styles = createStaticStyles(({ css }) => ({ container: css`
4
4
  width: 160px;
@@ -1,4 +1,4 @@
1
- import { SelectProps } from "@lobehub/ui/base-ui";
1
+ import { SelectProps } from "@lobehub/ui";
2
2
  //#region src/react/CodeLanguageSelect/type.d.ts
3
3
  type CodeLanguageSelectProps = Omit<SelectProps, 'options'>;
4
4
  //#endregion
@@ -1,9 +1,8 @@
1
1
  "use client";
2
2
  import { styles } from "./style.js";
3
3
  import ActionItem from "./components/ActionItem.js";
4
+ import { Flexbox, cx } from "@lobehub/ui";
4
5
  import { jsx } from "react/jsx-runtime";
5
- import { Flexbox } from "@lobehub/ui";
6
- import { cx } from "antd-style";
7
6
  import useMergeState from "use-merge-value";
8
7
  //#region src/react/FloatActions/FloatActions.tsx
9
8
  const FloatActions = ({ gap = 2, disabled, items = [], onActionClick, className, defaultGroupCollapse = false, onGroupCollapseChange, groupCollapse, ...rest }) => {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import ActionRender from "./ActionRender.js";
3
3
  import CollapsedActions from "./CollapsedActions.js";
4
- import { ActionIcon, DropdownMenu } from "@lobehub/ui/base-ui";
4
+ import { ActionIcon, DropdownMenu } from "@lobehub/ui";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/react/FloatActions/components/ActionItem.tsx
7
7
  const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, gap, setGroupCollapsed }) => {
@@ -1,5 +1,5 @@
1
1
  import { styles } from "../style.js";
2
- import { ActionIcon, Divider } from "@lobehub/ui/base-ui";
2
+ import { ActionIcon, Divider } from "@lobehub/ui";
3
3
  import { isValidElement } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/react/FloatActions/components/ActionRender.tsx
@@ -1,9 +1,8 @@
1
1
  "use client";
2
2
  import { styles } from "../style.js";
3
- import { ActionIcon } from "@lobehub/ui/base-ui";
3
+ import { ActionIcon, Flexbox, Popover, useMotionComponent } from "@lobehub/ui";
4
4
  import { CircleChevronLeftIcon, CircleChevronRightIcon, CircleChevronUpIcon } from "lucide-react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { Flexbox, Popover, useMotionComponent } from "@lobehub/ui";
7
6
  //#region src/react/FloatActions/components/CollapsedActions.tsx
8
7
  const CollapsedActions = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
9
8
  const Motion = useMotionComponent();
@@ -1,4 +1,4 @@
1
- import { createStaticStyles } from "antd-style";
1
+ import { createStaticStyles } from "@lobehub/ui";
2
2
  //#region src/react/FloatActions/style.ts
3
3
  const styles = createStaticStyles(({ css }) => ({
4
4
  collapsedContainer: css`
@@ -1,5 +1,5 @@
1
- import { ReactNode } from "react";
2
1
  import { FlexboxProps, MenuInfo, MenuItemType, TooltipProps } from "@lobehub/ui";
2
+ import { ReactNode } from "react";
3
3
  //#region src/react/FloatActions/type.d.ts
4
4
  type FloatActionsEvent = Pick<MenuInfo, 'key' | 'keyPath' | 'domEvent'>;
5
5
  interface ActionItem extends MenuItemType {
@@ -15,11 +15,11 @@ type CollapseItem = {
15
15
  children: (ActionItem | DividerItem)[];
16
16
  type: 'collapse';
17
17
  };
18
- type DropdownItem = Omit<ActionItem, 'children' | 'type'> & {
18
+ type DropdownItem$1 = Omit<ActionItem, 'children' | 'type'> & {
19
19
  children: MenuItemType[];
20
20
  type: 'dropdown';
21
21
  };
22
- type FloatActionsItem = ActionItem | DividerItem | CollapseItem | DropdownItem;
22
+ type FloatActionsItem = ActionItem | DividerItem | CollapseItem | DropdownItem$1;
23
23
  interface FloatActionsProps extends Omit<FlexboxProps, 'children'> {
24
24
  defaultGroupCollapse?: boolean;
25
25
  disabled?: boolean;
@@ -29,4 +29,4 @@ interface FloatActionsProps extends Omit<FlexboxProps, 'children'> {
29
29
  onGroupCollapseChange?: (collapse: boolean) => void;
30
30
  }
31
31
  //#endregion
32
- export { ActionItem, CollapseItem, DividerItem, DropdownItem, FloatActionsEvent, FloatActionsItem, FloatActionsProps };
32
+ export { ActionItem, CollapseItem, DividerItem, DropdownItem$1 as DropdownItem, FloatActionsEvent, FloatActionsItem, FloatActionsProps };
@@ -2,10 +2,9 @@
2
2
  import SendIcon from "./components/SendIcon.js";
3
3
  import StopIcon from "./components/StopIcon.js";
4
4
  import { styles } from "./style.js";
5
- import { Button, SplitButton } from "@lobehub/ui/base-ui";
5
+ import { Button, SplitButton, cx } from "@lobehub/ui";
6
6
  import { useMemo } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
- import { cx } from "antd-style";
9
8
  //#region src/react/SendButton/SendButton.tsx
10
9
  const SendButton = ({ type = "primary", menu, className, style, loading, generating, size = 32, shape, onSend, onStop, disabled, onClick, placement = "topRight", trigger, title, ...rest }) => {
11
10
  const cssVariables = useMemo(() => ({ "--send-button-size": `${size}px` }), [size]);
@@ -1,6 +1,6 @@
1
1
  "use client";
2
+ import { createStaticStyles, cx } from "@lobehub/ui";
2
3
  import { jsx } from "react/jsx-runtime";
3
- import { createStaticStyles, cx } from "antd-style";
4
4
  //#region src/react/SendButton/components/SendIcon.tsx
5
5
  const styles = createStaticStyles(({ css }) => ({ icon: css`
6
6
  flex: none;
@@ -1,5 +1,5 @@
1
+ import { createStaticStyles, cssVar, cx } from "@lobehub/ui";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { createStaticStyles, cssVar, cx } from "antd-style";
3
3
  //#region src/react/SendButton/components/StopIcon.tsx
4
4
  const styles = createStaticStyles(({ css }) => ({
5
5
  icon: css`
@@ -1,4 +1,4 @@
1
- import { createStaticStyles } from "antd-style";
1
+ import { createStaticStyles } from "@lobehub/ui";
2
2
  //#region src/react/SendButton/style.ts
3
3
  const styles = createStaticStyles(({ css, cssVar }) => ({
4
4
  button: css`
@@ -1,4 +1,4 @@
1
- import { ButtonProps, DropdownItem, DropdownMenuProps } from "@lobehub/ui/base-ui";
1
+ import { ButtonProps, DropdownItem, DropdownMenuProps } from "@lobehub/ui";
2
2
  import { CSSProperties, MouseEvent, Ref } from "react";
3
3
  //#region src/react/SendButton/type.d.ts
4
4
  type SendButtonClickHandler = (e: MouseEvent<HTMLElement>) => void;
@@ -1,9 +1,9 @@
1
1
  import { computeLexicalDiffRows } from "./diff/compute.js";
2
2
  import { diffStyles } from "./diff/style.js";
3
3
  import { LexicalRenderer } from "./LexicalRenderer.js";
4
+ import { cx } from "@lobehub/ui";
4
5
  import { useMemo } from "react";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { cx } from "antd-style";
7
7
  //#region src/renderer/LexicalDiff.tsx
8
8
  function wrapBlock(block) {
9
9
  return { root: {
@@ -2,8 +2,8 @@ import { getCSSVariables, getRendererClassName } from "./style.js";
2
2
  import { renderNode } from "./engine/render-tree.js";
3
3
  import { rendererNodes } from "./nodes/index.js";
4
4
  import { createDefaultRenderers } from "./renderers/index.js";
5
- import { createElement, use, useMemo } from "react";
6
5
  import { MotionComponent, MotionProvider } from "@lobehub/ui";
6
+ import { createElement, use, useMemo } from "react";
7
7
  import { createHeadlessEditor } from "@lexical/headless";
8
8
  import { $getRoot } from "lexical";
9
9
  import { motion } from "motion/react";
@@ -1,7 +1,7 @@
1
1
  //#region src/renderer/diff/compute.ts
2
2
  const CHAR_DIFF_MAX_MATRIX_CELLS = 5e4;
3
- const DELETE_MARK_STYLE = "background-color: color-mix(in srgb, var(--ant-color-error) 18%, transparent); text-decoration: line-through;";
4
- const INSERT_MARK_STYLE = "background-color: color-mix(in srgb, var(--ant-color-success) 18%, transparent);";
3
+ const DELETE_MARK_STYLE = "background-color: color-mix(in srgb, var(--lobe-color-error) 18%, transparent); text-decoration: line-through;";
4
+ const INSERT_MARK_STYLE = "background-color: color-mix(in srgb, var(--lobe-color-success) 18%, transparent);";
5
5
  function getBaseNodeType(node) {
6
6
  if (!node) return null;
7
7
  const type = node.type;
@@ -1,4 +1,4 @@
1
- import { createStaticStyles, cx } from "antd-style";
1
+ import { createStaticStyles, cx } from "@lobehub/ui";
2
2
  //#region src/renderer/diff/style.ts
3
3
  const base = createStaticStyles(({ css, cssVar }) => ({
4
4
  body: css`
@@ -43,7 +43,7 @@ const DIFF_LIST_ITEM_ROOT_STYLE = {
43
43
  position: "relative"
44
44
  };
45
45
  const DIFF_DELETED_STYLE = {
46
- color: "var(--ant-color-text-quaternary, rgba(0, 0, 0, 0.45))",
46
+ color: "var(--lobe-color-text-quaternary, rgba(0, 0, 0, 0.45))",
47
47
  textDecoration: "line-through"
48
48
  };
49
49
  function renderDiffNode(node, key, children) {
@@ -53,7 +53,7 @@ function renderDiffNode(node, key, children) {
53
53
  marginBlockStart: "calc(var(--lobe-markdown-margin-multiple, 1) * 0.5em)",
54
54
  paddingInlineEnd: 4
55
55
  };
56
- const borderColor = diffType === "add" || diffType === "listItemAdd" ? "var(--ant-color-success, #52c41a)" : diffType === "remove" || diffType === "listItemRemove" ? "var(--ant-color-error, #ff4d4f)" : "var(--ant-color-warning, #faad14)";
56
+ const borderColor = diffType === "add" || diffType === "listItemAdd" ? "var(--lobe-color-success, #52c41a)" : diffType === "remove" || diffType === "listItemRemove" ? "var(--lobe-color-error, #ff4d4f)" : "var(--lobe-color-warning, #faad14)";
57
57
  const contentStyle = diffType === "unchanged" ? sharedContentStyle : {
58
58
  ...sharedContentStyle,
59
59
  borderInlineEnd: `3px solid ${borderColor}`
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { renderMermaidBlock } from "./mermaid.js";
3
- import { jsx } from "react/jsx-runtime";
4
3
  import { Highlighter } from "@lobehub/ui";
4
+ import { jsx } from "react/jsx-runtime";
5
5
  //#region src/renderer/renderers/codeblock.tsx
6
6
  function CodeBlockRenderer({ node }) {
7
7
  const language = node.language || "";
@@ -1,5 +1,5 @@
1
+ import { createStaticStyles } from "@lobehub/ui";
1
2
  import { createElement } from "react";
2
- import { createStaticStyles } from "antd-style";
3
3
  //#region src/renderer/renderers/horizontalrule.tsx
4
4
  const useStyles = createStaticStyles(({ css, cssVar }) => css`
5
5
  display: flex;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
2
  import { Mermaid } from "@lobehub/ui";
3
+ import { jsx } from "react/jsx-runtime";
4
4
  //#region src/renderer/renderers/mermaid.tsx
5
5
  function renderMermaidBlock(node, key) {
6
6
  const code = node.code || "";
@@ -4,7 +4,7 @@ import { styles as styles$2 } from "../plugins/list/react/style.js";
4
4
  import { styles as styles$3 } from "../plugins/math/react/style.js";
5
5
  import { styles as styles$4 } from "../plugins/mention/react/style.js";
6
6
  import { styles as styles$5 } from "../plugins/table/react/style.js";
7
- import { createStaticStyles, cx } from "antd-style";
7
+ import { createStaticStyles, cx } from "@lobehub/ui";
8
8
  //#region src/renderer/style.ts
9
9
  const tableHeaderFix = createStaticStyles(({ css, cssVar }) => css`
10
10
  .editor_table > tbody > tr:first-of-type {
@@ -22,21 +22,32 @@ declare enum DiffAction {
22
22
  Reject = 0,
23
23
  Accept = 1
24
24
  }
25
- declare const LITEXML_MODIFY_COMMAND: import("lexical").LexicalCommand<({
26
- action: "insert";
25
+ type LiteXmlModifyOperation = {
26
+ action: 'insert';
27
27
  beforeId: string;
28
28
  litexml: string;
29
29
  } | {
30
- action: "insert";
30
+ action: 'insert';
31
31
  afterId: string;
32
32
  litexml: string;
33
33
  } | {
34
- action: "remove";
34
+ action: 'remove';
35
35
  id: string;
36
36
  } | {
37
- action: "modify";
37
+ action: 'modify';
38
38
  litexml: string | string[];
39
- })[]>;
39
+ };
40
+ interface LiteXmlOperationResult {
41
+ action: LiteXmlModifyOperation['action'];
42
+ index: number;
43
+ reason?: string;
44
+ status: 'applied' | 'failed';
45
+ }
46
+ declare const LITEXML_MODIFY_COMMAND: import("lexical").LexicalCommand<LiteXmlModifyOperation[]>;
47
+ declare const LITEXML_MODIFY_WITH_RESULTS_COMMAND: import("lexical").LexicalCommand<{
48
+ onResults: (results: LiteXmlOperationResult[]) => void;
49
+ operations: ReadonlyArray<LiteXmlModifyOperation>;
50
+ }>;
40
51
  declare const LITEXML_APPLY_COMMAND: import("lexical").LexicalCommand<{
41
52
  delay?: boolean;
42
53
  litexml: string | string[];
@@ -62,4 +73,4 @@ declare const LITEXML_DIFFNODE_ALL_COMMAND: import("lexical").LexicalCommand<{
62
73
  action: DiffAction;
63
74
  }>;
64
75
  //#endregion
65
- export { LITEXML_INSERT_COMMAND as a, LITEXML_DIFFNODE_COMMAND as i, LITEXML_APPLY_COMMAND as n, LITEXML_MODIFY_COMMAND as o, LITEXML_DIFFNODE_ALL_COMMAND as r, LITEXML_REMOVE_COMMAND as s, DiffAction as t };
76
+ export { LITEXML_INSERT_COMMAND as a, LITEXML_REMOVE_COMMAND as c, LITEXML_DIFFNODE_COMMAND as i, LiteXmlModifyOperation as l, LITEXML_APPLY_COMMAND as n, LITEXML_MODIFY_COMMAND as o, LITEXML_DIFFNODE_ALL_COMMAND as r, LITEXML_MODIFY_WITH_RESULTS_COMMAND as s, DiffAction as t, LiteXmlOperationResult as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.29.1",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -86,7 +86,8 @@
86
86
  "test": "vitest",
87
87
  "test:coverage": "vitest run --coverage --passWithNoTests",
88
88
  "test:watch": "vitest --watch",
89
- "type-check": "tsc --noEmit"
89
+ "type-check": "tsc --noEmit",
90
+ "verify:node-identity-package": "node scripts/verify-node-identity-package.mjs"
90
91
  },
91
92
  "dependencies": {
92
93
  "@floating-ui/dom": "^1.8.0",
@@ -107,7 +108,6 @@
107
108
  "@shikijs/engine-javascript": "^4.3.1",
108
109
  "@xmldom/xmldom": "^0.9.10",
109
110
  "ahooks": "^3.9.6",
110
- "antd-style": "^4.1.0",
111
111
  "debug": "^4.4.3",
112
112
  "es-toolkit": "^1.50.0",
113
113
  "eventemitter3": "^5.0.1",
@@ -131,9 +131,8 @@
131
131
  "yjs": "^13.6.31"
132
132
  },
133
133
  "peerDependencies": {
134
- "@lobehub/ui": "^5.55.0",
135
- "antd": "^6.1.1",
136
- "motion": "^12.0.0",
134
+ "@lobehub/ui": "^6.0.0-beta.1",
135
+ "motion": "^13.0.0",
137
136
  "react": "^19.0.0",
138
137
  "react-dom": "^19.0.0"
139
138
  },
@@ -143,8 +142,7 @@
143
142
  "chalk": "^4.1.2"
144
143
  },
145
144
  "patchedDependencies": {
146
- "@lexical/yjs@0.42.0": "patches/@lexical__yjs@0.42.0.patch",
147
- "lexical@0.42.0": "patches/lexical@0.42.0.patch"
145
+ "@lexical/yjs@0.42.0": "patches/@lexical__yjs@0.42.0.patch"
148
146
  }
149
147
  }
150
148
  }
@@ -7,27 +7,6 @@ const path = require('node:path');
7
7
 
8
8
  const PACKAGE_ROOT = path.resolve(__dirname, '..');
9
9
  const PATCH_CONFIGS = [
10
- {
11
- displayName: 'Lexical',
12
- fileHashes: {
13
- 'Lexical.dev.js': {
14
- patched: '7c81a9785b397dc09ce0ecc9f3126d3e4903cdfd12d5c51318965ed74b0e3ccb',
15
- },
16
- 'Lexical.dev.mjs': {
17
- patched: '880f22f2ec2d873e1699766de39edce5123b4730009bb88bb33d7e4da98a4ad9',
18
- },
19
- 'Lexical.prod.js': {
20
- patched: '9f97867340b84853cf82bbd2d60ef9f944ee61ef058daa37007b820c2780a103',
21
- },
22
- 'Lexical.prod.mjs': {
23
- patched: 'f7b2993582b2cc0573ca468373831b17971e0bb7383f5ca8785d4b93ab967c0b',
24
- },
25
- },
26
- packageName: 'lexical',
27
- patchFile: path.join(PACKAGE_ROOT, 'patches', 'lexical@0.42.0.patch'),
28
- rootOverride: process.env.LOBE_EDITOR_LEXICAL_ROOT,
29
- supportedVersion: '0.42.0',
30
- },
31
10
  {
32
11
  displayName: 'Lexical Yjs',
33
12
  fileHashes: {