From 6e1ef081b890c2755c70d4e5d48b305776db20a2 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Wed, 7 Sep 2022 17:25:15 +0900 Subject: [PATCH] no indented title --- app/views/components/editor.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/views/components/editor.tsx b/app/views/components/editor.tsx index 42a0654..f7ab74b 100644 --- a/app/views/components/editor.tsx +++ b/app/views/components/editor.tsx @@ -43,14 +43,11 @@ export default (props: { editor.registerUpdateListener(() => editor.update(() => { const root = $getRoot(); - const lines = root - .getChildren() - .map( - (line) => - `${" ".repeat( - $isElementNode(line) ? line.getIndent() : 0 - )}${line.getTextContent()}` - ); + const lines = root.getChildren().map((line, i) => { + if (i === 0) return line.getTextContent().trim(); + const indent = $isElementNode(line) ? line.getIndent() : 0; + return `${" ".repeat(indent)}${line.getTextContent()}`; + }); const title = lines[0]; const text = lines.join("\n"); props.onUpdatePage({ id: props.id, title: title ?? "", text });