@4399ywkf/editor 0.4.3 → 0.4.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 { EditorConfigProvider, NotionEditor } from './chunk-FQCG2HNJ.js';
1
+ import { EditorConfigProvider, NotionEditor } from './chunk-IUDLMN53.js';
2
2
  import './chunk-QMYT5WXO.js';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -15,5 +15,5 @@ function DocView({ content, readOnly, room, className, onReady }) {
15
15
  }
16
16
 
17
17
  export { DocView as default };
18
- //# sourceMappingURL=DocView-IZ4JBSIA.js.map
19
- //# sourceMappingURL=DocView-IZ4JBSIA.js.map
18
+ //# sourceMappingURL=DocView-XQMJUUVK.js.map
19
+ //# sourceMappingURL=DocView-XQMJUUVK.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;;AAMe,SAAR,QAAyB,EAAE,OAAA,EAAS,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AAClG,EAAA,2BACG,KAAA,EAAA,EAAI,SAAA,EACH,8BAAC,oBAAA,EAAA,EAAqB,MAAA,EAAQ,EAAC,EAC7B,QAAA,kBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,MAAM,IAAA,IAAQ,SAAA;AAAA,MACd,OAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-IZ4JBSIA.js","sourcesContent":["import type { Editor } from \"@tiptap/react\"\nimport { EditorConfigProvider } from \"../contexts/editor-config-context\"\nimport { NotionEditor } from \"../components/tiptap-templates/notion-like/notion-like-editor\"\nimport type { DocumentViewProps } from \"../registry\"\n\n/** doc 通道:云文档与本地 doc 是同一套 tiptap,不做区分 */\nexport default function DocView({ content, readOnly, room, className, onReady }: DocumentViewProps) {\n return (\n <div className={className}>\n <EditorConfigProvider config={{}}>\n <NotionEditor\n room={room ?? \"default\"}\n content={content as string}\n readOnly={readOnly}\n onEditorReady={(editor: Editor) => onReady?.(editor)}\n />\n </EditorConfigProvider>\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;;AAMe,SAAR,QAAyB,EAAE,OAAA,EAAS,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AAClG,EAAA,2BACG,KAAA,EAAA,EAAI,SAAA,EACH,8BAAC,oBAAA,EAAA,EAAqB,MAAA,EAAQ,EAAC,EAC7B,QAAA,kBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,MAAM,IAAA,IAAQ,SAAA;AAAA,MACd,OAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-XQMJUUVK.js","sourcesContent":["import type { Editor } from \"@tiptap/react\"\nimport { EditorConfigProvider } from \"../contexts/editor-config-context\"\nimport { NotionEditor } from \"../components/tiptap-templates/notion-like/notion-like-editor\"\nimport type { DocumentViewProps } from \"../registry\"\n\n/** doc 通道:云文档与本地 doc 是同一套 tiptap,不做区分 */\nexport default function DocView({ content, readOnly, room, className, onReady }: DocumentViewProps) {\n return (\n <div className={className}>\n <EditorConfigProvider config={{}}>\n <NotionEditor\n room={room ?? \"default\"}\n content={content as string}\n readOnly={readOnly}\n onEditorReady={(editor: Editor) => onReady?.(editor)}\n />\n </EditorConfigProvider>\n </div>\n )\n}\n"]}
@@ -20944,6 +20944,16 @@ function EditorProvider(props) {
20944
20944
  } = props;
20945
20945
  const { user } = useUser();
20946
20946
  const { setTocContent } = useToc();
20947
+ const scrollParentRef = useRef(null);
20948
+ const editorRef = useRef(null);
20949
+ const resolveScrollParent = useCallback(() => {
20950
+ if (scrollParentRef.current) return scrollParentRef.current;
20951
+ const dom = editorRef.current?.view?.dom;
20952
+ if (!dom?.isConnected) return window;
20953
+ const found = getScrollableAncestor(dom);
20954
+ scrollParentRef.current = found;
20955
+ return found;
20956
+ }, []);
20947
20957
  const editorConfig = useEditorConfig();
20948
20958
  const onUpload = editorConfig?.upload?.onUpload ?? handleImageUpload;
20949
20959
  const onUploadError = editorConfig?.upload?.onError ?? ((error) => console.error("Upload failed:", error));
@@ -21040,6 +21050,8 @@ function EditorProvider(props) {
21040
21050
  Image,
21041
21051
  TableOfContents.configure({
21042
21052
  getIndex: getHierarchicalIndexes,
21053
+ // 见 resolveScrollParent 的说明:默认的 window 在「内层 div 滚动」的宿主里收不到事件
21054
+ scrollParent: resolveScrollParent,
21043
21055
  onUpdate(content2) {
21044
21056
  setTocContent(content2);
21045
21057
  }
@@ -21123,6 +21135,24 @@ function EditorProvider(props) {
21123
21135
  ...extraExtensions ?? []
21124
21136
  ]
21125
21137
  });
21138
+ useEffect(() => {
21139
+ if (!editor) return;
21140
+ editorRef.current = editor;
21141
+ const dom = editor.view?.dom;
21142
+ if (!dom?.isConnected) return;
21143
+ const target = getScrollableAncestor(dom);
21144
+ if (target instanceof Window) return;
21145
+ scrollParentRef.current = target;
21146
+ const handler = () => {
21147
+ const storage = editor.storage?.tableOfContents;
21148
+ storage?.scrollHandler?.();
21149
+ };
21150
+ target.addEventListener("scroll", handler, { passive: true });
21151
+ handler();
21152
+ return () => {
21153
+ target.removeEventListener("scroll", handler);
21154
+ };
21155
+ }, [editor]);
21126
21156
  useEffect(() => {
21127
21157
  if (provider) return;
21128
21158
  if (!editor) return;
@@ -21243,5 +21273,5 @@ function ArticleViewer({ content, placeholder = "" }) {
21243
21273
  }
21244
21274
 
21245
21275
  export { ArticleViewer, Audio, CollabContext, CollabProvider, Column, Columns, DEFAULT_MAX_FILE_SIZES, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorProvider, FileAttachment, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, Video, defaultUiState, detectMediaKind, findSelectionPosition, hasContentAbove, markHideFloatingOnNext, pickFile, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, useUnmount, useUser, useWindowSize, use_ui_editor_state_default };
21246
- //# sourceMappingURL=chunk-FQCG2HNJ.js.map
21247
- //# sourceMappingURL=chunk-FQCG2HNJ.js.map
21276
+ //# sourceMappingURL=chunk-IUDLMN53.js.map
21277
+ //# sourceMappingURL=chunk-IUDLMN53.js.map