From 4721fe451fc9013a2a016f55063c43047ce708a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Sun, 28 Feb 2021 00:02:51 +0100 Subject: [PATCH] refactoring --- packages/core/src/Editor.ts | 4 ++-- packages/core/src/types.ts | 4 ++-- packages/vue-3/src/VueNodeViewRenderer.ts | 17 ----------------- packages/vue-3/src/index.ts | 6 +++--- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index 91c2a2c31..5aeb252a9 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -13,7 +13,7 @@ import ExtensionManager from './ExtensionManager' import EventEmitter from './EventEmitter' import { EditorOptions, - EditorContent, + Content, CanCommands, ChainedCommands, SingleCommands, @@ -237,7 +237,7 @@ export class Editor extends EventEmitter { /** * Creates a ProseMirror document. */ - public createDocument = (content: EditorContent, parseOptions = this.options.parseOptions): Node => { + public createDocument = (content: Content, parseOptions = this.options.parseOptions): Node => { if (content && typeof content === 'object') { try { return this.schema.nodeFromJSON(content) diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 4c61b49bb..617039902 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -32,7 +32,7 @@ export type Extensions = (Extension | Node | Mark)[] export interface EditorOptions { element: Element, - content: EditorContent, + content: Content, extensions: Extensions, injectCSS: boolean, autofocus: FocusPosition, @@ -50,7 +50,7 @@ export interface EditorOptions { onDestroy: () => void, } -export type EditorContent = string | JSON | null +export type Content = string | JSON | null export type CommandProps = { editor: Editor, diff --git a/packages/vue-3/src/VueNodeViewRenderer.ts b/packages/vue-3/src/VueNodeViewRenderer.ts index 7760dcc35..6469a1e94 100644 --- a/packages/vue-3/src/VueNodeViewRenderer.ts +++ b/packages/vue-3/src/VueNodeViewRenderer.ts @@ -15,12 +15,6 @@ import { Node as ProseMirrorNode } from 'prosemirror-model' import { Editor } from './Editor' import { VueRenderer } from './VueRenderer' -// function getComponentFromElement(element: HTMLElement): Component { -// // @ts-ignore -// // eslint-disable-next-line -// return element.__vueParentComponent -// } - interface VueNodeViewRendererOptions { stopEvent: ((event: Event) => boolean) | null, update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null, @@ -311,17 +305,6 @@ class VueNodeView implements NodeView { export function VueNodeViewRenderer(component: Component, options?: Partial): NodeViewRenderer { return (props: NodeViewRendererProps) => { - // try to get the parent component - // this is important for vue devtools to show the component hierarchy correctly - // maybe it’s `undefined` because isn’t rendered yet - // const parent = props.editor.view.dom.parentElement - // ? getComponentFromElement(props.editor.view.dom.parentElement) - // : undefined - - // if (!parent) { - // return {} - // } - if (!props.editor.contentComponent) { return {} } diff --git a/packages/vue-3/src/index.ts b/packages/vue-3/src/index.ts index 513910893..094ea3652 100644 --- a/packages/vue-3/src/index.ts +++ b/packages/vue-3/src/index.ts @@ -1,5 +1,5 @@ export * from '@tiptap/core' -export { VueRenderer } from './VueRenderer' -export { VueNodeViewRenderer } from './VueNodeViewRenderer' export { Editor } from './Editor' -export { EditorContent } from './EditorContent' +export * from './EditorContent' +export * from './VueRenderer' +export * from './VueNodeViewRenderer'