Skip to content

Commit

Permalink
fix: automatic indentation follows previous lines in lists (#4048) (#…
Browse files Browse the repository at this point in the history
…4050)

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

* fix: automatic indentation follows previous lines in lists (#4048)
change the position of this logic and recommit it
  • Loading branch information
new-aspect authored Oct 25, 2024
1 parent 2851f11 commit aa9649a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion web/src/components/MemoEditor/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} [ ] `;
Expand Down

0 comments on commit aa9649a

Please sign in to comment.