@tiptap/vue-2 3.0.0-next.5 → 3.0.0-next.6
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 +28 -82
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.js +22 -76
- package/dist/menus/index.js.map +1 -1
- package/package.json +5 -5
package/dist/menus/index.cjs
CHANGED
|
@@ -20,14 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/menus/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
BubbleMenu: () =>
|
|
24
|
-
FloatingMenu: () =>
|
|
23
|
+
BubbleMenu: () => BubbleMenu,
|
|
24
|
+
FloatingMenu: () => FloatingMenu
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
|
-
// ../extension-bubble-menu/dist/index.js
|
|
29
|
-
var import_core2 = require("@tiptap/core");
|
|
30
|
-
|
|
31
28
|
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
32
29
|
var sides = ["top", "right", "bottom", "left"];
|
|
33
30
|
var alignments = ["start", "end"];
|
|
@@ -1611,8 +1608,8 @@ var computePosition2 = (reference, floating, options) => {
|
|
|
1611
1608
|
});
|
|
1612
1609
|
};
|
|
1613
1610
|
|
|
1614
|
-
// ../extension-bubble-menu/
|
|
1615
|
-
var
|
|
1611
|
+
// ../extension-bubble-menu/src/bubble-menu-plugin.ts
|
|
1612
|
+
var import_core2 = require("@tiptap/core");
|
|
1616
1613
|
var import_state = require("@tiptap/pm/state");
|
|
1617
1614
|
var BubbleMenuView = class {
|
|
1618
1615
|
constructor({
|
|
@@ -1637,12 +1634,12 @@ var BubbleMenuView = class {
|
|
|
1637
1634
|
hide: false,
|
|
1638
1635
|
inline: false
|
|
1639
1636
|
};
|
|
1640
|
-
this.shouldShow = ({ view
|
|
1637
|
+
this.shouldShow = ({ view, state, from, to }) => {
|
|
1641
1638
|
const { doc, selection } = state;
|
|
1642
1639
|
const { empty } = selection;
|
|
1643
|
-
const isEmptyTextBlock = !doc.textBetween(from, to).length && (0,
|
|
1640
|
+
const isEmptyTextBlock = !doc.textBetween(from, to).length && (0, import_core2.isTextSelection)(state.selection);
|
|
1644
1641
|
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
1645
|
-
const hasEditorFocus =
|
|
1642
|
+
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
1646
1643
|
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
1647
1644
|
return false;
|
|
1648
1645
|
}
|
|
@@ -1671,9 +1668,9 @@ var BubbleMenuView = class {
|
|
|
1671
1668
|
}
|
|
1672
1669
|
this.hide();
|
|
1673
1670
|
};
|
|
1674
|
-
this.handleDebouncedUpdate = (
|
|
1675
|
-
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(
|
|
1676
|
-
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(
|
|
1671
|
+
this.handleDebouncedUpdate = (view, oldState) => {
|
|
1672
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
1673
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
1677
1674
|
if (!selectionChanged && !docChanged) {
|
|
1678
1675
|
return;
|
|
1679
1676
|
}
|
|
@@ -1681,17 +1678,17 @@ var BubbleMenuView = class {
|
|
|
1681
1678
|
clearTimeout(this.updateDebounceTimer);
|
|
1682
1679
|
}
|
|
1683
1680
|
this.updateDebounceTimer = window.setTimeout(() => {
|
|
1684
|
-
this.updateHandler(
|
|
1681
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
1685
1682
|
}, this.updateDelay);
|
|
1686
1683
|
};
|
|
1687
|
-
this.updateHandler = (
|
|
1688
|
-
const { composing } =
|
|
1684
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
1685
|
+
const { composing } = view;
|
|
1689
1686
|
const isSame = !selectionChanged && !docChanged;
|
|
1690
1687
|
if (composing || isSame) {
|
|
1691
1688
|
return;
|
|
1692
1689
|
}
|
|
1693
|
-
const
|
|
1694
|
-
if (!
|
|
1690
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
1691
|
+
if (!shouldShow) {
|
|
1695
1692
|
this.hide();
|
|
1696
1693
|
return;
|
|
1697
1694
|
}
|
|
@@ -1768,7 +1765,7 @@ var BubbleMenuView = class {
|
|
|
1768
1765
|
updatePosition() {
|
|
1769
1766
|
const { selection } = this.editor.state;
|
|
1770
1767
|
const virtualElement = {
|
|
1771
|
-
getBoundingClientRect: () => (0,
|
|
1768
|
+
getBoundingClientRect: () => (0, import_core2.posToDOMRect)(this.view, selection.from, selection.to)
|
|
1772
1769
|
};
|
|
1773
1770
|
computePosition2(virtualElement, this.element, {
|
|
1774
1771
|
placement: this.floatingUIOptions.placement,
|
|
@@ -1835,34 +1832,9 @@ var BubbleMenuPlugin = (options) => {
|
|
|
1835
1832
|
view: (view) => new BubbleMenuView({ view, ...options })
|
|
1836
1833
|
});
|
|
1837
1834
|
};
|
|
1838
|
-
var BubbleMenu = import_core2.Extension.create({
|
|
1839
|
-
name: "bubbleMenu",
|
|
1840
|
-
addOptions() {
|
|
1841
|
-
return {
|
|
1842
|
-
element: null,
|
|
1843
|
-
pluginKey: "bubbleMenu",
|
|
1844
|
-
updateDelay: void 0,
|
|
1845
|
-
shouldShow: null
|
|
1846
|
-
};
|
|
1847
|
-
},
|
|
1848
|
-
addProseMirrorPlugins() {
|
|
1849
|
-
if (!this.options.element) {
|
|
1850
|
-
return [];
|
|
1851
|
-
}
|
|
1852
|
-
return [
|
|
1853
|
-
BubbleMenuPlugin({
|
|
1854
|
-
pluginKey: this.options.pluginKey,
|
|
1855
|
-
editor: this.editor,
|
|
1856
|
-
element: this.options.element,
|
|
1857
|
-
updateDelay: this.options.updateDelay,
|
|
1858
|
-
shouldShow: this.options.shouldShow
|
|
1859
|
-
})
|
|
1860
|
-
];
|
|
1861
|
-
}
|
|
1862
|
-
});
|
|
1863
1835
|
|
|
1864
1836
|
// src/menus/BubbleMenu.ts
|
|
1865
|
-
var
|
|
1837
|
+
var BubbleMenu = {
|
|
1866
1838
|
name: "BubbleMenu",
|
|
1867
1839
|
props: {
|
|
1868
1840
|
pluginKey: {
|
|
@@ -1923,19 +1895,18 @@ var BubbleMenu2 = {
|
|
|
1923
1895
|
}
|
|
1924
1896
|
};
|
|
1925
1897
|
|
|
1926
|
-
// ../extension-floating-menu/
|
|
1927
|
-
var
|
|
1928
|
-
var import_core5 = require("@tiptap/core");
|
|
1898
|
+
// ../extension-floating-menu/src/floating-menu-plugin.ts
|
|
1899
|
+
var import_core3 = require("@tiptap/core");
|
|
1929
1900
|
var import_state2 = require("@tiptap/pm/state");
|
|
1930
1901
|
var FloatingMenuView = class {
|
|
1931
1902
|
constructor({ editor, element, view, options, shouldShow }) {
|
|
1932
1903
|
this.preventHide = false;
|
|
1933
|
-
this.shouldShow = ({ view
|
|
1904
|
+
this.shouldShow = ({ view, state }) => {
|
|
1934
1905
|
const { selection } = state;
|
|
1935
1906
|
const { $anchor, empty } = selection;
|
|
1936
1907
|
const isRootDepth = $anchor.depth === 1;
|
|
1937
1908
|
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
1938
|
-
if (!
|
|
1909
|
+
if (!view.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
1939
1910
|
return false;
|
|
1940
1911
|
}
|
|
1941
1912
|
return true;
|
|
@@ -1952,14 +1923,14 @@ var FloatingMenuView = class {
|
|
|
1952
1923
|
hide: false,
|
|
1953
1924
|
inline: false
|
|
1954
1925
|
};
|
|
1955
|
-
this.updateHandler = (
|
|
1956
|
-
const { composing } =
|
|
1926
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
1927
|
+
const { composing } = view;
|
|
1957
1928
|
const isSame = !selectionChanged && !docChanged;
|
|
1958
1929
|
if (composing || isSame) {
|
|
1959
1930
|
return;
|
|
1960
1931
|
}
|
|
1961
|
-
const
|
|
1962
|
-
if (!
|
|
1932
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
1933
|
+
if (!shouldShow) {
|
|
1963
1934
|
this.hide();
|
|
1964
1935
|
return;
|
|
1965
1936
|
}
|
|
@@ -2005,7 +1976,7 @@ var FloatingMenuView = class {
|
|
|
2005
1976
|
}
|
|
2006
1977
|
}
|
|
2007
1978
|
getTextContent(node) {
|
|
2008
|
-
return (0,
|
|
1979
|
+
return (0, import_core3.getText)(node, { textSerializers: (0, import_core3.getTextSerializersFromSchema)(this.editor.schema) });
|
|
2009
1980
|
}
|
|
2010
1981
|
get middlewares() {
|
|
2011
1982
|
const middlewares = [];
|
|
@@ -2065,7 +2036,7 @@ var FloatingMenuView = class {
|
|
|
2065
2036
|
updatePosition() {
|
|
2066
2037
|
const { selection } = this.editor.state;
|
|
2067
2038
|
const virtualElement = {
|
|
2068
|
-
getBoundingClientRect: () => (0,
|
|
2039
|
+
getBoundingClientRect: () => (0, import_core3.posToDOMRect)(this.view, selection.from, selection.to)
|
|
2069
2040
|
};
|
|
2070
2041
|
computePosition2(virtualElement, this.element, {
|
|
2071
2042
|
placement: this.floatingUIOptions.placement,
|
|
@@ -2107,34 +2078,9 @@ var FloatingMenuPlugin = (options) => {
|
|
|
2107
2078
|
view: (view) => new FloatingMenuView({ view, ...options })
|
|
2108
2079
|
});
|
|
2109
2080
|
};
|
|
2110
|
-
var FloatingMenu = import_core4.Extension.create({
|
|
2111
|
-
name: "floatingMenu",
|
|
2112
|
-
addOptions() {
|
|
2113
|
-
return {
|
|
2114
|
-
element: null,
|
|
2115
|
-
options: {},
|
|
2116
|
-
pluginKey: "floatingMenu",
|
|
2117
|
-
shouldShow: null
|
|
2118
|
-
};
|
|
2119
|
-
},
|
|
2120
|
-
addProseMirrorPlugins() {
|
|
2121
|
-
if (!this.options.element) {
|
|
2122
|
-
return [];
|
|
2123
|
-
}
|
|
2124
|
-
return [
|
|
2125
|
-
FloatingMenuPlugin({
|
|
2126
|
-
pluginKey: this.options.pluginKey,
|
|
2127
|
-
editor: this.editor,
|
|
2128
|
-
element: this.options.element,
|
|
2129
|
-
options: this.options.options,
|
|
2130
|
-
shouldShow: this.options.shouldShow
|
|
2131
|
-
})
|
|
2132
|
-
];
|
|
2133
|
-
}
|
|
2134
|
-
});
|
|
2135
2081
|
|
|
2136
2082
|
// src/menus/FloatingMenu.ts
|
|
2137
|
-
var
|
|
2083
|
+
var FloatingMenu = {
|
|
2138
2084
|
name: "FloatingMenu",
|
|
2139
2085
|
props: {
|
|
2140
2086
|
pluginKey: {
|