mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
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
This commit is contained in:
@@ -192,7 +192,19 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef<
|
|||||||
} else if (lastNode.type === NodeType.ORDERED_LIST_ITEM) {
|
} else if (lastNode.type === NodeType.ORDERED_LIST_ITEM) {
|
||||||
const { number } = lastNode.orderedListItemNode as OrderedListItemNode;
|
const { number } = lastNode.orderedListItemNode as OrderedListItemNode;
|
||||||
insertText += `${Number(number) + 1}. `;
|
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) {
|
if (insertText) {
|
||||||
editorActions.insertText(insertText);
|
editorActions.insertText(insertText);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user