mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Changes for #1234
This commit is contained in:
parent
6b42620ad3
commit
5251d85fef
1 changed files with 12 additions and 16 deletions
28
vendors/squire/build/squire-raw.js
vendored
28
vendors/squire/build/squire-raw.js
vendored
|
|
@ -1800,7 +1800,8 @@ function onKey(event) {
|
||||||
|
|
||||||
let key = event.key.toLowerCase(),
|
let key = event.key.toLowerCase(),
|
||||||
modifiers = '',
|
modifiers = '',
|
||||||
range = this.getSelection();
|
range = this.getSelection(),
|
||||||
|
root = this._root;
|
||||||
|
|
||||||
// We need to apply the backspace/delete handlers regardless of
|
// We need to apply the backspace/delete handlers regardless of
|
||||||
// control key modifiers.
|
// control key modifiers.
|
||||||
|
|
@ -1819,13 +1820,13 @@ function onKey(event) {
|
||||||
// Record undo checkpoint.
|
// Record undo checkpoint.
|
||||||
this.saveUndoState(range);
|
this.saveUndoState(range);
|
||||||
// Delete the selection
|
// Delete the selection
|
||||||
deleteContentsOfRange(range, this._root);
|
deleteContentsOfRange(range, root);
|
||||||
this._ensureBottomLine();
|
this._ensureBottomLine();
|
||||||
this.setSelection(range);
|
this.setSelection(range);
|
||||||
this._updatePath(range, true);
|
this._updatePath(range, true);
|
||||||
} else if (range.collapsed
|
} else if (range.collapsed
|
||||||
&& range.startContainer === this._root
|
&& range.startContainer === root
|
||||||
&& this._root.children.length > 0) {
|
&& root.children.length > 0) {
|
||||||
|
|
||||||
// Under certain conditions, cursor/range can be positioned directly
|
// Under certain conditions, cursor/range can be positioned directly
|
||||||
// under this._root (not wrapped) and when this happens, an inline(TEXT)
|
// under this._root (not wrapped) and when this happens, an inline(TEXT)
|
||||||
|
|
@ -1836,25 +1837,20 @@ function onKey(event) {
|
||||||
// Therefor, we try to detect this case here and wrap the cursor/range
|
// Therefor, we try to detect this case here and wrap the cursor/range
|
||||||
// before the text is inserted.
|
// before the text is inserted.
|
||||||
|
|
||||||
const nextElement = this._root.children[range.startOffset];
|
const nextElement = root.children[range.startOffset];
|
||||||
if (nextElement.tagName === blockTag
|
if (nextElement && !isBlock(nextElement)) {
|
||||||
&& nextElement.children.length === 1
|
|
||||||
&& nextElement.children[0].tagName === 'BR') {
|
|
||||||
// this is a suitable '<div<br></div>' wrapper, move selection to here
|
|
||||||
range = createRange(nextElement, 0);
|
|
||||||
} else {
|
|
||||||
// create a new wrapper
|
// create a new wrapper
|
||||||
range = createRange(this._root.insertBefore(
|
range = createRange(root.insertBefore(
|
||||||
this.createDefaultBlock(), nextElement
|
this.createDefaultBlock(), nextElement
|
||||||
), 0);
|
), 0);
|
||||||
if (nextElement.tagName === 'BR') {
|
if (nextElement.tagName === 'BR') {
|
||||||
// delete it because a new <br> is created by createDefaultBlock()
|
// delete it because a new <br> is created by createDefaultBlock()
|
||||||
this._root.removeChild(nextElement);
|
root.removeChild(nextElement);
|
||||||
}
|
}
|
||||||
|
const restore = this._restoreSelection;
|
||||||
|
this.setSelection(range);
|
||||||
|
this._restoreSelection = restore;
|
||||||
}
|
}
|
||||||
const restore = this._restoreSelection;
|
|
||||||
this.setSelection(range);
|
|
||||||
this._restoreSelection = restore;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue