mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-15 03:08:15 +08:00
parent
039e2252de
commit
9198ce187b
1 changed files with 21 additions and 29 deletions
40
vendors/squire/build/squire-raw.js
vendored
40
vendors/squire/build/squire-raw.js
vendored
|
@ -1420,10 +1420,7 @@ const
|
||||||
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 === root && root.children.length > 0) {
|
||||||
&& range.startContainer === root
|
|
||||||
&& 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)
|
||||||
// element is attached directly to this._root. There might be other
|
// element is attached directly to this._root. There might be other
|
||||||
|
@ -1466,14 +1463,17 @@ const
|
||||||
let restoreAndDoEnter = () => {
|
let restoreAndDoEnter = () => {
|
||||||
self.removeEventListener('keyup', restoreAndDoEnter);
|
self.removeEventListener('keyup', restoreAndDoEnter);
|
||||||
self._setHTML(html);
|
self._setHTML(html);
|
||||||
range = self._getRangeAndRemoveBookmark();
|
|
||||||
// Ignore the shift key on iOS, as this is for auto-capitalisation.
|
// Ignore the shift key on iOS, as this is for auto-capitalisation.
|
||||||
handleEnter(self, false, range);
|
handleEnter(self, false, self._getRangeAndRemoveBookmark());
|
||||||
};
|
};
|
||||||
self.addEventListener('keyup', restoreAndDoEnter);
|
self.addEventListener('keyup', restoreAndDoEnter);
|
||||||
} : (self, event, range) => {
|
} : (self, event, range) => {
|
||||||
event.preventDefault();
|
self._recordUndoState(range, false);
|
||||||
handleEnter(self, event.shiftKey, range);
|
self._config.addLinks && addLinks(range.startContainer, self._root);
|
||||||
|
self._removeZWS();
|
||||||
|
self._getRangeAndRemoveBookmark(range);
|
||||||
|
// event.preventDefault();
|
||||||
|
// handleEnter(self, event.shiftKey, range);
|
||||||
},
|
},
|
||||||
|
|
||||||
'shift-enter': (self, event, range) => self._keyHandlers.enter(self, event, range),
|
'shift-enter': (self, event, range) => self._keyHandlers.enter(self, event, range),
|
||||||
|
@ -1647,7 +1647,7 @@ const
|
||||||
space: (self, _, range) => {
|
space: (self, _, range) => {
|
||||||
let root = self._root;
|
let root = self._root;
|
||||||
self._recordUndoState(range, false);
|
self._recordUndoState(range, false);
|
||||||
self._config.addLinks && addLinks(range.startContainer, root, self);
|
self._config.addLinks && addLinks(range.startContainer, root);
|
||||||
self._getRangeAndRemoveBookmark(range);
|
self._getRangeAndRemoveBookmark(range);
|
||||||
/*
|
/*
|
||||||
// If the cursor is at the end of a link (<a>foo|</a>) then move it
|
// If the cursor is at the end of a link (<a>foo|</a>) then move it
|
||||||
|
@ -1850,7 +1850,7 @@ const
|
||||||
// Remove any zws so we don't think there's content in an empty
|
// Remove any zws so we don't think there's content in an empty
|
||||||
// block.
|
// block.
|
||||||
self._recordUndoState(range, false);
|
self._recordUndoState(range, false);
|
||||||
self._config.addLinks && addLinks(range.startContainer, root, self);
|
self._config.addLinks && addLinks(range.startContainer, root);
|
||||||
self._removeZWS();
|
self._removeZWS();
|
||||||
self._getRangeAndRemoveBookmark(range);
|
self._getRangeAndRemoveBookmark(range);
|
||||||
|
|
||||||
|
@ -1934,8 +1934,7 @@ const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, split at cursor point.
|
// Otherwise, split at cursor point.
|
||||||
nodeAfterSplit = splitBlock(self, block,
|
nodeAfterSplit = splitBlock(self, block, range.startContainer, range.startOffset);
|
||||||
range.startContainer, range.startOffset);
|
|
||||||
|
|
||||||
// Clean up any empty inlines if we hit enter at the beginning of the block
|
// Clean up any empty inlines if we hit enter at the beginning of the block
|
||||||
removeZWS(block);
|
removeZWS(block);
|
||||||
|
@ -2546,16 +2545,10 @@ class Squire
|
||||||
// selection, you can end up in a state where you type but the input
|
// selection, you can end up in a state where you type but the input
|
||||||
// doesn't get directed into the contenteditable area but is instead
|
// doesn't get directed into the contenteditable area but is instead
|
||||||
// lost in a black hole. Very strange.
|
// lost in a black hole. Very strange.
|
||||||
if (isIOS) {
|
isIOS && win.focus();
|
||||||
win.focus();
|
|
||||||
}
|
|
||||||
let sel = win.getSelection();
|
let sel = win.getSelection();
|
||||||
sel.setBaseAndExtent(
|
sel.empty();
|
||||||
range.startContainer,
|
sel.addRange(range);
|
||||||
range.startOffset,
|
|
||||||
range.endContainer,
|
|
||||||
range.endOffset,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
this._restoreSelection = true;
|
this._restoreSelection = true;
|
||||||
}
|
}
|
||||||
|
@ -3300,8 +3293,7 @@ class Squire
|
||||||
this.editStack.clear();
|
this.editStack.clear();
|
||||||
|
|
||||||
// Record undo state
|
// Record undo state
|
||||||
let range = this._getRangeAndRemoveBookmark() ||
|
let range = this._getRangeAndRemoveBookmark() || createRange(root.firstChild, 0);
|
||||||
createRange(root.firstChild, 0);
|
|
||||||
this.saveUndoState(range);
|
this.saveUndoState(range);
|
||||||
// IE will also set focus when selecting text so don't use
|
// IE will also set focus when selecting text so don't use
|
||||||
// setSelection. Instead, just store it in lastSelection, so if
|
// setSelection. Instead, just store it in lastSelection, so if
|
||||||
|
@ -3387,7 +3379,7 @@ class Squire
|
||||||
try {
|
try {
|
||||||
let root = this._root, node = frag;
|
let root = this._root, node = frag;
|
||||||
|
|
||||||
addLinks(frag, frag, this);
|
addLinks(frag, frag);
|
||||||
cleanTree(frag);
|
cleanTree(frag);
|
||||||
cleanupBRs(frag, root, false);
|
cleanupBRs(frag, root, false);
|
||||||
removeEmptyInlines(frag);
|
removeEmptyInlines(frag);
|
||||||
|
|
Loading…
Reference in a new issue