@milkdown/vue 7.4.0 → 7.5.8

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 CHANGED
@@ -1,6 +1,3 @@
1
- import type { InjectionKey } from 'vue';
2
- import type { EditorInfoCtx } from './types';
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").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export declare const MilkdownProvider: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
6
3
  //# sourceMappingURL=Editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AACA,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"}
1
+ {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,QAAQ,6UAOnB,CAAA;AAEF,eAAO,MAAM,gBAAgB,6UAiB3B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { InjectionKey } from 'vue';
2
+ import type { EditorInfoCtx } from './types';
3
+ export declare const editorInfoCtxKey: InjectionKey<EditorInfoCtx>;
4
+ //# sourceMappingURL=consts.d.ts.map
@@ -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 { dom: e, loading: o, editor: n, editorFactory: r } = a(i, {});
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 i = Symbol("editorInfoCtxKey"), k = /* @__PURE__ */ c({
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
  };
@@ -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 '.'\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","import 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","import { 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","import 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":";AAKO,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;;AA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","../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;AAAA,IACJ,KAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAQC;AAAA,IACR,eAAeC;AAAA,EAAA,IACbC,EAAON,GAAkB,EAAmB;AAEhD,SAAAO,EAAU,MAAM;AACV,QAAA,CAACL,EAAI,MAAO;AAEhB,UAAMM,IAASH,EAAU,MAAOH,EAAI,KAAK;AACzC,IAAKM,MAELL,EAAQ,QAAQ,IAChBK,EACG,OAAO,EACP,KAAK,CAACA,MAAW;AAChB,MAAAJ,EAAU,QAAQI;AAAAA,IAAA,CACnB,EACA,QAAQ,MAAM;AACb,MAAAL,EAAQ,QAAQ;AAAA,IAAA,CACjB,EACA,MAAM,QAAQ,KAAK;AAAA,EAAA,CACvB,GACDM,EAAY,MAAM;;AAChB,KAAAC,IAAAN,EAAU,UAAV,QAAAM,EAAiB;AAAA,EAAQ,CAC1B,GAEMR;AACT;ACxBaS,MAAAA,IAAWC,gBAAAA,EAAgB;AAAA,EACtCC,MAAM;AAAA,EACNC,OAAOA,MAAM;AACX,UAAMC,IAASd,EAAc;AAE7B,WAAO,MAAAe,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,UAAMjB,IAAMkB,EAA2B,IAAI,GACrCC,IAAgBD,EAA2BE,MAAS,GACpDd,IAASY,EAAwBE,MAAS,GAC1CnB,IAAUiB,EAAI,EAAI;AAExBG,WAAAA,EAAQvB,GAAkB;AAAA,MACxBG,SAAAA;AAAAA,MACAD,KAAAA;AAAAA,MACAM,QAAAA;AAAAA,MACAa,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;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;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGetEditor.d.ts","sourceRoot":"","sources":["../src/useGetEditor.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,6CA2B3B"}
1
+ {"version":3,"file":"useGetEditor.d.ts","sourceRoot":"","sources":["../src/useGetEditor.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,6CA8B3B"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@milkdown/vue",
3
3
  "type": "module",
4
- "version": "7.4.0",
4
+ "version": "7.5.8",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/Milkdown/milkdown.git",
9
- "directory": "packages/vue"
9
+ "directory": "packages/integrations/vue"
10
10
  },
11
11
  "keywords": [
12
12
  "milkdown",
@@ -32,12 +32,12 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "tslib": "^2.5.0",
35
- "@milkdown/utils": "7.4.0"
35
+ "@milkdown/utils": "7.5.8"
36
36
  },
37
37
  "devDependencies": {
38
38
  "vue": "^3.3.4",
39
- "@milkdown/core": "7.4.0",
40
- "@milkdown/prose": "7.4.0"
39
+ "@milkdown/prose": "7.5.8",
40
+ "@milkdown/core": "7.5.8"
41
41
  },
42
42
  "nx": {
43
43
  "targets": {
@@ -46,19 +46,13 @@
46
46
  "{projectRoot}/lib"
47
47
  ],
48
48
  "dependsOn": [
49
- {
50
- "target": "build",
51
- "projects": "dependencies"
52
- }
49
+ "build"
53
50
  ]
54
51
  },
55
52
  "tsc": {
56
53
  "outputs": [],
57
54
  "dependsOn": [
58
- {
59
- "target": "build",
60
- "projects": "dependencies"
61
- }
55
+ "build"
62
56
  ]
63
57
  }
64
58
  }
package/src/Editor.tsx CHANGED
@@ -1,23 +1,14 @@
1
1
  import type { Editor } from '@milkdown/core'
2
- import type { InjectionKey, Ref } from 'vue'
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 { EditorInfoCtx, GetEditor } from './types'
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
@@ -0,0 +1,5 @@
1
+ import type { InjectionKey } from 'vue'
2
+ import type { EditorInfoCtx } from './types'
3
+
4
+ export const editorInfoCtxKey: InjectionKey<EditorInfoCtx> =
5
+ Symbol('editorInfoCtxKey')
package/src/useEditor.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { inject } from 'vue'
2
- import { editorInfoCtxKey } from './Editor'
2
+ import { editorInfoCtxKey } from './consts'
3
3
 
4
4
  import type { GetEditor, UseEditorReturn } from './types'
5
5
 
@@ -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 { dom, loading, editor: editorRef, editorFactory: getEditor } = inject(editorInfoCtxKey, {} as EditorInfoCtx)
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
@@ -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 './Editor'
4
+ import { editorInfoCtxKey } from './consts'
5
5
 
6
6
  export type Instance = [Ref<true>, () => undefined] | [Ref<false>, () => Editor]
7
7