Skip to content

Conversation

@samuelgja
Copy link
Contributor

@samuelgja samuelgja commented Jan 30, 2026

Description

⚠️ EXPERIMENTAL FEATURE - This API is subject to change and not recommended for production use yet.

Introduces ControlledPaper - a new experimental approach for React integration that allows React to manage DOM elements directly via React-DOM, instead of JointJS handling the DOM structure and creating of React DOM portals.

Key Changes:

  • ControlledPaper: New class extending dia.Paper that delegates DOM management to React
  • ReactPaper Component: New React component using ControlledPaper for true React-DOM rendering
  • ReactPaperLink Model: Link model with empty markup - React renders the link content
  • ReactPaperStore: Store for managing ControlledPaper instances within GraphStore
  • External Elements API: Methods to register/unregister external DOM elements controlled by React

New Components:

  • ReactPaper - Main component for React-DOM based rendering
  • ReactPaperElement - Wrapper for element rendering
  • ReactPaperLinkComponent - Wrapper for link rendering with useLinkLayout hook
  • useReactPaper - Hook to access the underlying dia.Paper instance

Motivation and Context

This experimental approach explores benefits over the current SVG-based rendering:

  1. True React Integration: React controls the DOM, enabling full React ecosystem (hooks, context, portals)
  2. Performance: React's reconciliation handles updates efficiently
  3. Developer Experience: Standard React patterns for element/link rendering

Testing

  • Added comprehensive tests for ReactPaper and ControlledPaper
  • All 443 tests passing
  • Added stress test story for performance validation

…intJS elements and links

- Add BatchCache class for managing batched updates for links, ports, and clear views.
- Introduce ClearViewCacheEntry and related functions for managing clear view updates.
- Create PortUpdateCacheEntry and functions for merging port updates and groups.
- Implement state flushing functions to handle element and link updates in a React-friendly manner.
- Develop example story demonstrating cell actions with dynamic node and link management.
- Define GraphSchedulerData type for unified scheduling of updates across elements, links, and ports.
…using React-DOM

- Add ControlledPaper class to extend dia.Paper, allowing external DOM elements management.
- Implement methods for registering and unregistering external elements.
- Enhance rendering logic to utilize React-provided SVG structure.
- Create ReactPaperLink model with empty markup for React to render link content.
- Update ReactPaper to support new ControlledPaper features and improve view management.
- Introduce ReactPaperStore to manage ControlledPaper instances within GraphStore.
- Extend GraphStore to handle ReactPaper instances and link geometry updates.
- Add utility types and interfaces for ControlledPaper options and external elements.
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