@4399ywkf/editor 0.13.2 → 0.14.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.
@@ -1,4 +1,4 @@
1
- import { EditorConfigProvider, NotionEditor } from './chunk-I4FESO5C.js';
1
+ import { EditorConfigProvider, NotionEditor } from './chunk-IKYVPJQ5.js';
2
2
  import './chunk-MGSVKKK7.js';
3
3
  import './chunk-UD6MDBTN.js';
4
4
  import './chunk-ABMZOL26.js';
@@ -18,5 +18,5 @@ function DocView({ content, contentFormat, readOnly, room, className, onReady })
18
18
  }
19
19
 
20
20
  export { DocView as default };
21
- //# sourceMappingURL=DocView-K6PKSJII.js.map
22
- //# sourceMappingURL=DocView-K6PKSJII.js.map
21
+ //# sourceMappingURL=DocView-MZKHSN67.js.map
22
+ //# sourceMappingURL=DocView-MZKHSN67.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;;;;AAMe,SAAR,OAAA,CAAyB,EAAE,OAAA,EAAS,aAAA,EAAe,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AACjH,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,aAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-K6PKSJII.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, contentFormat, 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 contentFormat={contentFormat}\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,OAAA,CAAyB,EAAE,OAAA,EAAS,aAAA,EAAe,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AACjH,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,aAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-MZKHSN67.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, contentFormat, 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 contentFormat={contentFormat}\n readOnly={readOnly}\n onEditorReady={(editor: Editor) => onReady?.(editor)}\n />\n </EditorConfigProvider>\n </div>\n )\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { useTiptapEditor, isExtensionAvailable, isNodeInSchema, Button, cn, getSelectionBoundingRect, isSelectionValid, getSelectedNodesOfType, selectCurrentBlockContent, Popover, PopoverTrigger, PopoverContent, isValidPosition, updateNodesAttr, parseShortcutKeys, isMarkInSchema, isNodeTypeSelected, SR_ONLY, selectionWithinConvertibleTypes, getSelectedBlockNodes, findNodePosition, sanitizeUrl, clamp, handleImageUpload, focusNextNode, getAvatar, getUrlParam, isTextSelectionValid, AIButton, getElementOverflowPosition, getNodeDisplayName } from './chunk-MGSVKKK7.js';
2
- import { resolveCalloutLook, MARKDOWN_SEQ_PATTERN, markdownSeqFor, attrsForMenuAction, AUTO_NUMBER_MAX_LEVEL, AUTO, HIGHLIGHT_SWATCHES, BLOCK_BACKGROUND_SWATCHES, defaultReminder, normalizeReminder, reminderText, reminderColor, LEGACY_SWATCHES, TEXT_SWATCHES, createCodeHighlighter, swatchValue, resolveCodeLanguage, getCodeBlockTitle, CALLOUT_EMOJIS, CALLOUT_BORDER_SWATCHES, FEISHU_DEFAULT_CALLOUT, orderText, resolveShikiTheme, filterCodeLanguages, pairedBorderFor, computeHeadingOrders, notifyOptions, withDate, withWholeDay, withTime, formatTime, withNotify, withNotifyOffset, reminderFullText, remindUsersLine, calendarDays, TIME_SLOTS, parseTimeInput, resolveColorToHex, numberMenuState, MAX_SEQ_VALUE } from './chunk-UD6MDBTN.js';
1
+ import { useTiptapEditor, isExtensionAvailable, isNodeInSchema, Button, cn, getSelectionBoundingRect, isSelectionValid, getSelectedNodesOfType, selectCurrentBlockContent, Popover, PopoverTrigger, PopoverContent, isValidPosition, updateNodesAttr, parseShortcutKeys, isMarkInSchema, isNodeTypeSelected, SR_ONLY, selectionWithinConvertibleTypes, getSelectedBlockNodes, findNodePosition, sanitizeUrl, clamp, getAvatar, getUrlParam, handleImageUpload, isTextSelectionValid, AIButton, focusNextNode, getElementOverflowPosition, getNodeDisplayName } from './chunk-MGSVKKK7.js';
2
+ import { resolveCalloutLook, MARKDOWN_SEQ_PATTERN, markdownSeqFor, attrsForMenuAction, AUTO_NUMBER_MAX_LEVEL, AUTO, HIGHLIGHT_SWATCHES, BLOCK_BACKGROUND_SWATCHES, defaultReminder, normalizeReminder, reminderText, reminderColor, LEGACY_SWATCHES, TEXT_SWATCHES, createCodeHighlighter, swatchValue, resolveCodeLanguage, orderText, resolveShikiTheme, computeHeadingOrders, resolveColorToHex, getCodeBlockTitle, CALLOUT_EMOJIS, CALLOUT_BORDER_SWATCHES, FEISHU_DEFAULT_CALLOUT, numberMenuState, MAX_SEQ_VALUE, filterCodeLanguages, pairedBorderFor, notifyOptions, withDate, withWholeDay, withTime, formatTime, withNotify, withNotifyOffset, reminderFullText, remindUsersLine, calendarDays, TIME_SLOTS, parseTimeInput } from './chunk-UD6MDBTN.js';
3
3
  import { normalizeDiagram, defaultDiagram, toMermaid, DEFAULT_DIAGRAM_HEIGHT, clampDiagramHeight, toOutline, SHAPE_SIZE } from './chunk-ABMZOL26.js';
