mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
More autosave improvements
issue #4305, issue #4259, issue #1413 - change new->edit transitionToRoute to be replaceRoute - auto focus in the editor on transition to the edit route - change the one-time autosave to happen on codemirror focusin instead of title focusout - re-add removed tests, and reorder broken test
This commit is contained in:
parent
0f9342bf69
commit
768e335735
6 changed files with 21 additions and 9 deletions
|
@ -38,6 +38,14 @@ var onScrollHandler = function (cm) {
|
|||
};
|
||||
|
||||
var Codemirror = Ember.TextArea.extend(MarkerManager, {
|
||||
focus: true,
|
||||
|
||||
setFocus: function () {
|
||||
if (this.focus) {
|
||||
this.$().val(this.$().val()).focus();
|
||||
}
|
||||
}.on('didInsertElement'),
|
||||
|
||||
didInsertElement: function () {
|
||||
Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
|
||||
},
|
||||
|
@ -90,6 +98,10 @@ var Codemirror = Ember.TextArea.extend(MarkerManager, {
|
|||
offset: 10
|
||||
}));
|
||||
|
||||
codemirror.on('focus', function () {
|
||||
codemirror.component.sendAction('onFocusIn');
|
||||
});
|
||||
|
||||
this.set('codemirror', codemirror);
|
||||
},
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@ var TrimFocusInput = Ember.TextField.extend({
|
|||
var text = this.$().val();
|
||||
|
||||
this.$().val(text.trim());
|
||||
|
||||
this.sendAction('onFocusOut');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ var EditorNewController = Ember.ObjectController.extend(EditorControllerMixin, {
|
|||
var self = this;
|
||||
return this._super(options).then(function (model) {
|
||||
if (model.get('id')) {
|
||||
self.transitionToRoute('editor.edit', model);
|
||||
self.replaceRoute('editor.edit', model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -187,6 +187,7 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
|
|||
},
|
||||
|
||||
shouldFocusTitle: Ember.computed.alias('model.isNew'),
|
||||
shouldFocusEditor: Ember.computed.not('model.isNew'),
|
||||
|
||||
actions: {
|
||||
save: function (options) {
|
||||
|
@ -210,6 +211,7 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
|
|||
if (!this.get('titleScratch')) {
|
||||
this.set('titleScratch', '(Untitled)');
|
||||
}
|
||||
|
||||
this.set('title', this.get('titleScratch'));
|
||||
|
||||
return this.get('model').save(options).then(function (model) {
|
||||
|
@ -298,7 +300,7 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
|
|||
}
|
||||
},
|
||||
|
||||
autoSaveOnce: function () {
|
||||
autoSaveNew: function () {
|
||||
if (this.get('isNew')) {
|
||||
this.send('autoSave');
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
<div class="page-content">
|
||||
<header>
|
||||
<section class="box entry-title">
|
||||
{{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=titleScratch tabindex="1" focus=shouldFocusTitle onFocusOut="autoSaveOnce"}}
|
||||
{{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=titleScratch
|
||||
tabindex="1" focus=shouldFocusTitle}}
|
||||
</section>
|
||||
</header>
|
||||
|
||||
|
@ -17,9 +18,8 @@
|
|||
</header>
|
||||
<section id="entry-markdown-content" class="entry-markdown-content">
|
||||
{{gh-codemirror value=scratch scrollInfo=view.markdownScrollInfo
|
||||
setCodeMirror="setCodeMirror"
|
||||
openModal="openModal"
|
||||
typingPause="autoSave"}}
|
||||
setCodeMirror="setCodeMirror" openModal="openModal" typingPause="autoSave"
|
||||
focus=shouldFocusEditor onFocusIn="autoSaveNew"}}
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ var EditorSaveButtonView = Ember.View.extend({
|
|||
|
||||
'saveText': Ember.computed('controller.willPublish', function () {
|
||||
return this.get('controller.willPublish') ? this.get('publishText') : this.get('draftText');
|
||||
}),
|
||||
})
|
||||
});
|
||||
|
||||
export default EditorSaveButtonView;
|
||||
|
|
Loading…
Add table
Reference in a new issue