@clevertask/scribe 0.1.4 → 0.1.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.
Files changed (85) hide show
  1. package/README.md +3 -0
  2. package/dist/BarMenu-CXaFlpRJ.js +272 -0
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.d.ts.map +1 -1
  5. package/dist/components/Menu/BarMenu.js +2 -10
  6. package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
  7. package/dist/components/Menu/BubbleMenu.js +165 -1023
  8. package/dist/components/Menu/LinkBubbleMenu.d.ts +8 -0
  9. package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -0
  10. package/dist/components/Menu/LinkBubbleMenu.js +78 -0
  11. package/dist/components/Menu/LinkEditor.d.ts +14 -0
  12. package/dist/components/Menu/LinkEditor.d.ts.map +1 -0
  13. package/dist/components/Menu/LinkEditor.js +140 -0
  14. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  15. package/dist/components/Menu/Mobile/ListOptionBar.js +38 -44
  16. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +5 -0
  17. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -0
  18. package/dist/components/Menu/linkBubbleMenuPlugin.js +7 -0
  19. package/dist/components/Menu/linkUrl.d.ts +2 -0
  20. package/dist/components/Menu/linkUrl.d.ts.map +1 -0
  21. package/dist/components/Menu/linkUrl.js +21 -0
  22. package/dist/components/Scribe/extension/emoji/EmojiList.js +58 -45
  23. package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -2
  24. package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
  25. package/dist/components/Scribe/extension/emoji/suggest.js +39 -43
  26. package/dist/components/Scribe/extension/extension-link.d.ts.map +1 -1
  27. package/dist/components/Scribe/extension/extension-link.js +2 -4
  28. package/dist/components/Scribe/extension/extension-markdown-paste.d.ts.map +1 -1
  29. package/dist/components/Scribe/extension/extension-markdown-paste.js +50 -45
  30. package/dist/components/Scribe/extension/extension-selectedText.d.ts.map +1 -1
  31. package/dist/components/Scribe/extension/extension-selectedText.js +10 -12
  32. package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -1
  33. package/dist/components/Scribe/extension/getPopupMountTarget.js +12 -15
  34. package/dist/components/Scribe/extension/index.d.ts +4 -4
  35. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  36. package/dist/components/Scribe/extension/index.js +2 -39521
  37. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3369 -3731
  38. package/dist/components/Scribe/extension/slashCommand/index.js +2 -6
  39. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  40. package/dist/components/Scribe/extension/slashCommand/items.js +177 -176
  41. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
  42. package/dist/components/Scribe/extension/slashCommand/renderItems.js +35 -41
  43. package/dist/components/Scribe/extension/tableOfContents.js +153 -180
  44. package/dist/components/Scribe/index.d.ts.map +1 -1
  45. package/dist/components/Scribe/index.js +113 -153
  46. package/dist/dist-BQjH-i-q.js +7016 -0
  47. package/dist/dist-CnXCIcnl.js +3506 -0
  48. package/dist/dist-Cp938P7P.js +689 -0
  49. package/dist/extension-CZOsheCI.js +56236 -0
  50. package/dist/extension-link-DZID_SYl.js +908 -0
  51. package/dist/floating-ui.dom-rih69525.js +928 -0
  52. package/dist/html-to-markdown-CrNOkSye.js +497 -0
  53. package/dist/icons/ToolbarIcons.d.ts.map +1 -1
  54. package/dist/icons/ToolbarIcons.js +76 -135
  55. package/dist/main.css +10 -0
  56. package/dist/main.js +7 -15
  57. package/dist/markdown-to-html-DEczPfuq.js +1458 -0
  58. package/dist/menus-CakIdDdY.js +633 -0
  59. package/dist/purify.es-DF9CW1cl.js +767 -0
  60. package/dist/rolldown-runtime-CtkjhSXr.js +4 -0
  61. package/dist/slashCommand-B7CRIaKG.js +429 -0
  62. package/dist/tables-CjOC70rm.js +1345 -0
  63. package/dist/tippy.esm-D9LL2xiE.js +1713 -0
  64. package/dist/utils/convert-legacy-math-delimiters.d.ts.map +1 -1
  65. package/dist/utils/convert-legacy-math-delimiters.js +7 -13
  66. package/dist/utils/create-scribe-editor.js +2 -31
  67. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  68. package/dist/utils/html-to-markdown.js +2 -600
  69. package/dist/utils/index.js +24 -12
  70. package/dist/utils/is-in-viewport.d.ts.map +1 -1
  71. package/dist/utils/is-in-viewport.js +6 -6
  72. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  73. package/dist/utils/markdown-to-html.js +2 -5
  74. package/dist/vite-env.d.js +0 -1
  75. package/package.json +38 -36
  76. package/dist/BarMenu-BNk2I0zi.js +0 -327
  77. package/dist/extension-link-P1rro4zO.js +0 -1059
  78. package/dist/floating-ui.dom-ZRy7FSVk.js +0 -1246
  79. package/dist/index-BMISMQrG.js +0 -855
  80. package/dist/index-ByyiiYsp.js +0 -1410
  81. package/dist/index-CnKS-BY2.js +0 -13834
  82. package/dist/index-CnQHDObA.js +0 -539
  83. package/dist/markdown-to-html-Bw9L43K6.js +0 -1135
  84. package/dist/purify.es-DC1iJOxX.js +0 -864
  85. package/dist/tippy.esm-DLHdsnfG.js +0 -1711