4
4
  import * as React from 'react';
5
- import { createContext, memo, forwardRef, useState, useCallback, useRef, useEffect, useMemo, lazy, useLayoutEffect, Suspense, useContext, useReducer, useId, Children, isValidElement, cloneElement } from 'react';
5
+ import { createContext, memo, forwardRef, useState, useCallback, useRef, useEffect, useMemo, lazy, useLayoutEffect, useContext, Suspense, useReducer, useId, Children, isValidElement, cloneElement } from 'react';
6
6
  import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
7
7
  import { createPortal, flushSync } from 'react-dom';
8
8
  import { Extension, Node as Node$2, mergeAttributes as mergeAttributes$1, textblockTypeInputRule, Mark, InputRule, PasteRule, getChangedRanges, combineTransactionSteps, getTextSerializersFromSchema, getTextBetween, generateJSON, generateHTML } from '@tiptap/core';
@@ -11,7 +11,7 @@ import { Fragment, Slice, Mark as Mark$1, DOMSerializer } from '@tiptap/pm/model
11
11
  import { PluginKey, Plugin, TextSelection, Selection, NodeSelection, SelectionRange } from '@tiptap/pm/state';
12
12
  import { createGlobalStyle, useTheme } from 'antd-style';
13
13
  import { serialize, compile, stringify } from 'stylis';
14
- import { Node as Node$1, ReactNodeViewRenderer, mergeAttributes, Extension as Extension$1, NodeViewWrapper, NodeViewContent, useEditorState, EditorContext, EditorContent, useEditor, isNodeSelection } from '@tiptap/react';
14
+ import { Node as Node$1, mergeAttributes, Extension as Extension$1, ReactNodeViewRenderer as ReactNodeViewRenderer$1, useEditorState, EditorContext, EditorContent, useEditor, isNodeSelection, NodeViewWrapper, NodeViewContent } from '@tiptap/react';
15
15
  import { useHotkeys } from 'react-hotkeys-hook';
16
16
  import { canJoin, ReplaceStep, Mapping } from '@tiptap/pm/transform';
17
17
  import { CodeBlock } from '@tiptap/extension-code-block';
@@ -31,7 +31,7 @@ import { Superscript } from '@tiptap/extension-superscript';
31
31
  import { Subscript } from '@tiptap/extension-subscript';
32
32
  import { TextAlign } from '@tiptap/extension-text-align';
33
33
  import { UniqueID } from '@tiptap/extension-unique-id';
34
- import { gitHubEmojis, Emoji } from '@tiptap/extension-emoji';
34
+ import { Emoji, gitHubEmojis } from '@tiptap/extension-emoji';
35
35
  import { TableOfContents, getHierarchicalIndexes } from '@tiptap/extension-table-of-contents';
36
36
  import TiptapHorizontalRule from '@tiptap/extension-horizontal-rule';
37
37
  import { Heading as Heading$1 } from '@tiptap/extension-heading';
@@ -13951,9 +13951,27 @@ function editorComponentCss(ctx) {
13951
13951
  return COMPONENT_STYLES.map((fn) => fn(ctx)).join("\n");
13952
13952
  }
13953
13953
  var SSR_PSEUDO_FLAG = "/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */";
