mirror of
https://github.com/facebook/lexical.git
synced 2025-05-21 17:17:16 +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 type {NodeKey} from './OutlineNode';
|
||||||
|
|
||||||
import {isTextNode, TextNode} from '.';
|
import {isTextNode, TextNode, isLineBreakNode} from '.';
|
||||||
import {
|
import {
|
||||||
OutlineNode,
|
OutlineNode,
|
||||||
getNodeByKey,
|
getNodeByKey,
|
||||||
@ -215,7 +215,12 @@ export class BlockNode extends OutlineNode {
|
|||||||
updateDirectionIfNeeded(writableNodeToAppend);
|
updateDirectionIfNeeded(writableNodeToAppend);
|
||||||
}
|
}
|
||||||
// Handle immutable/segmented
|
// 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);
|
wrapInTextNodes(writableNodeToAppend);
|
||||||
}
|
}
|
||||||
return writableSelf;
|
return writableSelf;
|
||||||
|
@ -14,6 +14,7 @@ import type {Node as ReactNode} from 'react';
|
|||||||
import {
|
import {
|
||||||
createTextNode,
|
createTextNode,
|
||||||
isBlockNode,
|
isBlockNode,
|
||||||
|
isLineBreakNode,
|
||||||
isTextNode,
|
isTextNode,
|
||||||
isRootNode,
|
isRootNode,
|
||||||
BlockNode,
|
BlockNode,
|
||||||
@ -155,7 +156,12 @@ function replaceNode<N: OutlineNode>(
|
|||||||
updateDirectionIfNeeded(writableReplaceWith);
|
updateDirectionIfNeeded(writableReplaceWith);
|
||||||
}
|
}
|
||||||
// Handle immutable/segmented
|
// 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);
|
wrapInTextNodes(writableReplaceWith);
|
||||||
}
|
}
|
||||||
if (isTextNode(writableReplaceWith) && anchorOffset !== undefined) {
|
if (isTextNode(writableReplaceWith) && anchorOffset !== undefined) {
|
||||||
@ -628,7 +634,12 @@ export class OutlineNode {
|
|||||||
updateDirectionIfNeeded(writableNodeToInsert);
|
updateDirectionIfNeeded(writableNodeToInsert);
|
||||||
}
|
}
|
||||||
// Handle immutable/segmented
|
// 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);
|
wrapInTextNodes(writableNodeToInsert);
|
||||||
}
|
}
|
||||||
return writableSelf;
|
return writableSelf;
|
||||||
@ -663,7 +674,12 @@ export class OutlineNode {
|
|||||||
updateDirectionIfNeeded(writableNodeToInsert);
|
updateDirectionIfNeeded(writableNodeToInsert);
|
||||||
}
|
}
|
||||||
// Handle immutable/segmented
|
// 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);
|
wrapInTextNodes(writableNodeToInsert);
|
||||||
}
|
}
|
||||||
return writableSelf;
|
return writableSelf;
|
||||||
|
@ -40,5 +40,10 @@
|
|||||||
"38": "findIndexInPrevChildren: index in prevChildren not found",
|
"38": "findIndexInPrevChildren: index in prevChildren not found",
|
||||||
"39": "reconcileNodeChildren: keyToMove to was not nextStartKey",
|
"39": "reconcileNodeChildren: keyToMove to was not nextStartKey",
|
||||||
"40": "storeDOMWithNodeKey: key was null",
|
"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