diff --git a/docs/content/api/methods.md b/docs/content/api/methods.md index 9785274f..7b93de0d 100644 --- a/docs/content/api/methods.md +++ b/docs/content/api/methods.md @@ -53,6 +53,10 @@ We highly recommend to call method when the quill editor ready, use @ready event To import raw HTML from a non-Quill environment. + ## focus() + + Focuses the editor. + ## getText(index, length) - **Parameter:** `index?: number, length?: number` diff --git a/packages/vue-quill/src/components/QuillEditor.ts b/packages/vue-quill/src/components/QuillEditor.ts index aab9ab6b..9d8ce266 100644 --- a/packages/vue-quill/src/components/QuillEditor.ts +++ b/packages/vue-quill/src/components/QuillEditor.ts @@ -289,7 +289,7 @@ export const QuillEditor = defineComponent({ const getQuill = (): Quill => { if (quill) return quill else - throw `The quill editor hasn't been instantiated yet, + throw `The quill editor hasn't been instantiated yet, make sure to call this method when the editor ready or use v-on:ready="onReady(quill)" event instead.` } @@ -340,6 +340,10 @@ export const QuillEditor = defineComponent({ if (delta) quill?.setContents(delta, source) } + const focus = () => { + quill?.focus() + } + const reinit = () => { nextTick(() => { if (!ctx.slots.toolbar && quill) @@ -380,6 +384,7 @@ export const QuillEditor = defineComponent({ getHTML, setHTML, pasteHTML, + focus, getText, setText, reinit,