@lobehub/editor 4.18.1 → 4.19.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/es/index.d.ts CHANGED
@@ -91,7 +91,7 @@ import { SerializedMentionNode } from "./plugins/mention/node/MentionNode.js";
91
91
  import { MentionPlugin, MentionPluginOptions } from "./plugins/mention/plugin/index.js";
92
92
  import { ReactMentionPluginProps } from "./plugins/mention/react/type.js";
93
93
  import { ReactMentionPlugin } from "./plugins/mention/react/ReactMentionPlugin.js";
94
- import { ISlashMenuOption, ISlashOption, ISlashService, SlashOptions } from "./plugins/slash/service/i-slash-service.js";
94
+ import { ISlashDividerOption, ISlashMenuOption, ISlashOption, ISlashSectionOption, ISlashService, SlashOptions, flattenSlashOptions, isSlashDividerOption, isSlashMenuOption, isSlashSectionOption } from "./plugins/slash/service/i-slash-service.js";
95
95
  import { ITriggerContext, SlashPlugin, SlashPluginOptions } from "./plugins/slash/plugin/index.js";
96
96
  import { MenuRenderProps, ReactSlashOptionProps, ReactSlashPluginProps, SlashMenuProps } from "./plugins/slash/react/type.js";
97
97
  import { SlashMenu } from "./plugins/slash/react/components/SlashMenu.js";
@@ -122,4 +122,4 @@ declare function enableHotReload(): void;
122
122
  */
123
123
  declare function disableHotReload(): void;
124
124
  //#endregion
