Skip to content

Commit cb592dc

Browse files
Merge pull request #3 from vueup/alpha
Alpha
2 parents 16e31a0 + 8f71f8a commit cb592dc

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

docs/content/api/methods.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Methods
22

3+
::: warning
4+
We highly recommend to call method when the quill editor ready, use @ready event
5+
:::
6+
7+
## getEditor()
8+
9+
- **Return:** `editor: Element`
10+
11+
Returns the Editor Element.
12+
13+
## getToolbar()
14+
15+
- **Return:** `toolbar: Element`
16+
17+
Returns the Toolbar Element.
18+
319
## getQuill()
420

521
- **Return:** `quill: Quill`

src/components/QuillEditor.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export default defineComponent({
110110
if (props.theme !== "bubble") editor.value.classList.remove("ql-bubble");
111111
if (props.theme !== "snow") editor.value.classList.remove("ql-snow");
112112
// Fix clicking the quill toolbar is detected as blur event
113-
quill.getModule("toolbar")?.container.addEventListener("mousedown", (e) => {
113+
quill.getModule("toolbar")?.container.addEventListener("mousedown", (e: MouseEvent) => {
114114
e.preventDefault();
115115
});
116116
// Emit ready event
@@ -191,6 +191,14 @@ export default defineComponent({
191191
}
192192
};
193193

194+
const getEditor = (): Element => {
195+
return editor.value as Element
196+
}
197+
198+
const getToolbar = (): Element => {
199+
return quill?.getModule("toolbar")?.container
200+
}
201+
194202
const getQuill = (): Quill => {
195203
if (quill) return quill
196204
else throw `The quill editor hasn't been instantiated yet,
@@ -206,6 +214,12 @@ export default defineComponent({
206214
quill?.clipboard.dangerouslyPasteHTML(html)
207215
}
208216

217+
const reinit = () => {
218+
if (!ctx.slots.toolbar && quill)
219+
quill.getModule("toolbar")?.container.remove();
220+
initialize();
221+
}
222+
209223
watch(
210224
() => props.content,
211225
(newContent, oldContent) => {
@@ -222,19 +236,6 @@ export default defineComponent({
222236
}
223237
);
224238

225-
watch(
226-
[
227-
() => props.options,
228-
() => props.theme,
229-
() => props.toolbar
230-
],
231-
() => {
232-
if (!ctx.slots.toolbar && quill)
233-
quill.getModule("toolbar")?.container.remove();
234-
initialize();
235-
}
236-
);
237-
238239
watch(
239240
() => props.enable,
240241
(newValue, oldValue) => {
@@ -244,9 +245,12 @@ export default defineComponent({
244245

245246
return {
246247
editor,
248+
getEditor,
249+
getToolbar,
247250
getQuill,
248251
getHTML,
249252
setHTML,
253+
reinit,
250254
};
251255
},
252256
inheritAttrs: false,

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import QuillEditor from "./components/QuillEditor"
8-
import Quill from "quill"
8+
import Quill from "quill/core"
99

1010
export {
1111
QuillEditor as default,

0 commit comments

Comments
 (0)