Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinicius Reis <vinicius.reis@nextcloud.com>2022-04-26 15:37:15 +0300
committerVinicius Reis <vinicius.reis@nextcloud.com>2022-04-26 15:37:15 +0300
commit3cf3fdd436ebf7e42667ecc143bcc02a61acb065 (patch)
treefffffe46d90a1f16fbd1220efc395098d5709d13 /src/components/MenuBubble.vue
parent7feabf83b8064780f305f68cb57fa5c5679c94ad (diff)
⚡️ (#2323): inject editor into MenuBubble
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Diffstat (limited to 'src/components/MenuBubble.vue')
-rw-r--r--src/components/MenuBubble.vue19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/components/MenuBubble.vue b/src/components/MenuBubble.vue
index d63fc9c41..31be99db0 100644
--- a/src/components/MenuBubble.vue
+++ b/src/components/MenuBubble.vue
@@ -21,7 +21,7 @@
-->
<template>
- <BubbleMenu :editor="editor"
+ <BubbleMenu :editor="$editor"
:tippy-options="{ onHide: hideLinkMenu, duration: 200, placement: 'bottom' }"
class="menububble">
<form v-if="linkMenuIsActive" class="menububble__form" @submit.prevent="setLinkUrl()">
@@ -74,6 +74,8 @@ import { getCurrentUser } from '@nextcloud/auth'
import { optimalPath } from './../helpers/files'
import { loadState } from '@nextcloud/initial-state'
+import { useEditorMixin } from './EditorWrapper.provider'
+
export default {
name: 'MenuBubble',
components: {
@@ -82,11 +84,8 @@ export default {
directives: {
tooltip: Tooltip,
},
+ mixins: [useEditorMixin],
props: {
- editor: {
- type: Object,
- required: true,
- },
// used to calculate the position based on the scrollOffset
contentWrapper: {
type: HTMLDivElement,
@@ -108,7 +107,7 @@ export default {
},
methods: {
showLinkMenu() {
- const attrs = getMarkAttributes(this.editor.state, 'link')
+ const attrs = getMarkAttributes(this.$editor.state, 'link')
this.linkUrl = attrs.href
this.linkMenuIsActive = true
this.$nextTick(() => {
@@ -131,7 +130,7 @@ export default {
const path = optimalPath(this.filePath, `${fileInfo.path}/${fileInfo.name}`)
const encodedPath = path.split('/').map(encodeURIComponent).join('/')
const href = `${encodedPath}?fileId=${fileInfo.id}`
- this.editor.chain().setLink({ href }).focus().run()
+ this.$editor.chain().setLink({ href }).focus().run()
this.hideLinkMenu()
})
}, false, [], true, undefined, startPath)
@@ -153,14 +152,14 @@ export default {
// Avoid issues when parsing urls later on in markdown that might be entered in an invalid format (e.g. "mailto: example@example.com")
const href = url.replaceAll(' ', '%20')
- this.editor.chain().setLink({ href }).focus().run()
+ this.$editor.chain().setLink({ href }).focus().run()
this.hideLinkMenu()
},
removeLinkUrl() {
- this.editor.chain().unsetLink().focus().run()
+ this.$editor.chain().unsetLink().focus().run()
},
isActive(selector, args = {}) {
- return this.editor.isActive(selector, args)
+ return this.$editor.isActive(selector, args)
},
},
}