UX: Allow CTRL+ENTER to save topic title edits
This commit is contained in:
parent
3964929c75
commit
df213639f1
|
@ -3,8 +3,9 @@ import Composer from 'discourse/models/composer';
|
||||||
import afterTransition from 'discourse/lib/after-transition';
|
import afterTransition from 'discourse/lib/after-transition';
|
||||||
import positioningWorkaround from 'discourse/lib/safari-hacks';
|
import positioningWorkaround from 'discourse/lib/safari-hacks';
|
||||||
import { headerHeight } from 'discourse/components/site-header';
|
import { headerHeight } from 'discourse/components/site-header';
|
||||||
|
import KeyEnterEscape from 'discourse/mixins/key-enter-escape';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend(KeyEnterEscape, {
|
||||||
elementId: 'reply-control',
|
elementId: 'reply-control',
|
||||||
|
|
||||||
classNameBindings: ['composer.creatingPrivateMessage:private-message',
|
classNameBindings: ['composer.creatingPrivateMessage:private-message',
|
||||||
|
@ -65,17 +66,6 @@ export default Ember.Component.extend({
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
keyDown(e) {
|
|
||||||
if (e.which === 27) {
|
|
||||||
this.sendAction('cancelled');
|
|
||||||
return false;
|
|
||||||
} else if (e.which === 13 && (e.ctrlKey || e.metaKey)) {
|
|
||||||
// CTRL+ENTER or CMD+ENTER
|
|
||||||
this.sendAction('save');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
@observes('composeState')
|
@observes('composeState')
|
||||||
disableFullscreen() {
|
disableFullscreen() {
|
||||||
if (this.get('composeState') !== Composer.OPEN && positioningWorkaround.blur) {
|
if (this.get('composeState') !== Composer.OPEN && positioningWorkaround.blur) {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import KeyEnterEscape from 'discourse/mixins/key-enter-escape';
|
||||||
|
|
||||||
|
export default Ember.Component.extend(KeyEnterEscape, {
|
||||||
|
elementId: 'topic-title',
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
// A mixin where hitting ESC calls `cancelled` and ctrl+enter calls `save.
|
||||||
|
export default {
|
||||||
|
keyDown(e) {
|
||||||
|
if (e.which === 27) {
|
||||||
|
this.sendAction('cancelled');
|
||||||
|
return false;
|
||||||
|
} else if (e.which === 13 && (e.ctrlKey || e.metaKey)) {
|
||||||
|
// CTRL+ENTER or CMD+ENTER
|
||||||
|
this.sendAction('save');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<div class="container">
|
||||||
|
<div class="title-wrapper">
|
||||||
|
{{yield}}
|
||||||
|
</div>
|
||||||
|
{{plugin-outlet name="topic-title" args=(hash model=model)}}
|
||||||
|
</div>
|
|
@ -10,10 +10,7 @@
|
||||||
|
|
||||||
{{#if model.postStream.loaded}}
|
{{#if model.postStream.loaded}}
|
||||||
{{#if model.postStream.firstPostPresent}}
|
{{#if model.postStream.firstPostPresent}}
|
||||||
<div id="topic-title">
|
{{#topic-title cancelled="cancelEditingTopic" save="finishedEditingTopic"}}
|
||||||
<div class="container">
|
|
||||||
|
|
||||||
<div class="title-wrapper">
|
|
||||||
{{#if editingTopic}}
|
{{#if editingTopic}}
|
||||||
{{#if model.isPrivateMessage}}
|
{{#if model.isPrivateMessage}}
|
||||||
<span class="private-message-glyph">{{fa-icon "envelope"}}</span>
|
<span class="private-message-glyph">{{fa-icon "envelope"}}</span>
|
||||||
|
@ -59,10 +56,7 @@
|
||||||
{{topic-category topic=model class="topic-category"}}
|
{{topic-category topic=model class="topic-category"}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
{{/topic-title}}
|
||||||
{{plugin-outlet name="topic-title" args=(hash model=model)}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class="container posts">
|
<div class="container posts">
|
||||||
|
|
Loading…
Reference in New Issue