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:
parent
a6ae92d66c
commit
6e1ef081b8
1 changed files with 5 additions and 8 deletions
|
@ -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 });
|
||||||
|
|
Loading…
Add table
Reference in a new issue