@4399ywkf/editor 0.13.1 → 0.14.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.
@@ -46524,14 +46524,14 @@ function getOverflowAncestors(node, list, traverseIframes) {
46524
46524
  if (traverseIframes === void 0) {
46525
46525
  traverseIframes = true;
46526
46526
  }
46527
- const scrollableAncestor = getNearestOverflowAncestor(node);
46528
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
46529
- const win = getWindow(scrollableAncestor);
46527
+ const scrollableAncestor2 = getNearestOverflowAncestor(node);
46528
+ const isBody = scrollableAncestor2 === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
46529
+ const win = getWindow(scrollableAncestor2);
46530
46530
  if (isBody) {
46531
46531
  const frameElement = getFrameElement(win);
46532
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
46532
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor2) ? scrollableAncestor2 : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
46533
46533
  } else {
46534
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
46534
+ return list.concat(scrollableAncestor2, getOverflowAncestors(scrollableAncestor2, [], traverseIframes));
46535
46535
  }
46536
46536
  }
46537
46537
  function getFrameElement(win) {
@@ -71875,8 +71875,8 @@ var TableOfContents = Extension.create({
71875
71875
  if (!this.options.scrollParent) {
71876
71876
  return;
71877
71877
  }
71878
- const scrollParent22 = typeof this.options.scrollParent === "function" ? this.options.scrollParent() : this.options.scrollParent;
71879
- const scrollPosition = scrollParent22 instanceof HTMLElement ? scrollParent22.scrollTop : scrollParent22.scrollY;
71878
+ const scrollParent2 = typeof this.options.scrollParent === "function" ? this.options.scrollParent() : this.options.scrollParent;
71879
+ const scrollPosition = scrollParent2 instanceof HTMLElement ? scrollParent2.scrollTop : scrollParent2.scrollY;
71880
71880
  this.storage.scrollPosition = scrollPosition || 0;
71881
71881
  const updatedItems = addTocActiveStatesAndGetItems(this.storage.content, {
71882
71882
  editor: this.editor,
@@ -71889,18 +71889,18 @@ var TableOfContents = Extension.create({
71889
71889
  if (!this.options.scrollParent) {
71890
71890
  return;
71891
71891
  }
71892
- const scrollParent3 = typeof this.options.scrollParent === "function" ? this.options.scrollParent() : this.options.scrollParent;
71893
- if (scrollParent3) {
71894
- scrollParent3.addEventListener("scroll", this.storage.scrollHandler);
71892
+ const scrollParent = typeof this.options.scrollParent === "function" ? this.options.scrollParent() : this.options.scrollParent;
71893
+ if (scrollParent) {
71894
+ scrollParent.addEventListener("scroll", this.storage.scrollHandler);
71895
71895
  }
71896
71896
  },
71897
71897
  onDestroy() {
71898
71898
  if (!this.options.scrollParent) {
71899
71899
  return;
71900
71900
  }
71901
- const scrollParent3 = typeof this.options.scrollParent === "function" ? this.options.scrollParent() : this.options.scrollParent;
71902
- if (scrollParent3) {
71903
- scrollParent3.removeEventListener("scroll", this.storage.scrollHandler);
71901
+ const scrollParent = typeof this.options.scrollParent === "function" ? this.options.scrollParent() : this.options.scrollParent;
71902
+ if (scrollParent) {
71903
+ scrollParent.removeEventListener("scroll", this.storage.scrollHandler);
71904
71904
  }
71905
71905
  },
71906
71906
  addProseMirrorPlugins() {
@@ -76714,6 +76714,18 @@ var BlockSpacing = Extension.create({
76714
76714
  };
76715
76715
  }
76716
76716
  });
76717
+
76718
+ // src/lib/scroll-parent.ts
76719
+ function scrollableAncestor(el, styleOf = (node) => getComputedStyle(node)) {
76720
+ const { body, documentElement } = el.ownerDocument;
76721
+ for (let p = el.parentElement; p && p !== documentElement; p = p.parentElement) {
76722
+ if (p === body && styleOf(documentElement).overflowY === "visible") return null;
76723
+ const { overflowY } = styleOf(p);
76724
+ if ((overflowY === "auto" || overflowY === "scroll") && p.scrollHeight > p.clientHeight)
76725
+ return p;
76726
+ }
76727
+ return null;
76728
+ }
76717
76729
  function withOrder(item) {
76718
76730
  const order = item.editor && typeof item.pos === "number" ? headingOrderTextAt(item.editor.state, item.pos) : null;
76719
76731
  return order ? `${order} ${item.textContent}` : item.textContent;
@@ -76738,17 +76750,7 @@ function normalizeHeadingDepths(items) {
76738
76750
  }
76739
76751
  return depths;
76740
76752
  }
76741
- var getScrollableAncestor = (element) => {
76742
- let parent = element.parentElement;
76743
- while (parent) {
76744
- const { overflowY } = getComputedStyle(parent);
76745
- if ((overflowY === "auto" || overflowY === "scroll") && parent.scrollHeight > parent.clientHeight) {
76746
- return parent;
76747
- }
76748
- parent = parent.parentElement;
76749
- }
76750
- return window;
76751
- };
76753
+ var getScrollableAncestor = (element) => scrollableAncestor(element) ?? window;
76752
76754
  var isElementVisible = (element, topOffset) => {
76753
76755
  const rect = element.getBoundingClientRect();
76754
76756
  const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
@@ -83195,13 +83197,6 @@ function leafTextFor(editor) {
83195
83197
  }
83196
83198
  };
83197
83199
  }
83198
- function scrollParent(el) {
83199
- for (let p = el.parentElement; p; p = p.parentElement) {
83200
- const { overflowY } = getComputedStyle(p);
83201
- if ((overflowY === "auto" || overflowY === "scroll") && p.scrollHeight > p.clientHeight) return p;
83202
- }
83203
- return null;
83204
- }
83205
83200
  function scrollToMatch(view, from2) {
83206
83201
  let rect;
83207
83202
  try {
@@ -83209,7 +83204,7 @@ function scrollToMatch(view, from2) {
83209
83204
  } catch {
83210
83205
  return;
83211
83206
  }
83212
- const container = scrollParent(view.dom);
83207
+ const container = scrollableAncestor(view.dom);
83213
83208
  const top = container ? container.getBoundingClientRect().top : 0;
83214
83209
  const bottom = container ? container.getBoundingClientRect().bottom : window.innerHeight;
83215
83210
  if (rect.top > top + REVEAL_TOP && rect.bottom < bottom) return;
@@ -99757,15 +99752,7 @@ function stickyShift(m) {
99757
99752
  return Math.round(Math.min(shift6, max3));
99758
99753
  }
99759
99754
  function scrollParentTop(el) {
99760
- let p = el.parentElement;
99761
- while (p) {
99762
- const { overflowY } = getComputedStyle(p);
99763
- if ((overflowY === "auto" || overflowY === "scroll") && p.scrollHeight > p.clientHeight) {
99764
- return p.getBoundingClientRect().top;
99765
- }
99766
- p = p.parentElement;
99767
- }
99768
- return 0;
99755
+ return scrollableAncestor(el)?.getBoundingClientRect().top ?? 0;
99769
99756
  }
99770
99757
  function defaultTopOffset() {
99771
99758
  const header = document.querySelector(".notion-like-editor-header");
@@ -119512,13 +119499,6 @@ function showSelectAllTip() {
119512
119499
  }
119513
119500
  });
119514
119501
  }
119515
- function scrollParent2(el) {
119516
- for (let cur = el.parentElement; cur; cur = cur.parentElement) {
119517
- const { overflowY } = getComputedStyle(cur);
119518
- if ((overflowY === "auto" || overflowY === "scroll") && cur.scrollHeight > cur.clientHeight) return cur;
119519
- }
119520
- return null;
119521
- }
119522
119502
  function marqueeView(view) {
119523
119503
  const boundary = view.dom.closest(".notion-like-editor-wrapper") ?? view.dom.parentElement ?? view.dom;
119524
119504
  let start = null;
@@ -119606,7 +119586,7 @@ function marqueeView(view) {
119606
119586
  if (!view.editable || e.button !== 0 || e.shiftKey || isMac6() && e.ctrlKey) return;
119607
119587
  if (!isMargin(e)) return;
119608
119588
  e.preventDefault();
119609
- scroller = scrollParent2(view.dom);
119589
+ scroller = scrollableAncestor(view.dom);
119610
119590
  start = { x: e.clientX, y: e.clientY, scrollTop: scrollTop() };
119611
119591
  pointer = { x: e.clientX, y: e.clientY };
119612
119592
  document.addEventListener("mousemove", onMove);
@@ -119765,7 +119745,12 @@ function LoadingSpinner({ text = "Connecting..." }) {
119765
119745
  /* @__PURE__ */ jsx("div", { className: "spinner-loading-text", children: text })
119766
119746
  ] }) });
119767
119747
  }
119768
- function EditorContentArea({ hideFloatingToolbar = false }) {
119748
+ function EditorContentArea({
119749
+ hideFloatingToolbar = false,
119750
+ hideSlashMenu = false,
119751
+ hideDragHandle = false,
119752
+ hideEmojiMenu = false
119753
+ }) {
119769
119754
  const { editor } = useContext(EditorContext);
119770
119755
  useScrollToHash();
119771
119756
  if (!editor) {
@@ -119791,10 +119776,10 @@ function EditorContentArea({ hideFloatingToolbar = false }) {
119791
119776
  /* @__PURE__ */ jsx(FindReplacePanel, { editor }),
119792
119777
  /* @__PURE__ */ jsx(WordCountBadge, { editor }),
119793
119778
  isEditable && /* @__PURE__ */ jsxs(Fragment$1, { children: [
119794
- /* @__PURE__ */ jsx(DragContextMenu, {}),
119795
- /* @__PURE__ */ jsx(EmojiDropdownMenu, {}),
119779
+ !hideDragHandle && /* @__PURE__ */ jsx(DragContextMenu, {}),
119780
+ !hideEmojiMenu && /* @__PURE__ */ jsx(EmojiDropdownMenu, {}),
119796
119781
  /* @__PURE__ */ jsx(MentionDropdownMenu, {}),
119797
- /* @__PURE__ */ jsx(SlashDropdownMenu, {}),
119782
+ !hideSlashMenu && /* @__PURE__ */ jsx(SlashDropdownMenu, {}),
119798
119783
  !hideFloatingToolbar && /* @__PURE__ */ jsx(NotionToolbarFloating, {}),
119799
119784
  /* @__PURE__ */ jsx(MathEditorPopover, { editor }),
119800
119785
  /* @__PURE__ */ jsx(LinkPastePanel, { editor }),
@@ -119822,6 +119807,9 @@ function EditorProvider(props) {
119822
119807
  permissions,
119823
119808
  hideHeader = false,
119824
119809
  hideFloatingToolbar = false,
119810
+ hideSlashMenu = false,
119811
+ hideDragHandle = false,
119812
+ hideEmojiMenu = false,
119825
119813
  embedded = false,
119826
119814
  richMarkdown = false,
119827
119815
  sendKey,
@@ -120300,7 +120288,15 @@ function EditorProvider(props) {
120300
120288
  /* @__PURE__ */ jsx(ReadModeSelectionBar, { editor }),
120301
120289
  !readOnly && !hideHeader && /* @__PURE__ */ jsx(NotionEditorHeader, {}),
120302
120290
  /* @__PURE__ */ jsxs("div", { className: "notion-like-editor-layout", "data-width-mode": widthModeValue, children: [
120303
- /* @__PURE__ */ jsx(EditorContentArea, { hideFloatingToolbar }),
120291
+ /* @__PURE__ */ jsx(
120292
+ EditorContentArea,
120293
+ {
120294
+ hideFloatingToolbar,
120295
+ hideSlashMenu,
120296
+ hideDragHandle,
120297
+ hideEmojiMenu
120298
+ }
120299
+ ),
120304
120300
  !embedded && /* @__PURE__ */ jsx(TocSidebar, { topOffset: 48 })
120305
120301
  ] }),
120306
120302
  isEditable && /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -120331,6 +120327,9 @@ function NotionEditor({
120331
120327
  readOnly = false,
120332
120328
  hideHeader = false,
120333
120329
  hideFloatingToolbar = false,
120330
+ hideSlashMenu = false,
120331
+ hideDragHandle = false,
120332
+ hideEmojiMenu = false,
120334
120333
  embedded = false,
120335
120334
  richMarkdown = false,
120336
120335
  sendKey,
@@ -120363,6 +120362,9 @@ function NotionEditor({
120363
120362
  permissions,
120364
120363
  hideHeader,
120365
120364
  hideFloatingToolbar,
120365
+ hideSlashMenu,
120366
+ hideDragHandle,
120367
+ hideEmojiMenu,
120366
120368
  embedded,
120367
120369
  richMarkdown,
120368
120370
  sendKey,
@@ -120392,6 +120394,9 @@ function NotionEditorContent({
120392
120394
  permissions,
120393
120395
  hideHeader = false,
120394
120396
  hideFloatingToolbar = false,
120397
+ hideSlashMenu = false,
120398
+ hideDragHandle = false,
120399
+ hideEmojiMenu = false,
120395
120400
  embedded = false,
120396
120401
  richMarkdown = false,
120397
120402
  sendKey,
@@ -120429,6 +120434,9 @@ function NotionEditorContent({
120429
120434
  permissions,
120430
120435
  hideHeader,
120431
120436
  hideFloatingToolbar,
120437
+ hideSlashMenu,
120438
+ hideDragHandle,
120439
+ hideEmojiMenu,
120432
120440
  embedded,
120433
120441
  richMarkdown,
120434
120442
  sendKey,
@@ -120475,26 +120483,25 @@ function ArticleViewer({
120475
120483
  ) })
120476
120484
  ] });
120477
120485
  }
120486
+
120487
+ // src/components/tiptap-templates/notion-like/message-editor-defaults.ts
120488
+ function withMessageEditorDefaults(props) {
120489
+ return {
120490
+ ...props,
120491
+ embedded: props.embedded ?? true,
120492
+ hideHeader: props.hideHeader ?? true,
120493
+ sendKey: props.sendKey ?? "enter",
120494
+ placeholder: props.placeholder ?? "发送消息...",
120495
+ hideSlashMenu: props.hideSlashMenu ?? true,
120496
+ hideDragHandle: props.hideDragHandle ?? true,
120497
+ hideEmojiMenu: props.hideEmojiMenu ?? true
120498
+ };
120499
+ }
120478
120500
  function DocEditor(props) {
120479
120501
  return /* @__PURE__ */ jsx(NotionEditor, { ...props });
120480
120502
  }
120481
- function MessageEditor({
120482
- embedded = true,
120483
- hideHeader = true,
120484
- sendKey = "enter",
120485
- placeholder = "发送消息...",
120486
- ...props
120487
- }) {
120488
- return /* @__PURE__ */ jsx(
120489
- NotionEditor,
120490
- {
120491
- ...props,
120492
- embedded,
120493
- hideHeader,
120494
- sendKey,
120495
- placeholder
120496
- }
120497
- );
120503
+ function MessageEditor(props) {
120504
+ return /* @__PURE__ */ jsx(NotionEditor, { ...withMessageEditorDefaults(props) });
120498
120505
  }
120499
120506
  function useScrolling(target, options = {}) {
120500
120507
  const { debounce = 150, fallbackToDocument = true } = options;