13954
+ var PSEUDO = /:(?:first|nth|nth-last)-child/;
13955
+ function markUnsafePseudo(flat) {
13956
+ const parts = [];
13957
+ let segStart = 0;
13958
+ for (let i = 0; i < flat.length; i++) {
13959
+ const ch = flat.charCodeAt(i);
13960
+ if (ch !== 123 && ch !== 125) continue;
13961
+ const seg = flat.slice(segStart, i);
13962
+ parts.push(ch === 123 && PSEUDO.test(seg) ? `${seg} ${SSR_PSEUDO_FLAG} {` : seg + flat[i]);
13963
+ segStart = i + 1;
13964
+ }
13965
+ parts.push(flat.slice(segStart));
13966
+ return parts.join("");
13967
+ }
13968
+ var cache;
13954
13969
  function prepareForEmotion(css) {
13970
+ if (cache?.input === css) return cache.output;
13955
13971
  const flat = serialize(compile(css), stringify).replace(/\n/g, " ");
13956
- return flat.replace(/([^{}]*:(?:first|nth|nth-last)-child[^{}]*)\{/g, `$1 ${SSR_PSEUDO_FLAG} {`);
13972
+ const output = markUnsafePseudo(flat);
13973
+ cache = { input: css, output };
13974
+ return output;
13957
13975
  }
13958
13976
 
13959
13977
  // src/theme/style-context.ts
@@ -14638,6 +14656,30 @@ var getColorFromLocalStorage = () => {
14638
14656
  var getUserIdFromLocalStorage = () => {
14639
14657
  return getFromLocalStorage("_tiptap_user_id", () => uuid());
14640
14658
  };
14659
+ function isReactRenderMutation(mutation, dom, contentDOM) {
14660
+ if (mutation.type !== "childList" || !dom || !contentDOM) return false;
14661
+ if (contentDOM.contains(mutation.target)) return false;
14662
+ if (mutation.target === dom) return true;
14663
+ const changed = [
14664
+ ...Array.from(mutation.addedNodes ?? []),
14665
+ ...Array.from(mutation.removedNodes ?? [])
14666
+ ];
14667
+ return changed.includes(contentDOM);
14668
+ }
14669
+ function guardReactRenderMutations(view) {
14670
+ const v = view;
14671
+ const original = v.ignoreMutation;
14672
+ if (typeof original !== "function") return view;
14673
+ v.ignoreMutation = (mutation) => {
14674
+ if (isReactRenderMutation(mutation, v.dom, v.contentDOM)) return true;
14675
+ return original.call(view, mutation);
14676
+ };
14677
+ return view;
14678
+ }
14679
+ function ReactNodeViewRenderer(component, options) {
14680
+ const create = ReactNodeViewRenderer$1(component, options);
14681
+ return (props) => guardReactRenderMutations(create(props));
14682
+ }
14641
14683
 
14642
14684
  // src/lib/resizable-width.ts
14643
14685
  function computeResizedWidth({
@@ -52211,7 +52253,12 @@ function LoadingSpinner({ text = "Connecting..." }) {
52211
52253
  /* @__PURE__ */ jsx("div", { className: "spinner-loading-text", children: text })
52212
52254
  ] }) });
52213
52255
  }
