matias14acevedo-svg

greensystems-editor

Build editor-style interfaces for diagrams and organizational charts with the GreenSystems design system: a canvas with selection, drag, resize and connect, a shape, icon, chart and table library, text with per-word colour and appear animations, a properties inspector, slides, undo history, validation, English and Spanish, and export to JSON, SVG, PNG, interactive HTML and 1:1, 16:9, 9:16, 3:4 and 4:5 formats. Use when the user asks for a diagram editor, an org chart builder, a canvas tool, or wants to extend the reference editor.

matias14acevedo-svg 0 Updated 3h ago

Resources

2
GitHub

Install

npx skillscat add matias14acevedo-svg/greensystems/greensystems-editor

Install via the SkillsCat registry.

SKILL.md

GreenSystems — editor interfaces

Use this skill to build or extend a tool where a person draws a diagram or org chart by hand: places shapes, connects them, edits their text, and exports the result. The repository ships a working reference in editor/; start from it instead of starting from zero.

This skill defines how the tool is structured and how it behaves. How it looks is already decided by the greensystems skill: same tokens, same icons, same components. An editor is a new screen in the same system, never a new visual language.

The one idea

The specification is the document. The editor keeps one JSON specification, the same format tools/dt-generate.js reads. Every screen element is derived from it:

            ┌────────────── renderDiagram(spec) ─────────────▶ canvas
spec ───────┼────────────── validateSpec(spec)  ─────────────▶ status bar
            └────────────── inspector fields    ◀───────────── selection
  ▲
  └── model operation (addNode, moveNodes, connect, …) ◀─────── pointer and keyboard

Consequences you must keep:

  • The canvas is drawn by the library renderer. The editor never draws a node itself, so what you edit is exactly what you export.
  • Every change is a pure function spec → spec from src/editor/model.js. Undo is a list of specifications; saving is JSON.stringify.
  • Selection, zoom, the open tab and a drag in progress are view state. They live outside the specification and are never saved in it.
  • Validation runs on every change and is shown, not enforced: a person may pass through an invalid state while typing.

Source of truth

Asset Path
Reference editor editor/index.html, editor/editor.css, editor/editor.js
Interface text (English, Spanish) editor/i18n.js
Export formats and ZIP src/generator/formats.js, src/generator/zip.js
Documents with sheets src/generator/pages.js (pageSpec, mergePages)
Custom palettes src/svg/theme.js (extractPalette, harmonize, cleanTheme)
Editing operations and history src/editor/model.js
Tree layout src/generator/layout.js
Canvas renderer src/generator/render.js (renderDiagram(spec, { interactive: true }))
Validation src/generator/validate.js
Interactive export src/generator/interactive.js
Tokens assets/css/tokens.css
Icons src/svg/icons.js (iconInline)
Tests tests/interactive.test.js
Architecture references/architecture.md
Interaction rules references/interaction.md
Interface kit references/interface-kit.md
Template templates/editor-screen.md

Run it with npm run gallery (or npm run editor) and open http://localhost:4173/editor/. It uses ES modules, so it needs the local server; it has no build step and no dependencies.

What the reference editor does

