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.
Files changed (58) hide show
  1. package/README.md +525 -0
  2. package/dist/core/index.cjs.js +40 -0
  3. package/dist/core/index.esm.js +4 -0
  4. package/dist/dist-5Q_Z9Ell.js +6390 -0
  5. package/dist/dist-5Q_Z9Ell.js.map +1 -0
  6. package/dist/dist-CMM6n8DO.cjs +4629 -0
  7. package/dist/dist-CMM6n8DO.cjs.map +1 -0
  8. package/dist/dist-CRSJDo2G.cjs +6617 -0
  9. package/dist/dist-CRSJDo2G.cjs.map +1 -0
  10. package/dist/dist-CZw77IJK.js +4612 -0
  11. package/dist/dist-CZw77IJK.js.map +1 -0
  12. package/dist/dist-CnVrDtsI.js +556 -0
  13. package/dist/dist-CnVrDtsI.js.map +1 -0
  14. package/dist/dist-rItBfhNb.cjs +591 -0
  15. package/dist/dist-rItBfhNb.cjs.map +1 -0
  16. package/dist/export-utils-CYaNoyVg.cjs +167 -0
  17. package/dist/export-utils-CYaNoyVg.cjs.map +1 -0
  18. package/dist/export-utils-DN0Gu8Vu.js +144 -0
  19. package/dist/export-utils-DN0Gu8Vu.js.map +1 -0
  20. package/dist/extension-BPFuYyzN.cjs +338 -0
  21. package/dist/extension-BPFuYyzN.cjs.map +1 -0
  22. package/dist/extension-Cl6x5MDR.js +321 -0
  23. package/dist/extension-Cl6x5MDR.js.map +1 -0
  24. package/dist/extensions/index.cjs.js +3462 -0
  25. package/dist/extensions/index.cjs.js.map +1 -0
  26. package/dist/extensions/index.esm.js +3412 -0
  27. package/dist/extensions/index.esm.js.map +1 -0
  28. package/dist/prompt-B4AOP8f_.js +24143 -0
  29. package/dist/prompt-B4AOP8f_.js.map +1 -0
  30. package/dist/prompt-CGLw2O21.cjs +25530 -0
  31. package/dist/prompt-CGLw2O21.cjs.map +1 -0
  32. package/dist/react/index.cjs.js +839 -0
  33. package/dist/react/index.cjs.js.map +1 -0
  34. package/dist/react/index.esm.js +820 -0
  35. package/dist/react/index.esm.js.map +1 -0
  36. package/dist/shortcut-panel-BskGXV8n.js +49468 -0
  37. package/dist/shortcut-panel-BskGXV8n.js.map +1 -0
  38. package/dist/shortcut-panel-yP4RPTFt.cjs +49563 -0
  39. package/dist/shortcut-panel-yP4RPTFt.cjs.map +1 -0
  40. package/dist/toc-extension-BESc0uEW.js +150 -0
  41. package/dist/toc-extension-BESc0uEW.js.map +1 -0
  42. package/dist/toc-extension-SRvSuskn.cjs +173 -0
  43. package/dist/toc-extension-SRvSuskn.cjs.map +1 -0
  44. package/dist/toolbar-config-Cgc9mV2v.js +243 -0
  45. package/dist/toolbar-config-Cgc9mV2v.js.map +1 -0
  46. package/dist/toolbar-config-Cjt_fPMi.cjs +260 -0
  47. package/dist/toolbar-config-Cjt_fPMi.cjs.map +1 -0
  48. package/dist/ui/index.cjs.js +18 -0
  49. package/dist/ui/index.esm.js +3 -0
  50. package/dist/vue/index.cjs.js +323 -0
  51. package/dist/vue/index.cjs.js.map +1 -0
  52. package/dist/vue/index.esm.js +307 -0
  53. package/dist/vue/index.esm.js.map +1 -0
  54. package/dist/vue2/index.cjs.js +323 -0
  55. package/dist/vue2/index.cjs.js.map +1 -0
  56. package/dist/vue2/index.esm.js +307 -0
  57. package/dist/vue2/index.esm.js.map +1 -0
  58. package/package.json +116 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","names":[],"sources":["../../src/vue2/use-editor.ts","../../src/vue2/components.ts"],"sourcesContent":["import { ref, shallowRef, onBeforeUnmount, watch, type Ref } 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: ReturnType<typeof shallowRef<EditorView | null>>\n state: ReturnType<typeof 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 = () => { version.value++ }\n\n const dispatchTransaction = (tr: Transaction) => {\n const view = viewRef.value\n if (!view) return\n const newState = view.state.apply(tr)\n view.updateState(newState)\n stateRef.value = newState\n if (onUpdate) onUpdate(newState)\n if (onSelectionChange) onSelectionChange(newState)\n forceUpdate()\n }\n\n const createView = (element: HTMLElement) => {\n if (viewRef.value) return\n const editableVal = typeof options.editable === 'object'\n ? (options.editable as Ref<boolean>).value\n : (options.editable ?? true)\n const view = new EditorView({\n state: stateRef.value!,\n element,\n editable: editableVal,\n dispatchTransaction,\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>, () => { forceUpdate() })\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 } 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 ?? null,\n getState: () => editor.state.value ?? null,\n getSchema: () => editor.schema,\n getCommands: () => editor.commands,\n }\n}\n\nexport const EditorContent = defineComponent({\n name: 'EditorContent',\n props: { editor: { type: Object as PropType<EditorHandle>, required: true } },\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({ open: () => comp?.open(), close: () => comp?.close() })\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({ open: () => comp?.open(), openProductCard: () => comp?.openProductCard() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n"],"mappings":";;;;;;;;AA2BA,SAAgB,UAAU,UAA4B,CAAC,GAAiB;CACtE,MAAM,EAAE,aAAa,C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AAA,gBAAA,OAAsB;GAAE,MAAM,QAAQ;EAAE,CAAC;EACzC,OAAO,EAAE,YAAY,MAAM,KAAK,EAAE,CAAC;EACnC,cAAA,GAAA,IAAA,EAAA,CAAe,OAAO,EAAE,MAAM,OAAgB;GAAE,IAAI,cAAc,aAAa,aAAa,QAAQ;EAAG,EAAE,CAAC;CAC5G;AACF,CAAC;AAED,IAAa,YAAA,GAAA,IAAA,gBAAA,CAA2B;CACtC,MAAM;CACN,OAAO,EAAE,QAAQ;EAAE,MAAM;EAAkC,UAAU;CAAK,EAAE;CAC5E,MAAM,OAAO,EAAE,UAAU;EACvB,MAAM,gBAAA,GAAA,IAAA,IAAA,CAAuC,IAAI;EACjD,IAAI,OAA6B;EACjC,CAAA,GAAA,IAAA,UAAA,OAAgB;GACd,IAAI,CAAC,aAAa,OAAO;GACzB,OAAO,IAAI,uBAAA,SAAc,oBAAoB,MAAM,MAAM,CAAC;GAC1D,KAAK,MAAM,aAAa,KAAK;EAC/B,CAAC;EACD,CAAA,GAAA,IAAA,gBAAA,OAAsB;GAAE,MAAM,QAAQ;EAAE,CAAC;EACzC,OAAO;GAAE,YAAY,MAAM,KAAK;GAAG,uBAAuB,MAAM,gBAAgB;EAAE,CAAC;EACnF,cAAA,GAAA,IAAA,EAAA,CAAe,OAAO,EAAE,MAAM,OAAgB;GAAE,IAAI,cAAc,aAAa,aAAa,QAAQ;EAAG,EAAE,CAAC;CAC5G;AACF,CAAC"}
@@ -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/vue2/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/vue2/components.ts
71
+ function createEditorAdapter(editor) {
72
+ return {
73
+ getView: () => editor.view.value ?? null,
74
+ getState: () => editor.state.value ?? null,
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/vue2/use-editor.ts","../../src/vue2/components.ts"],"sourcesContent":["import { ref, shallowRef, onBeforeUnmount, watch, type Ref } 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: ReturnType<typeof shallowRef<EditorView | null>>\n state: ReturnType<typeof 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 = () => { version.value++ }\n\n const dispatchTransaction = (tr: Transaction) => {\n const view = viewRef.value\n if (!view) return\n const newState = view.state.apply(tr)\n view.updateState(newState)\n stateRef.value = newState\n if (onUpdate) onUpdate(newState)\n if (onSelectionChange) onSelectionChange(newState)\n forceUpdate()\n }\n\n const createView = (element: HTMLElement) => {\n if (viewRef.value) return\n const editableVal = typeof options.editable === 'object'\n ? (options.editable as Ref<boolean>).value\n : (options.editable ?? true)\n const view = new EditorView({\n state: stateRef.value!,\n element,\n editable: editableVal,\n dispatchTransaction,\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>, () => { forceUpdate() })\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 } 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 ?? null,\n getState: () => editor.state.value ?? null,\n getSchema: () => editor.schema,\n getCommands: () => editor.commands,\n }\n}\n\nexport const EditorContent = defineComponent({\n name: 'EditorContent',\n props: { editor: { type: Object as PropType<EditorHandle>, required: true } },\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({ open: () => comp?.open(), close: () => comp?.close() })\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({ open: () => comp?.open(), openProductCard: () => comp?.openProductCard() })\n return () => h('div', { ref: (el: unknown) => { if (el instanceof HTMLElement) containerRef.value = el } })\n },\n})\n"],"mappings":";;;;;;AA2BA,SAAgB,UAAU,UAA4B,CAAC,GAAiB;CACtE,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,UAAU,sBAAsB;CAElE,MAAM,UAAU,IAAI,iBAAiB,UAAU;CAC/C,MAAM,SAAS,QAAQ;CAEvB,IAAI;CACJ,IAAI,SACF,IAAI;EACF,MAAM,YAAY,SAAS,cAAc,KAAK;EAC9C,UAAU,YAAY;EACtB,aAAa,UAAY,WAAW,MAAM,CAAC,CAAC,MAAM,SAAS;CAC7D,QAAQ,CAER;CAGF,MAAM,eAAe,YAAY,OAAO;EACtC;EACA,KAAK;EACL,SAAS,QAAQ;CACnB,CAAC;CAED,MAAM,UAAU,WAA8B,IAAI;CAClD,MAAM,WAAW,WAA+B,YAAY;CAC5D,MAAM,UAAU,WAAW,CAAC;CAE5B,MAAM,oBAAoB;EAAE,QAAQ;CAAQ;CAE5C,MAAM,uBAAuB,OAAoB;EAC/C,MAAM,OAAO,QAAQ;EACrB,IAAI,CAAC,MAAM;EACX,MAAM,WAAW,KAAK,MAAM,MAAM,EAAE;EACpC,KAAK,YAAY,QAAQ;EACzB,SAAS,QAAQ;EACjB,IAAI,UAAU,SAAS,QA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IAAI;EACjD,IAAI,OAA6B;EACjC,gBAAgB;GACd,IAAI,CAAC,aAAa,OAAO;GACzB,OAAO,IAAI,WAAc,oBAAoB,MAAM,MAAM,CAAC;GAC1D,KAAK,MAAM,aAAa,KAAK;EAC/B,CAAC;EACD,sBAAsB;GAAE,MAAM,QAAQ;EAAE,CAAC;EACzC,OAAO;GAAE,YAAY,MAAM,KAAK;GAAG,uBAAuB,MAAM,gBAAgB;EAAE,CAAC;EACnF,aAAa,EAAE,OAAO,EAAE,MAAM,OAAgB;GAAE,IAAI,cAAc,aAAa,aAAa,QAAQ;EAAG,EAAE,CAAC;CAC5G;AACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,116 @@
1
+ {
2
+ "name": "miyuan-editor",
3
+ "version": "0.0.3",
4
+ "description": "A highly extensible rich text editor engine with multi-framework support",
5
+ "type": "module",
6
+ "main": "./dist/core/index.cjs.js",
7
+ "module": "./dist/core/index.esm.js",
8
+ "types": "./dist/core/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/core/index.esm.js",
12
+ "require": "./dist/core/index.cjs.js",
13
+ "types": "./dist/core/index.d.ts"
14
+ },
15
+ "./core": {
16
+ "import": "./dist/core/index.esm.js",
17
+ "require": "./dist/core/index.cjs.js",
18
+ "types": "./dist/core/index.d.ts"
19
+ },
20
+ "./extensions": {
21
+ "import": "./dist/extensions/index.esm.js",
22
+ "require": "./dist/extensions/index.cjs.js",
23
+ "types": "./dist/extensions/index.d.ts"
24
+ },
25
+ "./ui": {
26
+ "import": "./dist/ui/index.esm.js",
27
+ "require": "./dist/ui/index.cjs.js",
28
+ "types": "./dist/ui/index.d.ts"
29
+ },
30
+ "./react": {
31
+ "import": "./dist/react/index.esm.js",
32
+ "require": "./dist/react/index.cjs.js",
33
+ "types": "./dist/react/index.d.ts"
34
+ },
35
+ "./vue": {
36
+ "import": "./dist/vue/index.esm.js",
37
+ "require": "./dist/vue/index.cjs.js",
38
+ "types": "./dist/vue/index.d.ts"
39
+ },
40
+ "./vue2": {
41
+ "import": "./dist/vue2/index.esm.js",
42
+ "require": "./dist/vue2/index.cjs.js",
43
+ "types": "./dist/vue2/index.d.ts"
44
+ }
45
+ },
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "scripts": {
50
+ "dev": "vite --config playground/vite.config.ts",
51
+ "playground": "vite --config playground/vite.config.ts",
52
+ "build": "vite build",
53
+ "test": "vitest run",
54
+ "test:watch": "vitest",
55
+ "lint": "eslint src/",
56
+ "format": "prettier --write src/",
57
+ "typecheck": "tsc --noEmit"
58
+ },
59
+ "peerDependencies": {
60
+ "react": "^18.0.0",
61
+ "react-dom": "^18.0.0",
62
+ "vue": "^2.7.0 || ^3.3.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "react": {
66
+ "optional": true
67
+ },
68
+ "react-dom": {
69
+ "optional": true
70
+ },
71
+ "vue": {
72
+ "optional": true
73
+ }
74
+ },
75
+ "keywords": [
76
+ "editor",
77
+ "rich-text",
78
+ "wysiwyg",
79
+ "react",
80
+ "vue",
81
+ "typescript"
82
+ ],
83
+ "author": "jiahao",
84
+ "license": "MIT",
85
+ "devDependencies": {
86
+ "@eslint/js": "^9.39.4",
87
+ "@types/node": "^25.9.3",
88
+ "@types/react": "^19.2.17",
89
+ "@types/react-dom": "^19.2.3",
90
+ "@vitejs/plugin-react": "^6.0.2",
91
+ "eslint": "^9.39.4",
92
+ "eslint-config-prettier": "^10.1.8",
93
+ "eslint-plugin-prettier": "^5.5.6",
94
+ "jsdom": "^28.1.0",
95
+ "prettier": "^3.8.4",
96
+ "react": "^19.2.7",
97
+ "react-dom": "^19.2.7",
98
+ "typescript": "^6.0.3",
99
+ "typescript-eslint": "^8.61.1",
100
+ "vite": "^8.0.16",
101
+ "vite-plugin-node-polyfills": "^0.28.0",
102
+ "vitest": "^4.1.9"
103
+ },
104
+ "dependencies": {
105
+ "@jiahao/ai-agent-sdk": "^0.1.12",
106
+ "prosemirror-commands": "^1.7.1",
107
+ "prosemirror-history": "^1.5.0",
108
+ "prosemirror-inputrules": "^1.5.1",
109
+ "prosemirror-keymap": "^1.2.3",
110
+ "prosemirror-model": "^1.25.9",
111
+ "prosemirror-schema-list": "^1.5.1",
112
+ "prosemirror-state": "^1.4.4",
113
+ "prosemirror-transform": "^1.12.0",
114
+ "prosemirror-view": "^1.41.9"
115
+ }
116
+ }