125
- export { $closest, $closestNodeType, $createCursorNode, $getNearestNodeFromDOMNode, $getNodeFromDOMNode, $isCardLikeElementNode, $isCursorNode, ANCHOR_PADDING_CSS_VAR, AutoCompletePlugin, BlockDragTarget, BlockMenuService, BlockMovePayload, BlockPlugin, BlockPluginOptions, CONTENT_BLOCKS_DATA_TYPE, CardLikeElementNode, CodePlugin, CodeblockPlugin, CodeblockPluginOptions, CodemirrorPlugin, CodemirrorPluginOptions, CommonPlugin, CommonPluginOptions, ContentBlock, ContentBlocksDataSource, ContentBlocksPlugin, ContentBlocksPluginOptions, DEFAULT_BLOCK_ANCHOR_PADDING, DEFAULT_HEADLESS_EDITOR_PLUGINS, DOM_DOCUMENT_FRAGMENT_TYPE, DOM_DOCUMENT_TYPE, DOM_ELEMENT_TYPE, DOM_TEXT_TYPE, DataSource, DiffAction, EDITOR_THEME_KEY, ExtractContentBlocksOptions, FileContentBlock, FileListItem, FilePlugin, FilePluginOptions, GET_MARKDOWN_SELECTION_COMMAND, HIDE_TOOLBAR_COMMAND, HOVER_COMMAND, HRPlugin, HRPluginOptions, HeadlessDocumentType, HeadlessEditor, HeadlessEditorExport, HeadlessEditorExportOptions, HeadlessEditorHydrationInput, HeadlessEditorOptions, HeadlessLiteXMLBatchOperation, HeadlessLiteXMLInsertOperation, HeadlessLiteXMLOperation, HeadlessLiteXMLRemoveOperation, HeadlessLiteXMLReplaceOperation, HotkeyEnum, HotkeyId, HotkeyItem, HotkeyScopeEnum, HotkeyScopeId, IBlockActionButton, IBlockActionButtonIcon, IBlockMenuItem, IBlockMenuRenderContext, IBlockMenuService, IBlockSelectHandler, type IEditor, ILinkService, ILitexmlService, IMarkdownShortCutService, INSERT_CHECK_LIST_COMMAND, INSERT_CODEINLINE_COMMAND, INSERT_CODEMIRROR_COMMAND, INSERT_FILE_COMMAND, INSERT_HEADING_COMMAND, INSERT_HORIZONTAL_RULE_COMMAND, INSERT_IMAGE_COMMAND, INSERT_LINK_COMMAND, INSERT_LINK_HIGHLIGHT_COMMAND, INSERT_MARKDOWN_COMMAND, INSERT_MATH_COMMAND, INSERT_MENTION_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_QUOTE_COMMAND, INSERT_TABLE_COLUMN_COMMAND, INSERT_TABLE_COMMAND, INSERT_TABLE_ROW_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INodePlugin, INodePluginOptions, INodeService, ISlashMenuOption, ISlashOption, ISlashService, ITableControllerMenuActionItem, ITableControllerMenuItem, ITableControllerMenuRenderContext, ITableControllerMenuSeparatorItem, ITableControllerMenuService, ITriggerContext, IUploadService, ImageContentBlock, ImageListItem, ImagePlugin, ImagePluginOptions, Kernel, KeyEnum, LITEXML_APPLY_COMMAND, LITEXML_DIFFNODE_ALL_COMMAND, LITEXML_DIFFNODE_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_REMOVE_COMMAND, LexicalErrorBoundary, LexicalPortalContainer, LinkHighlightPlugin, LinkHighlightPluginOptions, LinkPlugin, LinkPluginOptions, ListPlugin, ListPluginOptions, LitexmlDataSource, LitexmlPlugin, LitexmlPluginOptions, LitexmlService, MARKDOWN_READER_LEVEL, MARKDOWN_READER_LEVEL_HIGH, MARKDOWN_READER_LEVEL_NORMAL, MARKDOWN_WRITER_LEVEL_MAX, MOVE_BLOCK_COMMAND, MarkdownPlugin, MathPlugin, MediaLists, MentionPlugin, MentionPluginOptions, MenuRenderProps, ModifierCombination, REMOVE_LIST_COMMAND, ReactAutoCompletePlugin, ReactBlockPlugin, ReactBlockPluginProps, ReactCodePlugin, ReactCodeblockPlugin, ReactCodeblockPluginProps, ReactCodemirrorPlugin, ReactEditor, ReactEditorContent, ReactEditorContentProps, ReactFilePlugin, ReactFilePluginProps, ReactHRPlugin, ReactHRPluginProps, ReactImagePlugin, ReactImagePluginProps, ReactLinkHighlightPlugin, ReactLinkPlugin, ReactLinkPluginProps, ReactListPlugin, ReactListPluginProps, ReactLiteXmlPlugin, ReactMarkdownPlugin, ReactMathPlugin, ReactMentionPlugin, ReactMentionPluginProps, ReactNodePlugin, ReactPlainText, ReactPlainTextProps, ReactSlashOption, ReactSlashOptionProps, ReactSlashPlugin, ReactSlashPluginProps, ReactTablePlugin, ReactToolbarPlugin, ReactVirtualBlockPlugin, SELECT_AFTER_CODEMIRROR_COMMAND, SELECT_BEFORE_CODEMIRROR_COMMAND, SELECT_TABLE_COMMAND, SHOW_TOOLBAR_COMMAND, SerializedMentionNode, SlashMenu, SlashMenuProps, SlashOptions, SlashPlugin, SlashPluginOptions, TableControllerMenuAxis, TableControllerMenuService, TablePlugin, TablePluginOptions, TextContentBlock, ToolbarCommandOptions, UPDATE_CODEBLOCK_LANG, UPDATE_LIST_START_COMMAND, UPLOAD_PRIORITY_HIGH, UPLOAD_PRIORITY_LOW, UPLOAD_PRIORITY_MEDIUM, UploadPlugin, UploadPluginOptions, VirtualBlockPlugin, VirtualBlockPluginOptions, XMLReaderFunc, XMLReaderRecord, XMLWriterFunc, XMLWriterRecord, assert, browserDebug, bundledLanguagesInfo, compareNodeOrder, createDebugLogger, createEmptyEditorState, createHeadlessEditor, cursorNodeSerialized, debugLogger, debugLoggers, detectCodeLanguage, detectLanguage, devConsole, disableHotReload, enableHotReload, extractContentBlocks, extractMediaFromEditorState, extractMediaLists, genServiceId, generateEditorId, getHotkeyById, getKernelFromEditor, getKernelFromEditorConfig, getNodeKeyFromDOMNode, getParentElement, isDOMNode, isDocumentFragment, isPunctuationChar, isPureUrl, isValidUrl, moment, noop, prodSafeLogger, reconcileDecorator, registerBlockMoveCommand, registerEditorKernel, registerLinkHighlightCommand, registerToolbarCommand, resetRandomKey, scrollIntoView, unregisterEditorKernel, useHasDiffNode, useLexicalComposerContext, useLexicalEditor };
125
+ export { $closest, $closestNodeType, $createCursorNode, $getNearestNodeFromDOMNode, $getNodeFromDOMNode, $isCardLikeElementNode, $isCursorNode, ANCHOR_PADDING_CSS_VAR, AutoCompletePlugin, BlockDragTarget, BlockMenuService, BlockMovePayload, BlockPlugin, BlockPluginOptions, CONTENT_BLOCKS_DATA_TYPE, CardLikeElementNode, CodePlugin, CodeblockPlugin, CodeblockPluginOptions, CodemirrorPlugin, CodemirrorPluginOptions, CommonPlugin, CommonPluginOptions, ContentBlock, ContentBlocksDataSource, ContentBlocksPlugin, ContentBlocksPluginOptions, DEFAULT_BLOCK_ANCHOR_PADDING, DEFAULT_HEADLESS_EDITOR_PLUGINS, DOM_DOCUMENT_FRAGMENT_TYPE, DOM_DOCUMENT_TYPE, DOM_ELEMENT_TYPE, DOM_TEXT_TYPE, DataSource, DiffAction, EDITOR_THEME_KEY, ExtractContentBlocksOptions, FileContentBlock, FileListItem, FilePlugin, FilePluginOptions, GET_MARKDOWN_SELECTION_COMMAND, HIDE_TOOLBAR_COMMAND, HOVER_COMMAND, HRPlugin, HRPluginOptions, HeadlessDocumentType, HeadlessEditor, HeadlessEditorExport, HeadlessEditorExportOptions, HeadlessEditorHydrationInput, HeadlessEditorOptions, HeadlessLiteXMLBatchOperation, HeadlessLiteXMLInsertOperation, HeadlessLiteXMLOperation, HeadlessLiteXMLRemoveOperation, HeadlessLiteXMLReplaceOperation, HotkeyEnum, HotkeyId, HotkeyItem, HotkeyScopeEnum, HotkeyScopeId, IBlockActionButton, IBlockActionButtonIcon, IBlockMenuItem, IBlockMenuRenderContext, IBlockMenuService, IBlockSelectHandler, type IEditor, ILinkService, ILitexmlService, IMarkdownShortCutService, INSERT_CHECK_LIST_COMMAND, INSERT_CODEINLINE_COMMAND, INSERT_CODEMIRROR_COMMAND, INSERT_FILE_COMMAND, INSERT_HEADING_COMMAND, INSERT_HORIZONTAL_RULE_COMMAND, INSERT_IMAGE_COMMAND, INSERT_LINK_COMMAND, INSERT_LINK_HIGHLIGHT_COMMAND, INSERT_MARKDOWN_COMMAND, INSERT_MATH_COMMAND, INSERT_MENTION_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_QUOTE_COMMAND, INSERT_TABLE_COLUMN_COMMAND, INSERT_TABLE_COMMAND, INSERT_TABLE_ROW_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INodePlugin, INodePluginOptions, INodeService, ISlashDividerOption, ISlashMenuOption, ISlashOption, ISlashSectionOption, ISlashService, ITableControllerMenuActionItem, ITableControllerMenuItem, ITableControllerMenuRenderContext, ITableControllerMenuSeparatorItem, ITableControllerMenuService, ITriggerContext, IUploadService, ImageContentBlock, ImageListItem, ImagePlugin, ImagePluginOptions, Kernel, KeyEnum, LITEXML_APPLY_COMMAND, LITEXML_DIFFNODE_ALL_COMMAND, LITEXML_DIFFNODE_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_REMOVE_COMMAND, LexicalErrorBoundary, LexicalPortalContainer, LinkHighlightPlugin, LinkHighlightPluginOptions, LinkPlugin, LinkPluginOptions, ListPlugin, ListPluginOptions, LitexmlDataSource, LitexmlPlugin, LitexmlPluginOptions, LitexmlService, MARKDOWN_READER_LEVEL, MARKDOWN_READER_LEVEL_HIGH, MARKDOWN_READER_LEVEL_NORMAL, MARKDOWN_WRITER_LEVEL_MAX, MOVE_BLOCK_COMMAND, MarkdownPlugin, MathPlugin, MediaLists, MentionPlugin, MentionPluginOptions, MenuRenderProps, ModifierCombination, REMOVE_LIST_COMMAND, ReactAutoCompletePlugin, ReactBlockPlugin, ReactBlockPluginProps, ReactCodePlugin, ReactCodeblockPlugin, ReactCodeblockPluginProps, ReactCodemirrorPlugin, ReactEditor, ReactEditorContent, ReactEditorContentProps, ReactFilePlugin, ReactFilePluginProps, ReactHRPlugin, ReactHRPluginProps, ReactImagePlugin, ReactImagePluginProps, ReactLinkHighlightPlugin, ReactLinkPlugin, ReactLinkPluginProps, ReactListPlugin, ReactListPluginProps, ReactLiteXmlPlugin, ReactMarkdownPlugin, ReactMathPlugin, ReactMentionPlugin, ReactMentionPluginProps, ReactNodePlugin, ReactPlainText, ReactPlainTextProps, ReactSlashOption, ReactSlashOptionProps, ReactSlashPlugin, ReactSlashPluginProps, ReactTablePlugin, ReactToolbarPlugin, ReactVirtualBlockPlugin, SELECT_AFTER_CODEMIRROR_COMMAND, SELECT_BEFORE_CODEMIRROR_COMMAND, SELECT_TABLE_COMMAND, SHOW_TOOLBAR_COMMAND, SerializedMentionNode, SlashMenu, SlashMenuProps, SlashOptions, SlashPlugin, SlashPluginOptions, TableControllerMenuAxis, TableControllerMenuService, TablePlugin, TablePluginOptions, TextContentBlock, ToolbarCommandOptions, UPDATE_CODEBLOCK_LANG, UPDATE_LIST_START_COMMAND, UPLOAD_PRIORITY_HIGH, UPLOAD_PRIORITY_LOW, UPLOAD_PRIORITY_MEDIUM, UploadPlugin, UploadPluginOptions, VirtualBlockPlugin, VirtualBlockPluginOptions, XMLReaderFunc, XMLReaderRecord, XMLWriterFunc, XMLWriterRecord, assert, browserDebug, bundledLanguagesInfo, compareNodeOrder, createDebugLogger, createEmptyEditorState, createHeadlessEditor, cursorNodeSerialized, debugLogger, debugLoggers, detectCodeLanguage, detectLanguage, devConsole, disableHotReload, enableHotReload, extractContentBlocks, extractMediaFromEditorState, extractMediaLists, flattenSlashOptions, genServiceId, generateEditorId, getHotkeyById, getKernelFromEditor, getKernelFromEditorConfig, getNodeKeyFromDOMNode, getParentElement, isDOMNode, isDocumentFragment, isPunctuationChar, isPureUrl, isSlashDividerOption, isSlashMenuOption, isSlashSectionOption, isValidUrl, moment, noop, prodSafeLogger, reconcileDecorator, registerBlockMoveCommand, registerEditorKernel, registerLinkHighlightCommand, registerToolbarCommand, resetRandomKey, scrollIntoView, unregisterEditorKernel, useHasDiffNode, useLexicalComposerContext, useLexicalEditor };
package/es/index.js CHANGED
@@ -88,6 +88,7 @@ import { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST
88
88
  import ReactListPlugin from "./plugins/list/react/ReactListPlugin.js";
89
89
  import { ReactMathPlugin } from "./plugins/math/react/index.js";
90
90
  import ReactMentionPlugin from "./plugins/mention/react/ReactMentionPlugin.js";
91
+ import { flattenSlashOptions, isSlashDividerOption, isSlashMenuOption, isSlashSectionOption } from "./plugins/slash/service/i-slash-service.js";
91
92
  import { SlashPlugin } from "./plugins/slash/plugin/index.js";
92
93
  import SlashMenu from "./plugins/slash/react/components/SlashMenu.js";
93
94
  import ReactSlashOption from "./plugins/slash/react/ReactSlashOption.js";
@@ -127,4 +128,4 @@ function disableHotReload() {
127
128
  }
128
129
  }
