返回 presentation-ai
snake-item.tsx
1 "use client";
2
3 import { PlateElement, type PlateElementProps } from "platejs/react";
4
5 import {
6 type TSnakeGroupElement,
7 type TSnakeItemElement,
8 } from "../plugins/diagram-components-plugin";
9 import { getSiblingIndexContext } from "./sibling-index";
10 import { getSnakeGridColumn, getSnakeGridRow } from "./snake-shared";
11
12 export function SnakeItem(props: PlateElementProps<TSnakeItemElement>) {
13 const { index } = getSiblingIndexContext<TSnakeGroupElement>(
14 props.editor,
15 props.element,
16 props.path,
17 );
18 const isLowerLaneItem = index % 2 === 1;
19
20 return (
21 <PlateElement
22 {...props}
23 className="z-10 grid min-w-0 items-start justify-items-center"
24 style={{
25 alignSelf: isLowerLaneItem ? "end" : "stretch",
26 gridRow: getSnakeGridRow(index),
27 gridColumn: getSnakeGridColumn(index),
28 justifySelf: "stretch",
29 }}
30 >
31 <div className="min-w-0 px-2 text-center text-(--presentation-muted-foreground) [&_h1]:text-xl [&_h2]:text-xl [&_h3]:text-xl [&_h4]:text-lg [&_h1]:text-(--presentation-muted-foreground) [&_h2]:text-(--presentation-muted-foreground) [&_h3]:text-(--presentation-muted-foreground) [&_p]:mt-1 [&_p]:text-sm">
32 {props.children}
33 </div>
34 </PlateElement>
35 );
36 }
37
37 lines Plain Text