mirror of
https://github.com/facebook/lexical.git
synced 2025-05-21 00:57:23 +08:00
Fix plain text (#463)
This commit is contained in:

committed by
acywatson

parent
1dc68ef05c
commit
fb3ce90eb0
@ -9,7 +9,7 @@
|
||||
|
||||
import type {NodeKey} from './OutlineNode';
|
||||
|
||||
import {isTextNode, TextNode} from '.';
|
||||
import {isTextNode, TextNode, isLineBreakNode} from '.';
|
||||
import {
|
||||
OutlineNode,
|
||||
getNodeByKey,
|
||||
@ -215,7 +215,12 @@ export class BlockNode extends OutlineNode {
|
||||
updateDirectionIfNeeded(writableNodeToAppend);
|
||||
}
|
||||
// Handle immutable/segmented
|
||||
if (flags & IS_IMMUTABLE || flags & IS_SEGMENTED || flags & IS_INERT) {
|
||||
if (
|
||||
flags & IS_IMMUTABLE ||
|
||||
flags & IS_SEGMENTED ||
|
||||
flags & IS_INERT ||
|
||||
isLineBreakNode(writableNodeToAppend)
|
||||
) {
|
||||
wrapInTextNodes(writableNodeToAppend);
|
||||
}
|
||||
return writableSelf;
|
||||
|
@ -14,6 +14,7 @@ import type {Node as ReactNode} from 'react';
|
||||
import {
|
||||
createTextNode,
|
||||
isBlockNode,
|
||||
isLineBreakNode,
|
||||
isTextNode,
|
||||
isRootNode,
|
||||
BlockNode,
|
||||
@ -155,7 +156,12 @@ function replaceNode<N: OutlineNode>(
|
||||
updateDirectionIfNeeded(writableReplaceWith);
|
||||
}
|
||||
// Handle immutable/segmented
|
||||
if (flags & IS_IMMUTABLE || flags & IS_SEGMENTED || flags & IS_INERT) {
|
||||
if (
|
||||
flags & IS_IMMUTABLE ||
|
||||
flags & IS_SEGMENTED ||
|
||||
flags & IS_INERT ||
|
||||
isLineBreakNode(writableReplaceWith)
|
||||
) {
|
||||
wrapInTextNodes(writableReplaceWith);
|
||||
}
|
||||
if (isTextNode(writableReplaceWith) && anchorOffset !== undefined) {
|
||||
@ -628,7 +634,12 @@ export class OutlineNode {
|
||||
updateDirectionIfNeeded(writableNodeToInsert);
|
||||
}
|
||||
// Handle immutable/segmented
|
||||
if (flags & IS_IMMUTABLE || flags & IS_SEGMENTED || flags & IS_INERT) {
|
||||
if (
|
||||
flags & IS_IMMUTABLE ||
|
||||
flags & IS_SEGMENTED ||
|
||||
flags & IS_INERT ||
|
||||
isLineBreakNode(writableNodeToInsert)
|
||||
) {
|
||||
wrapInTextNodes(writableNodeToInsert);
|
||||
}
|
||||
return writableSelf;
|
||||
@ -663,7 +674,12 @@ export class OutlineNode {
|
||||
updateDirectionIfNeeded(writableNodeToInsert);
|
||||
}
|
||||
// Handle immutable/segmented
|
||||
if (flags & IS_IMMUTABLE || flags & IS_SEGMENTED || flags & IS_INERT) {
|
||||
if (
|
||||
flags & IS_IMMUTABLE ||
|
||||
flags & IS_SEGMENTED ||
|
||||
flags & IS_INERT ||
|
||||
isLineBreakNode(writableNodeToInsert)
|
||||
) {
|
||||
wrapInTextNodes(writableNodeToInsert);
|
||||
}
|
||||
return writableSelf;
|
||||
|
@ -40,5 +40,10 @@
|
||||
"38": "findIndexInPrevChildren: index in prevChildren not found",
|
||||
"39": "reconcileNodeChildren: keyToMove to was not nextStartKey",
|
||||
"40": "storeDOMWithNodeKey: key was null",
|
||||
"41": "Reconciliation: could not find DOM element for node key \"${key}\""
|
||||
"41": "Reconciliation: could not find DOM element for node key \"${key}\"",
|
||||
"42": "getTextContent: base method not extended",
|
||||
"43": "decorate: base method not extended",
|
||||
"44": "getAnchorNode: anchorNode not a text or decorator node",
|
||||
"45": "getFocusNode: focusNode not a text or decorator node",
|
||||
"46": "undecorate: base method not extended"
|
||||
}
|
||||
|
Reference in New Issue
Block a user