返回 presentation-ai
alignment-utils.ts
根目录 / src / components / notebook / presentation / editor / utils / alignment-utils.ts
1 import type React from "react";
2
3 import { type PlateSlide } from "../../utils/parser";
4
5 /**
6 * Get alignment style for the editor when in present mode.
7 * Returns an inline style object for alignSelf property.
8 */
9 export function getAlignmentStyle(
10 isPresenting: boolean,
11 alignment: PlateSlide["alignment"],
12 layoutType: PlateSlide["layoutType"],
13 ): React.CSSProperties {
14 if (layoutType === "vertical") return {};
15 if (isPresenting) {
16 if (alignment === "start") return { alignSelf: "flex-start" };
17 if (alignment === "end") return { alignSelf: "flex-end" };
18 return { alignSelf: "center" };
19 }
20 return {};
21 }
22
23 /**
24 * Get alignment class for the editor based on slide alignment.
25 * Returns the justify-content class for vertical alignment.
26 */
27 export function getAlignmentClass(
28 alignment: PlateSlide["alignment"] | undefined,
29 ): string {
30 if (!alignment) return "justify-center";
31 switch (alignment) {
32 case "start":
33 return "justify-start";
34 case "center":
35 return "justify-center";
36 case "end":
37 return "justify-end";
38 default:
39 return "justify-center";
40 }
41 }
42
42 lines TYPESCRIPT