@4399ywkf/editor 0.11.0 → 0.12.0

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/dist/doc.d.ts CHANGED
@@ -418,6 +418,8 @@ declare function resolveEditorTheme(token: AntdTokenLike, options?: {
418
418
  isDarkMode?: boolean;
419
419
  }): ResolvedEditorTheme;
420
420
 
421
+ type MessageSendKey = "enter" | "mod-enter";
422
+
421
423
  interface NotionEditorProps {
422
424
  room: string;
423
425
  placeholder?: string;
@@ -426,7 +428,7 @@ interface NotionEditorProps {
426
428
  * 仅在**非协同模式**(无 provider)下生效——业务方通过 HTTP 拿到文档内容后传入。
427
429
  * 协同模式下 yjs Doc 接管内容,传入会被忽略以免跟 sync 冲突。
428
430
  */
429
- content?: string | JSONContent;
431
+ content?: string | JSONContent | null;
430
432
  /**
431
433
  * `content` 的格式。不传时沿用旧规则:对象按 JSON、字符串按 HTML。
432
434
  * `"markdown"` 时字符串经 Markdown 解析(支持 `::: code-group` 代码分组);
@@ -490,6 +492,16 @@ interface NotionEditorProps {
490
492
  embedded?: boolean;
491
493
  /** 用可逆的白名单 HTML-in-Markdown 保存颜色、字号、对齐等富格式。 */
492
494
  richMarkdown?: boolean;
495
+ /** 消息输入框的发送键;未传 `onSend` 时不改变默认编辑器行为。 */
496
+ sendKey?: MessageSendKey;
497
+ /** 消息输入框发送回调;回调收到当前公开 Editor 实例。 */
498
+ onSend?: (editor: Editor$1) => void;
499
+ /** 用户编辑文档后回调;宿主可在回调里读取 getJSON / getEditorMarkdown。 */
500
+ onUpdate?: (editor: Editor$1) => void;
501
+ /** 选区变化后回调;用于宿主同步工具栏、AI 或提及状态。 */
502
+ onSelectionUpdate?: (editor: Editor$1) => void;
503
+ /** 编辑器实例销毁前后由 Tiptap 触发的生命周期回调。 */
504
+ onEditorDestroy?: (editor: Editor$1) => void;
493
505
  /**
494
506
  * 编辑器实例就绪回调。包不感知业务 store —— 业务方拿到 editor 实例后自行接管
495
507
  * (如写进 zustand store,发布时用 editor.getHTML()/getJSON() 取正文)。
@@ -520,7 +532,7 @@ interface EditorProviderProps {
520
532
  ydoc: Doc;
521
533
  placeholder?: string;
522
534
  /** 本地编辑模式下的初始/同步内容,详见 NotionEditorProps.content */
523
- content?: string | JSONContent;
535
+ content?: string | JSONContent | null;
524
536
  /** 内容格式,详见 NotionEditorProps.contentFormat */
525
537
  contentFormat?: ContentFormat;
526
538
  /** 代码块高亮配置,详见 NotionEditorProps.codeBlock */
@@ -547,6 +559,11 @@ interface EditorProviderProps {
547
559
  */
548
560
  embedded?: boolean;
549
561
  richMarkdown?: boolean;
562
+ sendKey?: MessageSendKey;
563
+ onSend?: (editor: Editor$1) => void;
564
+ onUpdate?: (editor: Editor$1) => void;
565
+ onSelectionUpdate?: (editor: Editor$1) => void;
566
+ onEditorDestroy?: (editor: Editor$1) => void;
550
567
  hideFloatingToolbar?: boolean;
551
568
  /** editor 实例就绪回调,详见 NotionEditorProps.onEditorReady */
552
569
  onEditorReady?: (editor: Editor$1) => void;
@@ -580,11 +597,11 @@ declare function EditorProvider(props: EditorProviderProps): react.JSX.Element;
580
597
  /**
581
598
  * Full editor with all necessary providers, ready to use with just a room ID
582
599
  */
583
- declare function NotionEditor({ room, placeholder, content, contentFormat, codeBlock, readOnly, hideHeader, hideFloatingToolbar, embedded, richMarkdown, onEditorReady, extensions, pageHeader, defaultViewMode, viewMode, onViewModeChange, defaultWidthMode, widthMode, onWidthModeChange, visualTheme, permissions, }: NotionEditorProps): react.JSX.Element;
600
+ declare function NotionEditor({ room, placeholder, content, contentFormat, codeBlock, readOnly, hideHeader, hideFloatingToolbar, embedded, richMarkdown, sendKey, onSend, onUpdate, onSelectionUpdate, onEditorDestroy, onEditorReady, extensions, pageHeader, defaultViewMode, viewMode, onViewModeChange, defaultWidthMode, widthMode, onWidthModeChange, visualTheme, permissions, }: NotionEditorProps): react.JSX.Element;
584
601
  /**
585
602
  * Internal component that handles the editor loading state
586
603
  */
587
- declare function NotionEditorContent({ placeholder, content, contentFormat, codeBlock, readOnly, permissions, hideHeader, hideFloatingToolbar, embedded, richMarkdown, onEditorReady, extensions, pageHeader, defaultViewMode, viewMode, onViewModeChange, defaultWidthMode, widthMode, onWidthModeChange, }: {
604
+ declare function NotionEditorContent({ placeholder, content, contentFormat, codeBlock, readOnly, permissions, hideHeader, hideFloatingToolbar, embedded, richMarkdown, sendKey, onSend, onUpdate, onSelectionUpdate, onEditorDestroy, onEditorReady, extensions, pageHeader, defaultViewMode, viewMode, onViewModeChange, defaultWidthMode, widthMode, onWidthModeChange, }: {
588
605
  pageHeader?: boolean;
589
606
  defaultViewMode?: ViewMode;
590
607
  viewMode?: ViewMode;
@@ -593,7 +610,7 @@ declare function NotionEditorContent({ placeholder, content, contentFormat, code
593
610
  widthMode?: DocWidthMode;
594
611
  onWidthModeChange?: (mode: DocWidthMode) => void;
595
612
  placeholder?: string;
596
- content?: string | JSONContent;
613
+ content?: string | JSONContent | null;
597
614
  /** 内容格式,详见 NotionEditorProps.contentFormat */
598
615
  contentFormat?: ContentFormat;
599
616
  /** 代码块高亮配置,详见 NotionEditorProps.codeBlock */
@@ -604,6 +621,11 @@ declare function NotionEditorContent({ placeholder, content, contentFormat, code
604
621
  hideFloatingToolbar?: boolean;
605
622
  embedded?: boolean;
606
623
  richMarkdown?: boolean;
624
+ sendKey?: MessageSendKey;
625
+ onSend?: (editor: Editor$1) => void;
626
+ onUpdate?: (editor: Editor$1) => void;
627
+ onSelectionUpdate?: (editor: Editor$1) => void;
628
+ onEditorDestroy?: (editor: Editor$1) => void;
607
629
  onEditorReady?: (editor: Editor$1) => void;
608
630
  /**
609
631
  * 追加的 tiptap 扩展,挂在包内置扩展集之后。
@@ -1697,4 +1719,4 @@ declare function WidthModeMenu(props?: {
1697
1719
  onChange?: (mode: DocWidthMode) => void;
1698
1720
  }): react.JSX.Element;
1699
1721
 
1700
- export { type ApiParamAttrs, ApiParamExtension, ArticleViewer, type ArticleViewerProps, Audio, ButtonProps, type CalloutAttrs, CalloutExtension, type CalloutType, CodeBlockExtension, CodeBlockOptions, CodeGroupExtension, CollabContext, type CollabContextValue, CollabProvider, type CollabProviderLike, Column, type ColumnLayout, Columns, ContentFormat, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, type DetailsAttrs, DetailsExtension, type DocPermissions, type DocWidthMode, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type EditorButtonConfig, type EditorCollabConfig, type EditorConfig, EditorConfigProvider, type EditorConfigProviderProps, EditorContentArea, type EditorFileConfig, type EditorLinkConfig, type EditorMentionConfig, type EditorPollConfig, type EditorProviderProps, type EditorSurfaceToken, EditorThemeStyle, type EditorThemeStyleProps, type EditorUploadConfig, type EditorUserConfig, type EditorVisualTheme, FileAttachment, type FileAttachmentAttrs, FileInline, type FilePreviewInfo, type FileView, FloatingElement, HIDE_FLOATING_META, type LinkPreview, LoadingSpinner, MAC_SYMBOLS, MAX_FILE_SIZE, type MediaKind, type MediaKindForButton, MediaUploadButton, type MediaUploadButtonProps, MediaUploadPlaceholder, type MentionDoc, type MentionDocState, type MentionNotifyParams, type MentionUser, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, type NotionEditorProps, type OverflowPosition, type ParsedContent, PasteDropMedia, type PasteDropMediaOptions, type PasteDropMediaUploadFn, type PasteDropRehostProgressEvent, type PollVoter, type PollVotes, Popover, PopoverContent, PopoverTrigger, type PrintOptions, type RehostProgressEvent, type RenderHighlightedHTMLOptions, type ResolvedEditorTheme, SR_ONLY, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UiState as UiStateType, type User, UserContext, type UserContextValue, UserProvider, VIEW_MODE_TOAST, Video, type ViewMode, ViewModeSwitch, WidthModeMenu, type WordCount, clamp, cn, countDocument, countRange, countText, defaultUiState, detectMediaKind, findNodeAtPosition, findNodePosition, findSelectionPosition, focusNextNode, formatShortcutKey, getAvatar, getDocPermissions, getEditorMarkdown, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, hasContentAbove, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, markHideFloatingOnNext, parseEditorContent, parseShortcutKeys, pickFile, printDocument, removeEmptyParagraphs, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, sanitizeUrl, selectCurrentBlockContent, selectNodeAndHideFloating, selectionWithinConvertibleTypes, serializeEditorMarkdown, updateNodesAttr, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useScrolling, useThrottledCallback, useTiptapEditor, useUiEditorState, useUiEditorState as useUiEditorStateDefault, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize };
1722
+ export { type ApiParamAttrs, ApiParamExtension, ArticleViewer, type ArticleViewerProps, Audio, ButtonProps, type CalloutAttrs, CalloutExtension, type CalloutType, CodeBlockExtension, CodeBlockOptions, CodeGroupExtension, CollabContext, type CollabContextValue, CollabProvider, type CollabProviderLike, Column, type ColumnLayout, Columns, ContentFormat, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, type DetailsAttrs, DetailsExtension, type DocPermissions, type DocWidthMode, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type EditorButtonConfig, type EditorCollabConfig, type EditorConfig, EditorConfigProvider, type EditorConfigProviderProps, EditorContentArea, type EditorFileConfig, type EditorLinkConfig, type EditorMentionConfig, type EditorPollConfig, type EditorProviderProps, type EditorSurfaceToken, EditorThemeStyle, type EditorThemeStyleProps, type EditorUploadConfig, type EditorUserConfig, type EditorVisualTheme, FileAttachment, type FileAttachmentAttrs, FileInline, type FilePreviewInfo, type FileView, FloatingElement, HIDE_FLOATING_META, type LinkPreview, LoadingSpinner, MAC_SYMBOLS, MAX_FILE_SIZE, type MediaKind, type MediaKindForButton, MediaUploadButton, type MediaUploadButtonProps, MediaUploadPlaceholder, type MentionDoc, type MentionDocState, type MentionNotifyParams, type MentionUser, type MessageSendKey, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, type NotionEditorProps, type OverflowPosition, type ParsedContent, PasteDropMedia, type PasteDropMediaOptions, type PasteDropMediaUploadFn, type PasteDropRehostProgressEvent, type PollVoter, type PollVotes, Popover, PopoverContent, PopoverTrigger, type PrintOptions, type RehostProgressEvent, type RenderHighlightedHTMLOptions, type ResolvedEditorTheme, SR_ONLY, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UiState as UiStateType, type User, UserContext, type UserContextValue, UserProvider, VIEW_MODE_TOAST, Video, type ViewMode, ViewModeSwitch, WidthModeMenu, type WordCount, clamp, cn, countDocument, countRange, countText, defaultUiState, detectMediaKind, findNodeAtPosition, findNodePosition, findSelectionPosition, focusNextNode, formatShortcutKey, getAvatar, getDocPermissions, getEditorMarkdown, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, hasContentAbove, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, markHideFloatingOnNext, parseEditorContent, parseShortcutKeys, pickFile, printDocument, removeEmptyParagraphs, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, sanitizeUrl, selectCurrentBlockContent, selectNodeAndHideFloating, selectionWithinConvertibleTypes, serializeEditorMarkdown, updateNodesAttr, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useScrolling, useThrottledCallback, useTiptapEditor, useUiEditorState, useUiEditorState as useUiEditorStateDefault, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize };
package/dist/doc.js CHANGED
@@ -1,4 +1,4 @@
1
- export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, DetailsExtension, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WidthModeMenu, countDocument, countRange, countText, defaultUiState, detectMediaKind, findSelectionPosition, getDocPermissions, getEditorMarkdown, hasContentAbove, markHideFloatingOnNext, parseEditorContent, pickFile, printDocument, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, serializeEditorMarkdown, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize } from './chunk-6MZAYCF6.js';
1
+ export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, DetailsExtension, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WidthModeMenu, countDocument, countRange, countText, defaultUiState, detectMediaKind, findSelectionPosition, getDocPermissions, getEditorMarkdown, hasContentAbove, markHideFloatingOnNext, parseEditorContent, pickFile, printDocument, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, serializeEditorMarkdown, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize } from './chunk-SV3LH2TC.js';
2
2
  export { Button, MAC_SYMBOLS, MAX_FILE_SIZE, Popover, PopoverContent, PopoverTrigger, SR_ONLY, clamp, cn, findNodeAtPosition, findNodePosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, parseShortcutKeys, removeEmptyParagraphs, sanitizeUrl, selectCurrentBlockContent, selectionWithinConvertibleTypes, updateNodesAttr, useTiptapEditor } from './chunk-MGSVKKK7.js';
3
3
  import './chunk-UD6MDBTN.js';
4
4
  import './chunk-ABMZOL26.js';
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ registerFormat({
31
31
  importExtensions: [".docx", ".md", ".html"],
32
32
  exportFormats: ["docx", "html", "json", "markdown"]
33
33
  },
34
- load: () => import('./DocView-KUVYBQ66.js')
34
+ load: () => import('./DocView-5LI4KWEZ.js')
35
35
  });
36
36
  registerFormat({
37
37
  format: "sheet",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4399ywkf/editor",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "4399 多格式文档编辑器:doc(tiptap) / sheet(univer) / pdf / pptx,含 docx·xlsx·csv 双向导入导出与 AI 可驱动的结构化编辑面(./doc-runtime、./sheet-runtime)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -86,6 +86,7 @@
86
86
  "@tiptap/extension-highlight": "^3.30.0",
87
87
  "@tiptap/extension-horizontal-rule": "^3.30.0",
88
88
  "@tiptap/extension-image": "^3.30.0",
89
+ "@tiptap/extension-link": "^3.30.0",
89
90
  "@tiptap/extension-list": "^3.30.0",
90
91
  "@tiptap/extension-mathematics": "^3.30.0",
91
92
  "@tiptap/extension-mention": "^3.30.0",