Area Behaviour
Library Every node type and preset as a thumbnail drawn by the real renderer, with a search box: text styles (heading, paragraph, eyebrow, animated, typewriter), geometry, basic and flow shapes, cards, charts, tables (key-value, data, matrix, RACI, roster), connectors, system shapes, notes and windows. Click adds the item at the centre of the view, selected and ready to drag.
Connectors Fourteen connector styles. With a connection selected, a click restyles it; with two or more nodes selected, it chains them in selection order; otherwise it becomes the style for new connections.
Icons The whole registry with search and a category filter. With one node selected, a click sets its icon; otherwise it adds an icon node.
Canvas Click selects, Shift-click adds to the selection, drag moves on an 8 px grid, the corner handle resizes, the side handle draws a connection to another node, dragging empty space pans, the wheel zooms at the pointer.
Phone and tablet At 820 px or less (or a phone on its side) a dock switches between Library, Canvas and Properties; panels open as a sheet under the canvas, and the arrow at the start of the dock folds the open panel away and brings it back; the toolbar scrolls sideways, two fingers pinch to zoom and pan, added items open their properties, handles grow for touch and menus open above the dock. Keep the desktop layout unchanged when editing it.
Inspector Fields for the selected node, connection, several nodes, or the diagram. Text, type, icon, accent, hover text, facts, link, position and size, appear on entry, delay and duration (duration); fields per type (text style, chart values, table grid, people, “Build in when it appears” (grow) for charts and tables, text size in % as textScale for charts, tables, rosters, key-value tables, windows and terminals); arrowhead, heads at, motion, delay, duration, thickness (thickness, px), neon glow (neon), label text size, sides and line style for connections; page format and the sheet's video and GIF length (videoDuration) for the diagram.
Words For a text node: pick words or sentences as chips, then set their colour (the eight palette colours) and weight; Select all and Clear style. Saved as marks. Below, how the text appears: by word, sentence, line or letter, with effect (fade, rise, ink, type, scramble, mask, marquee, weight, split), step, delay and duration.
Play Plays every animation of the document on the canvas once (P), then returns to the static view used for editing.
Slides Add, rename, reorder and delete slides; set a slide's focus from the current selection; the canvas outlines the focus of the open slide.
Text style For a selected text, the library text styles as buttons; applyTextStyle in src/editor/model.js changes the look and keeps label, position, width and existing marks.
Typeface from a file “+ Add typeface from file…” in the Typeface menu stores the font in this browser (IndexedDB) and sets the text's font to file:Family name; exports embed it; elsewhere the text falls back to the body face. Never commit such a font: it lives only in the browser.
Terminal lines “Lines” text: $ command, # banner, + accent, * strong, ~ muted (saved as { text, tone }). “Colour of each line” sets the tone per output line with buttons.
Illustrations The library groups Computers, Components, Network and space, Servers, data and code, Buildings and energy, Security and errors, People, Photos, video and music, Tools and vehicles, Office apps and App icons hold 150 line drawings. Search finds them by brand or product too (Intel, AMD, NVIDIA, Starlink, MacBook, Cisco, Ubiquiti, Word, Excel, Teams, Python, Tesla, Cybertruck, iPhone, Android…), but the drawings carry no logos: the office apps are windows that show the kind of work, with the app's name written in the title bar, and the office suite has its apps floating around a hub that takes the suite's name (365, for example). App icons are square tiles with an original drawing of each kind of app (Word finds the documents icon, Excel the spreadsheet, Teams the chat); put the app's name in the label. The inspector sets the drawing, Text on the drawing (a model name such as RTX 4090, a percentage on the battery, a name on a person or an app's name in its title bar; the code file takes the language, PY, JS or SQL, and the audio and video files MP3 or MP4; 64 drawings have room for it), the label under it, accent, Trace the lines when it appears, Moving parts (fans turn, lights blink, signals pulse, people blink, the bug wiggles) and, on switches, the enterprise router, the satellite router, the PoE injector and the wall jack, Ports that blink: a grid laid out like the device (odd ports on top on two-row switches) where you click the ports to show where to connect, with All and None. Picked ports turn lime and blink, the others dim; the first port picked also turns Moving parts on. The canvas stays still while you edit; Play shows the motion, and “Animations in the presentation” (or A in the presentation) turns every animation off.
Images The Insert image button in the toolbar (I) and the Image card in the library upload a PNG, JPEG, GIF, WebP or SVG file; dropping files on the canvas or pasting one does the same. Pictures are embedded as data URIs, scaled to 1600 px on the long side. The image inspector sets fit (whole image or fill and crop), frame, Replace image and Palette from this image.
Palette With nothing selected, “Diagram palette” edits the colours of the open document only: eight colour fields, Dark or Light, ready-made palettes (themePresets, for example Blue and gold), From an image… (extracts the main colours and builds a harmonic palette), the colours found (click: main accent, Shift+click: second accent) and Original palette. Saved as theme; the editor's own interface and selection marks keep their colours.
Sheet background With nothing selected, “Sheet background” sets the open sheet's background: solid colour, transparent (no background: PNG and SVG come out see-through; the canvas shows the sheet as a dashed outline), dots, grid or coordinates (the grid with its axes numbered in sheet units), and “Spacing, px” for the patterns. Each sheet keeps its own.
Presentation animations “Animations in the presentation” off saves presentation.animate: false: Preview and the interactive page change slides without motion.
Motion sounds With nothing selected, “Motion sounds” saves sound on the document, “Sound style” its character (Technical, Serious, Corporate, Cheerful, Minimal, Calm, Cinematic, Elegant, Retro 8-bit, Futuristic; those marked “no typing” leave letters silent; choosing one turns sound on and plays a sample), “Typing sound” the typing ticks (saved as typing only when it differs from the style) and “Sound volume, %” its volume (off by default); “Listen to the sound style” plays every sound once in that style. “Background music” picks a track (music: Slow, 8-bit, Cheerful, Sad, Tutorial, News, Piano, Electronic, Techno; choosing one plays 12 s of it), “Music volume, %” its volume (default 40), and “Listen to the music” plays or stops a sample. The music plays under Play and goes into video, Reels and Story exports. Play then sounds each element as it appears (pop, typing ticks, whooshes, line sweeps, neon hum, illustration tracing, beeps and spin-ups), video exports carry them as the audio track, and Preview and the interactive page offer a sound button. With sound on, a node or connection has “Sound when it appears”; unticked saves "sound": false. All synthesized with Web Audio: no audio files. SVG, PNG, GIF and PDF are silent.
Sheets Tabs under the canvas switch between independent sheets; + adds one the size of the open sheet. The diagram inspector names, duplicates, moves and deletes the open sheet. SVG and PNG export the open sheet; the ZIP holds every sheet in every format; the interactive page presents all sheets. Next to the tabs, the format button shows the sheet's format (16:9, 9:16, 1:1, 3:4, 4:5, or its size) and opens a menu that turns the sheet into another format to work in it: the sheet takes the format's size and, with “Fit the content to the new format” on, the content is centred and, if it does not fit, shrunk as one block (boxes, text sizes, routes and groups). The Page format field does the same; the model function is resizePage(spec, width, height, { fit }).
Org charts “Add report” places a card under the selected one with a reporting line. “Tidy” arranges the hierarchy as a centred tree.
History Undo and redo of every change. The document is saved in the browser between visits. “Start with an empty canvas on every visit” (Open menu, stored as greensystems-editor:fresh) deletes the saved design on load and on pagehide, so nothing stays in the browser.
Status bar Valid or the number of problems (click to list them), selection, pointer position.
Open A JSON file from disk, one of the bundled examples, or an announcement template (maintenance, new system, phishing alert, outage) in the editor's language: examples/templates/{en,es}/<id>.json, built by tools/build-templates.js, each with a 9:16 story and a 1:1 post and the sound style that fits it (corporate, cheerful, serious). Facts stay as [placeholders] in brackets.
Export JSON specification, SVG, PNG, PDF, video, Instagram Reels and Story, GIF and the interactive HTML page. SVG, PNG, PDF, video and GIF in the original size or fitted to 1:1, 16:9, 9:16, 3:4 or 4:5, and one ZIP with every format as SVG and PNG. Video: each frame is the exported SVG with its animations paused at the moment the recording has reached (negative delays), drawn to a canvas; where WebCodecs can encode H.264 each frame goes to a VideoEncoder at its exact moment (no dropped frames, about 16 Mbit/s, a key frame every 2 s), the motion sounds are rendered with an OfflineAudioContext and encoded as AAC, and src/generator/mp4.js writes the MP4 (index first); otherwise MediaRecorder films it in real time (MP4 if supported, else WebM) after a 0.8 s still opening; no dependencies. Reels and Story: 1080 × 1920 MP4 at 30 fps with the sheet inside a safe margin (socialFormats in src/generator/formats.js: Reels 220/140/420/60 px top/right/bottom/left, Story 250/60/250/60), Story at most 60 s. GIF: the same frames drawn at exact moments, read back and written by src/generator/gif.js (palette from six sample frames, LZW, only the changed rectangle per frame, endless loop), 720 px long side at 7 hundredths of a second a frame. PDF: every sheet still, drawn at twice its size (at most 12 million pixels), RGB deflated with CompressionStream (JPEG where it is missing) and written by src/generator/pdf.js, one page per sheet sized at 0.75 pt a pixel. Preview opens the interactive page in a new tab.
Language English or Spanish, switched in the toolbar and remembered. Default node labels follow the language; text the person typed never changes.

