Canvas unification — Phase 4a: frame origin data model - #7
Conversation
Foundation for mind maps & flowcharts as frames on the unified canvas: each
auto-layout sub-model gains a frame `origin` {x,y} — its top-left on the shared
canvas. Data model only (no rendering yet); legacy single-type docs are
unaffected because {0,0} = no offset, exactly how they render today.
- mindmapModel/flowchartModel: createEmptyMindMap / createFlowchart include
origin {x:0,y:0}.
- schema: createUnifiedDocument places the frames at distinct default origins
(mind map {600,200}, flowchart {600,700}) so their content doesn't stack on the
block substrate or each other. Migration backfills origin {0,0} on older
unified docs.
Verified: build + 101 unit tests (adds frame-origin + migration cases). Next:
render the mind map / flowchart layers as positioned frames on the unified canvas.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Confidence Score: 4/5Safe to merge for current rendering; the
Reviews (1): Last reviewed commit: "Frappe Draw: canvas unification phase 4a..." | Re-trigger Greptile |
| export function createUnifiedDocument(presetName = DEFAULT_PRESET_NAME) { | ||
| return createDiagramDocument(presetName, UNIFIED_DIAGRAM_TYPE) | ||
| const document = createDiagramDocument(presetName, UNIFIED_DIAGRAM_TYPE) | ||
| document.mindmap.origin = { x: 600, y: 200 } | ||
| document.flowchart.origin = { x: 600, y: 700 } | ||
| return document | ||
| } |
There was a problem hiding this comment.
createEmptyMindMap() and createFlowchart() already set origin: {x:0, y:0}, so createUnifiedDocument immediately overwrites those values. A clarifying comment (or passing origins as constructor params) would make the intent explicit rather than looking like a first-time set.
| export function createUnifiedDocument(presetName = DEFAULT_PRESET_NAME) { | |
| return createDiagramDocument(presetName, UNIFIED_DIAGRAM_TYPE) | |
| const document = createDiagramDocument(presetName, UNIFIED_DIAGRAM_TYPE) | |
| document.mindmap.origin = { x: 600, y: 200 } | |
| document.flowchart.origin = { x: 600, y: 700 } | |
| return document | |
| } | |
| export function createUnifiedDocument(presetName = DEFAULT_PRESET_NAME) { | |
| const document = createDiagramDocument(presetName, UNIFIED_DIAGRAM_TYPE) | |
| // Override the {0,0} defaults from the sub-model factories with distinct | |
| // non-overlapping origins so frames don't stack on the block substrate. | |
| document.mindmap.origin = { x: 600, y: 200 } | |
| document.flowchart.origin = { x: 600, y: 700 } | |
| return document | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
What & why
First step of Phase 4 (mind maps & flowcharts as frames on the unified canvas). Data model only — each auto-layout sub-model gains a frame
origin{x,y} (its top-left on the shared canvas). No rendering change yet; legacy single-type docs are unaffected since{0,0}= no offset (exactly how they render today).Changes
mindmapModel/flowchartModel:createEmptyMindMap/createFlowchartincludeorigin: {x:0,y:0}.schema.js:createUnifiedDocumentplaces frames at distinct default origins (mind map{600,200}, flowchart{600,700}) so populated frames don't stack on the block substrate or each other. Migration backfillsorigin {0,0}on older unified docs.Testing
Build ✅ · 101 unit tests ✅ (adds frame-origin defaults + migration backfill cases). No model-shape regressions.
Next
Render the mind map / flowchart layers as positioned frames on the unified canvas (translate by origin), then wire in-frame interaction.
🤖 Generated with Claude Code