mirror of
https://github.com/kou029w/quot.git
synced 2025-02-26 10:35:20 +00:00
no indented title
This commit is contained in:
parent
a6ae92d66c
commit
6e1ef081b8
1 changed files with 5 additions and 8 deletions
|
@ -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 });
|
||||
|
|
Loading…
Add table
Reference in a new issue