Skip to content

Commit

Permalink
refactor(editorApi): add private function getEditorComponent
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Oct 2, 2023
1 parent efbc3ef commit e102f2e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/editor.js
Expand Up @@ -46,6 +46,10 @@ class TextEditorEmbed {
return this
}

#getEditorComponent() {
return this.#vm.$children[0]
}

onLoaded(onLoadedCallback = () => {}) {
this.#vm.$on('ready', () => {
onLoadedCallback()
Expand Down Expand Up @@ -84,12 +88,12 @@ class TextEditorEmbed {
// Update reactive prop for MarkdownContentEditor
this.#vm.$set(this.#data, 'content', content)
// Call setContent for file based Editor
this.#vm.$children[0]?.setContent?.(content)
this.#getEditorComponent()?.setContent?.(content)
return this
}

async save() {
return this.#vm.$children[0].save?.()
return this.#getEditorComponent().save?.()
}

setShowOutline(value) {
Expand All @@ -103,11 +107,11 @@ class TextEditorEmbed {
}

insertAtCursor(content) {
this.#vm.$children[0].$editor.chain().insertContent(content).focus().run()
this.#getEditorComponent().$editor.chain().insertContent(content).focus().run()
}

focus() {
this.#vm.$children[0].$editor.commands.focus()
this.#getEditorComponent().$editor.commands.focus()
}

#registerDebug() {
Expand Down

0 comments on commit e102f2e

Please sign in to comment.