feat: ctrl-enter shortcut for quick reply

main
Julian Lam 2 years ago
parent 0effa6c8ed
commit 64a92fadeb

@ -1,8 +1,12 @@
'use strict'; 'use strict';
define('persona/quickreply', [ define('persona/quickreply', [
'components', 'composer/autocomplete', 'api', 'alerts', 'uploadHelpers', 'components', 'composer/autocomplete', 'api',
], function (components, autocomplete, api, alerts, uploadHelpers) { 'alerts', 'uploadHelpers', 'mousetrap',
], function (
components, autocomplete, api,
alerts, uploadHelpers, mousetrap
) {
var QuickReply = {}; var QuickReply = {};
QuickReply.init = function () { QuickReply.init = function () {
@ -27,6 +31,11 @@ define('persona/quickreply', [
// data.element.textcomplete(data.strategies, data.options); // data.element.textcomplete(data.strategies, data.options);
// $('.textcomplete-wrapper').css('height', '100%').find('textarea').css('height', '100%'); // $('.textcomplete-wrapper').css('height', '100%').find('textarea').css('height', '100%');
mousetrap.bind('ctrl+return', (e) => {
if (e.target === element.get(0)) {
components.get('topic/quickreply/button').get(0).click();
}
});
uploadHelpers.init({ uploadHelpers.init({
dragDropAreaEl: $('[component="topic/quickreply/container"] .quickreply-message'), dragDropAreaEl: $('[component="topic/quickreply/container"] .quickreply-message'),

@ -12,7 +12,7 @@
<input type="hidden" name="tid" value="{tid}" /> <input type="hidden" name="tid" value="{tid}" />
<input type="hidden" name="_csrf" value="{config.csrf_token}" /> <input type="hidden" name="_csrf" value="{config.csrf_token}" />
<div class="quickreply-message"> <div class="quickreply-message">
<textarea name="content" component="topic/quickreply/text" class="form-control" rows="5" placeholder="[[modules:composer.textarea.placeholder]]"></textarea> <textarea name="content" component="topic/quickreply/text" class="form-control mousetrap" rows="5" placeholder="[[modules:composer.textarea.placeholder]]"></textarea>
<div class="imagedrop"><div>[[topic:composer.drag_and_drop_images]]</div></div> <div class="imagedrop"><div>[[topic:composer.drag_and_drop_images]]</div></div>
</div> </div>
<button type="submit" component="topic/quickreply/button" class="btn btn-primary pull-right">[[topic:post-quick-reply]]</button> <button type="submit" component="topic/quickreply/button" class="btn btn-primary pull-right">[[topic:post-quick-reply]]</button>

Loading…
Cancel
Save