nodebb-plugin-composer-quill
nodebb-plugin-composer-quill copied to clipboard
Deleting the entire content of the editor switches Direction
Solution that works (for now):
quill.on('text-change', function () {
if (isEmpty(quill)) {
console.log('empty!!');
//quill.deleteText(0, quill.getLength());
//quill.setText('​');
textareaEl.val('');
return;
}
textareaEl.val(JSON.stringify(quill.getContents()));
textareaEl.trigger('change');
});
Generally, I see that its better to repalce 'setText('') with setContents, see below: To that end, I recommend changing $(window).on('action:chat.sent', function (evt, data) accordingly.
//quill.setText('');
let textDirection = $('html').attr('data-dir');
quill.setContents({ ops: [{
insert: '\n',
attributes: {
direction: textDirection,
align: textDirection === 'rtl' ? 'right' : 'left',
},
}] }, 'api');