From 0e1d6d41fed8293fd726c8edf7c5eb23a92c52f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 4 May 2021 11:03:11 +0200 Subject: [PATCH] refactoring --- packages/vue-2/src/BubbleMenu.ts | 10 +++++----- packages/vue-2/src/EditorContent.ts | 8 +++----- packages/vue-2/src/FloatingMenu.ts | 4 ++-- packages/vue-2/src/NodeViewContent.ts | 4 ++-- packages/vue-2/src/NodeViewWrapper.ts | 12 +++++------- packages/vue-2/src/VueNodeViewRenderer.ts | 2 +- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/packages/vue-2/src/BubbleMenu.ts b/packages/vue-2/src/BubbleMenu.ts index 061f6d261..5b176feb4 100644 --- a/packages/vue-2/src/BubbleMenu.ts +++ b/packages/vue-2/src/BubbleMenu.ts @@ -1,9 +1,9 @@ import Vue, { Component, PropType } from 'vue' import { BubbleMenuPlugin, BubbleMenuPluginKey, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu' -interface BubleMenuInterface extends Vue { +export interface BubbleMenuInterface extends Vue { tippyOptions: BubbleMenuPluginProps['tippyOptions'], - editor: BubbleMenuPluginProps['editor'] + editor: BubbleMenuPluginProps['editor'], } export const BubbleMenu: Component = { @@ -24,7 +24,7 @@ export const BubbleMenu: Component = { watch: { editor: { immediate: true, - handler(this: BubleMenuInterface, editor: BubbleMenuPluginProps['editor']) { + handler(this: BubbleMenuInterface, editor: BubbleMenuPluginProps['editor']) { if (!editor) { return } @@ -40,11 +40,11 @@ export const BubbleMenu: Component = { }, }, - render(this: BubleMenuInterface, createElement) { + render(this: BubbleMenuInterface, createElement) { return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default) }, - beforeDestroy(this: BubleMenuInterface) { + beforeDestroy(this: BubbleMenuInterface) { this.editor.unregisterPlugin(BubbleMenuPluginKey) }, } diff --git a/packages/vue-2/src/EditorContent.ts b/packages/vue-2/src/EditorContent.ts index b1a8817e7..4ccffe6e6 100644 --- a/packages/vue-2/src/EditorContent.ts +++ b/packages/vue-2/src/EditorContent.ts @@ -1,11 +1,10 @@ import Vue, { PropType, Component } from 'vue' import { Editor } from './Editor' -interface EditorContentInterface extends Vue { - editor: Editor +export interface EditorContentInterface extends Vue { + editor: Editor, } -/** @this Component */ export const EditorContent: Component = { name: 'EditorContent', @@ -46,8 +45,7 @@ export const EditorContent: Component = { return createElement('div') }, - beforeDestroy() { - // @ts-ignore + beforeDestroy(this: EditorContentInterface) { const { editor } = this if (!editor.isDestroyed) { diff --git a/packages/vue-2/src/FloatingMenu.ts b/packages/vue-2/src/FloatingMenu.ts index 52619f1ab..40e380731 100644 --- a/packages/vue-2/src/FloatingMenu.ts +++ b/packages/vue-2/src/FloatingMenu.ts @@ -1,9 +1,9 @@ import Vue, { Component, PropType } from 'vue' import { FloatingMenuPlugin, FloatingMenuPluginKey, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu' -interface FloatingMenuInterface extends Vue { +export interface FloatingMenuInterface extends Vue { tippyOptions: FloatingMenuPluginProps['tippyOptions'], - editor: FloatingMenuPluginProps['editor'] + editor: FloatingMenuPluginProps['editor'], } export const FloatingMenu: Component = { diff --git a/packages/vue-2/src/NodeViewContent.ts b/packages/vue-2/src/NodeViewContent.ts index 251102546..8df7a8618 100644 --- a/packages/vue-2/src/NodeViewContent.ts +++ b/packages/vue-2/src/NodeViewContent.ts @@ -1,7 +1,7 @@ import Vue, { Component } from 'vue' -interface NodeViewContentInterface extends Vue { - as: string +export interface NodeViewContentInterface extends Vue { + as: string, } export const NodeViewContent: Component = { diff --git a/packages/vue-2/src/NodeViewWrapper.ts b/packages/vue-2/src/NodeViewWrapper.ts index c8c2563da..4a14ce00e 100644 --- a/packages/vue-2/src/NodeViewWrapper.ts +++ b/packages/vue-2/src/NodeViewWrapper.ts @@ -1,13 +1,11 @@ import Vue, { Component } from 'vue' -interface DecorationClass { - value: string -} - -interface NodeViewWrapperInterface extends Vue { +export interface NodeViewWrapperInterface extends Vue { as: string, - decorationClasses: DecorationClass, - onDragStart: Function + decorationClasses: { + value: string, + }, + onDragStart: Function, } export const NodeViewWrapper: Component = { diff --git a/packages/vue-2/src/VueNodeViewRenderer.ts b/packages/vue-2/src/VueNodeViewRenderer.ts index cd23b4724..210e12574 100644 --- a/packages/vue-2/src/VueNodeViewRenderer.ts +++ b/packages/vue-2/src/VueNodeViewRenderer.ts @@ -42,7 +42,7 @@ export const nodeViewProps = { }, } -interface VueNodeViewRendererOptions { +export interface VueNodeViewRendererOptions { stopEvent: ((event: Event) => boolean) | null, update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null, }