@tiptap/vue-2 3.0.0-beta.10 → 3.0.0-beta.12
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.
- package/dist/menus/index.cjs +77 -2
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.d.cts +8 -0
- package/dist/menus/index.d.ts +8 -0
- package/dist/menus/index.js +77 -2
- package/dist/menus/index.js.map +1 -1
- package/package.json +7 -7
package/dist/menus/index.d.cts
CHANGED
|
@@ -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
|
|
package/dist/menus/index.d.ts
CHANGED
|
@@ -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
|
|
package/dist/menus/index.js
CHANGED
|
@@ -1587,6 +1587,18 @@ var computePosition2 = (reference, floating, options) => {
|
|
|
1587
1587
|
// ../extension-bubble-menu/dist/index.js
|
|
1588
1588
|
import { isTextSelection, posToDOMRect } from "@tiptap/core";
|
|
1589
1589
|
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
1590
|
+
import { CellSelection } from "@tiptap/pm/tables";
|
|
1591
|
+
function combineDOMRects(rect1, rect2) {
|
|
1592
|
+
const top = Math.min(rect1.top, rect2.top);
|
|
1593
|
+
const bottom = Math.max(rect1.bottom, rect2.bottom);
|
|
1594
|
+
const left = Math.min(rect1.left, rect2.left);
|
|
1595
|
+
const right = Math.max(rect1.right, rect2.right);
|
|
1596
|
+
const width = right - left;
|
|
1597
|
+
const height = bottom - top;
|
|
1598
|
+
const x = left;
|
|
1599
|
+
const y = top;
|
|
1600
|
+
return new DOMRect(x, y, width, height);
|
|
1601
|
+
}
|
|
1590
1602
|
var BubbleMenuView = class {
|
|
1591
1603
|
constructor({
|
|
1592
1604
|
editor,
|
|
@@ -1598,6 +1610,7 @@ var BubbleMenuView = class {
|
|
|
1598
1610
|
options
|
|
1599
1611
|
}) {
|
|
1600
1612
|
this.preventHide = false;
|
|
1613
|
+
this.isVisible = false;
|
|
1601
1614
|
this.floatingUIOptions = {
|
|
1602
1615
|
strategy: "absolute",
|
|
1603
1616
|
placement: "top",
|
|
@@ -1608,7 +1621,11 @@ var BubbleMenuView = class {
|
|
|
1608
1621
|
size: false,
|
|
1609
1622
|
autoPlacement: false,
|
|
1610
1623
|
hide: false,
|
|
1611
|
-
inline: false
|
|
1624
|
+
inline: false,
|
|
1625
|
+
onShow: void 0,
|
|
1626
|
+
onHide: void 0,
|
|
1627
|
+
onUpdate: void 0,
|
|
1628
|
+
onDestroy: void 0
|
|
1612
1629
|
};
|
|
1613
1630
|
this.shouldShow = ({ view: view2, state, from, to }) => {
|
|
1614
1631
|
const { doc, selection } = state;
|
|
@@ -1740,9 +1757,26 @@ var BubbleMenuView = class {
|
|
|
1740
1757
|
}
|
|
1741
1758
|
updatePosition() {
|
|
1742
1759
|
const { selection } = this.editor.state;
|
|
1743
|
-
|
|
1760
|
+
let virtualElement = {
|
|
1744
1761
|
getBoundingClientRect: () => posToDOMRect(this.view, selection.from, selection.to)
|
|
1745
1762
|
};
|
|
1763
|
+
if (selection instanceof CellSelection) {
|
|
1764
|
+
const { $anchorCell, $headCell } = selection;
|
|
1765
|
+
const from = $anchorCell ? $anchorCell.pos : $headCell.pos;
|
|
1766
|
+
const to = $headCell ? $headCell.pos : $anchorCell.pos;
|
|
1767
|
+
const fromDOM = this.view.nodeDOM(from);
|
|
1768
|
+
const toDOM = this.view.nodeDOM(to);
|
|
1769
|
+
if (!fromDOM || !toDOM) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
const clientRect = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(
|
|
1773
|
+
fromDOM.getBoundingClientRect(),
|
|
1774
|
+
toDOM.getBoundingClientRect()
|
|
1775
|
+
);
|
|
1776
|
+
virtualElement = {
|
|
1777
|
+
getBoundingClientRect: () => clientRect
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1746
1780
|
computePosition2(virtualElement, this.element, {
|
|
1747
1781
|
placement: this.floatingUIOptions.placement,
|
|
1748
1782
|
strategy: this.floatingUIOptions.strategy,
|
|
@@ -1752,6 +1786,9 @@ var BubbleMenuView = class {
|
|
|
1752
1786
|
this.element.style.position = strategy;
|
|
1753
1787
|
this.element.style.left = `${x}px`;
|
|
1754
1788
|
this.element.style.top = `${y}px`;
|
|
1789
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
1790
|
+
this.floatingUIOptions.onUpdate();
|
|
1791
|
+
}
|
|
1755
1792
|
});
|
|
1756
1793
|
}
|
|
1757
1794
|
update(view, oldState) {
|
|
@@ -1785,14 +1822,28 @@ var BubbleMenuView = class {
|
|
|
1785
1822
|
}
|
|
1786
1823
|
show() {
|
|
1787
1824
|
var _a;
|
|
1825
|
+
if (this.isVisible) {
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1788
1828
|
this.element.style.visibility = "visible";
|
|
1789
1829
|
this.element.style.opacity = "1";
|
|
1790
1830
|
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
1831
|
+
if (this.floatingUIOptions.onShow) {
|
|
1832
|
+
this.floatingUIOptions.onShow();
|
|
1833
|
+
}
|
|
1834
|
+
this.isVisible = true;
|
|
1791
1835
|
}
|
|
1792
1836
|
hide() {
|
|
1837
|
+
if (!this.isVisible) {
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1793
1840
|
this.element.style.visibility = "hidden";
|
|
1794
1841
|
this.element.style.opacity = "0";
|
|
1795
1842
|
this.element.remove();
|
|
1843
|
+
if (this.floatingUIOptions.onHide) {
|
|
1844
|
+
this.floatingUIOptions.onHide();
|
|
1845
|
+
}
|
|
1846
|
+
this.isVisible = false;
|
|
1796
1847
|
}
|
|
1797
1848
|
destroy() {
|
|
1798
1849
|
this.hide();
|
|
@@ -1800,6 +1851,9 @@ var BubbleMenuView = class {
|
|
|
1800
1851
|
this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
|
|
1801
1852
|
this.editor.off("focus", this.focusHandler);
|
|
1802
1853
|
this.editor.off("blur", this.blurHandler);
|
|
1854
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
1855
|
+
this.floatingUIOptions.onDestroy();
|
|
1856
|
+
}
|
|
1803
1857
|
}
|
|
1804
1858
|
};
|
|
1805
1859
|
var BubbleMenuPlugin = (options) => {
|
|
@@ -1903,6 +1957,7 @@ import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
|
|
|
1903
1957
|
var FloatingMenuView = class {
|
|
1904
1958
|
constructor({ editor, element, view, options, shouldShow }) {
|
|
1905
1959
|
this.preventHide = false;
|
|
1960
|
+
this.isVisible = false;
|
|
1906
1961
|
this.shouldShow = ({ view: view2, state }) => {
|
|
1907
1962
|
const { selection } = state;
|
|
1908
1963
|
const { $anchor, empty } = selection;
|
|
@@ -2049,6 +2104,9 @@ var FloatingMenuView = class {
|
|
|
2049
2104
|
this.element.style.position = strategy;
|
|
2050
2105
|
this.element.style.left = `${x}px`;
|
|
2051
2106
|
this.element.style.top = `${y}px`;
|
|
2107
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
2108
|
+
this.floatingUIOptions.onUpdate();
|
|
2109
|
+
}
|
|
2052
2110
|
});
|
|
2053
2111
|
}
|
|
2054
2112
|
update(view, oldState) {
|
|
@@ -2058,20 +2116,37 @@ var FloatingMenuView = class {
|
|
|
2058
2116
|
}
|
|
2059
2117
|
show() {
|
|
2060
2118
|
var _a;
|
|
2119
|
+
if (this.isVisible) {
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2061
2122
|
this.element.style.visibility = "visible";
|
|
2062
2123
|
this.element.style.opacity = "1";
|
|
2063
2124
|
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
2125
|
+
if (this.floatingUIOptions.onShow) {
|
|
2126
|
+
this.floatingUIOptions.onShow();
|
|
2127
|
+
}
|
|
2128
|
+
this.isVisible = true;
|
|
2064
2129
|
}
|
|
2065
2130
|
hide() {
|
|
2131
|
+
if (!this.isVisible) {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2066
2134
|
this.element.style.visibility = "hidden";
|
|
2067
2135
|
this.element.style.opacity = "0";
|
|
2068
2136
|
this.element.remove();
|
|
2137
|
+
if (this.floatingUIOptions.onHide) {
|
|
2138
|
+
this.floatingUIOptions.onHide();
|
|
2139
|
+
}
|
|
2140
|
+
this.isVisible = false;
|
|
2069
2141
|
}
|
|
2070
2142
|
destroy() {
|
|
2071
2143
|
this.hide();
|
|
2072
2144
|
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
2073
2145
|
this.editor.off("focus", this.focusHandler);
|
|
2074
2146
|
this.editor.off("blur", this.blurHandler);
|
|
2147
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
2148
|
+
this.floatingUIOptions.onDestroy();
|
|
2149
|
+
}
|
|
2075
2150
|
}
|
|
2076
2151
|
};
|
|
2077
2152
|
var FloatingMenuPlugin = (options) => {
|