@@ -0,0 +1,633 @@
1
+ import { r as e } from "./dist-Cp938P7P.js";
2
+ import { a as t, i as n, r } from "./dist-CnXCIcnl.js";
3
+ import { A as i, C as a, I as o, S as s, n as c } from "./dist-BQjH-i-q.js";
4
+ import { a as l, c as u, i as d, l as f, n as p, o as m, s as h, t as g, u as _ } from "./floating-ui.dom-rih69525.js";
5
+ import { t as v } from "./tables-CjOC70rm.js";
6
+ import y, { useEffect as b, useLayoutEffect as x, useRef as S, useState as C } from "react";
7
+ import { createPortal as w } from "react-dom";
8
+ //#region node_modules/.pnpm/@tiptap+extension-bubble-menu@3.29.0_@tiptap+core@3.29.0_@tiptap+pm@3.29.0__@tiptap+pm@3.29.0/node_modules/@tiptap/extension-bubble-menu/dist/index.js
9
+ function T(e, t) {
10
+ let n = Math.min(e.top, t.top), r = Math.max(e.bottom, t.bottom), i = Math.min(e.left, t.left), a = Math.max(e.right, t.right) - i, o = r - n;
11
+ return new DOMRect(i, n, a, o);
12
+ }
13
+ var E = class {
14
+ constructor({ editor: e, element: t, view: n, pluginKey: r = "bubbleMenu", updateDelay: a = 250, resizeDelay: o = 60, shouldShow: s, appendTo: c, getReferencedVirtualElement: l, options: u }) {
15
+ this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.floatingUIOptions = {
16
+ strategy: "absolute",
17
+ placement: "top",
18
+ offset: 8,
19
+ flip: {},
20
+ shift: {},
21
+ arrow: !1,
22
+ size: !1,
23
+ autoPlacement: !1,
24
+ hide: !1,
25
+ inline: !1,
26
+ onShow: void 0,
27
+ onHide: void 0,
28
+ onUpdate: void 0,
29
+ onDestroy: void 0
30
+ }, this.shouldShow = ({ view: e, state: t, from: n, to: r }) => {
31
+ let { doc: a, selection: o } = t, { empty: s } = o, c = !a.textBetween(n, r).length && i(t.selection), l = this.element.contains(document.activeElement);
32
+ return !(!(e.hasFocus() || l) || s || c || !this.editor.isEditable);
33
+ }, this.mousedownHandler = () => {
34
+ this.preventHide = !0;
35
+ }, this.dragstartHandler = () => {
36
+ this.hide();
37
+ }, this.resizeHandler = () => {
38
+ this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
39
+ this.updatePosition();
40
+ }, this.resizeDelay);
41
+ }, this.focusHandler = () => {
42
+ setTimeout(() => this.update(this.editor.view));
43
+ }, this.blurHandler = ({ event: e }) => {
44
+ if (this.editor.isDestroyed) {
45
+ this.destroy();
46
+ return;
47
+ }
48
+ if (this.preventHide) {
49
+ this.preventHide = !1;
50
+ return;
51
+ }
52
+ e?.relatedTarget && this.element.parentNode?.contains(e.relatedTarget) || e?.relatedTarget !== this.editor.view.dom && this.hide();
53
+ }, this.handleDebouncedUpdate = (e, t) => {
54
+ let n = !t?.selection.eq(e.state.selection), r = !t?.doc.eq(e.state.doc);
55
+ !n && !r || (this.updateDebounceTimer && clearTimeout(this.updateDebounceTimer), this.updateDebounceTimer = window.setTimeout(() => {
56
+ this.updateHandler(e, n, r, t);
57
+ }, this.updateDelay));
58
+ }, this.updateHandler = (e, t, n, r) => {
59
+ let { composing: i } = e;
60
+ if (!(i || !t && !n)) {
61
+ if (!this.getShouldShow(r)) {
62
+ this.hide();
63
+ return;
64
+ }
65
+ this.show(), this.updatePosition();
66
+ }
67
+ }, this.transactionHandler = ({ transaction: e }) => {
68
+ let t = e.getMeta(this.pluginKey);
69
+ t === "updatePosition" ? this.updatePosition() : t && typeof t == "object" && t.type === "updateOptions" ? this.updateOptions(t.options) : t === "hide" ? this.hide() : t === "show" && (this.updatePosition(), this.show());
70
+ }, this.editor = e, this.element = t, this.view = n, this.pluginKey = r, this.updateDelay = a, this.resizeDelay = o, this.appendTo = c, this.scrollTarget = u?.scrollTarget ?? window, this.getReferencedVirtualElement = l, this.floatingUIOptions = {
71
+ ...this.floatingUIOptions,
72
+ ...u
73
+ }, this.element.tabIndex = 0, s && (this.shouldShow = s), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.editor.on("transaction", this.transactionHandler), window.addEventListener("resize", this.resizeHandler), this.scrollTarget.addEventListener("scroll", this.resizeHandler), this.update(n, n.state), this.getShouldShow() && (this.show(), this.updatePosition());
74
+ }
75
+ get middlewares() {
76
+ let e = [];
77
+ return this.floatingUIOptions.flip && e.push(l(typeof this.floatingUIOptions.flip == "boolean" ? void 0 : this.floatingUIOptions.flip)), this.floatingUIOptions.shift && e.push(f(typeof this.floatingUIOptions.shift == "boolean" ? void 0 : this.floatingUIOptions.shift)), this.floatingUIOptions.offset && e.push(u(typeof this.floatingUIOptions.offset == "boolean" ? void 0 : this.floatingUIOptions.offset)), this.floatingUIOptions.arrow && e.push(g(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && e.push(_(typeof this.floatingUIOptions.size == "boolean" ? void 0 : this.floatingUIOptions.size)), this.floatingUIOptions.autoPlacement && e.push(p(typeof this.floatingUIOptions.autoPlacement == "boolean" ? void 0 : this.floatingUIOptions.autoPlacement)), this.floatingUIOptions.hide && e.push(m(typeof this.floatingUIOptions.hide == "boolean" ? void 0 : this.floatingUIOptions.hide)), this.floatingUIOptions.inline && e.push(h(typeof this.floatingUIOptions.inline == "boolean" ? void 0 : this.floatingUIOptions.inline)), e;
78
+ }
79
+ get virtualElement() {
80
+ let { selection: e } = this.editor.state, t = this.getReferencedVirtualElement?.call(this);
81
+ if (t) return t;
82
+ if (!this.view?.dom?.parentNode) return;
83
+ let n = o(this.view, e.from, e.to), i = {
84
+ getBoundingClientRect: () => n,
85
+ getClientRects: () => [n]
86
+ };
87
+ if (e instanceof r) {
88
+ let t = this.view.nodeDOM(e.from), n = t.dataset.nodeViewWrapper ? t : t.querySelector("[data-node-view-wrapper]");
89
+ n && (t = n), t && (i = {
90
+ getBoundingClientRect: () => t.getBoundingClientRect(),
91
+ getClientRects: () => [t.getBoundingClientRect()]
92
+ });
93
+ }
94
+ if (e instanceof v) {
95
+ let { $anchorCell: t, $headCell: n } = e, r = t ? t.pos : n.pos, a = n ? n.pos : t.pos, o = this.view.nodeDOM(r), s = this.view.nodeDOM(a);
96
+ if (!o || !s) return;
97
+ let c = o === s ? o.getBoundingClientRect() : T(o.getBoundingClientRect(), s.getBoundingClientRect());
98
+ i = {
99
+ getBoundingClientRect: () => c,
100
+ getClientRects: () => [c]
101
+ };
102
+ }
103
+ return i;
104
+ }
105
+ updatePosition() {
106
+ if (!this.isVisible) return;
107
+ let e = this.virtualElement;
108
+ e && d(e, this.element, {
109
+ placement: this.floatingUIOptions.placement,
110
+ strategy: this.floatingUIOptions.strategy,
111
+ middleware: this.middlewares
112
+ }).then(({ x: e, y: t, strategy: n, middlewareData: r }) => {
113
+ if (!(!this.isVisible || this.editor.isDestroyed || !this.element.isConnected)) {
114
+ if (r.hide?.referenceHidden || r.hide?.escaped) {
115
+ this.element.style.visibility = "hidden";
116
+ return;
117
+ }
118
+ this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = n, this.element.style.left = `${e}px`, this.element.style.top = `${t}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
119
+ }
120
+ });
121
+ }
122
+ update(e, t) {
123
+ let { state: n } = e, r = n.selection.from !== n.selection.to;
124
+ if (this.updateDelay > 0 && r) {
125
+ this.handleDebouncedUpdate(e, t);
126
+ return;
127
+ }
128
+ let i = !t?.selection.eq(e.state.selection), a = !t?.doc.eq(e.state.doc);
129
+ this.updateHandler(e, i, a, t);
130
+ }
131
+ getShouldShow(e) {
132
+ let { state: t } = this.view, { selection: n } = t, { ranges: r } = n, i = Math.min(...r.map((e) => e.$from.pos)), a = Math.max(...r.map((e) => e.$to.pos));
133
+ return this.shouldShow?.call(this, {
134
+ editor: this.editor,
135
+ element: this.element,
136
+ view: this.view,
137
+ state: t,
138
+ oldState: e,
139
+ from: i,
140
+ to: a
141
+ }) || !1;
142
+ }
143
+ show() {
144
+ var e;
145
+ this.isVisible || (this.element.style.visibility = "visible", this.element.style.opacity = "1", (e = (typeof this.appendTo == "function" ? this.appendTo() : this.appendTo) ?? this.view.dom.parentElement) == null || e.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0);
146
+ }
147
+ hide() {
148
+ this.isVisible &&= (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), !1);
149
+ }
150
+ updateOptions(e) {
151
+ if (e.updateDelay !== void 0 && (this.updateDelay = e.updateDelay), e.resizeDelay !== void 0 && (this.resizeDelay = e.resizeDelay), e.appendTo !== void 0 && (this.appendTo = e.appendTo), e.getReferencedVirtualElement !== void 0 && (this.getReferencedVirtualElement = e.getReferencedVirtualElement), e.shouldShow !== void 0 && e.shouldShow && (this.shouldShow = e.shouldShow), e.options !== void 0) {
152
+ let t = e.options.scrollTarget ?? window;
153
+ t !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = t, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
154
+ ...this.floatingUIOptions,
155
+ ...e.options
156
+ };
157
+ }
158
+ }
159
+ destroy() {
160
+ this.hide(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), window.removeEventListener("resize", this.resizeHandler), this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler), this.editor.off("transaction", this.transactionHandler), this.floatingUIOptions.onDestroy && this.floatingUIOptions.onDestroy();
161
+ }
162
+ }, D = (e) => new n({
163
+ key: typeof e.pluginKey == "string" ? new t(e.pluginKey) : e.pluginKey,
164
+ view: (t) => new E({
165
+ view: t,
166
+ ...e
167
+ })
168
+ });
169
+ c.create({
170
+ name: "bubbleMenu",
171
+ addOptions() {
172
+ return {
173
+ element: null,
174
+ pluginKey: "bubbleMenu",
175
+ updateDelay: void 0,
176
+ appendTo: void 0,
177
+ shouldShow: null
178
+ };
179
+ },
180
+ addProseMirrorPlugins() {
181
+ return this.options.element ? [D({
182
+ pluginKey: this.options.pluginKey,
183
+ editor: this.editor,
184
+ element: this.options.element,
185
+ updateDelay: this.options.updateDelay,
186
+ options: this.options.options,
187
+ appendTo: this.options.appendTo,
188
+ getReferencedVirtualElement: this.options.getReferencedVirtualElement,
189
+ shouldShow: this.options.shouldShow
190
+ })] : [];
191
+ }
192
+ });
193
+ //#endregion
194
+ //#region node_modules/.pnpm/@tiptap+extension-floating-menu@3.29.0_@floating-ui+dom@1.8.0_@tiptap+core@3.29.0_@tiptap+pm@3.29.0__@tiptap+pm@3.29.0/node_modules/@tiptap/extension-floating-menu/dist/index.js
195
+ var O = class {
196
+ constructor({ editor: e, element: t, view: n, pluginKey: r = "floatingMenu", updateDelay: i = 250, resizeDelay: a = 60, options: o, appendTo: s, shouldShow: c }) {
197
+ this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.shouldShow = ({ view: e, state: t }) => {
198
+ let { selection: n } = t, { $anchor: r, empty: i } = n, a = r.depth === 1, o = r.parent.isTextblock && !r.parent.type.spec.code && !r.parent.textContent && r.parent.childCount === 0 && !this.getTextContent(r.parent);
199
+ return !(!e.hasFocus() || !i || !a || !o || !this.editor.isEditable);
200
+ }, this.floatingUIOptions = {
201
+ strategy: "absolute",
202
+ placement: "right",
203
+ offset: 8,
204
+ flip: {},
205
+ shift: {},
206
+ arrow: !1,
207
+ size: !1,
208
+ autoPlacement: !1,
209
+ hide: !1,
210
+ inline: !1
211
+ }, this.updateHandler = (e, t, n, r) => {
212
+ let { composing: i } = e;
213
+ if (!(i || !t && !n)) {
214
+ if (!this.getShouldShow(r)) {
215
+ this.hide();
216
+ return;
217
+ }
218
+ this.updatePosition(), this.show();
219
+ }
220
+ }, this.mousedownHandler = () => {
221
+ this.preventHide = !0;
222
+ }, this.focusHandler = () => {
223
+ setTimeout(() => this.update(this.editor.view));
224
+ }, this.blurHandler = ({ event: e }) => {
225
+ if (this.preventHide) {
226
+ this.preventHide = !1;
227
+ return;
228
+ }
229
+ e?.relatedTarget && this.element.parentNode?.contains(e.relatedTarget) || e?.relatedTarget !== this.editor.view.dom && this.hide();
230
+ }, this.transactionHandler = ({ transaction: e }) => {
231
+ let t = e.getMeta(this.pluginKey);
232
+ t === "updatePosition" ? this.updatePosition() : t && typeof t == "object" && t.type === "updateOptions" ? this.updateOptions(t.options) : t === "hide" ? this.hide() : t === "show" && (this.updatePosition(), this.show());
233
+ }, this.resizeHandler = () => {
234
+ this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
235
+ this.updatePosition();
236
+ }, this.resizeDelay);
237
+ }, this.editor = e, this.element = t, this.view = n, this.pluginKey = r, this.updateDelay = i, this.resizeDelay = a, this.appendTo = s, this.scrollTarget = o?.scrollTarget ?? window, this.floatingUIOptions = {
238
+ ...this.floatingUIOptions,
239
+ ...o
240
+ }, this.element.tabIndex = 0, c && (this.shouldShow = c), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.editor.on("transaction", this.transactionHandler), window.addEventListener("resize", this.resizeHandler), this.scrollTarget.addEventListener("scroll", this.resizeHandler), this.update(n, n.state), this.getShouldShow() && (this.show(), this.updatePosition());
241
+ }
242
+ getTextContent(e) {
243
+ return s(e, { textSerializers: a(this.editor.schema) });
244
+ }
245
+ get middlewares() {
246
+ let e = [];
247
+ return this.floatingUIOptions.flip && e.push(l(typeof this.floatingUIOptions.flip == "boolean" ? void 0 : this.floatingUIOptions.flip)), this.floatingUIOptions.shift && e.push(f(typeof this.floatingUIOptions.shift == "boolean" ? void 0 : this.floatingUIOptions.shift)), this.floatingUIOptions.offset && e.push(u(typeof this.floatingUIOptions.offset == "boolean" ? void 0 : this.floatingUIOptions.offset)), this.floatingUIOptions.arrow && e.push(g(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && e.push(_(typeof this.floatingUIOptions.size == "boolean" ? void 0 : this.floatingUIOptions.size)), this.floatingUIOptions.autoPlacement && e.push(p(typeof this.floatingUIOptions.autoPlacement == "boolean" ? void 0 : this.floatingUIOptions.autoPlacement)), this.floatingUIOptions.hide && e.push(m(typeof this.floatingUIOptions.hide == "boolean" ? void 0 : this.floatingUIOptions.hide)), this.floatingUIOptions.inline && e.push(h(typeof this.floatingUIOptions.inline == "boolean" ? void 0 : this.floatingUIOptions.inline)), e;
248
+ }
249
+ getShouldShow(e) {
250
+ let { state: t } = this.view, { selection: n } = t, { ranges: r } = n, i = Math.min(...r.map((e) => e.$from.pos)), a = Math.max(...r.map((e) => e.$to.pos));
251
+ return this.shouldShow?.call(this, {
252
+ editor: this.editor,
253
+ view: this.view,
254
+ state: t,
255
+ oldState: e,
256
+ from: i,
257
+ to: a
258
+ });
259
+ }
260
+ updateOptions(e) {
261
+ if (e.updateDelay !== void 0 && (this.updateDelay = e.updateDelay), e.resizeDelay !== void 0 && (this.resizeDelay = e.resizeDelay), e.appendTo !== void 0 && (this.appendTo = e.appendTo), e.shouldShow !== void 0 && e.shouldShow && (this.shouldShow = e.shouldShow), e.options !== void 0) {
262
+ let t = e.options.scrollTarget ?? window;
263
+ t !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = t, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
264
+ ...this.floatingUIOptions,
265
+ ...e.options
266
+ };
267
+ }
268
+ }
269
+ updatePosition() {
270
+ if (!this.view?.dom?.parentNode) return;
271
+ let { selection: e } = this.editor.state, t = o(this.view, e.from, e.to);
272
+ d({
273
+ getBoundingClientRect: () => t,
274
+ getClientRects: () => [t]
275
+ }, this.element, {
276
+ placement: this.floatingUIOptions.placement,
277
+ strategy: this.floatingUIOptions.strategy,
278
+ middleware: this.middlewares
279
+ }).then(({ x: e, y: t, strategy: n, middlewareData: r }) => {
280
+ if (r.hide?.referenceHidden || r.hide?.escaped) {
281
+ this.element.style.visibility = "hidden";
282
+ return;
283
+ }
284
+ this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = n, this.element.style.left = `${e}px`, this.element.style.top = `${t}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
285
+ });
286
+ }
287
+ update(e, t) {
288
+ let n = !t?.selection.eq(e.state.selection), r = !t?.doc.eq(e.state.doc);
289
+ this.updateHandler(e, n, r, t);
290
+ }
291
+ show() {
292
+ var e;
293
+ this.isVisible || (this.element.style.visibility = "visible", this.element.style.opacity = "1", (e = (typeof this.appendTo == "function" ? this.appendTo() : this.appendTo) ?? this.view.dom.parentElement) == null || e.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0);
294
+ }
295
+ hide() {
296
+ this.isVisible &&= (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), !1);
297
+ }
298
+ destroy() {
299
+ this.hide(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), window.removeEventListener("resize", this.resizeHandler), this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler), this.editor.off("transaction", this.transactionHandler), this.floatingUIOptions.onDestroy && this.floatingUIOptions.onDestroy();
300
+ }
301
+ }, k = (e) => new n({
302
+ key: typeof e.pluginKey == "string" ? new t(e.pluginKey) : e.pluginKey,
303
+ view: (t) => new O({
304
+ view: t,
305
+ ...e
306
+ })
307
+ });
308
+ c.create({
309
+ name: "floatingMenu",
310
+ addOptions() {
311
+ return {
312
+ element: null,
313
+ options: {},
314
+ pluginKey: "floatingMenu",
315
+ updateDelay: void 0,
316
+ resizeDelay: void 0,
317
+ appendTo: void 0,
318
+ shouldShow: null
319
+ };
320
+ },
321
+ addCommands() {
322
+ return { updateFloatingMenuPosition: () => ({ tr: e, dispatch: t }) => (t && e.setMeta(this.options.pluginKey, "updatePosition"), !0) };
323
+ },
324
+ addProseMirrorPlugins() {
325
+ return this.options.element ? [k({
326
+ pluginKey: this.options.pluginKey,
327
+ editor: this.editor,
328
+ element: this.options.element,
329
+ updateDelay: this.options.updateDelay,
330
+ resizeDelay: this.options.resizeDelay,
331
+ options: this.options.options,
332
+ appendTo: this.options.appendTo,
333
+ shouldShow: this.options.shouldShow
334
+ })] : [];
335
+ }
336
+ });
337
+ //#endregion
338
+ //#region node_modules/.pnpm/@tiptap+react@3.29.0_@floating-ui+dom@1.8.0_@tiptap+core@3.29.0_@tiptap+pm@3.29.0__@tip_e48c41d8ded29fe9094841602ccdf61f/node_modules/@tiptap/react/dist/menus/index.js
339
+ function A(e, n) {
340
+ return e ?? new t(n);
341
+ }
342
+ var j = typeof window < "u" ? x : b, M = /* @__PURE__ */ new Set([
343
+ "left",
344
+ "opacity",
345
+ "position",
346
+ "top",
347
+ "visibility",
348
+ "width"
349
+ ]), N = /* @__PURE__ */ new Set(/* @__PURE__ */ "animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom".split(".")), ee = /* @__PURE__ */ new Set([
350
+ "children",
351
+ "className",
352
+ "style"
353
+ ]), P = /* @__PURE__ */ new Set(["tabIndex"]), F = /* @__PURE__ */ new Set([
354
+ "accessKey",
355
+ "autoCapitalize",
356
+ "contentEditable",
357
+ "contextMenu",
358
+ "dir",
359
+ "draggable",
360
+ "enterKeyHint",
361
+ "hidden",
362
+ "id",
363
+ "lang",
364
+ "nonce",
365
+ "role",
366
+ "slot",
367
+ "spellCheck",
368
+ "tabIndex",
369
+ "title",
370
+ "translate"
371
+ ]), I = {
372
+ Blur: "focusout",
373
+ DoubleClick: "dblclick",
374
+ Focus: "focusin",
375
+ MouseEnter: "mouseenter",
376
+ MouseLeave: "mouseleave"
377
+ };
378
+ function L(e, t) {
379
+ return /^on[A-Z]/.test(e) && typeof t == "function";
380
+ }
381
+ function R(e) {
382
+ return e.startsWith("aria-") || e.startsWith("data-"), e;
383
+ }
384
+ function z(e) {
385
+ return e.startsWith("aria-") || e.startsWith("data-") || F.has(e);
386
+ }
387
+ function B(e) {
388
+ return e.startsWith("--") ? e : e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
389
+ }
390
+ function V(e) {
391
+ let t = e.endsWith("Capture"), n = (t ? e.slice(0, -7) : e).slice(2);
392
+ return {
393
+ eventName: I[n] ?? n.toLowerCase(),
394
+ options: t ? { capture: !0 } : void 0
395
+ };
396
+ }
397
+ function H(e, t) {
398
+ let n = t.defaultPrevented, r = !1, i = Object.create(t);
399
+ return Object.defineProperties(i, {
400
+ nativeEvent: { value: t },
401
+ currentTarget: { value: e },
402
+ target: { value: t.target },
403
+ persist: { value: () => void 0 },
404
+ isDefaultPrevented: { value: () => n },
405
+ isPropagationStopped: { value: () => r },
406
+ preventDefault: { value: () => {
407
+ n = !0, t.preventDefault();
408
+ } },
409
+ stopPropagation: { value: () => {
410
+ r = !0, t.stopPropagation();
411
+ } }
412
+ }), i;
413
+ }
414
+ function U(e) {
415
+ return P.has(e);
416
+ }
417
+ function W(e, t, n) {
418
+ if (t === "tabIndex") {
419
+ e.tabIndex = Number(n);
420
+ return;
421
+ }
422
+ e[t] = n;
423
+ }
424
+ function G(e, t) {
425
+ if (t === "tabIndex") {
426
+ e.removeAttribute("tabindex");
427
+ return;
428
+ }
429
+ let n = e[t];
430
+ if (typeof n == "boolean") {
431
+ e[t] = !1;
432
+ return;
433
+ }
434
+ if (typeof n == "number") {
435
+ e[t] = 0;
436
+ return;
437
+ }
438
+ e[t] = "";
439
+ }
440
+ function K(e, t) {
441
+ return typeof t != "number" || t === 0 || e.startsWith("--") || N.has(e) ? String(t) : `${t}px`;
442
+ }
443
+ function q(e, t) {
444
+ M.has(t) || e.style.removeProperty(B(t));
445
+ }
446
+ function J(e, t, n) {
447
+ M.has(t) || e.style.setProperty(B(t), K(t, n));
448
+ }
449
+ function Y(e, t, n) {
450
+ (/* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(n)])).forEach((r) => {
451
+ if (ee.has(r) || !z(r) || L(r, t[r]) || L(r, n[r])) return;
452
+ let i = t[r], a = n[r];
453
+ if (i === a) return;
454
+ let o = R(r);
455
+ if (a == null || a === !1) {
456
+ U(r) && G(e, r), e.removeAttribute(o);
457
+ return;
458
+ }
459
+ if (a === !0) {
460
+ U(r) && W(e, r, !0), e.setAttribute(o, "");
461
+ return;
462
+ }
463
+ if (U(r)) {
464
+ W(e, r, a);
465
+ return;
466
+ }
467
+ e.setAttribute(o, String(a));
468
+ });
469
+ }
470
+ function X(e, t, n) {
471
+ if (t !== n) {
472
+ if (n) {
473
+ e.className = n;
474
+ return;
475
+ }
476
+ e.removeAttribute("class");
477
+ }
478
+ }
479
+ function Z(e, t, n) {
480
+ let r = t ?? {}, i = n ?? {};
481
+ (/* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])).forEach((t) => {
482
+ let n = r[t], a = i[t];
483
+ if (n !== a) {
484
+ if (a == null) {
485
+ q(e, t);
486
+ return;
487
+ }
488
+ J(e, t, a);
489
+ }
490
+ });
491
+ }
492
+ function Q(e, t, n) {
493
+ t.forEach(({ eventName: t, listener: n, options: r }) => {
494
+ e.removeEventListener(t, n, r);
495
+ });
496
+ let r = [];
497
+ return Object.entries(n).forEach(([t, n]) => {
498
+ if (!L(t, n)) return;
499
+ let { eventName: i, options: a } = V(t), o = (t) => {
500
+ n(H(e, t));
501
+ };
502
+ e.addEventListener(i, o, a), r.push({
503
+ eventName: i,
504
+ listener: o,
505
+ options: a
506
+ });
507
+ }), r;
508
+ }
509
+ function $(e, t) {
510
+ let n = S({}), r = S([]);
511
+ j(() => {
512
+ let i = n.current;
513
+ return X(e, i.className, t.className), Z(e, i.style, t.style), Y(e, i, t), r.current = Q(e, r.current, t), n.current = t, () => {
514
+ r.current.forEach(({ eventName: t, listener: n, options: r }) => {
515
+ e.removeEventListener(t, n, r);
516
+ }), r.current = [];
517
+ };
518
+ }, [e, t]);
519
+ }
520
+ var te = y.forwardRef(({ pluginKey: t, editor: n, updateDelay: r, resizeDelay: i, appendTo: a, shouldShow: o = null, getReferencedVirtualElement: s, options: c, children: l, ...u }, d) => {
521
+ let f = S(document.createElement("div")), p = S(A(t, "bubbleMenu")).current;
522
+ $(f.current, u), typeof d == "function" ? d(f.current) : d && (d.current = f.current);
523
+ let { editor: m } = e(), h = n || m, g = {
524
+ updateDelay: r,
525
+ resizeDelay: i,
526
+ appendTo: a,
527
+ pluginKey: p,
528
+ shouldShow: o,
529
+ getReferencedVirtualElement: s,
530
+ options: c
531
+ }, _ = S(g);
532
+ _.current = g;
533
+ let [v, y] = C(!1), x = S(!0);
534
+ return b(() => {
535
+ if (h?.isDestroyed) return;
536
+ if (!h) {
537
+ console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");
538
+ return;
539
+ }
540
+ let e = f.current;
541
+ e.style.visibility = "hidden", e.style.position = "absolute";
542
+ let t = D({
543
+ ..._.current,
544
+ editor: h,
545
+ element: e
546
+ });
547
+ h.registerPlugin(t);
548
+ let n = _.current.pluginKey;
549
+ return x.current = !0, y(!0), () => {
550
+ y(!1), h.unregisterPlugin(n), window.requestAnimationFrame(() => {
551
+ e.parentNode && e.parentNode.removeChild(e);
552
+ });
553
+ };
554
+ }, [h]), b(() => {
555
+ if (!(!v || !h || h.isDestroyed)) {
556
+ if (x.current) {
557
+ x.current = !1;
558
+ return;
559
+ }
560
+ h.view.dispatch(h.state.tr.setMeta(p, {
561
+ type: "updateOptions",
562
+ options: _.current
563
+ }));
564
+ }
565
+ }, [
566
+ v,
567
+ h,
568
+ r,
569
+ i,
570
+ o,
571
+ c,
572
+ a,
573
+ s,
574
+ p
575
+ ]), w(l, f.current);
576
+ });
577
+ y.forwardRef(({ pluginKey: t, editor: n, updateDelay: r, resizeDelay: i, appendTo: a, shouldShow: o = null, options: s, children: c, ...l }, u) => {
578
+ let d = S(document.createElement("div")), f = S(A(t, "floatingMenu")).current;
579
+ $(d.current, l), typeof u == "function" ? u(d.current) : u && (u.current = d.current);
580
+ let { editor: p } = e(), m = n || p, h = {
581
+ updateDelay: r,
582
+ resizeDelay: i,
583
+ appendTo: a,
584
+ pluginKey: f,
585
+ shouldShow: o,
586
+ options: s
587
+ }, g = S(h);
588
+ g.current = h;
589
+ let [_, v] = C(!1), y = S(!0);
590
+ return b(() => {
591
+ if (m?.isDestroyed) return;
592
+ if (!m) {
593
+ console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");
594
+ return;
595
+ }
596
+ let e = d.current;
597
+ e.style.visibility = "hidden", e.style.position = "absolute";
598
+ let t = k({
599
+ ...g.current,
600
+ editor: m,
601
+ element: e
602
+ });
603
+ m.registerPlugin(t);
604
+ let n = g.current.pluginKey;
605
+ return y.current = !0, v(!0), () => {
606
+ v(!1), m.unregisterPlugin(n), window.requestAnimationFrame(() => {
607
+ e.parentNode && e.parentNode.removeChild(e);
608
+ });
609
+ };
610
+ }, [m]), b(() => {
611
+ if (!(!_ || !m || m.isDestroyed)) {
612
+ if (y.current) {
613
+ y.current = !1;
614
+ return;
615
+ }
616
+ m.view.dispatch(m.state.tr.setMeta(f, {
617
+ type: "updateOptions",
618
+ options: g.current
619
+ }));
620
+ }
621
+ }, [
622
+ _,
623
+ m,
624
+ r,
625
+ i,
626
+ o,
627
+ s,
628
+ a,
629
+ f
630
+ ]), w(c, d.current);
631
+ });
632
+ //#endregion
633
+ export { te as t };