I've created a text-editor vue component with quill editor and configured it to display data from a database inside its input field. For that I need the ref="quill" property on the <quill-editor> element together with a watcher. Problem is that as soon as I add the property, the editor switches to bi-directional (right-to-left) language direction.
text-editor.vue:
<template>
<div id="text-editor" class="text-editor">
<quill-editor ref="quill" :modules="modules" :toolbar="toolbar" v-model:content="store.re.body" contentType="html"/>
</div>
</template>
<script setup>
import BlotFormatter from 'quill-blot-formatter'
import store from "../../../js/store";
import {ref, watch} from "vue";
store.re.body = ''
const modules = {
module: BlotFormatter,
}
const toolbar = [
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'size': ['small', false, 'large', 'huge'] }],
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'align': [] }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
['link', 'image', 'video'],
['clean']
];
const quill = ref(null)
watch(() => store.re.body, newValue => quill.value.setHTML(newValue))
</script>
I've tried changing it with CSS but it didn't help:
.ql-editor { direction: ltr }
The css-property is applied to quill but the language direction stays RTL.
Adding [{ 'direction': 'ltr' }] to the toolbar object does not help either. Any idea how to debug this?

The issue isn't caused by adding a
refto<quill-editor>.This looks like
vue-quill#52. The author tried to fix it in this patch, but that only broke editor updates viav-model:content. You usedsetHTML()to workaround that issue, but cursor-reset bug was still active. Then, typing anything would cause text to be prepended, making it only appear to be RTL.As a workaround, you could move the cursor to the end of the line and re-focus:
demo 1
However, this reveals a new problem in that deleting text from the middle of the editor causes the cursor to jump to the end. We need a way to update
store.re.bodyand move the cursor only when the update is from thev-model. Otherwise, the external update (from the other component's fetch) should not move the cursor.You can implement that behavior as follows:
Replace the
<quill-editor>'sv-model:contentwith a newcontentref.Watch the
contentref, updatingstore.re.bodywith the new value. Also track this new value asnewContent.In the watch on
store.re.body, ignore the new value if it's equal tonewContent.demo 2