11<template >
22 <div class =" mb-2 w-full flex flex-col" >
33 <div class =" flex flex-wrap items-center gap-3 p-1.5 border border-gray-300 dark:border-gray-600 rounded-t-lg bg-gray-50 dark:bg-gray-800 w-full box-border " >
4- <button type =" button" @click =" applyFormat('bold')" :class =" btnClass" title =" Bold" aria-label =" Bold" ><IconLetterBoldOutline class =" w-5 h-5" /></button >
5- <button type =" button" @click =" applyFormat('italic')" :class =" btnClass" title =" Italic" aria-label =" Italic" ><IconLetterItalicOutline class =" w-5 h-5" /></button >
6- <button type =" button" @click =" applyFormat('underline')" :class =" btnClass" title =" Underline" aria-label =" Underline" ><IconLetterUnderlineOutline class =" w-5 h-5" /></button >
7- <button type =" button" @click =" applyFormat('strike')" :class =" btnClass" title =" Strikethrough" aria-label =" Strikethrough" ><IconTextSlashOutline class =" w-5 h-5" /></button >
4+
5+ <button v-if =" isBtnVisible('bold')" type =" button" @click =" applyFormat('bold')" :class =" btnClass" title =" Bold" ><IconLetterBoldOutline class =" w-5 h-5" /></button >
6+ <button v-if =" isBtnVisible('italic')" type =" button" @click =" applyFormat('italic')" :class =" btnClass" title =" Italic" ><IconLetterItalicOutline class =" w-5 h-5" /></button >
7+ <button v-if =" isBtnVisible('underline')" type =" button" @click =" applyFormat('underline')" :class =" btnClass" title =" Underline" ><IconLetterUnderlineOutline class =" w-5 h-5" /></button >
8+ <button v-if =" isBtnVisible('strike')" type =" button" @click =" applyFormat('strike')" :class =" btnClass" title =" Strikethrough" ><IconTextSlashOutline class =" w-5 h-5" /></button >
89
910 <div class =" w-px h-4 bg-gray-300 dark:bg-gray-600 mx-1" ></div >
1011
11- <button type =" button" @click =" applyFormat('h2')" :class =" btnClass" title =" Heading 2" aria-label =" Heading 2" ><IconH216Solid class =" w-5 h-5" /></button >
12- <button type =" button" @click =" applyFormat('h3')" :class =" btnClass" title =" Heading 3" aria-label =" Heading 3" ><IconH316Solid class =" w-5 h-5" /></button >
12+ <button v-if =" isBtnVisible('h1')" type =" button" @click =" applyFormat('h1')" :class =" btnClass" title =" Heading 1" ><IconH116Solid class =" w-5 h-5" /></button >
13+ <button v-if =" isBtnVisible('h2')" type =" button" @click =" applyFormat('h2')" :class =" btnClass" title =" Heading 2" ><IconH216Solid class =" w-5 h-5" /></button >
14+ <button v-if =" isBtnVisible('h3')" type =" button" @click =" applyFormat('h3')" :class =" btnClass" title =" Heading 3" ><IconH316Solid class =" w-5 h-5" /></button >
1315
1416 <div class =" w-px h-4 bg-gray-300 dark:bg-gray-600 mx-1" ></div >
1517
16- <button type =" button" @click =" applyFormat('ul')" :class =" btnClass" title = " Bulleted List " aria-label =" Bulleted List" ><IconRectangleListOutline class =" w-5 h-5" /></button >
17- <button type =" button" @click =" applyFormat('ol')" :class =" btnClass" title = " Numbered List " aria-label =" Numbered List" ><IconOrderedListOutline class =" w-5 h-5" /></button >
18+ <button v-if = " isBtnVisible('ul') " type =" button" @click =" applyFormat('ul')" :class =" btnClass" title =" Bulleted List" ><IconRectangleListOutline class =" w-5 h-5" /></button >
19+ <button v-if = " isBtnVisible('ol') " type =" button" @click =" applyFormat('ol')" :class =" btnClass" title =" Numbered List" ><IconOrderedListOutline class =" w-5 h-5" /></button >
1820
19- <div class =" w-px h-4 bg-gray-300 dark:bg-gray-600 mx-1" ></div >
20-
21- <button type =" button" @click =" applyFormat('link')" :class =" btnClass" title =" Link" aria-label =" Link" ><IconLinkOutline class =" w-5 h-5" /></button >
22- <button type =" button" @click =" applyFormat('codeBlock')" :class =" btnClass" title =" Code" aria-label =" Code" ><IconCodeOutline class =" w-5 h-5" /></button >
21+ <button v-if =" isBtnVisible('link')" type =" button" @click =" applyFormat('link')" :class =" btnClass" title =" Link" ><IconLinkOutline class =" w-5 h-5" /></button >
22+ <button v-if =" isBtnVisible('codeBlock')" type =" button" @click =" applyFormat('codeBlock')" :class =" btnClass" title =" Code" ><IconCodeOutline class =" w-5 h-5" /></button >
2323 </div >
2424
2525 <div
@@ -43,14 +43,21 @@ import TurndownService from 'turndown';
4343import { gfm , tables } from ' turndown-plugin-gfm' ;
4444import { toggleWrapSmart } from ' ./utils/monacoMarkdownToggle' ;
4545import { IconLinkOutline , IconCodeOutline , IconRectangleListOutline , IconOrderedListOutline , IconLetterBoldOutline , IconLetterUnderlineOutline , IconLetterItalicOutline , IconTextSlashOutline } from ' @iconify-prerendered/vue-flowbite' ;
46- import { IconH216Solid , IconH316Solid } from ' @iconify-prerendered/vue-heroicons' ;
46+ import { IconH116Solid , IconH216Solid , IconH316Solid } from ' @iconify-prerendered/vue-heroicons' ;
4747
4848const props = defineProps <{
4949 column: any ,
5050 record: any ,
5151 meta: any ,
5252}>()
5353
54+ const isBtnVisible = (btnKey : string ) => {
55+ const settings = props .meta .topPanelSettings ;
56+ if (! settings || Object .keys (settings ).length === 0 ) return true ;
57+ if (settings [btnKey ] !== undefined ) return settings [btnKey ];
58+ return true ;
59+ };
60+
5461const btnClass = ' flex items-center justify-center h-8 px-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 transition-colors duration-200' ;
5562
5663const emit = defineEmits ([' update:value' ]);
@@ -578,7 +585,7 @@ const applyFormat = (type: string) => {
578585 };
579586
580587 const handleBlockFormat = (formatType : string ) => {
581- const prefixMap: Record <string , string > = { h2: ' ## ' , h3: ' ### ' , ul: ' * ' };
588+ const prefixMap: Record <string , string > = { h1: ' # ' , h2: ' ## ' , h3: ' ### ' , ul: ' * ' };
582589 const edits: monaco .editor .IIdentifiedSingleEditOperation [] = [];
583590
584591 for (let i = selection .startLineNumber ; i <= selection .endLineNumber ; i ++ ) {
@@ -608,6 +615,7 @@ const applyFormat = (type: string) => {
608615 case ' underline' : handleWrap (' <u>' , ' </u>' ); break ;
609616 case ' codeBlock' : handleCodeBlock (); break ;
610617 case ' link' : handleLink (); break ;
618+ case ' h1' :
611619 case ' h2' :
612620 case ' h3' :
613621 case ' ul' :
0 commit comments