@lobehub/editor 4.8.3 → 4.8.5

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.
@@ -1,4 +1,4 @@
1
- import { A as $createCodeMirrorNode, At as createDebugLogger, B as Editor, C as $createCodeNode$1, D as getCodeInlineNode, Ft as init_debug, Gt as INodeHelper, H as DataSource, Ht as exportNodeToJSON$1, Jt as __exportAll, K as $closest, Kt as init_helper, L as CursorNode, Lt as $canShowPlaceholderCurry, N as $createCursorNode, O as styles$2, Ot as init_hotkey, R as cursorNodeSerialized, Rt as $isCursorInQuote, Tt as HotkeyEnum, Ut as init_utils$1, Vt as createBlockNode, Wt as sampleReader, Xt as __toESM, Y as $getNodeFromDOMNode, d as $isLinkHighlightNode, i as MentionNode, it as genServiceId, k as themeStyles, mt as noop, n as $createMentionNode, p as getLinkHighlightNode, q as $closestNodeType, qt as __commonJSMin, r as $isMentionNode, t as styles$3, tt as assert, u as $createLinkHighlightNode, ut as init_utils, vt as KernelPlugin, w as $isCodeInlineNode, yt as init_plugin, z as registerCursorNode, zt as $isCursorInTable } from "./style-D-9k-451.js";
1
+ import { A as $createCodeMirrorNode, At as createDebugLogger, B as Editor, C as $createCodeNode$1, D as getCodeInlineNode, Ft as init_debug, Gt as INodeHelper, H as DataSource, Ht as exportNodeToJSON$1, Jt as __exportAll, K as $closest, Kt as init_helper, L as CursorNode, Lt as $canShowPlaceholderCurry, N as $createCursorNode, O as styles$2, Ot as init_hotkey, R as cursorNodeSerialized, Rt as $isCursorInQuote, Tt as HotkeyEnum, Ut as init_utils$1, Vt as createBlockNode, Wt as sampleReader, Xt as __toESM, Y as $getNodeFromDOMNode, d as $isLinkHighlightNode, i as MentionNode, it as genServiceId, k as themeStyles, mt as noop, n as $createMentionNode, p as getLinkHighlightNode, q as $closestNodeType, qt as __commonJSMin, r as $isMentionNode, t as styles$3, tt as assert, u as $createLinkHighlightNode, ut as init_utils, vt as KernelPlugin, w as $isCodeInlineNode, yt as init_plugin, z as registerCursorNode, zt as $isCursorInTable } from "./style-Tlcvrhqp.js";
2
2
  import { registerHistory } from "@lexical/history";
3
3
  import { $isTableSelection } from "@lexical/table";
4
4
  import { $caretFromPoint, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createPoint, $createRangeSelection, $createTabNode, $createTextNode, $getCaretRange, $getCaretRangeInDirection, $getCharacterOffsets, $getChildCaret, $getNearestNodeFromDOMNode, $getNodeByKey, $getRoot, $getSelection, $getSiblingCaret, $getTextPointCaret, $insertNodes, $isBlockElementNode, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isNodeSelection, $isRangeSelection, $isRootOrShadowRoot, $isTabNode, $isTextNode, $isTextPointCaret, $normalizeCaret, $parseSerializedNode, $setSelection, $setSelectionFromCaretRange, CLICK_COMMAND, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, FORMAT_TEXT_COMMAND, HISTORIC_TAG, HISTORY_PUSH_TAG, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, INSERT_TAB_COMMAND, IS_BOLD, IS_CODE, IS_ITALIC, IS_STRIKETHROUGH, IS_SUBSCRIPT, IS_SUPERSCRIPT, IS_UNDERLINE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DOWN_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, MOVE_TO_END, MOVE_TO_START, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, ParagraphNode, REDO_COMMAND, SELECTION_CHANGE_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, TEXT_TYPE_TO_FORMAT, TabNode, TextNode, UNDO_COMMAND, createCommand, getDOMSelection, getNearestEditorFromDOMNode, resetRandomKey } from "lexical";
