fix(messages): override Enter in Quill keyboard config at init time
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
This commit is contained in:
parent
29e98d0b03
commit
b944042a85
@ -1222,28 +1222,36 @@
|
|||||||
placeholder: 'Napisz wiadomość...',
|
placeholder: 'Napisz wiadomość...',
|
||||||
modules: {
|
modules: {
|
||||||
toolbar: [['bold', 'italic'], ['link'], ['clean']],
|
toolbar: [['bold', 'italic'], ['link'], ['clean']],
|
||||||
|
keyboard: {
|
||||||
|
bindings: {
|
||||||
|
// Override ALL Enter behavior — send message instead of newline
|
||||||
|
enter: {
|
||||||
|
key: 'Enter',
|
||||||
|
handler: function() {
|
||||||
|
var html = state.quill.root.innerHTML;
|
||||||
|
var text = state.quill.getText().trim();
|
||||||
|
if (text) {
|
||||||
|
state.quill.setText('');
|
||||||
|
Composer.sendContent(html, text);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Shift+Enter = newline
|
||||||
|
linebreak: {
|
||||||
|
key: 'Enter',
|
||||||
|
shiftKey: true,
|
||||||
|
handler: function(range) {
|
||||||
|
this.quill.insertText(range.index, '\n');
|
||||||
|
this.quill.setSelection(range.index + 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enter = send: prepend our handler BEFORE Quill's default Enter handlers
|
|
||||||
// Quill stores handlers in keyboard.bindings keyed by keyCode
|
|
||||||
var enterBindings = state.quill.keyboard.bindings[13] || [];
|
|
||||||
// Insert our handler at the BEGINNING so it runs first
|
|
||||||
enterBindings.unshift({
|
|
||||||
key: 13,
|
|
||||||
shiftKey: false,
|
|
||||||
handler: function() {
|
|
||||||
var html = state.quill.root.innerHTML;
|
|
||||||
var text = state.quill.getText().trim();
|
|
||||||
if (text) {
|
|
||||||
state.quill.setText('');
|
|
||||||
Composer.sendContent(html, text);
|
|
||||||
}
|
|
||||||
return false; // Block Quill's default Enter (newline insertion)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
state.quill.keyboard.bindings[13] = enterBindings;
|
|
||||||
|
|
||||||
// Typing indicator
|
// Typing indicator
|
||||||
state.quill.on('text-change', function () {
|
state.quill.on('text-change', function () {
|
||||||
Composer.sendTyping();
|
Composer.sendTyping();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user