@tiptap/vue-2 3.4.1 → 3.4.3

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.
@@ -1635,10 +1635,12 @@ var BubbleMenuView = class {
1635
1635
  resizeDelay = 60,
1636
1636
  shouldShow,
1637
1637
  appendTo,
1638
+ getReferencedVirtualElement,
1638
1639
  options
1639
1640
  }) {
1640
1641
  this.preventHide = false;
1641
1642
  this.isVisible = false;
1643
+ this.scrollTarget = window;
1642
1644
  this.floatingUIOptions = {
1643
1645
  strategy: "absolute",
1644
1646
  placement: "top",
@@ -1684,12 +1686,12 @@ var BubbleMenuView = class {
1684
1686
  setTimeout(() => this.update(this.editor.view));
1685
1687
  };
1686
1688
  this.blurHandler = ({ event }) => {
1687
- var _a;
1689
+ var _a2;
1688
1690
  if (this.preventHide) {
1689
1691
  this.preventHide = false;
1690
1692
  return;
1691
1693
  }
1692
- if ((event == null ? void 0 : event.relatedTarget) && ((_a = this.element.parentNode) == null ? void 0 : _a.contains(event.relatedTarget))) {
1694
+ if ((event == null ? void 0 : event.relatedTarget) && ((_a2 = this.element.parentNode) == null ? void 0 : _a2.contains(event.relatedTarget))) {
1693
1695
  return;
1694
1696
  }
1695
1697
  if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
@@ -1724,12 +1726,15 @@ var BubbleMenuView = class {
1724
1726
  this.updatePosition();
1725
1727
  this.show();
1726
1728
  };
1729
+ var _a;
1727
1730
  this.editor = editor;
1728
1731
  this.element = element;
1729
1732
  this.view = view;
1730
1733
  this.updateDelay = updateDelay;
1731
1734
  this.resizeDelay = resizeDelay;
1732
1735
  this.appendTo = appendTo;
1736
+ this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
1737
+ this.getReferencedVirtualElement = getReferencedVirtualElement;
1733
1738
  this.floatingUIOptions = {
1734
1739
  ...this.floatingUIOptions,
1735
1740
  ...options
@@ -1743,6 +1748,7 @@ var BubbleMenuView = class {
1743
1748
  this.editor.on("focus", this.focusHandler);
1744
1749
  this.editor.on("blur", this.blurHandler);
1745
1750
  window.addEventListener("resize", this.resizeHandler);
1751
+ this.scrollTarget.addEventListener("scroll", this.resizeHandler);
1746
1752
  this.update(view, view.state);
1747
1753
  if (this.getShouldShow()) {
1748
1754
  this.show();
@@ -1786,8 +1792,13 @@ var BubbleMenuView = class {
1786
1792
  }
1787
1793
  return middlewares;
1788
1794
  }
1789
- updatePosition() {
1795
+ get virtualElement() {
1796
+ var _a;
1790
1797
  const { selection } = this.editor.state;
1798
+ const referencedVirtualElement = (_a = this.getReferencedVirtualElement) == null ? void 0 : _a.call(this);
1799
+ if (referencedVirtualElement) {
1800
+ return referencedVirtualElement;
1801
+ }
1791
1802
  const domRect = (0, import_core3.posToDOMRect)(this.view, selection.from, selection.to);
1792
1803
  let virtualElement = {
1793
1804
  getBoundingClientRect: () => domRect,
@@ -1824,6 +1835,13 @@ var BubbleMenuView = class {
1824
1835
  getClientRects: () => [clientRect]
1825
1836
  };
1826
1837
  }
1838
+ return virtualElement;
1839
+ }
1840
+ updatePosition() {
1841
+ const virtualElement = this.virtualElement;
1842
+ if (!virtualElement) {
1843
+ return;
1844
+ }
1827
1845
  computePosition2(virtualElement, this.element, {
1828
1846
  placement: this.floatingUIOptions.placement,
1829
1847
  strategy: this.floatingUIOptions.strategy,
@@ -1897,6 +1915,7 @@ var BubbleMenuView = class {
1897
1915
  this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
1898
1916
  this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
1899
1917
  window.removeEventListener("resize", this.resizeHandler);
1918
+ this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
1900
1919
  this.editor.off("focus", this.focusHandler);
1901
1920
  this.editor.off("blur", this.blurHandler);
1902
1921
  if (this.floatingUIOptions.onDestroy) {
@@ -1933,6 +1952,7 @@ var BubbleMenu = import_core2.Extension.create({
1933
1952
  updateDelay: this.options.updateDelay,
1934
1953
  options: this.options.options,
1935
1954
  appendTo: this.options.appendTo,
1955
+ getReferencedVirtualElement: this.options.getReferencedVirtualElement,
1936
1956
  shouldShow: this.options.shouldShow
1937
1957
  })
1938
1958
  ];
@@ -1986,7 +2006,8 @@ var BubbleMenu2 = {
1986
2006
  editor,
1987
2007
  element: this.$el,
1988
2008
  pluginKey: this.pluginKey,
1989
- shouldShow: this.shouldShow
2009
+ shouldShow: this.shouldShow,
2010
+ getReferencedVirtualElement: this.getReferencedVirtualElement
1990
2011
  })
1991
2012
  );
1992
2013
  });