mirror of https://github.com/buster-so/buster.git
fix toc
This commit is contained in:
parent
1f8cdd1677
commit
ab9b19e9cd
|
@ -71,7 +71,7 @@ export const ReportPlayground: React.FC = () => {
|
||||||
|
|
||||||
<ThemePicker />
|
<ThemePicker />
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-background h-full max-h-[calc(100vh-56px)] overflow-y-auto rounded border shadow">
|
<div className="bg-background h-full max-h-[calc(100vh-56px)] overflow-hidden rounded border shadow">
|
||||||
<DynamicReportEditor value={usedValue} readOnly={false} onValueChange={logValueChanges} />
|
<DynamicReportEditor value={usedValue} readOnly={false} onValueChange={logValueChanges} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -50,7 +50,7 @@ export function EditorContainer({
|
||||||
return (
|
return (
|
||||||
<PlateContainer
|
<PlateContainer
|
||||||
className={cn(
|
className={cn(
|
||||||
'ignore-click-outside/toolbar',
|
'ignore-click-outside/toolbar overflow-y-auto',
|
||||||
editorContainerVariants({ variant, readonly }),
|
editorContainerVariants({ variant, readonly }),
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -12,7 +12,9 @@ interface ThemeWrapperProps extends React.ComponentProps<'div'> {
|
||||||
export function ThemeWrapper({ children, className, defaultTheme }: ThemeWrapperProps) {
|
export function ThemeWrapper({ children, className, defaultTheme }: ThemeWrapperProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div style={THEME_RESET_STYLE} className={cn('themes-wrapper w-full antialiased', className)}>
|
<div
|
||||||
|
style={THEME_RESET_STYLE}
|
||||||
|
className={cn('themes-wrapper h-full w-full overflow-hidden antialiased', className)}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,7 @@ import LiteYouTubeEmbed from 'react-lite-youtube-embed';
|
||||||
import type { TMediaEmbedElement } from 'platejs';
|
import type { TMediaEmbedElement } from 'platejs';
|
||||||
import type { PlateElementProps } from 'platejs/react';
|
import type { PlateElementProps } from 'platejs/react';
|
||||||
|
|
||||||
import {
|
import { parseTwitterUrl, parseVideoUrl, type EmbedUrlParser } from '@platejs/media';
|
||||||
parseTwitterUrl,
|
|
||||||
parseVideoUrl,
|
|
||||||
parseIframeUrl,
|
|
||||||
parseMediaUrl,
|
|
||||||
type EmbedUrlParser
|
|
||||||
} from '@platejs/media';
|
|
||||||
import { MediaEmbedPlugin, useMediaState } from '@platejs/media/react';
|
import { MediaEmbedPlugin, useMediaState } from '@platejs/media/react';
|
||||||
import { ResizableProvider, useResizableValue } from '@platejs/resizable';
|
import { ResizableProvider, useResizableValue } from '@platejs/resizable';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -6,12 +6,10 @@ import type { PlateElementProps } from 'platejs/react';
|
||||||
|
|
||||||
import { useTocElement, useTocElementState } from '@platejs/toc/react';
|
import { useTocElement, useTocElementState } from '@platejs/toc/react';
|
||||||
import { cva } from 'class-variance-authority';
|
import { cva } from 'class-variance-authority';
|
||||||
import { PlateElement } from 'platejs/react';
|
import { PlateElement, useScrollRef } from 'platejs/react';
|
||||||
|
|
||||||
import { Button } from '@/components/ui/buttons';
|
|
||||||
|
|
||||||
const headingItemVariants = cva(
|
const headingItemVariants = cva(
|
||||||
'block h-auto w-full cursor-pointer truncate rounded-none px-0.5 py-1.5 text-left font-medium text-muted-foreground underline decoration-[0.5px] underline-offset-4 hover:bg-accent hover:text-muted-foreground',
|
'block! h-auto w-full cursor-pointer truncate rounded-none px-0.5 py-1 text-left font-medium text-muted-foreground underline decoration-[0.5px] underline-offset-4 hover:bg-accent hover:text-muted-foreground',
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
depth: {
|
depth: {
|
||||||
|
@ -28,21 +26,22 @@ export function TocElement(props: PlateElementProps) {
|
||||||
const { props: btnProps } = useTocElement(state);
|
const { props: btnProps } = useTocElement(state);
|
||||||
const { headingList } = state;
|
const { headingList } = state;
|
||||||
|
|
||||||
|
const containerRef = useScrollRef();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PlateElement {...props} className="mb-1 p-0">
|
<PlateElement {...props} className="mb-1 p-0">
|
||||||
<div contentEditable={false}>
|
<div contentEditable={false}>
|
||||||
{headingList.length > 0 ? (
|
{headingList.length > 0 ? (
|
||||||
headingList.map((item) => (
|
headingList.map((item) => (
|
||||||
<Button
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
variant="ghost"
|
|
||||||
className={headingItemVariants({
|
className={headingItemVariants({
|
||||||
depth: item.depth as 1 | 2 | 3
|
depth: item.depth as 1 | 2 | 3
|
||||||
})}
|
})}
|
||||||
onClick={(e) => btnProps.onClick(e, item, 'smooth')}
|
onClick={(e) => btnProps.onClick(e, item, 'smooth')}
|
||||||
aria-current>
|
aria-current>
|
||||||
{item.title}
|
{item.title}
|
||||||
</Button>
|
</div>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
|
|
Loading…
Reference in New Issue