From 499bc16120a821b27f7b7180da40ca9cc153d28e Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Thu, 9 Feb 2023 13:36:00 +0000 Subject: [PATCH] Ensure deletions capture existing formatting (#3867) --- packages/lexical/src/LexicalSelection.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/lexical/src/LexicalSelection.ts b/packages/lexical/src/LexicalSelection.ts index a4d18bca35a..8457d3ca483 100644 --- a/packages/lexical/src/LexicalSelection.ts +++ b/packages/lexical/src/LexicalSelection.ts @@ -2032,6 +2032,11 @@ export class RangeSelection implements BaseSelection { anchorNode.collapseAtStart(this); } } + const anchorNode = this.anchor.getNode(); + if ($isTextNode(anchorNode)) { + this.format = anchorNode.getFormat(); + this.style = anchorNode.getStyle(); + } } deleteLine(isBackward: boolean): void {