refactor: use the faster .eq method for determining equality

This commit is contained in:
Nick the Sick 2024-05-31 15:53:16 +02:00 committed by Nick Perez
parent aee15c2874
commit f4a7dbaf5c

View File

@ -1,8 +1,11 @@
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
export function isNodeEmpty(node: ProseMirrorNode): boolean {
const defaultContent = node.type.createAndFill()?.toJSON()
const content = node.toJSON()
const defaultContent = node.type.createAndFill()
return JSON.stringify(defaultContent) === JSON.stringify(content)
if (!defaultContent) {
return false
}
return node.eq(defaultContent)
}