kevmodrome / svelte-quill

An action for Svelte components to easily use QuillJS.
MIT License
39 stars 10 forks source link

No way to retrieve quill instance to make native API calls on it? #4

Open ggaabe opened 3 years ago

ggaabe commented 3 years ago

I'm new to svelte so maybe I'm missing something, but as far as I can tell, with the svelte implementation being inline within the HTML, there's no way to retrieve the quill instance. Is that correct?

Eragra3 commented 1 year ago

In case somebody has the same issue.

Example in Github readme didn't work for me, I noticed you can get the html element and access hidden __quill property or use Quill directly - which is way nicer.

So I did that:

<script lang="ts">
    import Quill from 'quill/core';

    let quillElement;

    onMount(() => {
        const editorInstance = Quill.find(quillElement);

        editorInstance?.setText(initialText);
    });
</script>

<div class="wysiwyg-container">
    <div bind:this={quillElement}
         use:quill={options}
         on:text-change></div>
</div>
</style>