Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

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

Dimitris Zervasc2528c57f038
diff --git a/web/src/components/MemoEditor/Editor/index.tsx b/web/src/components/MemoEditor/Editor/index.tsx
index 2d48f6c6f..193815578 100644
--- a/web/src/components/MemoEditor/Editor/index.tsx
+++ b/web/src/components/MemoEditor/Editor/index.tsx
@@ -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);
}