返回 presentation-ai
cycle-plugin.tsx
根目录 / src / components / notebook / presentation / editor / plugins / cycle-plugin.tsx
1 import { type TElement } from "platejs";
2 import { createTPlatePlugin } from "platejs/react";
3
4 import { CycleElement } from "../custom-elements/cycle-element";
5 import { CycleItem } from "../custom-elements/cycle-item";
6 import { CYCLE_GROUP, CYCLE_ITEM } from "../lib";
7
8 // Create plugin for cycle
9 export const CyclePlugin = createTPlatePlugin({
10 key: CYCLE_GROUP,
11 node: {
12 isElement: true,
13 component: CycleElement,
14 },
15 });
16
17 // Create plugin for cycle item
18 export const CycleItemPlugin = createTPlatePlugin({
19 key: CYCLE_ITEM,
20 node: {
21 isElement: true,
22 isStrictSiblings: true,
23 component: CycleItem,
24 },
25 });
26
27 export type TCycleGroupElement = TElement & {
28 type: typeof CYCLE_GROUP;
29 totalChildren?: number;
30 hasOddItems?: boolean;
31 alignment?: "left" | "center" | "right";
32 variant?: "cycle" | "flower" | "ring" | "circle";
33 };
34 export type TCycleItemElement = TElement & {
35 type: typeof CYCLE_ITEM;
36 alignment?: "left" | "center" | "right";
37 icon?: string; // react-icons name, e.g. "FaHome" — drives the wheel segment icon
38 };
39
39 lines Plain Text