|
|
|
@ -14,13 +14,12 @@ import MsFormatQuote from '~icons/material-symbols/format-quote'
|
|
|
|
|
interface Props { |
|
|
|
|
editor: Editor |
|
|
|
|
embedMode?: boolean |
|
|
|
|
isFormField?: boolean |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const props = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
const editor = computed(() => props.editor) |
|
|
|
|
|
|
|
|
|
const embedMode = computed(() => props.embedMode) |
|
|
|
|
const { editor, embedMode } = toRefs(props) |
|
|
|
|
|
|
|
|
|
const cmdOrCtrlKey = computed(() => { |
|
|
|
|
return isMac() ? '⌘' : 'CTRL' |
|
|
|
@ -79,13 +78,15 @@ const onToggleLink = () => {
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
|
<div |
|
|
|
|
class="bubble-menu flex flex-row gap-x-1 bg-gray-100 py-1 rounded-lg px-1" |
|
|
|
|
class="bubble-menu flex-row gap-x-1 py-1 rounded-lg" |
|
|
|
|
:class="{ |
|
|
|
|
'inline-flex !bg-transparent': isFormField, |
|
|
|
|
'flex bg-gray-100 px-1': !isFormField, |
|
|
|
|
'embed-mode': embedMode, |
|
|
|
|
'full-mode': !embedMode, |
|
|
|
|
}" |
|
|
|
|
> |
|
|
|
|
<NcTooltip :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<NcTooltip :placement="isFormField ? 'bottom' : undefined" :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
@ -99,13 +100,14 @@ const onToggleLink = () => {
|
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('bold') }" |
|
|
|
|
:disabled="editor.isActive('codeBlock')" |
|
|
|
|
:tabindex="isFormField ? -1 : 0" |
|
|
|
|
@click="editor!.chain().focus().toggleBold().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatBold /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<NcTooltip :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<NcTooltip :placement="isFormField ? 'bottom' : undefined" :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
@ -119,12 +121,13 @@ const onToggleLink = () => {
|
|
|
|
|
type="text" |
|
|
|
|
:disabled="editor.isActive('codeBlock')" |
|
|
|
|
:class="{ 'is-active': editor.isActive('italic') }" |
|
|
|
|
:tabindex="isFormField ? -1 : 0" |
|
|
|
|
@click=";(editor!.chain().focus() as any).toggleItalic().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatItalic /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<NcTooltip :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<NcTooltip :placement="isFormField ? 'bottom' : undefined" :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
@ -139,12 +142,13 @@ const onToggleLink = () => {
|
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('underline') }" |
|
|
|
|
:disabled="editor.isActive('codeBlock')" |
|
|
|
|
:tabindex="isFormField ? -1 : 0" |
|
|
|
|
@click="editor!.chain().focus().toggleUnderline().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatUnderline /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<NcTooltip :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<NcTooltip :placement="isFormField ? 'bottom' : undefined" :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
@ -158,155 +162,160 @@ const onToggleLink = () => {
|
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('strike') }" |
|
|
|
|
:disabled="editor.isActive('codeBlock')" |
|
|
|
|
:tabindex="isFormField ? -1 : 0" |
|
|
|
|
@click="editor!.chain().focus().toggleStrike().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatStrikeThrough /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<NcTooltip v-if="embedMode"> |
|
|
|
|
<template #title> {{ $t('general.code') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('codeBlock') }" |
|
|
|
|
@click="editor!.chain().focus().toggleCodeBlock().run()" |
|
|
|
|
> |
|
|
|
|
<MsCode /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<NcTooltip v-else :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<template #title> {{ $t('general.quote') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('code') }" |
|
|
|
|
:disabled="editor.isActive('codeBlock')" |
|
|
|
|
@click="editor!.chain().focus().toggleCode().run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatQuote /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<div class="divider"></div> |
|
|
|
|
<template v-if="!isFormField"> |
|
|
|
|
<NcTooltip v-if="embedMode"> |
|
|
|
|
<template #title> {{ $t('general.code') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('codeBlock') }" |
|
|
|
|
@click="editor!.chain().focus().toggleCodeBlock().run()" |
|
|
|
|
> |
|
|
|
|
<MsCode /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<NcTooltip v-else :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<template #title> {{ $t('general.quote') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('code') }" |
|
|
|
|
:disabled="editor.isActive('codeBlock')" |
|
|
|
|
@click="editor!.chain().focus().toggleCode().run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatQuote /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<div class="divider"></div> |
|
|
|
|
|
|
|
|
|
<template v-if="embedMode"> |
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
|
{{ $t('labels.heading1') }} |
|
|
|
|
<template v-if="embedMode"> |
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
|
{{ $t('labels.heading1') }} |
|
|
|
|
</div> |
|
|
|
|
<div>{{ cmdOrCtrlKey }} {{ altKey }} 1</div> |
|
|
|
|
</div> |
|
|
|
|
<div>{{ cmdOrCtrlKey }} {{ altKey }} 1</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('heading', { level: 1 }) }" |
|
|
|
|
@click="editor!.chain().focus().toggleHeading({ level: 1 }).run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatH1 /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
|
{{ $t('labels.heading2') }} |
|
|
|
|
</div> |
|
|
|
|
<div>{{ cmdOrCtrlKey }} {{ altKey }} 2</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('heading', { level: 2 }) }" |
|
|
|
|
@click="editor!.chain().focus().toggleHeading({ level: 2 }).run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatH2 /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
|
{{ $t('labels.heading3') }} |
|
|
|
|
</div> |
|
|
|
|
<div>{{ cmdOrCtrlKey }} {{ altKey }} 3</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('heading', { level: 3 }) }" |
|
|
|
|
@click="editor!.chain().focus().toggleHeading({ level: 3 }).run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatH3 /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<div class="divider"></div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<NcTooltip v-if="embedMode"> |
|
|
|
|
<template #title> {{ $t('labels.blockQuote') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('heading', { level: 1 }) }" |
|
|
|
|
@click="editor!.chain().focus().toggleHeading({ level: 1 }).run()" |
|
|
|
|
:class="{ 'is-active': editor.isActive('blockquote') }" |
|
|
|
|
@click="editor!.chain().focus().toggleBlockquote().run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatH1 /> |
|
|
|
|
<TablerBlockQuote class="-mt-0.25" /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
|
{{ $t('labels.heading2') }} |
|
|
|
|
</div> |
|
|
|
|
<div>{{ cmdOrCtrlKey }} {{ altKey }} 2</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<template #title> {{ $t('labels.bulletList') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('heading', { level: 2 }) }" |
|
|
|
|
@click="editor!.chain().focus().toggleHeading({ level: 2 }).run()" |
|
|
|
|
:class="{ 'is-active': editor.isActive('bulletList') }" |
|
|
|
|
@click="editor!.chain().focus().toggleBulletList().run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatH2 /> |
|
|
|
|
<MdiFormatBulletList /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> |
|
|
|
|
<div class="flex flex-col items-center"> |
|
|
|
|
<div> |
|
|
|
|
{{ $t('labels.heading3') }} |
|
|
|
|
</div> |
|
|
|
|
<div>{{ cmdOrCtrlKey }} {{ altKey }} 3</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<template #title> {{ $t('labels.numberedList') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('heading', { level: 3 }) }" |
|
|
|
|
@click="editor!.chain().focus().toggleHeading({ level: 3 }).run()" |
|
|
|
|
:class="{ 'is-active': editor.isActive('orderedList') }" |
|
|
|
|
@click="editor!.chain().focus().toggleOrderedList().run()" |
|
|
|
|
> |
|
|
|
|
<MsFormatH3 /> |
|
|
|
|
<MdiFormatListNumber /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> {{ $t('labels.taskList') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('taskList') }" |
|
|
|
|
@click="editor!.chain().focus().toggleTaskList().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatListCheckbox /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<div class="divider"></div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<NcTooltip v-if="embedMode"> |
|
|
|
|
<template #title> {{ $t('labels.blockQuote') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('blockquote') }" |
|
|
|
|
@click="editor!.chain().focus().toggleBlockquote().run()" |
|
|
|
|
> |
|
|
|
|
<TablerBlockQuote class="-mt-0.25" /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> {{ $t('labels.bulletList') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('bulletList') }" |
|
|
|
|
@click="editor!.chain().focus().toggleBulletList().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatBulletList /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> {{ $t('labels.numberedList') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('orderedList') }" |
|
|
|
|
@click="editor!.chain().focus().toggleOrderedList().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatListNumber /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<NcTooltip> |
|
|
|
|
<template #title> {{ $t('labels.taskList') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('taskList') }" |
|
|
|
|
@click="editor!.chain().focus().toggleTaskList().run()" |
|
|
|
|
> |
|
|
|
|
<MdiFormatListCheckbox /> |
|
|
|
|
</NcButton> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<div class="divider"></div> |
|
|
|
|
|
|
|
|
|
<NcTooltip :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<NcTooltip :placement="isFormField ? 'bottom' : undefined" :disabled="editor.isActive('codeBlock')"> |
|
|
|
|
<template #title> {{ $t('general.link') }}</template> |
|
|
|
|
<NcButton |
|
|
|
|
size="small" |
|
|
|
|
type="text" |
|
|
|
|
:class="{ 'is-active': editor.isActive('link') }" |
|
|
|
|
:disabled="editor.isActive('codeBlock')" |
|
|
|
|
:tabindex="isFormField ? -1 : 0" |
|
|
|
|
@click="onToggleLink" |
|
|
|
|
> |
|
|
|
|
<div class="flex flex-row items-center px-0.5"> |
|
|
|
|
<GeneralIcon v-if="isFormField" icon="link2"></GeneralIcon> |
|
|
|
|
<div v-else class="flex flex-row items-center px-0.5"> |
|
|
|
|
<MdiLink /> |
|
|
|
|
<div class="!text-xs !ml-1">{{ $t('general.link') }}</div> |
|
|
|
|
</div> |
|
|
|
@ -343,6 +352,9 @@ const onToggleLink = () => {
|
|
|
|
|
.bubble-menu.embed-mode { |
|
|
|
|
@apply border-transparent !shadow-none; |
|
|
|
|
} |
|
|
|
|
.bubble-menu.form-field-mode { |
|
|
|
|
@apply bg-transparent px-0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.embed-mode.bubble-menu { |
|
|
|
|
@apply !py-0 !my-0 !border-0; |
|
|
|
|