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.

fix: automatic indentation follows previous lines in lists (#4048) (#4050)

new-aspectaa9649adf0fc
diff --git a/web/src/components/MemoEditor/Editor/index.tsx b/web/src/components/MemoEditor/Editor/index.tsx
index fa56b7299..749b70687 100644
--- a/web/src/components/MemoEditor/Editor/index.tsx
+++ b/web/src/components/MemoEditor/Editor/index.tsx
@@ -164,7 +164,11 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef<
return;
}
- let insertText = "";
+ // Get the indentation of the previous line
+ const lines = prevContent.split("\n");
+ const lastLine = lines[lines.length - 1];
+ const indentationMatch = lastLine.match(/^\s*/);
+ let insertText = indentationMatch ? indentationMatch[0] : ""; // Keep the indentation of the previous line
if (lastNode.type === NodeType.TASK_LIST_ITEM) {
const { symbol } = lastNode.taskListItemNode as TaskListItemNode;
insertText = `${symbol} [ ] `;