1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-01-31 06:18:01 +00:00

LFのみ残り続ける問題を修正

This commit is contained in:
Nebel 2022-08-29 12:24:40 +09:00
parent 887eafef4d
commit 3ea90fbd06

View file

@ -1,4 +1,5 @@
import {
$createLineBreakNode,
$createParagraphNode,
$createTextNode,
$getRoot,
@ -25,8 +26,11 @@ export default (props: {
const root = $getRoot();
if (root.getFirstChild()) return;
const paragraphNode = $createParagraphNode();
const textNode = $createTextNode(props.text);
paragraphNode.append(textNode);
const text = props.text
.split("\n")
.flatMap((line) => [$createTextNode(line), $createLineBreakNode()])
.slice(0, -1);
paragraphNode.append(...text);
root.append(paragraphNode);
};
onCleanup(registerPlainText(editor, initialEditorState));