miyuan-editor 0.0.3
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 +525 -0
- package/dist/core/index.cjs.js +40 -0
- package/dist/core/index.esm.js +4 -0
- package/dist/dist-5Q_Z9Ell.js +6390 -0
- package/dist/dist-5Q_Z9Ell.js.map +1 -0
- package/dist/dist-CMM6n8DO.cjs +4629 -0
- package/dist/dist-CMM6n8DO.cjs.map +1 -0
- package/dist/dist-CRSJDo2G.cjs +6617 -0
- package/dist/dist-CRSJDo2G.cjs.map +1 -0
- package/dist/dist-CZw77IJK.js +4612 -0
- package/dist/dist-CZw77IJK.js.map +1 -0
- package/dist/dist-CnVrDtsI.js +556 -0
- package/dist/dist-CnVrDtsI.js.map +1 -0
- package/dist/dist-rItBfhNb.cjs +591 -0
- package/dist/dist-rItBfhNb.cjs.map +1 -0
- package/dist/export-utils-CYaNoyVg.cjs +167 -0
- package/dist/export-utils-CYaNoyVg.cjs.map +1 -0
- package/dist/export-utils-DN0Gu8Vu.js +144 -0
- package/dist/export-utils-DN0Gu8Vu.js.map +1 -0
- package/dist/extension-BPFuYyzN.cjs +338 -0
- package/dist/extension-BPFuYyzN.cjs.map +1 -0
- package/dist/extension-Cl6x5MDR.js +321 -0
- package/dist/extension-Cl6x5MDR.js.map +1 -0
- package/dist/extensions/index.cjs.js +3462 -0
- package/dist/extensions/index.cjs.js.map +1 -0
- package/dist/extensions/index.esm.js +3412 -0
- package/dist/extensions/index.esm.js.map +1 -0
- package/dist/prompt-B4AOP8f_.js +24143 -0
- package/dist/prompt-B4AOP8f_.js.map +1 -0
- package/dist/prompt-CGLw2O21.cjs +25530 -0
- package/dist/prompt-CGLw2O21.cjs.map +1 -0
- package/dist/react/index.cjs.js +839 -0
- package/dist/react/index.cjs.js.map +1 -0
- package/dist/react/index.esm.js +820 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/shortcut-panel-BskGXV8n.js +49468 -0
- package/dist/shortcut-panel-BskGXV8n.js.map +1 -0
- package/dist/shortcut-panel-yP4RPTFt.cjs +49563 -0
- package/dist/shortcut-panel-yP4RPTFt.cjs.map +1 -0
- package/dist/toc-extension-BESc0uEW.js +150 -0
- package/dist/toc-extension-BESc0uEW.js.map +1 -0
- package/dist/toc-extension-SRvSuskn.cjs +173 -0
- package/dist/toc-extension-SRvSuskn.cjs.map +1 -0
- package/dist/toolbar-config-Cgc9mV2v.js +243 -0
- package/dist/toolbar-config-Cgc9mV2v.js.map +1 -0
- package/dist/toolbar-config-Cjt_fPMi.cjs +260 -0
- package/dist/toolbar-config-Cjt_fPMi.cjs.map +1 -0
- package/dist/ui/index.cjs.js +18 -0
- package/dist/ui/index.esm.js +3 -0
- package/dist/vue/index.cjs.js +323 -0
- package/dist/vue/index.cjs.js.map +1 -0
- package/dist/vue/index.esm.js +307 -0
- package/dist/vue/index.esm.js.map +1 -0
- package/dist/vue2/index.cjs.js +323 -0
- package/dist/vue2/index.cjs.js.map +1 -0
- package/dist/vue2/index.esm.js +307 -0
- package/dist/vue2/index.esm.js.map +1 -0
- package/package.json +116 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { A as DOMParser, d as EditorState } from "../dist-5Q_Z9Ell.js";
|
|
2
|
+
import { r as EditorView, t as ExtensionManager } from "../extension-Cl6x5MDR.js";
|
|
3
|
+
import { a as AIMenu$1, d as BubbleMenu$1, f as Toolbar$1, h as ensureStylesInjected, i as AIWriter$1, n as TocPanel$1, r as WordCountDisplay$1, t as ShortcutPanel$1, u as DragHandle$1 } from "../shortcut-panel-BskGXV8n.js";
|
|
4
|
+
import { i as exportAsPlainText, n as exportAsJSON, r as exportAsMarkdown, t as exportAsHTML } from "../export-utils-DN0Gu8Vu.js";
|
|
5
|
+
import { defineComponent, h, onBeforeUnmount, onMounted, ref, shallowRef, watch } from "vue";
|
|
6
|
+
//#region src/vue/use-editor.ts
|
|
7
|
+
function useEditor(options = {}) {
|
|
8
|
+
const { extensions = [], content, onUpdate, onSelectionChange } = options;
|
|
9
|
+
const manager = new ExtensionManager(extensions);
|
|
10
|
+
const schema = manager.schema;
|
|
11
|
+
let initialDoc;
|
|
12
|
+
if (content) try {
|
|
13
|
+
const container = document.createElement("div");
|
|
14
|
+
container.innerHTML = content;
|
|
15
|
+
initialDoc = DOMParser.fromSchema(schema).parse(container);
|
|
16
|
+
} catch {}
|
|
17
|
+
const initialState = EditorState.create({
|
|
18
|
+
schema,
|
|
19
|
+
doc: initialDoc,
|
|
20
|
+
plugins: manager.plugins
|
|
21
|
+
});
|
|
22
|
+
const viewRef = shallowRef(null);
|
|
23
|
+
const stateRef = shallowRef(initialState);
|
|
24
|
+
const version = shallowRef(0);
|
|
25
|
+
const forceUpdate = () => {
|
|
26
|
+
version.value++;
|
|
27
|
+
};
|
|
28
|
+
const dispatchTransaction = (tr) => {
|
|
29
|
+
const view = viewRef.value;
|
|
30
|
+
if (!view) return;
|
|
31
|
+
const newState = view.state.apply(tr);
|
|
32
|
+
view.updateState(newState);
|
|
33
|
+
stateRef.value = newState;
|
|
34
|
+
if (onUpdate) onUpdate(newState);
|
|
35
|
+
if (onSelectionChange) onSelectionChange(newState);
|
|
36
|
+
forceUpdate();
|
|
37
|
+
};
|
|
38
|
+
const createView = (element) => {
|
|
39
|
+
if (viewRef.value) return;
|
|
40
|
+
const editableVal = typeof options.editable === "object" ? options.editable.value : options.editable ?? true;
|
|
41
|
+
const view = new EditorView({
|
|
42
|
+
state: stateRef.value,
|
|
43
|
+
element,
|
|
44
|
+
editable: editableVal,
|
|
45
|
+
dispatchTransaction
|
|
46
|
+
});
|
|
47
|
+
viewRef.value = view;
|
|
48
|
+
stateRef.value = view.state;
|
|
49
|
+
forceUpdate();
|
|
50
|
+
};
|
|
51
|
+
onBeforeUnmount(() => {
|
|
52
|
+
if (viewRef.value) {
|
|
53
|
+
viewRef.value.destroy();
|
|
54
|
+
viewRef.value = null;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (typeof options.editable === "object") watch(options.editable, () => {
|
|
58
|
+
forceUpdate();
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
view: viewRef,
|
|
62
|
+
state: stateRef,
|
|
63
|
+
schema,
|
|
64
|
+
commands: manager.commands,
|
|
65
|
+
forceUpdate,
|
|
66
|
+
_createView: createView
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/vue/components.ts
|
|
71
|
+
function createEditorAdapter(editor) {
|
|
72
|
+
return {
|
|
73
|
+
getView: () => editor.view.value,
|
|
74
|
+
getState: () => editor.state.value,
|
|
75
|
+
getSchema: () => editor.schema,
|
|
76
|
+
getCommands: () => editor.commands
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
var EditorContent = defineComponent({
|
|
80
|
+
name: "EditorContent",
|
|
81
|
+
props: { editor: {
|
|
82
|
+
type: Object,
|
|
83
|
+
required: true
|
|
84
|
+
} },
|
|
85
|
+
setup(props) {
|
|
86
|
+
onMounted(() => {
|
|
87
|
+
ensureStylesInjected();
|
|
88
|
+
});
|
|
89
|
+
return () => h("div", { ref: (el) => {
|
|
90
|
+
if (el && el instanceof HTMLElement) props.editor._createView(el);
|
|
91
|
+
} });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
var Toolbar = defineComponent({
|
|
95
|
+
name: "MiToolbar",
|
|
96
|
+
props: { editor: {
|
|
97
|
+
type: Object,
|
|
98
|
+
required: true
|
|
99
|
+
} },
|
|
100
|
+
setup(props) {
|
|
101
|
+
const containerRef = ref(null);
|
|
102
|
+
let comp = null;
|
|
103
|
+
onMounted(() => {
|
|
104
|
+
if (!containerRef.value) return;
|
|
105
|
+
comp = new Toolbar$1(createEditorAdapter(props.editor));
|
|
106
|
+
comp.mount(containerRef.value);
|
|
107
|
+
});
|
|
108
|
+
onBeforeUnmount(() => {
|
|
109
|
+
comp?.destroy();
|
|
110
|
+
});
|
|
111
|
+
return () => h("div", { ref: (el) => {
|
|
112
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
113
|
+
} });
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
var BubbleMenu = defineComponent({
|
|
117
|
+
name: "MiBubbleMenu",
|
|
118
|
+
props: { editor: {
|
|
119
|
+
type: Object,
|
|
120
|
+
required: true
|
|
121
|
+
} },
|
|
122
|
+
setup(props) {
|
|
123
|
+
const containerRef = ref(null);
|
|
124
|
+
let comp = null;
|
|
125
|
+
onMounted(() => {
|
|
126
|
+
if (!containerRef.value) return;
|
|
127
|
+
comp = new BubbleMenu$1(createEditorAdapter(props.editor));
|
|
128
|
+
comp.mount(containerRef.value);
|
|
129
|
+
});
|
|
130
|
+
onBeforeUnmount(() => {
|
|
131
|
+
comp?.destroy();
|
|
132
|
+
});
|
|
133
|
+
return () => h("div", { ref: (el) => {
|
|
134
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
135
|
+
} });
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
var DragHandle = defineComponent({
|
|
139
|
+
name: "MiDragHandle",
|
|
140
|
+
props: { editor: {
|
|
141
|
+
type: Object,
|
|
142
|
+
required: true
|
|
143
|
+
} },
|
|
144
|
+
setup(props) {
|
|
145
|
+
const containerRef = ref(null);
|
|
146
|
+
let comp = null;
|
|
147
|
+
onMounted(() => {
|
|
148
|
+
if (!containerRef.value) return;
|
|
149
|
+
comp = new DragHandle$1(createEditorAdapter(props.editor));
|
|
150
|
+
comp.mount(containerRef.value);
|
|
151
|
+
});
|
|
152
|
+
onBeforeUnmount(() => {
|
|
153
|
+
comp?.destroy();
|
|
154
|
+
});
|
|
155
|
+
return () => h("div", { ref: (el) => {
|
|
156
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
157
|
+
} });
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
var WordCountDisplay = defineComponent({
|
|
161
|
+
name: "MiWordCountDisplay",
|
|
162
|
+
props: {
|
|
163
|
+
editor: {
|
|
164
|
+
type: Object,
|
|
165
|
+
required: true
|
|
166
|
+
},
|
|
167
|
+
showDetails: {
|
|
168
|
+
type: Boolean,
|
|
169
|
+
default: false
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
setup(props) {
|
|
173
|
+
const containerRef = ref(null);
|
|
174
|
+
let comp = null;
|
|
175
|
+
onMounted(() => {
|
|
176
|
+
if (!containerRef.value) return;
|
|
177
|
+
comp = new WordCountDisplay$1(createEditorAdapter(props.editor), { showDetails: props.showDetails });
|
|
178
|
+
comp.mount(containerRef.value);
|
|
179
|
+
});
|
|
180
|
+
onBeforeUnmount(() => {
|
|
181
|
+
comp?.destroy();
|
|
182
|
+
});
|
|
183
|
+
return () => h("div", { ref: (el) => {
|
|
184
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
185
|
+
} });
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
var TocPanel = defineComponent({
|
|
189
|
+
name: "MiTocPanel",
|
|
190
|
+
props: {
|
|
191
|
+
editor: {
|
|
192
|
+
type: Object,
|
|
193
|
+
required: true
|
|
194
|
+
},
|
|
195
|
+
title: {
|
|
196
|
+
type: String,
|
|
197
|
+
default: void 0
|
|
198
|
+
},
|
|
199
|
+
onItemClick: {
|
|
200
|
+
type: Function,
|
|
201
|
+
default: void 0
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
setup(props) {
|
|
205
|
+
const containerRef = ref(null);
|
|
206
|
+
let comp = null;
|
|
207
|
+
onMounted(() => {
|
|
208
|
+
if (!containerRef.value) return;
|
|
209
|
+
comp = new TocPanel$1(createEditorAdapter(props.editor), {
|
|
210
|
+
title: props.title,
|
|
211
|
+
onItemClick: props.onItemClick
|
|
212
|
+
});
|
|
213
|
+
comp.mount(containerRef.value);
|
|
214
|
+
});
|
|
215
|
+
onBeforeUnmount(() => {
|
|
216
|
+
comp?.destroy();
|
|
217
|
+
});
|
|
218
|
+
return () => h("div", { ref: (el) => {
|
|
219
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
220
|
+
} });
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
var ShortcutPanel = defineComponent({
|
|
224
|
+
name: "MiShortcutPanel",
|
|
225
|
+
props: {
|
|
226
|
+
editor: {
|
|
227
|
+
type: Object,
|
|
228
|
+
required: true
|
|
229
|
+
},
|
|
230
|
+
shortcuts: {
|
|
231
|
+
type: Array,
|
|
232
|
+
default: void 0
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
setup(props, { expose }) {
|
|
236
|
+
const containerRef = ref(null);
|
|
237
|
+
let comp = null;
|
|
238
|
+
onMounted(() => {
|
|
239
|
+
if (!containerRef.value) return;
|
|
240
|
+
comp = new ShortcutPanel$1(createEditorAdapter(props.editor), { shortcuts: props.shortcuts });
|
|
241
|
+
comp.mount(containerRef.value);
|
|
242
|
+
});
|
|
243
|
+
onBeforeUnmount(() => {
|
|
244
|
+
comp?.destroy();
|
|
245
|
+
});
|
|
246
|
+
expose({
|
|
247
|
+
open: () => comp?.open(),
|
|
248
|
+
close: () => comp?.close()
|
|
249
|
+
});
|
|
250
|
+
return () => h("div", { ref: (el) => {
|
|
251
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
252
|
+
} });
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
var AIMenu = defineComponent({
|
|
256
|
+
name: "MiAIMenu",
|
|
257
|
+
props: { editor: {
|
|
258
|
+
type: Object,
|
|
259
|
+
required: true
|
|
260
|
+
} },
|
|
261
|
+
setup(props, { expose }) {
|
|
262
|
+
const containerRef = ref(null);
|
|
263
|
+
let comp = null;
|
|
264
|
+
onMounted(() => {
|
|
265
|
+
if (!containerRef.value) return;
|
|
266
|
+
comp = new AIMenu$1(createEditorAdapter(props.editor));
|
|
267
|
+
comp.mount(containerRef.value);
|
|
268
|
+
});
|
|
269
|
+
onBeforeUnmount(() => {
|
|
270
|
+
comp?.destroy();
|
|
271
|
+
});
|
|
272
|
+
expose({ open: () => comp?.open() });
|
|
273
|
+
return () => h("div", { ref: (el) => {
|
|
274
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
275
|
+
} });
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
var AIWriter = defineComponent({
|
|
279
|
+
name: "MiAIWriter",
|
|
280
|
+
props: { editor: {
|
|
281
|
+
type: Object,
|
|
282
|
+
required: true
|
|
283
|
+
} },
|
|
284
|
+
setup(props, { expose }) {
|
|
285
|
+
const containerRef = ref(null);
|
|
286
|
+
let comp = null;
|
|
287
|
+
onMounted(() => {
|
|
288
|
+
if (!containerRef.value) return;
|
|
289
|
+
comp = new AIWriter$1(createEditorAdapter(props.editor));
|
|
290
|
+
comp.mount(containerRef.value);
|
|
291
|
+
});
|
|
292
|
+
onBeforeUnmount(() => {
|
|
293
|
+
comp?.destroy();
|
|
294
|
+
});
|
|
295
|
+
expose({
|
|
296
|
+
open: () => comp?.open(),
|
|
297
|
+
openProductCard: () => comp?.openProductCard()
|
|
298
|
+
});
|
|
299
|
+
return () => h("div", { ref: (el) => {
|
|
300
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
301
|
+
} });
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
//#endregion
|
|
305
|
+
export { AIMenu, AIWriter, BubbleMenu, DragHandle, EditorContent, ShortcutPanel, TocPanel, Toolbar, WordCountDisplay, createEditorAdapter, exportAsHTML, exportAsJSON, exportAsMarkdown, exportAsPlainText, useEditor };
|
|
306
|
+
|
|
307
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","names":[],"sources":["../../src/vue/use-editor.ts","../../src/vue/components.ts"],"sourcesContent":["import { ref, shallowRef, onBeforeUnmount, watch, type Ref, type ShallowRef } from 'vue'\nimport { EditorState } from 'prosemirror-state'\nimport { DOMParser as PMDOMParser } from 'prosemirror-model'\nimport type { Schema } from 'prosemirror-model'\nimport type { Transaction } from 'prosemirror-state'\nimport type { Command } from 'prosemirror-state'\nimport { EditorView } from '../core/editor-view'\nimport { ExtensionManager } from '../core/extension'\nimport type { Extension } from '../core/extension'\n\nexport interface UseEditorOptions {\n extensions?: Extension[]\n content?: string\n editable?: boolean | Ref<boolean>\n onUpdate?: (state: EditorState) => void\n onSelectionChange?: (state: EditorState) => void\n}\n\nexport interface EditorHandle {\n view: ShallowRef<EditorView | null>\n state: ShallowRef<EditorState | null>\n schema: Schema\n commands: Record<string, (...args: unknown[]) => Command>\n forceUpdate: () => void\n _createView: (element: HTMLElement) => void\n}\n\nexport function useEditor(options: UseEditorOptions = {}): EditorHandle {\n const { extensions = [], content, onUpdate, onSelectionChange } = options\n\n const manager = new ExtensionManager(extensions)\n const schema = manager.schema\n\n let initialDoc\n if (content) {\n try {\n const container = document.createElement('div')\n container.innerHTML = content\n initialDoc = PMDOMParser.fromSchema(schema).parse(container)\n } catch {\n // fall through\n }\n }\n\n const initialState = EditorState.create({\n schema,\n doc: initialDoc,\n plugins: manager.plugins,\n })\n\n const viewRef = shallowRef<EditorView | null>(null)\n const stateRef = shallowRef<EditorState | null>(initialState)\n const version = shallowRef(0)\n\n const forceUpdate = () => {\n version.value++\n }\n\n const dispatchTransaction = (tr: Transaction) => {\n const view = viewRef.value\n if (!view) return\n\n const newState = view.state.apply(tr)\n view.updateState(newState)\n stateRef.value = newState\n\n if (onUpdate) onUpdate(newState)\n if (onSelectionChange) onSelectionChange(newState)\n\n forceUpdate()\n }\n\n const createView = (element: HTMLElement) => {\n if (viewRef.value) return\n\n const editableVal = typeof options.editable === 'object'\n ? (options.editable as Ref<boolean>).value\n : (options.editable ?? true)\n\n const view = new EditorView({\n state: stateRef.value!,\n element,\n editable: editableVal,\n dispatchTransaction,\n })\n\n viewRef.value = view\n stateRef.value = view.state\n forceUpdate()\n }\n\n onBeforeUnmount(() => {\n if (viewRef.value) {\n viewRef.value.destroy()\n viewRef.value = null\n }\n })\n\n if (typeof options.editable === 'object') {\n watch(options.editable as Ref<boolean>, () => {\n forceUpdate()\n })\n }\n\n return {\n view: viewRef,\n state: stateRef,\n schema,\n commands: manager.commands,\n forceUpdate,\n _createView: createView,\n }\n}\n","import { defineComponent, h, onMounted, onBeforeUnmount, ref, type PropType, type ShallowRef } from 'vue'\nimport type { EditorHandle } from './use-editor'\nimport type { EditorLike } from '../ui/types'\nimport { ensureStylesInjected } from '../ui/editor-styles'\nimport { Toolbar as ToolbarClass } from '../ui/toolbar'\nimport { BubbleMenu as BubbleMenuClass } from '../ui/bubble-menu'\nimport { DragHandle as DragHandleClass } from '../ui/drag-handle'\nimport { AIMenu as AIMenuClass } from '../ui/ai-menu'\nimport { AIWriter as AIWriterClass } from '../ui/ai-writer'\nimport { WordCountDisplay as WordCountClass } from '../ui/word-count'\nimport { TocPanel as TocPanelClass } from '../ui/toc-panel'\nimport { ShortcutPanel as ShortcutPanelClass } from '../ui/shortcut-panel'\nimport type { TocItem } from '../extensions/toc-extension'\nimport type { ShortcutItem } from '../ui/shortcut-panel'\n\nexport function createEditorAdapter(editor: EditorHandle): EditorLike {\n return {\n getView: () => editor.view.value,\n getState: () => editor.state.value,\n getSchema: () => editor.schema,\n getCommands: () => editor.commands,\n }\n}\n\nexport const EditorContent = defineComponent({\n name: 'EditorContent',\n props: {\n editor: { type: Object as PropType<EditorHandle>, required: true },\n },\n setup(props) {\n onMounted(() => { ensureStylesInjected() })\n return () => h('div', {\n ref: (el: unknown) => {\n if (el && el instanceof HTMLElement) props.editor._createView(el)\n },\n })\n },\n})\n\nexport const Toolbar = defineComponent({\n name: 'MiToolbar',\n props: { editor: { type: Object as PropType<EditorHandle>, required: true } },\n setup(props) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: ToolbarClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new ToolbarClass(createEditorAdapter(props.editor))\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n\nexport const BubbleMenu = defineComponent({\n name: 'MiBubbleMenu',\n props: { editor: { type: Object as PropType<EditorHandle>, required: true } },\n setup(props) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: BubbleMenuClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new BubbleMenuClass(createEditorAdapter(props.editor))\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n\nexport const DragHandle = defineComponent({\n name: 'MiDragHandle',\n props: { editor: { type: Object as PropType<EditorHandle>, required: true } },\n setup(props) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: DragHandleClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new DragHandleClass(createEditorAdapter(props.editor))\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n\nexport const WordCountDisplay = defineComponent({\n name: 'MiWordCountDisplay',\n props: {\n editor: { type: Object as PropType<EditorHandle>, required: true },\n showDetails: { type: Boolean, default: false },\n },\n setup(props) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: WordCountClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new WordCountClass(createEditorAdapter(props.editor), { showDetails: props.showDetails })\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n\nexport const TocPanel = defineComponent({\n name: 'MiTocPanel',\n props: {\n editor: { type: Object as PropType<EditorHandle>, required: true },\n title: { type: String, default: undefined },\n onItemClick: { type: Function as PropType<(item: TocItem) => void>, default: undefined },\n },\n setup(props) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: TocPanelClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new TocPanelClass(createEditorAdapter(props.editor), { title: props.title, onItemClick: props.onItemClick })\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n\nexport const ShortcutPanel = defineComponent({\n name: 'MiShortcutPanel',\n props: {\n editor: { type: Object as PropType<EditorHandle>, required: true },\n shortcuts: { type: Array as PropType<ShortcutItem[]>, default: undefined },\n },\n setup(props, { expose }) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: ShortcutPanelClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new ShortcutPanelClass(createEditorAdapter(props.editor), { shortcuts: props.shortcuts })\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n expose({\n open: () => comp?.open(),\n close: () => comp?.close(),\n })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n\nexport const AIMenu = defineComponent({\n name: 'MiAIMenu',\n props: { editor: { type: Object as PropType<EditorHandle>, required: true } },\n setup(props, { expose }) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: AIMenuClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new AIMenuClass(createEditorAdapter(props.editor))\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n expose({ open: () => comp?.open() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n\nexport const AIWriter = defineComponent({\n name: 'MiAIWriter',\n props: { editor: { type: Object as PropType<EditorHandle>, required: true } },\n setup(props, { expose }) {\n const containerRef = ref<HTMLElement | null>(null)\n let comp: AIWriterClass | null = null\n onMounted(() => {\n if (!containerRef.value) return\n comp = new AIWriterClass(createEditorAdapter(props.editor))\n comp.mount(containerRef.value)\n })\n onBeforeUnmount(() => { comp?.destroy() })\n expose({\n open: () => comp?.open(),\n openProductCard: () => comp?.openProductCard(),\n })\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
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../prompt-CGLw2O21.cjs");
|
|
3
|
+
const require_dist = require("../dist-CRSJDo2G.cjs");
|
|
4
|
+
const require_extension = require("../extension-BPFuYyzN.cjs");
|
|
5
|
+
const require_shortcut_panel = require("../shortcut-panel-yP4RPTFt.cjs");
|
|
6
|
+
const require_export_utils = require("../export-utils-CYaNoyVg.cjs");
|
|
7
|
+
let vue = require("vue");
|
|
8
|
+
//#region src/vue2/use-editor.ts
|
|
9
|
+
function useEditor(options = {}) {
|
|
10
|
+
const { extensions = [], content, onUpdate, onSelectionChange } = options;
|
|
11
|
+
const manager = new require_extension.ExtensionManager(extensions);
|
|
12
|
+
const schema = manager.schema;
|
|
13
|
+
let initialDoc;
|
|
14
|
+
if (content) try {
|
|
15
|
+
const container = document.createElement("div");
|
|
16
|
+
container.innerHTML = content;
|
|
17
|
+
initialDoc = require_dist.DOMParser.fromSchema(schema).parse(container);
|
|
18
|
+
} catch {}
|
|
19
|
+
const initialState = require_dist.EditorState.create({
|
|
20
|
+
schema,
|
|
21
|
+
doc: initialDoc,
|
|
22
|
+
plugins: manager.plugins
|
|
23
|
+
});
|
|
24
|
+
const viewRef = (0, vue.shallowRef)(null);
|
|
25
|
+
const stateRef = (0, vue.shallowRef)(initialState);
|
|
26
|
+
const version = (0, vue.shallowRef)(0);
|
|
27
|
+
const forceUpdate = () => {
|
|
28
|
+
version.value++;
|
|
29
|
+
};
|
|
30
|
+
const dispatchTransaction = (tr) => {
|
|
31
|
+
const view = viewRef.value;
|
|
32
|
+
if (!view) return;
|
|
33
|
+
const newState = view.state.apply(tr);
|
|
34
|
+
view.updateState(newState);
|
|
35
|
+
stateRef.value = newState;
|
|
36
|
+
if (onUpdate) onUpdate(newState);
|
|
37
|
+
if (onSelectionChange) onSelectionChange(newState);
|
|
38
|
+
forceUpdate();
|
|
39
|
+
};
|
|
40
|
+
const createView = (element) => {
|
|
41
|
+
if (viewRef.value) return;
|
|
42
|
+
const editableVal = typeof options.editable === "object" ? options.editable.value : options.editable ?? true;
|
|
43
|
+
const view = new require_extension.EditorView({
|
|
44
|
+
state: stateRef.value,
|
|
45
|
+
element,
|
|
46
|
+
editable: editableVal,
|
|
47
|
+
dispatchTransaction
|
|
48
|
+
});
|
|
49
|
+
viewRef.value = view;
|
|
50
|
+
stateRef.value = view.state;
|
|
51
|
+
forceUpdate();
|
|
52
|
+
};
|
|
53
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
54
|
+
if (viewRef.value) {
|
|
55
|
+
viewRef.value.destroy();
|
|
56
|
+
viewRef.value = null;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (typeof options.editable === "object") (0, vue.watch)(options.editable, () => {
|
|
60
|
+
forceUpdate();
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
view: viewRef,
|
|
64
|
+
state: stateRef,
|
|
65
|
+
schema,
|
|
66
|
+
commands: manager.commands,
|
|
67
|
+
forceUpdate,
|
|
68
|
+
_createView: createView
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/vue2/components.ts
|
|
73
|
+
function createEditorAdapter(editor) {
|
|
74
|
+
return {
|
|
75
|
+
getView: () => editor.view.value ?? null,
|
|
76
|
+
getState: () => editor.state.value ?? null,
|
|
77
|
+
getSchema: () => editor.schema,
|
|
78
|
+
getCommands: () => editor.commands
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
var EditorContent = (0, vue.defineComponent)({
|
|
82
|
+
name: "EditorContent",
|
|
83
|
+
props: { editor: {
|
|
84
|
+
type: Object,
|
|
85
|
+
required: true
|
|
86
|
+
} },
|
|
87
|
+
setup(props) {
|
|
88
|
+
(0, vue.onMounted)(() => {
|
|
89
|
+
require_shortcut_panel.ensureStylesInjected();
|
|
90
|
+
});
|
|
91
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
92
|
+
if (el && el instanceof HTMLElement) props.editor._createView(el);
|
|
93
|
+
} });
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
var Toolbar = (0, vue.defineComponent)({
|
|
97
|
+
name: "MiToolbar",
|
|
98
|
+
props: { editor: {
|
|
99
|
+
type: Object,
|
|
100
|
+
required: true
|
|
101
|
+
} },
|
|
102
|
+
setup(props) {
|
|
103
|
+
const containerRef = (0, vue.ref)(null);
|
|
104
|
+
let comp = null;
|
|
105
|
+
(0, vue.onMounted)(() => {
|
|
106
|
+
if (!containerRef.value) return;
|
|
107
|
+
comp = new require_shortcut_panel.Toolbar(createEditorAdapter(props.editor));
|
|
108
|
+
comp.mount(containerRef.value);
|
|
109
|
+
});
|
|
110
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
111
|
+
comp?.destroy();
|
|
112
|
+
});
|
|
113
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
114
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
115
|
+
} });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
var BubbleMenu = (0, vue.defineComponent)({
|
|
119
|
+
name: "MiBubbleMenu",
|
|
120
|
+
props: { editor: {
|
|
121
|
+
type: Object,
|
|
122
|
+
required: true
|
|
123
|
+
} },
|
|
124
|
+
setup(props) {
|
|
125
|
+
const containerRef = (0, vue.ref)(null);
|
|
126
|
+
let comp = null;
|
|
127
|
+
(0, vue.onMounted)(() => {
|
|
128
|
+
if (!containerRef.value) return;
|
|
129
|
+
comp = new require_shortcut_panel.BubbleMenu(createEditorAdapter(props.editor));
|
|
130
|
+
comp.mount(containerRef.value);
|
|
131
|
+
});
|
|
132
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
133
|
+
comp?.destroy();
|
|
134
|
+
});
|
|
135
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
136
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
137
|
+
} });
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
var DragHandle = (0, vue.defineComponent)({
|
|
141
|
+
name: "MiDragHandle",
|
|
142
|
+
props: { editor: {
|
|
143
|
+
type: Object,
|
|
144
|
+
required: true
|
|
145
|
+
} },
|
|
146
|
+
setup(props) {
|
|
147
|
+
const containerRef = (0, vue.ref)(null);
|
|
148
|
+
let comp = null;
|
|
149
|
+
(0, vue.onMounted)(() => {
|
|
150
|
+
if (!containerRef.value) return;
|
|
151
|
+
comp = new require_shortcut_panel.DragHandle(createEditorAdapter(props.editor));
|
|
152
|
+
comp.mount(containerRef.value);
|
|
153
|
+
});
|
|
154
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
155
|
+
comp?.destroy();
|
|
156
|
+
});
|
|
157
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
158
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
159
|
+
} });
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
var WordCountDisplay = (0, vue.defineComponent)({
|
|
163
|
+
name: "MiWordCountDisplay",
|
|
164
|
+
props: {
|
|
165
|
+
editor: {
|
|
166
|
+
type: Object,
|
|
167
|
+
required: true
|
|
168
|
+
},
|
|
169
|
+
showDetails: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
default: false
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
setup(props) {
|
|
175
|
+
const containerRef = (0, vue.ref)(null);
|
|
176
|
+
let comp = null;
|
|
177
|
+
(0, vue.onMounted)(() => {
|
|
178
|
+
if (!containerRef.value) return;
|
|
179
|
+
comp = new require_shortcut_panel.WordCountDisplay(createEditorAdapter(props.editor), { showDetails: props.showDetails });
|
|
180
|
+
comp.mount(containerRef.value);
|
|
181
|
+
});
|
|
182
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
183
|
+
comp?.destroy();
|
|
184
|
+
});
|
|
185
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
186
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
187
|
+
} });
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
var TocPanel = (0, vue.defineComponent)({
|
|
191
|
+
name: "MiTocPanel",
|
|
192
|
+
props: {
|
|
193
|
+
editor: {
|
|
194
|
+
type: Object,
|
|
195
|
+
required: true
|
|
196
|
+
},
|
|
197
|
+
title: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: void 0
|
|
200
|
+
},
|
|
201
|
+
onItemClick: {
|
|
202
|
+
type: Function,
|
|
203
|
+
default: void 0
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
setup(props) {
|
|
207
|
+
const containerRef = (0, vue.ref)(null);
|
|
208
|
+
let comp = null;
|
|
209
|
+
(0, vue.onMounted)(() => {
|
|
210
|
+
if (!containerRef.value) return;
|
|
211
|
+
comp = new require_shortcut_panel.TocPanel(createEditorAdapter(props.editor), {
|
|
212
|
+
title: props.title,
|
|
213
|
+
onItemClick: props.onItemClick
|
|
214
|
+
});
|
|
215
|
+
comp.mount(containerRef.value);
|
|
216
|
+
});
|
|
217
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
218
|
+
comp?.destroy();
|
|
219
|
+
});
|
|
220
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
221
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
222
|
+
} });
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
var ShortcutPanel = (0, vue.defineComponent)({
|
|
226
|
+
name: "MiShortcutPanel",
|
|
227
|
+
props: {
|
|
228
|
+
editor: {
|
|
229
|
+
type: Object,
|
|
230
|
+
required: true
|
|
231
|
+
},
|
|
232
|
+
shortcuts: {
|
|
233
|
+
type: Array,
|
|
234
|
+
default: void 0
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
setup(props, { expose }) {
|
|
238
|
+
const containerRef = (0, vue.ref)(null);
|
|
239
|
+
let comp = null;
|
|
240
|
+
(0, vue.onMounted)(() => {
|
|
241
|
+
if (!containerRef.value) return;
|
|
242
|
+
comp = new require_shortcut_panel.ShortcutPanel(createEditorAdapter(props.editor), { shortcuts: props.shortcuts });
|
|
243
|
+
comp.mount(containerRef.value);
|
|
244
|
+
});
|
|
245
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
246
|
+
comp?.destroy();
|
|
247
|
+
});
|
|
248
|
+
expose({
|
|
249
|
+
open: () => comp?.open(),
|
|
250
|
+
close: () => comp?.close()
|
|
251
|
+
});
|
|
252
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
253
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
254
|
+
} });
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
var AIMenu = (0, vue.defineComponent)({
|
|
258
|
+
name: "MiAIMenu",
|
|
259
|
+
props: { editor: {
|
|
260
|
+
type: Object,
|
|
261
|
+
required: true
|
|
262
|
+
} },
|
|
263
|
+
setup(props, { expose }) {
|
|
264
|
+
const containerRef = (0, vue.ref)(null);
|
|
265
|
+
let comp = null;
|
|
266
|
+
(0, vue.onMounted)(() => {
|
|
267
|
+
if (!containerRef.value) return;
|
|
268
|
+
comp = new require_shortcut_panel.AIMenu(createEditorAdapter(props.editor));
|
|
269
|
+
comp.mount(containerRef.value);
|
|
270
|
+
});
|
|
271
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
272
|
+
comp?.destroy();
|
|
273
|
+
});
|
|
274
|
+
expose({ open: () => comp?.open() });
|
|
275
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
276
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
277
|
+
} });
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
var AIWriter = (0, vue.defineComponent)({
|
|
281
|
+
name: "MiAIWriter",
|
|
282
|
+
props: { editor: {
|
|
283
|
+
type: Object,
|
|
284
|
+
required: true
|
|
285
|
+
} },
|
|
286
|
+
setup(props, { expose }) {
|
|
287
|
+
const containerRef = (0, vue.ref)(null);
|
|
288
|
+
let comp = null;
|
|
289
|
+
(0, vue.onMounted)(() => {
|
|
290
|
+
if (!containerRef.value) return;
|
|
291
|
+
comp = new require_shortcut_panel.AIWriter(createEditorAdapter(props.editor));
|
|
292
|
+
comp.mount(containerRef.value);
|
|
293
|
+
});
|
|
294
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
295
|
+
comp?.destroy();
|
|
296
|
+
});
|
|
297
|
+
expose({
|
|
298
|
+
open: () => comp?.open(),
|
|
299
|
+
openProductCard: () => comp?.openProductCard()
|
|
300
|
+
});
|
|
301
|
+
return () => (0, vue.h)("div", { ref: (el) => {
|
|
302
|
+
if (el instanceof HTMLElement) containerRef.value = el;
|
|
303
|
+
} });
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
//#endregion
|
|
307
|
+
exports.AIMenu = AIMenu;
|
|
308
|
+
exports.AIWriter = AIWriter;
|
|
309
|
+
exports.BubbleMenu = BubbleMenu;
|
|
310
|
+
exports.DragHandle = DragHandle;
|
|
311
|
+
exports.EditorContent = EditorContent;
|
|
312
|
+
exports.ShortcutPanel = ShortcutPanel;
|
|
313
|
+
exports.TocPanel = TocPanel;
|
|
314
|
+
exports.Toolbar = Toolbar;
|
|
315
|
+
exports.WordCountDisplay = WordCountDisplay;
|
|
316
|
+
exports.createEditorAdapter = createEditorAdapter;
|
|
317
|
+
exports.exportAsHTML = require_export_utils.exportAsHTML;
|
|
318
|
+
exports.exportAsJSON = require_export_utils.exportAsJSON;
|
|
319
|
+
exports.exportAsMarkdown = require_export_utils.exportAsMarkdown;
|
|
320
|
+
exports.exportAsPlainText = require_export_utils.exportAsPlainText;
|
|
321
|
+
exports.useEditor = useEditor;
|
|
322
|
+
|
|
323
|
+
//# sourceMappingURL=index.cjs.js.map
|