mirror of
https://github.com/kou029w/quot.git
synced 2025-01-31 06:18:01 +00:00
LFのみ残り続ける問題を修正
This commit is contained in:
parent
887eafef4d
commit
3ea90fbd06
1 changed files with 6 additions and 2 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue