返回 presentation-ai
visualization-item-static.tsx
根目录 / src / components / notebook / presentation / editor / custom-elements / legacy / visualization-item-static.tsx
1 import { NodeApi, PathApi, type TElement } from "platejs";
2 import { type SlateElementProps } from "platejs/static";
3 import type * as React from "react";
4
5 import { ARROW_LIST_ITEM, PYRAMID_ITEM, TIMELINE_ITEM } from "../../lib";
6 import { type TArrowListItemElement } from "../../plugins/arrow-plugin";
7 import { ArrowItemStatic } from "../static/arrow-item-static";
8 import { PyramidItemStatic } from "../static/pyramid-item-static";
9 import { TimelineItemStatic } from "../static/timeline-item-static";
10
11 export default function VisualizationItemElementStatic({
12 element,
13 ...props
14 }: SlateElementProps) {
15 const parentPath = PathApi.parent(props.path);
16 const parentElement = NodeApi.get(props.editor, parentPath);
17
18 const visualizationType = parentElement?.visualizationType as
19 | "arrow"
20 | "pyramid"
21 | "timeline";
22
23 switch (visualizationType) {
24 case "pyramid": {
25 const pyramidItemElement = {
26 ...element,
27 children: element.children,
28 type: PYRAMID_ITEM,
29 };
30 return (
31 <PyramidItemStatic element={pyramidItemElement as TElement} {...props}>
32 {props.children as React.ReactNode}
33 </PyramidItemStatic>
34 );
35 }
36 case "arrow": {
37 const arrowItemElement = {
38 ...element,
39 children: element.children,
40 type: ARROW_LIST_ITEM,
41 };
42 return (
43 <ArrowItemStatic
44 element={arrowItemElement as TArrowListItemElement}
45 {...props}
46 >
47 {props.children as React.ReactNode}
48 </ArrowItemStatic>
49 );
50 }
51 case "timeline": {
52 const timelineItemElement = {
53 ...element,
54 children: element.children,
55 type: TIMELINE_ITEM,
56 };
57 return (
58 <TimelineItemStatic
59 element={timelineItemElement as TElement}
60 {...props}
61 >
62 {props.children as React.ReactNode}
63 </TimelineItemStatic>
64 );
65 }
66 }
67 }
68
68 lines Plain Text