0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Koenig - Fixed backspace not deleting empty para at beginning of doc

refs https://github.com/TryGhost/Ghost/issues/9311
- something that became apparent after adding the "<kbd>Enter</kbd> in post title adds blank paragraph" feature was that using that feature left you in a position where Backspace doesn't do what you expect - it does nothing rather than deleting the blank paragraph
- added logic to the `handleBackspaceKey` handler in `{{koenig-editor}}` to detect when backspace is pressed on a blank paragraph at the start of the doc so that we remove it then focus the title
This commit is contained in:
Kevin Ansfield 2018-03-14 16:13:33 +00:00
parent d7bae46f5c
commit 6e5710364e

View file

@ -528,6 +528,20 @@ export default Component.extend({
return;
}
// if the caret is at the beginning of the doc, on a blank para, and
// there are more sections then delete the para and trigger the
// `cursorDidExitAtTop` closure action
let isFirstSection = section === section.parent.sections.head;
if (isFirstSection && isCollapsed && offset === 0 && (section.isBlank || section.text === '') && section.next) {
this.editor.run((postEditor) => {
postEditor.removeSection(section);
});
// allow default behaviour which will trigger `cursorDidChange` and
// fire our `cursorDidExitAtTop` action
return;
}
// if the section about to be deleted by a backspace is a card then
// actually delete the card rather than selecting it.
// However, if the current paragraph is blank then delete the paragraph