Editor container fix

This commit is contained in:
Nate Kelley 2025-08-07 13:25:08 -06:00
parent 12d060cf58
commit 409af5e02e
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
11 changed files with 32 additions and 72 deletions

View File

@ -13,6 +13,7 @@ import {
COLLAPSED_JUSTIFY_CENTER, COLLAPSED_JUSTIFY_CENTER,
COLLAPSED_VISIBLE, COLLAPSED_VISIBLE,
type ISidebarGroup, type ISidebarGroup,
type ISidebarItem,
type ISidebarList, type ISidebarList,
type SidebarProps type SidebarProps
} from '@/components/ui/sidebar'; } from '@/components/ui/sidebar';
@ -89,15 +90,15 @@ const yourStuff = (
route: createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS }), route: createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS }),
id: BusterRoutes.APP_COLLECTIONS, id: BusterRoutes.APP_COLLECTIONS,
active: isActiveCheck('collection', BusterRoutes.APP_COLLECTIONS) active: isActiveCheck('collection', BusterRoutes.APP_COLLECTIONS)
},
process.env.NEXT_PUBLIC_ENABLE_REPORTS === 'true' && {
label: 'Reports',
icon: <ASSET_ICONS.reports />,
route: createBusterRoute({ route: BusterRoutes.APP_REPORTS }),
id: BusterRoutes.APP_REPORTS,
active: isActiveCheck('report', BusterRoutes.APP_REPORTS)
} }
// { ].filter(Boolean) as ISidebarItem[]
// label: 'Reports',
// icon: <ASSET_ICONS.reports />,
// route: createBusterRoute({ route: BusterRoutes.APP_REPORTS }),
// id: BusterRoutes.APP_REPORTS,
// active: isActiveCheck('report', BusterRoutes.APP_REPORTS)
// }
]
}; };
}; };

View File