129
130
  //#endregion
130
- export { $closest, $closestNodeType, $createCursorNode, $getNearestNodeFromDOMNode, $getNodeFromDOMNode, $isCardLikeElementNode, $isCursorNode, ANCHOR_PADDING_CSS_VAR, AutoCompletePlugin, BlockMenuService, BlockPlugin, CONTENT_BLOCKS_DATA_TYPE, CardLikeElementNode, CodePlugin, CodeblockPlugin, CodemirrorPlugin, CommonPlugin, ContentBlocksDataSource, ContentBlocksPlugin, DEFAULT_BLOCK_ANCHOR_PADDING, DEFAULT_HEADLESS_EDITOR_PLUGINS, DOM_DOCUMENT_FRAGMENT_TYPE, DOM_DOCUMENT_TYPE, DOM_ELEMENT_TYPE, DOM_TEXT_TYPE, DataSource, DiffAction, EDITOR_THEME_KEY, FilePlugin, GET_MARKDOWN_SELECTION_COMMAND, HIDE_TOOLBAR_COMMAND, HOVER_COMMAND, HRPlugin, HeadlessEditor, HotkeyEnum, HotkeyScopeEnum, IBlockMenuService, ILinkService, ILitexmlService, IMarkdownShortCutService, INSERT_CHECK_LIST_COMMAND, INSERT_CODEINLINE_COMMAND, INSERT_CODEMIRROR_COMMAND, INSERT_FILE_COMMAND, INSERT_HEADING_COMMAND, INSERT_HORIZONTAL_RULE_COMMAND, INSERT_IMAGE_COMMAND, INSERT_LINK_COMMAND, INSERT_LINK_HIGHLIGHT_COMMAND, INSERT_MARKDOWN_COMMAND, INSERT_MATH_COMMAND, INSERT_MENTION_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_QUOTE_COMMAND, INSERT_TABLE_COLUMN_COMMAND, INSERT_TABLE_COMMAND, INSERT_TABLE_ROW_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INodePlugin, INodeService, ITableControllerMenuService, IUploadService, ImagePlugin, Kernel, KeyEnum, LITEXML_APPLY_COMMAND, LITEXML_DIFFNODE_ALL_COMMAND, LITEXML_DIFFNODE_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_REMOVE_COMMAND, LexicalErrorBoundary, LexicalPortalContainer, LinkHighlightPlugin, LinkPlugin, ListPlugin, LitexmlDataSource, LitexmlPlugin, LitexmlService, MARKDOWN_READER_LEVEL_HIGH, MARKDOWN_READER_LEVEL_NORMAL, MARKDOWN_WRITER_LEVEL_MAX, MOVE_BLOCK_COMMAND, MarkdownPlugin, MathPlugin, MentionPlugin, REMOVE_LIST_COMMAND, ReactAutoCompletePlugin, ReactBlockPlugin, ReactCodePlugin, ReactCodeblockPlugin, ReactCodemirrorPlugin, ReactEditor, ReactEditorContent, ReactFilePlugin, ReactHRPlugin, ReactImagePlugin, ReactLinkHighlightPlugin, ReactLinkPlugin, ReactListPlugin, ReactLiteXmlPlugin, ReactMarkdownPlugin, ReactMathPlugin, ReactMentionPlugin, ReactNodePlugin, ReactPlainText, ReactSlashOption, ReactSlashPlugin, ReactTablePlugin, ReactToolbarPlugin, ReactVirtualBlockPlugin, SELECT_AFTER_CODEMIRROR_COMMAND, SELECT_BEFORE_CODEMIRROR_COMMAND, SELECT_TABLE_COMMAND, SHOW_TOOLBAR_COMMAND, SlashMenu, SlashPlugin, TableControllerMenuService, TablePlugin, UPDATE_CODEBLOCK_LANG, UPDATE_LIST_START_COMMAND, UPLOAD_PRIORITY_HIGH, UPLOAD_PRIORITY_LOW, UPLOAD_PRIORITY_MEDIUM, UploadPlugin, VirtualBlockPlugin, assert, browserDebug, bundledLanguagesInfo, compareNodeOrder, createDebugLogger, createEmptyEditorState, createHeadlessEditor, cursorNodeSerialized, debugLogger, debugLoggers, detectCodeLanguage, detectLanguage, devConsole, disableHotReload, enableHotReload, extractContentBlocks, extractMediaFromEditorState, extractMediaLists, genServiceId, generateEditorId, getHotkeyById, getKernelFromEditor, getKernelFromEditorConfig, getNodeKeyFromDOMNode, getParentElement, isDOMNode, isDocumentFragment, isPunctuationChar, isPureUrl, isValidUrl, moment, noop, prodSafeLogger, reconcileDecorator, registerBlockMoveCommand, registerEditorKernel, registerLinkHighlightCommand, registerToolbarCommand, resetRandomKey, scrollIntoView, unregisterEditorKernel, useHasDiffNode, useLexicalComposerContext, useLexicalEditor };
131
+ export { $closest, $closestNodeType, $createCursorNode, $getNearestNodeFromDOMNode, $getNodeFromDOMNode, $isCardLikeElementNode, $isCursorNode, ANCHOR_PADDING_CSS_VAR, AutoCompletePlugin, BlockMenuService, BlockPlugin, CONTENT_BLOCKS_DATA_TYPE, CardLikeElementNode, CodePlugin, CodeblockPlugin, CodemirrorPlugin, CommonPlugin, ContentBlocksDataSource, ContentBlocksPlugin, DEFAULT_BLOCK_ANCHOR_PADDING, DEFAULT_HEADLESS_EDITOR_PLUGINS, DOM_DOCUMENT_FRAGMENT_TYPE, DOM_DOCUMENT_TYPE, DOM_ELEMENT_TYPE, DOM_TEXT_TYPE, DataSource, DiffAction, EDITOR_THEME_KEY, FilePlugin, GET_MARKDOWN_SELECTION_COMMAND, HIDE_TOOLBAR_COMMAND, HOVER_COMMAND, HRPlugin, HeadlessEditor, HotkeyEnum, HotkeyScopeEnum, IBlockMenuService, ILinkService, ILitexmlService, IMarkdownShortCutService, INSERT_CHECK_LIST_COMMAND, INSERT_CODEINLINE_COMMAND, INSERT_CODEMIRROR_COMMAND, INSERT_FILE_COMMAND, INSERT_HEADING_COMMAND, INSERT_HORIZONTAL_RULE_COMMAND, INSERT_IMAGE_COMMAND, INSERT_LINK_COMMAND, INSERT_LINK_HIGHLIGHT_COMMAND, INSERT_MARKDOWN_COMMAND, INSERT_MATH_COMMAND, INSERT_MENTION_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_QUOTE_COMMAND, INSERT_TABLE_COLUMN_COMMAND, INSERT_TABLE_COMMAND, INSERT_TABLE_ROW_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INodePlugin, INodeService, ITableControllerMenuService, IUploadService, ImagePlugin, Kernel, KeyEnum, LITEXML_APPLY_COMMAND, LITEXML_DIFFNODE_ALL_COMMAND, LITEXML_DIFFNODE_COMMAND, LITEXML_INSERT_COMMAND, LITEXML_MODIFY_COMMAND, LITEXML_REMOVE_COMMAND, LexicalErrorBoundary, LexicalPortalContainer, LinkHighlightPlugin, LinkPlugin, ListPlugin, LitexmlDataSource, LitexmlPlugin, LitexmlService, MARKDOWN_READER_LEVEL_HIGH, MARKDOWN_READER_LEVEL_NORMAL, MARKDOWN_WRITER_LEVEL_MAX, MOVE_BLOCK_COMMAND, MarkdownPlugin, MathPlugin, MentionPlugin, REMOVE_LIST_COMMAND, ReactAutoCompletePlugin, ReactBlockPlugin, ReactCodePlugin, ReactCodeblockPlugin, ReactCodemirrorPlugin, ReactEditor, ReactEditorContent, ReactFilePlugin, ReactHRPlugin, ReactImagePlugin, ReactLinkHighlightPlugin, ReactLinkPlugin, ReactListPlugin, ReactLiteXmlPlugin, ReactMarkdownPlugin, ReactMathPlugin, ReactMentionPlugin, ReactNodePlugin, ReactPlainText, ReactSlashOption, ReactSlashPlugin, ReactTablePlugin, ReactToolbarPlugin, ReactVirtualBlockPlugin, SELECT_AFTER_CODEMIRROR_COMMAND, SELECT_BEFORE_CODEMIRROR_COMMAND, SELECT_TABLE_COMMAND, SHOW_TOOLBAR_COMMAND, SlashMenu, SlashPlugin, TableControllerMenuService, TablePlugin, UPDATE_CODEBLOCK_LANG, UPDATE_LIST_START_COMMAND, UPLOAD_PRIORITY_HIGH, UPLOAD_PRIORITY_LOW, UPLOAD_PRIORITY_MEDIUM, UploadPlugin, VirtualBlockPlugin, assert, browserDebug, bundledLanguagesInfo, compareNodeOrder, createDebugLogger, createEmptyEditorState, createHeadlessEditor, cursorNodeSerialized, debugLogger, debugLoggers, detectCodeLanguage, detectLanguage, devConsole, disableHotReload, enableHotReload, extractContentBlocks, extractMediaFromEditorState, extractMediaLists, flattenSlashOptions, genServiceId, generateEditorId, getHotkeyById, getKernelFromEditor, getKernelFromEditorConfig, getNodeKeyFromDOMNode, getParentElement, isDOMNode, isDocumentFragment, isPunctuationChar, isPureUrl, isSlashDividerOption, isSlashMenuOption, isSlashSectionOption, isValidUrl, moment, noop, prodSafeLogger, reconcileDecorator, registerBlockMoveCommand, registerEditorKernel, registerLinkHighlightCommand, registerToolbarCommand, resetRandomKey, scrollIntoView, unregisterEditorKernel, useHasDiffNode, useLexicalComposerContext, useLexicalEditor };
@@ -1,4 +1,4 @@
1
- import { ISlashMenuOption, ISlashOption, ISlashService, SlashOptions } from "./service/i-slash-service.js";
1
+ import { ISlashDividerOption, ISlashMenuOption, ISlashOption, ISlashSectionOption, ISlashService, SlashOptions, flattenSlashOptions, isSlashDividerOption, isSlashMenuOption, isSlashSectionOption } from "./service/i-slash-service.js";
2
2
  import { ITriggerContext, SlashPlugin, SlashPluginOptions } from "./plugin/index.js";
