mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Fix format intent lost after pressing Space
On Chrome, if you made an inline formatting change, this would insert a new <span> 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).
This commit is contained in:
parent
2d37608aac
commit
9f5df9e5c0
1 changed files with 1 additions and 2 deletions
|
@ -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<Text>(block, SHOW_TEXT);
|
||||
|
|
Loading…
Reference in a new issue