Keyboard: Ctrl Z / Ctrl Shift Z undo and redo, Ctrl D duplicate, Ctrl A select all, Ctrl S save the JSON, Delete remove, arrows move by 8 px (Shift by 40), + − 0 zoom and fit, P play, I insert an image, Esc clear.

Workflow

  1. State what the tool is for. An org chart builder, a flow editor and an architecture sketcher need different libraries and different defaults, and the same core. Write the list of node types and the two or three actions specific to the domain.
  2. Start from the reference. Copy editor/ or extend it in place. Keep the three files: structure, styles, behaviour.
  3. Add operations to the model first. A new action is a new pure function in src/editor/model.js with a test. Only then wire a button or a gesture to it.
  4. Wire the interface. A toolbar button is data-act="name" plus an entry in the actions map. An inspector field is one entry in inspectorModel(). A library item is a node type in a group of PALETTE.
  5. Keep the look. Use the classes in references/interface-kit.md and the --dt-* tokens. Reuse registry icons; do not draw new ones for a toolbar.
  6. Verify in a browser. Add, move, resize, connect, undo, reload the page, export each format and open the exports.
  7. Validate. npm run check.

Rules

  • No frameworks and no dependencies. Plain ES modules, as the rest of the repository. If a feature seems to need a library, it is probably out of scope.
  • Never fork the renderer. If a node cannot be drawn the way the editor needs, fix or extend src/svg/ so every output gains it.
  • Never store view state in the specification. No selected, collapsed or zoom keys on nodes.
  • Operations do not mutate. They take a specification and return a new one. Tests assert the input is unchanged.
  • Empty means absent. Clearing a field deletes the key, so exported JSON stays minimal and valid.
  • Renaming an id is a refactor. It must update every connection and every slide that mentions it; updateNode does.
  • Coordinates snap to 8 px unless the person turns snapping off. Sizes never go below 24 px, the validator's minimum.
  • Lime means selection and the primary action. One accent button per bar. Do not introduce a second accent for hover, drag or drop states; use line weight and dashes.
  • Text from the document is never markup. Build DOM nodes or set textContent; the only markup injected is what the library renders from a validated specification.
  • Opening a file is untrusted input. Parse it, validate it, and show the problems. Do not run anything from it.
  • Facts stay the user's. Starter content in a new node is a placeholder (“New role”), never invented data.
  • Every interface string is translated. A new label, title or toast goes into both dictionaries in editor/i18n.js with the same key; tests check that English and Spanish have the same keys.
  • The history holds documents; the canvas edits one sheet. Sheet operations (addPage, duplicatePage, movePage, renamePage, removePage) change the document; every other operation works on pageAt(doc, index) and is written back with setPage. One sheet left makes the file a plain specification again.
  • Edit static, play on demand. The canvas renders the specification without motion so nodes can be picked; animations play only from Play and in the exports.