@ -11,7 +11,7 @@ import React from 'react';
const editorVariants = cva( const editorVariants = cva(
cn( cn(
'group/editor', 'group/editor',
'relative w-full cursor-text overflow-x-hidden break-words whitespace-pre-wrap select-text', 'relative w-full cursor-text overflow-x-visible break-words whitespace-pre-wrap select-text',
'rounded-md ring-offset-background focus-visible:outline-none', 'rounded-md ring-offset-background focus-visible:outline-none',
'placeholder:text-muted-foreground/80 **:data-slate-placeholder:!top-1/2 **:data-slate-placeholder:-translate-y-1/2 **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!', 'placeholder:text-muted-foreground/80 **:data-slate-placeholder:!top-1/2 **:data-slate-placeholder:-translate-y-1/2 **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!',
'[&_strong]:font-bold' '[&_strong]:font-bold'
@ -42,6 +42,7 @@ export type EditorProps = PlateContentProps & VariantProps<typeof editorVariants
export const Editor = React.forwardRef<HTMLDivElement, EditorProps>( export const Editor = React.forwardRef<HTMLDivElement, EditorProps>(
({ className, disabled, focused, variant, ...props }, ref) => { ({ className, disabled, focused, variant, ...props }, ref) => {
console.log('Editor', { className, disabled, focused, variant, ...props });
return ( return (
<PlateContent <PlateContent
ref={ref} ref={ref}

View File

@ -50,7 +50,7 @@ export function EditorContainer({
return ( return (
<PlateContainer <PlateContainer
className={cn( className={cn(
'ignore-click-outside/toolbar overflow-y-auto', 'ignore-click-outside/toolbar overflow-visible! overflow-y-auto',
editorContainerVariants({ variant, readonly }), editorContainerVariants({ variant, readonly }),
className className
)} )}

View File

@ -1,49 +0,0 @@
import * as React from 'react';
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import { type PlateStaticProps, PlateStatic } from 'platejs';
import { cn } from '@/lib/utils';
export const editorVariants = cva(
cn(
'group/editor',
'relative w-full cursor-text overflow-x-hidden break-words whitespace-pre-wrap select-text',
'rounded-md ring-offset-background focus-visible:outline-none',
'placeholder:text-muted-foreground/80 **:data-slate-placeholder:top-[auto_!important] **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!',
'[&_strong]:font-bold'
),
{
defaultVariants: {
variant: 'none'
},
variants: {
disabled: {
true: 'cursor-not-allowed opacity-50'
},
focused: {
true: 'ring-2 ring-ring ring-offset-2'
},
variant: {
ai: 'w-full px-0 text-base md:text-sm',
aiChat:
'max-h-[min(70vh,320px)] w-full max-w-[700px] overflow-y-auto px-5 py-3 text-base md:text-sm',
default: 'size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
demo: 'size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
fullWidth: 'size-full px-16 pt-4 pb-72 text-base sm:px-24',
none: '',
select: 'px-3 py-2 text-base data-readonly:w-fit'
}
}
}
);
export function EditorStatic({
className,
variant,
...props
}: PlateStaticProps & VariantProps<typeof editorVariants>) {
return <PlateStatic className={cn(editorVariants({ variant }), className)} {...props} />;
}

View File

@ -16,6 +16,7 @@ interface ReportEditorProps {
readOnly?: boolean; readOnly?: boolean;
variant?: 'default'; variant?: 'default';
className?: string; className?: string;
containerClassName?: string;
disabled?: boolean; disabled?: boolean;
style?: React.CSSProperties; style?: React.CSSProperties;
onValueChange?: (value: ReportElements) => void; onValueChange?: (value: ReportElements) => void;
@ -41,6 +42,7 @@ export const ReportEditor = React.memo(
onReady, onReady,
variant = 'default', variant = 'default',
className, className,
containerClassName,
style, style,
useFixedToolbarKit = false, useFixedToolbarKit = false,
readOnly = false, readOnly = false,
@ -73,8 +75,14 @@ export const ReportEditor = React.memo(
variant={variant} variant={variant}
readonly={readOnly} readonly={readOnly}
disabled={disabled} disabled={disabled}
className={cn('pb-[15vh]', className)}> className={containerClassName}>
<Editor style={style} placeholder={placeholder} disabled={disabled} autoFocus /> <Editor
style={style}
placeholder={placeholder}
disabled={disabled}
className={cn('pb-[20vh]', className)}
autoFocus
/>
</EditorContainer> </EditorContainer>
</Plate> </Plate>
</ThemeWrapper> </ThemeWrapper>

View File

@ -49,7 +49,7 @@ export function ThemeWrapper({ children, className, defaultTheme }: ThemeWrapper
<div <div
style={EDITOR_THEME} style={EDITOR_THEME}
className={cn( className={cn(
'themes-wrapper h-full w-full overflow-hidden bg-transparent antialiased', 'themes-wrapper h-full w-full overflow-visible bg-transparent antialiased',
className className
)}> )}>
{children} {children}

View File

@ -6,7 +6,7 @@ import { useAIChatEditor } from '@platejs/ai/react';
import { usePlateEditor } from 'platejs/react'; import { usePlateEditor } from 'platejs/react';
import { BaseEditorKit } from '../editor-base-kit'; import { BaseEditorKit } from '../editor-base-kit';
import { EditorStatic } from '../EditorStatic'; import { EditorStatic } from './EditorStatic';
export const AIChatEditor = React.memo(function AIChatEditor({ content }: { content: string }) { export const AIChatEditor = React.memo(function AIChatEditor({ content }: { content: string }) {
const aiEditor = usePlateEditor({ const aiEditor = usePlateEditor({

View File

@ -45,7 +45,6 @@ export const MetricPlugin = createPlatePlugin<
}, },
updateMetric: (metricId: string, options?: SetNodesOptions<TMetricElement[]>) => { updateMetric: (metricId: string, options?: SetNodesOptions<TMetricElement[]>) => {
tf.setNodes<TMetricElement>({ metricId }, options); tf.setNodes<TMetricElement>({ metricId }, options);
console.log('updated metric', metricId);
} }
}; };
}) })

View File

@ -8,7 +8,7 @@ import { useMemoizedFn } from '@/hooks/useMemoizedFn';
import { useDebounceFn } from '@/hooks/useDebounce'; import { useDebounceFn } from '@/hooks/useDebounce';
import type { ReportElements } from '@buster/server-shared/reports'; import type { ReportElements } from '@buster/server-shared/reports';
import DynamicReportEditor from '@/components/ui/report/DynamicReportEditor'; import DynamicReportEditor from '@/components/ui/report/DynamicReportEditor';
import type { AppReportRef, IReportEditor } from '@/components/ui/report/ReportEditor'; import { ReportEditor, type AppReportRef } from '@/components/ui/report/ReportEditor';
export const ReportPageController: React.FC<{ export const ReportPageController: React.FC<{
reportId: string; reportId: string;
@ -33,19 +33,19 @@ export const ReportPageController: React.FC<{
}); });
return ( return (
<div className={cn('space-y-1.5 pt-9 pb-[15vh] sm:px-[max(64px,calc(50%-350px))]', className)}> <div className={cn('space-y-1.5 pt-9 sm:px-[max(64px,calc(50%-350px))]', className)}>
<ReportPageHeader <ReportPageHeader
name={report?.name} name={report?.name}
updatedAt={report?.updated_at} updatedAt={report?.updated_at}
onChangeName={onChangeName} onChangeName={onChangeName}
/> />
<DynamicReportEditor <ReportEditor
ref={editor} ref={editor}
value={content} value={content}
onValueChange={onChangeContent} onValueChange={onChangeContent}
readOnly={readOnly} readOnly={readOnly}
className="p-0" className="swagswag px-0!"
/> />
</div> </div>
); );

View File

@ -25,8 +25,10 @@ export const ReportPageHeader = React.forwardRef<
<EditableTitle className="h-9" level={1} ref={ref} onChange={onChangeName}> <EditableTitle className="h-9" level={1} ref={ref} onChange={onChangeName}>
{name} {name}
</EditableTitle> </EditableTitle>
<Paragraph size={'base'} variant={'tertiary'}> <Paragraph size={'base'} variant={'tertiary'} className="select-none">
{updatedAtFormatted} {DEFAULT_CREATED_BY} <span className="select-text">{updatedAtFormatted}</span>
<span className="select-none"> </span>
<span className="select-text">{DEFAULT_CREATED_BY}</span>
</Paragraph> </Paragraph>
</div> </div>
); );

View File

@ -20,9 +20,7 @@ const ACCEPTED_DOMAINS = [
*/ */
export function isUrlFromAcceptedDomain(url: string): boolean { export function isUrlFromAcceptedDomain(url: string): boolean {
try { try {
console.log('url', url);
const parsedUrl = new URL(url); const parsedUrl = new URL(url);
console.log('parsedUrl', parsedUrl);
return ACCEPTED_DOMAINS.some((accepted) => { return ACCEPTED_DOMAINS.some((accepted) => {
try { try {
// If accepted is a full URL, compare origins // If accepted is a full URL, compare origins