Koenig - Fixed UP or LEFT on a blank list item jumping cursor to title

refs https://github.com/TryGhost/Ghost/issues/9505
- ListItem sections have a parent rather than a prev section so we need to look for a section before the parent section when determining if the cursor is at the beginning of the doc for <kbd>Up</kbd> and <kbd>Left</kbd> key handling
This commit is contained in:
Kevin Ansfield 2018-04-10 11:26:22 +01:00
parent 4519ccd087
commit d6a6fc3d7c

View File

@ -595,8 +595,9 @@ export default Component.extend({
// the doc
handleUpKey(editor) {
let {isCollapsed, head: {offset, section}} = editor.range;
let prevSection = section.isListItem ? section.parent.prev : section.prev;
if (isCollapsed && !section.prev && offset === 0) {
if (isCollapsed && offset === 0 && !prevSection) {
this.cursorDidExitAtTop();
}
@ -608,7 +609,8 @@ export default Component.extend({
// trigger a closure action to indicate that the caret "left" the top of
// the editor canvas if the caret is at the very beginning of the doc
if (isCollapsed && !section.prev && offset === 0) {
let prevSection = section.isListItem ? section.parent.prev : section.prev;
if (isCollapsed && offset === 0 && !prevSection) {
this.cursorDidExitAtTop();
return;
}