Extending: three common requests

A domain action (for example “add a direct report”):

// src/editor/model.js — pure, tested
export function addReport(spec, parentId, { gapY = 96, gapX = 32 } = {}) { /* returns { spec, id } */ }

// editor/editor.js — one entry in the actions map
report() {
  const result = M.addReport(history.current(), [...ui.selection][0]);
  if (!result.id) return;
  selectOnly([result.id]);
  commit(result.spec);
},

An inspector field (for example a node's status): add one row to the node fields of inspectorModel(), ["Status", "status", node.status || "", { type: "select", options }]. The shared change handler turns the value into updateNode(spec, id, { status }).

A library group (for example cloud resources): add ["Cloud", ["cloud", "queue", "database"]] to PALETTE in editor/editor.js. Thumbnails come from the renderer, so there is nothing to draw.

Quality gate

  • The exported SVG matches the canvas exactly.
  • Every change can be undone, and redo restores it.
  • Reloading the page restores the document; “Open” replaces it and resets the history.
  • An invalid document shows its problems and can still be edited and saved as JSON.
  • Keyboard only: every toolbar action, the inspector and node movement work without a pointer.
  • No colour, font, radius or icon that is not in the design tokens and the icon registry.
  • New model operations have tests and do not mutate their input.
  • The existing gallery and library pages are unchanged.
  • npm run check passes.

Credits

The framing camera, the layered Esc key and the export menu follow interaction patterns studied in Archify (Apache-2.0). No code from that project is included.

Agent compatibility

Agent Reads this skill from
Codex, Gemini CLI, Cursor, GitHub Copilot, Amp, goose, Windsurf, Kiro, Factory, Roo .agents/skills/greensystems-editor/SKILL.md (canonical)
Claude Code, Cline .claude/skills/greensystems-editor/SKILL.md
OpenCode .opencode/skills/greensystems-editor/SKILL.md
GitHub Copilot in VS Code .github/skills/greensystems-editor/SKILL.md
Claude.ai and the Claude apps, ChatGPT, the OpenAI API upload dist/skills/greensystems-editor.zip, built by npm run pack:skills

The copies are mirrors. Edit the canonical .agents copy and run npm run sync:skills; never edit the mirrors by hand. Outside the repository, an uploaded skill still teaches the rules; the components and the generator need the repository.

Categories