From 9f5df9e5c03c8a263c4ab6ac886630b81abfff59 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Wed, 27 Sep 2023 14:56:00 +1000 Subject: [PATCH] Fix format intent lost after pressing Space On Chrome, if you made an inline formatting change, this would insert a new with a ZWS inside so we could focus it. Pressing Space would remove this ZWS resulting in the focus ending up outside and so the formatting would be lost. We were removing the ZWS so we could check if we were at a block boundary correctly; instead, I've made it so the boundary check can handle trailing or leading ZWS (see previous commit). --- source/keyboard/Space.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/keyboard/Space.ts b/source/keyboard/Space.ts index 5abf545..1ec8e31 100644 --- a/source/keyboard/Space.ts +++ b/source/keyboard/Space.ts @@ -18,7 +18,6 @@ const Space = (self: Squire, event: KeyboardEvent, range: Range): void => { const root = self._root; self._recordUndoState(range); self._getRangeAndRemoveBookmark(range); - self._removeZWS(); // Delete the selection if not collapsed if (!range.collapsed) { @@ -29,7 +28,7 @@ const Space = (self: Squire, event: KeyboardEvent, range: Range): void => { } else if (rangeDoesEndAtBlockBoundary(range, root)) { const block = getStartBlockOfRange(range, root); if (block && block.nodeName !== 'PRE') { - const text = block.textContent?.trimEnd(); + const text = block.textContent?.trimEnd().replace(ZWS, ''); if (text === '*' || text === '1.') { event.preventDefault(); const walker = new TreeIterator(block, SHOW_TEXT);