diff --git a/packages/outline/src/core/OutlineBlockNode.js b/packages/outline/src/core/OutlineBlockNode.js index 3212a5125..ae7ce3c75 100644 --- a/packages/outline/src/core/OutlineBlockNode.js +++ b/packages/outline/src/core/OutlineBlockNode.js @@ -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; diff --git a/packages/outline/src/core/OutlineNode.js b/packages/outline/src/core/OutlineNode.js index e290ca2b8..dd8728fb6 100644 --- a/packages/outline/src/core/OutlineNode.js +++ b/packages/outline/src/core/OutlineNode.js @@ -14,6 +14,7 @@ import type {Node as ReactNode} from 'react'; import { createTextNode, isBlockNode, + isLineBreakNode, isTextNode, isRootNode, BlockNode, @@ -155,7 +156,12 @@ function replaceNode( 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; diff --git a/scripts/error-codes/codes.json b/scripts/error-codes/codes.json index fb628cc6a..7d8dd7b0d 100644 --- a/scripts/error-codes/codes.json +++ b/scripts/error-codes/codes.json @@ -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" }