Skip to content

Commit

Permalink
fix: maybe move content dom on update, see ueberdosis#1370
Browse files Browse the repository at this point in the history
  • Loading branch information
philippkuehn committed May 28, 2021
1 parent e1b450a commit 3a329d7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/ReactNodeViewRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor> {
return null
}

this.maybeMoveContentDOM()

return this.contentDOMElement
}

maybeMoveContentDOM(): void {
const contentElement = this.dom.querySelector('[data-node-view-content]')

if (
Expand All @@ -100,8 +106,6 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor> {
) {
contentElement.appendChild(this.contentDOMElement)
}

return this.contentDOMElement
}

update(node: ProseMirrorNode, decorations: Decoration[]) {
Expand All @@ -117,6 +121,7 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor> {
return true
}

this.maybeMoveContentDOM()
this.node = node
this.decorations = decorations
this.renderer.updateProps({ node, decorations })
Expand Down

0 comments on commit 3a329d7

Please sign in to comment.