@milkdown/vue 7.3.1 → 7.3.2
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/lib/Editor.d.ts.map +1 -1
- package/lib/index.es.js +11 -8
- package/lib/index.es.js.map +1 -1
- package/lib/useEditor.d.ts +1 -1
- package/lib/useEditor.d.ts.map +1 -1
- package/lib/useGetEditor.d.ts +1 -1
- package/lib/useGetEditor.d.ts.map +1 -1
- package/lib/useInstance.d.ts +1 -1
- package/lib/useInstance.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Editor.tsx +5 -1
- package/src/useEditor.ts +1 -1
- package/src/useGetEditor.ts +1 -1
- package/src/useInstance.ts +1 -1
package/lib/Editor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAO,MAAM,KAAK,CAAA;AAS5C,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,SAAS,CAAA;AAQvD,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,aAAa,CAA8B,CAAA;AAEvF,eAAO,MAAM,QAAQ,mTAOnB,CAAA;AAEF,eAAO,MAAM,gBAAgB,mTAiB3B,CAAA"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { inject as a, onMounted as
|
|
2
|
-
|
|
1
|
+
import { inject as a, onMounted as v, onUnmounted as s, defineComponent as c, createVNode as f, ref as d, provide as m, Fragment as y } from "vue";
|
|
2
|
+
function g() {
|
|
3
3
|
const { dom: e, loading: o, editor: n, editorFactory: r } = a(i, {});
|
|
4
|
-
return
|
|
4
|
+
return v(() => {
|
|
5
5
|
if (!e.value)
|
|
6
6
|
return;
|
|
7
7
|
const t = r.value(e.value);
|
|
@@ -10,11 +10,12 @@ const g = () => {
|
|
|
10
10
|
}).finally(() => {
|
|
11
11
|
o.value = !1;
|
|
12
12
|
}).catch(console.error));
|
|
13
|
-
}),
|
|
13
|
+
}), s(() => {
|
|
14
14
|
var t;
|
|
15
15
|
(t = n.value) == null || t.destroy();
|
|
16
16
|
}), e;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
const i = Symbol("editorInfoCtxKey"), k = /* @__PURE__ */ c({
|
|
18
19
|
name: "Milkdown",
|
|
19
20
|
setup: () => {
|
|
20
21
|
const e = g();
|
|
@@ -39,16 +40,18 @@ const g = () => {
|
|
|
39
40
|
return f(y, null, [(l = o.default) == null ? void 0 : l.call(o)]);
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
})
|
|
43
|
+
});
|
|
44
|
+
function M(e) {
|
|
43
45
|
const { editorFactory: o, loading: n, editor: r } = a(i);
|
|
44
46
|
return o.value = e, {
|
|
45
47
|
loading: n,
|
|
46
48
|
get: () => r.value
|
|
47
49
|
};
|
|
48
|
-
}
|
|
50
|
+
}
|
|
51
|
+
function F() {
|
|
49
52
|
const e = a(i);
|
|
50
53
|
return [e.loading, () => e.editor.value];
|
|
51
|
-
}
|
|
54
|
+
}
|
|
52
55
|
export {
|
|
53
56
|
k as Milkdown,
|
|
54
57
|
w as MilkdownProvider,
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/useGetEditor.ts","../src/Editor.tsx","../src/useEditor.ts","../src/useInstance.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nimport { inject, onMounted, onUnmounted } from 'vue'\n\nimport type { EditorInfoCtx } from './types'\nimport { editorInfoCtxKey } from '.'\n\nexport
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/useGetEditor.ts","../src/Editor.tsx","../src/useEditor.ts","../src/useInstance.ts"],"sourcesContent":["/* Copyright 2021, Milkdown by Mirone. */\nimport { inject, onMounted, onUnmounted } from 'vue'\n\nimport type { EditorInfoCtx } from './types'\nimport { editorInfoCtxKey } from '.'\n\nexport function useGetEditor() {\n const { dom, loading, editor: editorRef, editorFactory: getEditor } = inject(editorInfoCtxKey, {} as EditorInfoCtx)\n\n onMounted(() => {\n if (!dom.value)\n return\n\n const editor = getEditor.value!(dom.value)\n if (!editor)\n 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 editorRef.value?.destroy()\n })\n\n return dom\n}\n","/* Copyright 2021, Milkdown by Mirone. */\nimport type { Editor } from '@milkdown/core'\nimport type { InjectionKey, Ref } from 'vue'\nimport {\n Fragment,\n defineComponent,\n h,\n provide,\n ref,\n} from 'vue'\n\nimport type { EditorInfoCtx, GetEditor } from './types'\nimport { useGetEditor } from './useGetEditor'\n\n// eslint-disable-next-line no-unused-expressions\nh\n// eslint-disable-next-line no-unused-expressions\nFragment\n\nexport const editorInfoCtxKey: InjectionKey<EditorInfoCtx> = Symbol('editorInfoCtxKey')\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","/* Copyright 2021, Milkdown by Mirone. */\n\nimport { inject } from 'vue'\nimport { editorInfoCtxKey } from './Editor'\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","/* Copyright 2021, Milkdown by Mirone. */\nimport type { Editor } from '@milkdown/core'\nimport type { Ref } from 'vue'\nimport { inject } from 'vue'\nimport { editorInfoCtxKey } from './Editor'\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":["useGetEditor","dom","loading","editorRef","getEditor","inject","editorInfoCtxKey","onMounted","editor","onUnmounted","_a","Symbol","Milkdown","defineComponent","name","setup","domRef","_createVNode","MilkdownProvider","_","slots","ref","editorFactory","undefined","provide","_Fragment","default","useEditor","useInstance","editorInfo"],"mappings":";AAMO,SAASA,IAAe;AACvB,QAAA,EAAE,KAAAC,GAAK,SAAAC,GAAS,QAAQC,GAAW,eAAeC,MAAcC,EAAOC,GAAkB,CAAmB,CAAA;AAElH,SAAAC,EAAU,MAAM;AACd,QAAI,CAACN,EAAI;AACP;AAEF,UAAMO,IAASJ,EAAU,MAAOH,EAAI,KAAK;AACzC,IAAKO,MAGLN,EAAQ,QAAQ,IAChBM,EACG,OAAO,EACP,KAAK,CAACA,MAAW;AAChB,MAAAL,EAAU,QAAQK;AAAAA,IAAA,CACnB,EACA,QAAQ,MAAM;AACb,MAAAN,EAAQ,QAAQ;AAAA,IACjB,CAAA,EACA,MAAM,QAAQ,KAAK;AAAA,EAAA,CACvB,GACDO,EAAY,MAAM;;AAChB,KAAAC,IAAAP,EAAU,UAAV,QAAAO,EAAiB;AAAA,EAAQ,CAC1B,GAEMT;AACT;MCdaK,IAAgDK,OAAO,kBAAkB,GAEzEC,IAAWC,gBAAAA,EAAgB;AAAA,EACtCC,MAAM;AAAA,EACNC,OAAOA,MAAM;AACX,UAAMC,IAAShB;AAEf,WAAO,MAAAiB,EAAA,OAAA;AAAA,MAAA,sBAAA;AAAA,MAAA,KAAmCD;AAAAA,IAAU,GAAA,IAAA;AAAA,EACtD;AACF,CAAC,GAEYE,IAAmBL,gBAAAA,EAAgB;AAAA,EAC9CC,MAAM;AAAA,EACNC,OAAOA,CAACI,GAAG;AAAA,IAAEC,OAAAA;AAAAA,EAAM,MAAM;AACvB,UAAMnB,IAAMoB,EAA2B,IAAI,GACrCC,IAAgBD,EAA2BE,MAAS,GACpDf,IAASa,EAAwBE,MAAS,GAC1CrB,IAAUmB,EAAI,EAAI;AAExBG,WAAAA,EAAQlB,GAAkB;AAAA,MACxBJ,SAAAA;AAAAA,MACAD,KAAAA;AAAAA,MACAO,QAAAA;AAAAA,MACAc,eAAAA;AAAAA,IACF,CAAC,GAEM,MAAA;;AAAAL,aAAAA,EAAAQ,GAAA,MAAA,EAASL,IAAAA,EAAMM,YAANN,gBAAAA,EAAAA,KAAAA,EAAiB,CAAI;AAAA;AAAA,EACvC;AACF,CAAC;ACxCM,SAASO,EAAUvB,GAAuC;AAC/D,QAAM,EAAE,eAAAkB,GAAe,SAAApB,GAAS,QAAAM,EAAO,IAAIH,EAAOC,CAAgB;AAElE,SAAAgB,EAAc,QAAQlB,GAEf;AAAA,IACL,SAAAF;AAAA,IACA,KAAK,MAAMM,EAAO;AAAA,EAAA;AAEtB;ACRO,SAASoB,IAAwB;AAChC,QAAAC,IAAaxB,EAAOC,CAAgB;AAE1C,SAAO,CAACuB,EAAW,SAAS,MAAMA,EAAW,OAAO,KAAK;AAC3D;"}
|
package/lib/useEditor.d.ts
CHANGED
package/lib/useEditor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../src/useEditor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAEzD,
|
|
1
|
+
{"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../src/useEditor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAEzD,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,eAAe,CAS/D"}
|
package/lib/useGetEditor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function useGetEditor(): import("vue").Ref<HTMLDivElement | null>;
|
|
2
2
|
//# sourceMappingURL=useGetEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetEditor.d.ts","sourceRoot":"","sources":["../src/useGetEditor.ts"],"names":[],"mappings":"AAMA,
|
|
1
|
+
{"version":3,"file":"useGetEditor.d.ts","sourceRoot":"","sources":["../src/useGetEditor.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,6CA2B3B"}
|
package/lib/useInstance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Editor } from '@milkdown/core';
|
|
2
2
|
import type { Ref } from 'vue';
|
|
3
3
|
export type Instance = [Ref<true>, () => undefined] | [Ref<false>, () => Editor];
|
|
4
|
-
export declare
|
|
4
|
+
export declare function useInstance(): Instance;
|
|
5
5
|
//# sourceMappingURL=useInstance.d.ts.map
|
package/lib/useInstance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInstance.d.ts","sourceRoot":"","sources":["../src/useInstance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC,CAAA;AAEhF,
|
|
1
|
+
{"version":3,"file":"useInstance.d.ts","sourceRoot":"","sources":["../src/useInstance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC,CAAA;AAEhF,wBAAgB,WAAW,IAAI,QAAQ,CAItC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.3.
|
|
4
|
+
"version": "7.3.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"tslib": "^2.5.0",
|
|
30
|
-
"@milkdown/utils": "7.3.
|
|
30
|
+
"@milkdown/utils": "7.3.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"vue": "^3.3.4",
|
|
34
|
-
"@milkdown/core": "7.3.
|
|
35
|
-
"@milkdown/prose": "7.3.
|
|
34
|
+
"@milkdown/core": "7.3.2",
|
|
35
|
+
"@milkdown/prose": "7.3.2"
|
|
36
36
|
},
|
|
37
37
|
"nx": {
|
|
38
38
|
"targets": {
|
package/src/Editor.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
/* eslint-disable vue/one-component-per-file */
|
|
3
2
|
import type { Editor } from '@milkdown/core'
|
|
4
3
|
import type { InjectionKey, Ref } from 'vue'
|
|
5
4
|
import {
|
|
@@ -13,6 +12,11 @@ import {
|
|
|
13
12
|
import type { EditorInfoCtx, GetEditor } from './types'
|
|
14
13
|
import { useGetEditor } from './useGetEditor'
|
|
15
14
|
|
|
15
|
+
// eslint-disable-next-line no-unused-expressions
|
|
16
|
+
h
|
|
17
|
+
// eslint-disable-next-line no-unused-expressions
|
|
18
|
+
Fragment
|
|
19
|
+
|
|
16
20
|
export const editorInfoCtxKey: InjectionKey<EditorInfoCtx> = Symbol('editorInfoCtxKey')
|
|
17
21
|
|
|
18
22
|
export const Milkdown = defineComponent({
|
package/src/useEditor.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { editorInfoCtxKey } from './Editor'
|
|
|
5
5
|
|
|
6
6
|
import type { GetEditor, UseEditorReturn } from './types'
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export function useEditor(getEditor: GetEditor): UseEditorReturn {
|
|
9
9
|
const { editorFactory, loading, editor } = inject(editorInfoCtxKey)!
|
|
10
10
|
|
|
11
11
|
editorFactory.value = getEditor
|
package/src/useGetEditor.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { inject, onMounted, onUnmounted } from 'vue'
|
|
|
4
4
|
import type { EditorInfoCtx } from './types'
|
|
5
5
|
import { editorInfoCtxKey } from '.'
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export function useGetEditor() {
|
|
8
8
|
const { dom, loading, editor: editorRef, editorFactory: getEditor } = inject(editorInfoCtxKey, {} as EditorInfoCtx)
|
|
9
9
|
|
|
10
10
|
onMounted(() => {
|
package/src/useInstance.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { editorInfoCtxKey } from './Editor'
|
|
|
6
6
|
|
|
7
7
|
export type Instance = [Ref<true>, () => undefined] | [Ref<false>, () => Editor]
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export function useInstance(): Instance {
|
|
10
10
|
const editorInfo = inject(editorInfoCtxKey)!
|
|
11
11
|
|
|
12
12
|
return [editorInfo.loading, () => editorInfo.editor.value] as Instance
|