mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 13:30:47 +08:00
Move between title/post inputs with return and backspace keys
This commit is contained in:
parent
52ff2f25ba
commit
5c21efe09d
|
@ -41,12 +41,32 @@ export default class DiscussionComposer extends ComposerBody {
|
|||
if (empty) { $this.val(''); }
|
||||
});
|
||||
setTimeout(() => $(element).trigger('input'));
|
||||
},
|
||||
onkeydown: (e) => {
|
||||
if (e.which === 13) { // return
|
||||
e.preventDefault();
|
||||
this.editor.setSelectionRange(0, 0);
|
||||
}
|
||||
m.redraw.strategy('none');
|
||||
}
|
||||
})));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
onload(element) {
|
||||
super.onload(element);
|
||||
|
||||
this.editor.$('textarea').keydown((e) => {
|
||||
if (e.which === 8 && e.target.selectionStart == 0 && e.target.selectionEnd == 0) { // Backspace
|
||||
e.preventDefault();
|
||||
var title = this.$(':input:enabled:visible:first')[0];
|
||||
title.focus();
|
||||
title.selectionStart = title.selectionEnd = title.value.length;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
preventExit() {
|
||||
return (this.title() || this.content()) && !confirm(this.props.confirmExit);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user