Repository navigation
feat(dia.Paper): support useModelGeometry: { filter } in content area measurement - #3561
Open
Geliogabalus wants to merge 4 commits into
Open
Geliogabalus wants to merge 4 commits into
Geliogabalus wants to merge 4 commits into
Conversation
…ement `getContentArea()` with `useModelGeometry: true` returned the bbox of every cell in the graph, including the cells the paper hides through `cellVisibility`. The paper scroller, the navigator and "fit to content" helpers therefore sized themselves to content the paper does not show. - dia.Graph: `getBBox()` and `getCellsBBox()` accept a `filter(cell)` option - dia.Paper: `getContentArea()`, `getContentBBox()`, `getFitToContentArea()`, `fitToContent()` and `transformToFitContent()` accept a `filter(cell, paper)` option, used with `useModelGeometry: true` The paper's `cellVisibility` is deliberately not applied automatically: with virtual rendering it also culls cells outside the viewport, which would shrink the content area to the viewport. Refs clientIO/joint-plus#836 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the `filter(cell)` signature of `dia.Graph` and `Element.fitToChildren()` instead of binding the paper as `this` and passing it as an argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…BBox() Callers of `getCellsBBox()` already choose the cells, so filtering them is `cells.filter(fn)`. `paper.getContentArea()` now filters the cells itself, which keeps the new option on the paper only, where `ui.PaperScroller` and `ui.Navigator` can pass it through their content options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
kumilingus
requested changes
Oct 29, 2026
Contributor
There was a problem hiding this comment.
Could we nest the filter under useModelGeometry instead of making it a separate option?
paper.getContentArea({ useModelGeometry: { filter: (cell) => !cell.get('hidden') } });
interface ContentAreaOptions {
useModelGeometry?: boolean | { filter?: (cell: Cell) => boolean };
}- filter only works with useModelGeometry. As a separate option, { filter } alone is silently ignored. Nesting it rules that combination out.
- It follows the existing boolean | { ...options } pattern (e.g. snapLinks: boolean | { radius }).
- Code that only forwards useModelGeometry picks up the filter with no changes, and the core check stays truthy.
The filter applies only to the model-based measurement, so it now lives in
`useModelGeometry: { filter }` instead of next to the flag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
paper.getContentArea({ useModelGeometry: true })returnsgraph.getBBox(), which includes every cell, also the ones the paper hides throughcellVisibility. Anything that sizes or fits the paper from the model geometry therefore makes room for content that is not shown:fitToContent();getFitToContentArea();transformToFitContent();This PR lets
useModelGeometrytake an options object with afilter. It is non-breaking:useModelGeometry: trueandfalsework as before.dia.PapergetContentArea()andgetContentBBox().FitToContentOptionsandTransformToFitContentOptionsnow extendContentAreaOptions, sogetFitToContentArea(),fitToContent()andtransformToFitContent()pass it through.useModelGeometrybecause it only applies there. On the view path, hidden cells are not mounted, so they are never measured anyway.thisbinding and nopaperargument, since the caller already holds the paper. It is the same(cell) => booleansignature as thefilterofElement.fitToChildren().filter(useModelGeometry: {}) measures every cell, the same astrue.Why only on the paper
Code that measures content through these paper methods passes an options object, so an option is the only way to tell it which cells count.
graph.getCellsBBox(cells)has no such need, because its caller already chooses the cells:graph.getCellsBBox(graph.getCells().filter(fn)).Why
cellVisibilityis not applied automaticallycellVisibilityis also used for viewport culling, where it hides cells outside the visible area. Applying it while measuring would shrink the content area to the viewport, and a paper resized to fit its content would shrink with it. The callback also takes anisMountedargument that has no meaning outside the update loop. Only the caller can tell hidden cells from culled ones, so the filter is explicit.Tests
getContentArea()/getContentBBox()/getFitToContentArea()/fitToContent()/transformToFitContent()withuseModelGeometry: { filter };useModelGeometry: {}measures every cell.test/ts/index.test.ts.dia.Paper.🤖 Generated with Claude Code