From 64952806b91826bcc6e18eaafb7c43ee464e74b4 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:21:46 +0800 Subject: [PATCH] fix: slate cannot get the start point in the node at path [0] --- libs/components/common/src/lib/text/slate-utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/components/common/src/lib/text/slate-utils.ts b/libs/components/common/src/lib/text/slate-utils.ts index 43a47ad85f..ec7e219810 100644 --- a/libs/components/common/src/lib/text/slate-utils.ts +++ b/libs/components/common/src/lib/text/slate-utils.ts @@ -605,6 +605,11 @@ class SlateUtils { } textChildren.push(child); } + // If nothing, should preserve empty string + // Fix Slate Cannot get the start point in the node at path [0] because it has no start text node. + if (!textChildren.length) { + textChildren.push({ text: '' }); + } return textChildren; }