Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): dont show bubble menu popup on all select shortcut

Ramesh Maneddfa73803b72
diff --git a/packages/nc-gui/components/cell/RichText.vue b/packages/nc-gui/components/cell/RichText.vue
index 3321349b86..ddb5314ef3 100644
--- a/packages/nc-gui/components/cell/RichText.vue
+++ b/packages/nc-gui/components/cell/RichText.vue
@@ -319,6 +319,7 @@ onClickOutside(editorDom, (e) => {
v-if="editor && !isFormField && !isForm"
:editor="editor"
:hide-mention="hideMention"
+ hide-on-select-all-sortcut
/>
<template v-if="shouldShowLinkOption">
diff --git a/packages/nc-gui/components/cell/RichText/SelectedBubbleMenuPopup.vue b/packages/nc-gui/components/cell/RichText/SelectedBubbleMenuPopup.vue
index ea46cbec34..616a7258ac 100644
--- a/packages/nc-gui/components/cell/RichText/SelectedBubbleMenuPopup.vue
+++ b/packages/nc-gui/components/cell/RichText/SelectedBubbleMenuPopup.vue
@@ -5,18 +5,22 @@ import { BubbleMenu } from '@tiptap/vue-3'
interface Props {
editor: Editor
hideMention?: boolean
+ hideOnSelectAllSortcut?: boolean
}
const props = defineProps<Props>()
const editor = computed(() => props.editor)
+const isSelectAllShortcut = ref(false)
+
// Debounce show menu to prevent flickering
const showMenu = computed(() => {
- if (!editor) return false
+ if (!editor || isSelectAllShortcut.value) return false
return !editor.value.state.selection.empty
})
+
const showMenuDebounced = ref(false)
watchDebounced(
@@ -34,7 +38,10 @@ watchDebounced(
const handleEditorMouseDown = (e: MouseEvent) => {
const domsInEvent = document.elementsFromPoint(e.clientX, e.clientY) as HTMLElement[]
const isBubble = domsInEvent.some((dom) => dom?.classList?.contains('bubble-menu'))
- if (isBubble) return
+ if (isBubble || isSelectAllShortcut.value) {
+ isSelectAllShortcut.value = false
+ return
+ }
const pageContent = document.querySelector('.nc-textarea-rich-editor')
pageContent?.classList.add('bubble-menu-hidden')
@@ -43,7 +50,11 @@ const handleEditorMouseDown = (e: MouseEvent) => {
const handleEditorMouseUp = (e: MouseEvent) => {
const domsInEvent = document.elementsFromPoint(e.clientX, e.clientY) as HTMLElement[]
const isBubble = domsInEvent.some((dom) => dom?.classList?.contains('bubble-menu'))
- if (isBubble) return
+
+ if (isBubble || isSelectAllShortcut.value) {
+ isSelectAllShortcut.value = false
+ return
+ }
setTimeout(() => {
const pageContent = document.querySelector('.nc-textarea-rich-editor')
@@ -51,6 +62,14 @@ const handleEditorMouseUp = (e: MouseEvent) => {
}, 100)
}
+useEventListener('keydown', (e: KeyboardEvent) => {
+ if (!props.hideOnSelectAllSortcut) return
+
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'a') {
+ isSelectAllShortcut.value = true
+ }
+})
+
onMounted(() => {
document.addEventListener('mouseup', handleEditorMouseUp)
document.addEventListener('mousedown', handleEditorMouseDown)