@4399ywkf/editor 0.11.0 → 0.13.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/README.md +37 -0
- package/dist/{DocView-KUVYBQ66.js → DocView-ZC6IDEAA.js} +3 -3
- package/dist/{DocView-KUVYBQ66.js.map → DocView-ZC6IDEAA.js.map} +1 -1
- package/dist/{chunk-6MZAYCF6.js → chunk-MKJY3LFJ.js} +1542 -402
- package/dist/chunk-MKJY3LFJ.js.map +1 -0
- package/dist/doc-standalone.js +1624 -397
- package/dist/doc-standalone.js.map +1 -1
- package/dist/doc.d.ts +75 -7
- package/dist/doc.js +93 -3
- package/dist/doc.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +19 -10
- package/package.json +3 -2
- package/dist/chunk-6MZAYCF6.js.map +0 -1
package/dist/doc.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, RefObject, useEffect, HTMLAttributes } from 'react';
|
|
3
3
|
import { JSONContent, Editor as Editor$1, NodeWithPos, Extension as Extension$1, Node as Node$1 } from '@tiptap/react';
|
|
4
4
|
import * as _tiptap_core from '@tiptap/core';
|
|
5
|
-
import { Editor, Extensions, JSONContent as JSONContent$1, Extension, Node as Node$2 } from '@tiptap/core';
|
|
5
|
+
import { Editor, Extensions, JSONContent as JSONContent$1, Mark, Extension, Node as Node$2 } from '@tiptap/core';
|
|
6
6
|
import { Doc } from 'yjs';
|
|
7
7
|
import { C as ContentFormat, a as CodeBlockOptions, b as CodeHighlighter } from './code-types-BTrUO25D.js';
|
|
8
8
|
export { c as CodeBlockAttrs, d as CodeGroupAttrs, H as HighlightResult, e as HighlightToken, S as ShikiTheme } from './code-types-BTrUO25D.js';
|
|
@@ -38,6 +38,26 @@ interface WidthModeContextValue {
|
|
|
38
38
|
}
|
|
39
39
|
declare const useWidthMode: () => WidthModeContextValue;
|
|
40
40
|
|
|
41
|
+
type DocumentSaveState = "unsaved" | "saving" | "saved" | "error" | "offline";
|
|
42
|
+
interface EditorDocumentConfig {
|
|
43
|
+
saveState?: DocumentSaveState;
|
|
44
|
+
onRetrySave?: () => void;
|
|
45
|
+
onShare?: () => void;
|
|
46
|
+
onOpenComments?: () => void;
|
|
47
|
+
commentCount?: number;
|
|
48
|
+
onOpenHistory?: () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface EditorCommentSelection {
|
|
52
|
+
from: number;
|
|
53
|
+
to: number;
|
|
54
|
+
text: string;
|
|
55
|
+
}
|
|
56
|
+
interface EditorCommentConfig {
|
|
57
|
+
onCreateComment: (selection: EditorCommentSelection) => void;
|
|
58
|
+
onSelectThread?: (threadId: string) => void;
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
/**
|
|
42
62
|
* 包消费者通过 `<EditorConfigProvider>` 注入业务侧能力。
|
|
43
63
|
*
|
|
@@ -292,6 +312,8 @@ interface EditorButtonConfig {
|
|
|
292
312
|
followPage?: () => void;
|
|
293
313
|
}
|
|
294
314
|
interface EditorConfig {
|
|
315
|
+
document?: EditorDocumentConfig;
|
|
316
|
+
comments?: EditorCommentConfig;
|
|
295
317
|
button?: EditorButtonConfig;
|
|
296
318
|
poll?: EditorPollConfig;
|
|
297
319
|
collab?: EditorCollabConfig;
|
|
@@ -418,6 +440,8 @@ declare function resolveEditorTheme(token: AntdTokenLike, options?: {
|
|
|
418
440
|
isDarkMode?: boolean;
|
|
419
441
|
}): ResolvedEditorTheme;
|
|
420
442
|
|
|
443
|
+
type MessageSendKey = "enter" | "mod-enter";
|
|
444
|
+
|
|
421
445
|
interface NotionEditorProps {
|
|
422
446
|
room: string;
|
|
423
447
|
placeholder?: string;
|
|
@@ -426,7 +450,7 @@ interface NotionEditorProps {
|
|
|
426
450
|
* 仅在**非协同模式**(无 provider)下生效——业务方通过 HTTP 拿到文档内容后传入。
|
|
427
451
|
* 协同模式下 yjs Doc 接管内容,传入会被忽略以免跟 sync 冲突。
|
|
428
452
|
*/
|
|
429
|
-
content?: string | JSONContent;
|
|
453
|
+
content?: string | JSONContent | null;
|
|
430
454
|
/**
|
|
431
455
|
* `content` 的格式。不传时沿用旧规则:对象按 JSON、字符串按 HTML。
|
|
432
456
|
* `"markdown"` 时字符串经 Markdown 解析(支持 `::: code-group` 代码分组);
|
|
@@ -490,6 +514,16 @@ interface NotionEditorProps {
|
|
|
490
514
|
embedded?: boolean;
|
|
491
515
|
/** 用可逆的白名单 HTML-in-Markdown 保存颜色、字号、对齐等富格式。 */
|
|
492
516
|
richMarkdown?: boolean;
|
|
517
|
+
/** 消息输入框的发送键;未传 `onSend` 时不改变默认编辑器行为。 */
|
|
518
|
+
sendKey?: MessageSendKey;
|
|
519
|
+
/** 消息输入框发送回调;回调收到当前公开 Editor 实例。 */
|
|
520
|
+
onSend?: (editor: Editor$1) => void;
|
|
521
|
+
/** 用户编辑文档后回调;宿主可在回调里读取 getJSON / getEditorMarkdown。 */
|
|
522
|
+
onUpdate?: (editor: Editor$1) => void;
|
|
523
|
+
/** 选区变化后回调;用于宿主同步工具栏、AI 或提及状态。 */
|
|
524
|
+
onSelectionUpdate?: (editor: Editor$1) => void;
|
|
525
|
+
/** 编辑器实例销毁前后由 Tiptap 触发的生命周期回调。 */
|
|
526
|
+
onEditorDestroy?: (editor: Editor$1) => void;
|
|
493
527
|
/**
|
|
494
528
|
* 编辑器实例就绪回调。包不感知业务 store —— 业务方拿到 editor 实例后自行接管
|
|
495
529
|
* (如写进 zustand store,发布时用 editor.getHTML()/getJSON() 取正文)。
|
|
@@ -520,7 +554,7 @@ interface EditorProviderProps {
|
|
|
520
554
|
ydoc: Doc;
|
|
521
555
|
placeholder?: string;
|
|
522
556
|
/** 本地编辑模式下的初始/同步内容,详见 NotionEditorProps.content */
|
|
523
|
-
content?: string | JSONContent;
|
|
557
|
+
content?: string | JSONContent | null;
|
|
524
558
|
/** 内容格式,详见 NotionEditorProps.contentFormat */
|
|
525
559
|
contentFormat?: ContentFormat;
|
|
526
560
|
/** 代码块高亮配置,详见 NotionEditorProps.codeBlock */
|
|
@@ -547,6 +581,11 @@ interface EditorProviderProps {
|
|
|
547
581
|
*/
|
|
548
582
|
embedded?: boolean;
|
|
549
583
|
richMarkdown?: boolean;
|
|
584
|
+
sendKey?: MessageSendKey;
|
|
585
|
+
onSend?: (editor: Editor$1) => void;
|
|
586
|
+
onUpdate?: (editor: Editor$1) => void;
|
|
587
|
+
onSelectionUpdate?: (editor: Editor$1) => void;
|
|
588
|
+
onEditorDestroy?: (editor: Editor$1) => void;
|
|
550
589
|
hideFloatingToolbar?: boolean;
|
|
551
590
|
/** editor 实例就绪回调,详见 NotionEditorProps.onEditorReady */
|
|
552
591
|
onEditorReady?: (editor: Editor$1) => void;
|
|
@@ -580,11 +619,11 @@ declare function EditorProvider(props: EditorProviderProps): react.JSX.Element;
|
|
|
580
619
|
/**
|
|
581
620
|
* Full editor with all necessary providers, ready to use with just a room ID
|
|
582
621
|
*/
|
|
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;
|
|
622
|
+
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
623
|
/**
|
|
585
624
|
* Internal component that handles the editor loading state
|
|
586
625
|
*/
|
|
587
|
-
declare function NotionEditorContent({ placeholder, content, contentFormat, codeBlock, readOnly, permissions, hideHeader, hideFloatingToolbar, embedded, richMarkdown, onEditorReady, extensions, pageHeader, defaultViewMode, viewMode, onViewModeChange, defaultWidthMode, widthMode, onWidthModeChange, }: {
|
|
626
|
+
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
627
|
pageHeader?: boolean;
|
|
589
628
|
defaultViewMode?: ViewMode;
|
|
590
629
|
viewMode?: ViewMode;
|
|
@@ -593,7 +632,7 @@ declare function NotionEditorContent({ placeholder, content, contentFormat, code
|
|
|
593
632
|
widthMode?: DocWidthMode;
|
|
594
633
|
onWidthModeChange?: (mode: DocWidthMode) => void;
|
|
595
634
|
placeholder?: string;
|
|
596
|
-
content?: string | JSONContent;
|
|
635
|
+
content?: string | JSONContent | null;
|
|
597
636
|
/** 内容格式,详见 NotionEditorProps.contentFormat */
|
|
598
637
|
contentFormat?: ContentFormat;
|
|
599
638
|
/** 代码块高亮配置,详见 NotionEditorProps.codeBlock */
|
|
@@ -604,6 +643,11 @@ declare function NotionEditorContent({ placeholder, content, contentFormat, code
|
|
|
604
643
|
hideFloatingToolbar?: boolean;
|
|
605
644
|
embedded?: boolean;
|
|
606
645
|
richMarkdown?: boolean;
|
|
646
|
+
sendKey?: MessageSendKey;
|
|
647
|
+
onSend?: (editor: Editor$1) => void;
|
|
648
|
+
onUpdate?: (editor: Editor$1) => void;
|
|
649
|
+
onSelectionUpdate?: (editor: Editor$1) => void;
|
|
650
|
+
onEditorDestroy?: (editor: Editor$1) => void;
|
|
607
651
|
onEditorReady?: (editor: Editor$1) => void;
|
|
608
652
|
/**
|
|
609
653
|
* 追加的 tiptap 扩展,挂在包内置扩展集之后。
|
|
@@ -640,6 +684,16 @@ interface ArticleViewerProps {
|
|
|
640
684
|
*/
|
|
641
685
|
declare function ArticleViewer({ content, contentFormat, codeBlock, placeholder, visualTheme, permissions, }: ArticleViewerProps): react.JSX.Element;
|
|
642
686
|
|
|
687
|
+
type DocEditorProps = Omit<NotionEditorProps, "sendKey" | "onSend">;
|
|
688
|
+
/** 文档编辑器(对标飞书云文档):整页文档编辑,不带发送行为。 */
|
|
689
|
+
declare function DocEditor(props: DocEditorProps): react.JSX.Element;
|
|
690
|
+
type MessageEditorProps = Omit<NotionEditorProps, "onSend"> & {
|
|
691
|
+
/** 发送回调(必填);按 `sendKey` 触发,输入法选词、提及菜单打开时不触发。 */
|
|
692
|
+
onSend: (editor: Editor) => void;
|
|
693
|
+
};
|
|
694
|
+
/** 消息编辑器(对标飞书消息输入框):默认内嵌、无顶部工具条、Enter 发送。 */
|
|
695
|
+
declare function MessageEditor({ embedded, hideHeader, sendKey, placeholder, ...props }: MessageEditorProps): react.JSX.Element;
|
|
696
|
+
|
|
643
697
|
interface EditorThemeStyleProps {
|
|
644
698
|
/** 视觉风格,默认 Notion */
|
|
645
699
|
visualTheme?: EditorVisualTheme;
|
|
@@ -736,6 +790,20 @@ interface ApiParamAttrs {
|
|
|
736
790
|
|
|
737
791
|
declare const ApiParamExtension: _tiptap_core.Node<any, any>;
|
|
738
792
|
|
|
793
|
+
interface CommentThreadOptions extends Pick<EditorCommentConfig, "onSelectThread"> {
|
|
794
|
+
isInteractive?: () => boolean;
|
|
795
|
+
}
|
|
796
|
+
declare function refreshCommentThreadInteractivity(editor: Editor, interactive?: boolean): void;
|
|
797
|
+
declare module "@tiptap/core" {
|
|
798
|
+
interface Commands<ReturnType> {
|
|
799
|
+
commentThread: {
|
|
800
|
+
setCommentThread: (threadId: string) => ReturnType;
|
|
801
|
+
unsetCommentThread: (threadId: string) => ReturnType;
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
declare const CommentThread: Mark<CommentThreadOptions, any>;
|
|
806
|
+
|
|
739
807
|
type CollabContextValue = {
|
|
740
808
|
provider: CollabProviderLike | null;
|
|
741
809
|
ydoc: Doc;
|
|
@@ -1697,4 +1765,4 @@ declare function WidthModeMenu(props?: {
|
|
|
1697
1765
|
onChange?: (mode: DocWidthMode) => void;
|
|
1698
1766
|
}): react.JSX.Element;
|
|
1699
1767
|
|
|
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 };
|
|
1768
|
+
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, CommentThread, ContentFormat, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, type DetailsAttrs, DetailsExtension, DocEditor, type DocEditorProps, type DocPermissions, type DocWidthMode, type DocumentSaveState, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type EditorButtonConfig, type EditorCollabConfig, type EditorCommentConfig, type EditorCommentSelection, type EditorConfig, EditorConfigProvider, type EditorConfigProviderProps, EditorContentArea, type EditorDocumentConfig, 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, MessageEditor, type MessageEditorProps, 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, refreshCommentThreadInteractivity, 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,9 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
import { NotionEditor, useWidthMode, WIDTH_MODE_MENU_TITLE, WIDTH_MODE_MENU_HEADER, WIDTH_MODE_ITEMS } from './chunk-MKJY3LFJ.js';
|
|
2
|
+
export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, CommentThread, 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, countDocument, countRange, countText, defaultUiState, detectMediaKind, findSelectionPosition, getDocPermissions, getEditorMarkdown, hasContentAbove, markHideFloatingOnNext, parseEditorContent, pickFile, printDocument, refreshCommentThreadInteractivity, 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-MKJY3LFJ.js';
|
|
2
3
|
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
4
|
import './chunk-UD6MDBTN.js';
|
|
4
5
|
import './chunk-ABMZOL26.js';
|
|
5
|
-
import {
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
import { useState, useEffect, useRef } from 'react';
|
|
6
8
|
|
|
9
|
+
function DocEditor(props) {
|
|
10
|
+
return /* @__PURE__ */ jsx(NotionEditor, { ...props });
|
|
11
|
+
}
|
|
12
|
+
function MessageEditor({
|
|
13
|
+
embedded = true,
|
|
14
|
+
hideHeader = true,
|
|
15
|
+
sendKey = "enter",
|
|
16
|
+
placeholder = "发送消息...",
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
NotionEditor,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
embedded,
|
|
24
|
+
hideHeader,
|
|
25
|
+
sendKey,
|
|
26
|
+
placeholder
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
7
30
|
function useScrolling(target, options = {}) {
|
|
8
31
|
const { debounce = 150, fallbackToDocument = true } = options;
|
|
9
32
|
const [isScrolling, setIsScrolling] = useState(false);
|
|
@@ -36,7 +59,74 @@ function useScrolling(target, options = {}) {
|
|
|
36
59
|
}, [target, debounce, fallbackToDocument, isScrolling]);
|
|
37
60
|
return isScrolling;
|
|
38
61
|
}
|
|
62
|
+
var PageWidthIcon = () => /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
63
|
+
/* @__PURE__ */ jsx("path", { d: "M3 4v16M21 4v16" }),
|
|
64
|
+
/* @__PURE__ */ jsx("path", { d: "M7 12h10M10 9l-3 3 3 3M14 9l3 3-3 3" })
|
|
65
|
+
] });
|
|
66
|
+
function WidthModeMenu(props = {}) {
|
|
67
|
+
const ctx = useWidthMode();
|
|
68
|
+
const mode = props.mode ?? ctx.mode;
|
|
69
|
+
const setMode = props.onChange ?? ctx.setMode;
|
|
70
|
+
const [open, setOpen] = useState(false);
|
|
71
|
+
const ref = useRef(null);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!open) return;
|
|
74
|
+
const onDown = (e) => {
|
|
75
|
+
if (!ref.current?.contains(e.target)) setOpen(false);
|
|
76
|
+
};
|
|
77
|
+
const onKey = (e) => {
|
|
78
|
+
if (e.key === "Escape") setOpen(false);
|
|
79
|
+
};
|
|
80
|
+
document.addEventListener("mousedown", onDown);
|
|
81
|
+
document.addEventListener("keydown", onKey);
|
|
82
|
+
return () => {
|
|
83
|
+
document.removeEventListener("mousedown", onDown);
|
|
84
|
+
document.removeEventListener("keydown", onKey);
|
|
85
|
+
};
|
|
86
|
+
}, [open]);
|
|
87
|
+
return /* @__PURE__ */ jsxs("div", { className: "tt-width-mode", ref, children: [
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
"button",
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
className: "tt-width-mode__btn",
|
|
93
|
+
"aria-label": WIDTH_MODE_MENU_TITLE,
|
|
94
|
+
title: WIDTH_MODE_MENU_TITLE,
|
|
95
|
+
"aria-haspopup": "menu",
|
|
96
|
+
"aria-expanded": open,
|
|
97
|
+
onClick: () => setOpen((o) => !o),
|
|
98
|
+
children: /* @__PURE__ */ jsx(PageWidthIcon, {})
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
open ? /* @__PURE__ */ jsxs("div", { className: "tt-width-mode__menu", role: "menu", "aria-label": WIDTH_MODE_MENU_TITLE, children: [
|
|
102
|
+
/* @__PURE__ */ jsx("div", { className: "tt-width-mode__header", children: WIDTH_MODE_MENU_HEADER }),
|
|
103
|
+
/* @__PURE__ */ jsx("div", { className: "tt-width-mode__items", children: WIDTH_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
type: "button",
|
|
107
|
+
role: "menuitemradio",
|
|
108
|
+
"aria-checked": item.mode === mode,
|
|
109
|
+
className: `tt-width-mode__item tt-width-mode__item--${item.mode}`,
|
|
110
|
+
onClick: () => {
|
|
111
|
+
setOpen(false);
|
|
112
|
+
if (item.mode !== mode) setMode(item.mode);
|
|
113
|
+
},
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsxs("span", { className: "tt-width-mode__icon", "aria-hidden": "true", children: [
|
|
116
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
117
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
118
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
119
|
+
/* @__PURE__ */ jsx("span", {})
|
|
120
|
+
] }),
|
|
121
|
+
/* @__PURE__ */ jsx("span", { className: "tt-width-mode__name", children: item.name })
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
item.mode
|
|
125
|
+
)) })
|
|
126
|
+
] }) : null
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
39
129
|
|
|
40
|
-
export { useScrolling };
|
|
130
|
+
export { DocEditor, MessageEditor, WidthModeMenu, useScrolling };
|
|
41
131
|
//# sourceMappingURL=doc.js.map
|
|
42
132
|
//# sourceMappingURL=doc.js.map
|
package/dist/doc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-scrolling.ts"],"names":[],"mappings":";;;;;;AAWO,SAAS,YAAA,CACd,MAAA,EACA,OAAA,GAA+B,EAAC,EACvB;AACT,EAAA,MAAM,EAAE,QAAA,GAAW,GAAA,EAAK,kBAAA,GAAqB,MAAK,GAAI,OAAA;AACtD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,KAAK,CAAA;AAEpD,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,MAAM,OAAA,GACJ,UAAU,OAAO,MAAA,KAAW,eAAe,MAAA,YAAkB,MAAA,GACzD,MAAA,GACE,MAAA,EAAmC,OAAA,IAAW,MAAA;AAGtD,IAAA,MAAM,cACJ,kBAAA,IACA,OAAA,KAAY,UACZ,OAAO,QAAA,KAAa,cAChB,QAAA,GACA,OAAA;AAEN,IAAA,MAAM,EAAA,GAAK,CACT,EAAA,EACA,KAAA,EACA,YACG,EAAA,CAAG,gBAAA,CAAiB,KAAA,EAAO,OAAA,EAAS,IAAI,CAAA;AAE7C,IAAA,MAAM,GAAA,GAAM,CACV,EAAA,EACA,KAAA,EACA,YACG,EAAA,CAAG,mBAAA,CAAoB,OAAO,OAAO,CAAA;AAE1C,IAAA,IAAI,OAAA;AACJ,IAAA,MAAM,iBAAA,GAAoB,OAAA,KAAY,MAAA,IAAU,aAAA,IAAiB,MAAA;AAEjE,IAAA,MAAM,eAA8B,MAAM;AACxC,MAAA,IAAI,CAAC,WAAA,EAAa,cAAA,CAAe,IAAI,CAAA;AAErC,MAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,QAAA,YAAA,CAAa,OAAO,CAAA;AACpB,QAAA,OAAA,GAAU,UAAA,CAAW,MAAM,cAAA,CAAe,KAAK,GAAG,QAAQ,CAAA;AAAA,MAC5D;AAAA,IACF,CAAA;AAEA,IAAA,MAAM,eAAA,GAAiC,MAAM,cAAA,CAAe,KAAK,CAAA;AAEjE,IAAA,EAAA,CAAG,WAAA,EAAa,UAAU,YAAY,CAAA;AACtC,IAAA,IAAI,iBAAA,EAAmB;AACrB,MAAA,EAAA,CAAG,WAAA,EAAa,aAAa,eAAe,CAAA;AAAA,IAC9C;AAEA,IAAA,OAAO,MAAM;AACX,MAAA,GAAA,CAAI,WAAA,EAAa,UAAU,YAAY,CAAA;AACvC,MAAA,IAAI,iBAAA,EAAmB;AACrB,QAAA,GAAA,CAAI,WAAA,EAAa,aAAa,eAAe,CAAA;AAAA,MAC/C;AACA,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA,IACtB,CAAA;AAAA,EACF,GAAG,CAAC,MAAA,EAAQ,QAAA,EAAU,kBAAA,EAAoB,WAAW,CAAC,CAAA;AAEtD,EAAA,OAAO,WAAA;AACT","file":"doc.js","sourcesContent":["import type { RefObject } from \"react\"\nimport { useEffect, useState } from \"react\"\n\ntype ScrollTarget = RefObject<HTMLElement> | Window | null | undefined\ntype EventTargetWithScroll = Window | HTMLElement | Document\n\ninterface UseScrollingOptions {\n debounce?: number\n fallbackToDocument?: boolean\n}\n\nexport function useScrolling(\n target?: ScrollTarget,\n options: UseScrollingOptions = {}\n): boolean {\n const { debounce = 150, fallbackToDocument = true } = options\n const [isScrolling, setIsScrolling] = useState(false)\n\n useEffect(() => {\n // Resolve element or window\n const element: EventTargetWithScroll =\n target && typeof Window !== \"undefined\" && target instanceof Window\n ? target\n : ((target as RefObject<HTMLElement>)?.current ?? window)\n\n // Mobile: fallback to document when using window\n const eventTarget: EventTargetWithScroll =\n fallbackToDocument &&\n element === window &&\n typeof document !== \"undefined\"\n ? document\n : element\n\n const on = (\n el: EventTargetWithScroll,\n event: string,\n handler: EventListener\n ) => el.addEventListener(event, handler, true)\n\n const off = (\n el: EventTargetWithScroll,\n event: string,\n handler: EventListener\n ) => el.removeEventListener(event, handler)\n\n let timeout: ReturnType<typeof setTimeout>\n const supportsScrollEnd = element === window && \"onscrollend\" in window\n\n const handleScroll: EventListener = () => {\n if (!isScrolling) setIsScrolling(true)\n\n if (!supportsScrollEnd) {\n clearTimeout(timeout)\n timeout = setTimeout(() => setIsScrolling(false), debounce)\n }\n }\n\n const handleScrollEnd: EventListener = () => setIsScrolling(false)\n\n on(eventTarget, \"scroll\", handleScroll)\n if (supportsScrollEnd) {\n on(eventTarget, \"scrollend\", handleScrollEnd)\n }\n\n return () => {\n off(eventTarget, \"scroll\", handleScroll)\n if (supportsScrollEnd) {\n off(eventTarget, \"scrollend\", handleScrollEnd)\n }\n clearTimeout(timeout)\n }\n }, [target, debounce, fallbackToDocument, isScrolling])\n\n return isScrolling\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/tiptap-templates/notion-like/editor-presets.tsx","../src/hooks/use-scrolling.ts","../src/components/tiptap-ui/width-mode-menu/width-mode-menu.tsx"],"names":["jsx","useState","useEffect"],"mappings":";;;;;;;;AAMO,SAAS,UAAU,KAAA,EAAuB;AAC/C,EAAA,uBAAO,GAAA,CAAC,YAAA,EAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AAClC;AAQO,SAAS,aAAA,CAAc;AAAA,EAC5B,QAAA,GAAW,IAAA;AAAA,EACX,UAAA,GA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AAA,EAAK,SAAA,EAAU,qBAAA,EAAuB,eAAK,IAAA,EAAK;AAAA;AAAA,SAAA;AAAA,QAhB5C,IAAA,CAAK;AAAA,OAkBb,CAAA,EACH;AAAA,KAAA,EACF,CAAA,GACE;AAAA,GAAA,EACN,CAAA;AAEJ","file":"doc.js","sourcesContent":["import type { Editor } from \"@tiptap/core\"\nimport { NotionEditor, type NotionEditorProps } from \"./notion-like-editor\"\n\nexport type DocEditorProps = Omit<NotionEditorProps, \"sendKey\" | \"onSend\">\n\n/** 文档编辑器(对标飞书云文档):整页文档编辑,不带发送行为。 */\nexport function DocEditor(props: DocEditorProps) {\n return <NotionEditor {...props} />\n}\n\nexport type MessageEditorProps = Omit<NotionEditorProps, \"onSend\"> & {\n /** 发送回调(必填);按 `sendKey` 触发,输入法选词、提及菜单打开时不触发。 */\n onSend: (editor: Editor) => void\n}\n\n/** 消息编辑器(对标飞书消息输入框):默认内嵌、无顶部工具条、Enter 发送。 */\nexport function MessageEditor({\n embedded = true,\n hideHeader = true,\n sendKey = \"enter\",\n placeholder = \"发送消息...\",\n ...props\n}: MessageEditorProps) {\n return (\n <NotionEditor\n {...props}\n embedded={embedded}\n hideHeader={hideHeader}\n sendKey={sendKey}\n placeholder={placeholder}\n />\n )\n}\n","import type { RefObject } from \"react\"\nimport { useEffect, useState } from \"react\"\n\ntype ScrollTarget = RefObject<HTMLElement> | Window | null | undefined\ntype EventTargetWithScroll = Window | HTMLElement | Document\n\ninterface UseScrollingOptions {\n debounce?: number\n fallbackToDocument?: boolean\n}\n\nexport function useScrolling(\n target?: ScrollTarget,\n options: UseScrollingOptions = {}\n): boolean {\n const { debounce = 150, fallbackToDocument = true } = options\n const [isScrolling, setIsScrolling] = useState(false)\n\n useEffect(() => {\n // Resolve element or window\n const element: EventTargetWithScroll =\n target && typeof Window !== \"undefined\" && target instanceof Window\n ? target\n : ((target as RefObject<HTMLElement>)?.current ?? window)\n\n // Mobile: fallback to document when using window\n const eventTarget: EventTargetWithScroll =\n fallbackToDocument &&\n element === window &&\n typeof document !== \"undefined\"\n ? document\n : element\n\n const on = (\n el: EventTargetWithScroll,\n event: string,\n handler: EventListener\n ) => el.addEventListener(event, handler, true)\n\n const off = (\n el: EventTargetWithScroll,\n event: string,\n handler: EventListener\n ) => el.removeEventListener(event, handler)\n\n let timeout: ReturnType<typeof setTimeout>\n const supportsScrollEnd = element === window && \"onscrollend\" in window\n\n const handleScroll: EventListener = () => {\n if (!isScrolling) setIsScrolling(true)\n\n if (!supportsScrollEnd) {\n clearTimeout(timeout)\n timeout = setTimeout(() => setIsScrolling(false), debounce)\n }\n }\n\n const handleScrollEnd: EventListener = () => setIsScrolling(false)\n\n on(eventTarget, \"scroll\", handleScroll)\n if (supportsScrollEnd) {\n on(eventTarget, \"scrollend\", handleScrollEnd)\n }\n\n return () => {\n off(eventTarget, \"scroll\", handleScroll)\n if (supportsScrollEnd) {\n off(eventTarget, \"scrollend\", handleScrollEnd)\n }\n clearTimeout(timeout)\n }\n }, [target, debounce, fallbackToDocument, isScrolling])\n\n return isScrolling\n}\n","import { useEffect, useRef, useState } from \"react\"\n\nimport {\n type DocWidthMode,\n WIDTH_MODE_ITEMS,\n WIDTH_MODE_MENU_HEADER,\n WIDTH_MODE_MENU_TITLE,\n useWidthMode,\n} from \"../../../contexts/width-mode-context\"\n\n\nexport const PageWidthIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M3 4v16M21 4v16\" />\n <path d=\"M7 12h10M10 9l-3 3 3 3M14 9l3 3-3 3\" />\n </svg>\n)\n\n/**\n * 页宽设置(飞书「···」更多菜单里的 DOCX_WIDTH_MODE,module 785625 / 947449):\n * 弹层顶上一行「为当前窗口选择合适页宽」,下面三张卡片「默认 / 较宽 / 全宽」,每张是四条线画的示意图 + 名字,当前项高亮。\n * 我们顶栏没有「···」菜单,做成顶栏上的一个按钮。\n *\n * 编辑器顶栏里不用传参;宿主隐藏了顶栏、放进自己的头部时传 `mode` / `onChange`,\n * 再把同一个 mode 作为 `<NotionEditor widthMode>` 传给编辑器。\n */\nexport function WidthModeMenu(props: { mode?: DocWidthMode; onChange?: (mode: DocWidthMode) => void } = {}) {\n const ctx = useWidthMode()\n const mode = props.mode ?? ctx.mode\n const setMode = props.onChange ?? ctx.setMode\n const [open, setOpen] = useState(false)\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!open) return\n const onDown = (e: MouseEvent) => {\n if (!ref.current?.contains(e.target as Node)) setOpen(false)\n }\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false)\n }\n document.addEventListener(\"mousedown\", onDown)\n document.addEventListener(\"keydown\", onKey)\n return () => {\n document.removeEventListener(\"mousedown\", onDown)\n document.removeEventListener(\"keydown\", onKey)\n }\n }, [open])\n\n return (\n <div className=\"tt-width-mode\" ref={ref}>\n <button\n type=\"button\"\n className=\"tt-width-mode__btn\"\n aria-label={WIDTH_MODE_MENU_TITLE}\n title={WIDTH_MODE_MENU_TITLE}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={() => setOpen((o) => !o)}\n >\n <PageWidthIcon />\n </button>\n {open ? (\n <div className=\"tt-width-mode__menu\" role=\"menu\" aria-label={WIDTH_MODE_MENU_TITLE}>\n <div className=\"tt-width-mode__header\">{WIDTH_MODE_MENU_HEADER}</div>\n <div className=\"tt-width-mode__items\">\n {WIDTH_MODE_ITEMS.map((item) => (\n <button\n key={item.mode}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={item.mode === mode}\n className={`tt-width-mode__item tt-width-mode__item--${item.mode}`}\n onClick={() => {\n setOpen(false)\n if (item.mode !== mode) setMode(item.mode)\n }}\n >\n <span className=\"tt-width-mode__icon\" aria-hidden=\"true\">\n <span />\n <span />\n <span />\n <span />\n </span>\n <span className=\"tt-width-mode__name\">{item.name}</span>\n </button>\n ))}\n </div>\n </div>\n ) : null}\n </div>\n )\n}\n"]}
|
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-
|
|
34
|
+
load: () => import('./DocView-ZC6IDEAA.js')
|
|
35
35
|
});
|
|
36
36
|
registerFormat({
|
|
37
37
|
format: "sheet",
|