@tiptap/vue-2 3.0.0-beta.2 → 3.0.0-beta.21
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 +87 -10
- 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 +87 -10
- package/dist/menus/index.js.map +1 -1
- package/package.json +9 -9
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;
|
|
@@ -1627,6 +1644,14 @@ var BubbleMenuView = class {
|
|
|
1627
1644
|
this.dragstartHandler = () => {
|
|
1628
1645
|
this.hide();
|
|
1629
1646
|
};
|
|
1647
|
+
this.resizeHandler = () => {
|
|
1648
|
+
if (this.resizeDebounceTimer) {
|
|
1649
|
+
clearTimeout(this.resizeDebounceTimer);
|
|
1650
|
+
}
|
|
1651
|
+
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
1652
|
+
this.updatePosition();
|
|
1653
|
+
}, this.resizeDelay);
|
|
1654
|
+
};
|
|
1630
1655
|
this.focusHandler = () => {
|
|
1631
1656
|
setTimeout(() => this.update(this.editor.view));
|
|
1632
1657
|
};
|
|
@@ -1687,14 +1712,7 @@ var BubbleMenuView = class {
|
|
|
1687
1712
|
this.view.dom.addEventListener("dragstart", this.dragstartHandler);
|
|
1688
1713
|
this.editor.on("focus", this.focusHandler);
|
|
1689
1714
|
this.editor.on("blur", this.blurHandler);
|
|
1690
|
-
window.addEventListener("resize",
|
|
1691
|
-
if (this.resizeDebounceTimer) {
|
|
1692
|
-
clearTimeout(this.resizeDebounceTimer);
|
|
1693
|
-
}
|
|
1694
|
-
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
1695
|
-
this.updatePosition();
|
|
1696
|
-
}, this.resizeDelay);
|
|
1697
|
-
});
|
|
1715
|
+
window.addEventListener("resize", this.resizeHandler);
|
|
1698
1716
|
this.update(view, view.state);
|
|
1699
1717
|
if (this.getShouldShow()) {
|
|
1700
1718
|
this.show();
|
|
@@ -1740,9 +1758,26 @@ var BubbleMenuView = class {
|
|
|
1740
1758
|
}
|
|
1741
1759
|
updatePosition() {
|
|
1742
1760
|
const { selection } = this.editor.state;
|
|
1743
|
-
|
|
1761
|
+
let virtualElement = {
|
|
1744
1762
|
getBoundingClientRect: () => posToDOMRect(this.view, selection.from, selection.to)
|
|
1745
1763
|
};
|
|
1764
|
+
if (selection instanceof CellSelection) {
|
|
1765
|
+
const { $anchorCell, $headCell } = selection;
|
|
1766
|
+
const from = $anchorCell ? $anchorCell.pos : $headCell.pos;
|
|
1767
|
+
const to = $headCell ? $headCell.pos : $anchorCell.pos;
|
|
1768
|
+
const fromDOM = this.view.nodeDOM(from);
|
|
1769
|
+
const toDOM = this.view.nodeDOM(to);
|
|
1770
|
+
if (!fromDOM || !toDOM) {
|
|
1771
|
+
return;
|
|
1772
|
+
}
|
|
1773
|
+
const clientRect = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(
|
|
1774
|
+
fromDOM.getBoundingClientRect(),
|
|
1775
|
+
toDOM.getBoundingClientRect()
|
|
1776
|
+
);
|
|
1777
|
+
virtualElement = {
|
|
1778
|
+
getBoundingClientRect: () => clientRect
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1746
1781
|
computePosition2(virtualElement, this.element, {
|
|
1747
1782
|
placement: this.floatingUIOptions.placement,
|
|
1748
1783
|
strategy: this.floatingUIOptions.strategy,
|
|
@@ -1752,6 +1787,9 @@ var BubbleMenuView = class {
|
|
|
1752
1787
|
this.element.style.position = strategy;
|
|
1753
1788
|
this.element.style.left = `${x}px`;
|
|
1754
1789
|
this.element.style.top = `${y}px`;
|
|
1790
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
1791
|
+
this.floatingUIOptions.onUpdate();
|
|
1792
|
+
}
|
|
1755
1793
|
});
|
|
1756
1794
|
}
|
|
1757
1795
|
update(view, oldState) {
|
|
@@ -1785,21 +1823,39 @@ var BubbleMenuView = class {
|
|
|
1785
1823
|
}
|
|
1786
1824
|
show() {
|
|
1787
1825
|
var _a;
|
|
1826
|
+
if (this.isVisible) {
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1788
1829
|
this.element.style.visibility = "visible";
|
|
1789
1830
|
this.element.style.opacity = "1";
|
|
1790
1831
|
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
1832
|
+
if (this.floatingUIOptions.onShow) {
|
|
1833
|
+
this.floatingUIOptions.onShow();
|
|
1834
|
+
}
|
|
1835
|
+
this.isVisible = true;
|
|
1791
1836
|
}
|
|
1792
1837
|
hide() {
|
|
1838
|
+
if (!this.isVisible) {
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1793
1841
|
this.element.style.visibility = "hidden";
|
|
1794
1842
|
this.element.style.opacity = "0";
|
|
1795
1843
|
this.element.remove();
|
|
1844
|
+
if (this.floatingUIOptions.onHide) {
|
|
1845
|
+
this.floatingUIOptions.onHide();
|
|
1846
|
+
}
|
|
1847
|
+
this.isVisible = false;
|
|
1796
1848
|
}
|
|
1797
1849
|
destroy() {
|
|
1798
1850
|
this.hide();
|
|
1799
1851
|
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
1800
1852
|
this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
|
|
1853
|
+
window.removeEventListener("resize", this.resizeHandler);
|
|
1801
1854
|
this.editor.off("focus", this.focusHandler);
|
|
1802
1855
|
this.editor.off("blur", this.blurHandler);
|
|
1856
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
1857
|
+
this.floatingUIOptions.onDestroy();
|
|
1858
|
+
}
|
|
1803
1859
|
}
|
|
1804
1860
|
};
|
|
1805
1861
|
var BubbleMenuPlugin = (options) => {
|
|
@@ -1903,6 +1959,7 @@ import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
|
|
|
1903
1959
|
var FloatingMenuView = class {
|
|
1904
1960
|
constructor({ editor, element, view, options, shouldShow }) {
|
|
1905
1961
|
this.preventHide = false;
|
|
1962
|
+
this.isVisible = false;
|
|
1906
1963
|
this.shouldShow = ({ view: view2, state }) => {
|
|
1907
1964
|
const { selection } = state;
|
|
1908
1965
|
const { $anchor, empty } = selection;
|
|
@@ -2049,6 +2106,9 @@ var FloatingMenuView = class {
|
|
|
2049
2106
|
this.element.style.position = strategy;
|
|
2050
2107
|
this.element.style.left = `${x}px`;
|
|
2051
2108
|
this.element.style.top = `${y}px`;
|
|
2109
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
2110
|
+
this.floatingUIOptions.onUpdate();
|
|
2111
|
+
}
|
|
2052
2112
|
});
|
|
2053
2113
|
}
|
|
2054
2114
|
update(view, oldState) {
|
|
@@ -2058,20 +2118,37 @@ var FloatingMenuView = class {
|
|
|
2058
2118
|
}
|
|
2059
2119
|
show() {
|
|
2060
2120
|
var _a;
|
|
2121
|
+
if (this.isVisible) {
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2061
2124
|
this.element.style.visibility = "visible";
|
|
2062
2125
|
this.element.style.opacity = "1";
|
|
2063
2126
|
(_a = this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
2127
|
+
if (this.floatingUIOptions.onShow) {
|
|
2128
|
+
this.floatingUIOptions.onShow();
|
|
2129
|
+
}
|
|
2130
|
+
this.isVisible = true;
|
|
2064
2131
|
}
|
|
2065
2132
|
hide() {
|
|
2133
|
+
if (!this.isVisible) {
|
|
2134
|
+
return;
|
|
2135
|
+
}
|
|
2066
2136
|
this.element.style.visibility = "hidden";
|
|
2067
2137
|
this.element.style.opacity = "0";
|
|
2068
2138
|
this.element.remove();
|
|
2139
|
+
if (this.floatingUIOptions.onHide) {
|
|
2140
|
+
this.floatingUIOptions.onHide();
|
|
2141
|
+
}
|
|
2142
|
+
this.isVisible = false;
|
|
2069
2143
|
}
|
|
2070
2144
|
destroy() {
|
|
2071
2145
|
this.hide();
|
|
2072
2146
|
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
2073
2147
|
this.editor.off("focus", this.focusHandler);
|
|
2074
2148
|
this.editor.off("blur", this.blurHandler);
|
|
2149
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
2150
|
+
this.floatingUIOptions.onDestroy();
|
|
2151
|
+
}
|
|
2075
2152
|
}
|
|
2076
2153
|
};
|
|
2077
2154
|
var FloatingMenuPlugin = (options) => {
|