@tiptap/vue-2 3.0.0-beta.10 → 3.0.0-beta.11

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.
@@ -62,6 +62,10 @@ interface BubbleMenuPluginProps {
62
62
  autoPlacement?: Parameters<typeof autoPlacement>[0] | boolean;
63
63
  hide?: Parameters<typeof hide>[0] | boolean;
64
64
  inline?: Parameters<typeof inline>[0] | boolean;
65
+ onShow?: () => void;
66
+ onHide?: () => void;
67
+ onUpdate?: () => void;
68
+ onDestroy?: () => void;
65
69
  };
66
70
  }
67
71
 
@@ -117,6 +121,10 @@ interface FloatingMenuPluginProps {
117
121
  autoPlacement?: Parameters<typeof autoPlacement>[0] | boolean;
118
122
  hide?: Parameters<typeof hide>[0] | boolean;
119
123
  inline?: Parameters<typeof inline>[0] | boolean;
124
+ onShow?: () => void;
125
+ onHide?: () => void;
126
+ onUpdate?: () => void;
127
+ onDestroy?: () => void;
120
128
  };
121
129
  }
122
130
 
@@ -62,6 +62,10 @@ interface BubbleMenuPluginProps {
62
62
  autoPlacement?: Parameters<typeof autoPlacement>[0] | boolean;
63
63
  hide?: Parameters<typeof hide>[0] | boolean;
64
64
  inline?: Parameters<typeof inline>[0] | boolean;
65
+ onShow?: () => void;
66
+ onHide?: () => void;
67
+ onUpdate?: () => void;
68
+ onDestroy?: () => void;
65
69
  };
66
70
  }
67
71
 
@@ -117,6 +121,10 @@ interface FloatingMenuPluginProps {
117
121
  autoPlacement?: Parameters<typeof autoPlacement>[0] | boolean;
118
122
  hide?: Parameters<typeof hide>[0] | boolean;
119
123
  inline?: Parameters<typeof inline>[0] | boolean;
124
+ onShow?: () => void;
125
+ onHide?: () => void;
126
+ onUpdate?: () => void;
127
+ onDestroy?: () => void;
120
128
  };
121
129
  }
122
130
 
@@ -1598,6 +1598,7 @@ var BubbleMenuView = class {
1598
1598
  options
1599
1599
  }) {
1600
1600
  this.preventHide = false;
1601
+ this.isVisible = false;
1601
1602
  this.floatingUIOptions = {
1602
1603
  strategy: "absolute",
1603
1604
  placement: "top",
@@ -1608,7 +1609,11 @@ var BubbleMenuView = class {
1608
1609
  size: false,
1609
1610
  autoPlacement: false,
1610
1611
  hide: false,
1611
- inline: false
1612
+ inline: false,
1613
+ onShow: void 0,
1614
+ onHide: void 0,
1615
+ onUpdate: void 0,
1616
+ onDestroy: void 0
1612
1617
  };
1613
1618
  this.shouldShow = ({ view: view2, state, from, to }) => {
1614
1619
  const { doc, selection } = state;
@@ -1752,6 +1757,9 @@ var BubbleMenuView = class {
1752
1757
  this.element.style.position = strategy;
1753
1758
  this.element.style.left = `${x}px`;
1754
1759
  this.element.style.top = `${y}px`;
1760
+ if (this.isVisible && this.floatingUIOptions.onUpdate) {
1761
+ this.floatingUIOptions.onUpdate();
1762
+ }
1755
1763
  });
1756
1764
  }
1757
1765
  update(view, oldState) {
@@ -1785,14 +1793,28 @@ var BubbleMenuView = class {
1785
1793
  }
1786
1794
  show() {
1787
1795
  var _a;
1796
+ if (this.isVisible) {
1797
+ return;
1798
+ }
1788
1799
  this.element.style.visibility = "visible";
1789
1800
  this.element.style.opacity = "1";
1790
1801
  (_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
1802
+ if (this.floatingUIOptions.onShow) {
1803
+ this.floatingUIOptions.onShow();
1804
+ }
1805
+ this.isVisible = true;
1791
1806
  }
1792
1807
  hide() {
1808
+ if (!this.isVisible) {
1809
+ return;
1810
+ }
1793
1811
  this.element.style.visibility = "hidden";
1794
1812
  this.element.style.opacity = "0";
1795
1813
  this.element.remove();
1814
+ if (this.floatingUIOptions.onHide) {
1815
+ this.floatingUIOptions.onHide();
1816
+ }
1817
+ this.isVisible = false;
1796
1818
  }
1797
1819
  destroy() {
1798
1820
  this.hide();
@@ -1800,6 +1822,9 @@ var BubbleMenuView = class {
1800
1822
  this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
1801
1823
  this.editor.off("focus", this.focusHandler);
1802
1824
  this.editor.off("blur", this.blurHandler);
1825
+ if (this.floatingUIOptions.onDestroy) {
1826
+ this.floatingUIOptions.onDestroy();
1827
+ }
1803
1828
  }
1804
1829
  };
1805
1830
  var BubbleMenuPlugin = (options) => {
@@ -1903,6 +1928,7 @@ import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
1903
1928
  var FloatingMenuView = class {
1904
1929
  constructor({ editor, element, view, options, shouldShow }) {
1905
1930
  this.preventHide = false;
1931
+ this.isVisible = false;
1906
1932
  this.shouldShow = ({ view: view2, state }) => {
1907
1933
  const { selection } = state;
1908
1934
  const { $anchor, empty } = selection;
@@ -2049,6 +2075,9 @@ var FloatingMenuView = class {
2049
2075
  this.element.style.position = strategy;
2050
2076
  this.element.style.left = `${x}px`;
2051
2077
  this.element.style.top = `${y}px`;
2078
+ if (this.isVisible && this.floatingUIOptions.onUpdate) {
2079
+ this.floatingUIOptions.onUpdate();
2080
+ }
2052
2081
  });
2053
2082
  }
2054
2083
  update(view, oldState) {
@@ -2058,20 +2087,37 @@ var FloatingMenuView = class {
2058
2087
  }
2059
2088
  show() {
2060
2089
  var _a;
2090
+ if (this.isVisible) {
2091
+ return;
2092
+ }
2061
2093
  this.element.style.visibility = "visible";
2062
2094
  this.element.style.opacity = "1";
2063
2095
  (_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
2096
+ if (this.floatingUIOptions.onShow) {
2097
+ this.floatingUIOptions.onShow();
2098
+ }
2099
+ this.isVisible = true;
2064
2100
  }
2065
2101
  hide() {
2102
+ if (!this.isVisible) {
2103
+ return;
2104
+ }
2066
2105
  this.element.style.visibility = "hidden";
2067
2106
  this.element.style.opacity = "0";
2068
2107
  this.element.remove();
2108
+ if (this.floatingUIOptions.onHide) {
2109
+ this.floatingUIOptions.onHide();
2110
+ }
2111
+ this.isVisible = false;
2069
2112
  }
2070
2113
  destroy() {
2071
2114
  this.hide();
2072
2115
  this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
2073
2116
  this.editor.off("focus", this.focusHandler);
2074
2117
  this.editor.off("blur", this.blurHandler);
2118
+ if (this.floatingUIOptions.onDestroy) {
2119
+ this.floatingUIOptions.onDestroy();
2120
+ }
2075
2121
  }
2076
2122
  };
2077
2123
  var FloatingMenuPlugin = (options) => {