Skip to content

Commit

Permalink
fix: 🐛 add isLinkBack flag to prevent link menu change
Browse files Browse the repository at this point in the history
  • Loading branch information
Leecason committed Jul 6, 2020
1 parent d245e04 commit ccd305f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/MenuBubble/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
v-if="textMenuEnable"
class="el-tiptap-editor__command-button"
@mousedown.prevent
@click="setMenuType('default')"
@click="linkBack"
>
<v-icon name="arrow-left" />
</div>
Expand Down Expand Up @@ -85,6 +85,7 @@ export default class MenuBubble extends Vue {
@Inject() readonly et!: any;
activeMenu: MenuType = MenuType.NONE;
isLinkBack: boolean = false;
private get bubbleMenuEnable (): boolean {
return this.linkMenuEnable || this.textMenuEnable;
Expand Down Expand Up @@ -120,9 +121,19 @@ export default class MenuBubble extends Vue {
return false;
}
linkBack () {
this.setMenuType(MenuType.DEFAULT);
this.isLinkBack = true;
}
@Watch('editor.state.selection')
onSelectionChange () {
this.activeMenu = this.$_getCurrentMenuType();
if (this.isLinkSelection && !this.isLinkBack) {
this.setMenuType(MenuType.LINK);
} else {
this.activeMenu = this.$_getCurrentMenuType();
this.isLinkBack = false;
}
}
private generateCommandButtonComponentSpecs (editorContext: MenuData): MenuBtnViewType[] {
Expand Down

0 comments on commit ccd305f

Please sign in to comment.