@tiptap/vue-2 3.0.0-beta.0 → 3.0.0-beta.2
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/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/menus/index.cjs +48 -20
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.d.cts +1 -1
- package/dist/menus/index.d.ts +1 -1
- package/dist/menus/index.js +43 -15
- package/dist/menus/index.js.map +1 -1
- package/package.json +5 -5
- package/src/VueNodeViewRenderer.ts +1 -3
package/dist/menus/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
2
1
|
import { Editor } from '@tiptap/core';
|
|
2
|
+
import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
3
3
|
import { PluginKey, EditorState } from '@tiptap/pm/state';
|
|
4
4
|
import { EditorView } from '@tiptap/pm/view';
|
|
5
5
|
import Vue, { Component } from 'vue';
|
package/dist/menus/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
2
1
|
import { Editor } from '@tiptap/core';
|
|
2
|
+
import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
3
3
|
import { PluginKey, EditorState } from '@tiptap/pm/state';
|
|
4
4
|
import { EditorView } from '@tiptap/pm/view';
|
|
5
5
|
import Vue, { Component } from 'vue';
|
package/dist/menus/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// ../extension-bubble-menu/dist/index.js
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
|
+
|
|
1
4
|
// ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
2
5
|
var sides = ["top", "right", "bottom", "left"];
|
|
3
6
|
var alignments = ["start", "end"];
|
|
@@ -1581,7 +1584,7 @@ var computePosition2 = (reference, floating, options) => {
|
|
|
1581
1584
|
});
|
|
1582
1585
|
};
|
|
1583
1586
|
|
|
1584
|
-
// ../extension-bubble-menu/
|
|
1587
|
+
// ../extension-bubble-menu/dist/index.js
|
|
1585
1588
|
import { isTextSelection, posToDOMRect } from "@tiptap/core";
|
|
1586
1589
|
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
1587
1590
|
var BubbleMenuView = class {
|
|
@@ -1607,12 +1610,12 @@ var BubbleMenuView = class {
|
|
|
1607
1610
|
hide: false,
|
|
1608
1611
|
inline: false
|
|
1609
1612
|
};
|
|
1610
|
-
this.shouldShow = ({ view, state, from, to }) => {
|
|
1613
|
+
this.shouldShow = ({ view: view2, state, from, to }) => {
|
|
1611
1614
|
const { doc, selection } = state;
|
|
1612
1615
|
const { empty } = selection;
|
|
1613
1616
|
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
1614
1617
|
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
1615
|
-
const hasEditorFocus =
|
|
1618
|
+
const hasEditorFocus = view2.hasFocus() || isChildOfMenu;
|
|
1616
1619
|
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
1617
1620
|
return false;
|
|
1618
1621
|
}
|
|
@@ -1641,9 +1644,9 @@ var BubbleMenuView = class {
|
|
|
1641
1644
|
}
|
|
1642
1645
|
this.hide();
|
|
1643
1646
|
};
|
|
1644
|
-
this.handleDebouncedUpdate = (
|
|
1645
|
-
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(
|
|
1646
|
-
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(
|
|
1647
|
+
this.handleDebouncedUpdate = (view2, oldState) => {
|
|
1648
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view2.state.selection));
|
|
1649
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view2.state.doc));
|
|
1647
1650
|
if (!selectionChanged && !docChanged) {
|
|
1648
1651
|
return;
|
|
1649
1652
|
}
|
|
@@ -1651,17 +1654,17 @@ var BubbleMenuView = class {
|
|
|
1651
1654
|
clearTimeout(this.updateDebounceTimer);
|
|
1652
1655
|
}
|
|
1653
1656
|
this.updateDebounceTimer = window.setTimeout(() => {
|
|
1654
|
-
this.updateHandler(
|
|
1657
|
+
this.updateHandler(view2, selectionChanged, docChanged, oldState);
|
|
1655
1658
|
}, this.updateDelay);
|
|
1656
1659
|
};
|
|
1657
|
-
this.updateHandler = (
|
|
1658
|
-
const { composing } =
|
|
1660
|
+
this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
1661
|
+
const { composing } = view2;
|
|
1659
1662
|
const isSame = !selectionChanged && !docChanged;
|
|
1660
1663
|
if (composing || isSame) {
|
|
1661
1664
|
return;
|
|
1662
1665
|
}
|
|
1663
|
-
const
|
|
1664
|
-
if (!
|
|
1666
|
+
const shouldShow2 = this.getShouldShow(oldState);
|
|
1667
|
+
if (!shouldShow2) {
|
|
1665
1668
|
this.hide();
|
|
1666
1669
|
return;
|
|
1667
1670
|
}
|
|
@@ -1805,9 +1808,34 @@ var BubbleMenuPlugin = (options) => {
|
|
|
1805
1808
|
view: (view) => new BubbleMenuView({ view, ...options })
|
|
1806
1809
|
});
|
|
1807
1810
|
};
|
|
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
|
+
});
|
|
1808
1836
|
|
|
1809
1837
|
// src/menus/BubbleMenu.ts
|
|
1810
|
-
var
|
|
1838
|
+
var BubbleMenu2 = {
|
|
1811
1839
|
name: "BubbleMenu",
|
|
1812
1840
|
props: {
|
|
1813
1841
|
pluginKey: {
|
|
@@ -1869,7 +1897,7 @@ var BubbleMenu = {
|
|
|
1869
1897
|
};
|
|
1870
1898
|
|
|
1871
1899
|
// ../extension-floating-menu/dist/index.js
|
|
1872
|
-
import { Extension } from "@tiptap/core";
|
|
1900
|
+
import { Extension as Extension2 } from "@tiptap/core";
|
|
1873
1901
|
import { getText, getTextSerializersFromSchema, posToDOMRect as posToDOMRect2 } from "@tiptap/core";
|
|
1874
1902
|
import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
|
|
1875
1903
|
var FloatingMenuView = class {
|
|
@@ -2052,7 +2080,7 @@ var FloatingMenuPlugin = (options) => {
|
|
|
2052
2080
|
view: (view) => new FloatingMenuView({ view, ...options })
|
|
2053
2081
|
});
|
|
2054
2082
|
};
|
|
2055
|
-
var FloatingMenu =
|
|
2083
|
+
var FloatingMenu = Extension2.create({
|
|
2056
2084
|
name: "floatingMenu",
|
|
2057
2085
|
addOptions() {
|
|
2058
2086
|
return {
|
|
@@ -2132,7 +2160,7 @@ var FloatingMenu2 = {
|
|
|
2132
2160
|
}
|
|
2133
2161
|
};
|
|
2134
2162
|
export {
|
|
2135
|
-
BubbleMenu,
|
|
2163
|
+
BubbleMenu2 as BubbleMenu,
|
|
2136
2164
|
FloatingMenu2 as FloatingMenu
|
|
2137
2165
|
};
|
|
2138
2166
|
//# sourceMappingURL=index.js.map
|