Skip to content

Regular .boxes files can be templates#3

Merged
jpmccu merged 2 commits into
mainfrom
feature/template-files
Mar 25, 2026
Merged

Regular .boxes files can be templates#3
jpmccu merged 2 commits into
mainfrom
feature/template-files

Conversation

@jpmccu
Copy link
Copy Markdown
Owner

@jpmccu jpmccu commented Mar 25, 2026

No description provided.

Jamie McCusker and others added 2 commits March 24, 2026 19:46
…in file format

- Move template definitions from templates.js inline JS to JSON files in
  packages/core/src/templates/ (blank.json, arrows.json, owl-ontology.json)
- Template format now uses 'title'/'description' (replacing 'name') and
  'userStylesheet' (consistent with saved file format)
- Add 'palette: { nodeTypes, edgeTypes }' to the graph file format so that
  the palette is saved and restored automatically on file load
- BoxesEditor constructor accepts a 'template' option (pre-loaded JSON object);
  individual options (style, nodeTypes, edgeTypes, context) still work and
  take precedence over template fields
- BoxesEditor.exportGraph() now includes title, description, and palette
- BoxesEditor.importGraph() restores palette (nodeTypes/edgeTypes), title,
  and description from the loaded file
- app.js: startWithTemplate() now accepts a full template object (or ID string
  for backwards compatibility); loadFromFile() restores palette directly from
  the loaded file rather than looking up templateId; saves no longer store
  templateId (backwards compat: old files with templateId still load correctly)
- Add loadTemplateFromUrl(url) utility (fetch-based) exported from core;
  app.js loadTemplates() accepts optional extra template URL list
- core vite.config.js: copy template JSON files to dist/templates/ so they
  are fetch-accessible at /core/templates/*.json
- Update tests: templates.test.js uses title/description/palette fields;
  boxes-editor.test.js adds palette export, palette restore, and template
  constructor option tests (150 tests pass, up from 146)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Palette items now show edit (✎) and delete (×) buttons on hover.
'+ Add node type' and '+ Add edge type' buttons appear below each section.
Clicking edit or add opens an inline form with:
  - Node types: label, id, background color, border color, shape
  - Edge types: label, id, color, line style
  - Both: optional JSON data template for default node/edge properties

Public API additions on BoxesEditor:
  addNodeType(type), updateNodeType(id, updates), removeNodeType(id)
  addEdgeType(type), updateEdgeType(id, updates), removeEdgeType(id)
All mutations re-render the palette and emit a 'paletteChanged' event.

Together with the palette-in-file-format change, this lets users build and
save custom palettes directly from the editor UI, making it easy to create
new templates by designing a palette and saving the file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jpmccu jpmccu merged commit efda8d0 into main Mar 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant