fix: Incorrect empty check for collection description results in large empty space below title

This commit is contained in:
Tom Moor
2024-05-30 18:46:03 -04:00
parent 6920f13ae4
commit 1f980050ca
2 changed files with 32 additions and 1 deletions

View File

@@ -52,6 +52,30 @@ export class ProsemirrorHelper {
};
}
/**
* Returns true if the data looks like an empty document.
*
* @param data The ProsemirrorData to check.
* @returns True if the document is empty.
*/
static isEmptyData(data: ProsemirrorData): boolean {
if (data.type !== "doc") {
return false;
}
if (data.content.length === 1) {
const node = data.content[0];
return (
node.type === "paragraph" &&
(node.content === null ||
node.content === undefined ||
node.content.length === 0)
);
}
return data.content.length === 0;
}
/**
* Returns the node as plain text.
*