返回 presentation-ai
getNewDirection.ts
根目录 / src / components / notebook / presentation / editor / dnd / utils / getNewDirection.ts
1 /** Get new direction if updated */
2 import { type DropLineDirection } from "@platejs/dnd";
3
4 export const getNewDirection = (
5 previousDir: string,
6 dir?: string,
7 ): DropLineDirection | undefined => {
8 if (!dir && previousDir) {
9 return "";
10 }
11 if (dir === "top" && previousDir !== "top") {
12 return "top";
13 }
14 if (dir === "bottom" && previousDir !== "bottom") {
15 return "bottom";
16 }
17 if (dir === "left" && previousDir !== "left") {
18 return "left";
19 }
20 if (dir === "right" && previousDir !== "right") {
21 return "right";
22 }
23 };
24
24 lines TYPESCRIPT