@tiptap/vue-2 3.0.0-next.7 → 3.0.0-next.8
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.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// ../extension-bubble-menu/dist/index.js
|
|
2
|
-
import { Extension } from "@tiptap/core";
|
|
3
|
-
|
|
4
1
|
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
5
2
|
var sides = ["top", "right", "bottom", "left"];
|
|
6
3
|
var alignments = ["start", "end"];
|
|
@@ -1584,7 +1581,7 @@ var computePosition2 = (reference, floating, options) => {
|
|
|
1584
1581
|
});
|
|
1585
1582
|
};
|
|
1586
1583
|
|
|
1587
|
-
// ../extension-bubble-menu/
|
|
1584
|
+
// ../extension-bubble-menu/src/bubble-menu-plugin.ts
|
|
1588
1585
|
import { isTextSelection, posToDOMRect } from "@tiptap/core";
|
|
1589
1586
|
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
1590
1587
|
var BubbleMenuView = class {
|
|
@@ -1610,12 +1607,12 @@ var BubbleMenuView = class {
|
|
|
1610
1607
|
hide: false,
|
|
1611
1608
|
inline: false
|
|
1612
1609
|
};
|
|
1613
|
-
this.shouldShow = ({ view
|
|
1610
|
+
this.shouldShow = ({ view, state, from, to }) => {
|
|
1614
1611
|
const { doc, selection } = state;
|
|
1615
1612
|
const { empty } = selection;
|
|
1616
1613
|
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
1617
1614
|
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
1618
|
-
const hasEditorFocus =
|
|
1615
|
+
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
1619
1616
|
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
1620
1617
|
return false;
|
|
1621
1618
|
}
|
|
@@ -1644,9 +1641,9 @@ var BubbleMenuView = class {
|
|
|
1644
1641
|
}
|
|
1645
1642
|
this.hide();
|
|
1646
1643
|
};
|
|
1647
|
-
this.handleDebouncedUpdate = (
|
|
1648
|
-
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(
|
|
1649
|
-
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(
|
|
1644
|
+
this.handleDebouncedUpdate = (view, oldState) => {
|
|
1645
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
1646
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
1650
1647
|
if (!selectionChanged && !docChanged) {
|
|
1651
1648
|
return;
|
|
1652
1649
|
}
|
|
@@ -1654,17 +1651,17 @@ var BubbleMenuView = class {
|
|
|
1654
1651
|
clearTimeout(this.updateDebounceTimer);
|
|
1655
1652
|
}
|
|
1656
1653
|
this.updateDebounceTimer = window.setTimeout(() => {
|
|
1657
|
-
this.updateHandler(
|
|
1654
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
1658
1655
|
}, this.updateDelay);
|
|
1659
1656
|
};
|
|
1660
|
-
this.updateHandler = (
|
|
1661
|
-
const { composing } =
|
|
1657
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
1658
|
+
const { composing } = view;
|
|
1662
1659
|
const isSame = !selectionChanged && !docChanged;
|
|
1663
1660
|
if (composing || isSame) {
|
|
1664
1661
|
return;
|
|
1665
1662
|
}
|
|
1666
|
-
const
|
|
1667
|
-
if (!
|
|
1663
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
1664
|
+
if (!shouldShow) {
|
|
1668
1665
|
this.hide();
|
|
1669
1666
|
return;
|
|
1670
1667
|
}
|
|
@@ -1808,34 +1805,9 @@ var BubbleMenuPlugin = (options) => {
|
|
|
1808
1805
|
view: (view) => new BubbleMenuView({ view, ...options })
|
|
1809
1806
|
});
|
|
1810
1807
|
};
|
|
1811
|
-
var BubbleMenu = Extension.create({
|
|
1812
|
-
name: "bubbleMenu",
|
|
1813
|
-
addOptions() {
|
|
1814
|
-
return {
|
|
1815
|
-
element: null,
|
|
1816
|
-
pluginKey: "bubbleMenu",
|
|
1817
|
-
updateDelay: void 0,
|
|
1818
|
-
shouldShow: null
|
|
1819
|
-
};
|
|
1820
|
-
},
|
|
1821
|
-
addProseMirrorPlugins() {
|
|
1822
|
-
if (!this.options.element) {
|
|
1823
|
-
return [];
|
|
1824
|
-
}
|
|
1825
|
-
return [
|
|
1826
|
-
BubbleMenuPlugin({
|
|
1827
|
-
pluginKey: this.options.pluginKey,
|
|
1828
|
-
editor: this.editor,
|
|
1829
|
-
element: this.options.element,
|
|
1830
|
-
updateDelay: this.options.updateDelay,
|
|
1831
|
-
shouldShow: this.options.shouldShow
|
|
1832
|
-
})
|
|
1833
|
-
];
|
|
1834
|
-
}
|
|
1835
|
-
});
|
|
1836
1808
|
|
|
1837
1809
|
// src/menus/BubbleMenu.ts
|
|
1838
|
-
var
|
|
1810
|
+
var BubbleMenu = {
|
|
1839
1811
|
name: "BubbleMenu",
|
|
1840
1812
|
props: {
|
|
1841
1813
|
pluginKey: {
|
|
@@ -1896,19 +1868,18 @@ var BubbleMenu2 = {
|
|
|
1896
1868
|
}
|
|
1897
1869
|
};
|
|
1898
1870
|
|
|
1899
|
-
// ../extension-floating-menu/
|
|
1900
|
-
import { Extension as Extension2 } from "@tiptap/core";
|
|
1871
|
+
// ../extension-floating-menu/src/floating-menu-plugin.ts
|
|
1901
1872
|
import { getText, getTextSerializersFromSchema, posToDOMRect as posToDOMRect2 } from "@tiptap/core";
|
|
1902
1873
|
import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
|
|
1903
1874
|
var FloatingMenuView = class {
|
|
1904
1875
|
constructor({ editor, element, view, options, shouldShow }) {
|
|
1905
1876
|
this.preventHide = false;
|
|
1906
|
-
this.shouldShow = ({ view
|
|
1877
|
+
this.shouldShow = ({ view, state }) => {
|
|
1907
1878
|
const { selection } = state;
|
|
1908
1879
|
const { $anchor, empty } = selection;
|
|
1909
1880
|
const isRootDepth = $anchor.depth === 1;
|
|
1910
1881
|
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
1911
|
-
if (!
|
|
1882
|
+
if (!view.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
1912
1883
|
return false;
|
|
1913
1884
|
}
|
|
1914
1885
|
return true;
|
|
@@ -1925,14 +1896,14 @@ var FloatingMenuView = class {
|
|
|
1925
1896
|
hide: false,
|
|
1926
1897
|
inline: false
|
|
1927
1898
|
};
|
|
1928
|
-
this.updateHandler = (
|
|
1929
|
-
const { composing } =
|
|
1899
|
+
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
1900
|
+
const { composing } = view;
|
|
1930
1901
|
const isSame = !selectionChanged && !docChanged;
|
|
1931
1902
|
if (composing || isSame) {
|
|
1932
1903
|
return;
|
|
1933
1904
|
}
|
|
1934
|
-
const
|
|
1935
|
-
if (!
|
|
1905
|
+
const shouldShow = this.getShouldShow(oldState);
|
|
1906
|
+
if (!shouldShow) {
|
|
1936
1907
|
this.hide();
|
|
1937
1908
|
return;
|
|
1938
1909
|
}
|
|
@@ -2080,34 +2051,9 @@ var FloatingMenuPlugin = (options) => {
|
|
|
2080
2051
|
view: (view) => new FloatingMenuView({ view, ...options })
|
|
2081
2052
|
});
|
|
2082
2053
|
};
|
|
2083
|
-
var FloatingMenu = Extension2.create({
|
|
2084
|
-
name: "floatingMenu",
|
|
2085
|
-
addOptions() {
|
|
2086
|
-
return {
|
|
2087
|
-
element: null,
|
|
2088
|
-
options: {},
|
|
2089
|
-
pluginKey: "floatingMenu",
|
|
2090
|
-
shouldShow: null
|
|
2091
|
-
};
|
|
2092
|
-
},
|
|
2093
|
-
addProseMirrorPlugins() {
|
|
2094
|
-
if (!this.options.element) {
|
|
2095
|
-
return [];
|
|
2096
|
-
}
|
|
2097
|
-
return [
|
|
2098
|
-
FloatingMenuPlugin({
|
|
2099
|
-
pluginKey: this.options.pluginKey,
|
|
2100
|
-
editor: this.editor,
|
|
2101
|
-
element: this.options.element,
|
|
2102
|
-
options: this.options.options,
|
|
2103
|
-
shouldShow: this.options.shouldShow
|
|
2104
|
-
})
|
|
2105
|
-
];
|
|
2106
|
-
}
|
|
2107
|
-
});
|
|
2108
2054
|
|
|
2109
2055
|
// src/menus/FloatingMenu.ts
|
|
2110
|
-
var
|
|
2056
|
+
var FloatingMenu = {
|
|
2111
2057
|
name: "FloatingMenu",
|
|
2112
2058
|
props: {
|
|
2113
2059
|
pluginKey: {
|
|
@@ -2160,7 +2106,7 @@ var FloatingMenu2 = {
|
|
|
2160
2106
|
}
|
|
2161
2107
|
};
|
|
2162
2108
|
export {
|
|
2163
|
-
|
|
2164
|
-
|
|
2109
|
+
BubbleMenu,
|
|
2110
|
+
FloatingMenu
|
|
2165
2111
|
};
|
|
2166
2112
|
//# sourceMappingURL=index.js.map
|