返回 presentation-ai
pyramid-plugin.tsx
根目录 / src / components / notebook / presentation / editor / plugins / pyramid-plugin.tsx
1 // plugins/pyramid-plugin.ts
2 import { type TElement } from "platejs";
3 import { createTPlatePlugin } from "platejs/react";
4
5 import Pyramid from "../custom-elements/pyramid";
6 import { PyramidItem } from "../custom-elements/pyramid-item";
7 import { PYRAMID_GROUP, PYRAMID_ITEM } from "../lib";
8
9 // Create plugin for pyramid group (container)
10 export const PyramidGroupPlugin = createTPlatePlugin({
11 key: PYRAMID_GROUP,
12 node: {
13 isElement: true,
14 component: Pyramid,
15 },
16 options: {
17 totalChildren: 0,
18 },
19 });
20
21 // Create plugin for pyramid item
22 export const PyramidItemPlugin = createTPlatePlugin({
23 key: PYRAMID_ITEM,
24 node: {
25 isElement: true,
26 isStrictSiblings: true,
27 component: PyramidItem,
28 },
29 });
30
31 // Type definitions
32 export interface TPyramidGroupElement extends TElement {
33 type: typeof PYRAMID_GROUP;
34 totalChildren?: number; // Store the count on the pyramid element
35 isFunnel?: boolean;
36 alignment?: "left" | "center" | "right";
37 variant?: "default" | "inside";
38 }
39
40 export interface TPyramidItemElement extends TElement {
41 type: typeof PYRAMID_ITEM;
42 alignment?: "left" | "center" | "right";
43 variant?: "default" | "inside";
44 icon?: string;
45 }
46
46 lines Plain Text