3
3
  import { MenuRenderProps, ReactSlashOptionProps, ReactSlashPluginProps, SlashMenuProps } from "./react/type.js";
4
4
  import { SlashMenu } from "./react/components/SlashMenu.js";
@@ -3,7 +3,7 @@ import { noop } from "../../../editor-kernel/utils.js";
3
3
  import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context.js";
4
4
  import { useLexicalEditor } from "../../../editor-kernel/react/useLexicalEditor.js";
5
5
  import { $splitNodeContainingQuery } from "../utils/utils.js";
6
- import { ISlashService } from "../service/i-slash-service.js";
6
+ import { ISlashService, flattenSlashOptions } from "../service/i-slash-service.js";
7
7
  import { SlashPlugin } from "../plugin/index.js";
8
8
  import SlashMenu from "./components/SlashMenu.js";
9
9
  import { setCancelablePromise } from "./utils.js";
@@ -35,6 +35,12 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
35
35
  const handleActiveKeyChange = useCallback((key) => {
36
36
  setActiveKey(key);
37
37
  }, []);
38
+ const setInitialActiveKey = useCallback((items) => {
39
+ if (!activeKey) {
40
+ const firstOption = flattenSlashOptions(items)[0];
41
+ setActiveKey(firstOption?.key ? String(firstOption.key) : null);
42
+ }
43
+ }, [activeKey]);
38
44
  useLayoutEffect(() => {
39
45
  const options = Children.map(children, (child) => {
40
46
  if (!child) return null;
@@ -53,7 +59,7 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
53
59
  cancelRef.current.cancel();
54
60
  if (Array.isArray(ctx.items)) {
55
61
  setOptions(ctx.items);
56
- if (!activeKey) setActiveKey(ctx.items?.[0]?.key);
62
+ setInitialActiveKey(ctx.items);
57
63
  } else {
58
64
  setLoading(true);
59
65
  const pr = setCancelablePromise((resolve, reject) => {
@@ -62,7 +68,7 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
62
68
  pr.promise.then((items) => {
63
69
  const typedItems = items;
64
70
  setOptions(typedItems);
65
- if (!activeKey) setActiveKey(typedItems?.[0]?.key);
71
+ setInitialActiveKey(typedItems);
66
72
  });
67
73
  cancelRef.current.cancel = () => {
68
74
  pr.cancel();
@@ -80,9 +86,9 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
80
86
  }
81
87
  });
82
88
  }, [
83
- activeKey,
84
89
  editor,
85
- close
90
+ close,
91
+ setInitialActiveKey
86
92
  ]);
87
93
  useLayoutEffect(() => {
88
94
  const slash = editor.requireService(ISlashService);
@@ -97,7 +103,6 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
97
103
  }
98
104
  }, [children]);
99
105
  const handleMenuSelect = useCallback((option) => {
100
- if ("type" in option && option.type === "divider") return;
101
106
  const lexicalEditor = editor.getLexicalEditor();
102
107
  if (lexicalEditor && resolution) lexicalEditor.update(() => {
103
108
  (resolution.match ? $splitNodeContainingQuery(resolution.match) : null)?.remove();
@@ -112,7 +117,7 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
112
117
  close
113
118
  ]);
114
119
  useLexicalEditor(() => {
115
- const pureOptions = options.filter((item) => !("type" in item && item.type === "divider") && "key" in item && Boolean(item.key));
120
+ const pureOptions = flattenSlashOptions(options).filter((item) => Boolean(item.key));
116
121
  return mergeRegister(editor.registerHighCommand(KEY_ARROW_DOWN_COMMAND, (payload) => {
117
122
  const event = payload;
118
123
  if (pureOptions !== null && pureOptions.length) {
@@ -144,7 +149,7 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
144
149
  }, COMMAND_PRIORITY_CRITICAL), editor.registerHighCommand(KEY_TAB_COMMAND, (payload) => {
145
150
  const event = payload;
146
151
  if (options === null || activeKey === null) return false;
147
- const selectedOption = options.find((opt) => "key" in opt && opt.key === activeKey);
152
+ const selectedOption = flattenSlashOptions(options).find((opt) => opt.key === activeKey);
148
153
  if (!selectedOption) return false;
149
154
  event.preventDefault();
150
155
  event.stopImmediatePropagation();
@@ -155,7 +160,7 @@ const ReactSlashPlugin = ({ children, anchorClassName, getPopupContainer, placem
155
160
  event.preventDefault();
156
161
  event.stopImmediatePropagation();
157
162
  if (options !== null && activeKey !== null) {
158
- const selectedOption = options.find((opt) => "key" in opt && opt.key === activeKey);
163
+ const selectedOption = flattenSlashOptions(options).find((opt) => opt.key === activeKey);
159
164
  if (selectedOption) handleMenuSelect(selectedOption);
160
165
  }
161
166
  return true;
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { Icon, menuSharedStyles } from "@lobehub/ui";
2
+ import { flattenSlashOptions, isSlashDividerOption, isSlashSectionOption } from "../../service/i-slash-service.js";
3
+ import { Icon, LOBE_THEME_APP_ID, menuSharedStyles } from "@lobehub/ui";
3
4
  import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  import { createStaticStyles } from "antd-style";
6
7
  import { createPortal } from "react-dom";
7
8
  import { autoUpdate, flip, offset, shift, size, useFloating } from "@floating-ui/react";
8
9
  //#region src/plugins/slash/react/components/DefaultSlashMenu.tsx
9
- const LOBE_THEME_APP_ID$1 = "lobe-ui-theme-app";
10
10
  const styles = createStaticStyles(({ css, cssVar }) => ({
11
11
  popup: css`
12
12
  scrollbar-width: none;
@@ -30,50 +30,115 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
30
30
  `,
31
31
  root: css`
32
32
  z-index: 1100;
33
+ `,
34
+ section: css`
35
+ margin-block-start: 4px;
36
+ `,
37
+ sectionFirst: css`
38
+ margin-block-start: 0;
39
+ `,
40
+ sectionLabel: css`
41
+ padding-block: 12px 6px;
42
+ padding-inline: 8px;
43
+
44
+ font-size: 12px;
45
+ line-height: 1;
46
+ color: ${cssVar.colorTextDescription};
47
+
48
+ &:first-child {
49
+ padding-block-start: 6px;
50
+ }
51
+ `,
52
+ text: css`
53
+ overflow: hidden;
54
+ display: flex;
55
+ flex: 1 1 auto;
56
+ gap: 8px;
57
+ align-items: baseline;
58
+
59
+ min-width: 0;
60
+
61
+ white-space: nowrap;
62
+ `,
63
+ textDescription: css`
64
+ overflow: hidden;
65
+ flex: 1 1 auto;
66
+
67
+ min-width: 0;
68
+
69
+ color: ${cssVar.colorTextDescription};
70
+ text-overflow: ellipsis;
71
+ white-space: nowrap;
72
+ `,
73
+ textLabel: css`
74
+ overflow: hidden;
75
+ flex: 0 1 auto;
76
+
77
+ max-width: min(42ch, 55%);
78
+
79
+ font-weight: 500;
80
+ color: ${cssVar.colorText};
81
+ text-overflow: ellipsis;
82
+ white-space: nowrap;
33
83
  `
34
84
  }));
35
- const isDividerOption = (option) => "type" in option && option.type === "divider";
85
+ const renderMenuItem = (item, activeKey, onSelect) => {
86
+ const isHighlighted = item.key === activeKey;
87
+ const isDisabled = Boolean(item.disabled);
88
+ const description = item.metadata?.description;
89
+ return /* @__PURE__ */ jsxs("div", {
90
+ "aria-disabled": isDisabled || void 0,
91
+ className: menuSharedStyles.item,
92
+ "data-disabled": isDisabled ? "" : void 0,
93
+ "data-highlighted": isHighlighted ? "" : void 0,
94
+ onClick: () => {
95
+ if (isDisabled) return;
96
+ onSelect(item);
97
+ },
98
+ onMouseDown: (event) => event.preventDefault(),
99
+ role: "menuitem",
100
+ children: [
101
+ item.icon ? /* @__PURE__ */ jsx("span", {
102
+ className: menuSharedStyles.icon,
103
+ children: /* @__PURE__ */ jsx(Icon, { icon: item.icon })
104
+ }) : null,
105
+ /* @__PURE__ */ jsxs("span", {
106
+ className: styles.text,
107
+ children: [/* @__PURE__ */ jsx("span", {
108
+ className: styles.textLabel,
109
+ children: item.label
110
+ }), description ? /* @__PURE__ */ jsx("span", {
111
+ className: styles.textDescription,
112
+ children: description
113
+ }) : null]
114
+ }),
115
+ item.extra ? /* @__PURE__ */ jsx("span", {
116
+ className: menuSharedStyles.extra,
117
+ children: item.extra
118
+ }) : null
119
+ ]
120
+ }, String(item.key));
121
+ };
36
122
  const renderItems = (options, activeKey, loading, onSelect) => {
37
123
  if (loading) return /* @__PURE__ */ jsx("div", {
38
124
  className: menuSharedStyles.empty,
39
125
  children: "Loading..."
40
126
  });
41
127
  return options.map((opt, index) => {
42
- if (isDividerOption(opt)) return /* @__PURE__ */ jsx("div", { className: menuSharedStyles.separator }, `__divider_${index}`);
43
- const item = opt;
44
- const isHighlighted = item.key === activeKey;
45
- const isDisabled = Boolean(item.disabled);
46
- return /* @__PURE__ */ jsxs("div", {
47
- "aria-disabled": isDisabled || void 0,
48
- className: menuSharedStyles.item,
49
- "data-disabled": isDisabled ? "" : void 0,
50
- "data-highlighted": isHighlighted ? "" : void 0,
51
- onClick: () => {
52
- if (isDisabled) return;
53
- onSelect(item);
54
- },
55
- onMouseDown: (event) => event.preventDefault(),
56
- role: "menuitem",
57
- children: [
58
- item.icon ? /* @__PURE__ */ jsx("span", {
59
- className: menuSharedStyles.icon,
60
- children: /* @__PURE__ */ jsx(Icon, { icon: item.icon })
61
- }) : null,
62
- /* @__PURE__ */ jsx("span", {
63
- className: menuSharedStyles.label,
64
- children: item.label
65
- }),
66
- item.extra ? /* @__PURE__ */ jsx("span", {
67
- className: menuSharedStyles.extra,
68
- children: item.extra
69
- }) : null
70
- ]
71
- }, String(item.key));
128
+ if (isSlashDividerOption(opt)) return /* @__PURE__ */ jsx("div", { className: menuSharedStyles.separator }, `__divider_${index}`);
129
+ if (isSlashSectionOption(opt)) return /* @__PURE__ */ jsxs("div", {
130
+ className: `${styles.section} ${index === 0 ? styles.sectionFirst : ""}`,
131
+ children: [/* @__PURE__ */ jsx("div", {
132
+ className: styles.sectionLabel,
133
+ children: opt.label
134
+ }), opt.items.map((item) => renderMenuItem(item, activeKey, onSelect))]
135
+ }, String(opt.key ?? `__section_${index}`));
136
+ return renderMenuItem(opt, activeKey, onSelect);
72
137
  });
73
138
  };
74
139
  const resolvePortalContainer = () => {
75
140
  if (typeof document === "undefined") return null;
76
- return document.getElementById(LOBE_THEME_APP_ID$1) ?? document.body;
141
+ return document.getElementById(LOBE_THEME_APP_ID) ?? document.body;
77
142
  };
78
143
  const FullWidthSlashMenu = ({ activeKey, anchor, loading, onSelect, open, options, placement }) => {
79
144
  const resolvedPlacement = placement === "bottom" ? "bottom-start" : "top-start";
@@ -164,7 +229,7 @@ const CaretSlashMenu = ({ activeKey, loading, onSelect, open, options, placement
164
229
  }), portalContainer);
165
230
  };
166
231
  const DefaultSlashMenu = ({ activeKey, getPopupContainer, loading, onSelect, open, options, placement, position }) => {
167
- const hasVisibleItems = options?.some((item) => !isDividerOption(item));
232
+ const hasVisibleItems = flattenSlashOptions(options).length > 0;
168
233
  if (!open || !hasVisibleItems) return null;
169
234
  const anchor = getPopupContainer?.() ?? null;
170
235
  if (anchor) return /* @__PURE__ */ jsx(FullWidthSlashMenu, {
@@ -1,5 +1,6 @@
1
1
  import { IEditor, IServiceID } from "../../../types/kernel.js";
2
2
  import { DropdownMenuItemType } from "@lobehub/ui";
3
+ import { ReactNode } from "react";
3
4
  import Fuse, { IFuseOptions } from "fuse.js";
4
5
 
5
6
  //#region src/plugins/slash/service/i-slash-service.d.ts
@@ -10,7 +11,17 @@ interface ISlashMenuOption extends DropdownMenuItemType {
10
11
  metadata?: Record<string, any>;
11
12
  onSelect?: (editor: IEditor, matchingString: string) => void;
12
13
  }
13
- type ISlashOption = ISlashMenuOption | ISlashDividerOption;
14
+ interface ISlashSectionOption {
15
+ items: ISlashMenuOption[];
16
+ key?: string;
17
+ label: ReactNode;
18
+ type: 'section';
19
+ }
20
+ type ISlashOption = ISlashMenuOption | ISlashDividerOption | ISlashSectionOption;
21
+ declare const isSlashDividerOption: (option: ISlashOption) => option is ISlashDividerOption;
22
+ declare const isSlashSectionOption: (option: ISlashOption) => option is ISlashSectionOption;
23
+ declare const isSlashMenuOption: (option: ISlashOption) => option is ISlashMenuOption;
24
+ declare const flattenSlashOptions: (options: ISlashOption[]) => ISlashMenuOption[];
14
25
  interface SlashOptions {
15
26
  allowWhitespace?: boolean;
16
27
  /**
@@ -47,4 +58,4 @@ interface ISlashService {
47
58
  }
48
59
  declare const ISlashService: IServiceID<ISlashService>;
49
60
  //#endregion
50
- export { ISlashMenuOption, ISlashOption, ISlashService, SlashOptions };
61
+ export { ISlashDividerOption, ISlashMenuOption, ISlashOption, ISlashSectionOption, ISlashService, SlashOptions, flattenSlashOptions, isSlashDividerOption, isSlashMenuOption, isSlashSectionOption };
@@ -4,6 +4,14 @@ import { getBasicTypeaheadTriggerMatch } from "../utils/utils.js";
4
4
  import Fuse from "fuse.js";
5
5
  //#region src/plugins/slash/service/i-slash-service.ts
6
6
  init_debug();
7
+ const isSlashDividerOption = (option) => "type" in option && option.type === "divider";
8
+ const isSlashSectionOption = (option) => "type" in option && option.type === "section";
9
+ const isSlashMenuOption = (option) => !isSlashDividerOption(option) && !isSlashSectionOption(option);
10
+ const flattenSlashOptions = (options) => options.flatMap((option) => {
11
+ if (isSlashDividerOption(option)) return [];
12
+ if (isSlashSectionOption(option)) return option.items;
13
+ return [option];
14
+ });
7
15
  const ISlashService = genServiceId("SlashService");
8
16
  var SlashService = class {
9
17
  constructor(kernel) {
@@ -25,7 +33,7 @@ var SlashService = class {
25
33
  }));
26
34
  this.logger.debug(`⚡ Slash trigger: ${options.trigger}`);
27
35
  if (Array.isArray(options.items)) {
28
- const searchableItems = options.items.filter((item) => !("type" in item) || item.type !== "divider");
36
+ const searchableItems = flattenSlashOptions(options.items);
29
37
  const fuseConfig = options.fuseOptions || { keys: options.searchKeys || ["key"] };
30
38
  this.triggerFuseMap.set(options.trigger, new Fuse(searchableItems, fuseConfig));
31
39
  }
@@ -52,4 +60,4 @@ var SlashService = class {
52
60
  }
53
61
  };
54
62
  //#endregion
55
- export { ISlashService, SlashService };
63
+ export { ISlashService, SlashService, flattenSlashOptions, isSlashDividerOption, isSlashMenuOption, isSlashSectionOption };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.18.1",
3
+ "version": "4.19.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",