@milkdown/vue 4.13.3 → 4.14.0
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 +4 -0
- package/lib/Editor.d.ts +2 -1
- package/lib/Editor.d.ts.map +1 -1
- package/lib/Editor.js.map +1 -1
- package/lib/VueNode.d.ts +2 -7
- package/lib/VueNode.d.ts.map +1 -1
- package/lib/VueNode.js +1 -2
- package/lib/VueNode.js.map +1 -1
- package/lib/VueNodeView.d.ts +4 -5
- package/lib/VueNodeView.d.ts.map +1 -1
- package/lib/VueNodeView.js +7 -7
- package/lib/VueNodeView.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -0
- package/lib/utils.js.map +1 -1
- package/package.json +3 -2
- package/src/Editor.tsx +2 -1
- package/src/VueNode.tsx +2 -6
- package/src/VueNodeView.tsx +8 -9
- package/src/utils.ts +1 -0
package/README.md
CHANGED
package/lib/Editor.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Editor
|
|
1
|
+
import { Editor } from '@milkdown/core';
|
|
2
|
+
import { ViewFactory } from '@milkdown/prose';
|
|
2
3
|
import { DefineComponent, Ref } from 'vue';
|
|
3
4
|
declare type GetEditor = (container: HTMLDivElement, renderVue: (Component: DefineComponent) => ViewFactory) => Editor;
|
|
4
5
|
export declare const EditorComponent: DefineComponent<{
|
package/lib/Editor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAiB,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACH,eAAe,EAUf,GAAG,EAGN,MAAM,KAAK,CAAC;AAOb,aAAK,SAAS,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,SAAS,EAAE,eAAe,KAAK,WAAW,KAAK,MAAM,CAAC;AA8B/G,eAAO,MAAM,eAAe;YAAqC,SAAS;;;;;;;;OAUxE,CAAC;AAGH,oBAAY,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,cAAc,GAAG,IAAI,CAAA;CAAE,CAAC;AAE5F,eAAO,MAAM,SAAS;YAAqC,SAAS;;;;;;;;OAkBlE,CAAC;AAGH,eAAO,MAAM,SAAS,cAAe,SAAS,wDAlEsB,eAAe,KAAK,WAAW,WAoElG,CAAC"}
|
package/lib/Editor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.js","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAU,aAAa,
|
|
1
|
+
{"version":3,"file":"Editor.js","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAU,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAEH,eAAe,EACf,QAAQ,EACR,CAAC,EACD,MAAM,EAEN,OAAO,EACP,SAAS,EACT,WAAW,EACX,OAAO,EAEP,GAAG,EACH,eAAe,GAClB,MAAM,KAAK,CAAC;AAEb,OAAO,EAAc,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,GAA8D,MAAM,EAAE,CAAC;AAIxF,MAAM,YAAY,GAAG,CAAC,SAAoB,EAAE,EAAE;IAC1C,MAAM,MAAM,GAAG,GAAG,CAAwB,IAAI,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,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CAAC,MAAM,SAAS,GAAG,CAAC,SAAoB,EAAE,EAAE;IAC9C,OAAO,CAAC,GAAG,IAA2B,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;AAClE,CAAC,CAAC"}
|
package/lib/VueNode.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { Mark, Node } from '
|
|
3
|
-
import { Decoration, EditorView } from 'prosemirror-view';
|
|
1
|
+
/// <reference types="prosemirror-model" />
|
|
2
|
+
import { Decoration, EditorView, Mark, Node } from '@milkdown/prose';
|
|
4
3
|
import { InjectionKey } from 'vue';
|
|
5
4
|
export declare type NodeContext = {
|
|
6
|
-
editor: Editor;
|
|
7
5
|
node: Node | Mark;
|
|
8
6
|
view: EditorView;
|
|
9
7
|
getPos: boolean | (() => number);
|
|
@@ -11,13 +9,11 @@ export declare type NodeContext = {
|
|
|
11
9
|
};
|
|
12
10
|
export declare const nodeMetadata: InjectionKey<NodeContext>;
|
|
13
11
|
export declare const VueNodeContainer: import("vue").DefineComponent<{
|
|
14
|
-
editor: Editor;
|
|
15
12
|
node: Node | Mark;
|
|
16
13
|
view: EditorView;
|
|
17
14
|
getPos: boolean | (() => number);
|
|
18
15
|
decorations: Decoration[];
|
|
19
16
|
}, () => JSX.Element, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
20
|
-
editor?: unknown;
|
|
21
17
|
node?: unknown;
|
|
22
18
|
view?: unknown;
|
|
23
19
|
getPos?: unknown;
|
|
@@ -28,7 +24,6 @@ export declare const VueNodeContainer: import("vue").DefineComponent<{
|
|
|
28
24
|
}>[] | undefined;
|
|
29
25
|
node?: Mark<any> | Node<any> | undefined;
|
|
30
26
|
view?: EditorView<any> | undefined;
|
|
31
|
-
editor?: Editor | undefined;
|
|
32
27
|
getPos?: boolean | (() => number) | undefined;
|
|
33
28
|
}>, {}>;
|
|
34
29
|
export declare const Content: import("vue").DefineComponent<{
|
package/lib/VueNode.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VueNode.d.ts","sourceRoot":"","sources":["../src/VueNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"VueNode.d.ts","sourceRoot":"","sources":["../src/VueNode.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAgC,YAAY,EAA6B,MAAM,KAAK,CAAC;AAE5F,oBAAY,WAAW,GAAG;IACtB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACjC,WAAW,EAAE,UAAU,EAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,WAAW,CAAY,CAAC;AAEhE,eAAO,MAAM,gBAAgB;UARnB,IAAI,GAAG,IAAI;UACX,UAAU;YACR,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC;iBACnB,UAAU,EAAE;;;;;;;;;;;;8BADA,MAAM;OAcjC,CAAC;AAGH,eAAO,MAAM,OAAO;SAAkC,WAAW;;;;;OAO/D,CAAC"}
|
package/lib/VueNode.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { defineComponent, Fragment, h, provide, ref, watchEffect } from 'vue';
|
|
2
2
|
export const nodeMetadata = Symbol();
|
|
3
|
-
export const VueNodeContainer = defineComponent(({
|
|
3
|
+
export const VueNodeContainer = defineComponent(({ node, view, getPos, decorations }, context) => {
|
|
4
4
|
provide(nodeMetadata, {
|
|
5
|
-
editor,
|
|
6
5
|
node,
|
|
7
6
|
view,
|
|
8
7
|
getPos,
|
package/lib/VueNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VueNode.js","sourceRoot":"","sources":["../src/VueNode.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VueNode.js","sourceRoot":"","sources":["../src/VueNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,EAAgB,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAS5F,MAAM,CAAC,MAAM,YAAY,GAA8B,MAAM,EAAE,CAAC;AAEhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAe,EAAE,OAAO,EAAE,EAAE;IAC1G,OAAO,CAAC,YAAY,EAAE;QAClB,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,WAAW;KACd,CAAC,CAAC;IACH,OAAO,GAAG,EAAE,mBAAC,OAAA,kBAAG,MAAA,MAAA,MAAA,OAAO,CAAC,KAAK,EAAC,OAAO,kDAAI,mCAAI,EAAE,CAAI,CAAA,EAAA,CAAC;AACxD,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,KAAK,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC,KAA2B,EAAE,EAAE;IACnE,MAAM,YAAY,GAAG,GAAG,CAAwB,IAAI,CAAC,CAAC;IACtD,WAAW,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK;YAAE,OAAO;QAC9C,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE,CAAC,WAAK,GAAG,EAAE,YAAY,GAAI,CAAC;AAC5C,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC"}
|
package/lib/VueNodeView.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
/// <reference types="prosemirror-model" />
|
|
2
|
+
import type { Decoration, EditorView, NodeView, ViewFactory } from '@milkdown/prose';
|
|
3
|
+
import { Mark, Node } from '@milkdown/prose';
|
|
4
4
|
import { DefineComponent } from 'vue';
|
|
5
5
|
export declare const createVueView: (addPortal: (portal: DefineComponent, key: string) => void, removePortalByKey: (key: string) => void) => (component: DefineComponent) => ViewFactory;
|
|
6
6
|
export declare class VueNodeView implements NodeView {
|
|
7
7
|
private component;
|
|
8
8
|
private addPortal;
|
|
9
9
|
private removePortalByKey;
|
|
10
|
-
private editor;
|
|
11
10
|
private node;
|
|
12
11
|
private view;
|
|
13
12
|
private getPos;
|
|
@@ -15,7 +14,7 @@ export declare class VueNodeView implements NodeView {
|
|
|
15
14
|
dom: HTMLElement | undefined;
|
|
16
15
|
contentDOM: HTMLElement | undefined;
|
|
17
16
|
key: string;
|
|
18
|
-
constructor(component: DefineComponent, addPortal: (portal: DefineComponent, key: string) => void, removePortalByKey: (key: string) => void,
|
|
17
|
+
constructor(component: DefineComponent, addPortal: (portal: DefineComponent, key: string) => void, removePortalByKey: (key: string) => void, node: Node | Mark, view: EditorView, getPos: boolean | (() => number), decorations: Decoration[]);
|
|
19
18
|
renderPortal(): void;
|
|
20
19
|
destroy(): void;
|
|
21
20
|
ignoreMutation(mutation: MutationRecord | {
|
package/lib/VueNodeView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VueNodeView.d.ts","sourceRoot":"","sources":["../src/VueNodeView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,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@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Mark, Node } from '@milkdown/prose';
|
|
2
|
+
import { customAlphabet } from 'nanoid';
|
|
3
3
|
import { defineComponent, h, Teleport } from 'vue';
|
|
4
4
|
import { Content, VueNodeContainer } from './VueNode';
|
|
5
|
-
|
|
5
|
+
const nanoid = customAlphabet('abcedfghicklmn', 10);
|
|
6
|
+
export const createVueView = (addPortal, removePortalByKey) => (component) => (node, view, getPos, decorations) => new VueNodeView(component, addPortal, removePortalByKey, node, view, getPos, decorations);
|
|
6
7
|
export class VueNodeView {
|
|
7
|
-
constructor(component, addPortal, removePortalByKey,
|
|
8
|
+
constructor(component, addPortal, removePortalByKey, node, view, getPos, decorations) {
|
|
8
9
|
this.component = component;
|
|
9
10
|
this.addPortal = addPortal;
|
|
10
11
|
this.removePortalByKey = removePortalByKey;
|
|
11
|
-
this.editor = editor;
|
|
12
12
|
this.node = node;
|
|
13
13
|
this.view = view;
|
|
14
14
|
this.getPos = getPos;
|
|
15
15
|
this.decorations = decorations;
|
|
16
|
-
this.key =
|
|
16
|
+
this.key = nanoid();
|
|
17
17
|
const dom = document.createElement(node instanceof Mark ? 'span' : 'div');
|
|
18
18
|
dom.classList.add('dom-wrapper');
|
|
19
19
|
const contentDOM = node instanceof Node && node.isLeaf
|
|
@@ -33,7 +33,7 @@ export class VueNodeView {
|
|
|
33
33
|
const CustomComponent = this.component;
|
|
34
34
|
const Portal = defineComponent(() => {
|
|
35
35
|
return () => (h(Teleport, { to: this.dom },
|
|
36
|
-
h(VueNodeContainer, { key: this.key,
|
|
36
|
+
h(VueNodeContainer, { key: this.key, node: this.node, view: this.view, getPos: this.getPos, decorations: this.decorations },
|
|
37
37
|
h(CustomComponent, null,
|
|
38
38
|
h(Content, { dom: this.contentDOM })))));
|
|
39
39
|
});
|
package/lib/VueNodeView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VueNodeView.js","sourceRoot":"","sources":["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,CAAC;IAED,OAAO;QACH,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,cAAc,CAAC,QAAiE;QAC5E,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,OAAO,IAAI,CAAC;SACf;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;CACJ"}
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,aAAK,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AACjD,aAAK,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,IAAI;KACpE,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACtG,CAAC,MAAM,CAAC,CAAC,CAAC;AACX,oBAAY,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC"}
|
package/lib/utils.js
CHANGED
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,yCAAyC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/vue",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"vue"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@milkdown/utils": "4.
|
|
19
|
+
"@milkdown/utils": "4.14.0",
|
|
20
|
+
"nanoid": "^3.1.25",
|
|
20
21
|
"tslib": "^2.2.0"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
package/src/Editor.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { Editor, editorViewCtx
|
|
2
|
+
import { Editor, editorViewCtx } from '@milkdown/core';
|
|
3
|
+
import { ViewFactory } from '@milkdown/prose';
|
|
3
4
|
import {
|
|
4
5
|
DefineComponent,
|
|
5
6
|
defineComponent,
|
package/src/VueNode.tsx
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import {
|
|
3
|
-
import { Mark, Node } from 'prosemirror-model';
|
|
4
|
-
import { Decoration, EditorView } from 'prosemirror-view';
|
|
2
|
+
import { Decoration, EditorView, Mark, Node } from '@milkdown/prose';
|
|
5
3
|
import { defineComponent, Fragment, h, InjectionKey, provide, ref, watchEffect } from 'vue';
|
|
6
4
|
|
|
7
5
|
export type NodeContext = {
|
|
8
|
-
editor: Editor;
|
|
9
6
|
node: Node | Mark;
|
|
10
7
|
view: EditorView;
|
|
11
8
|
getPos: boolean | (() => number);
|
|
@@ -14,9 +11,8 @@ export type NodeContext = {
|
|
|
14
11
|
|
|
15
12
|
export const nodeMetadata: InjectionKey<NodeContext> = Symbol();
|
|
16
13
|
|
|
17
|
-
export const VueNodeContainer = defineComponent(({
|
|
14
|
+
export const VueNodeContainer = defineComponent(({ node, view, getPos, decorations }: NodeContext, context) => {
|
|
18
15
|
provide(nodeMetadata, {
|
|
19
|
-
editor,
|
|
20
16
|
node,
|
|
21
17
|
view,
|
|
22
18
|
getPos,
|
package/src/VueNodeView.tsx
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type { Decoration, EditorView, NodeView } from 'prosemirror-view';
|
|
2
|
+
import type { Decoration, EditorView, NodeView, ViewFactory } from '@milkdown/prose';
|
|
3
|
+
import { Mark, Node } from '@milkdown/prose';
|
|
4
|
+
import { customAlphabet } from 'nanoid';
|
|
6
5
|
import { DefineComponent, defineComponent, h, Teleport } from 'vue';
|
|
7
6
|
|
|
8
7
|
import { Content, VueNodeContainer } from './VueNode';
|
|
9
8
|
|
|
9
|
+
const nanoid = customAlphabet('abcedfghicklmn', 10);
|
|
10
|
+
|
|
10
11
|
export const createVueView =
|
|
11
12
|
(addPortal: (portal: DefineComponent, key: string) => void, removePortalByKey: (key: string) => void) =>
|
|
12
13
|
(component: DefineComponent): ViewFactory =>
|
|
13
|
-
(
|
|
14
|
-
new VueNodeView(component, addPortal, removePortalByKey,
|
|
14
|
+
(node, view, getPos, decorations) =>
|
|
15
|
+
new VueNodeView(component, addPortal, removePortalByKey, node, view, getPos, decorations);
|
|
15
16
|
|
|
16
17
|
export class VueNodeView implements NodeView {
|
|
17
18
|
dom: HTMLElement | undefined;
|
|
@@ -22,13 +23,12 @@ export class VueNodeView implements NodeView {
|
|
|
22
23
|
private component: DefineComponent,
|
|
23
24
|
private addPortal: (portal: DefineComponent, key: string) => void,
|
|
24
25
|
private removePortalByKey: (key: string) => void,
|
|
25
|
-
private editor: Editor,
|
|
26
26
|
private node: Node | Mark,
|
|
27
27
|
private view: EditorView,
|
|
28
28
|
private getPos: boolean | (() => number),
|
|
29
29
|
private decorations: Decoration[],
|
|
30
30
|
) {
|
|
31
|
-
this.key =
|
|
31
|
+
this.key = nanoid();
|
|
32
32
|
const dom = document.createElement(node instanceof Mark ? 'span' : 'div');
|
|
33
33
|
dom.classList.add('dom-wrapper');
|
|
34
34
|
|
|
@@ -54,7 +54,6 @@ export class VueNodeView implements NodeView {
|
|
|
54
54
|
<Teleport to={this.dom}>
|
|
55
55
|
<VueNodeContainer
|
|
56
56
|
key={this.key}
|
|
57
|
-
editor={this.editor}
|
|
58
57
|
node={this.node}
|
|
59
58
|
view={this.view}
|
|
60
59
|
getPos={this.getPos}
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
+
|
|
2
3
|
type Prepend<T, U extends unknown[]> = [T, ...U];
|
|
3
4
|
type Keys_<T extends Record<string, unknown>, U extends PropertyKey[]> = {
|
|
4
5
|
[P in keyof T]: Record<string, unknown> extends Omit<T, P> ? [P] : Prepend<P, Keys_<Omit<T, P>, U>>;
|