Skip to content

Commit

Permalink
fix(extension): Link bubble menu, back to main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mekery committed Jan 17, 2021
1 parent 6b62808 commit 821d394
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/components/menubars/OEditorMenuBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
!(editorContext.isActive.embed && editorContext.isActive.embed()) &&
!(editorContext.isActive.katex_block && editorContext.isActive.katex_block()) }"
:style="`left: ${editorContext.menu.left}px; bottom: ${editorContext.menu.bottom + 8}px;`">
<template v-if="showBack">
<o-menubar-btn icon="arrow_back"
:tooltip="$o.lang.link.back" @click.native="onBackToMain" />
<q-separator vertical inset />
</template>
<template v-for="(item, index) of bubbleToolbar">
<q-separator vertical inset :key="index" v-if="item==='separator'" />
<component :key="index"
Expand Down Expand Up @@ -59,6 +64,7 @@ export default {
name: 'o-editor-menu-bubble',
data () {
return {
backToMain: false
}
},
props: {
Expand Down Expand Up @@ -120,16 +126,24 @@ export default {
if (!range) return false
return range.to === $to.pos
},
onBackToMain () {
this.backToMain = true
}
},
computed: {
bubbleToolbar () {
let toolbar = this.toolbar
if (this.isLinkSelected) {
toolbar = LinkBubble
if (!this.backToMain) {
if (this.isLinkSelected) {
toolbar = LinkBubble
}
}
return toolbar
},
showBack () {
return !this.backToMain && this.isLinkSelected
},
isLinkSelected () {
const { state } = this.editor
const { tr } = state
Expand All @@ -138,6 +152,11 @@ export default {
return this.isLinkSelection(selection)
}
},
watch: {
isLinkSelected (to, from) {
this.backToMain = false
}
},
mounted () {
},
deactivated () {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en-us/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default {
linkWarning: 'Invalid link',
},
link: {
back: 'Back to main menu',
edit: 'Edit Link',
off: 'Disable Link',
open: 'Open Link',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/pl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default {
linkWarning: 'Invalid link',
},
link: {
back: 'Back to main menu',
edit: 'Edit Link',
off: 'Disable Link',
open: 'Open Link',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/pt-br/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default {
linkWarning: 'Invalid link',
},
link: {
back: 'Back to main menu',
edit: 'Edit Link',
off: 'Disable Link',
open: 'Open Link',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/zh-hans/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default {
linkWarning: '无效的链接',
},
link: {
back: '返回主菜单',
edit: '编辑链接',
off: '取消链接',
open: '打开链接',
Expand Down

0 comments on commit 821d394

Please sign in to comment.