@@ -2447,6 +2447,7 @@ function previous$2(code) {
2447
2447
  * @type {Tokenizer}
2448
2448
  */
2449
2449
  function tokenizeCodeText(effects, ok, nok) {
2450
+ this;
2450
2451
  let sizeOpen = 0;
2451
2452
  /** @type {number} */
2452
2453
  let size;
@@ -18151,6 +18152,7 @@ function mathText(options) {
18151
18152
  * @type {Tokenizer}
18152
18153
  */
18153
18154
  function tokenizeMathText(effects, ok, nok) {
18155
+ this;
18154
18156
  let sizeOpen = 0;
18155
18157
  /** @type {number} */
18156
18158
  let size;
package/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { $ as DOM_TEXT_TYPE, A as $createCodeMirrorNode, At as createDebugLogger, C as $createCodeNode$1, Ct as CONTROL_OR_META, Dt as KeyEnum, E as CodeNode$1, Et as HotkeyScopeEnum, F as $isCursorNode, Ft as init_debug, G as kernel_exports, Gt as INodeHelper, H as DataSource, I as CardLikeElementNode, It as prodSafeLogger, J as $getNearestNodeFromDOMNode, K as $closest, Kt as init_helper, M as CodeMirrorNode, Mt as debugLoggers, N as $createCursorNode, Nt as debug_exports, Ot as init_hotkey, P as $isCardLikeElementNode, Pt as devConsole, Q as DOM_ELEMENT_TYPE, R as cursorNodeSerialized, S as formatUrl, St as init_registerHotkey, Tt as HotkeyEnum, U as Kernel, V as resetRandomKey, W as init_kernel, X as DOM_DOCUMENT_FRAGMENT_TYPE, Y as $getNodeFromDOMNode, Yt as __toCommonJS, Z as DOM_DOCUMENT_TYPE, _ as AutoLinkNode, _t as unregisterEditorKernel, a as $createMathBlockNode, at as generateEditorId, b as LinkNode, bt as HOVER_COMMAND, c as MathBlockNode, ct as getNodeKeyFromDOMNode, dt as isDOMNode, et as EDITOR_THEME_KEY, f as LinkHighlightNode, ft as isDocumentFragment, g as $toggleLink, gt as registerEditorKernel, h as $isLinkNode, ht as reconcileDecorator, it as genServiceId, j as $isCodeMirrorNode, jt as debugLogger, kt as browserDebug, l as MathInlineNode, lt as getParentElement, m as $createLinkNode, mt as noop, nt as compareNodeOrder, o as $createMathInlineNode, ot as getKernelFromEditor, pt as moment, q as $closestNodeType, rt as createEmptyEditorState, s as $isMathNode, st as getKernelFromEditorConfig, tt as assert, u as $createLinkHighlightNode, ut as init_utils, v as HOVER_LINK_COMMAND, vt as KernelPlugin, wt as init_sys, x as TOGGLE_LINK_COMMAND, xt as getHotkeyById, y as HOVER_OUT_LINK_COMMAND, yt as init_plugin } from "./style-D-9k-451.js";
2
- import { A as idToChar, B as MARKDOWN_READER_LEVEL_NORMAL, C as ReactEditorContent, D as $cloneNode, E as LitexmlService, F as MarkdownPlugin, G as INSERT_MARKDOWN_COMMAND, H as INodePlugin, I as detectCodeLanguage, J as ReactEditor, K as isPunctuationChar, L as detectLanguage, M as INSERT_QUOTE_COMMAND, N as ReactMarkdownPlugin, O as $parseSerializedNodeImpl, P as useTranslation, R as IMarkdownShortCutService, S as ReactPlainText, T as ILitexmlService, U as INodeService, V as MARKDOWN_WRITER_LEVEL_MAX, W as GET_MARKDOWN_SELECTION_COMMAND, X as LexicalErrorBoundary, Y as useLexicalComposerContext, _ as bundledLanguagesInfo, a as ReactMentionPlugin, b as INSERT_CODEINLINE_COMMAND, c as INSERT_CHECK_LIST_COMMAND, d as registerLinkHighlightCommand, f as extractUrlFromText, g as useLexicalNodeSelection, i as SlashPlugin, j as INSERT_HEADING_COMMAND, k as charToId, l as registerCheckList, m as sanitizeUrl, n as ReactSlashOption, o as MentionPlugin, p as getSelectedNode, q as useLexicalEditor, r as SlashMenu, s as INSERT_MENTION_COMMAND, t as ReactSlashPlugin, u as INSERT_LINK_HIGHLIGHT_COMMAND, v as CodeblockPlugin, w as CommonPlugin, x as registerCodeInlineCommand, y as UPDATE_CODEBLOCK_LANG, z as MARKDOWN_READER_LEVEL_HIGH } from "./ReactSlashPlugin-B-UVEkP7.js";
3
- import { S as PlaceholderNode, _ as $isFileNode, a as styles$16, b as DiffNode, c as ImageNode, d as BlockImageNode, f as $createHorizontalRuleNode, g as $createFileNode, h as styles$15, i as imageBroken, l as $createBlockImageNode, m as HorizontalRuleNode, n as styles$18, o as $createImageNode, p as $isHorizontalRuleNode, r as styles$17, s as $isImageNode, t as styles$19, u as $isBlockImageNode, v as FileNode, x as PlaceholderBlockNode, y as $createDiffNode } from "./style-DPKmYLEF.js";
1
+ import { $ as DOM_TEXT_TYPE, A as $createCodeMirrorNode, At as createDebugLogger, C as $createCodeNode$1, Ct as CONTROL_OR_META, Dt as KeyEnum, E as CodeNode$1, Et as HotkeyScopeEnum, F as $isCursorNode, Ft as init_debug, G as kernel_exports, Gt as INodeHelper, H as DataSource, I as CardLikeElementNode, It as prodSafeLogger, J as $getNearestNodeFromDOMNode, K as $closest, Kt as init_helper, M as CodeMirrorNode, Mt as debugLoggers, N as $createCursorNode, Nt as debug_exports, Ot as init_hotkey, P as $isCardLikeElementNode, Pt as devConsole, Q as DOM_ELEMENT_TYPE, R as cursorNodeSerialized, S as formatUrl, St as init_registerHotkey, Tt as HotkeyEnum, U as Kernel, V as resetRandomKey, W as init_kernel, X as DOM_DOCUMENT_FRAGMENT_TYPE, Y as $getNodeFromDOMNode, Yt as __toCommonJS, Z as DOM_DOCUMENT_TYPE, _ as AutoLinkNode, _t as unregisterEditorKernel, a as $createMathBlockNode, at as generateEditorId, b as LinkNode, bt as HOVER_COMMAND, c as MathBlockNode, ct as getNodeKeyFromDOMNode, dt as isDOMNode, et as EDITOR_THEME_KEY, f as LinkHighlightNode, ft as isDocumentFragment, g as $toggleLink, gt as registerEditorKernel, h as $isLinkNode, ht as reconcileDecorator, it as genServiceId, j as $isCodeMirrorNode, jt as debugLogger, kt as browserDebug, l as MathInlineNode, lt as getParentElement, m as $createLinkNode, mt as noop, nt as compareNodeOrder, o as $createMathInlineNode, ot as getKernelFromEditor, pt as moment, q as $closestNodeType, rt as createEmptyEditorState, s as $isMathNode, st as getKernelFromEditorConfig, tt as assert, u as $createLinkHighlightNode, ut as init_utils, v as HOVER_LINK_COMMAND, vt as KernelPlugin, wt as init_sys, x as TOGGLE_LINK_COMMAND, xt as getHotkeyById, y as HOVER_OUT_LINK_COMMAND, yt as init_plugin } from "./style-Tlcvrhqp.js";
2
+ import { A as idToChar, B as MARKDOWN_READER_LEVEL_NORMAL, C as ReactEditorContent, D as $cloneNode, E as LitexmlService, F as MarkdownPlugin, G as INSERT_MARKDOWN_COMMAND, H as INodePlugin, I as detectCodeLanguage, J as ReactEditor, K as isPunctuationChar, L as detectLanguage, M as INSERT_QUOTE_COMMAND, N as ReactMarkdownPlugin, O as $parseSerializedNodeImpl, P as useTranslation, R as IMarkdownShortCutService, S as ReactPlainText, T as ILitexmlService, U as INodeService, V as MARKDOWN_WRITER_LEVEL_MAX, W as GET_MARKDOWN_SELECTION_COMMAND, X as LexicalErrorBoundary, Y as useLexicalComposerContext, _ as bundledLanguagesInfo, a as ReactMentionPlugin, b as INSERT_CODEINLINE_COMMAND, c as INSERT_CHECK_LIST_COMMAND, d as registerLinkHighlightCommand, f as extractUrlFromText, g as useLexicalNodeSelection, i as SlashPlugin, j as INSERT_HEADING_COMMAND, k as charToId, l as registerCheckList, m as sanitizeUrl, n as ReactSlashOption, o as MentionPlugin, p as getSelectedNode, q as useLexicalEditor, r as SlashMenu, s as INSERT_MENTION_COMMAND, t as ReactSlashPlugin, u as INSERT_LINK_HIGHLIGHT_COMMAND, v as CodeblockPlugin, w as CommonPlugin, x as registerCodeInlineCommand, y as UPDATE_CODEBLOCK_LANG, z as MARKDOWN_READER_LEVEL_HIGH } from "./ReactSlashPlugin-BZvB0g1k.js";
3
+ import { S as PlaceholderNode, _ as $isFileNode, a as styles$16, b as DiffNode, c as ImageNode, d as BlockImageNode, f as $createHorizontalRuleNode, g as $createFileNode, h as styles$15, i as imageBroken, l as $createBlockImageNode, m as HorizontalRuleNode, n as styles$18, o as $createImageNode, p as $isHorizontalRuleNode, r as styles$17, s as $isImageNode, t as styles$19, u as $isBlockImageNode, v as FileNode, x as PlaceholderBlockNode, y as $createDiffNode } from "./style-B7Vfm0cE.js";
4
4
  import { $computeTableMapSkipCellCheck, $createTableNodeWithDimensions, $createTableSelection, $deleteTableColumnAtSelection, $deleteTableRowAtSelection, $findTableNode, $getElementForTableNode, $getNodeTriplet, $getTableAndElementByKey, $getTableCellNodeFromLexicalNode, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $insertTableColumnAtSelection, $insertTableRowAtSelection, $isTableCellNode, $isTableNode, $isTableRowNode, $isTableSelection, $mergeCells, $unmergeCell, TableCellHeaderStates, TableCellNode, TableNode, TableNode as TableNode$1, TableRowNode, getDOMCellFromTarget, getTableElement, getTableObserverFromTableElement, registerTableCellUnmergeTransform, registerTablePlugin, registerTableSelectionObserver, setScrollableTablesActive } from "@lexical/table";
5
5
  import { debounce } from "es-toolkit/compat";
6
6
  import EventEmitter from "eventemitter3";
@@ -196,6 +196,27 @@ const AutoCompletePlugin = class extends KernelPlugin {
196
196
  input: textRet.textBefore,
197
197
  selectionType
198
198
  }).then((result) => {
199
+ let currentSelection = null;
200
+ editor.getEditorState().read(() => {
201
+ currentSelection = $getSelection();
202
+ });
203
+ if (editor.isComposing()) {
204
+ this.clearPlaceholderNodes(editor);
205
+ return;
206
+ }
207
+ if (!currentSelection || !$isRangeSelection(currentSelection) || !currentSelection.isCollapsed()) {
208
+ this.clearPlaceholderNodes(editor);
209
+ return;
210
+ }
211
+ const newPosition = {
212
+ key: currentSelection.anchor.key,
213
+ offset: currentSelection.anchor.offset,
214
+ type: currentSelection.anchor.type
215
+ };
216
+ if (!this.isSamePosition(currentPosition, newPosition)) {
217
+ this.clearPlaceholderNodes(editor);
218
+ return;
219
+ }
199
220
  if (result) {
200
221
  this.currentSuggestion = result;
201
222
  this.showPlaceholderNodes(editor, result);
@@ -709,25 +730,25 @@ const LITEXML_DIFFNODE_ALL_COMMAND = createCommand("LITEXML_DIFFNODE_ALL_COMMAND
709
730
  function doAction(node, action) {
710
731
  if (node.diffType === "modify") {
711
732
  const children = node.getChildren();
712
- if (action === DiffAction.Accept) node.replace(children[1], false).selectEnd();
713
- else if (action === DiffAction.Reject) node.replace(children[0], false).selectEnd();
733
+ if (action === 1) node.replace(children[1], false).selectEnd();
734
+ else if (action === 0) node.replace(children[0], false).selectEnd();
714
735
  }
715
736
  if (node.diffType === "remove") {
716
- if (action === DiffAction.Accept) node.remove();
717
- else if (action === DiffAction.Reject) {
737
+ if (action === 1) node.remove();
738
+ else if (action === 0) {
718
739
  const children = node.getChildren();
719
740
  node.replace(children[0], false).selectEnd();
720
741
  }
721
742
  }
722
743
  if (node.diffType === "add") {
723
- if (action === DiffAction.Accept) {
744
+ if (action === 1) {
724
745
  const children = node.getChildren();
725
746
  node.replace(children[0], false).selectEnd();
726
- } else if (action === DiffAction.Reject) node.remove();
747
+ } else if (action === 0) node.remove();
727
748
  }
728
749
  if (node.diffType === "listItemModify") {
729
750
  const children = node.getChildren();
730
- if (action === DiffAction.Accept) {
751
+ if (action === 1) {
731
752
  const lastChild = children[1];
732
753
  if (!$isElementNode(lastChild)) throw new Error("Expected element node as child of DiffNode");
733
754
  const nodeChildrens = lastChild.getChildren();
@@ -735,7 +756,7 @@ function doAction(node, action) {
735
756
  const parent = node.getParentOrThrow();
736
757
  node.remove();
737
758
  parent.selectEnd();
738
- } else if (action === DiffAction.Reject) {
759
+ } else if (action === 0) {
739
760
  const firstChild = children[0];
740
761
  if (!$isElementNode(firstChild)) throw new Error("Expected element node as child of DiffNode");
741
762
  const nodeChildrens = firstChild.getChildren();
@@ -746,8 +767,8 @@ function doAction(node, action) {
746
767
  }
747
768
  }
748
769
  if (node.diffType === "listItemRemove") {
749
- if (action === DiffAction.Accept) node.getParentOrThrow().remove();
750
- else if (action === DiffAction.Reject) {
770
+ if (action === 1) node.getParentOrThrow().remove();
771
+ else if (action === 0) {
751
772
  node.getChildren().forEach((child) => {
752
773
  node.getParentOrThrow().append(child);
753
774
  });
@@ -756,13 +777,13 @@ function doAction(node, action) {
756
777
  }
757
778
  }
758
779
  if (node.diffType === "listItemAdd") {
759
- if (action === DiffAction.Accept) {
780
+ if (action === 1) {
760
781
  node.getChildren().forEach((child) => {
761
782
  node.getParentOrThrow().append(child);
762
783
  });
763
784
  node.getParentOrThrow().selectEnd();
764
785
  node.remove();
765
- } else if (action === DiffAction.Reject) node.remove();
786
+ } else if (action === 0) node.remove();
766
787
  }
767
788
  }
768
789
  function registerLiteXMLDiffCommand(editor) {
@@ -1202,7 +1223,7 @@ const ReactDiffNodeToolbar = ({ editor, node }) => {
1202
1223
  icon: X,
1203
1224
  onClick: () => {
1204
1225
  editor.dispatchCommand(LITEXML_DIFFNODE_COMMAND, {
1205
- action: DiffAction.Reject,
1226
+ action: 0,
1206
1227
  nodeKey: node.getKey()
1207
1228
  });
1208
1229
  },
@@ -1217,7 +1238,7 @@ const ReactDiffNodeToolbar = ({ editor, node }) => {
1217
1238
  icon: Check,
1218
1239
  onClick: () => {
1219
1240
  editor.dispatchCommand(LITEXML_DIFFNODE_COMMAND, {
1220
- action: DiffAction.Accept,
1241
+ action: 1,
1221
1242
  nodeKey: node.getKey()
1222
1243
  });
1223
1244
  },
@@ -2182,13 +2203,6 @@ function modeMatch(mode = "") {
2182
2203
  mode = mode.toLocaleLowerCase() || "plain";
2183
2204
  return MODES.find((m) => m.value === mode || m.ext?.includes(mode))?.value || "plain";
2184
2205
  }
2185
- let CODE_THEME_ENUM = /* @__PURE__ */ function(CODE_THEME_ENUM) {
2186
- CODE_THEME_ENUM["LOBE"] = "default";
2187
- return CODE_THEME_ENUM;
2188
- }({});
2189
- CODE_THEME_ENUM.LOBE, CODE_THEME_ENUM.LOBE;
2190
- CODE_THEME_ENUM.LOBE;
2191
- CODE_THEME_ENUM.LOBE;
2192
2206
  //#endregion
2193
2207
  //#region src/plugins/codemirror-block/plugin/index.ts
2194
2208
  init_helper();
package/es/react.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A as $createCodeMirrorNode, B as Editor$2, Bt as $isRootTextContentEmpty, S as formatUrl, T as $isSelectionInCodeInline, Ut as init_utils, a as $createMathBlockNode, d as $isLinkHighlightNode, h as $isLinkNode, j as $isCodeMirrorNode, mt as noop, o as $createMathInlineNode, x as TOGGLE_LINK_COMMAND } from "./style-D-9k-451.js";
2
- import { C as ReactEditorContent, J as ReactEditor, N as ReactMarkdownPlugin, S as ReactPlainText, a as ReactMentionPlugin, b as INSERT_CODEINLINE_COMMAND, c as INSERT_CHECK_LIST_COMMAND, f as extractUrlFromText, h as validateUrl, m as sanitizeUrl, n as ReactSlashOption, t as ReactSlashPlugin, u as INSERT_LINK_HIGHLIGHT_COMMAND, y as UPDATE_CODEBLOCK_LANG } from "./ReactSlashPlugin-B-UVEkP7.js";
1
+ import { A as $createCodeMirrorNode, B as Editor$2, Bt as $isRootTextContentEmpty, S as formatUrl, T as $isSelectionInCodeInline, Ut as init_utils, a as $createMathBlockNode, d as $isLinkHighlightNode, h as $isLinkNode, j as $isCodeMirrorNode, mt as noop, o as $createMathInlineNode, x as TOGGLE_LINK_COMMAND } from "./style-Tlcvrhqp.js";
2
+ import { C as ReactEditorContent, J as ReactEditor, N as ReactMarkdownPlugin, S as ReactPlainText, a as ReactMentionPlugin, b as INSERT_CODEINLINE_COMMAND, c as INSERT_CHECK_LIST_COMMAND, f as extractUrlFromText, h as validateUrl, m as sanitizeUrl, n as ReactSlashOption, t as ReactSlashPlugin, u as INSERT_LINK_HIGHLIGHT_COMMAND, y as UPDATE_CODEBLOCK_LANG } from "./ReactSlashPlugin-BZvB0g1k.js";
3
3
  import { $createNodeSelection, $createParagraphNode, $getSelection, $isParagraphNode, $isRangeSelection, $isRootOrShadowRoot, $setSelection, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from "lexical";
4
4
  import { $createQuoteNode, $isHeadingNode, $isQuoteNode } from "@lexical/rich-text";
5
5
  import { $findMatchingParent, $getNearestNodeOfType, mergeRegister } from "@lexical/utils";
package/es/renderer.js CHANGED
@@ -1,5 +1,5 @@
1
- import { E as CodeNode, L as CursorNode, M as CodeMirrorNode, O as styles, _ as AutoLinkNode, b as LinkNode, c as MathBlockNode, f as LinkHighlightNode, i as MentionNode, l as MathInlineNode, t as styles$1 } from "./style-D-9k-451.js";
2
- import { S as PlaceholderNode, a as styles$5, b as DiffNode, c as ImageNode, d as BlockImageNode, h as styles$6, m as HorizontalRuleNode, n as styles$4, r as styles$2, t as styles$3, v as FileNode, x as PlaceholderBlockNode } from "./style-DPKmYLEF.js";
1
+ import { E as CodeNode, L as CursorNode, M as CodeMirrorNode, O as styles, _ as AutoLinkNode, b as LinkNode, c as MathBlockNode, f as LinkHighlightNode, i as MentionNode, l as MathInlineNode, t as styles$1 } from "./style-Tlcvrhqp.js";
2
+ import { S as PlaceholderNode, a as styles$5, b as DiffNode, c as ImageNode, d as BlockImageNode, h as styles$6, m as HorizontalRuleNode, n as styles$4, r as styles$2, t as styles$3, v as FileNode, x as PlaceholderBlockNode } from "./style-B7Vfm0cE.js";
3
3
  import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
4
4
  import { $getRoot, $isElementNode, $isTextNode } from "lexical";
5
5
  import { HeadingNode, QuoteNode } from "@lexical/rich-text";
@@ -121,6 +121,65 @@ function formatLinkHighlightUrl(url) {
121
121
  function textToSlug(text) {
122
122
  return text.toLowerCase().trim().replaceAll(/[^\s\w\u3000-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF-]/g, "").replaceAll(/[\s_]+/g, "-").replaceAll(/^-+|-+$/g, "");
123
123
  }
124
+ const DIFF_ROOT_STYLE = { position: "relative" };
125
+ const DIFF_LIST_ITEM_ROOT_STYLE = {
126
+ display: "inline-block",
127
+ minWidth: "100%",
128
+ position: "relative"
129
+ };
130
+ const DIFF_DELETED_STYLE = {
131
+ color: "var(--ant-color-text-quaternary, rgba(0, 0, 0, 0.45))",
132
+ textDecoration: "line-through"
133
+ };
134
+ function renderDiffNode(node, key, children) {
135
+ const diffType = typeof node.diffType === "string" ? node.diffType : "unchanged";
136
+ const renderedChildren = children ?? [];
137
+ const sharedContentStyle = {
138
+ marginBlockStart: "calc(var(--lobe-markdown-margin-multiple, 1) * 0.5em)",
139
+ paddingInlineEnd: 4
140
+ };
141
+ 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)";
142
+ const contentStyle = diffType === "unchanged" ? sharedContentStyle : {
143
+ ...sharedContentStyle,
144
+ borderInlineEnd: `3px solid ${borderColor}`
145
+ };
146
+ const rootStyle = diffType === "listItemAdd" || diffType === "listItemModify" || diffType === "listItemRemove" ? DIFF_LIST_ITEM_ROOT_STYLE : DIFF_ROOT_STYLE;
147
+ const wrapChild = (child, childKey, style) => {
148
+ if (child === void 0 || child === null) return null;
149
+ return /* @__PURE__ */ jsx("div", {
150
+ style,
151
+ children: child
152
+ }, childKey);
153
+ };
154
+ let content;
155
+ switch (diffType) {
156
+ case "add":
157
+ case "listItemAdd":
158
+ content = wrapChild(renderedChildren[0], `${key}-add`);
159
+ break;
160
+ case "remove":
161
+ case "listItemRemove":
162
+ content = wrapChild(renderedChildren[0], `${key}-remove`, DIFF_DELETED_STYLE);
163
+ break;
164
+ case "modify":
165
+ case "listItemModify":
166
+ content = [wrapChild(renderedChildren[0], `${key}-old`, DIFF_DELETED_STYLE), wrapChild(renderedChildren[1], `${key}-new`)];
167
+ break;
168
+ default:
169
+ content = renderedChildren;
170
+ break;
171
+ }
172
+ return /* @__PURE__ */ jsx("div", {
173
+ className: "ne-diff",
174
+ "data-diff-type": diffType,
175
+ style: rootStyle,
176
+ children: /* @__PURE__ */ jsx("div", {
177
+ className: "content",
178
+ style: contentStyle,
179
+ children: content
180
+ })
181
+ }, key);
182
+ }
124
183
  function renderBuiltinNode(node, key, children, headingSlugs, textContent) {
125
184
  switch (node.type) {
126
185
  case "root": return children;
@@ -216,6 +275,7 @@ function renderBuiltinNode(node, key, children, headingSlugs, textContent) {
216
275
  children: node.text
217
276
  }, key);
218
277
  return /* @__PURE__ */ jsx("span", { children: node.text }, key);
278
+ case "diff": return renderDiffNode(node, key, children);
219
279
  case "cursor": return null;
220
280
  default:
221
281
  console.warn(`[LexicalRenderer] Unknown node type: "${node.type}"`);
@@ -1,4 +1,4 @@
1
- import { I as CardLikeElementNode, ht as reconcileDecorator, ot as getKernelFromEditor, st as getKernelFromEditorConfig, ut as init_utils } from "./style-D-9k-451.js";
1
+ import { I as CardLikeElementNode, ht as reconcileDecorator, ot as getKernelFromEditor, st as getKernelFromEditorConfig, ut as init_utils } from "./style-Tlcvrhqp.js";
2
2
  import { $applyNodeReplacement, DecoratorNode, ElementNode } from "lexical";
3
3
  import { addClassNamesToElement } from "@lexical/utils";
4
4
  import { createStaticStyles, cx } from "antd-style";
@@ -15,7 +15,7 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
15
15
  var __getProtoOf = Object.getPrototypeOf;
16
16
  var __hasOwnProp = Object.prototype.hasOwnProperty;
17
17
  var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
18
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
19
19
  var __exportAll = (all, no_symbols) => {
20
20
  let target = {};
21
21
  for (var name in all) __defProp(target, name, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.8.3",
3
+ "version": "4.8.5",
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",