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 <[email protected]>
  • Loading branch information
mejo- authored and backportbot-nextcloud[bot] committed Oct 10, 2023
1 parent e305b2e commit 898f5da
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/editor.js
Original file line number Diff line number Diff line change
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 898f5da

Please sign in to comment.