@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/LICENSE.md +36 -0
- package/dist/Editor.d.ts +24 -0
- package/dist/EditorContent.d.ts +18 -0
- package/dist/FloatingMenu-BKkixozS.js +226 -0
- package/dist/FloatingMenu-By8Qi7tW.cjs +1 -0
- package/dist/NodeViewContent.d.ts +13 -0
- package/dist/NodeViewWrapper.d.ts +13 -0
- package/dist/VueMarkViewRenderer.d.ts +63 -0
- package/dist/VueNodeViewRenderer.d.ts +63 -0
- package/dist/VueRenderer.d.ts +35 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +718 -0
- package/dist/menus/BubbleMenu.d.ts +6 -0
- package/dist/menus/FloatingMenu.d.ts +6 -0
- package/dist/menus/index.d.ts +3 -0
- package/dist/menus.cjs +1 -0
- package/dist/menus.d.ts +1 -0
- package/dist/menus.js +6 -0
- package/dist/useEditor.d.ts +4 -0
- package/dist/useSlideEditor.d.ts +36 -0
- package/package.json +69 -0
- package/src/Editor.ts +93 -0
- package/src/EditorContent.ts +77 -0
- package/src/NodeViewContent.ts +21 -0
- package/src/NodeViewWrapper.ts +31 -0
- package/src/SlideEditor.vue +54 -0
- package/src/VueMarkViewRenderer.ts +130 -0
- package/src/VueNodeViewRenderer.ts +317 -0
- package/src/VueRenderer.ts +104 -0
- package/src/index.ts +12 -0
- package/src/menus/BubbleMenu.ts +111 -0
- package/src/menus/BubbleMenuPreset.vue +137 -0
- package/src/menus/FloatingMenu.ts +84 -0
- package/src/menus/index.ts +3 -0
- package/src/useEditor.ts +24 -0
- package/src/useSlideEditor.ts +255 -0
- package/src/vue-shims.d.ts +5 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 BlockSlides
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Acknowledgments
|
|
26
|
+
|
|
27
|
+
This project includes code and patterns adapted from [Tiptap](https://tiptap.dev),
|
|
28
|
+
an open-source headless editor framework for web artisans.
|
|
29
|
+
|
|
30
|
+
**Tiptap License:**
|
|
31
|
+
|
|
32
|
+
- Copyright (c) 2025, Tiptap GmbH
|
|
33
|
+
- Licensed under MIT License
|
|
34
|
+
- Original source: https://github.com/ueberdosis/tiptap
|
|
35
|
+
|
|
36
|
+
See `_tiptap/LICENSE.md` for the full Tiptap license.
|
package/dist/Editor.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EditorOptions, Storage, Editor as CoreEditor } from '../../core/src';
|
|
2
|
+
import { EditorState, Plugin, PluginKey } from '../../pm/state/src';
|
|
3
|
+
import { AppContext, ComponentInternalInstance, ComponentPublicInstance } from 'vue';
|
|
4
|
+
|
|
5
|
+
export type ContentComponent = ComponentInternalInstance & {
|
|
6
|
+
ctx: ComponentPublicInstance;
|
|
7
|
+
};
|
|
8
|
+
export declare class Editor extends CoreEditor {
|
|
9
|
+
private reactiveState;
|
|
10
|
+
private reactiveExtensionStorage;
|
|
11
|
+
contentComponent: ContentComponent | null;
|
|
12
|
+
appContext: AppContext | null;
|
|
13
|
+
constructor(options?: Partial<EditorOptions>);
|
|
14
|
+
get state(): EditorState;
|
|
15
|
+
get storage(): Storage;
|
|
16
|
+
/**
|
|
17
|
+
* Register a ProseMirror plugin.
|
|
18
|
+
*/
|
|
19
|
+
registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
|
|
20
|
+
/**
|
|
21
|
+
* Unregister a ProseMirror plugin.
|
|
22
|
+
*/
|
|
23
|
+
unregisterPlugin(nameOrPluginKey: string | PluginKey): EditorState | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PropType, Ref } from 'vue';
|
|
2
|
+
import { Editor } from './Editor.js';
|
|
3
|
+
|
|
4
|
+
export declare const EditorContent: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
+
editor: {
|
|
6
|
+
default: null;
|
|
7
|
+
type: PropType<Editor>;
|
|
8
|
+
};
|
|
9
|
+
}>, {
|
|
10
|
+
rootEl: Ref<Element | undefined, Element | undefined>;
|
|
11
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
12
|
+
editor: {
|
|
13
|
+
default: null;
|
|
14
|
+
type: PropType<Editor>;
|
|
15
|
+
};
|
|
16
|
+
}>> & Readonly<{}>, {
|
|
17
|
+
editor: Editor;
|
|
18
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { defineComponent as m, ref as f, onMounted as g, watch as F, onBeforeUnmount as y, openBlock as D, createElementBlock as _, createCommentVNode as A, nextTick as M, h as v } from "vue";
|
|
2
|
+
import { BubbleMenuPlugin as E } from "@blockslides/extension-bubble-menu";
|
|
3
|
+
import { NodeSelection as N } from "@blockslides/pm/state";
|
|
4
|
+
import { buildMenuElement as C, DEFAULT_ALIGNMENTS as x, DEFAULT_FONT_SIZES as B, DEFAULT_FONTS as P, DEFAULT_HIGHLIGHT_PALETTE as j, DEFAULT_COLOR_PALETTE as L, DEFAULT_ITEMS as O } from "@blockslides/extension-bubble-menu-preset";
|
|
5
|
+
import { isTextSelection as R } from "@blockslides/core";
|
|
6
|
+
import { FloatingMenuPlugin as w } from "@blockslides/extension-floating-menu";
|
|
7
|
+
const z = {
|
|
8
|
+
key: 0,
|
|
9
|
+
style: { display: "none" }
|
|
10
|
+
}, S = "bubbleMenuPreset", H = /* @__PURE__ */ m({
|
|
11
|
+
__name: "BubbleMenuPreset",
|
|
12
|
+
props: {
|
|
13
|
+
editor: {},
|
|
14
|
+
updateDelay: {},
|
|
15
|
+
resizeDelay: {},
|
|
16
|
+
appendTo: { type: Function },
|
|
17
|
+
shouldShow: { type: [Function, null] },
|
|
18
|
+
getReferencedVirtualElement: { type: Function },
|
|
19
|
+
options: {},
|
|
20
|
+
items: {},
|
|
21
|
+
className: {},
|
|
22
|
+
injectStyles: { type: Boolean },
|
|
23
|
+
textColors: {},
|
|
24
|
+
highlightColors: {},
|
|
25
|
+
fonts: {},
|
|
26
|
+
fontSizes: {},
|
|
27
|
+
alignments: {},
|
|
28
|
+
onTextAction: { type: Function },
|
|
29
|
+
onImageReplace: { type: Function }
|
|
30
|
+
},
|
|
31
|
+
setup(r) {
|
|
32
|
+
const e = r, l = f(null);
|
|
33
|
+
let o;
|
|
34
|
+
const n = () => {
|
|
35
|
+
const t = e.editor;
|
|
36
|
+
if (!t || t.isDestroyed)
|
|
37
|
+
return;
|
|
38
|
+
o && (o(), o = void 0);
|
|
39
|
+
const { element: a, cleanup: s } = C(t, {
|
|
40
|
+
items: e.items ?? O,
|
|
41
|
+
className: e.className ?? "",
|
|
42
|
+
injectStyles: e.injectStyles !== !1,
|
|
43
|
+
textColors: e.textColors ?? L,
|
|
44
|
+
highlightColors: e.highlightColors ?? j,
|
|
45
|
+
fonts: e.fonts ?? P,
|
|
46
|
+
fontSizes: e.fontSizes ?? B,
|
|
47
|
+
alignments: e.alignments ?? x,
|
|
48
|
+
onTextAction: e.onTextAction,
|
|
49
|
+
onImageReplace: e.onImageReplace
|
|
50
|
+
});
|
|
51
|
+
l.value = a, o = s;
|
|
52
|
+
const p = ({ state: d, editor: c }) => {
|
|
53
|
+
var b, T;
|
|
54
|
+
const i = d.selection, h = i instanceof N && ["image", "imageBlock"].includes((T = (b = i.node) == null ? void 0 : b.type) == null ? void 0 : T.name) || c.isActive("image") || c.isActive("imageBlock");
|
|
55
|
+
return !!(h || R(i) && !i.empty && !h);
|
|
56
|
+
}, u = E({
|
|
57
|
+
editor: t,
|
|
58
|
+
element: a,
|
|
59
|
+
updateDelay: e.updateDelay,
|
|
60
|
+
resizeDelay: e.resizeDelay,
|
|
61
|
+
appendTo: e.appendTo,
|
|
62
|
+
pluginKey: S,
|
|
63
|
+
shouldShow: e.shouldShow ?? p,
|
|
64
|
+
getReferencedVirtualElement: e.getReferencedVirtualElement,
|
|
65
|
+
options: e.options
|
|
66
|
+
});
|
|
67
|
+
t.registerPlugin(u);
|
|
68
|
+
};
|
|
69
|
+
return g(() => {
|
|
70
|
+
n();
|
|
71
|
+
}), F(
|
|
72
|
+
() => [
|
|
73
|
+
e.editor,
|
|
74
|
+
e.updateDelay,
|
|
75
|
+
e.resizeDelay,
|
|
76
|
+
e.appendTo,
|
|
77
|
+
e.shouldShow,
|
|
78
|
+
e.getReferencedVirtualElement,
|
|
79
|
+
e.options,
|
|
80
|
+
e.items,
|
|
81
|
+
e.className,
|
|
82
|
+
e.injectStyles,
|
|
83
|
+
e.textColors,
|
|
84
|
+
e.highlightColors,
|
|
85
|
+
e.fonts,
|
|
86
|
+
e.fontSizes,
|
|
87
|
+
e.alignments,
|
|
88
|
+
e.onTextAction,
|
|
89
|
+
e.onImageReplace
|
|
90
|
+
],
|
|
91
|
+
() => {
|
|
92
|
+
n();
|
|
93
|
+
}
|
|
94
|
+
), y(() => {
|
|
95
|
+
var t;
|
|
96
|
+
e.editor && e.editor.unregisterPlugin(S), o && o(), (t = l.value) != null && t.parentNode && l.value.parentNode.removeChild(l.value);
|
|
97
|
+
}), (t, a) => l.value ? (D(), _("div", z)) : A("", !0);
|
|
98
|
+
}
|
|
99
|
+
}), q = m({
|
|
100
|
+
name: "BubbleMenu",
|
|
101
|
+
inheritAttrs: !1,
|
|
102
|
+
props: {
|
|
103
|
+
pluginKey: {
|
|
104
|
+
type: [String, Object],
|
|
105
|
+
default: "bubbleMenu"
|
|
106
|
+
},
|
|
107
|
+
editor: {
|
|
108
|
+
type: Object,
|
|
109
|
+
required: !0
|
|
110
|
+
},
|
|
111
|
+
updateDelay: {
|
|
112
|
+
type: Number,
|
|
113
|
+
default: void 0
|
|
114
|
+
},
|
|
115
|
+
resizeDelay: {
|
|
116
|
+
type: Number,
|
|
117
|
+
default: void 0
|
|
118
|
+
},
|
|
119
|
+
options: {
|
|
120
|
+
type: Object,
|
|
121
|
+
default: () => ({})
|
|
122
|
+
},
|
|
123
|
+
appendTo: {
|
|
124
|
+
type: [Object, Function],
|
|
125
|
+
default: void 0
|
|
126
|
+
},
|
|
127
|
+
shouldShow: {
|
|
128
|
+
type: Function,
|
|
129
|
+
default: null
|
|
130
|
+
},
|
|
131
|
+
getReferencedVirtualElement: {
|
|
132
|
+
type: Function,
|
|
133
|
+
default: void 0
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
setup(r, { slots: e, attrs: l }) {
|
|
137
|
+
const o = f(null);
|
|
138
|
+
return g(() => {
|
|
139
|
+
const {
|
|
140
|
+
editor: n,
|
|
141
|
+
options: t,
|
|
142
|
+
pluginKey: a,
|
|
143
|
+
resizeDelay: s,
|
|
144
|
+
appendTo: p,
|
|
145
|
+
shouldShow: u,
|
|
146
|
+
getReferencedVirtualElement: d,
|
|
147
|
+
updateDelay: c
|
|
148
|
+
} = r, i = o.value;
|
|
149
|
+
i && (i.style.visibility = "hidden", i.style.position = "absolute", i.remove(), M(() => {
|
|
150
|
+
n.registerPlugin(
|
|
151
|
+
E({
|
|
152
|
+
editor: n,
|
|
153
|
+
element: i,
|
|
154
|
+
options: t,
|
|
155
|
+
pluginKey: a,
|
|
156
|
+
resizeDelay: s,
|
|
157
|
+
appendTo: p,
|
|
158
|
+
shouldShow: u,
|
|
159
|
+
getReferencedVirtualElement: d,
|
|
160
|
+
updateDelay: c
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
}));
|
|
164
|
+
}), y(() => {
|
|
165
|
+
const { pluginKey: n, editor: t } = r;
|
|
166
|
+
t.unregisterPlugin(n);
|
|
167
|
+
}), () => {
|
|
168
|
+
var n;
|
|
169
|
+
return v("div", { ref: o, ...l }, (n = e.default) == null ? void 0 : n.call(e));
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}), Z = m({
|
|
173
|
+
name: "FloatingMenu",
|
|
174
|
+
inheritAttrs: !1,
|
|
175
|
+
props: {
|
|
176
|
+
pluginKey: {
|
|
177
|
+
// TODO: TypeScript breaks
|
|
178
|
+
// type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
|
|
179
|
+
type: null,
|
|
180
|
+
default: "floatingMenu"
|
|
181
|
+
},
|
|
182
|
+
editor: {
|
|
183
|
+
type: Object,
|
|
184
|
+
required: !0
|
|
185
|
+
},
|
|
186
|
+
options: {
|
|
187
|
+
type: Object,
|
|
188
|
+
default: () => ({})
|
|
189
|
+
},
|
|
190
|
+
appendTo: {
|
|
191
|
+
type: [Object, Function],
|
|
192
|
+
default: void 0
|
|
193
|
+
},
|
|
194
|
+
shouldShow: {
|
|
195
|
+
type: Function,
|
|
196
|
+
default: null
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
setup(r, { slots: e, attrs: l }) {
|
|
200
|
+
const o = f(null);
|
|
201
|
+
return g(() => {
|
|
202
|
+
const { pluginKey: n, editor: t, options: a, appendTo: s, shouldShow: p } = r, u = o.value;
|
|
203
|
+
u && (u.style.visibility = "hidden", u.style.position = "absolute", u.remove(), t.registerPlugin(
|
|
204
|
+
w({
|
|
205
|
+
pluginKey: n,
|
|
206
|
+
editor: t,
|
|
207
|
+
element: u,
|
|
208
|
+
options: a,
|
|
209
|
+
appendTo: s,
|
|
210
|
+
shouldShow: p
|
|
211
|
+
})
|
|
212
|
+
));
|
|
213
|
+
}), y(() => {
|
|
214
|
+
const { pluginKey: n, editor: t } = r;
|
|
215
|
+
t.unregisterPlugin(n);
|
|
216
|
+
}), () => {
|
|
217
|
+
var n;
|
|
218
|
+
return v("div", { ref: o, ...l }, (n = e.default) == null ? void 0 : n.call(e));
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
export {
|
|
223
|
+
q as B,
|
|
224
|
+
Z as F,
|
|
225
|
+
H as _
|
|
226
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("vue"),T=require("@blockslides/extension-bubble-menu"),S=require("@blockslides/pm/state"),c=require("@blockslides/extension-bubble-menu-preset"),v=require("@blockslides/core"),E=require("@blockslides/extension-floating-menu"),F={key:0,style:{display:"none"}},b="bubbleMenuPreset",M=t.defineComponent({__name:"BubbleMenuPreset",props:{editor:{},updateDelay:{},resizeDelay:{},appendTo:{type:Function},shouldShow:{type:[Function,null]},getReferencedVirtualElement:{type:Function},options:{},items:{},className:{},injectStyles:{type:Boolean},textColors:{},highlightColors:{},fonts:{},fontSizes:{},alignments:{},onTextAction:{type:Function},onImageReplace:{type:Function}},setup(s){const e=s,u=t.ref(null);let i;const o=()=>{const n=e.editor;if(!n||n.isDestroyed)return;i&&(i(),i=void 0);const{element:a,cleanup:d}=c.buildMenuElement(n,{items:e.items??c.DEFAULT_ITEMS,className:e.className??"",injectStyles:e.injectStyles!==!1,textColors:e.textColors??c.DEFAULT_COLOR_PALETTE,highlightColors:e.highlightColors??c.DEFAULT_HIGHLIGHT_PALETTE,fonts:e.fonts??c.DEFAULT_FONTS,fontSizes:e.fontSizes??c.DEFAULT_FONT_SIZES,alignments:e.alignments??c.DEFAULT_ALIGNMENTS,onTextAction:e.onTextAction,onImageReplace:e.onImageReplace});u.value=a,i=d;const p=({state:f,editor:g})=>{var y,h;const l=f.selection,m=l instanceof S.NodeSelection&&["image","imageBlock"].includes((h=(y=l.node)==null?void 0:y.type)==null?void 0:h.name)||g.isActive("image")||g.isActive("imageBlock");return!!(m||v.isTextSelection(l)&&!l.empty&&!m)},r=T.BubbleMenuPlugin({editor:n,element:a,updateDelay:e.updateDelay,resizeDelay:e.resizeDelay,appendTo:e.appendTo,pluginKey:b,shouldShow:e.shouldShow??p,getReferencedVirtualElement:e.getReferencedVirtualElement,options:e.options});n.registerPlugin(r)};return t.onMounted(()=>{o()}),t.watch(()=>[e.editor,e.updateDelay,e.resizeDelay,e.appendTo,e.shouldShow,e.getReferencedVirtualElement,e.options,e.items,e.className,e.injectStyles,e.textColors,e.highlightColors,e.fonts,e.fontSizes,e.alignments,e.onTextAction,e.onImageReplace],()=>{o()}),t.onBeforeUnmount(()=>{var n;e.editor&&e.editor.unregisterPlugin(b),i&&i(),(n=u.value)!=null&&n.parentNode&&u.value.parentNode.removeChild(u.value)}),(n,a)=>u.value?(t.openBlock(),t.createElementBlock("div",F)):t.createCommentVNode("",!0)}}),D=t.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(s,{slots:e,attrs:u}){const i=t.ref(null);return t.onMounted(()=>{const{editor:o,options:n,pluginKey:a,resizeDelay:d,appendTo:p,shouldShow:r,getReferencedVirtualElement:f,updateDelay:g}=s,l=i.value;l&&(l.style.visibility="hidden",l.style.position="absolute",l.remove(),t.nextTick(()=>{o.registerPlugin(T.BubbleMenuPlugin({editor:o,element:l,options:n,pluginKey:a,resizeDelay:d,appendTo:p,shouldShow:r,getReferencedVirtualElement:f,updateDelay:g}))}))}),t.onBeforeUnmount(()=>{const{pluginKey:o,editor:n}=s;n.unregisterPlugin(o)}),()=>{var o;return t.h("div",{ref:i,...u},(o=e.default)==null?void 0:o.call(e))}}}),_=t.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(s,{slots:e,attrs:u}){const i=t.ref(null);return t.onMounted(()=>{const{pluginKey:o,editor:n,options:a,appendTo:d,shouldShow:p}=s,r=i.value;r&&(r.style.visibility="hidden",r.style.position="absolute",r.remove(),n.registerPlugin(E.FloatingMenuPlugin({pluginKey:o,editor:n,element:r,options:a,appendTo:d,shouldShow:p})))}),t.onBeforeUnmount(()=>{const{pluginKey:o,editor:n}=s;n.unregisterPlugin(o)}),()=>{var o;return t.h("div",{ref:i,...u},(o=e.default)==null?void 0:o.call(e))}}});exports.BubbleMenu=D;exports.FloatingMenu=_;exports._sfc_main=M;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const NodeViewContent: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
2
|
+
as: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
7
|
+
as: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
}>> & Readonly<{}>, {
|
|
12
|
+
as: string;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const NodeViewWrapper: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
2
|
+
as: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
7
|
+
as: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
}>> & Readonly<{}>, {
|
|
12
|
+
as: string;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MarkViewProps, MarkViewRenderer, MarkViewRendererOptions, MarkView } from '../../core/src';
|
|
2
|
+
import { Component, PropType } from 'vue';
|
|
3
|
+
import { VueRenderer } from './VueRenderer.js';
|
|
4
|
+
|
|
5
|
+
export interface VueMarkViewRendererOptions extends MarkViewRendererOptions {
|
|
6
|
+
as?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
attrs?: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare const markViewProps: {
|
|
13
|
+
editor: {
|
|
14
|
+
type: PropType<MarkViewProps["editor"]>;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
mark: {
|
|
18
|
+
type: PropType<MarkViewProps["mark"]>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
extension: {
|
|
22
|
+
type: PropType<MarkViewProps["extension"]>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
inline: {
|
|
26
|
+
type: PropType<MarkViewProps["inline"]>;
|
|
27
|
+
required: true;
|
|
28
|
+
};
|
|
29
|
+
view: {
|
|
30
|
+
type: PropType<MarkViewProps["view"]>;
|
|
31
|
+
required: true;
|
|
32
|
+
};
|
|
33
|
+
updateAttributes: {
|
|
34
|
+
type: PropType<MarkViewProps["updateAttributes"]>;
|
|
35
|
+
required: true;
|
|
36
|
+
};
|
|
37
|
+
HTMLAttributes: {
|
|
38
|
+
type: PropType<MarkViewProps["HTMLAttributes"]>;
|
|
39
|
+
required: true;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export declare const MarkViewContent: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
43
|
+
as: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
48
|
+
as: {
|
|
49
|
+
type: StringConstructor;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
}>> & Readonly<{}>, {
|
|
53
|
+
as: string;
|
|
54
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
55
|
+
export declare class VueMarkView extends MarkView<Component, VueMarkViewRendererOptions> {
|
|
56
|
+
renderer: VueRenderer;
|
|
57
|
+
constructor(component: Component, props: MarkViewProps, options?: Partial<VueMarkViewRendererOptions>);
|
|
58
|
+
get dom(): HTMLElement;
|
|
59
|
+
get contentDOM(): HTMLElement | null;
|
|
60
|
+
updateAttributes(attrs: Record<string, any>): void;
|
|
61
|
+
destroy(): void;
|
|
62
|
+
}
|
|
63
|
+
export declare function VueMarkViewRenderer(component: Component, options?: Partial<VueMarkViewRendererOptions>): MarkViewRenderer;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NodeViewProps, NodeViewRenderer, NodeViewRendererOptions } from '../../core/src';
|
|
2
|
+
import { Node as ProseMirrorNode } from '../../pm/model/src';
|
|
3
|
+
import { Decoration, DecorationSource } from '../../pm/view/src';
|
|
4
|
+
import { Component, PropType } from 'vue';
|
|
5
|
+
|
|
6
|
+
export declare const nodeViewProps: {
|
|
7
|
+
editor: {
|
|
8
|
+
type: PropType<NodeViewProps["editor"]>;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
node: {
|
|
12
|
+
type: PropType<NodeViewProps["node"]>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
decorations: {
|
|
16
|
+
type: PropType<NodeViewProps["decorations"]>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
selected: {
|
|
20
|
+
type: PropType<NodeViewProps["selected"]>;
|
|
21
|
+
required: true;
|
|
22
|
+
};
|
|
23
|
+
extension: {
|
|
24
|
+
type: PropType<NodeViewProps["extension"]>;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
getPos: {
|
|
28
|
+
type: PropType<NodeViewProps["getPos"]>;
|
|
29
|
+
required: true;
|
|
30
|
+
};
|
|
31
|
+
updateAttributes: {
|
|
32
|
+
type: PropType<NodeViewProps["updateAttributes"]>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
deleteNode: {
|
|
36
|
+
type: PropType<NodeViewProps["deleteNode"]>;
|
|
37
|
+
required: true;
|
|
38
|
+
};
|
|
39
|
+
view: {
|
|
40
|
+
type: PropType<NodeViewProps["view"]>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
innerDecorations: {
|
|
44
|
+
type: PropType<NodeViewProps["innerDecorations"]>;
|
|
45
|
+
required: true;
|
|
46
|
+
};
|
|
47
|
+
HTMLAttributes: {
|
|
48
|
+
type: PropType<NodeViewProps["HTMLAttributes"]>;
|
|
49
|
+
required: true;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export interface VueNodeViewRendererOptions extends NodeViewRendererOptions {
|
|
53
|
+
update: ((props: {
|
|
54
|
+
oldNode: ProseMirrorNode;
|
|
55
|
+
oldDecorations: readonly Decoration[];
|
|
56
|
+
oldInnerDecorations: DecorationSource;
|
|
57
|
+
newNode: ProseMirrorNode;
|
|
58
|
+
newDecorations: readonly Decoration[];
|
|
59
|
+
innerDecorations: DecorationSource;
|
|
60
|
+
updateProps: () => void;
|
|
61
|
+
}) => boolean) | null;
|
|
62
|
+
}
|
|
63
|
+
export declare function VueNodeViewRenderer(component: Component<NodeViewProps>, options?: Partial<VueNodeViewRendererOptions>): NodeViewRenderer;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Editor } from '../../core/src';
|
|
2
|
+
import { Component, h } from 'vue';
|
|
3
|
+
import { Editor as ExtendedEditor } from './Editor.js';
|
|
4
|
+
|
|
5
|
+
export interface VueRendererOptions {
|
|
6
|
+
editor: Editor;
|
|
7
|
+
props?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
type ExtendedVNode = ReturnType<typeof h> | null;
|
|
10
|
+
interface RenderedComponent {
|
|
11
|
+
vNode: ExtendedVNode;
|
|
12
|
+
destroy: () => void;
|
|
13
|
+
el: Element | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* This class is used to render Vue components inside the editor.
|
|
17
|
+
*/
|
|
18
|
+
export declare class VueRenderer {
|
|
19
|
+
renderedComponent: RenderedComponent;
|
|
20
|
+
editor: ExtendedEditor;
|
|
21
|
+
component: Component;
|
|
22
|
+
el: Element | null;
|
|
23
|
+
props: Record<string, any>;
|
|
24
|
+
/**
|
|
25
|
+
* Flag to track if the renderer has been destroyed, preventing queued or asynchronous renders from executing after teardown.
|
|
26
|
+
*/
|
|
27
|
+
destroyed: boolean;
|
|
28
|
+
constructor(component: Component, { props, editor }: VueRendererOptions);
|
|
29
|
+
get element(): Element | null;
|
|
30
|
+
get ref(): any;
|
|
31
|
+
renderComponent(): RenderedComponent;
|
|
32
|
+
updateProps(props?: Record<string, any>): void;
|
|
33
|
+
destroy(): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@blockslides/core"),o=require("vue"),j=require("@blockslides/ai-context"),O=require("@blockslides/extension-kit"),f=require("./FloatingMenu-By8Qi7tW.cjs");function x(r){return o.customRef((e,t)=>({get(){return e(),r},set(n){r=n,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}class _ extends g.Editor{constructor(e={}){return super(e),this.contentComponent=null,this.appContext=null,this.reactiveState=x(this.view.state),this.reactiveExtensionStorage=x(this.extensionStorage),this.on("beforeTransaction",({nextState:t})=>{this.reactiveState.value=t,this.reactiveExtensionStorage.value=this.extensionStorage}),o.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){const n=super.registerPlugin(e,t);return this.reactiveState&&(this.reactiveState.value=n),n}unregisterPlugin(e){const t=super.unregisterPlugin(e);return this.reactiveState&&t&&(this.reactiveState.value=t),t}}const P=o.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(r){const e=o.ref(),t=o.getCurrentInstance();return o.watchEffect(()=>{const n=r.editor;n&&n.options.element&&e.value&&o.nextTick(()=>{var s;if(!e.value||!((s=n.view.dom)!=null&&s.parentNode))return;const i=o.unref(e.value);e.value.append(...n.view.dom.parentNode.childNodes),n.contentComponent=t.ctx._,t&&(n.appContext={...t.appContext,provides:t.provides}),n.setOptions({element:i}),n.createNodeViews()})}),o.onBeforeUnmount(()=>{const n=r.editor;n&&(n.contentComponent=null,n.appContext=null)}),{rootEl:e}},render(){return o.h("div",{ref:r=>{this.rootEl=r}})}}),V=o.defineComponent({name:"NodeViewContent",props:{as:{type:String,default:"div"}},render(){return o.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}}),B=o.defineComponent({name:"NodeViewWrapper",props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var r,e;return o.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(r=this.$slots).default)==null?void 0:e.call(r))}}),M=(r={})=>{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);const e=o.shallowRef();return o.onMounted(()=>{var t;console.log("[useEditor] onMounted - Creating Editor instance"),console.log("[useEditor] onMounted - options:",r),console.log("[useEditor] onMounted - options.enableCoreExtensions:",r.enableCoreExtensions),e.value=new _(r),console.log("[useEditor] Editor instance created:",e.value),console.log("[useEditor] Editor view:",(t=e.value)==null?void 0:t.view)}),o.onBeforeUnmount(()=>{var i,s,d,a;console.log("[useEditor] onBeforeUnmount - Cleaning up editor");const t=(s=(i=e.value)==null?void 0:i.view.dom)==null?void 0:s.parentNode,n=t==null?void 0:t.cloneNode(!0);(d=t==null?void 0:t.parentNode)==null||d.replaceChild(n,t),(a=e.value)==null||a.destroy()}),e},q=()=>({type:"doc",content:[{type:"slide",attrs:{size:"16x9",className:"",id:"slide-1",backgroundMode:"none",backgroundColor:null,backgroundImage:null,backgroundOverlayColor:null,backgroundOverlayOpacity:null},content:[{type:"column",attrs:{align:"center",padding:"lg",margin:null,gap:"md",backgroundColor:"#ffffff",backgroundImage:null,borderRadius:null,border:null,fill:!0,width:null,height:null,justify:"center"},content:[{type:"heading",attrs:{align:null,padding:null,margin:null,gap:null,backgroundColor:null,backgroundImage:null,borderRadius:null,border:null,fill:null,width:null,height:null,justify:null,id:"1fc4664c-333d-4203-a3f1-3ad27a54c535","data-toc-id":"1fc4664c-333d-4203-a3f1-3ad27a54c535",level:1},content:[{type:"text",text:"Lorem ipsum dolor sit amet"}]},{type:"paragraph",attrs:{align:null,padding:null,margin:null,gap:null,backgroundColor:null,backgroundImage:null,borderRadius:null,border:null,fill:null,width:null,height:null,justify:null},content:[{type:"text",text:"Consectetur adipiscing elit. Sed do eiusmod tempor incididunt. "}]}]}]}]}),D=r=>({showPresets:!0,presets:r,presetBackground:"#0f172a",presetForeground:"#e5e7eb"}),R={renderMode:"dynamic",hoverOutline:{color:"#3b82f6",width:"1.5px",offset:"4px"},hoverOutlineCascade:!1},k=(r={})=>{console.log("[useSlideEditor] Called with props:",r);const{content:e,onChange:t,extensions:n,extensionKitOptions:i,presetTemplates:s,onEditorReady:d,theme:a="light",editorProps:u,onUpdate:c,...h}=r;console.log("[useSlideEditor] editorOptions:",h),console.log("[useSlideEditor] editorOptions.enableCoreExtensions:",h.enableCoreExtensions),console.log("[useSlideEditor] editorOptions.injectCSS:",h.injectCSS),console.log("[useSlideEditor] Content:",e),console.log("[useSlideEditor] ExtensionKitOptions:",i);const S=o.computed(()=>s??j.templatesV1.listPresetTemplates()),y=o.computed(()=>{const l=(i==null?void 0:i.addSlideButton)===!1?!1:{...D(S.value),...(i==null?void 0:i.addSlideButton)??{}},p=(i==null?void 0:i.slide)===!1?!1:{...R,...(i==null?void 0:i.slide)??{}},b={...i,addSlideButton:l,slide:p};return console.log("[useSlideEditor] mergedExtensionKitOptions:",b),console.log("[useSlideEditor] addSlideButton config:",b.addSlideButton),console.log("[useSlideEditor] presets:",S.value),b}),v=o.computed(()=>{console.log("[useSlideEditor] Configuring ExtensionKit with options:",y.value);const l=O.ExtensionKit.configure(y.value);console.log("[useSlideEditor] ExtensionKit configured:",l),console.log("[useSlideEditor] ExtensionKit name:",l.name);const p=n?[l,...n]:[l];return console.log("[useSlideEditor] Final extensions array:",p),p}),w=e??q();console.log("[useSlideEditor] Initial content resolved:",w),console.log("[useSlideEditor] Resolved extensions:",v.value);const m={content:w,extensions:v.value,theme:a,editorProps:{attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off",class:"min-h-full min-w-full",...(u==null?void 0:u.attributes)??{}},...u},...h,onUpdate:l=>{console.log("[useSlideEditor] onUpdate called");const p=l.editor.getJSON();t==null||t(p,l.editor),c==null||c(l)}};console.log("[useSlideEditor] Final editor config:",m),console.log("[useSlideEditor] Final editor config enableCoreExtensions:",m.enableCoreExtensions),console.log("[useSlideEditor] Final editor config injectCSS:",m.injectCSS);const E=M(m);return console.log("[useSlideEditor] Editor ref created:",E),o.watch(E,l=>{console.log("[useSlideEditor] Editor watch triggered, newEditor:",l),l&&!l.isDestroyed?(console.log("[useSlideEditor] ✅ Calling onEditorReady"),d==null||d(l)):console.log("[useSlideEditor] ❌ Editor not ready or destroyed")},{immediate:!0}),{editor:E,presets:S}},A={class:"bs-viewport"},F=o.defineComponent({__name:"SlideEditor",props:{bubbleMenuPreset:{type:[Boolean,Object],default:!0},className:{},style:{},content:{},onChange:{},extensions:{},extensionKitOptions:{},presetTemplates:{},onEditorReady:{},element:{},theme:{},injectCSS:{type:Boolean},injectNonce:{},autofocus:{type:[String,Number,Boolean,null]},editable:{type:Boolean},editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:{type:[Array,Boolean]},enablePasteRules:{type:[Array,Boolean]},enableCoreExtensions:{type:[Boolean,Object]},enableContentCheck:{type:Boolean},emitContentError:{type:Boolean},onBeforeCreate:{},onCreate:{},onMount:{},onUnmount:{},onContentError:{},onUpdate:{},onSelectionUpdate:{},onTransaction:{},onFocus:{},onBlur:{},onDestroy:{},onPaste:{},onDrop:{},onDelete:{}},setup(r){console.log("[SlideEditor.vue] Component loading");const e=r;console.log("[SlideEditor.vue] Props:",e),console.log("[SlideEditor.vue] Props.enableCoreExtensions:",e.enableCoreExtensions),console.log("[SlideEditor.vue] Props.injectCSS:",e.injectCSS);const{bubbleMenuPreset:t,className:n,style:i,...s}=e;console.log("[SlideEditor.vue] Hook props:",s),console.log("[SlideEditor.vue] hookProps.enableCoreExtensions:",s.enableCoreExtensions),console.log("[SlideEditor.vue] hookProps.injectCSS:",s.injectCSS);const{editor:d,presets:a}=k(s);console.log("[SlideEditor.vue] Editor from useSlideEditor:",d);const u=o.computed(()=>e.bubbleMenuPreset===!1?null:e.bubbleMenuPreset===!0?{}:e.bubbleMenuPreset);return o.watch(d,c=>{console.log("[SlideEditor.vue] Editor watch - newEditor:",c),console.log("[SlideEditor.vue] Editor exists:",!!c)},{immediate:!0}),o.onMounted(()=>{console.log("[SlideEditor.vue] Component mounted"),console.log("[SlideEditor.vue] Editor value:",d.value)}),(c,h)=>o.unref(d)?(o.openBlock(),o.createElementBlock("div",{key:0,class:o.normalizeClass(o.unref(n)),style:o.normalizeStyle(o.unref(i))},[o.createElementVNode("div",A,[o.createVNode(o.unref(P),{editor:o.unref(d)},null,8,["editor"]),u.value?(o.openBlock(),o.createBlock(f._sfc_main,o.mergeProps({key:0,editor:o.unref(d)},u.value),null,16,["editor"])):o.createCommentVNode("",!0)])],6)):o.createCommentVNode("",!0)}});class C{constructor(e,{props:t={},editor:n}){this.destroyed=!1,this.editor=n,this.component=o.markRaw(e),this.el=document.createElement("div"),this.props=o.reactive(t),this.renderedComponent=this.renderComponent()}get element(){return this.renderedComponent.el}get ref(){var e,t,n,i;return(t=(e=this.renderedComponent.vNode)==null?void 0:e.component)!=null&&t.exposed?this.renderedComponent.vNode.component.exposed:(i=(n=this.renderedComponent.vNode)==null?void 0:n.component)==null?void 0:i.proxy}renderComponent(){if(this.destroyed)return this.renderedComponent;let e=o.h(this.component,this.props);return this.editor.appContext&&(e.appContext=this.editor.appContext),typeof document<"u"&&this.el&&o.render(e,this.el),{vNode:e,destroy:()=>{this.el&&o.render(null,this.el),this.el=null,e=null},el:this.el?this.el.firstElementChild:null}}updateProps(e={}){this.destroyed||(Object.entries(e).forEach(([t,n])=>{this.props[t]=n}),this.renderComponent())}destroy(){this.destroyed||(this.destroyed=!0,this.renderedComponent.destroy())}}const U={editor:{type:Object,required:!0},mark:{type:Object,required:!0},extension:{type:Object,required:!0},inline:{type:Boolean,required:!0},view:{type:Object,required:!0},updateAttributes:{type:Function,required:!0},HTMLAttributes:{type:Object,required:!0}},I=o.defineComponent({name:"MarkViewContent",props:{as:{type:String,default:"span"}},render(){return o.h(this.as,{style:{whiteSpace:"inherit"},"data-mark-view-content":""})}});class N extends g.MarkView{constructor(e,t,n){super(e,t,n);const i={...t,updateAttributes:this.updateAttributes.bind(this)},s=o.defineComponent({extends:{...e},props:Object.keys(i),template:this.component.template,setup:d=>{var a;return(a=e.setup)==null?void 0:a.call(e,d,{expose:()=>{}})},__scopeId:e.__scopeId,__cssModules:e.__cssModules,__name:e.__name,__file:e.__file});this.renderer=new C(s,{editor:this.editor,props:i})}get dom(){return this.renderer.element}get contentDOM(){return this.dom.querySelector("[data-mark-view-content]")}updateAttributes(e){const t=o.toRaw(this.mark);super.updateAttributes(e,t)}destroy(){this.renderer.destroy()}}function T(r,e={}){return t=>t.editor.contentComponent?new N(r,t,e):{}}const W={editor:{type:Object,required:!0},node:{type:Object,required:!0},decorations:{type:Object,required:!0},selected:{type:Boolean,required:!0},extension:{type:Object,required:!0},getPos:{type:Function,required:!0},updateAttributes:{type:Function,required:!0},deleteNode:{type:Function,required:!0},view:{type:Object,required:!0},innerDecorations:{type:Object,required:!0},HTMLAttributes:{type:Object,required:!0}};class L extends g.NodeView{constructor(){super(...arguments),this.cachedExtensionWithSyncedStorage=null}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,i,s){return i==="storage"?e.storage[t.name]??{}:Reflect.get(n,i,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(i={})=>this.updateAttributes(i),deleteNode:()=>this.deleteNode()},t=this.onDragStart.bind(this);this.decorationClasses=o.ref(this.getDecorationClasses());const n=o.defineComponent({extends:{...this.component},props:Object.keys(e),template:this.component.template,setup:i=>{var s,d;return o.provide("onDragStart",t),o.provide("decorationClasses",this.decorationClasses),(d=(s=this.component).setup)==null?void 0:d.call(s,i,{expose:()=>{}})},__scopeId:this.component.__scopeId,__cssModules:this.component.__cssModules,__name:this.component.__name,__file:this.component.__file});this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.renderer=new C(n,{editor:this.editor,props:e})}get dom(){if(!this.renderer.element||!this.renderer.element.hasAttribute("data-node-view-wrapper"))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.dom.querySelector("[data-node-view-content]")}handleSelectionUpdate(){const{from:e,to:t}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t,n){const i=s=>{this.decorationClasses.value=this.getDecorationClasses(),this.renderer.updateProps(s)};if(typeof this.options.update=="function"){const s=this.node,d=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:d,newNode:e,newDecorations:t,oldInnerDecorations:a,innerDecorations:n,updateProps:()=>i({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}return e.type!==this.node.type?!1:(e===this.node&&this.decorations===t&&this.innerDecorations===n||(this.node=e,this.decorations=t,this.innerDecorations=n,i({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})),!0)}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element&&this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element&&this.renderer.element.classList.remove("ProseMirror-selectednode")}getDecorationClasses(){return this.decorations.flatMap(e=>e.type.attrs.class).join(" ")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate)}}function z(r,e){return t=>{if(!t.editor.contentComponent)return{};const n=typeof r=="function"&&"__vccOpts"in r?r.__vccOpts:r;return new L(n,t,e)}}exports.BubbleMenu=f.BubbleMenu;exports.BubbleMenuPreset=f._sfc_main;exports.FloatingMenu=f.FloatingMenu;exports.Editor=_;exports.EditorContent=P;exports.MarkViewContent=I;exports.NodeViewContent=V;exports.NodeViewWrapper=B;exports.SlideEditor=F;exports.VueMarkView=N;exports.VueMarkViewRenderer=T;exports.VueNodeViewRenderer=z;exports.VueRenderer=C;exports.markViewProps=U;exports.nodeViewProps=W;exports.useEditor=M;exports.useSlideEditor=k;Object.keys(g).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>g[r]})});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Editor } from './Editor.js';
|
|
2
|
+
export * from './EditorContent.js';
|
|
3
|
+
export * from './NodeViewContent.js';
|
|
4
|
+
export * from './NodeViewWrapper.js';
|
|
5
|
+
export * from './useEditor.js';
|
|
6
|
+
export * from './useSlideEditor.js';
|
|
7
|
+
export { default as SlideEditor } from './SlideEditor.vue';
|
|
8
|
+
export * from './VueMarkViewRenderer.js';
|
|
9
|
+
export * from './VueNodeViewRenderer.js';
|
|
10
|
+
export * from './VueRenderer.js';
|
|
11
|
+
export * from '../../core/src';
|
|
12
|
+
export * from './menus/index.js';
|