Skip to content

Layout engines, short relationship labels and easier canvas navigation - #1187

Closed
lroder wants to merge 2 commits into
drawdb-io:mainfrom
lroder:feat/layout-engines
Closed

lroder wants to merge 2 commits into
drawdb-io:mainfrom
lroder:feat/layout-engines

Conversation

@lroder

@lroder lroder commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Layout engines, short relationship labels and easier canvas navigation

I used drawDB to review a schema for a new time-and-billing feature, 18 tables and 36 foreign keys, and I made these changes along the way. Each one fixed something that slowed me down. If any of them helps, great. I'm also glad to drop or split anything you'd rather not take.

  1. A layout menu on the auto arrange button. The wand now offers five layouts: Dagre left to right (the existing behavior), Dagre top to bottom, ELK layered, ELK stress, and one that arranges each subject area separately. Each one is a single undo step, so I can try them all with Ctrl+Z in between. ELK (elkjs) loads only when someone picks one of its layouts.
  2. Imports arrive arranged and in view. The SQL import placed tables in two rows and centered the view on the origin, so most of my diagram sat off the bottom right of the window. Every import now runs auto arrange and fits the view.
  3. Spread out and Pull together. Two toolbar buttons move everything away from or toward the center of the screen by 20% per click. Tables keep their size, so the gaps between them grow until lines and labels are readable.
  4. Short relationship labels. A View menu toggle replaces long FK names on the canvas with initials, so fk_time_entry_change_requests_requested_by_auth_user_id_auth_users shows as tecr.rbau. The editor never saves these labels. When you point at a line, the editor shows its full name.
  5. A relationship legend. It maps each short label to its full name and columns. You can drag it, resize it and collapse it, or toggle it from a toolbar button. PNG, SVG and PDF exports include it.
  6. Scrollbars and a zoom slider. The canvas shows scrollbars when the diagram extends past the window. The toolbar has a slider that zooms smoothly between the presets.
  7. A fix for Postgres text defaults. The problem checker compared a text column's default against a size that text doesn't have, so every text default was flagged.

The new interface strings are in 33 of drawDB's languages.¹ The new settings are off by default, so the editor looks the same until someone turns them on.

¹ I added the twelve new strings to 32 languages besides English: Arabic, Bulgarian, Chinese (Simplified and Traditional), Czech, Danish, Dutch, Filipino, Finnish, French, German, Greek, Hebrew, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Malay, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Spanish, Swedish, Thai, Turkish, Ukrainian and Vietnamese. Claude drafted them using each file's existing words for relationship and subject area. A native speaker's review would be welcome. The other 18 languages fall back to English for these strings for now.

🤖 Generated with Claude Code

lroder and others added 2 commits October 31, 2026 08:52
The auto arrange button now opens a menu of five layouts. The editor
applies each one as a single undo step. Dagre lays tables out left to right
or top to bottom. ELK's layered engine gives every related field a port on
its table's edge, so it orders tables by the rows their lines leave from.
ELK's stress engine pulls related tables into clusters. Our removeOverlaps
function then pushes any overlapping tables apart. The fifth option lays out
each subject area on its own and packs the areas in the order of the Areas
tab. The browser loads ELK only when someone picks one of its layouts.

SQL, AI and database imports now go through auto arrange, and the editor
fits the view to the new tables. The SQL import used to place tables in two
rows and center the screen on the origin, so most of an imported diagram sat
off the bottom right of the window.

Spread out and Pull together move every unlocked table, area and note away
from the center of the screen, or toward it, by a factor of 1.2 per click.
The editor keeps each table's size, so the gaps between tables change while
the tables stay as they are.

The View menu can switch relationship lines to short labels. The editor
abbreviates the child table and the foreign key column to their initials,
so fk_time_entry_change_requests_requested_by_auth_user_id_auth_users reads
tecr.rbau. A table keeps one abbreviation in every label. The editor adds
letters only where two names would otherwise clash. It computes the labels
each time it draws them and never saves them. When the person points at a
line, the editor shows its full name above the tables. A legend maps each
short label to its relationship. The person can drag, resize and collapse
the legend, or show and hide it from a toolbar button. We render the legend
inside the exported area, so image and PDF exports include it.

The canvas now has scrollbars measured against the diagram's bounds. The
toolbar also has a zoom slider on a log scale. A Postgres text column no
longer fails the default value check, because text has no size to check the
default against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
I added the twelve strings from the previous commit to 32 of drawDB's
language files. Claude Opus 5.5 drafted them on 2026-10-31 and matched each
file's existing words for relationship, subject area and auto arrange. The
other 18 files (as, bn, gu, hy, ka, ml, mn, mr, ne, od, pa, pa-pk, sd, sw,
te, tm, ug, ur) still fall back to English for these strings.

We committed without the pre-commit hook. The locale files already differ
from Prettier's formatting, so the hook would rewrap about 1,300 lines that
have nothing to do with these strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 31, 2026

Copy link
Copy Markdown

@lroder is attempting to deploy a commit to the dottle's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
drawdb Ready Ready Preview Oct 31, 2026 2:40pm UTC

@1ilit 1ilit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

I'd love to have these in the app:

  1. A layout menu on the auto arrange button.
  2. Imports arrive arranged and in view.
  3. A fix for Postgres text defaults.

could you please either update this pr or open a new one?

@lroder

lroder commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for going through this. I'm closing this PR and creating a new one, #1188, with the three changes you listed: the layout menu, imports that arrive arranged and in view, and the Postgres text fix.

I also kept the canvas scrollbars, the zoom slider and the Spread out and Pull together buttons, because I used all three after every auto arrange on a large import. They are the last three commits in the new PR, so if you'd rather not take any of them, I can drop it, or you can merge the commits before it. I left out the short relationship labels and the legend.

@lroder lroder closed this Nov 1, 2026

This branch was successfully deployed

1 active deployment
Preview — ce8a39bd Deployed Oct 31, 2026 by vercel[bot]
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.

2 participants