feat: add bold and italic buttons to editor (#1469)
This commit is contained in:
parent
7380e243c4
commit
b7a3e93097
4 changed files with 61 additions and 14 deletions
52
components/publish/PublishEditorTools.vue
Normal file
52
components/publish/PublishEditorTools.vue
Normal file
|
@ -0,0 +1,52 @@
|
|||
<script setup lang="ts">
|
||||
import type { Editor } from '@tiptap/core'
|
||||
const { editor } = defineProps<{
|
||||
editor: Editor
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CommonTooltip placement="top" :content="$t('tooltip.open_editor_tools')">
|
||||
<VDropdown v-if="editor" placement="top">
|
||||
<button
|
||||
btn-action-icon
|
||||
>
|
||||
<div i-ri:font-size-2 />
|
||||
</button>
|
||||
<template #popper>
|
||||
<div flex gap-1>
|
||||
<CommonTooltip placement="top" :content="$t('tooltip.toggle_code_block')">
|
||||
<button
|
||||
btn-action-icon
|
||||
:aria-label="$t('tooltip.toggle_code_block')"
|
||||
:class="editor.isActive('codeBlock') ? 'text-primary' : ''"
|
||||
@click="editor?.chain().focus().toggleCodeBlock().run()"
|
||||
>
|
||||
<div i-ri:code-s-slash-line />
|
||||
</button>
|
||||
</CommonTooltip>
|
||||
<CommonTooltip placement="top" :content="$t('tooltip.toggle_bold')">
|
||||
<button
|
||||
btn-action-icon
|
||||
:aria-label="$t('tooltip.toggle_bold')"
|
||||
:class="editor.isActive('bold') ? 'text-primary' : ''"
|
||||
@click="editor?.chain().focus().toggleBold().run()"
|
||||
>
|
||||
<div i-ri:bold />
|
||||
</button>
|
||||
</CommonTooltip>
|
||||
<CommonTooltip placement="top" :content="$t('tooltip.toggle_italic')">
|
||||
<button
|
||||
btn-action-icon
|
||||
:aria-label="$t('tooltip.toggle_italic')"
|
||||
:class="editor.isActive('italic') ? 'text-primary' : ''"
|
||||
@click="editor?.chain().focus().toggleItalic().run()"
|
||||
>
|
||||
<div i-ri:italic />
|
||||
</button>
|
||||
</CommonTooltip>
|
||||
</div>
|
||||
</template>
|
||||
</VDropdown>
|
||||
</CommonTooltip>
|
||||
</template>
|
|
@ -268,18 +268,7 @@ defineExpose({
|
|||
</button>
|
||||
</CommonTooltip>
|
||||
|
||||
<template v-if="editor">
|
||||
<CommonTooltip placement="top" :content="$t('tooltip.toggle_code_block')">
|
||||
<button
|
||||
btn-action-icon
|
||||
:aria-label="$t('tooltip.toggle_code_block')"
|
||||
:class="editor.isActive('codeBlock') ? 'text-primary' : ''"
|
||||
@click="editor?.chain().focus().toggleCodeBlock().run()"
|
||||
>
|
||||
<div i-ri:code-s-slash-line />
|
||||
</button>
|
||||
</CommonTooltip>
|
||||
</template>
|
||||
<PublishEditorTools v-if="editor" :editor="editor" />
|
||||
|
||||
<div flex-auto />
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue