1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-02-26 18:45:22 +00:00

no indented title

This commit is contained in:
Nebel 2022-09-07 17:25:15 +09:00
parent a6ae92d66c
commit 6e1ef081b8

View file

@ -43,14 +43,11 @@ export default (props: {
editor.registerUpdateListener(() => editor.registerUpdateListener(() =>
editor.update(() => { editor.update(() => {
const root = $getRoot(); const root = $getRoot();
const lines = root const lines = root.getChildren().map((line, i) => {
.getChildren() if (i === 0) return line.getTextContent().trim();
.map( const indent = $isElementNode(line) ? line.getIndent() : 0;
(line) => return `${" ".repeat(indent)}${line.getTextContent()}`;
`${" ".repeat( });
$isElementNode(line) ? line.getIndent() : 0
)}${line.getTextContent()}`
);
const title = lines[0]; const title = lines[0];
const text = lines.join("\n"); const text = lines.join("\n");
props.onUpdatePage({ id: props.id, title: title ?? "", text }); props.onUpdatePage({ id: props.id, title: title ?? "", text });