mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-13 04:59:51 +08:00
- stores/versions-store.ts, hooks/use-session-manager.ts, lib/session-storage.ts: remove the diagramHistory conversion layer, the localStorage chat migration and the empty templates store - stores/canvas-store.ts, lib/drawio/editor-bridge.ts: remove the pages list nothing read - components/chat/chat-engine.tsx: use the context's chartXMLRef and latestSvgRef instead of local copies, subscribe to one settings field, stop prefetching quota limits (lib/use-quota-manager.tsx takes the values from the 429 body), readDiagramFile delegates to the MCP loader (which now strips XML prologs and accepts <svg:svg>) - contexts/diagram-context.tsx: one requestTaggedExport path for thumbnails, validation, fetch and save; fetchDiagramXml replaces handleExport plus the exported resolver map - hooks/use-validate-diagram.ts and app/api/validate-diagram: plain fetch returning JSON instead of a streamed object nobody consumed - hooks/use-diagram-tool-handlers.ts: drop the DEBUG blocks; canvas vars inheritance lives in placeOnPage (lib/diagram-pages.ts) - lobby-hero, icon-button, drawio-frame: remove unreachable branches and unused props
39 lines
973 B
TypeScript
39 lines
973 B
TypeScript
import { create } from "zustand"
|
|
|
|
export interface SelectedCell {
|
|
id: string
|
|
label: string
|
|
isEdge: boolean
|
|
}
|
|
|
|
/** Rectangle relative to the draw.io iframe's top-left corner */
|
|
interface CanvasRect {
|
|
x: number
|
|
y: number
|
|
width: number
|
|
height: number
|
|
}
|
|
|
|
interface CanvasState {
|
|
/** The page can call the draw.io editor directly (same-origin iframe) */
|
|
hasEditor: boolean
|
|
currentPageId: string | null
|
|
selection: SelectedCell[]
|
|
selectionRect: CanvasRect | null
|
|
/** Freehand drawing is on */
|
|
isFreehand: boolean
|
|
/** One of draw.io's menus or dialogs is open over the canvas */
|
|
isDrawioPopupOpen: boolean
|
|
set: (partial: Partial<Omit<CanvasState, "set">>) => void
|
|
}
|
|
|
|
export const useCanvasStore = create<CanvasState>((set) => ({
|
|
hasEditor: false,
|
|
currentPageId: null,
|
|
selection: [],
|
|
selectionRect: null,
|
|
isFreehand: false,
|
|
isDrawioPopupOpen: false,
|
|
set: (partial) => set(partial),
|
|
}))
|