Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions src/components/editor/RichContentEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,36 @@ interface RichContentEditorProps {
onUpdate?: (content: string) => void;
}

interface ToolbarButtonProps {
onClick: () => void;
isActive?: boolean;
disabled?: boolean;
children: React.ReactNode;
title?: string;
}

const ToolbarButton = ({
onClick,
isActive = false,
disabled = false,
children,
title,
}: ToolbarButtonProps) => (
<button
type="button"
onClick={onClick}
disabled={disabled}
aria-pressed={isActive}
aria-label={title}
className={`p-2 rounded hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors ${
isActive ? 'bg-gray-200 dark:bg-gray-600 text-blue-600' : 'text-gray-600 dark:text-gray-300'
} ${disabled ? 'opacity-50 cursor-not-allowed' : ''}`}
title={title}
>
{children}
</button>
);

export const RichContentEditor: React.FC<RichContentEditorProps> = ({
initialContent,
onUpdate,
Expand All @@ -43,34 +73,6 @@ export const RichContentEditor: React.FC<RichContentEditorProps> = ({
return null;
}

const ToolbarButton = ({
onClick,
isActive = false,
disabled = false,
children,
title,
}: {
onClick: () => void;
isActive?: boolean;
disabled?: boolean;
children: React.ReactNode;
title?: string;
}) => (
<button
type="button"
onClick={onClick}
disabled={disabled}
aria-pressed={isActive}
aria-label={title}
className={`p-2 rounded hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors ${
isActive ? 'bg-gray-200 dark:bg-gray-600 text-blue-600' : 'text-gray-600 dark:text-gray-300'
} ${disabled ? 'opacity-50 cursor-not-allowed' : ''}`}
title={title}
>
{children}
</button>
);

return (
<section
aria-labelledby={editorTitleId}
Expand Down
Loading