@tiptap/vue-2 3.4.2 → 3.4.3
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 +18 -2
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.d.cts +9 -1
- package/dist/menus/index.d.ts +9 -1
- package/dist/menus/index.js +18 -2
- package/dist/menus/index.js.map +1 -1
- package/package.json +7 -7
- package/src/menus/BubbleMenu.ts +2 -0
package/dist/menus/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/core';
|
|
2
|
-
import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
2
|
+
import { VirtualElement, 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';
|
|
@@ -57,6 +57,13 @@ interface BubbleMenuPluginProps {
|
|
|
57
57
|
* @default null
|
|
58
58
|
*/
|
|
59
59
|
appendTo?: HTMLElement;
|
|
60
|
+
/**
|
|
61
|
+
* A function that returns the virtual element for the menu.
|
|
62
|
+
* This is useful when the menu needs to be positioned relative to a specific DOM element.
|
|
63
|
+
* @type {() => VirtualElement | null}
|
|
64
|
+
* @default Position based on the selection.
|
|
65
|
+
*/
|
|
66
|
+
getReferencedVirtualElement?: () => VirtualElement | null;
|
|
60
67
|
/**
|
|
61
68
|
* The options for the bubble menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,
|
|
62
69
|
* hide, and inline middlewares.
|
|
@@ -93,6 +100,7 @@ interface BubbleMenuInterface extends Vue {
|
|
|
93
100
|
updateDelay: BubbleMenuPluginProps['updateDelay'];
|
|
94
101
|
resizeDelay: BubbleMenuPluginProps['resizeDelay'];
|
|
95
102
|
shouldShow: BubbleMenuPluginProps['shouldShow'];
|
|
103
|
+
getReferencedVirtualElement: BubbleMenuPluginProps['getReferencedVirtualElement'];
|
|
96
104
|
options: BubbleMenuPluginProps['options'];
|
|
97
105
|
}
|
|
98
106
|
declare const BubbleMenu: Component;
|
package/dist/menus/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/core';
|
|
2
|
-
import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
|
|
2
|
+
import { VirtualElement, 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';
|
|
@@ -57,6 +57,13 @@ interface BubbleMenuPluginProps {
|
|
|
57
57
|
* @default null
|
|
58
58
|
*/
|
|
59
59
|
appendTo?: HTMLElement;
|
|
60
|
+
/**
|
|
61
|
+
* A function that returns the virtual element for the menu.
|
|
62
|
+
* This is useful when the menu needs to be positioned relative to a specific DOM element.
|
|
63
|
+
* @type {() => VirtualElement | null}
|
|
64
|
+
* @default Position based on the selection.
|
|
65
|
+
*/
|
|
66
|
+
getReferencedVirtualElement?: () => VirtualElement | null;
|
|
60
67
|
/**
|
|
61
68
|
* The options for the bubble menu. Those are passed to Floating UI and include options for the placement, offset, flip, shift, arrow, size, autoPlacement,
|
|
62
69
|
* hide, and inline middlewares.
|
|
@@ -93,6 +100,7 @@ interface BubbleMenuInterface extends Vue {
|
|
|
93
100
|
updateDelay: BubbleMenuPluginProps['updateDelay'];
|
|
94
101
|
resizeDelay: BubbleMenuPluginProps['resizeDelay'];
|
|
95
102
|
shouldShow: BubbleMenuPluginProps['shouldShow'];
|
|
103
|
+
getReferencedVirtualElement: BubbleMenuPluginProps['getReferencedVirtualElement'];
|
|
96
104
|
options: BubbleMenuPluginProps['options'];
|
|
97
105
|
}
|
|
98
106
|
declare const BubbleMenu: Component;
|
package/dist/menus/index.js
CHANGED
|
@@ -1608,6 +1608,7 @@ var BubbleMenuView = class {
|
|
|
1608
1608
|
resizeDelay = 60,
|
|
1609
1609
|
shouldShow,
|
|
1610
1610
|
appendTo,
|
|
1611
|
+
getReferencedVirtualElement,
|
|
1611
1612
|
options
|
|
1612
1613
|
}) {
|
|
1613
1614
|
this.preventHide = false;
|
|
@@ -1706,6 +1707,7 @@ var BubbleMenuView = class {
|
|
|
1706
1707
|
this.resizeDelay = resizeDelay;
|
|
1707
1708
|
this.appendTo = appendTo;
|
|
1708
1709
|
this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
|
|
1710
|
+
this.getReferencedVirtualElement = getReferencedVirtualElement;
|
|
1709
1711
|
this.floatingUIOptions = {
|
|
1710
1712
|
...this.floatingUIOptions,
|
|
1711
1713
|
...options
|
|
@@ -1763,8 +1765,13 @@ var BubbleMenuView = class {
|
|
|
1763
1765
|
}
|
|
1764
1766
|
return middlewares;
|
|
1765
1767
|
}
|
|
1766
|
-
|
|
1768
|
+
get virtualElement() {
|
|
1769
|
+
var _a;
|
|
1767
1770
|
const { selection } = this.editor.state;
|
|
1771
|
+
const referencedVirtualElement = (_a = this.getReferencedVirtualElement) == null ? void 0 : _a.call(this);
|
|
1772
|
+
if (referencedVirtualElement) {
|
|
1773
|
+
return referencedVirtualElement;
|
|
1774
|
+
}
|
|
1768
1775
|
const domRect = posToDOMRect(this.view, selection.from, selection.to);
|
|
1769
1776
|
let virtualElement = {
|
|
1770
1777
|
getBoundingClientRect: () => domRect,
|
|
@@ -1801,6 +1808,13 @@ var BubbleMenuView = class {
|
|
|
1801
1808
|
getClientRects: () => [clientRect]
|
|
1802
1809
|
};
|
|
1803
1810
|
}
|
|
1811
|
+
return virtualElement;
|
|
1812
|
+
}
|
|
1813
|
+
updatePosition() {
|
|
1814
|
+
const virtualElement = this.virtualElement;
|
|
1815
|
+
if (!virtualElement) {
|
|
1816
|
+
return;
|
|
1817
|
+
}
|
|
1804
1818
|
computePosition2(virtualElement, this.element, {
|
|
1805
1819
|
placement: this.floatingUIOptions.placement,
|
|
1806
1820
|
strategy: this.floatingUIOptions.strategy,
|
|
@@ -1911,6 +1925,7 @@ var BubbleMenu = Extension.create({
|
|
|
1911
1925
|
updateDelay: this.options.updateDelay,
|
|
1912
1926
|
options: this.options.options,
|
|
1913
1927
|
appendTo: this.options.appendTo,
|
|
1928
|
+
getReferencedVirtualElement: this.options.getReferencedVirtualElement,
|
|
1914
1929
|
shouldShow: this.options.shouldShow
|
|
1915
1930
|
})
|
|
1916
1931
|
];
|
|
@@ -1964,7 +1979,8 @@ var BubbleMenu2 = {
|
|
|
1964
1979
|
editor,
|
|
1965
1980
|
element: this.$el,
|
|
1966
1981
|
pluginKey: this.pluginKey,
|
|
1967
|
-
shouldShow: this.shouldShow
|
|
1982
|
+
shouldShow: this.shouldShow,
|
|
1983
|
+
getReferencedVirtualElement: this.getReferencedVirtualElement
|
|
1968
1984
|
})
|
|
1969
1985
|
);
|
|
1970
1986
|
});
|