Koenig - Fixed card deselection when cursor exits top of doc

refs https://github.com/TryGhost/Ghost/issues/9623
- add a `exitCursorAtTop` action to `{{koenig-editor}}` that will deselect any cards before calling the closure action
- check if the we're on a card section when pressing UP or LEFT so that the cursor being before/after the card doesn't trip up the logic
This commit is contained in:
Kevin Ansfield 2018-05-23 14:49:39 +01:00
parent c81b39e942
commit 6cbf03f7f4
2 changed files with 12 additions and 4 deletions

View File

@ -371,6 +371,14 @@ export default Component.extend({
},
actions: {
exitCursorAtTop() {
if (this.selectedCard) {
this.deselectCard(this.selectedCard);
}
this.cursorDidExitAtTop();
},
toggleMarkup(markupTagName, postEditor) {
(postEditor || this.editor).toggleMarkup(markupTagName);
},

View File

@ -182,8 +182,8 @@ export const DEFAULT_KEY_COMMANDS = [{
let {isCollapsed, head: {offset, section}} = editor.range;
let prevSection = section.isListItem ? section.parent.prev : section.prev;
if (isCollapsed && offset === 0 && !prevSection) {
koenig.cursorDidExitAtTop();
if (isCollapsed && (offset === 0 || section.isCardSection) && !prevSection) {
koenig.send('exitCursorAtTop');
}
return false;
@ -196,8 +196,8 @@ export const DEFAULT_KEY_COMMANDS = [{
// 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
let prevSection = section.isListItem ? section.parent.prev : section.prev;
if (isCollapsed && offset === 0 && !prevSection) {
koenig.cursorDidExitAtTop();
if (isCollapsed && (offset === 0 || section.isCardSection) && !prevSection) {
koenig.send('exitCursorAtTop');
return;
}