@lobehub/editor 4.8.2 → 4.8.4

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-Ub1LiKko.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";
@@ -22,6 +22,10 @@ import { bundledLanguagesInfo, bundledLanguagesInfo as bundledLanguagesInfo$1, b
22
22
  import Fuse from "fuse.js";
23
23
  import { flip, offset, shift, useFloating } from "@floating-ui/react";
24
24
  //#region src/editor-kernel/react/LexicalErrorBoundary.tsx
25
+ init_helper();
26
+ init_debug();
27
+ init_plugin();
28
+ init_utils();
25
29
  function LexicalErrorBoundary({ children, onError }) {
26
30
  return /* @__PURE__ */ jsx(ErrorBoundary, {
27
31
  fallback: /* @__PURE__ */ jsx("div", {
@@ -38,7 +42,6 @@ function LexicalErrorBoundary({ children, onError }) {
38
42
  }
39
43
  //#endregion
40
44
  //#region src/editor-kernel/react/react-context.ts
41
- init_utils();
42
45
  const LexicalComposerContext = createContext(null);
43
46
  function createLexicalComposerContext(parent, theme) {
44
47
  let parentContext = null;
@@ -2444,6 +2447,7 @@ function previous$2(code) {
2444
2447
  * @type {Tokenizer}
2445
2448
  */
2446
2449
  function tokenizeCodeText(effects, ok, nok) {
2450
+ this;
2447
2451
  let sizeOpen = 0;
2448
2452
  /** @type {number} */
2449
2453
  let size;
@@ -8739,6 +8743,7 @@ function configure(base, extension) {
8739
8743
  if (extension.extensions) while (++index < extension.extensions.length) configure(base, extension.extensions[index]);
8740
8744
  for (key in extension) if (own$1.call(extension, key)) switch (key) {
8741
8745
  case "extensions": break;
8746
+ /* c8 ignore next 4 */
8742
8747
  case "unsafe":
8743
8748
  list$1(base[key], extension[key]);
8744
8749
  break;
@@ -11449,8 +11454,8 @@ function bail(error) {
11449
11454
  if (error) throw error;
11450
11455
  }
11451
11456
  //#endregion
11452
- //#region node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js
11453
- var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11457
+ //#region node_modules/.pnpm/devlop@1.1.0/node_modules/devlop/lib/default.js
11458
+ var import_extend = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
11454
11459
  var hasOwn = Object.prototype.hasOwnProperty;
11455
11460
  var toStr = Object.prototype.toString;
11456
11461
  var defineProperty = Object.defineProperty;
@@ -11520,7 +11525,7 @@ var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11520
11525
  }
11521
11526
  return target;
11522
11527
  };
11523
- }));
11528
+ })))(), 1);
11524
11529
  //#endregion
11525
11530
  //#region node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
11526
11531
  function isPlainObject(value) {
@@ -13108,7 +13113,6 @@ const CallableInstance = (function(property) {
13108
13113
  * If a result that is not acceptable on a `VFile` is used, that will
13109
13114
  * be stored on the `result` field of {@linkcode VFile}.
13110
13115
  */
13111
- var import_extend = /* @__PURE__ */ __toESM(require_extend(), 1);
13112
13116
  const own = {}.hasOwnProperty;
13113
13117
  /**
13114
13118
  * Create a new processor.
@@ -18148,6 +18152,7 @@ function mathText(options) {
18148
18152
  * @type {Tokenizer}
18149
18153
  */
18150
18154
  function tokenizeMathText(effects, ok, nok) {
18155
+ this;
18151
18156
  let sizeOpen = 0;
18152
18157
  /** @type {number} */
18153
18158
  let size;
@@ -18359,11 +18364,9 @@ function remarkMath(options) {
18359
18364
  }
18360
18365
  //#endregion
18361
18366
  //#region src/plugins/markdown/utils/logger.ts
18362
- init_debug();
18363
18367
  const logger$2 = createDebugLogger("plugin", "markdown");
18364
18368
  //#endregion
18365
18369
  //#region src/plugins/markdown/data-source/markdown/parse.ts
18366
- init_helper();
18367
18370
  const selfClosingHtmlTags = new Set([
18368
18371
  "area",
18369
18372
  "base",
@@ -18758,7 +18761,6 @@ var NodeService = class {
18758
18761
  };
18759
18762
  //#endregion
18760
18763
  //#region src/plugins/inode/plugin/index.ts
18761
- init_plugin();
18762
18764
  /**
18763
18765
  * LitexmlPlugin - A plugin that provides XML-based data source support
18764
18766
  * Allows converting between Lexical editor state and XML format
package/es/index.js CHANGED
@@ -1,10 +1,10 @@
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-Ub1LiKko.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-Dp1bUEGK.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-CFkese2R.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";
7
- import { $createNodeSelection, $createParagraphNode, $createRangeSelection, $createTextNode, $getNearestNodeFromDOMNode as $getNearestNodeFromDOMNode$1, $getNodeByKey, $getPreviousSelection, $getRoot, $getSelection, $insertNodes, $isBlockElementNode, $isDecoratorNode, $isElementNode, $isNodeSelection, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isTextNode, $normalizeSelection__EXPERIMENTAL, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, DROP_COMMAND, HISTORY_MERGE_TAG, INDENT_CONTENT_COMMAND, INSERT_TAB_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DOWN_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, ParagraphNode, SELECTION_CHANGE_COMMAND, SKIP_SCROLL_INTO_VIEW_TAG, TextNode, createCommand, getDOMSelection, getDOMSelectionFromTarget, isHTMLElement, isModifierMatch } from "lexical";
7
+ import { $createNodeSelection, $createParagraphNode, $createRangeSelection, $createTextNode, $getNearestNodeFromDOMNode as $getNearestNodeFromDOMNode$1, $getNodeByKey, $getPreviousSelection, $getRoot, $getSelection, $insertNodes, $isBlockElementNode, $isDecoratorNode, $isElementNode, $isNodeSelection, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isTextNode, $nodesOfType, $normalizeSelection__EXPERIMENTAL, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, DROP_COMMAND, HISTORY_MERGE_TAG, INDENT_CONTENT_COMMAND, INSERT_TAB_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DOWN_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, ParagraphNode, SELECTION_CHANGE_COMMAND, SKIP_SCROLL_INTO_VIEW_TAG, TextNode, createCommand, getDOMSelection, getDOMSelectionFromTarget, isHTMLElement, isModifierMatch } from "lexical";
8
8
  import { DRAG_DROP_PASTE } from "@lexical/rich-text";
9
9
  import { $filter, $findMatchingParent, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, $insertNodeToNearestRoot, $wrapNodeInElement, addClassNamesToElement, calculateZoomLevel, mergeRegister, removeClassNamesFromElement } from "@lexical/utils";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -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) {
@@ -1101,6 +1122,16 @@ const LitexmlPlugin = class extends KernelPlugin {
1101
1122
  onInit(editor) {
1102
1123
  this.register(registerLiteXMLCommand(editor, this.datasource));
1103
1124
  this.register(registerLiteXMLDiffCommand(editor));
1125
+ this.register(editor.registerNodeTransform(DiffNode, (node) => {
1126
+ if (node.diffType === "modify" && node.getChildrenSize() === 1) node.setDiffType("remove");
1127
+ }));
1128
+ this.register(editor.registerUpdateListener(({ editorState, prevEditorState }) => {
1129
+ if (editorState === prevEditorState) return;
1130
+ editor.update(() => {
1131
+ const diffNodes = $nodesOfType(DiffNode);
1132
+ for (const node of diffNodes) if (node.diffType === "modify" && node.getChildrenSize() === 1) node.setDiffType("remove");
1133
+ });
1134
+ }));
1104
1135
  this.registerLiteXml();
1105
1136
  this.registerMarkdown();
1106
1137
  }
@@ -1192,7 +1223,7 @@ const ReactDiffNodeToolbar = ({ editor, node }) => {
1192
1223
  icon: X,
1193
1224
  onClick: () => {
1194
1225
  editor.dispatchCommand(LITEXML_DIFFNODE_COMMAND, {
1195
- action: DiffAction.Reject,
1226
+ action: 0,
1196
1227
  nodeKey: node.getKey()
1197
1228
  });
1198
1229
  },
@@ -1207,7 +1238,7 @@ const ReactDiffNodeToolbar = ({ editor, node }) => {
1207
1238
  icon: Check,
1208
1239
  onClick: () => {
1209
1240
  editor.dispatchCommand(LITEXML_DIFFNODE_COMMAND, {
1210
- action: DiffAction.Accept,
1241
+ action: 1,
1211
1242
  nodeKey: node.getKey()
1212
1243
  });
1213
1244
  },
@@ -2172,13 +2203,6 @@ function modeMatch(mode = "") {
2172
2203
  mode = mode.toLocaleLowerCase() || "plain";
2173
2204
  return MODES.find((m) => m.value === mode || m.ext?.includes(mode))?.value || "plain";
2174
2205
  }
2175
- let CODE_THEME_ENUM = /* @__PURE__ */ function(CODE_THEME_ENUM) {
2176
- CODE_THEME_ENUM["LOBE"] = "default";
2177
- return CODE_THEME_ENUM;
2178
- }({});
2179
- CODE_THEME_ENUM.LOBE, CODE_THEME_ENUM.LOBE;
2180
- CODE_THEME_ENUM.LOBE;
2181
- CODE_THEME_ENUM.LOBE;
2182
2206
  //#endregion
2183
2207
  //#region src/plugins/codemirror-block/plugin/index.ts
2184
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-Ub1LiKko.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-Dp1bUEGK.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-Ub1LiKko.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-CFkese2R.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";
@@ -1,4 +1,4 @@
1
- import { I as CardLikeElementNode, ht as reconcileDecorator, ot as getKernelFromEditor, st as getKernelFromEditorConfig, ut as init_utils } from "./style-Ub1LiKko.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, {
@@ -1511,6 +1511,7 @@ var init_kernel = __esmMin((() => {
1511
1511
  }));
1512
1512
  //#endregion
1513
1513
  //#region src/editor-kernel/data-source.ts
1514
+ init_kernel();
1514
1515
  var DataSource = class {
1515
1516
  constructor(dataType) {
1516
1517
  this.dataType = dataType;
@@ -1525,7 +1526,6 @@ var DataSource = class {
1525
1526
  };
1526
1527
  //#endregion
1527
1528
  //#region src/editor-kernel/index.ts
1528
- init_kernel();
1529
1529
  init_utils();
1530
1530
  init_event();
1531
1531
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.8.2",
3
+ "version": "4.8.4",
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",