返回 presentation-ai
stats-plugin.tsx
根目录 / src / components / notebook / presentation / editor / plugins / stats-plugin.tsx
1 import { type TElement } from "platejs";
2 import { createTPlatePlugin } from "platejs/react";
3
4 import StatsGroup from "../custom-elements/stats";
5 import { StatsItem } from "../custom-elements/stats-item";
6 import { STATS_GROUP, STATS_ITEM } from "../lib";
7
8 export const StatsGroupPlugin = createTPlatePlugin({
9 key: STATS_GROUP,
10 node: {
11 isElement: true,
12 type: STATS_GROUP,
13 component: StatsGroup,
14 },
15 });
16
17 export const StatsItemPlugin = createTPlatePlugin({
18 key: STATS_ITEM,
19 node: {
20 isElement: true,
21 isStrictSiblings: true,
22 type: STATS_ITEM,
23 component: StatsItem,
24 },
25 });
26
27 export type TStatsGroupElement = TElement & {
28 type: typeof STATS_GROUP;
29 columnSize?: "sm" | "md" | "lg" | "xl";
30 statsType?:
31 | "plain"
32 | "circle"
33 | "circle-bold"
34 | "star"
35 | "bar"
36 | "dot-grid"
37 | "dot-line";
38 color?: string;
39 alignment?: "left" | "center" | "right";
40 };
41
42 export type TStatsItemElement = TElement & {
43 type: typeof STATS_ITEM;
44 stat?: string;
45 alignment?: "left" | "center" | "right";
46 };
47
47 lines Plain Text