Skip to content

Commit

Permalink
Make Vue 2 nodeViewProps compatible with @vue/composition-api (#4123
Browse files Browse the repository at this point in the history
)

* Add `vue-ts-types` as dependency for `@tiptap/vue-2`

* Use `vue-ts-types` for Vue 2 `nodeViewProps`

to make them compatible with `@vue/composition-api`
  • Loading branch information
FloEdelmann authored Jul 10, 2023
1 parent 15df913 commit c305944
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 36 deletions.
20 changes: 18 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/vue-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
],
"dependencies": {
"@tiptap/extension-bubble-menu": "^2.1.0-rc.11",
"@tiptap/extension-floating-menu": "^2.1.0-rc.11"
"@tiptap/extension-floating-menu": "^2.1.0-rc.11",
"vue-ts-types": "^1.6.0"
},
"devDependencies": {
"@tiptap/core": "^2.1.0-rc.11",
Expand Down
43 changes: 10 additions & 33 deletions packages/vue-2/src/VueNodeViewRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,21 @@ import {
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
import { Decoration, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view'
import Vue from 'vue'
import { PropType, VueConstructor } from 'vue/types/umd'
import { VueConstructor } from 'vue/types/umd'
import { booleanProp, functionProp, objectProp } from 'vue-ts-types'

import { Editor } from './Editor.js'
import { VueRenderer } from './VueRenderer.js'

export const nodeViewProps = {
editor: {
type: Object as PropType<NodeViewProps['editor']>,
required: true as const,
},
node: {
type: Object as PropType<NodeViewProps['node']>,
required: true as const,
},
decorations: {
type: Object as PropType<NodeViewProps['decorations']>,
required: true as const,
},
selected: {
type: Boolean as PropType<NodeViewProps['selected']>,
required: true as const,
},
extension: {
type: Object as PropType<NodeViewProps['extension']>,
required: true as const,
},
getPos: {
type: Function as PropType<NodeViewProps['getPos']>,
required: true as const,
},
updateAttributes: {
type: Function as PropType<NodeViewProps['updateAttributes']>,
required: true as const,
},
deleteNode: {
type: Function as PropType<NodeViewProps['deleteNode']>,
required: true as const,
},
editor: objectProp<NodeViewProps['editor']>().required,
node: objectProp<NodeViewProps['node']>().required,
decorations: objectProp<NodeViewProps['decorations']>().required,
selected: booleanProp().required,
extension: objectProp<NodeViewProps['extension']>().required,
getPos: functionProp<NodeViewProps['getPos']>().required,
updateAttributes: functionProp<NodeViewProps['updateAttributes']>().required,
deleteNode: functionProp<NodeViewProps['deleteNode']>().required,
}

export interface VueNodeViewRendererOptions extends NodeViewRendererOptions {
Expand Down

0 comments on commit c305944

Please sign in to comment.