@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.
- package/README.md +3 -0
- package/dist/BarMenu-CXaFlpRJ.js +272 -0
- package/dist/assets/index.css +1 -1
- package/dist/components/Menu/BarMenu.d.ts.map +1 -1
- package/dist/components/Menu/BarMenu.js +2 -10
- package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/BubbleMenu.js +165 -1023
- package/dist/components/Menu/LinkBubbleMenu.d.ts +8 -0
- package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -0
- package/dist/components/Menu/LinkBubbleMenu.js +78 -0
- package/dist/components/Menu/LinkEditor.d.ts +14 -0
- package/dist/components/Menu/LinkEditor.d.ts.map +1 -0
- package/dist/components/Menu/LinkEditor.js +140 -0
- package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
- package/dist/components/Menu/Mobile/ListOptionBar.js +38 -44
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +5 -0
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -0
- package/dist/components/Menu/linkBubbleMenuPlugin.js +7 -0
- package/dist/components/Menu/linkUrl.d.ts +2 -0
- package/dist/components/Menu/linkUrl.d.ts.map +1 -0
- package/dist/components/Menu/linkUrl.js +21 -0
- package/dist/components/Scribe/extension/emoji/EmojiList.js +58 -45
- package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -2
- package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
- package/dist/components/Scribe/extension/emoji/suggest.js +39 -43
- package/dist/components/Scribe/extension/extension-link.d.ts.map +1 -1
- package/dist/components/Scribe/extension/extension-link.js +2 -4
- package/dist/components/Scribe/extension/extension-markdown-paste.d.ts.map +1 -1
- package/dist/components/Scribe/extension/extension-markdown-paste.js +50 -45
- package/dist/components/Scribe/extension/extension-selectedText.d.ts.map +1 -1
- package/dist/components/Scribe/extension/extension-selectedText.js +10 -12
- package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -1
- package/dist/components/Scribe/extension/getPopupMountTarget.js +12 -15
- package/dist/components/Scribe/extension/index.d.ts +4 -4
- package/dist/components/Scribe/extension/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +2 -39521
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3369 -3731
- package/dist/components/Scribe/extension/slashCommand/index.js +2 -6
- package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
- package/dist/components/Scribe/extension/slashCommand/items.js +177 -176
- package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +35 -41
- package/dist/components/Scribe/extension/tableOfContents.js +153 -180
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +113 -153
- package/dist/dist-BQjH-i-q.js +7016 -0
- package/dist/dist-CnXCIcnl.js +3506 -0
- package/dist/dist-Cp938P7P.js +689 -0
- package/dist/extension-CZOsheCI.js +56236 -0
- package/dist/extension-link-DZID_SYl.js +908 -0
- package/dist/floating-ui.dom-rih69525.js +928 -0
- package/dist/html-to-markdown-CrNOkSye.js +497 -0
- package/dist/icons/ToolbarIcons.d.ts.map +1 -1
- package/dist/icons/ToolbarIcons.js +76 -135
- package/dist/main.css +10 -0
- package/dist/main.js +7 -15
- package/dist/markdown-to-html-DEczPfuq.js +1458 -0
- package/dist/menus-CakIdDdY.js +633 -0
- package/dist/purify.es-DF9CW1cl.js +767 -0
- package/dist/rolldown-runtime-CtkjhSXr.js +4 -0
- package/dist/slashCommand-B7CRIaKG.js +429 -0
- package/dist/tables-CjOC70rm.js +1345 -0
- package/dist/tippy.esm-D9LL2xiE.js +1713 -0
- package/dist/utils/convert-legacy-math-delimiters.d.ts.map +1 -1
- package/dist/utils/convert-legacy-math-delimiters.js +7 -13
- package/dist/utils/create-scribe-editor.js +2 -31
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +2 -600
- package/dist/utils/index.js +24 -12
- package/dist/utils/is-in-viewport.d.ts.map +1 -1
- package/dist/utils/is-in-viewport.js +6 -6
- package/dist/utils/markdown-to-html.d.ts.map +1 -1
- package/dist/utils/markdown-to-html.js +2 -5
- package/dist/vite-env.d.js +0 -1
- package/package.json +38 -36
- package/dist/BarMenu-BNk2I0zi.js +0 -327
- package/dist/extension-link-P1rro4zO.js +0 -1059
- package/dist/floating-ui.dom-ZRy7FSVk.js +0 -1246
- package/dist/index-BMISMQrG.js +0 -855
- package/dist/index-ByyiiYsp.js +0 -1410
- package/dist/index-CnKS-BY2.js +0 -13834
- package/dist/index-CnQHDObA.js +0 -539
- package/dist/markdown-to-html-Bw9L43K6.js +0 -1135
- package/dist/purify.es-DC1iJOxX.js +0 -864
- package/dist/tippy.esm-DLHdsnfG.js +0 -1711
|
@@ -1,1024 +1,166 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return;
|
|
165
|
-
const t = this.virtualElement;
|
|
166
|
-
t && N(t, this.element, {
|
|
167
|
-
placement: this.floatingUIOptions.placement,
|
|
168
|
-
strategy: this.floatingUIOptions.strategy,
|
|
169
|
-
middleware: this.middlewares
|
|
170
|
-
}).then(({ x: e, y: n, strategy: s, middlewareData: i }) => {
|
|
171
|
-
var l, o;
|
|
172
|
-
if (!(!this.isVisible || this.editor.isDestroyed || !this.element.isConnected)) {
|
|
173
|
-
if ((l = i.hide) != null && l.referenceHidden || (o = i.hide) != null && o.escaped) {
|
|
174
|
-
this.element.style.visibility = "hidden";
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = s, this.element.style.left = `${e}px`, this.element.style.top = `${n}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
update(t, e) {
|
|
182
|
-
const { state: n } = t, s = n.selection.from !== n.selection.to;
|
|
183
|
-
if (this.updateDelay > 0 && s) {
|
|
184
|
-
this.handleDebouncedUpdate(t, e);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const i = !e?.selection.eq(t.state.selection), l = !e?.doc.eq(t.state.doc);
|
|
188
|
-
this.updateHandler(t, i, l, e);
|
|
189
|
-
}
|
|
190
|
-
getShouldShow(t) {
|
|
191
|
-
var e;
|
|
192
|
-
const { state: n } = this.view, { selection: s } = n, { ranges: i } = s, l = Math.min(...i.map((u) => u.$from.pos)), o = Math.max(...i.map((u) => u.$to.pos));
|
|
193
|
-
return ((e = this.shouldShow) == null ? void 0 : e.call(this, {
|
|
194
|
-
editor: this.editor,
|
|
195
|
-
element: this.element,
|
|
196
|
-
view: this.view,
|
|
197
|
-
state: n,
|
|
198
|
-
oldState: t,
|
|
199
|
-
from: l,
|
|
200
|
-
to: o
|
|
201
|
-
})) || !1;
|
|
202
|
-
}
|
|
203
|
-
show() {
|
|
204
|
-
var t;
|
|
205
|
-
if (this.isVisible)
|
|
206
|
-
return;
|
|
207
|
-
this.element.style.visibility = "visible", this.element.style.opacity = "1";
|
|
208
|
-
const e = typeof this.appendTo == "function" ? this.appendTo() : this.appendTo;
|
|
209
|
-
(t = e ?? this.view.dom.parentElement) == null || t.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0;
|
|
210
|
-
}
|
|
211
|
-
hide() {
|
|
212
|
-
this.isVisible && (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), this.isVisible = !1);
|
|
213
|
-
}
|
|
214
|
-
updateOptions(t) {
|
|
215
|
-
var e;
|
|
216
|
-
if (t.updateDelay !== void 0 && (this.updateDelay = t.updateDelay), t.resizeDelay !== void 0 && (this.resizeDelay = t.resizeDelay), t.appendTo !== void 0 && (this.appendTo = t.appendTo), t.getReferencedVirtualElement !== void 0 && (this.getReferencedVirtualElement = t.getReferencedVirtualElement), t.shouldShow !== void 0 && t.shouldShow && (this.shouldShow = t.shouldShow), t.options !== void 0) {
|
|
217
|
-
const n = (e = t.options.scrollTarget) != null ? e : window;
|
|
218
|
-
n !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = n, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
|
|
219
|
-
...this.floatingUIOptions,
|
|
220
|
-
...t.options
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
destroy() {
|
|
225
|
-
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();
|
|
226
|
-
}
|
|
227
|
-
}, F = (t) => new D({
|
|
228
|
-
key: typeof t.pluginKey == "string" ? new S(t.pluginKey) : t.pluginKey,
|
|
229
|
-
view: (e) => new dt({ view: e, ...t })
|
|
230
|
-
});
|
|
231
|
-
z.create({
|
|
232
|
-
name: "bubbleMenu",
|
|
233
|
-
addOptions() {
|
|
234
|
-
return {
|
|
235
|
-
element: null,
|
|
236
|
-
pluginKey: "bubbleMenu",
|
|
237
|
-
updateDelay: void 0,
|
|
238
|
-
appendTo: void 0,
|
|
239
|
-
shouldShow: null
|
|
240
|
-
};
|
|
241
|
-
},
|
|
242
|
-
addProseMirrorPlugins() {
|
|
243
|
-
return this.options.element ? [
|
|
244
|
-
F({
|
|
245
|
-
pluginKey: this.options.pluginKey,
|
|
246
|
-
editor: this.editor,
|
|
247
|
-
element: this.options.element,
|
|
248
|
-
updateDelay: this.options.updateDelay,
|
|
249
|
-
options: this.options.options,
|
|
250
|
-
appendTo: this.options.appendTo,
|
|
251
|
-
getReferencedVirtualElement: this.options.getReferencedVirtualElement,
|
|
252
|
-
shouldShow: this.options.shouldShow
|
|
253
|
-
})
|
|
254
|
-
] : [];
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
var ht = class {
|
|
258
|
-
constructor({
|
|
259
|
-
editor: t,
|
|
260
|
-
element: e,
|
|
261
|
-
view: n,
|
|
262
|
-
pluginKey: s = "floatingMenu",
|
|
263
|
-
updateDelay: i = 250,
|
|
264
|
-
resizeDelay: l = 60,
|
|
265
|
-
options: o,
|
|
266
|
-
appendTo: a,
|
|
267
|
-
shouldShow: u
|
|
268
|
-
}) {
|
|
269
|
-
this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.shouldShow = ({ view: c, state: r }) => {
|
|
270
|
-
const { selection: d } = r, { $anchor: h, empty: p } = d, m = h.depth === 1, v = h.parent.isTextblock && !h.parent.type.spec.code && !h.parent.textContent && h.parent.childCount === 0 && !this.getTextContent(h.parent);
|
|
271
|
-
return !(!c.hasFocus() || !p || !m || !v || !this.editor.isEditable);
|
|
272
|
-
}, this.floatingUIOptions = {
|
|
273
|
-
strategy: "absolute",
|
|
274
|
-
placement: "right",
|
|
275
|
-
offset: 8,
|
|
276
|
-
flip: {},
|
|
277
|
-
shift: {},
|
|
278
|
-
arrow: !1,
|
|
279
|
-
size: !1,
|
|
280
|
-
autoPlacement: !1,
|
|
281
|
-
hide: !1,
|
|
282
|
-
inline: !1
|
|
283
|
-
}, this.updateHandler = (c, r, d, h) => {
|
|
284
|
-
const { composing: p } = c;
|
|
285
|
-
if (p || !r && !d)
|
|
286
|
-
return;
|
|
287
|
-
if (!this.getShouldShow(h)) {
|
|
288
|
-
this.hide();
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
this.updatePosition(), this.show();
|
|
292
|
-
}, this.mousedownHandler = () => {
|
|
293
|
-
this.preventHide = !0;
|
|
294
|
-
}, this.focusHandler = () => {
|
|
295
|
-
setTimeout(() => this.update(this.editor.view));
|
|
296
|
-
}, this.blurHandler = ({ event: c }) => {
|
|
297
|
-
var r;
|
|
298
|
-
if (this.preventHide) {
|
|
299
|
-
this.preventHide = !1;
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
c?.relatedTarget && ((r = this.element.parentNode) != null && r.contains(c.relatedTarget)) || c?.relatedTarget !== this.editor.view.dom && this.hide();
|
|
303
|
-
}, this.transactionHandler = ({ transaction: c }) => {
|
|
304
|
-
const r = c.getMeta(this.pluginKey);
|
|
305
|
-
r === "updatePosition" ? this.updatePosition() : r && typeof r == "object" && r.type === "updateOptions" ? this.updateOptions(r.options) : r === "hide" ? this.hide() : r === "show" && (this.updatePosition(), this.show());
|
|
306
|
-
}, this.resizeHandler = () => {
|
|
307
|
-
this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
|
|
308
|
-
this.updatePosition();
|
|
309
|
-
}, this.resizeDelay);
|
|
310
|
-
};
|
|
311
|
-
var f;
|
|
312
|
-
this.editor = t, this.element = e, this.view = n, this.pluginKey = s, this.updateDelay = i, this.resizeDelay = l, this.appendTo = a, this.scrollTarget = (f = o?.scrollTarget) != null ? f : window, this.floatingUIOptions = {
|
|
313
|
-
...this.floatingUIOptions,
|
|
314
|
-
...o
|
|
315
|
-
}, this.element.tabIndex = 0, u && (this.shouldShow = u), 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());
|
|
316
|
-
}
|
|
317
|
-
getTextContent(t) {
|
|
318
|
-
return nt(t, { textSerializers: st(this.editor.schema) });
|
|
319
|
-
}
|
|
320
|
-
get middlewares() {
|
|
321
|
-
const t = [];
|
|
322
|
-
return this.floatingUIOptions.flip && t.push(
|
|
323
|
-
P(
|
|
324
|
-
typeof this.floatingUIOptions.flip != "boolean" ? this.floatingUIOptions.flip : void 0
|
|
325
|
-
)
|
|
326
|
-
), this.floatingUIOptions.shift && t.push(
|
|
327
|
-
x(
|
|
328
|
-
typeof this.floatingUIOptions.shift != "boolean" ? this.floatingUIOptions.shift : void 0
|
|
329
|
-
)
|
|
330
|
-
), this.floatingUIOptions.offset && t.push(
|
|
331
|
-
R(
|
|
332
|
-
typeof this.floatingUIOptions.offset != "boolean" ? this.floatingUIOptions.offset : void 0
|
|
333
|
-
)
|
|
334
|
-
), this.floatingUIOptions.arrow && t.push(B(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && t.push(
|
|
335
|
-
V(
|
|
336
|
-
typeof this.floatingUIOptions.size != "boolean" ? this.floatingUIOptions.size : void 0
|
|
337
|
-
)
|
|
338
|
-
), this.floatingUIOptions.autoPlacement && t.push(
|
|
339
|
-
A(
|
|
340
|
-
typeof this.floatingUIOptions.autoPlacement != "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
341
|
-
)
|
|
342
|
-
), this.floatingUIOptions.hide && t.push(
|
|
343
|
-
K(
|
|
344
|
-
typeof this.floatingUIOptions.hide != "boolean" ? this.floatingUIOptions.hide : void 0
|
|
345
|
-
)
|
|
346
|
-
), this.floatingUIOptions.inline && t.push(
|
|
347
|
-
_(
|
|
348
|
-
typeof this.floatingUIOptions.inline != "boolean" ? this.floatingUIOptions.inline : void 0
|
|
349
|
-
)
|
|
350
|
-
), t;
|
|
351
|
-
}
|
|
352
|
-
getShouldShow(t) {
|
|
353
|
-
var e;
|
|
354
|
-
const { state: n } = this.view, { selection: s } = n, { ranges: i } = s, l = Math.min(...i.map((u) => u.$from.pos)), o = Math.max(...i.map((u) => u.$to.pos));
|
|
355
|
-
return (e = this.shouldShow) == null ? void 0 : e.call(this, {
|
|
356
|
-
editor: this.editor,
|
|
357
|
-
view: this.view,
|
|
358
|
-
state: n,
|
|
359
|
-
oldState: t,
|
|
360
|
-
from: l,
|
|
361
|
-
to: o
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
updateOptions(t) {
|
|
365
|
-
var e;
|
|
366
|
-
if (t.updateDelay !== void 0 && (this.updateDelay = t.updateDelay), t.resizeDelay !== void 0 && (this.resizeDelay = t.resizeDelay), t.appendTo !== void 0 && (this.appendTo = t.appendTo), t.shouldShow !== void 0 && t.shouldShow && (this.shouldShow = t.shouldShow), t.options !== void 0) {
|
|
367
|
-
const n = (e = t.options.scrollTarget) != null ? e : window;
|
|
368
|
-
n !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = n, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
|
|
369
|
-
...this.floatingUIOptions,
|
|
370
|
-
...t.options
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
updatePosition() {
|
|
375
|
-
var t, e;
|
|
376
|
-
if (!((e = (t = this.view) == null ? void 0 : t.dom) != null && e.parentNode))
|
|
377
|
-
return;
|
|
378
|
-
const { selection: n } = this.editor.state, s = L(this.view, n.from, n.to);
|
|
379
|
-
N({
|
|
380
|
-
getBoundingClientRect: () => s,
|
|
381
|
-
getClientRects: () => [s]
|
|
382
|
-
}, this.element, {
|
|
383
|
-
placement: this.floatingUIOptions.placement,
|
|
384
|
-
strategy: this.floatingUIOptions.strategy,
|
|
385
|
-
middleware: this.middlewares
|
|
386
|
-
}).then(({ x: l, y: o, strategy: a, middlewareData: u }) => {
|
|
387
|
-
var f, c;
|
|
388
|
-
if ((f = u.hide) != null && f.referenceHidden || (c = u.hide) != null && c.escaped) {
|
|
389
|
-
this.element.style.visibility = "hidden";
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = a, this.element.style.left = `${l}px`, this.element.style.top = `${o}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
update(t, e) {
|
|
396
|
-
const n = !e?.selection.eq(t.state.selection), s = !e?.doc.eq(t.state.doc);
|
|
397
|
-
this.updateHandler(t, n, s, e);
|
|
398
|
-
}
|
|
399
|
-
show() {
|
|
400
|
-
var t;
|
|
401
|
-
if (this.isVisible)
|
|
402
|
-
return;
|
|
403
|
-
this.element.style.visibility = "visible", this.element.style.opacity = "1";
|
|
404
|
-
const e = typeof this.appendTo == "function" ? this.appendTo() : this.appendTo;
|
|
405
|
-
(t = e ?? this.view.dom.parentElement) == null || t.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0;
|
|
406
|
-
}
|
|
407
|
-
hide() {
|
|
408
|
-
this.isVisible && (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), this.isVisible = !1);
|
|
409
|
-
}
|
|
410
|
-
destroy() {
|
|
411
|
-
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();
|
|
412
|
-
}
|
|
413
|
-
}, $ = (t) => new D({
|
|
414
|
-
key: typeof t.pluginKey == "string" ? new S(t.pluginKey) : t.pluginKey,
|
|
415
|
-
view: (e) => new ht({ view: e, ...t })
|
|
416
|
-
});
|
|
417
|
-
z.create({
|
|
418
|
-
name: "floatingMenu",
|
|
419
|
-
addOptions() {
|
|
420
|
-
return {
|
|
421
|
-
element: null,
|
|
422
|
-
options: {},
|
|
423
|
-
pluginKey: "floatingMenu",
|
|
424
|
-
updateDelay: void 0,
|
|
425
|
-
resizeDelay: void 0,
|
|
426
|
-
appendTo: void 0,
|
|
427
|
-
shouldShow: null
|
|
428
|
-
};
|
|
429
|
-
},
|
|
430
|
-
addCommands() {
|
|
431
|
-
return {
|
|
432
|
-
updateFloatingMenuPosition: () => ({ tr: t, dispatch: e }) => (e && t.setMeta(this.options.pluginKey, "updatePosition"), !0)
|
|
433
|
-
};
|
|
434
|
-
},
|
|
435
|
-
addProseMirrorPlugins() {
|
|
436
|
-
return this.options.element ? [
|
|
437
|
-
$({
|
|
438
|
-
pluginKey: this.options.pluginKey,
|
|
439
|
-
editor: this.editor,
|
|
440
|
-
element: this.options.element,
|
|
441
|
-
updateDelay: this.options.updateDelay,
|
|
442
|
-
resizeDelay: this.options.resizeDelay,
|
|
443
|
-
options: this.options.options,
|
|
444
|
-
appendTo: this.options.appendTo,
|
|
445
|
-
shouldShow: this.options.shouldShow
|
|
446
|
-
})
|
|
447
|
-
] : [];
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
function q(t, e) {
|
|
451
|
-
return t ?? new S(e);
|
|
452
|
-
}
|
|
453
|
-
var ct = typeof window < "u" ? rt : E, Y = /* @__PURE__ */ new Set([
|
|
454
|
-
"left",
|
|
455
|
-
"opacity",
|
|
456
|
-
"position",
|
|
457
|
-
"top",
|
|
458
|
-
"visibility",
|
|
459
|
-
"width"
|
|
460
|
-
]), pt = /* @__PURE__ */ new Set([
|
|
461
|
-
"animationIterationCount",
|
|
462
|
-
"aspectRatio",
|
|
463
|
-
"borderImageOutset",
|
|
464
|
-
"borderImageSlice",
|
|
465
|
-
"borderImageWidth",
|
|
466
|
-
"columnCount",
|
|
467
|
-
"columns",
|
|
468
|
-
"fillOpacity",
|
|
469
|
-
"flex",
|
|
470
|
-
"flexGrow",
|
|
471
|
-
"flexShrink",
|
|
472
|
-
"fontWeight",
|
|
473
|
-
"gridArea",
|
|
474
|
-
"gridColumn",
|
|
475
|
-
"gridColumnEnd",
|
|
476
|
-
"gridColumnStart",
|
|
477
|
-
"gridRow",
|
|
478
|
-
"gridRowEnd",
|
|
479
|
-
"gridRowStart",
|
|
480
|
-
"lineClamp",
|
|
481
|
-
"lineHeight",
|
|
482
|
-
"opacity",
|
|
483
|
-
"order",
|
|
484
|
-
"orphans",
|
|
485
|
-
"scale",
|
|
486
|
-
"stopOpacity",
|
|
487
|
-
"strokeDasharray",
|
|
488
|
-
"strokeDashoffset",
|
|
489
|
-
"strokeMiterlimit",
|
|
490
|
-
"strokeOpacity",
|
|
491
|
-
"strokeWidth",
|
|
492
|
-
"tabSize",
|
|
493
|
-
"widows",
|
|
494
|
-
"zIndex",
|
|
495
|
-
"zoom"
|
|
496
|
-
]), ft = /* @__PURE__ */ new Set(["children", "className", "style"]), gt = /* @__PURE__ */ new Set(["tabIndex"]), mt = /* @__PURE__ */ new Set([
|
|
497
|
-
"accessKey",
|
|
498
|
-
"autoCapitalize",
|
|
499
|
-
"contentEditable",
|
|
500
|
-
"contextMenu",
|
|
501
|
-
"dir",
|
|
502
|
-
"draggable",
|
|
503
|
-
"enterKeyHint",
|
|
504
|
-
"hidden",
|
|
505
|
-
"id",
|
|
506
|
-
"lang",
|
|
507
|
-
"nonce",
|
|
508
|
-
"role",
|
|
509
|
-
"slot",
|
|
510
|
-
"spellCheck",
|
|
511
|
-
"tabIndex",
|
|
512
|
-
"title",
|
|
513
|
-
"translate"
|
|
514
|
-
]), vt = {
|
|
515
|
-
Blur: "focusout",
|
|
516
|
-
DoubleClick: "dblclick",
|
|
517
|
-
Focus: "focusin",
|
|
518
|
-
MouseEnter: "mouseenter",
|
|
519
|
-
MouseLeave: "mouseleave"
|
|
520
|
-
};
|
|
521
|
-
function U(t, e) {
|
|
522
|
-
return /^on[A-Z]/.test(t) && typeof e == "function";
|
|
523
|
-
}
|
|
524
|
-
function bt(t) {
|
|
525
|
-
return t.startsWith("aria-") || t.startsWith("data-"), t;
|
|
526
|
-
}
|
|
527
|
-
function wt(t) {
|
|
528
|
-
return t.startsWith("aria-") || t.startsWith("data-") || mt.has(t);
|
|
529
|
-
}
|
|
530
|
-
function G(t) {
|
|
531
|
-
return t.startsWith("--") ? t : t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
532
|
-
}
|
|
533
|
-
function yt(t) {
|
|
534
|
-
var e;
|
|
535
|
-
const n = t.endsWith("Capture"), i = (n ? t.slice(0, -7) : t).slice(2);
|
|
536
|
-
return {
|
|
537
|
-
eventName: (e = vt[i]) != null ? e : i.toLowerCase(),
|
|
538
|
-
options: n ? { capture: !0 } : void 0
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
function Ot(t, e) {
|
|
542
|
-
let n = e.defaultPrevented, s = !1;
|
|
543
|
-
const i = Object.create(e);
|
|
544
|
-
return Object.defineProperties(i, {
|
|
545
|
-
nativeEvent: { value: e },
|
|
546
|
-
currentTarget: { value: t },
|
|
547
|
-
target: { value: e.target },
|
|
548
|
-
persist: { value: () => {
|
|
549
|
-
} },
|
|
550
|
-
isDefaultPrevented: { value: () => n },
|
|
551
|
-
isPropagationStopped: { value: () => s },
|
|
552
|
-
preventDefault: {
|
|
553
|
-
value: () => {
|
|
554
|
-
n = !0, e.preventDefault();
|
|
555
|
-
}
|
|
556
|
-
},
|
|
557
|
-
stopPropagation: {
|
|
558
|
-
value: () => {
|
|
559
|
-
s = !0, e.stopPropagation();
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}), i;
|
|
563
|
-
}
|
|
564
|
-
function H(t) {
|
|
565
|
-
return gt.has(t);
|
|
566
|
-
}
|
|
567
|
-
function C(t, e, n) {
|
|
568
|
-
if (e === "tabIndex") {
|
|
569
|
-
t.tabIndex = Number(n);
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
t[e] = n;
|
|
573
|
-
}
|
|
574
|
-
function It(t, e) {
|
|
575
|
-
if (e === "tabIndex") {
|
|
576
|
-
t.removeAttribute("tabindex");
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
const n = t[e];
|
|
580
|
-
if (typeof n == "boolean") {
|
|
581
|
-
t[e] = !1;
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
if (typeof n == "number") {
|
|
585
|
-
t[e] = 0;
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
t[e] = "";
|
|
589
|
-
}
|
|
590
|
-
function Et(t, e) {
|
|
591
|
-
return typeof e != "number" || e === 0 || t.startsWith("--") || pt.has(t) ? String(e) : `${e}px`;
|
|
592
|
-
}
|
|
593
|
-
function Tt(t, e) {
|
|
594
|
-
Y.has(e) || t.style.removeProperty(G(e));
|
|
595
|
-
}
|
|
596
|
-
function Ht(t, e, n) {
|
|
597
|
-
Y.has(e) || t.style.setProperty(G(e), Et(e, n));
|
|
598
|
-
}
|
|
599
|
-
function Ut(t, e, n) {
|
|
600
|
-
(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(n)])).forEach((i) => {
|
|
601
|
-
if (ft.has(i) || !wt(i) || U(i, e[i]) || U(i, n[i]))
|
|
602
|
-
return;
|
|
603
|
-
const l = e[i], o = n[i];
|
|
604
|
-
if (l === o)
|
|
605
|
-
return;
|
|
606
|
-
const a = bt(i);
|
|
607
|
-
if (o == null || o === !1) {
|
|
608
|
-
H(i) && It(t, i), t.removeAttribute(a);
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
if (o === !0) {
|
|
612
|
-
H(i) && C(t, i, !0), t.setAttribute(a, "");
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
if (H(i)) {
|
|
616
|
-
C(t, i, o);
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
t.setAttribute(a, String(o));
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
function St(t, e, n) {
|
|
623
|
-
if (e !== n) {
|
|
624
|
-
if (n) {
|
|
625
|
-
t.className = n;
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
628
|
-
t.removeAttribute("class");
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
function Ct(t, e, n) {
|
|
632
|
-
const s = e ?? {}, i = n ?? {};
|
|
633
|
-
(/* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(i)])).forEach((o) => {
|
|
634
|
-
const a = s[o], u = i[o];
|
|
635
|
-
if (a !== u) {
|
|
636
|
-
if (u == null) {
|
|
637
|
-
Tt(t, o);
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
Ht(t, o, u);
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
function Mt(t, e, n) {
|
|
645
|
-
e.forEach(({ eventName: i, listener: l, options: o }) => {
|
|
646
|
-
t.removeEventListener(i, l, o);
|
|
647
|
-
});
|
|
648
|
-
const s = [];
|
|
649
|
-
return Object.entries(n).forEach(([i, l]) => {
|
|
650
|
-
if (!U(i, l))
|
|
651
|
-
return;
|
|
652
|
-
const { eventName: o, options: a } = yt(i), u = (f) => {
|
|
653
|
-
l(Ot(t, f));
|
|
654
|
-
};
|
|
655
|
-
t.addEventListener(o, u, a), s.push({ eventName: o, listener: u, options: a });
|
|
656
|
-
}), s;
|
|
657
|
-
}
|
|
658
|
-
function Z(t, e) {
|
|
659
|
-
const n = w({}), s = w([]);
|
|
660
|
-
ct(() => {
|
|
661
|
-
const i = n.current;
|
|
662
|
-
return St(t, i.className, e.className), Ct(t, i.style, e.style), Ut(t, i, e), s.current = Mt(t, s.current, e), n.current = e, () => {
|
|
663
|
-
s.current.forEach(({ eventName: l, listener: o, options: a }) => {
|
|
664
|
-
t.removeEventListener(l, o, a);
|
|
665
|
-
}), s.current = [];
|
|
666
|
-
};
|
|
667
|
-
}, [t, e]);
|
|
668
|
-
}
|
|
669
|
-
var Dt = W.forwardRef(
|
|
670
|
-
({
|
|
671
|
-
pluginKey: t,
|
|
672
|
-
editor: e,
|
|
673
|
-
updateDelay: n,
|
|
674
|
-
resizeDelay: s,
|
|
675
|
-
appendTo: i,
|
|
676
|
-
shouldShow: l = null,
|
|
677
|
-
getReferencedVirtualElement: o,
|
|
678
|
-
options: a,
|
|
679
|
-
children: u,
|
|
680
|
-
...f
|
|
681
|
-
}, c) => {
|
|
682
|
-
const r = w(document.createElement("div")), d = w(
|
|
683
|
-
q(t, "bubbleMenu")
|
|
684
|
-
).current;
|
|
685
|
-
Z(r.current, f), typeof c == "function" ? c(r.current) : c && (c.current = r.current);
|
|
686
|
-
const { editor: h } = M(), p = e || h, m = {
|
|
687
|
-
updateDelay: n,
|
|
688
|
-
resizeDelay: s,
|
|
689
|
-
appendTo: i,
|
|
690
|
-
pluginKey: d,
|
|
691
|
-
shouldShow: l,
|
|
692
|
-
getReferencedVirtualElement: o,
|
|
693
|
-
options: a
|
|
694
|
-
}, v = w(m);
|
|
695
|
-
v.current = m;
|
|
696
|
-
const [O, I] = k(!1), b = w(!0);
|
|
697
|
-
return E(() => {
|
|
698
|
-
if (p?.isDestroyed)
|
|
699
|
-
return;
|
|
700
|
-
if (!p) {
|
|
701
|
-
console.warn(
|
|
702
|
-
"BubbleMenu component is not rendered inside of an editor component or does not have editor prop."
|
|
703
|
-
);
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
const y = r.current;
|
|
707
|
-
y.style.visibility = "hidden", y.style.position = "absolute";
|
|
708
|
-
const T = F({
|
|
709
|
-
...v.current,
|
|
710
|
-
editor: p,
|
|
711
|
-
element: y
|
|
712
|
-
});
|
|
713
|
-
p.registerPlugin(T);
|
|
714
|
-
const X = v.current.pluginKey;
|
|
715
|
-
return b.current = !0, I(!0), () => {
|
|
716
|
-
I(!1), p.unregisterPlugin(X), window.requestAnimationFrame(() => {
|
|
717
|
-
y.parentNode && y.parentNode.removeChild(y);
|
|
718
|
-
});
|
|
719
|
-
};
|
|
720
|
-
}, [p]), E(() => {
|
|
721
|
-
if (!(!O || !p || p.isDestroyed)) {
|
|
722
|
-
if (b.current) {
|
|
723
|
-
b.current = !1;
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
|
-
p.view.dispatch(
|
|
727
|
-
p.state.tr.setMeta(d, {
|
|
728
|
-
type: "updateOptions",
|
|
729
|
-
options: v.current
|
|
730
|
-
})
|
|
731
|
-
);
|
|
732
|
-
}
|
|
733
|
-
}, [
|
|
734
|
-
O,
|
|
735
|
-
p,
|
|
736
|
-
n,
|
|
737
|
-
s,
|
|
738
|
-
l,
|
|
739
|
-
a,
|
|
740
|
-
i,
|
|
741
|
-
o,
|
|
742
|
-
d
|
|
743
|
-
]), j(u, r.current);
|
|
744
|
-
}
|
|
745
|
-
);
|
|
746
|
-
W.forwardRef(
|
|
747
|
-
({
|
|
748
|
-
pluginKey: t,
|
|
749
|
-
editor: e,
|
|
750
|
-
updateDelay: n,
|
|
751
|
-
resizeDelay: s,
|
|
752
|
-
appendTo: i,
|
|
753
|
-
shouldShow: l = null,
|
|
754
|
-
options: o,
|
|
755
|
-
children: a,
|
|
756
|
-
...u
|
|
757
|
-
}, f) => {
|
|
758
|
-
const c = w(document.createElement("div")), r = w(
|
|
759
|
-
q(t, "floatingMenu")
|
|
760
|
-
).current;
|
|
761
|
-
Z(c.current, u), typeof f == "function" ? f(c.current) : f && (f.current = c.current);
|
|
762
|
-
const { editor: d } = M(), h = e || d, p = {
|
|
763
|
-
updateDelay: n,
|
|
764
|
-
resizeDelay: s,
|
|
765
|
-
appendTo: i,
|
|
766
|
-
pluginKey: r,
|
|
767
|
-
shouldShow: l,
|
|
768
|
-
options: o
|
|
769
|
-
}, m = w(p);
|
|
770
|
-
m.current = p;
|
|
771
|
-
const [v, O] = k(!1), I = w(!0);
|
|
772
|
-
return E(() => {
|
|
773
|
-
if (h?.isDestroyed)
|
|
774
|
-
return;
|
|
775
|
-
if (!h) {
|
|
776
|
-
console.warn(
|
|
777
|
-
"FloatingMenu component is not rendered inside of an editor component or does not have editor prop."
|
|
778
|
-
);
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
const b = c.current;
|
|
782
|
-
b.style.visibility = "hidden", b.style.position = "absolute";
|
|
783
|
-
const y = $({
|
|
784
|
-
...m.current,
|
|
785
|
-
editor: h,
|
|
786
|
-
element: b
|
|
787
|
-
});
|
|
788
|
-
h.registerPlugin(y);
|
|
789
|
-
const T = m.current.pluginKey;
|
|
790
|
-
return I.current = !0, O(!0), () => {
|
|
791
|
-
O(!1), h.unregisterPlugin(T), window.requestAnimationFrame(() => {
|
|
792
|
-
b.parentNode && b.parentNode.removeChild(b);
|
|
793
|
-
});
|
|
794
|
-
};
|
|
795
|
-
}, [h]), E(() => {
|
|
796
|
-
if (!(!v || !h || h.isDestroyed)) {
|
|
797
|
-
if (I.current) {
|
|
798
|
-
I.current = !1;
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
h.view.dispatch(
|
|
802
|
-
h.state.tr.setMeta(r, {
|
|
803
|
-
type: "updateOptions",
|
|
804
|
-
options: m.current
|
|
805
|
-
})
|
|
806
|
-
);
|
|
807
|
-
}
|
|
808
|
-
}, [
|
|
809
|
-
v,
|
|
810
|
-
h,
|
|
811
|
-
n,
|
|
812
|
-
s,
|
|
813
|
-
l,
|
|
814
|
-
o,
|
|
815
|
-
i,
|
|
816
|
-
r
|
|
817
|
-
]), j(a, c.current);
|
|
818
|
-
}
|
|
819
|
-
);
|
|
820
|
-
const _t = ({ editor: t }) => {
|
|
821
|
-
const e = tt({
|
|
822
|
-
editor: t,
|
|
823
|
-
selector: ({ editor: i }) => i ? {
|
|
824
|
-
isHeading1: i.isActive("heading", { level: 1 }),
|
|
825
|
-
isHeading2: i.isActive("heading", { level: 2 }),
|
|
826
|
-
isHeading3: i.isActive("heading", { level: 3 }),
|
|
827
|
-
isBold: i.isActive("bold"),
|
|
828
|
-
isItalic: i.isActive("italic"),
|
|
829
|
-
isStrike: i.isActive("strike"),
|
|
830
|
-
isCode: i.isActive("code")
|
|
831
|
-
} : null
|
|
832
|
-
}), n = lt(
|
|
833
|
-
(i, l) => {
|
|
834
|
-
i.preventDefault(), l();
|
|
835
|
-
},
|
|
836
|
-
[]
|
|
837
|
-
), s = [
|
|
838
|
-
{
|
|
839
|
-
ariaLabel: "Heading 1",
|
|
840
|
-
command: () => t.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
841
|
-
isActive: () => !!e?.isHeading1,
|
|
842
|
-
icon: /* @__PURE__ */ g(
|
|
843
|
-
"svg",
|
|
844
|
-
{
|
|
845
|
-
className: "scribe-inline-menu-icon",
|
|
846
|
-
viewBox: "0 0 24 24",
|
|
847
|
-
fill: "none",
|
|
848
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
849
|
-
children: /* @__PURE__ */ g(
|
|
850
|
-
"path",
|
|
851
|
-
{
|
|
852
|
-
d: "M4.00023 5L4 17M13 5L12.9998 17M4 11H12.9998M19.875 19V10L17.625 12.25",
|
|
853
|
-
strokeWidth: "1.5",
|
|
854
|
-
strokeLinecap: "round",
|
|
855
|
-
strokeLinejoin: "round"
|
|
856
|
-
}
|
|
857
|
-
)
|
|
858
|
-
}
|
|
859
|
-
)
|
|
860
|
-
},
|
|
861
|
-
{
|
|
862
|
-
ariaLabel: "Heading 2",
|
|
863
|
-
command: () => t.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
864
|
-
isActive: () => !!e?.isHeading2,
|
|
865
|
-
icon: /* @__PURE__ */ g(
|
|
866
|
-
"svg",
|
|
867
|
-
{
|
|
868
|
-
fill: "none",
|
|
869
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
870
|
-
className: "scribe-inline-menu-icon",
|
|
871
|
-
viewBox: "0 0 24 24",
|
|
872
|
-
children: /* @__PURE__ */ g(
|
|
873
|
-
"path",
|
|
874
|
-
{
|
|
875
|
-
d: "M3.37402 5V17M12.374 5V17M3.37402 11H12.374M16.302 11.373C16.5035 10.8941 16.8644 10.4997 17.3236 10.2566C17.7829 10.0136 18.312 9.93705 18.8213 10.0399C19.3306 10.1427 19.7886 10.4186 20.1175 10.8207C20.4465 11.2229 20.6262 11.7265 20.626 12.246C20.628 12.694 20.494 13.132 20.242 13.503L16.123 19H20.626",
|
|
876
|
-
strokeWidth: "1.5",
|
|
877
|
-
strokeLinecap: "round",
|
|
878
|
-
strokeLinejoin: "round"
|
|
879
|
-
}
|
|
880
|
-
)
|
|
881
|
-
}
|
|
882
|
-
)
|
|
883
|
-
},
|
|
884
|
-
{
|
|
885
|
-
ariaLabel: "Heading 3",
|
|
886
|
-
command: () => t.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
887
|
-
isActive: () => !!e?.isHeading3,
|
|
888
|
-
icon: /* @__PURE__ */ g(
|
|
889
|
-
"svg",
|
|
890
|
-
{
|
|
891
|
-
className: "scribe-inline-menu-icon",
|
|
892
|
-
viewBox: "0 0 24 24",
|
|
893
|
-
fill: "none",
|
|
894
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
895
|
-
children: /* @__PURE__ */ g(
|
|
896
|
-
"path",
|
|
897
|
-
{
|
|
898
|
-
d: "M3.375 5V17M12.375 5V17M3.375 11H12.375M16.125 10H20.625L18 13.75C18.4317 13.7499 18.8568 13.8564 19.2375 14.0598C19.6183 14.2633 19.943 14.5575 20.1828 14.9165C20.4227 15.2754 20.5703 15.688 20.6127 16.1176C20.655 16.5472 20.5907 16.9807 20.4255 17.3795C20.2603 17.7783 19.9993 18.1303 19.6656 18.4042C19.3319 18.678 18.9358 18.8654 18.5123 18.9496C18.0889 19.0338 17.6513 19.0123 17.2382 18.8869C16.8251 18.7616 16.4492 18.5363 16.144 18.231",
|
|
899
|
-
strokeWidth: "1.5",
|
|
900
|
-
strokeLinecap: "round",
|
|
901
|
-
strokeLinejoin: "round"
|
|
902
|
-
}
|
|
903
|
-
)
|
|
904
|
-
}
|
|
905
|
-
)
|
|
906
|
-
},
|
|
907
|
-
{
|
|
908
|
-
ariaLabel: "Bold",
|
|
909
|
-
command: () => t.chain().focus().toggleBold().run(),
|
|
910
|
-
isActive: () => !!e?.isBold,
|
|
911
|
-
icon: /* @__PURE__ */ g(
|
|
912
|
-
"svg",
|
|
913
|
-
{
|
|
914
|
-
className: "scribe-inline-menu-icon",
|
|
915
|
-
viewBox: "0 0 24 24",
|
|
916
|
-
fill: "none",
|
|
917
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
918
|
-
children: /* @__PURE__ */ g(
|
|
919
|
-
"path",
|
|
920
|
-
{
|
|
921
|
-
d: "M12.8571 12C13.918 12 14.9354 11.5786 15.6856 10.8284C16.4357 10.0783 16.8571 9.06087 16.8571 8C16.8571 6.93913 16.4357 5.92172 15.6856 5.17157C14.9354 4.42143 13.918 4 12.8571 4H6V12M12.8571 12H6M12.8571 12H14C15.0609 12 16.0783 12.4214 16.8284 13.1716C17.5786 13.9217 18 14.9391 18 16C18 17.0609 17.5786 18.0783 16.8284 18.8284C16.0783 19.5786 15.0609 20 14 20H6V12",
|
|
922
|
-
strokeWidth: "1.5",
|
|
923
|
-
strokeLinecap: "round",
|
|
924
|
-
strokeLinejoin: "round"
|
|
925
|
-
}
|
|
926
|
-
)
|
|
927
|
-
}
|
|
928
|
-
)
|
|
929
|
-
},
|
|
930
|
-
{
|
|
931
|
-
ariaLabel: "Italic",
|
|
932
|
-
command: () => t.chain().focus().toggleItalic().run(),
|
|
933
|
-
isActive: () => !!e?.isItalic,
|
|
934
|
-
icon: /* @__PURE__ */ g(
|
|
935
|
-
"svg",
|
|
936
|
-
{
|
|
937
|
-
className: "scribe-inline-menu-icon",
|
|
938
|
-
viewBox: "0 0 24 24",
|
|
939
|
-
fill: "none",
|
|
940
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
941
|
-
children: /* @__PURE__ */ g(
|
|
942
|
-
"path",
|
|
943
|
-
{
|
|
944
|
-
d: "M10.8571 4H17.7142M6.28564 20H13.1428M14.2856 4L9.71422 20",
|
|
945
|
-
strokeWidth: "1.5",
|
|
946
|
-
strokeLinecap: "round",
|
|
947
|
-
strokeLinejoin: "round"
|
|
948
|
-
}
|
|
949
|
-
)
|
|
950
|
-
}
|
|
951
|
-
)
|
|
952
|
-
},
|
|
953
|
-
{
|
|
954
|
-
ariaLabel: "Strike",
|
|
955
|
-
command: () => t.chain().focus().toggleStrike().run(),
|
|
956
|
-
isActive: () => !!e?.isStrike,
|
|
957
|
-
icon: /* @__PURE__ */ g(
|
|
958
|
-
"svg",
|
|
959
|
-
{
|
|
960
|
-
className: "scribe-inline-menu-icon",
|
|
961
|
-
viewBox: "0 0 24 24",
|
|
962
|
-
fill: "none",
|
|
963
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
964
|
-
children: /* @__PURE__ */ g(
|
|
965
|
-
"path",
|
|
966
|
-
{
|
|
967
|
-
d: "M11.0121 12H12.9874C15.1693 12 16.938 13.7909 16.938 16C16.938 18.2091 15.1693 20 12.9874 20H11.0121C8.83024 20 7.06149 18.2091 7.06149 16M16.938 8C16.938 5.79086 15.1693 4 12.9874 4H11.0121C8.83024 4 7.06149 5.79086 7.06149 8C7.06149 8.3453 7.1047 8.68038 7.18595 9M4 12H20",
|
|
968
|
-
strokeWidth: "1.5",
|
|
969
|
-
strokeLinecap: "round",
|
|
970
|
-
strokeLinejoin: "round"
|
|
971
|
-
}
|
|
972
|
-
)
|
|
973
|
-
}
|
|
974
|
-
)
|
|
975
|
-
},
|
|
976
|
-
{
|
|
977
|
-
ariaLabel: "Inline code",
|
|
978
|
-
command: () => t.chain().focus().toggleCode().run(),
|
|
979
|
-
isActive: () => !!e?.isCode,
|
|
980
|
-
icon: /* @__PURE__ */ g(
|
|
981
|
-
"svg",
|
|
982
|
-
{
|
|
983
|
-
className: "scribe-inline-menu-icon",
|
|
984
|
-
viewBox: "0 0 24 24",
|
|
985
|
-
fill: "none",
|
|
986
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
987
|
-
children: /* @__PURE__ */ g(
|
|
988
|
-
"path",
|
|
989
|
-
{
|
|
990
|
-
d: "M16.5 16.5L21 12L16.5 7.50002M7.5 7.50002L3 12L7.5 16.5M13.8 3.90002L10.2 20.1",
|
|
991
|
-
strokeWidth: "1.5",
|
|
992
|
-
strokeLinecap: "round",
|
|
993
|
-
strokeLinejoin: "round"
|
|
994
|
-
}
|
|
995
|
-
)
|
|
996
|
-
}
|
|
997
|
-
)
|
|
998
|
-
}
|
|
999
|
-
];
|
|
1000
|
-
return /* @__PURE__ */ g(
|
|
1001
|
-
Dt,
|
|
1002
|
-
{
|
|
1003
|
-
editor: t,
|
|
1004
|
-
appendTo: at(t),
|
|
1005
|
-
options: { strategy: "fixed" },
|
|
1006
|
-
children: /* @__PURE__ */ g("div", { className: "scribe-bubble-menu", children: /* @__PURE__ */ g(J, { align: "center", gap: "2", children: s.map((i) => /* @__PURE__ */ g(
|
|
1007
|
-
Q,
|
|
1008
|
-
{
|
|
1009
|
-
type: "button",
|
|
1010
|
-
size: "1",
|
|
1011
|
-
radius: "medium",
|
|
1012
|
-
color: "gray",
|
|
1013
|
-
variant: i.isActive() ? "soft" : "ghost",
|
|
1014
|
-
onMouseDown: (l) => n(l, i.command),
|
|
1015
|
-
children: i.icon
|
|
1016
|
-
},
|
|
1017
|
-
i.ariaLabel
|
|
1018
|
-
)) }) })
|
|
1019
|
-
}
|
|
1020
|
-
);
|
|
1021
|
-
};
|
|
1022
|
-
export {
|
|
1023
|
-
_t as default
|
|
1
|
+
import { i as e } from "../../dist-Cp938P7P.js";
|
|
2
|
+
import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
|
|
3
|
+
import { t as n } from "../../menus-CakIdDdY.js";
|
|
4
|
+
import { Flex as r, IconButton as i } from "@radix-ui/themes";
|
|
5
|
+
import { useCallback as a } from "react";
|
|
6
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
7
|
+
//#region lib/components/Menu/BubbleMenu.tsx
|
|
8
|
+
var s = ({ editor: s }) => {
|
|
9
|
+
let c = e({
|
|
10
|
+
editor: s,
|
|
11
|
+
selector: ({ editor: e }) => e ? {
|
|
12
|
+
isHeading1: e.isActive("heading", { level: 1 }),
|
|
13
|
+
isHeading2: e.isActive("heading", { level: 2 }),
|
|
14
|
+
isHeading3: e.isActive("heading", { level: 3 }),
|
|
15
|
+
isBold: e.isActive("bold"),
|
|
16
|
+
isItalic: e.isActive("italic"),
|
|
17
|
+
isStrike: e.isActive("strike"),
|
|
18
|
+
isCode: e.isActive("code")
|
|
19
|
+
} : null
|
|
20
|
+
}), l = a((e, t) => {
|
|
21
|
+
e.preventDefault(), t();
|
|
22
|
+
}, []), u = [
|
|
23
|
+
{
|
|
24
|
+
ariaLabel: "Heading 1",
|
|
25
|
+
command: () => s.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
26
|
+
isActive: () => !!c?.isHeading1,
|
|
27
|
+
icon: /* @__PURE__ */ o("svg", {
|
|
28
|
+
className: "scribe-inline-menu-icon",
|
|
29
|
+
viewBox: "0 0 24 24",
|
|
30
|
+
fill: "none",
|
|
31
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
32
|
+
children: /* @__PURE__ */ o("path", {
|
|
33
|
+
d: "M4.00023 5L4 17M13 5L12.9998 17M4 11H12.9998M19.875 19V10L17.625 12.25",
|
|
34
|
+
strokeWidth: "1.5",
|
|
35
|
+
strokeLinecap: "round",
|
|
36
|
+
strokeLinejoin: "round"
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
ariaLabel: "Heading 2",
|
|
42
|
+
command: () => s.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
43
|
+
isActive: () => !!c?.isHeading2,
|
|
44
|
+
icon: /* @__PURE__ */ o("svg", {
|
|
45
|
+
fill: "none",
|
|
46
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
47
|
+
className: "scribe-inline-menu-icon",
|
|
48
|
+
viewBox: "0 0 24 24",
|
|
49
|
+
children: /* @__PURE__ */ o("path", {
|
|
50
|
+
d: "M3.37402 5V17M12.374 5V17M3.37402 11H12.374M16.302 11.373C16.5035 10.8941 16.8644 10.4997 17.3236 10.2566C17.7829 10.0136 18.312 9.93705 18.8213 10.0399C19.3306 10.1427 19.7886 10.4186 20.1175 10.8207C20.4465 11.2229 20.6262 11.7265 20.626 12.246C20.628 12.694 20.494 13.132 20.242 13.503L16.123 19H20.626",
|
|
51
|
+
strokeWidth: "1.5",
|
|
52
|
+
strokeLinecap: "round",
|
|
53
|
+
strokeLinejoin: "round"
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
ariaLabel: "Heading 3",
|
|
59
|
+
command: () => s.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
60
|
+
isActive: () => !!c?.isHeading3,
|
|
61
|
+
icon: /* @__PURE__ */ o("svg", {
|
|
62
|
+
className: "scribe-inline-menu-icon",
|
|
63
|
+
viewBox: "0 0 24 24",
|
|
64
|
+
fill: "none",
|
|
65
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
66
|
+
children: /* @__PURE__ */ o("path", {
|
|
67
|
+
d: "M3.375 5V17M12.375 5V17M3.375 11H12.375M16.125 10H20.625L18 13.75C18.4317 13.7499 18.8568 13.8564 19.2375 14.0598C19.6183 14.2633 19.943 14.5575 20.1828 14.9165C20.4227 15.2754 20.5703 15.688 20.6127 16.1176C20.655 16.5472 20.5907 16.9807 20.4255 17.3795C20.2603 17.7783 19.9993 18.1303 19.6656 18.4042C19.3319 18.678 18.9358 18.8654 18.5123 18.9496C18.0889 19.0338 17.6513 19.0123 17.2382 18.8869C16.8251 18.7616 16.4492 18.5363 16.144 18.231",
|
|
68
|
+
strokeWidth: "1.5",
|
|
69
|
+
strokeLinecap: "round",
|
|
70
|
+
strokeLinejoin: "round"
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
ariaLabel: "Bold",
|
|
76
|
+
command: () => s.chain().focus().toggleBold().run(),
|
|
77
|
+
isActive: () => !!c?.isBold,
|
|
78
|
+
icon: /* @__PURE__ */ o("svg", {
|
|
79
|
+
className: "scribe-inline-menu-icon",
|
|
80
|
+
viewBox: "0 0 24 24",
|
|
81
|
+
fill: "none",
|
|
82
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
83
|
+
children: /* @__PURE__ */ o("path", {
|
|
84
|
+
d: "M12.8571 12C13.918 12 14.9354 11.5786 15.6856 10.8284C16.4357 10.0783 16.8571 9.06087 16.8571 8C16.8571 6.93913 16.4357 5.92172 15.6856 5.17157C14.9354 4.42143 13.918 4 12.8571 4H6V12M12.8571 12H6M12.8571 12H14C15.0609 12 16.0783 12.4214 16.8284 13.1716C17.5786 13.9217 18 14.9391 18 16C18 17.0609 17.5786 18.0783 16.8284 18.8284C16.0783 19.5786 15.0609 20 14 20H6V12",
|
|
85
|
+
strokeWidth: "1.5",
|
|
86
|
+
strokeLinecap: "round",
|
|
87
|
+
strokeLinejoin: "round"
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
ariaLabel: "Italic",
|
|
93
|
+
command: () => s.chain().focus().toggleItalic().run(),
|
|
94
|
+
isActive: () => !!c?.isItalic,
|
|
95
|
+
icon: /* @__PURE__ */ o("svg", {
|
|
96
|
+
className: "scribe-inline-menu-icon",
|
|
97
|
+
viewBox: "0 0 24 24",
|
|
98
|
+
fill: "none",
|
|
99
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
100
|
+
children: /* @__PURE__ */ o("path", {
|
|
101
|
+
d: "M10.8571 4H17.7142M6.28564 20H13.1428M14.2856 4L9.71422 20",
|
|
102
|
+
strokeWidth: "1.5",
|
|
103
|
+
strokeLinecap: "round",
|
|
104
|
+
strokeLinejoin: "round"
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
ariaLabel: "Strike",
|
|
110
|
+
command: () => s.chain().focus().toggleStrike().run(),
|
|
111
|
+
isActive: () => !!c?.isStrike,
|
|
112
|
+
icon: /* @__PURE__ */ o("svg", {
|
|
113
|
+
className: "scribe-inline-menu-icon",
|
|
114
|
+
viewBox: "0 0 24 24",
|
|
115
|
+
fill: "none",
|
|
116
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
117
|
+
children: /* @__PURE__ */ o("path", {
|
|
118
|
+
d: "M11.0121 12H12.9874C15.1693 12 16.938 13.7909 16.938 16C16.938 18.2091 15.1693 20 12.9874 20H11.0121C8.83024 20 7.06149 18.2091 7.06149 16M16.938 8C16.938 5.79086 15.1693 4 12.9874 4H11.0121C8.83024 4 7.06149 5.79086 7.06149 8C7.06149 8.3453 7.1047 8.68038 7.18595 9M4 12H20",
|
|
119
|
+
strokeWidth: "1.5",
|
|
120
|
+
strokeLinecap: "round",
|
|
121
|
+
strokeLinejoin: "round"
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
ariaLabel: "Inline code",
|
|
127
|
+
command: () => s.chain().focus().toggleCode().run(),
|
|
128
|
+
isActive: () => !!c?.isCode,
|
|
129
|
+
icon: /* @__PURE__ */ o("svg", {
|
|
130
|
+
className: "scribe-inline-menu-icon",
|
|
131
|
+
viewBox: "0 0 24 24",
|
|
132
|
+
fill: "none",
|
|
133
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
134
|
+
children: /* @__PURE__ */ o("path", {
|
|
135
|
+
d: "M16.5 16.5L21 12L16.5 7.50002M7.5 7.50002L3 12L7.5 16.5M13.8 3.90002L10.2 20.1",
|
|
136
|
+
strokeWidth: "1.5",
|
|
137
|
+
strokeLinecap: "round",
|
|
138
|
+
strokeLinejoin: "round"
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
return /* @__PURE__ */ o(n, {
|
|
144
|
+
editor: s,
|
|
145
|
+
appendTo: t(s),
|
|
146
|
+
options: { strategy: "fixed" },
|
|
147
|
+
children: /* @__PURE__ */ o("div", {
|
|
148
|
+
className: "scribe-bubble-menu",
|
|
149
|
+
children: /* @__PURE__ */ o(r, {
|
|
150
|
+
align: "center",
|
|
151
|
+
gap: "2",
|
|
152
|
+
children: u.map((e) => /* @__PURE__ */ o(i, {
|
|
153
|
+
type: "button",
|
|
154
|
+
size: "1",
|
|
155
|
+
radius: "medium",
|
|
156
|
+
color: "gray",
|
|
157
|
+
variant: e.isActive() ? "soft" : "ghost",
|
|
158
|
+
onMouseDown: (t) => l(t, e.command),
|
|
159
|
+
children: e.icon
|
|
160
|
+
}, e.ariaLabel))
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
});
|
|
1024
164
|
};
|
|
165
|
+
//#endregion
|
|
166
|
+
export { s as default };
|