260728_02_ENH: 에디터 툴바 동적 슬롯 사용할 수 있도록 변경
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import type { Editor } from '@tiptap/react'
|
||||
import {
|
||||
AlignCenter,
|
||||
@@ -50,6 +50,7 @@ interface ToolbarProps {
|
||||
onAddRow: () => void
|
||||
onAddColumn: () => void
|
||||
onDeleteTable: () => void
|
||||
customContent?: ReactNode
|
||||
}
|
||||
|
||||
const PRESET_COLORS = [
|
||||
@@ -85,6 +86,7 @@ export function Toolbar({
|
||||
onAddRow,
|
||||
onAddColumn,
|
||||
onDeleteTable,
|
||||
customContent,
|
||||
}: ToolbarProps) {
|
||||
const enabled = (feature: KriEditorToolbarFeature) => config?.[feature] !== false
|
||||
const showTextStyle = enabled('bold') || enabled('italic') || enabled('underline') || enabled('strike')
|
||||
@@ -278,6 +280,12 @@ export function Toolbar({
|
||||
<ToolbarButton active={isHtmlView} title={isHtmlView ? 'WYSIWYG로 전환' : 'HTML 편집'} onClick={onToggleHtmlView}><Code2 className="size-4" /></ToolbarButton>
|
||||
</>
|
||||
) : null}
|
||||
{customContent ? (
|
||||
<>
|
||||
<Separator orientation="vertical" className="mx-1 h-6" />
|
||||
{customContent}
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { ReactNode, MouseEvent } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type Props = {
|
||||
export type KriEditorToolbarButtonProps = {
|
||||
active?: boolean;
|
||||
disabled?: boolean;
|
||||
title?: string;
|
||||
@@ -13,7 +13,7 @@ type Props = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function ToolbarButton({ active, disabled, title, onClick, children, className }: Props) {
|
||||
export function ToolbarButton({ active, disabled, title, onClick, children, className }: KriEditorToolbarButtonProps) {
|
||||
const onMouseDown = (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user