@milkdown/vue 7.6.1 → 7.6.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 +1 -1
- package/lib/index.es.js +15 -15
- package/lib/index.es.js.map +1 -1
- package/lib/types.d.ts +2 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/use-get-editor.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/types.ts +2 -1
- package/src/use-get-editor.ts +6 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Vue integration for [milkdown](https://milkdown.dev/).
|
|
|
4
4
|
|
|
5
5
|
# Official Documentation
|
|
6
6
|
|
|
7
|
-
Documentation can be found on the [Milkdown website](https://milkdown.dev/
|
|
7
|
+
Documentation can be found on the [Milkdown website](https://milkdown.dev/).
|
|
8
8
|
|
|
9
9
|
# License
|
|
10
10
|
|
package/lib/index.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
const
|
|
1
|
+
import { inject as l, ref as d, onMounted as v, onUnmounted as s, defineComponent as c, createVNode as f, provide as m, Fragment as y } from "vue";
|
|
2
|
+
const a = Symbol("editorInfoCtxKey");
|
|
3
3
|
function g() {
|
|
4
4
|
const {
|
|
5
5
|
dom: e,
|
|
6
6
|
loading: o,
|
|
7
7
|
editor: n,
|
|
8
8
|
editorFactory: r
|
|
9
|
-
} = a
|
|
9
|
+
} = l(a, {}), i = d();
|
|
10
10
|
return v(() => {
|
|
11
11
|
if (!e.value) return;
|
|
12
12
|
const t = r.value(e.value);
|
|
13
|
-
t && (o.value = !0, t.create().then((u) => {
|
|
13
|
+
t && (o.value = !0, i.value = t, t.create().then((u) => {
|
|
14
14
|
n.value = u;
|
|
15
15
|
}).finally(() => {
|
|
16
16
|
o.value = !1;
|
|
17
17
|
}).catch(console.error));
|
|
18
18
|
}), s(() => {
|
|
19
19
|
var t;
|
|
20
|
-
(t =
|
|
20
|
+
(t = i.value) == null || t.destroy();
|
|
21
21
|
}), e;
|
|
22
22
|
}
|
|
23
23
|
const k = /* @__PURE__ */ c({
|
|
@@ -34,33 +34,33 @@ const k = /* @__PURE__ */ c({
|
|
|
34
34
|
setup: (e, {
|
|
35
35
|
slots: o
|
|
36
36
|
}) => {
|
|
37
|
-
const n = d(null), r = d(void 0),
|
|
38
|
-
return m(
|
|
39
|
-
loading:
|
|
37
|
+
const n = d(null), r = d(void 0), i = d(void 0), t = d(!0);
|
|
38
|
+
return m(a, {
|
|
39
|
+
loading: t,
|
|
40
40
|
dom: n,
|
|
41
|
-
editor:
|
|
41
|
+
editor: i,
|
|
42
42
|
editorFactory: r
|
|
43
43
|
}), () => {
|
|
44
|
-
var
|
|
45
|
-
return f(y, null, [(
|
|
44
|
+
var u;
|
|
45
|
+
return f(y, null, [(u = o.default) == null ? void 0 : u.call(o)]);
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
function M(e) {
|
|
50
|
-
const { editorFactory: o, loading: n, editor: r } = a
|
|
50
|
+
const { editorFactory: o, loading: n, editor: r } = l(a);
|
|
51
51
|
return o.value = e, {
|
|
52
52
|
loading: n,
|
|
53
53
|
get: () => r.value
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const e = a
|
|
56
|
+
function E() {
|
|
57
|
+
const e = l(a);
|
|
58
58
|
return [e.loading, () => e.editor.value];
|
|
59
59
|
}
|
|
60
60
|
export {
|
|
61
61
|
k as Milkdown,
|
|
62
62
|
w as MilkdownProvider,
|
|
63
63
|
M as useEditor,
|
|
64
|
-
|
|
64
|
+
E as useInstance
|
|
65
65
|
};
|
|
66
66
|
//# sourceMappingURL=index.es.js.map
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/consts.ts","../src/use-get-editor.ts","../src/editor.tsx","../src/use-editor.ts","../src/use-instance.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { EditorInfoCtx } from './types'\n\nexport const editorInfoCtxKey: InjectionKey<EditorInfoCtx> =\n Symbol('editorInfoCtxKey')\n","import { inject, onMounted, onUnmounted } from 'vue'\n\nimport type { EditorInfoCtx } from './types'\nimport { editorInfoCtxKey } from './consts'\n\nexport function useGetEditor() {\n const {\n dom,\n loading,\n editor: editorRef,\n editorFactory: getEditor,\n } = inject(editorInfoCtxKey, {} as EditorInfoCtx)\n\n onMounted(() => {\n if (!dom.value) return\n\n const editor = getEditor.value!(dom.value)\n if (!editor) return\n\n loading.value = true\n editor\n .create()\n .then((editor) => {\n editorRef.value = editor\n })\n .finally(() => {\n loading.value = false\n })\n .catch(console.error)\n })\n onUnmounted(() => {\n
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/consts.ts","../src/use-get-editor.ts","../src/editor.tsx","../src/use-editor.ts","../src/use-instance.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { EditorInfoCtx } from './types'\n\nexport const editorInfoCtxKey: InjectionKey<EditorInfoCtx> =\n Symbol('editorInfoCtxKey')\n","import { inject, onMounted, onUnmounted, ref } from 'vue'\n\nimport type { EditorInfoCtx } from './types'\nimport { editorInfoCtxKey } from './consts'\nimport type { Crepe } from '@milkdown/crepe'\nimport type { Editor } from '@milkdown/kit/core'\n\nexport function useGetEditor() {\n const {\n dom,\n loading,\n editor: editorRef,\n editorFactory: getEditor,\n } = inject(editorInfoCtxKey, {} as EditorInfoCtx)\n const currentEditorRef = ref<Editor | Crepe>()\n\n onMounted(() => {\n if (!dom.value) return\n\n const editor = getEditor.value!(dom.value)\n if (!editor) return\n\n loading.value = true\n currentEditorRef.value = editor\n editor\n .create()\n .then((editor) => {\n editorRef.value = editor\n })\n .finally(() => {\n loading.value = false\n })\n .catch(console.error)\n })\n onUnmounted(() => {\n currentEditorRef.value?.destroy()\n })\n\n return dom\n}\n","import type { Editor } from '@milkdown/kit/core'\nimport type { Ref } from 'vue'\nimport { Fragment, defineComponent, h, provide, ref } from 'vue'\n\nimport type { GetEditor } from './types'\nimport { useGetEditor } from './use-get-editor'\nimport { editorInfoCtxKey } from './consts'\n\nh\nFragment\n\nexport const Milkdown = defineComponent({\n name: 'Milkdown',\n setup: () => {\n const domRef = useGetEditor()\n\n return () => <div data-milkdown-root ref={domRef} />\n },\n})\n\nexport const MilkdownProvider = defineComponent({\n name: 'MilkdownProvider',\n setup: (_, { slots }) => {\n const dom = ref<HTMLDivElement | null>(null)\n const editorFactory = ref<GetEditor | undefined>(undefined)\n const editor = ref<Editor | undefined>(undefined) as Ref<Editor | undefined>\n const loading = ref(true)\n\n provide(editorInfoCtxKey, {\n loading,\n dom,\n editor,\n editorFactory,\n })\n\n return () => <>{slots.default?.()}</>\n },\n})\n","import { inject } from 'vue'\nimport { editorInfoCtxKey } from './consts'\n\nimport type { GetEditor, UseEditorReturn } from './types'\n\nexport function useEditor(getEditor: GetEditor): UseEditorReturn {\n const { editorFactory, loading, editor } = inject(editorInfoCtxKey)!\n\n editorFactory.value = getEditor\n\n return {\n loading,\n get: () => editor.value,\n }\n}\n","import type { Editor } from '@milkdown/kit/core'\nimport type { Ref } from 'vue'\nimport { inject } from 'vue'\nimport { editorInfoCtxKey } from './consts'\n\nexport type Instance = [Ref<true>, () => undefined] | [Ref<false>, () => Editor]\n\nexport function useInstance(): Instance {\n const editorInfo = inject(editorInfoCtxKey)!\n\n return [editorInfo.loading, () => editorInfo.editor.value] as Instance\n}\n"],"names":["editorInfoCtxKey","useGetEditor","dom","loading","editorRef","getEditor","inject","currentEditorRef","ref","onMounted","editor","onUnmounted","_a","Milkdown","defineComponent","name","setup","domRef","_createVNode","MilkdownProvider","_","slots","editorFactory","undefined","provide","_Fragment","default","useEditor","useInstance","editorInfo"],"mappings":";AAGa,MAAAA,IACX,OAAO,kBAAkB;ACGpB,SAASC,IAAe;AACvB,QAAA;AAAA,IACJ,KAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAQC;AAAA,IACR,eAAeC;AAAA,E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AAA,EACvC;AACF,CAAC;AChCM,SAASM,EAAUtB,GAAuC;AAC/D,QAAM,EAAE,eAAAiB,GAAe,SAAAnB,GAAS,QAAAO,EAAO,IAAIJ,EAAON,CAAgB;AAElE,SAAAsB,EAAc,QAAQjB,GAEf;AAAA,IACL,SAAAF;AAAA,IACA,KAAK,MAAMO,EAAO;AAAA,EACpB;AACF;ACPO,SAASkB,IAAwB;AAChC,QAAAC,IAAavB,EAAON,CAAgB;AAE1C,SAAO,CAAC6B,EAAW,SAAS,MAAMA,EAAW,OAAO,KAAK;AAC3D;"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Crepe } from '@milkdown/crepe';
|
|
1
2
|
import type { Editor } from '@milkdown/kit/core';
|
|
2
3
|
import type { Ref } from 'vue';
|
|
3
|
-
export type GetEditor = (container: HTMLDivElement) => Editor;
|
|
4
|
+
export type GetEditor = (container: HTMLDivElement) => Editor | Crepe;
|
|
4
5
|
export interface EditorInfoCtx {
|
|
5
6
|
dom: Ref<HTMLDivElement | null>;
|
|
6
7
|
editor: Ref<Editor | undefined>;
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,MAAM,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,cAAc,KAAK,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,MAAM,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,cAAc,KAAK,MAAM,GAAG,KAAK,CAAA;AAErE,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC/B,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC/B,aAAa,EAAE,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;IACzC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,GAAG,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-get-editor.d.ts","sourceRoot":"","sources":["../src/use-get-editor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-get-editor.d.ts","sourceRoot":"","sources":["../src/use-get-editor.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,oEAgC3B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.6.
|
|
4
|
+
"version": "7.6.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"tslib": "^2.8.1",
|
|
33
|
-
"@milkdown/kit": "7.6.
|
|
33
|
+
"@milkdown/kit": "7.6.3",
|
|
34
|
+
"@milkdown/crepe": "7.6.3"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"vue": "^3.3.4"
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { Crepe } from '@milkdown/crepe'
|
|
1
2
|
import type { Editor } from '@milkdown/kit/core'
|
|
2
3
|
import type { Ref } from 'vue'
|
|
3
4
|
|
|
4
|
-
export type GetEditor = (container: HTMLDivElement) => Editor
|
|
5
|
+
export type GetEditor = (container: HTMLDivElement) => Editor | Crepe
|
|
5
6
|
|
|
6
7
|
export interface EditorInfoCtx {
|
|
7
8
|
dom: Ref<HTMLDivElement | null>
|
package/src/use-get-editor.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { inject, onMounted, onUnmounted } from 'vue'
|
|
1
|
+
import { inject, onMounted, onUnmounted, ref } from 'vue'
|
|
2
2
|
|
|
3
3
|
import type { EditorInfoCtx } from './types'
|
|
4
4
|
import { editorInfoCtxKey } from './consts'
|
|
5
|
+
import type { Crepe } from '@milkdown/crepe'
|
|
6
|
+
import type { Editor } from '@milkdown/kit/core'
|
|
5
7
|
|
|
6
8
|
export function useGetEditor() {
|
|
7
9
|
const {
|
|
@@ -10,6 +12,7 @@ export function useGetEditor() {
|
|
|
10
12
|
editor: editorRef,
|
|
11
13
|
editorFactory: getEditor,
|
|
12
14
|
} = inject(editorInfoCtxKey, {} as EditorInfoCtx)
|
|
15
|
+
const currentEditorRef = ref<Editor | Crepe>()
|
|
13
16
|
|
|
14
17
|
onMounted(() => {
|
|
15
18
|
if (!dom.value) return
|
|
@@ -18,6 +21,7 @@ export function useGetEditor() {
|
|
|
18
21
|
if (!editor) return
|
|
19
22
|
|
|
20
23
|
loading.value = true
|
|
24
|
+
currentEditorRef.value = editor
|
|
21
25
|
editor
|
|
22
26
|
.create()
|
|
23
27
|
.then((editor) => {
|
|
@@ -29,7 +33,7 @@ export function useGetEditor() {
|
|
|
29
33
|
.catch(console.error)
|
|
30
34
|
})
|
|
31
35
|
onUnmounted(() => {
|
|
32
|
-
|
|
36
|
+
currentEditorRef.value?.destroy()
|
|
33
37
|
})
|
|
34
38
|
|
|
35
39
|
return dom
|