mirror of
https://github.com/flarum/core.git
synced 2025-07-27 19:50:20 +02:00
Move between title/post inputs with return and backspace keys
This commit is contained in:
@@ -41,12 +41,32 @@ export default class DiscussionComposer extends ComposerBody {
|
|||||||
if (empty) { $this.val(''); }
|
if (empty) { $this.val(''); }
|
||||||
});
|
});
|
||||||
setTimeout(() => $(element).trigger('input'));
|
setTimeout(() => $(element).trigger('input'));
|
||||||
|
},
|
||||||
|
onkeydown: (e) => {
|
||||||
|
if (e.which === 13) { // return
|
||||||
|
e.preventDefault();
|
||||||
|
this.editor.setSelectionRange(0, 0);
|
||||||
|
}
|
||||||
|
m.redraw.strategy('none');
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
return items;
|
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() {
|
preventExit() {
|
||||||
return (this.title() || this.content()) && !confirm(this.props.confirmExit);
|
return (this.title() || this.content()) && !confirm(this.props.confirmExit);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user