nodebb-plugin-composer-quill icon indicating copy to clipboard operation
nodebb-plugin-composer-quill copied to clipboard

Deleting the entire content of the editor switches Direction

Open PostMidnight opened this issue 6 years ago • 1 comments

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');
		});

PostMidnight avatar Aug 01 '19 18:08 PostMidnight

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');

PostMidnight avatar Aug 12 '19 16:08 PostMidnight