refactoring

This commit is contained in:
Philipp Kühn
2021-05-04 11:03:11 +02:00
parent a96e0c2816
commit 0e1d6d41fe
6 changed files with 18 additions and 22 deletions

View File

@@ -1,9 +1,9 @@
import Vue, { Component, PropType } from 'vue' import Vue, { Component, PropType } from 'vue'
import { BubbleMenuPlugin, BubbleMenuPluginKey, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu' import { BubbleMenuPlugin, BubbleMenuPluginKey, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
interface BubleMenuInterface extends Vue { export interface BubbleMenuInterface extends Vue {
tippyOptions: BubbleMenuPluginProps['tippyOptions'], tippyOptions: BubbleMenuPluginProps['tippyOptions'],
editor: BubbleMenuPluginProps['editor'] editor: BubbleMenuPluginProps['editor'],
} }
export const BubbleMenu: Component = { export const BubbleMenu: Component = {
@@ -24,7 +24,7 @@ export const BubbleMenu: Component = {
watch: { watch: {
editor: { editor: {
immediate: true, immediate: true,
handler(this: BubleMenuInterface, editor: BubbleMenuPluginProps['editor']) { handler(this: BubbleMenuInterface, editor: BubbleMenuPluginProps['editor']) {
if (!editor) { if (!editor) {
return 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) return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default)
}, },
beforeDestroy(this: BubleMenuInterface) { beforeDestroy(this: BubbleMenuInterface) {
this.editor.unregisterPlugin(BubbleMenuPluginKey) this.editor.unregisterPlugin(BubbleMenuPluginKey)
}, },
} }

View File

@@ -1,11 +1,10 @@
import Vue, { PropType, Component } from 'vue' import Vue, { PropType, Component } from 'vue'
import { Editor } from './Editor' import { Editor } from './Editor'
interface EditorContentInterface extends Vue { export interface EditorContentInterface extends Vue {
editor: Editor editor: Editor,
} }
/** @this Component */
export const EditorContent: Component = { export const EditorContent: Component = {
name: 'EditorContent', name: 'EditorContent',
@@ -46,8 +45,7 @@ export const EditorContent: Component = {
return createElement('div') return createElement('div')
}, },
beforeDestroy() { beforeDestroy(this: EditorContentInterface) {
// @ts-ignore
const { editor } = this const { editor } = this
if (!editor.isDestroyed) { if (!editor.isDestroyed) {

View File

@@ -1,9 +1,9 @@
import Vue, { Component, PropType } from 'vue' import Vue, { Component, PropType } from 'vue'
import { FloatingMenuPlugin, FloatingMenuPluginKey, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu' import { FloatingMenuPlugin, FloatingMenuPluginKey, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'
interface FloatingMenuInterface extends Vue { export interface FloatingMenuInterface extends Vue {
tippyOptions: FloatingMenuPluginProps['tippyOptions'], tippyOptions: FloatingMenuPluginProps['tippyOptions'],
editor: FloatingMenuPluginProps['editor'] editor: FloatingMenuPluginProps['editor'],
} }
export const FloatingMenu: Component = { export const FloatingMenu: Component = {

View File

@@ -1,7 +1,7 @@
import Vue, { Component } from 'vue' import Vue, { Component } from 'vue'
interface NodeViewContentInterface extends Vue { export interface NodeViewContentInterface extends Vue {
as: string as: string,
} }
export const NodeViewContent: Component = { export const NodeViewContent: Component = {

View File

@@ -1,13 +1,11 @@
import Vue, { Component } from 'vue' import Vue, { Component } from 'vue'
interface DecorationClass { export interface NodeViewWrapperInterface extends Vue {
value: string
}
interface NodeViewWrapperInterface extends Vue {
as: string, as: string,
decorationClasses: DecorationClass, decorationClasses: {
onDragStart: Function value: string,
},
onDragStart: Function,
} }
export const NodeViewWrapper: Component = { export const NodeViewWrapper: Component = {

View File

@@ -42,7 +42,7 @@ export const nodeViewProps = {
}, },
} }
interface VueNodeViewRendererOptions { export interface VueNodeViewRendererOptions {
stopEvent: ((event: Event) => boolean) | null, stopEvent: ((event: Event) => boolean) | null,
update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null, update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null,
} }