260810_02_ENH: wysiwyg 에디터 툴바에 폰트 패밀리 추가
This commit is contained in:
@@ -25,7 +25,7 @@ import { Input } from '@/components/ui/input'
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { cn } from '@/lib/utils'
|
||||
import type { KriEditorToolbarConfig, KriEditorToolbarFeature, ToolbarState } from '../types'
|
||||
import type { KriEditorFontFamilyOption, KriEditorToolbarConfig, KriEditorToolbarFeature, ToolbarState } from '../types'
|
||||
import { ToolbarButton } from './ToolbarButton'
|
||||
|
||||
interface ToolbarProps {
|
||||
@@ -38,6 +38,8 @@ interface ToolbarProps {
|
||||
showHtmlToggle: boolean
|
||||
isHtmlView: boolean
|
||||
onToggleHtmlView: () => void
|
||||
fontFamilyOptions: KriEditorFontFamilyOption[]
|
||||
onSetFontFamily: (value: string) => void
|
||||
onSetFontSize: (value: string) => void
|
||||
onSetTextColor: (value: string) => void
|
||||
onUnsetTextColor: () => void
|
||||
@@ -74,6 +76,8 @@ export function Toolbar({
|
||||
showHtmlToggle,
|
||||
isHtmlView,
|
||||
onToggleHtmlView,
|
||||
fontFamilyOptions,
|
||||
onSetFontFamily,
|
||||
onSetFontSize,
|
||||
onSetTextColor,
|
||||
onUnsetTextColor,
|
||||
@@ -89,6 +93,7 @@ export function Toolbar({
|
||||
customContent,
|
||||
}: ToolbarProps) {
|
||||
const enabled = (feature: KriEditorToolbarFeature) => config?.[feature] !== false
|
||||
const showFontControls = enabled('fontFamily') || enabled('fontSize')
|
||||
const showTextStyle = enabled('bold') || enabled('italic') || enabled('underline') || enabled('strike')
|
||||
const showColors = enabled('textColor') || enabled('highlight')
|
||||
const showLists = enabled('bulletList') || enabled('orderedList')
|
||||
@@ -108,6 +113,19 @@ export function Toolbar({
|
||||
|
||||
return (
|
||||
<div className={cn('flex items-center gap-1 overflow-x-auto whitespace-nowrap px-2 py-1', className)}>
|
||||
{enabled('fontFamily') ? (
|
||||
<select
|
||||
className="h-8 w-[132px] rounded-md border bg-background px-2 text-sm"
|
||||
value={state.fontFamily ?? ''}
|
||||
onChange={(event) => onSetFontFamily(event.target.value)}
|
||||
title="글꼴"
|
||||
>
|
||||
{fontFamilyOptions.map((option) => (
|
||||
<option key={option.value} value={option.value}>{option.label}</option>
|
||||
))}
|
||||
</select>
|
||||
) : null}
|
||||
|
||||
{enabled('fontSize') ? (
|
||||
<select
|
||||
className="h-8 w-[72px] rounded-md border bg-background px-2 text-sm"
|
||||
@@ -121,7 +139,7 @@ export function Toolbar({
|
||||
</select>
|
||||
) : null}
|
||||
|
||||
{enabled('fontSize') && showTextStyle ? <Separator orientation="vertical" className="mx-1 h-6" /> : null}
|
||||
{showFontControls && showTextStyle ? <Separator orientation="vertical" className="mx-1 h-6" /> : null}
|
||||
|
||||
{enabled('bold') ? (
|
||||
<ToolbarButton active={state.isBold} disabled={!editor.can().chain().focus().toggleBold().run()} onClick={() => editor.chain().focus().toggleBold().run()} title="굵게">
|
||||
|
||||
Reference in New Issue
Block a user