plane/web/components/pages/editor/summary/content-browser.tsx
Anmol Singh Bhatia d1978be778
[WEB-1100] fix: bug fixes and enhancement (#4318)
* fix: inbox issue description

* chore: outline heading removed from page toc

* chore: label setting page ui improvement

* fix: update issue modal description resetting

* chore: project page head title improvement
2024-04-30 19:39:50 +05:30

49 lines
1.5 KiB
TypeScript

// types
import { EditorReadOnlyRefApi, EditorRefApi, IMarking } from "@plane/document-editor";
import { OutlineHeading1, OutlineHeading2, OutlineHeading3 } from "./heading-components";
type Props = {
editorRef: EditorRefApi | EditorReadOnlyRefApi | null;
markings: IMarking[];
setSidePeekVisible?: (sidePeekState: boolean) => void;
};
export const PageContentBrowser: React.FC<Props> = (props) => {
const { editorRef, markings, setSidePeekVisible } = props;
const handleOnClick = (marking: IMarking) => {
editorRef?.scrollSummary(marking);
if (setSidePeekVisible) setSidePeekVisible(false);
};
const HeadingComponent: {
[key: number]: React.FC<{ marking: IMarking; onClick: () => void }>;
} = {
1: OutlineHeading1,
2: OutlineHeading2,
3: OutlineHeading3,
};
return (
<div className="h-full flex flex-col overflow-hidden">
<div className="h-full flex flex-col items-start gap-y-2 overflow-y-auto mt-2">
{markings.length !== 0 ? (
markings.map((marking) => {
const Component = HeadingComponent[marking.level];
if (!Component) return null;
return (
<Component
key={`${marking.level}-${marking.sequence}`}
marking={marking}
onClick={() => handleOnClick(marking)}
/>
);
})
) : (
<p className="mt-3 text-xs text-custom-text-400">Headings will be displayed here for navigation</p>
)}
</div>
</div>
);
};