@blockslides/vue-3 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,718 @@
1
+ import { Editor as D, MarkView as A, NodeView as R } from "@blockslides/core";
2
+ export * from "@blockslides/core";
3
+ import { markRaw as j, customRef as F, defineComponent as p, h as m, ref as M, getCurrentInstance as I, watchEffect as U, nextTick as T, unref as c, onBeforeUnmount as O, shallowRef as W, onMounted as B, computed as S, watch as V, openBlock as w, createElementBlock as L, normalizeStyle as z, normalizeClass as H, createElementVNode as $, createVNode as J, createBlock as K, mergeProps as G, createCommentVNode as _, reactive as Q, render as P, toRaw as X, provide as k } from "vue";
4
+ import { templatesV1 as Y } from "@blockslides/ai-context";
5
+ import { ExtensionKit as Z } from "@blockslides/extension-kit";
6
+ import { _ as ee } from "./FloatingMenu-BKkixozS.js";
7
+ import { B as ke, F as Ne } from "./FloatingMenu-BKkixozS.js";
8
+ function N(r) {
9
+ return F((e, t) => ({
10
+ get() {
11
+ return e(), r;
12
+ },
13
+ set(o) {
14
+ r = o, requestAnimationFrame(() => {
15
+ requestAnimationFrame(() => {
16
+ t();
17
+ });
18
+ });
19
+ }
20
+ }));
21
+ }
22
+ class te extends D {
23
+ constructor(e = {}) {
24
+ return super(e), this.contentComponent = null, this.appContext = null, this.reactiveState = N(this.view.state), this.reactiveExtensionStorage = N(this.extensionStorage), this.on("beforeTransaction", ({ nextState: t }) => {
25
+ this.reactiveState.value = t, this.reactiveExtensionStorage.value = this.extensionStorage;
26
+ }), j(this);
27
+ }
28
+ get state() {
29
+ return this.reactiveState ? this.reactiveState.value : this.view.state;
30
+ }
31
+ get storage() {
32
+ return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
33
+ }
34
+ /**
35
+ * Register a ProseMirror plugin.
36
+ */
37
+ registerPlugin(e, t) {
38
+ const o = super.registerPlugin(e, t);
39
+ return this.reactiveState && (this.reactiveState.value = o), o;
40
+ }
41
+ /**
42
+ * Unregister a ProseMirror plugin.
43
+ */
44
+ unregisterPlugin(e) {
45
+ const t = super.unregisterPlugin(e);
46
+ return this.reactiveState && t && (this.reactiveState.value = t), t;
47
+ }
48
+ }
49
+ const oe = p({
50
+ name: "EditorContent",
51
+ props: {
52
+ editor: {
53
+ default: null,
54
+ type: Object
55
+ }
56
+ },
57
+ setup(r) {
58
+ const e = M(), t = I();
59
+ return U(() => {
60
+ const o = r.editor;
61
+ o && o.options.element && e.value && T(() => {
62
+ var i;
63
+ if (!e.value || !((i = o.view.dom) != null && i.parentNode))
64
+ return;
65
+ const n = c(e.value);
66
+ e.value.append(...o.view.dom.parentNode.childNodes), o.contentComponent = t.ctx._, t && (o.appContext = {
67
+ ...t.appContext,
68
+ // Vue internally uses prototype chain to forward/shadow injects across the entire component chain
69
+ // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext
70
+ // @ts-expect-error forward instance's 'provides' into appContext
71
+ provides: t.provides
72
+ }), o.setOptions({
73
+ element: n
74
+ }), o.createNodeViews();
75
+ });
76
+ }), O(() => {
77
+ const o = r.editor;
78
+ o && (o.contentComponent = null, o.appContext = null);
79
+ }), { rootEl: e };
80
+ },
81
+ render() {
82
+ return m("div", {
83
+ ref: (r) => {
84
+ this.rootEl = r;
85
+ }
86
+ });
87
+ }
88
+ }), fe = p({
89
+ name: "NodeViewContent",
90
+ props: {
91
+ as: {
92
+ type: String,
93
+ default: "div"
94
+ }
95
+ },
96
+ render() {
97
+ return m(this.as, {
98
+ style: {
99
+ whiteSpace: "pre-wrap"
100
+ },
101
+ "data-node-view-content": ""
102
+ });
103
+ }
104
+ }), Se = p({
105
+ name: "NodeViewWrapper",
106
+ props: {
107
+ as: {
108
+ type: String,
109
+ default: "div"
110
+ }
111
+ },
112
+ inject: ["onDragStart", "decorationClasses"],
113
+ render() {
114
+ var r, e;
115
+ return m(
116
+ this.as,
117
+ {
118
+ // @ts-ignore
119
+ class: this.decorationClasses,
120
+ style: {
121
+ whiteSpace: "normal"
122
+ },
123
+ "data-node-view-wrapper": "",
124
+ // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)
125
+ onDragstart: this.onDragStart
126
+ },
127
+ (e = (r = this.$slots).default) == null ? void 0 : e.call(r)
128
+ );
129
+ }
130
+ }), ne = (r = {}) => {
131
+ console.log("[useEditor] THE OPTIONS ARE:", r), console.log("[useEditor] Creating editor with options:", r), console.log("[useEditor] options.enableCoreExtensions:", r.enableCoreExtensions), console.log("[useEditor] options.injectCSS:", r.injectCSS);
132
+ const e = W();
133
+ return B(() => {
134
+ var t;
135
+ console.log("[useEditor] onMounted - Creating Editor instance"), console.log("[useEditor] onMounted - options:", r), console.log("[useEditor] onMounted - options.enableCoreExtensions:", r.enableCoreExtensions), e.value = new te(r), console.log("[useEditor] Editor instance created:", e.value), console.log("[useEditor] Editor view:", (t = e.value) == null ? void 0 : t.view);
136
+ }), O(() => {
137
+ var n, i, s, l;
138
+ console.log("[useEditor] onBeforeUnmount - Cleaning up editor");
139
+ const t = (i = (n = e.value) == null ? void 0 : n.view.dom) == null ? void 0 : i.parentNode, o = t == null ? void 0 : t.cloneNode(!0);
140
+ (s = t == null ? void 0 : t.parentNode) == null || s.replaceChild(o, t), (l = e.value) == null || l.destroy();
141
+ }), e;
142
+ }, re = () => ({
143
+ /**
144
+ * Placeholder slide if no content is provided.
145
+ */
146
+ type: "doc",
147
+ content: [
148
+ {
149
+ type: "slide",
150
+ attrs: {
151
+ size: "16x9",
152
+ className: "",
153
+ id: "slide-1",
154
+ backgroundMode: "none",
155
+ backgroundColor: null,
156
+ backgroundImage: null,
157
+ backgroundOverlayColor: null,
158
+ backgroundOverlayOpacity: null
159
+ },
160
+ content: [
161
+ {
162
+ type: "column",
163
+ attrs: {
164
+ align: "center",
165
+ padding: "lg",
166
+ margin: null,
167
+ gap: "md",
168
+ backgroundColor: "#ffffff",
169
+ backgroundImage: null,
170
+ borderRadius: null,
171
+ border: null,
172
+ fill: !0,
173
+ width: null,
174
+ height: null,
175
+ justify: "center"
176
+ },
177
+ content: [
178
+ {
179
+ type: "heading",
180
+ attrs: {
181
+ align: null,
182
+ padding: null,
183
+ margin: null,
184
+ gap: null,
185
+ backgroundColor: null,
186
+ backgroundImage: null,
187
+ borderRadius: null,
188
+ border: null,
189
+ fill: null,
190
+ width: null,
191
+ height: null,
192
+ justify: null,
193
+ id: "1fc4664c-333d-4203-a3f1-3ad27a54c535",
194
+ "data-toc-id": "1fc4664c-333d-4203-a3f1-3ad27a54c535",
195
+ level: 1
196
+ },
197
+ content: [
198
+ {
199
+ type: "text",
200
+ text: "Lorem ipsum dolor sit amet"
201
+ }
202
+ ]
203
+ },
204
+ {
205
+ type: "paragraph",
206
+ attrs: {
207
+ align: null,
208
+ padding: null,
209
+ margin: null,
210
+ gap: null,
211
+ backgroundColor: null,
212
+ backgroundImage: null,
213
+ borderRadius: null,
214
+ border: null,
215
+ fill: null,
216
+ width: null,
217
+ height: null,
218
+ justify: null
219
+ },
220
+ content: [
221
+ {
222
+ type: "text",
223
+ text: "Consectetur adipiscing elit. Sed do eiusmod tempor incididunt. "
224
+ }
225
+ ]
226
+ }
227
+ ]
228
+ }
229
+ ]
230
+ }
231
+ ]
232
+ }), ie = (r) => ({
233
+ showPresets: !0,
234
+ presets: r,
235
+ presetBackground: "#0f172a",
236
+ presetForeground: "#e5e7eb"
237
+ }), se = {
238
+ renderMode: "dynamic",
239
+ hoverOutline: { color: "#3b82f6", width: "1.5px", offset: "4px" },
240
+ hoverOutlineCascade: !1
241
+ }, de = (r = {}) => {
242
+ console.log("[useSlideEditor] Called with props:", r);
243
+ const {
244
+ content: e,
245
+ onChange: t,
246
+ extensions: o,
247
+ extensionKitOptions: n,
248
+ presetTemplates: i,
249
+ onEditorReady: s,
250
+ theme: l = "light",
251
+ editorProps: a,
252
+ onUpdate: u,
253
+ ...g
254
+ } = r;
255
+ console.log("[useSlideEditor] editorOptions:", g), console.log("[useSlideEditor] editorOptions.enableCoreExtensions:", g.enableCoreExtensions), console.log("[useSlideEditor] editorOptions.injectCSS:", g.injectCSS), console.log("[useSlideEditor] Content:", e), console.log("[useSlideEditor] ExtensionKitOptions:", n);
256
+ const E = S(
257
+ () => i ?? Y.listPresetTemplates()
258
+ ), v = S(() => {
259
+ const d = (n == null ? void 0 : n.addSlideButton) === !1 ? !1 : {
260
+ ...ie(E.value),
261
+ ...(n == null ? void 0 : n.addSlideButton) ?? {}
262
+ }, h = (n == null ? void 0 : n.slide) === !1 ? !1 : {
263
+ ...se,
264
+ ...(n == null ? void 0 : n.slide) ?? {}
265
+ }, y = {
266
+ ...n,
267
+ addSlideButton: d,
268
+ slide: h
269
+ };
270
+ return console.log("[useSlideEditor] mergedExtensionKitOptions:", y), console.log("[useSlideEditor] addSlideButton config:", y.addSlideButton), console.log("[useSlideEditor] presets:", E.value), y;
271
+ }), C = S(() => {
272
+ console.log("[useSlideEditor] Configuring ExtensionKit with options:", v.value);
273
+ const d = Z.configure(v.value);
274
+ console.log("[useSlideEditor] ExtensionKit configured:", d), console.log("[useSlideEditor] ExtensionKit name:", d.name);
275
+ const h = o ? [d, ...o] : [d];
276
+ return console.log("[useSlideEditor] Final extensions array:", h), h;
277
+ }), x = e ?? re();
278
+ console.log("[useSlideEditor] Initial content resolved:", x), console.log("[useSlideEditor] Resolved extensions:", C.value);
279
+ const f = {
280
+ content: x,
281
+ extensions: C.value,
282
+ theme: l,
283
+ editorProps: {
284
+ attributes: {
285
+ autocomplete: "off",
286
+ autocorrect: "off",
287
+ autocapitalize: "off",
288
+ class: "min-h-full min-w-full",
289
+ ...(a == null ? void 0 : a.attributes) ?? {}
290
+ },
291
+ ...a
292
+ },
293
+ ...g,
294
+ onUpdate: (d) => {
295
+ console.log("[useSlideEditor] onUpdate called");
296
+ const h = d.editor.getJSON();
297
+ t == null || t(h, d.editor), u == null || u(d);
298
+ }
299
+ };
300
+ console.log("[useSlideEditor] Final editor config:", f), console.log("[useSlideEditor] Final editor config enableCoreExtensions:", f.enableCoreExtensions), console.log("[useSlideEditor] Final editor config injectCSS:", f.injectCSS);
301
+ const b = ne(f);
302
+ return console.log("[useSlideEditor] Editor ref created:", b), V(
303
+ b,
304
+ (d) => {
305
+ console.log("[useSlideEditor] Editor watch triggered, newEditor:", d), d && !d.isDestroyed ? (console.log("[useSlideEditor] ✅ Calling onEditorReady"), s == null || s(d)) : console.log("[useSlideEditor] ❌ Editor not ready or destroyed");
306
+ },
307
+ { immediate: !0 }
308
+ ), { editor: b, presets: E };
309
+ }, le = { class: "bs-viewport" }, Ee = /* @__PURE__ */ p({
310
+ __name: "SlideEditor",
311
+ props: {
312
+ bubbleMenuPreset: { type: [Boolean, Object], default: !0 },
313
+ className: {},
314
+ style: {},
315
+ content: {},
316
+ onChange: {},
317
+ extensions: {},
318
+ extensionKitOptions: {},
319
+ presetTemplates: {},
320
+ onEditorReady: {},
321
+ element: {},
322
+ theme: {},
323
+ injectCSS: { type: Boolean },
324
+ injectNonce: {},
325
+ autofocus: { type: [String, Number, Boolean, null] },
326
+ editable: { type: Boolean },
327
+ editorProps: {},
328
+ parseOptions: {},
329
+ coreExtensionOptions: {},
330
+ enableInputRules: { type: [Array, Boolean] },
331
+ enablePasteRules: { type: [Array, Boolean] },
332
+ enableCoreExtensions: { type: [Boolean, Object] },
333
+ enableContentCheck: { type: Boolean },
334
+ emitContentError: { type: Boolean },
335
+ onBeforeCreate: {},
336
+ onCreate: {},
337
+ onMount: {},
338
+ onUnmount: {},
339
+ onContentError: {},
340
+ onUpdate: {},
341
+ onSelectionUpdate: {},
342
+ onTransaction: {},
343
+ onFocus: {},
344
+ onBlur: {},
345
+ onDestroy: {},
346
+ onPaste: {},
347
+ onDrop: {},
348
+ onDelete: {}
349
+ },
350
+ setup(r) {
351
+ console.log("[SlideEditor.vue] Component loading");
352
+ const e = r;
353
+ console.log("[SlideEditor.vue] Props:", e), console.log("[SlideEditor.vue] Props.enableCoreExtensions:", e.enableCoreExtensions), console.log("[SlideEditor.vue] Props.injectCSS:", e.injectCSS);
354
+ const {
355
+ bubbleMenuPreset: t,
356
+ className: o,
357
+ style: n,
358
+ ...i
359
+ } = e;
360
+ console.log("[SlideEditor.vue] Hook props:", i), console.log("[SlideEditor.vue] hookProps.enableCoreExtensions:", i.enableCoreExtensions), console.log("[SlideEditor.vue] hookProps.injectCSS:", i.injectCSS);
361
+ const { editor: s, presets: l } = de(i);
362
+ console.log("[SlideEditor.vue] Editor from useSlideEditor:", s);
363
+ const a = S(() => e.bubbleMenuPreset === !1 ? null : e.bubbleMenuPreset === !0 ? {} : e.bubbleMenuPreset);
364
+ return V(s, (u) => {
365
+ console.log("[SlideEditor.vue] Editor watch - newEditor:", u), console.log("[SlideEditor.vue] Editor exists:", !!u);
366
+ }, { immediate: !0 }), B(() => {
367
+ console.log("[SlideEditor.vue] Component mounted"), console.log("[SlideEditor.vue] Editor value:", s.value);
368
+ }), (u, g) => c(s) ? (w(), L("div", {
369
+ key: 0,
370
+ class: H(c(o)),
371
+ style: z(c(n))
372
+ }, [
373
+ $("div", le, [
374
+ J(c(oe), { editor: c(s) }, null, 8, ["editor"]),
375
+ a.value ? (w(), K(ee, G({
376
+ key: 0,
377
+ editor: c(s)
378
+ }, a.value), null, 16, ["editor"])) : _("", !0)
379
+ ])
380
+ ], 6)) : _("", !0);
381
+ }
382
+ });
383
+ class q {
384
+ constructor(e, { props: t = {}, editor: o }) {
385
+ this.destroyed = !1, this.editor = o, this.component = j(e), this.el = document.createElement("div"), this.props = Q(t), this.renderedComponent = this.renderComponent();
386
+ }
387
+ get element() {
388
+ return this.renderedComponent.el;
389
+ }
390
+ get ref() {
391
+ var e, t, o, n;
392
+ return (t = (e = this.renderedComponent.vNode) == null ? void 0 : e.component) != null && t.exposed ? this.renderedComponent.vNode.component.exposed : (n = (o = this.renderedComponent.vNode) == null ? void 0 : o.component) == null ? void 0 : n.proxy;
393
+ }
394
+ renderComponent() {
395
+ if (this.destroyed)
396
+ return this.renderedComponent;
397
+ let e = m(this.component, this.props);
398
+ return this.editor.appContext && (e.appContext = this.editor.appContext), typeof document < "u" && this.el && P(e, this.el), { vNode: e, destroy: () => {
399
+ this.el && P(null, this.el), this.el = null, e = null;
400
+ }, el: this.el ? this.el.firstElementChild : null };
401
+ }
402
+ updateProps(e = {}) {
403
+ this.destroyed || (Object.entries(e).forEach(([t, o]) => {
404
+ this.props[t] = o;
405
+ }), this.renderComponent());
406
+ }
407
+ destroy() {
408
+ this.destroyed || (this.destroyed = !0, this.renderedComponent.destroy());
409
+ }
410
+ }
411
+ const be = {
412
+ editor: {
413
+ type: Object,
414
+ required: !0
415
+ },
416
+ mark: {
417
+ type: Object,
418
+ required: !0
419
+ },
420
+ extension: {
421
+ type: Object,
422
+ required: !0
423
+ },
424
+ inline: {
425
+ type: Boolean,
426
+ required: !0
427
+ },
428
+ view: {
429
+ type: Object,
430
+ required: !0
431
+ },
432
+ updateAttributes: {
433
+ type: Function,
434
+ required: !0
435
+ },
436
+ HTMLAttributes: {
437
+ type: Object,
438
+ required: !0
439
+ }
440
+ }, ye = p({
441
+ name: "MarkViewContent",
442
+ props: {
443
+ as: {
444
+ type: String,
445
+ default: "span"
446
+ }
447
+ },
448
+ render() {
449
+ return m(this.as, {
450
+ style: {
451
+ whiteSpace: "inherit"
452
+ },
453
+ "data-mark-view-content": ""
454
+ });
455
+ }
456
+ });
457
+ class ae extends A {
458
+ constructor(e, t, o) {
459
+ super(e, t, o);
460
+ const n = { ...t, updateAttributes: this.updateAttributes.bind(this) }, i = p({
461
+ extends: { ...e },
462
+ props: Object.keys(n),
463
+ template: this.component.template,
464
+ setup: (s) => {
465
+ var l;
466
+ return (l = e.setup) == null ? void 0 : l.call(e, s, {
467
+ expose: () => {
468
+ }
469
+ });
470
+ },
471
+ // Add support for scoped styles
472
+ __scopeId: e.__scopeId,
473
+ __cssModules: e.__cssModules,
474
+ __name: e.__name,
475
+ __file: e.__file
476
+ });
477
+ this.renderer = new q(i, {
478
+ editor: this.editor,
479
+ props: n
480
+ });
481
+ }
482
+ get dom() {
483
+ return this.renderer.element;
484
+ }
485
+ get contentDOM() {
486
+ return this.dom.querySelector("[data-mark-view-content]");
487
+ }
488
+ updateAttributes(e) {
489
+ const t = X(this.mark);
490
+ super.updateAttributes(e, t);
491
+ }
492
+ destroy() {
493
+ this.renderer.destroy();
494
+ }
495
+ }
496
+ function ve(r, e = {}) {
497
+ return (t) => t.editor.contentComponent ? new ae(r, t, e) : {};
498
+ }
499
+ const Ce = {
500
+ editor: {
501
+ type: Object,
502
+ required: !0
503
+ },
504
+ node: {
505
+ type: Object,
506
+ required: !0
507
+ },
508
+ decorations: {
509
+ type: Object,
510
+ required: !0
511
+ },
512
+ selected: {
513
+ type: Boolean,
514
+ required: !0
515
+ },
516
+ extension: {
517
+ type: Object,
518
+ required: !0
519
+ },
520
+ getPos: {
521
+ type: Function,
522
+ required: !0
523
+ },
524
+ updateAttributes: {
525
+ type: Function,
526
+ required: !0
527
+ },
528
+ deleteNode: {
529
+ type: Function,
530
+ required: !0
531
+ },
532
+ view: {
533
+ type: Object,
534
+ required: !0
535
+ },
536
+ innerDecorations: {
537
+ type: Object,
538
+ required: !0
539
+ },
540
+ HTMLAttributes: {
541
+ type: Object,
542
+ required: !0
543
+ }
544
+ };
545
+ class ue extends R {
546
+ constructor() {
547
+ super(...arguments), this.cachedExtensionWithSyncedStorage = null;
548
+ }
549
+ /**
550
+ * Returns a proxy of the extension that redirects storage access to the editor's mutable storage.
551
+ * This preserves the original prototype chain (instanceof checks, methods like configure/extend work).
552
+ * Cached to avoid proxy creation on every update.
553
+ */
554
+ get extensionWithSyncedStorage() {
555
+ if (!this.cachedExtensionWithSyncedStorage) {
556
+ const e = this.editor, t = this.extension;
557
+ this.cachedExtensionWithSyncedStorage = new Proxy(t, {
558
+ get(o, n, i) {
559
+ return n === "storage" ? e.storage[t.name] ?? {} : Reflect.get(o, n, i);
560
+ }
561
+ });
562
+ }
563
+ return this.cachedExtensionWithSyncedStorage;
564
+ }
565
+ mount() {
566
+ const e = {
567
+ editor: this.editor,
568
+ node: this.node,
569
+ decorations: this.decorations,
570
+ innerDecorations: this.innerDecorations,
571
+ view: this.view,
572
+ selected: !1,
573
+ extension: this.extensionWithSyncedStorage,
574
+ HTMLAttributes: this.HTMLAttributes,
575
+ getPos: () => this.getPos(),
576
+ updateAttributes: (n = {}) => this.updateAttributes(n),
577
+ deleteNode: () => this.deleteNode()
578
+ }, t = this.onDragStart.bind(this);
579
+ this.decorationClasses = M(this.getDecorationClasses());
580
+ const o = p({
581
+ extends: { ...this.component },
582
+ props: Object.keys(e),
583
+ template: this.component.template,
584
+ setup: (n) => {
585
+ var i, s;
586
+ return k("onDragStart", t), k("decorationClasses", this.decorationClasses), (s = (i = this.component).setup) == null ? void 0 : s.call(i, n, {
587
+ expose: () => {
588
+ }
589
+ });
590
+ },
591
+ // add support for scoped styles
592
+ // @ts-ignore
593
+ // eslint-disable-next-line
594
+ __scopeId: this.component.__scopeId,
595
+ // add support for CSS Modules
596
+ // @ts-ignore
597
+ // eslint-disable-next-line
598
+ __cssModules: this.component.__cssModules,
599
+ // add support for vue devtools
600
+ // @ts-ignore
601
+ // eslint-disable-next-line
602
+ __name: this.component.__name,
603
+ // @ts-ignore
604
+ // eslint-disable-next-line
605
+ __file: this.component.__file
606
+ });
607
+ this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this), this.editor.on("selectionUpdate", this.handleSelectionUpdate), this.renderer = new q(o, {
608
+ editor: this.editor,
609
+ props: e
610
+ });
611
+ }
612
+ /**
613
+ * Return the DOM element.
614
+ * This is the element that will be used to display the node view.
615
+ */
616
+ get dom() {
617
+ if (!this.renderer.element || !this.renderer.element.hasAttribute("data-node-view-wrapper"))
618
+ throw Error("Please use the NodeViewWrapper component for your node view.");
619
+ return this.renderer.element;
620
+ }
621
+ /**
622
+ * Return the content DOM element.
623
+ * This is the element that will be used to display the rich-text content of the node.
624
+ */
625
+ get contentDOM() {
626
+ return this.node.isLeaf ? null : this.dom.querySelector("[data-node-view-content]");
627
+ }
628
+ /**
629
+ * On editor selection update, check if the node is selected.
630
+ * If it is, call `selectNode`, otherwise call `deselectNode`.
631
+ */
632
+ handleSelectionUpdate() {
633
+ const { from: e, to: t } = this.editor.state.selection, o = this.getPos();
634
+ if (typeof o == "number")
635
+ if (e <= o && t >= o + this.node.nodeSize) {
636
+ if (this.renderer.props.selected)
637
+ return;
638
+ this.selectNode();
639
+ } else {
640
+ if (!this.renderer.props.selected)
641
+ return;
642
+ this.deselectNode();
643
+ }
644
+ }
645
+ /**
646
+ * On update, update the Vue component.
647
+ * To prevent unnecessary updates, the `update` option can be used.
648
+ */
649
+ update(e, t, o) {
650
+ const n = (i) => {
651
+ this.decorationClasses.value = this.getDecorationClasses(), this.renderer.updateProps(i);
652
+ };
653
+ if (typeof this.options.update == "function") {
654
+ const i = this.node, s = this.decorations, l = this.innerDecorations;
655
+ return this.node = e, this.decorations = t, this.innerDecorations = o, this.options.update({
656
+ oldNode: i,
657
+ oldDecorations: s,
658
+ newNode: e,
659
+ newDecorations: t,
660
+ oldInnerDecorations: l,
661
+ innerDecorations: o,
662
+ updateProps: () => n({ node: e, decorations: t, innerDecorations: o, extension: this.extensionWithSyncedStorage })
663
+ });
664
+ }
665
+ return e.type !== this.node.type ? !1 : (e === this.node && this.decorations === t && this.innerDecorations === o || (this.node = e, this.decorations = t, this.innerDecorations = o, n({ node: e, decorations: t, innerDecorations: o, extension: this.extensionWithSyncedStorage })), !0);
666
+ }
667
+ /**
668
+ * Select the node.
669
+ * Add the `selected` prop and the `ProseMirror-selectednode` class.
670
+ */
671
+ selectNode() {
672
+ this.renderer.updateProps({
673
+ selected: !0
674
+ }), this.renderer.element && this.renderer.element.classList.add("ProseMirror-selectednode");
675
+ }
676
+ /**
677
+ * Deselect the node.
678
+ * Remove the `selected` prop and the `ProseMirror-selectednode` class.
679
+ */
680
+ deselectNode() {
681
+ this.renderer.updateProps({
682
+ selected: !1
683
+ }), this.renderer.element && this.renderer.element.classList.remove("ProseMirror-selectednode");
684
+ }
685
+ getDecorationClasses() {
686
+ return this.decorations.flatMap((e) => e.type.attrs.class).join(" ");
687
+ }
688
+ destroy() {
689
+ this.renderer.destroy(), this.editor.off("selectionUpdate", this.handleSelectionUpdate);
690
+ }
691
+ }
692
+ function xe(r, e) {
693
+ return (t) => {
694
+ if (!t.editor.contentComponent)
695
+ return {};
696
+ const o = typeof r == "function" && "__vccOpts" in r ? r.__vccOpts : r;
697
+ return new ue(o, t, e);
698
+ };
699
+ }
700
+ export {
701
+ ke as BubbleMenu,
702
+ ee as BubbleMenuPreset,
703
+ te as Editor,
704
+ oe as EditorContent,
705
+ Ne as FloatingMenu,
706
+ ye as MarkViewContent,
707
+ fe as NodeViewContent,
708
+ Se as NodeViewWrapper,
709
+ Ee as SlideEditor,
710
+ ae as VueMarkView,
711
+ ve as VueMarkViewRenderer,
712
+ xe as VueNodeViewRenderer,
713
+ q as VueRenderer,
714
+ be as markViewProps,
715
+ Ce as nodeViewProps,
716
+ ne as useEditor,
717
+ de as useSlideEditor
718
+ };