copy change when open

This commit is contained in:
Nate Kelley 2025-09-30 13:38:32 -06:00
parent 5326938722
commit c08cdc085f
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 5 additions and 7 deletions

View File

@ -7,6 +7,7 @@ import {
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import type { TElement } from 'platejs';
import { usePluginOption } from 'platejs/react';
import type * as React from 'react';
import { Button } from '@/components/ui/buttons';
import { cn } from '@/lib/utils';
@ -49,11 +50,12 @@ export function CaptionTextarea(props: React.ComponentProps<typeof CaptionTextar
export const CaptionButton = (props: React.ComponentProps<typeof Button>) => {
const captionButtonState = useCaptionButtonState();
const hasCaption = (captionButtonState.element?.caption as TElement[])?.length > 0;
const visibleId = usePluginOption(CaptionPlugin, 'visibleId');
const element = captionButtonState.element;
const isOpen = visibleId === element.id;
const hasCaption = (captionButtonState.element?.caption as TElement[]) !== undefined || isOpen;
const text = hasCaption ? NodeTypeLabels.removeCaption.label : NodeTypeLabels.addCaption.label;
const editor = captionButtonState.editor;
const element = captionButtonState.element;
const addCaption = () => {
const path = editor.api.findPath(element);

View File

@ -72,10 +72,6 @@ export function MetricToolbar({
onOpenAutoFocus={(e) => e.preventDefault()}
>
<div className="box-content flex items-center space-x-2">
{/* <Button onClick={onOpenEdit} variant="ghost">
{NodeTypeLabels.editMetric?.label}
</Button> */}
<CaptionButton />
<Separator orientation="vertical" className=" h-6" />