Skip to content

Commit 1527f9a

Browse files
committed
refactor(editorApi): add private function getEditorComponent
Signed-off-by: Jonas <[email protected]>
1 parent d758772 commit 1527f9a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/editor.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class TextEditorEmbed {
4646
return this
4747
}
4848

49+
#getEditorComponent() {
50+
return this.#vm.$children[0]
51+
}
52+
4953
onLoaded(onLoadedCallback = () => {}) {
5054
this.#vm.$on('ready', () => {
5155
onLoadedCallback()
@@ -84,12 +88,12 @@ class TextEditorEmbed {
8488
// Update reactive prop for MarkdownContentEditor
8589
this.#vm.$set(this.#data, 'content', content)
8690
// Call setContent for file based Editor
87-
this.#vm.$children[0]?.setContent?.(content)
91+
this.#getEditorComponent()?.setContent?.(content)
8892
return this
8993
}
9094

9195
async save() {
92-
return this.#vm.$children[0].save?.()
96+
return this.getEditorComponent().save?.()
9397
}
9498

9599
setShowOutline(value) {
@@ -103,11 +107,11 @@ class TextEditorEmbed {
103107
}
104108

105109
insertAtCursor(content) {
106-
this.#vm.$children[0].$editor.chain().insertContent(content).focus().run()
110+
this.getEditorComponent().$editor.chain().insertContent(content).focus().run()
107111
}
108112

109113
focus() {
110-
this.#vm.$children[0].$editor.commands.focus()
114+
this.getEditorComponent().$editor.commands.focus()
111115
}
112116

113117
#registerDebug() {

0 commit comments

Comments
 (0)