返回 presentation-ai
arrow-plugin.tsx
根目录 / src / components / notebook / presentation / editor / plugins / arrow-plugin.tsx
1 import { type TElement } from "platejs";
2 import { createPlatePlugin } from "platejs/react";
3
4 import { ArrowItem } from "../custom-elements/arrow-item";
5 import ArrowList from "../custom-elements/arrow-list";
6 import { ARROW_LIST, ARROW_LIST_ITEM } from "../lib";
7
8 // Create plugin for visualization item
9 export const ArrowListPlugin = createPlatePlugin({
10 key: ARROW_LIST,
11 node: {
12 isElement: true,
13 component: ArrowList,
14 },
15 });
16
17 // Create plugin for visualization list
18 export const ArrowListItemPlugin = createPlatePlugin({
19 key: ARROW_LIST_ITEM,
20 node: {
21 isElement: true,
22 isStrictSiblings: true,
23 component: ArrowItem,
24 },
25 options: {
26 visualizationType: "arrow",
27 },
28 });
29
30 export type TArrowListElement = TElement & {
31 type: typeof ARROW_LIST;
32 orientation: "vertical" | "horizontal";
33 columns: number;
34 svgType: "arrow" | "pill" | "parallelogram";
35 showIcon: boolean;
36 alignment?: "left" | "center" | "right";
37 };
38
39 export type TArrowListItemElement = TElement & {
40 type: typeof ARROW_LIST_ITEM;
41 icon?: string;
42 alignment?: "left" | "center" | "right";
43 };
44
44 lines Plain Text