mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-06 06:13:51 +08:00
- 修复 SQL 元数据 hover provider 多实例重复注册导致内容重复显示 - 修复侧栏对象拖入编辑器后 Monaco 原生拖拽虚线残留 - 修复跨库拖拽对象丢失来源库导致后续无法跳转 - 兼容 macOS Cmd 点击时 Monaco 未提供 leftButton 的事件结构 - 补充 hover 去重、拖拽插入、对象跳转和 Cmd 点击回归测试
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
export const SIDEBAR_SQL_EDITOR_DRAG_MIME = 'application/x-gonavi-sql-object';
|
|
|
|
export interface SidebarSqlEditorDragPayload {
|
|
text: string;
|
|
nodeType?: string;
|
|
connectionId?: string;
|
|
dbName?: string;
|
|
}
|
|
|
|
export const encodeSidebarSqlEditorDragPayload = (payload: SidebarSqlEditorDragPayload): string =>
|
|
JSON.stringify({
|
|
text: String(payload.text || '').trim(),
|
|
nodeType: payload.nodeType ? String(payload.nodeType) : undefined,
|
|
connectionId: payload.connectionId ? String(payload.connectionId) : undefined,
|
|
dbName: payload.dbName ? String(payload.dbName) : undefined,
|
|
});
|
|
|
|
export const hasSidebarSqlEditorDragPayload = (dataTransfer: Pick<DataTransfer, 'types'> | null | undefined): boolean => {
|
|
const rawTypes = dataTransfer?.types;
|
|
if (!rawTypes) return false;
|
|
const types = Array.from(rawTypes as any).map((type) => String(type || '').toLowerCase());
|
|
return types.includes(SIDEBAR_SQL_EDITOR_DRAG_MIME);
|
|
};
|
|
|
|
export const decodeSidebarSqlEditorDragPayload = (value: string): SidebarSqlEditorDragPayload | null => {
|
|
try {
|
|
const parsed = JSON.parse(String(value || '')) as SidebarSqlEditorDragPayload;
|
|
const text = String(parsed?.text || '').trim();
|
|
if (!text) return null;
|
|
return {
|
|
text,
|
|
nodeType: parsed?.nodeType ? String(parsed.nodeType) : undefined,
|
|
connectionId: parsed?.connectionId ? String(parsed.connectionId) : undefined,
|
|
dbName: parsed?.dbName ? String(parsed.dbName) : undefined,
|
|
};
|
|
} catch {
|
|
return null;
|
|
}
|
|
};
|