feat: automatically add a new table row in the editor when pressing enter (#4706)

Automatically add a new table row in the editor when pressing enter
pull/4713/head
Dimitris Zervas 1 month ago committed by GitHub
parent 72babbb393
commit c2528c57f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -192,7 +192,19 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef<
} else if (lastNode.type === NodeType.ORDERED_LIST_ITEM) {
const { number } = lastNode.orderedListItemNode as OrderedListItemNode;
insertText += `${Number(number) + 1}. `;
} else if (lastNode.type === NodeType.TABLE) {
const columns = lastNode.tableNode?.header.length;
if (!columns) {
return;
}
insertText += "| ";
for (let i = 1; i < columns; i++) {
insertText += " | ";
}
insertText += " |";
}
if (insertText) {
editorActions.insertText(insertText);
}

Loading…
Cancel
Save