@tiptap/vue-2 3.4.6 → 3.5.1
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 +33 -5
- package/dist/menus/index.cjs.map +1 -1
- package/dist/menus/index.d.cts +23 -0
- package/dist/menus/index.d.ts +23 -0
- package/dist/menus/index.js +33 -5
- package/dist/menus/index.js.map +1 -1
- package/package.json +7 -7
- package/src/menus/BubbleMenu.ts +8 -1
- package/src/menus/FloatingMenu.ts +8 -1
package/dist/menus/index.cjs
CHANGED
|
@@ -1747,6 +1747,7 @@ var BubbleMenuView = class {
|
|
|
1747
1747
|
this.view.dom.addEventListener("dragstart", this.dragstartHandler);
|
|
1748
1748
|
this.editor.on("focus", this.focusHandler);
|
|
1749
1749
|
this.editor.on("blur", this.blurHandler);
|
|
1750
|
+
this.editor.on("transaction", this.transactionHandler);
|
|
1750
1751
|
window.addEventListener("resize", this.resizeHandler);
|
|
1751
1752
|
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
|
|
1752
1753
|
this.update(view, view.state);
|
|
@@ -1910,6 +1911,12 @@ var BubbleMenuView = class {
|
|
|
1910
1911
|
}
|
|
1911
1912
|
this.isVisible = false;
|
|
1912
1913
|
}
|
|
1914
|
+
transactionHandler({ transaction: tr }) {
|
|
1915
|
+
const meta = tr.getMeta("bubbleMenu");
|
|
1916
|
+
if (meta === "updatePosition") {
|
|
1917
|
+
this.updatePosition();
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1913
1920
|
destroy() {
|
|
1914
1921
|
this.hide();
|
|
1915
1922
|
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
@@ -1918,6 +1925,7 @@ var BubbleMenuView = class {
|
|
|
1918
1925
|
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
|
|
1919
1926
|
this.editor.off("focus", this.focusHandler);
|
|
1920
1927
|
this.editor.off("blur", this.blurHandler);
|
|
1928
|
+
this.editor.off("transaction", this.transactionHandler);
|
|
1921
1929
|
if (this.floatingUIOptions.onDestroy) {
|
|
1922
1930
|
this.floatingUIOptions.onDestroy();
|
|
1923
1931
|
}
|
|
@@ -1956,6 +1964,13 @@ var BubbleMenu = import_core2.Extension.create({
|
|
|
1956
1964
|
shouldShow: this.options.shouldShow
|
|
1957
1965
|
})
|
|
1958
1966
|
];
|
|
1967
|
+
},
|
|
1968
|
+
addCommands() {
|
|
1969
|
+
return {
|
|
1970
|
+
updateBubbleMenuPosition: () => ({ commands }) => {
|
|
1971
|
+
return commands.setMeta("bubbleMenu", "updatePosition");
|
|
1972
|
+
}
|
|
1973
|
+
};
|
|
1959
1974
|
}
|
|
1960
1975
|
});
|
|
1961
1976
|
|
|
@@ -1981,6 +1996,10 @@ var BubbleMenu2 = {
|
|
|
1981
1996
|
resizeDelay: {
|
|
1982
1997
|
type: Number
|
|
1983
1998
|
},
|
|
1999
|
+
appendTo: {
|
|
2000
|
+
type: Object,
|
|
2001
|
+
default: void 0
|
|
2002
|
+
},
|
|
1984
2003
|
shouldShow: {
|
|
1985
2004
|
type: Function,
|
|
1986
2005
|
default: null
|
|
@@ -2006,6 +2025,7 @@ var BubbleMenu2 = {
|
|
|
2006
2025
|
editor,
|
|
2007
2026
|
element: this.$el,
|
|
2008
2027
|
pluginKey: this.pluginKey,
|
|
2028
|
+
appendTo: this.appendTo,
|
|
2009
2029
|
shouldShow: this.shouldShow,
|
|
2010
2030
|
getReferencedVirtualElement: this.getReferencedVirtualElement
|
|
2011
2031
|
})
|
|
@@ -2015,7 +2035,7 @@ var BubbleMenu2 = {
|
|
|
2015
2035
|
}
|
|
2016
2036
|
},
|
|
2017
2037
|
render(createElement) {
|
|
2018
|
-
return createElement("div", {
|
|
2038
|
+
return createElement("div", {}, this.$slots.default);
|
|
2019
2039
|
},
|
|
2020
2040
|
beforeDestroy() {
|
|
2021
2041
|
this.editor.unregisterPlugin(this.pluginKey);
|
|
@@ -2027,7 +2047,7 @@ var import_core4 = require("@tiptap/core");
|
|
|
2027
2047
|
var import_core5 = require("@tiptap/core");
|
|
2028
2048
|
var import_state2 = require("@tiptap/pm/state");
|
|
2029
2049
|
var FloatingMenuView = class {
|
|
2030
|
-
constructor({ editor, element, view, options, shouldShow }) {
|
|
2050
|
+
constructor({ editor, element, view, options, appendTo, shouldShow }) {
|
|
2031
2051
|
this.preventHide = false;
|
|
2032
2052
|
this.isVisible = false;
|
|
2033
2053
|
this.shouldShow = ({ view: view2, state }) => {
|
|
@@ -2089,6 +2109,7 @@ var FloatingMenuView = class {
|
|
|
2089
2109
|
this.editor = editor;
|
|
2090
2110
|
this.element = element;
|
|
2091
2111
|
this.view = view;
|
|
2112
|
+
this.appendTo = appendTo;
|
|
2092
2113
|
this.floatingUIOptions = {
|
|
2093
2114
|
...this.floatingUIOptions,
|
|
2094
2115
|
...options
|
|
@@ -2190,13 +2211,13 @@ var FloatingMenuView = class {
|
|
|
2190
2211
|
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
2191
2212
|
}
|
|
2192
2213
|
show() {
|
|
2193
|
-
var _a;
|
|
2214
|
+
var _a, _b;
|
|
2194
2215
|
if (this.isVisible) {
|
|
2195
2216
|
return;
|
|
2196
2217
|
}
|
|
2197
2218
|
this.element.style.visibility = "visible";
|
|
2198
2219
|
this.element.style.opacity = "1";
|
|
2199
|
-
(_a = this.view.dom.parentElement) == null ? void 0 :
|
|
2220
|
+
(_b = (_a = this.appendTo) != null ? _a : this.view.dom.parentElement) == null ? void 0 : _b.appendChild(this.element);
|
|
2200
2221
|
if (this.floatingUIOptions.onShow) {
|
|
2201
2222
|
this.floatingUIOptions.onShow();
|
|
2202
2223
|
}
|
|
@@ -2237,6 +2258,7 @@ var FloatingMenu = import_core4.Extension.create({
|
|
|
2237
2258
|
element: null,
|
|
2238
2259
|
options: {},
|
|
2239
2260
|
pluginKey: "floatingMenu",
|
|
2261
|
+
appendTo: void 0,
|
|
2240
2262
|
shouldShow: null
|
|
2241
2263
|
};
|
|
2242
2264
|
},
|
|
@@ -2250,6 +2272,7 @@ var FloatingMenu = import_core4.Extension.create({
|
|
|
2250
2272
|
editor: this.editor,
|
|
2251
2273
|
element: this.options.element,
|
|
2252
2274
|
options: this.options.options,
|
|
2275
|
+
appendTo: this.options.appendTo,
|
|
2253
2276
|
shouldShow: this.options.shouldShow
|
|
2254
2277
|
})
|
|
2255
2278
|
];
|
|
@@ -2272,6 +2295,10 @@ var FloatingMenu2 = {
|
|
|
2272
2295
|
type: Object,
|
|
2273
2296
|
default: () => ({})
|
|
2274
2297
|
},
|
|
2298
|
+
appendTo: {
|
|
2299
|
+
type: Object,
|
|
2300
|
+
default: void 0
|
|
2301
|
+
},
|
|
2275
2302
|
shouldShow: {
|
|
2276
2303
|
type: Function,
|
|
2277
2304
|
default: null
|
|
@@ -2295,6 +2322,7 @@ var FloatingMenu2 = {
|
|
|
2295
2322
|
editor,
|
|
2296
2323
|
element: this.$el,
|
|
2297
2324
|
options: this.options,
|
|
2325
|
+
appendTo: this.appendTo,
|
|
2298
2326
|
shouldShow: this.shouldShow
|
|
2299
2327
|
})
|
|
2300
2328
|
);
|
|
@@ -2303,7 +2331,7 @@ var FloatingMenu2 = {
|
|
|
2303
2331
|
}
|
|
2304
2332
|
},
|
|
2305
2333
|
render(createElement) {
|
|
2306
|
-
return createElement("div", {
|
|
2334
|
+
return createElement("div", {}, this.$slots.default);
|
|
2307
2335
|
},
|
|
2308
2336
|
beforeDestroy() {
|
|
2309
2337
|
this.editor.unregisterPlugin(this.pluginKey);
|