52214
- function EditorContentArea({ hideFloatingToolbar = false }) {
52256
+ function EditorContentArea({
52257
+ hideFloatingToolbar = false,
52258
+ hideSlashMenu = false,
52259
+ hideDragHandle = false,
52260
+ hideEmojiMenu = false
52261
+ }) {
52215
52262
  const { editor } = useContext(EditorContext);
52216
52263
  useScrollToHash();
52217
52264
  if (!editor) {
@@ -52237,10 +52284,10 @@ function EditorContentArea({ hideFloatingToolbar = false }) {
52237
52284
  /* @__PURE__ */ jsx(FindReplacePanel, { editor }),
52238
52285
  /* @__PURE__ */ jsx(WordCountBadge, { editor }),
52239
52286
  isEditable && /* @__PURE__ */ jsxs(Fragment$1, { children: [
52240
- /* @__PURE__ */ jsx(DragContextMenu, {}),
52241
- /* @__PURE__ */ jsx(EmojiDropdownMenu, {}),
52287
+ !hideDragHandle && /* @__PURE__ */ jsx(DragContextMenu, {}),
52288
+ !hideEmojiMenu && /* @__PURE__ */ jsx(EmojiDropdownMenu, {}),
52242
52289
  /* @__PURE__ */ jsx(MentionDropdownMenu, {}),
52243
- /* @__PURE__ */ jsx(SlashDropdownMenu, {}),
52290
+ !hideSlashMenu && /* @__PURE__ */ jsx(SlashDropdownMenu, {}),
52244
52291
  !hideFloatingToolbar && /* @__PURE__ */ jsx(NotionToolbarFloating, {}),
52245
52292
  /* @__PURE__ */ jsx(MathEditorPopover, { editor }),
52246
52293
  /* @__PURE__ */ jsx(LinkPastePanel, { editor }),
@@ -52268,6 +52315,9 @@ function EditorProvider(props) {
52268
52315
  permissions,
52269
52316
  hideHeader = false,
52270
52317
  hideFloatingToolbar = false,
52318
+ hideSlashMenu = false,
52319
+ hideDragHandle = false,
52320
+ hideEmojiMenu = false,
52271
52321
  embedded = false,
52272
52322
  richMarkdown = false,
52273
52323
  sendKey,
@@ -52746,7 +52796,15 @@ function EditorProvider(props) {
52746
52796
  /* @__PURE__ */ jsx(ReadModeSelectionBar, { editor }),
52747
52797
  !readOnly && !hideHeader && /* @__PURE__ */ jsx(NotionEditorHeader, {}),
52748
52798
  /* @__PURE__ */ jsxs("div", { className: "notion-like-editor-layout", "data-width-mode": widthModeValue, children: [
52749
- /* @__PURE__ */ jsx(EditorContentArea, { hideFloatingToolbar }),
52799
+ /* @__PURE__ */ jsx(
52800
+ EditorContentArea,
52801
+ {
52802
+ hideFloatingToolbar,
52803
+ hideSlashMenu,
52804
+ hideDragHandle,
52805
+ hideEmojiMenu
52806
+ }
52807
+ ),
52750
52808
  !embedded && /* @__PURE__ */ jsx(TocSidebar, { topOffset: 48 })
52751
52809
  ] }),
52752
52810
  isEditable && /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -52777,6 +52835,9 @@ function NotionEditor({
52777
52835
  readOnly = false,
52778
52836
  hideHeader = false,
52779
52837
  hideFloatingToolbar = false,
52838
+ hideSlashMenu = false,
52839
+ hideDragHandle = false,
52840
+ hideEmojiMenu = false,
52780
52841
  embedded = false,
52781
52842
  richMarkdown = false,
52782
52843
  sendKey,
@@ -52809,6 +52870,9 @@ function NotionEditor({
52809
52870
  permissions,
52810
52871
  hideHeader,
52811
52872
  hideFloatingToolbar,
52873
+ hideSlashMenu,
52874
+ hideDragHandle,
52875
+ hideEmojiMenu,
52812
52876
  embedded,
52813
52877
  richMarkdown,
52814
52878
  sendKey,
@@ -52838,6 +52902,9 @@ function NotionEditorContent({
52838
52902
  permissions,
52839
52903
  hideHeader = false,
52840
52904
  hideFloatingToolbar = false,
52905
+ hideSlashMenu = false,
52906
+ hideDragHandle = false,
52907
+ hideEmojiMenu = false,
52841
52908
  embedded = false,
52842
52909
  richMarkdown = false,
52843
52910
  sendKey,
@@ -52875,6 +52942,9 @@ function NotionEditorContent({
52875
52942
  permissions,
52876
52943
  hideHeader,
52877
52944
  hideFloatingToolbar,
52945
+ hideSlashMenu,
52946
+ hideDragHandle,
52947
+ hideEmojiMenu,
52878
52948
  embedded,
52879
52949
  richMarkdown,
52880
52950
  sendKey,
@@ -52923,5 +52993,5 @@ function ArticleViewer({
52923
52993
  }
52924
52994
 
52925
52995
  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, EditorProvider, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WIDTH_MODE_ITEMS, WIDTH_MODE_MENU_HEADER, WIDTH_MODE_MENU_TITLE, 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, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize, use_ui_editor_state_default };
52926
- //# sourceMappingURL=chunk-I4FESO5C.js.map
52927
- //# sourceMappingURL=chunk-I4FESO5C.js.map
52996
+ //# sourceMappingURL=chunk-IKYVPJQ5.js.map
52997
+ //# sourceMappingURL=chunk-IKYVPJQ5.js.map