@milkdown/vue 7.5.0 → 7.5.9
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 +2 -5
- package/lib/Editor.d.ts.map +1 -1
- package/lib/consts.d.ts +4 -0
- package/lib/consts.d.ts.map +1 -0
- package/lib/index.es.js +9 -5
- package/lib/index.es.js.map +1 -1
- package/lib/useGetEditor.d.ts +1 -1
- package/lib/useGetEditor.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Editor.tsx +4 -13
- package/src/consts.ts +5 -0
- package/src/useEditor.ts +1 -1
- package/src/useGetEditor.ts +9 -6
- package/src/useInstance.ts +1 -1
package/lib/Editor.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export declare const editorInfoCtxKey: InjectionKey<EditorInfoCtx>;
|
|
4
|
-
export declare const Milkdown: import("vue").DefineComponent<{}, () => JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
5
|
-
export declare const MilkdownProvider: import("vue").DefineComponent<{}, () => JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
1
|
+
export declare const Milkdown: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export declare const MilkdownProvider: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
3
|
//# sourceMappingURL=Editor.d.ts.map
|
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":"AAWA,eAAO,MAAM,QAAQ,wTAOnB,CAAA;AAEF,eAAO,MAAM,gBAAgB,wTAiB3B,CAAA"}
|
package/lib/consts.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,aAAa,CAC7B,CAAA"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
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
|
+
const i = Symbol("editorInfoCtxKey");
|
|
2
3
|
function g() {
|
|
3
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
dom: e,
|
|
6
|
+
loading: o,
|
|
7
|
+
editor: n,
|
|
8
|
+
editorFactory: r
|
|
9
|
+
} = a(i, {});
|
|
4
10
|
return v(() => {
|
|
5
|
-
if (!e.value)
|
|
6
|
-
return;
|
|
11
|
+
if (!e.value) return;
|
|
7
12
|
const t = r.value(e.value);
|
|
8
13
|
t && (o.value = !0, t.create().then((u) => {
|
|
9
14
|
n.value = u;
|
|
@@ -15,7 +20,7 @@ function g() {
|
|
|
15
20
|
(t = n.value) == null || t.destroy();
|
|
16
21
|
}), e;
|
|
17
22
|
}
|
|
18
|
-
const
|
|
23
|
+
const k = /* @__PURE__ */ c({
|
|
19
24
|
name: "Milkdown",
|
|
20
25
|
setup: () => {
|
|
21
26
|
const e = g();
|
|
@@ -55,7 +60,6 @@ function F() {
|
|
|
55
60
|
export {
|
|
56
61
|
k as Milkdown,
|
|
57
62
|
w as MilkdownProvider,
|
|
58
|
-
i as editorInfoCtxKey,
|
|
59
63
|
M as useEditor,
|
|
60
64
|
F as useInstance
|
|
61
65
|
};
|
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":["import { inject, onMounted, onUnmounted } from 'vue'\n\nimport type { EditorInfoCtx } from './types'\nimport { editorInfoCtxKey } from '
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/consts.ts","../src/useGetEditor.ts","../src/Editor.tsx","../src/useEditor.ts","../src/useInstance.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 editorRef.value?.destroy()\n })\n\n return dom\n}\n","import type { Editor } from '@milkdown/core'\nimport type { Ref } from 'vue'\nimport { Fragment, defineComponent, h, provide, ref } from 'vue'\n\nimport type { GetEditor } from './types'\nimport { useGetEditor } from './useGetEditor'\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/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","onMounted","editor","onUnmounted","_a","Milkdown","defineComponent","name","setup","domRef","_createVNode","MilkdownProvider","_","slots","ref","editorFactory","undefined","provide","_Fragment","default","useEditor","useInstance","editorInfo"],"mappings":";AAGa,MAAAA,IACX,OAAO,kBAAkB;ACCpB,SAASC,IAAe;AACvB,QAAA;AA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AAA,EAAiB,CAAI;AAAA;AAAA,EACvC;AACF,CAAC;AChCM,SAASO,EAAUrB,GAAuC;AAC/D,QAAM,EAAE,eAAAgB,GAAe,SAAAlB,GAAS,QAAAK,EAAO,IAAIF,EAAON,CAAgB;AAElE,SAAAqB,EAAc,QAAQhB,GAEf;AAAA,IACL,SAAAF;AAAA,IACA,KAAK,MAAMK,EAAO;AAAA,EACpB;AACF;ACPO,SAASmB,IAAwB;AAChC,QAAAC,IAAatB,EAAON,CAAgB;AAE1C,SAAO,CAAC4B,EAAW,SAAS,MAAMA,EAAW,OAAO,KAAK;AAC3D;"}
|
package/lib/useGetEditor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function useGetEditor(): import("vue").Ref<HTMLDivElement | null>;
|
|
1
|
+
export declare function useGetEditor(): import("vue").Ref<HTMLDivElement | null, 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":"AAKA,wBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"useGetEditor.d.ts","sourceRoot":"","sources":["../src/useGetEditor.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,oEA8B3B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.5.
|
|
4
|
+
"version": "7.5.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"tslib": "^2.5.0",
|
|
35
|
-
"@milkdown/utils": "7.5.
|
|
35
|
+
"@milkdown/utils": "7.5.9"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"vue": "^3.3.4",
|
|
39
|
-
"@milkdown/core": "7.5.
|
|
40
|
-
"@milkdown/prose": "7.5.
|
|
39
|
+
"@milkdown/core": "7.5.9",
|
|
40
|
+
"@milkdown/prose": "7.5.9"
|
|
41
41
|
},
|
|
42
42
|
"nx": {
|
|
43
43
|
"targets": {
|
package/src/Editor.tsx
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import type { Editor } from '@milkdown/core'
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
Fragment,
|
|
5
|
-
defineComponent,
|
|
6
|
-
h,
|
|
7
|
-
provide,
|
|
8
|
-
ref,
|
|
9
|
-
} from 'vue'
|
|
2
|
+
import type { Ref } from 'vue'
|
|
3
|
+
import { Fragment, defineComponent, h, provide, ref } from 'vue'
|
|
10
4
|
|
|
11
|
-
import type {
|
|
5
|
+
import type { GetEditor } from './types'
|
|
12
6
|
import { useGetEditor } from './useGetEditor'
|
|
7
|
+
import { editorInfoCtxKey } from './consts'
|
|
13
8
|
|
|
14
|
-
// eslint-disable-next-line no-unused-expressions
|
|
15
9
|
h
|
|
16
|
-
// eslint-disable-next-line no-unused-expressions
|
|
17
10
|
Fragment
|
|
18
11
|
|
|
19
|
-
export const editorInfoCtxKey: InjectionKey<EditorInfoCtx> = Symbol('editorInfoCtxKey')
|
|
20
|
-
|
|
21
12
|
export const Milkdown = defineComponent({
|
|
22
13
|
name: 'Milkdown',
|
|
23
14
|
setup: () => {
|
package/src/consts.ts
ADDED
package/src/useEditor.ts
CHANGED
package/src/useGetEditor.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { inject, onMounted, onUnmounted } from 'vue'
|
|
2
2
|
|
|
3
3
|
import type { EditorInfoCtx } from './types'
|
|
4
|
-
import { editorInfoCtxKey } from '
|
|
4
|
+
import { editorInfoCtxKey } from './consts'
|
|
5
5
|
|
|
6
6
|
export function useGetEditor() {
|
|
7
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
dom,
|
|
9
|
+
loading,
|
|
10
|
+
editor: editorRef,
|
|
11
|
+
editorFactory: getEditor,
|
|
12
|
+
} = inject(editorInfoCtxKey, {} as EditorInfoCtx)
|
|
8
13
|
|
|
9
14
|
onMounted(() => {
|
|
10
|
-
if (!dom.value)
|
|
11
|
-
return
|
|
15
|
+
if (!dom.value) return
|
|
12
16
|
|
|
13
17
|
const editor = getEditor.value!(dom.value)
|
|
14
|
-
if (!editor)
|
|
15
|
-
return
|
|
18
|
+
if (!editor) return
|
|
16
19
|
|
|
17
20
|
loading.value = true
|
|
18
21
|
editor
|
package/src/useInstance.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Editor } from '@milkdown/core'
|
|
2
2
|
import type { Ref } from 'vue'
|
|
3
3
|
import { inject } from 'vue'
|
|
4
|
-
import { editorInfoCtxKey } from './
|
|
4
|
+
import { editorInfoCtxKey } from './consts'
|
|
5
5
|
|
|
6
6
|
export type Instance = [Ref<true>, () => undefined] | [Ref<false>, () => Editor]
|
|
7
7
|
|