返回 presentation-ai
cons-item-static.tsx
根目录 / src / components / notebook / presentation / editor / custom-elements / static / cons-item-static.tsx
1 import { NodeApi, PathApi } from "platejs";
2 import { SlateElement, type SlateElementProps } from "platejs/static";
3
4 import { cn } from "@/lib/utils";
5 import { getAlignmentClasses } from "../../utils";
6
7 export function ConsItemStatic(props: SlateElementProps) {
8 const path = props.editor.api.findPath(props.element) ?? [-1];
9 const parentPath = PathApi.parent(path);
10 const parentElement = NodeApi.get(props.editor, parentPath);
11 const { alignment = "left" } = parentElement as {
12 alignment?: "left" | "center" | "right";
13 };
14
15 return (
16 <div
17 className={cn("flex h-full flex-col rounded-lg p-6 text-white")}
18 data-bg-export="true"
19 style={{
20 background: "linear-gradient(135deg, #e74c3c 0%, #c0392b 100%)",
21 }}
22 >
23 <SlateElement {...props} className={cn(getAlignmentClasses(alignment))}>
24 {props.children}
25 </SlateElement>
26 </div>
27 );
28 }
29
29 lines Plain Text