Card creation and deletion bugs. (#664)

closes https://github.com/TryGhost/Ghost/issues/8312
- all new cards created now enter in selected mode and if enabled edit mode.
- if deleting cards places the cursor in an empty section the '+' menu is placed AFTER the card is deleted which ensures it's placed in the correct location
This commit is contained in:
Ryan McCarvill 2017-04-25 02:02:20 +12:00 committed by Kevin Ansfield
parent f2784ea372
commit 88209e8227
4 changed files with 11 additions and 13 deletions

View File

@ -42,6 +42,10 @@ export default Component.extend({
didReceiveAttrs() {
if (!this.get('isEditing')) {
this.set('preview', formatMarkdown([this.get('payload').markdown]));
} else {
run.next(() => {
this.$('textarea').focus();
});
}
},

View File

@ -363,18 +363,19 @@ export default Component.extend({
if (forwards && section.next) {
range = section.next.toRange();
range.tail.offset = 0;
editor.selectRange(range);
} else if (section.prev) {
range = section.prev.toRange();
range.head.offset = range.tail.offset;
editor.selectRange(range);
} else if (section.next) {
range = section.next.toRange();
range.tail.offset = 0;
editor.selectRange(range);
} else {
card.env.remove();
return;
}
card.env.remove();
editor.selectRange(range);
});
},
stopEditingCard() {

View File

@ -12,7 +12,7 @@ export default Component.extend({
this._super(...arguments);
let card = this.get('card');
if (card.newlyCreated) {
run.schedule('afterRender', this, () => {
run.next(() => {
if (card.card.launchMode === 'edit') {
this.send('startEdit');
this.send('selectCard');

View File

@ -73,10 +73,9 @@ export default Component.extend({
let $editor = $(this.get('containerSelector'));
input.blur(() => {
// nasty hack - give the tool time to execute before removing this from the dom.
window.setTimeout(() => {
run.later(() => {
this.send('closeMenuKeepButton');
}, 200);
}, 100);
});
editor.cursorDidChange(() => {
@ -107,13 +106,7 @@ export default Component.extend({
run.schedule('afterRender', this,
() => {
let button = this.$('.gh-cardmenu-button');
button.css('top', offset.top + $editor.scrollTop() - editorOffset.top - 2);
if (currentNode.tagName.toLowerCase() === 'li') {
// button.css('left', this.$(currentNode.parentNode).position().left + $editor.scrollLeft());
} else {
// button.css('left', offset.left + $editor.scrollLeft() - 50);
}
});
});
},