Browse Source

fix: Disabled btns in select bubble menu in the case of code block as those format btns will have no effect

pull/7046/head
Muhammed Mustafa 1 year ago
parent
commit
a2a95b8c8d
  1. 28
      packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue
  2. 3
      packages/nc-gui/components/nc/Button.vue

28
packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue

@ -85,7 +85,7 @@ const onToggleLink = () => {
'full-mode': !embedMode, 'full-mode': !embedMode,
}" }"
> >
<NcTooltip> <NcTooltip :disabled="editor.isActive('codeBlock')">
<template #title> <template #title>
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<div> <div>
@ -98,13 +98,14 @@ const onToggleLink = () => {
size="small" size="small"
type="text" type="text"
:class="{ 'is-active': editor.isActive('bold') }" :class="{ 'is-active': editor.isActive('bold') }"
:disabled="editor.isActive('codeBlock')"
@click="editor!.chain().focus().toggleBold().run()" @click="editor!.chain().focus().toggleBold().run()"
> >
<MdiFormatBold /> <MdiFormatBold />
</NcButton> </NcButton>
</NcTooltip> </NcTooltip>
<NcTooltip> <NcTooltip :disabled="editor.isActive('codeBlock')">
<template #title> <template #title>
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<div> <div>
@ -116,13 +117,14 @@ const onToggleLink = () => {
<NcButton <NcButton
size="small" size="small"
type="text" type="text"
:disabled="editor.isActive('codeBlock')"
:class="{ 'is-active': editor.isActive('italic') }" :class="{ 'is-active': editor.isActive('italic') }"
@click=";(editor!.chain().focus() as any).toggleItalic().run()" @click=";(editor!.chain().focus() as any).toggleItalic().run()"
> >
<MdiFormatItalic /> <MdiFormatItalic />
</NcButton> </NcButton>
</NcTooltip> </NcTooltip>
<NcTooltip> <NcTooltip :disabled="editor.isActive('codeBlock')">
<template #title> <template #title>
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<div> <div>
@ -136,12 +138,13 @@ const onToggleLink = () => {
size="small" size="small"
type="text" type="text"
:class="{ 'is-active': editor.isActive('underline') }" :class="{ 'is-active': editor.isActive('underline') }"
:disabled="editor.isActive('codeBlock')"
@click="editor!.chain().focus().toggleUnderline().run()" @click="editor!.chain().focus().toggleUnderline().run()"
> >
<MdiFormatUnderline /> <MdiFormatUnderline />
</NcButton> </NcButton>
</NcTooltip> </NcTooltip>
<NcTooltip> <NcTooltip :disabled="editor.isActive('codeBlock')">
<template #title> <template #title>
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<div> <div>
@ -154,6 +157,7 @@ const onToggleLink = () => {
size="small" size="small"
type="text" type="text"
:class="{ 'is-active': editor.isActive('strike') }" :class="{ 'is-active': editor.isActive('strike') }"
:disabled="editor.isActive('codeBlock')"
@click="editor!.chain().focus().toggleStrike().run()" @click="editor!.chain().focus().toggleStrike().run()"
> >
<MdiFormatStrikeThrough /> <MdiFormatStrikeThrough />
@ -170,12 +174,13 @@ const onToggleLink = () => {
<MsCode /> <MsCode />
</NcButton> </NcButton>
</NcTooltip> </NcTooltip>
<NcTooltip v-else> <NcTooltip v-else :disabled="editor.isActive('codeBlock')">
<template #title> {{ $t('general.quote') }}</template> <template #title> {{ $t('general.quote') }}</template>
<NcButton <NcButton
size="small" size="small"
type="text" type="text"
:class="{ 'is-active': editor.isActive('code') }" :class="{ 'is-active': editor.isActive('code') }"
:disabled="editor.isActive('codeBlock')"
@click="editor!.chain().focus().toggleCode().run()" @click="editor!.chain().focus().toggleCode().run()"
> >
<MsFormatQuote /> <MsFormatQuote />
@ -291,9 +296,15 @@ const onToggleLink = () => {
<div class="divider"></div> <div class="divider"></div>
<NcTooltip> <NcTooltip :disabled="editor.isActive('codeBlock')">
<template #title> {{ $t('general.link') }}</template> <template #title> {{ $t('general.link') }}</template>
<NcButton size="small" type="text" :class="{ 'is-active': editor.isActive('link') }" @click="onToggleLink"> <NcButton
size="small"
type="text"
:class="{ 'is-active': editor.isActive('link') }"
:disabled="editor.isActive('codeBlock')"
@click="onToggleLink"
>
<div class="flex flex-row items-center px-0.5"> <div class="flex flex-row items-center px-0.5">
<MdiLink /> <MdiLink />
<div class="!text-xs !ml-1">{{ $t('general.link') }}</div> <div class="!text-xs !ml-1">{{ $t('general.link') }}</div>
@ -338,7 +349,8 @@ const onToggleLink = () => {
border-width: 1px; border-width: 1px;
.is-active { .is-active {
@apply border-1 !hover:bg-gray-200 border-1 border-gray-200 bg-gray-100; @apply !hover:outline-gray-200 bg-gray-100;
outline: 1px;
} }
.divider { .divider {
@apply border-r-1 border-gray-200 !h-6 !mx-0.5 my-1; @apply border-r-1 border-gray-200 !h-6 !mx-0.5 my-1;

3
packages/nc-gui/components/nc/Button.vue

@ -172,7 +172,8 @@ useEventListener(NcButton, 'mousedown', () => {
@apply p-0 h-5.75 min-w-5.75 rounded-md; @apply p-0 h-5.75 min-w-5.75 rounded-md;
} }
.nc-button.ant-btn[disabled] { .nc-button.ant-btn[disabled],
.ant-btn-text.nc-button.ant-btn[disabled] {
box-shadow: none !important; box-shadow: none !important;
@apply bg-gray-50 border-0 text-gray-300 cursor-not-allowed md:(hover:bg-gray-50); @apply bg-gray-50 border-0 text-gray-300 cursor-not-allowed md:(hover:bg-gray-50);
} }

Loading…
Cancel
Save