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:
parent
c81b39e942
commit
6cbf03f7f4
|
@ -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);
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue