mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-09 13:58:36 +03:00
26 lines
762 B
TypeScript
26 lines
762 B
TypeScript
export const SESSION_DRAG_TYPE = "application/x-nanobot-session-key";
|
|
|
|
let activeSessionKey: string | null = null;
|
|
|
|
export function hasDraggedSession(dataTransfer: DataTransfer): boolean {
|
|
return Array.from(dataTransfer.types).includes(SESSION_DRAG_TYPE);
|
|
}
|
|
|
|
export function readDraggedSession(dataTransfer: DataTransfer): string | null {
|
|
const sessionKey = dataTransfer.getData(SESSION_DRAG_TYPE).trim();
|
|
return sessionKey || activeSessionKey;
|
|
}
|
|
|
|
export function clearDraggedSession(): void {
|
|
activeSessionKey = null;
|
|
}
|
|
|
|
export function writeDraggedSession(
|
|
dataTransfer: DataTransfer,
|
|
sessionKey: string,
|
|
): void {
|
|
activeSessionKey = sessionKey;
|
|
dataTransfer.effectAllowed = "copyMove";
|
|
dataTransfer.setData(SESSION_DRAG_TYPE, sessionKey);
|
|
}
|