Unverified Commit aa9649ad authored by new-aspect's avatar new-aspect Committed by GitHub

fix: automatic indentation follows previous lines in lists (#4048) (#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
parent 2851f113
...@@ -164,7 +164,11 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef< ...@@ -164,7 +164,11 @@ const Editor = forwardRef(function Editor(props: Props, ref: React.ForwardedRef<
return; 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) { if (lastNode.type === NodeType.TASK_LIST_ITEM) {
const { symbol } = lastNode.taskListItemNode as TaskListItemNode; const { symbol } = lastNode.taskListItemNode as TaskListItemNode;
insertText = `${symbol} [ ] `; insertText = `${symbol} [ ] `;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment