fixes vue 3 custom node views when using class components (#5410)

This commit is contained in:
wagich 2024-08-07 15:08:42 +02:00 committed by GitHub
parent 535dcccb40
commit be63e59050
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/vue-3": patch
---
fix vue3 class components not working as node views

View File

@ -221,7 +221,12 @@ export function VueNodeViewRenderer(
if (!(props.editor as Editor).contentComponent) {
return {}
}
// check for class-component and normalize if neccessary
const normalizedComponent = typeof component === 'function' && '__vccOpts' in component
// eslint-disable-next-line no-underscore-dangle
? component.__vccOpts as Component
: component
return new VueNodeView(component, props, options) as unknown as ProseMirrorNodeView
return new VueNodeView(normalizedComponent, props, options) as unknown as ProseMirrorNodeView
}
}