read only partial fix

This commit is contained in:
Nate Kelley 2025-08-21 21:37:28 -06:00
parent 29fe1a1b34
commit 4cfacbc1e3
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 10 additions and 12 deletions

View File

@ -21,14 +21,13 @@ const editorVariants = cva(
variant: 'default'
},
variants: {
disabled: {
true: 'cursor-not-allowed opacity-50'
readOnly: {
true: ''
},
focused: {
true: 'ring-2 ring-ring ring-offset-2'
},
variant: {
ai: 'w-full px-0 text-base md:text-sm',
comment: cn('rounded-none border-none bg-transparent text-sm'),
default: 'px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
fullWidth: 'px-16 pt-4 pb-72 text-base sm:px-24',
@ -41,20 +40,20 @@ const editorVariants = cva(
export type EditorProps = PlateContentProps & VariantProps<typeof editorVariants>;
export const Editor = React.forwardRef<HTMLDivElement, EditorProps>(
({ className, disabled, focused, variant, ...props }, ref) => {
({ className, readOnly, focused, variant, ...props }, ref) => {
return (
<PlateContent
ref={ref}
className={cn(
editorVariants({
disabled,
readOnly,
focused,
variant
}),
className
)}
disabled={disabled}
disableDefaultStyles
readOnly={readOnly}
disableDefaultStyles={true}
{...props}
/>
);

View File

@ -26,8 +26,8 @@ const editorContainerVariants = cva(
'has-data-readonly:w-fit has-data-readonly:cursor-default has-data-readonly:border-transparent has-data-readonly:focus-within:[box-shadow:none]'
)
},
readonly: {
true: 'cursor-default pointer-events-none user-select-none'
readOnly: {
true: 'cursor-default user-select-none '
}
},
defaultVariants: {

View File

@ -118,9 +118,7 @@ export const ReportEditor = React.memo(
if (!editor) return null;
return (
<Plate
editor={editor}
onValueChange={onValueChangeDebounced}>
<Plate editor={editor} onValueChange={onValueChangeDebounced}>
<EditorContainer
variant={variant}
readOnly={readOnly}
@ -131,6 +129,7 @@ export const ReportEditor = React.memo(
style={style}
placeholder={placeholder}
className={cn('editor', className)}
readOnly={readOnly || isStreaming}
autoFocus
/>
</ThemeWrapper>