mirror of
https://github.com/kou029w/quot.git
synced 2025-01-31 14:28:06 +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 {
|
import {
|
||||||
|
$createLineBreakNode,
|
||||||
$createParagraphNode,
|
$createParagraphNode,
|
||||||
$createTextNode,
|
$createTextNode,
|
||||||
$getRoot,
|
$getRoot,
|
||||||
|
@ -25,8 +26,11 @@ export default (props: {
|
||||||
const root = $getRoot();
|
const root = $getRoot();
|
||||||
if (root.getFirstChild()) return;
|
if (root.getFirstChild()) return;
|
||||||
const paragraphNode = $createParagraphNode();
|
const paragraphNode = $createParagraphNode();
|
||||||
const textNode = $createTextNode(props.text);
|
const text = props.text
|
||||||
paragraphNode.append(textNode);
|
.split("\n")
|
||||||
|
.flatMap((line) => [$createTextNode(line), $createLineBreakNode()])
|
||||||
|
.slice(0, -1);
|
||||||
|
paragraphNode.append(...text);
|
||||||
root.append(paragraphNode);
|
root.append(paragraphNode);
|
||||||
};
|
};
|
||||||
onCleanup(registerPlainText(editor, initialEditorState));
|
onCleanup(registerPlainText(editor, initialEditorState));
|
||||||
|
|
Loading…
Add table
Reference in a new issue