Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Added blank paragraph insertion when selecting unsplash/gif image
Browse files Browse the repository at this point in the history
refs TryGhost/Product#1225

- provides a more obvious continuation point after selecting an image
- added `scrollIntoView` option to `addParagraphAfterCard()` because for large images the cursor in the new paragraph could be pushed out of the visible area
  • Loading branch information
kevinansfield committed Nov 30, 2021
1 parent 6f41382 commit a30e8b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/koenig-editor/addon/components/koenig-card-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ export default Component.extend({
// create undo snapshot when selecting an image
this.editor.run(() => {
saveCard(payload, false);
this.addParagraphAfterCard({scrollIntoView: true});
});
this.deselectCard();
this.selectCard();
this.scrollToCard();
},

closeImageSelector(reselectParagraph = true) {
Expand Down
6 changes: 5 additions & 1 deletion lib/koenig-editor/addon/components/koenig-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ export default Component.extend({
}
},

addParagraphAfterCard(card) {
addParagraphAfterCard(card, {scrollIntoView = false}) {
let editor = this.editor;
let section = this.getSectionFromCard(card);
let collection = section.parent.sections;
Expand All @@ -700,6 +700,10 @@ export default Component.extend({

postEditor.setRange(newPara.tailPosition());
});

if (scrollIntoView) {
run.schedule('afterRender', this, this._scrollCursorIntoView);
}
},

openSelectorComponent(componentName, range) {
Expand Down

0 comments on commit a30e8b1

Please sign in to comment.