Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented May 4, 2025

Previously, the cursors used in various places where define in the CURSOR enum, so their values wasn't configurable.
The cursors can now be configurable using global configuration objects or directly in the classes where they are used.

BREAKING CHANGES: the constants.CURSOR enum has been removed. The values are now configurable and have been moved to:

  • ConnectionHandler
  • EdgeHandlerConfig
  • HandleConfig
  • VertexHandlerConfig

Notes

Covers #192
Closes #378

Impact on the size of the examples

Example v0.19.0 With #795 and #796 With #798, #799, #800 and #801 With #802, #803, #804 and #806
js-example 475.30 kB 474.01 kB 470.31 kB 469.8 kB
js-example-selected-features 415.10 kB 413.98 kB 410.72 kB 410.18 kB
js-example-without-default 347.33 kB 346.21 kB 343.09 kB 342.69 kB
ts-example 438.64 kB 437.42 kB 435.02 kB 434.80 kB
ts-example-selected-features 380.70 kB 379.54 kB 377.37 kB 377.11 kB
ts-example-without-default 329.90 kB 328.74 kB 326.63 kB 326.43 kB

Summary by CodeRabbit

  • Breaking Changes

    • Cursor styles for interactive elements are now configurable through new properties in handler configuration objects, instead of being fixed values.
    • The previous cursor constants are removed; you may need to update any custom integrations that referenced them directly.
  • Documentation

    • Updated changelog to reflect the removal of fixed cursor constants and their new configurable locations.

Previously, the cursors used in various places where define in the CURSOR enum, so their values wasn't configurable.
The cursors can now be configurable using global configuration objects or directly in the classes where they are used.

BREAKING CHANGES: the `constants.CURSOR` enum has been removed. The values are now configurable and have been moved to:
  - `ConnectionHandler`
  - `EdgeHandlerConfig`
  - `HandleConfig`
  - `VertexHandlerConfig`
@tbouffard tbouffard added the enhancement New feature or request label May 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 4, 2025

Walkthrough

This change removes the CURSOR enum from the constants module and replaces all its usages throughout the codebase with configurable cursor properties attached to handler configuration objects (EdgeHandlerConfig, HandleConfig, VertexHandlerConfig) and as an instance property in ConnectionHandler. The changelog is updated to reflect this breaking change. The update ensures that cursor styles for various interactive elements are now configurable rather than fixed, with the relevant cursor values relocated to the appropriate configuration objects or class properties.

Changes

File(s) Change Summary
CHANGELOG.md Updated to document the breaking change: removal of constants.CURSOR enum and relocation to config objects.
packages/core/src/util/Constants.ts Removed the exported CURSOR enum and all its members.
packages/core/src/view/handler/config.ts Added cursor-related properties to EdgeHandlerConfig, HandleConfig, and VertexHandlerConfig.
packages/core/src/view/handler/EdgeHandler.ts
packages/core/src/view/handler/EdgeSegmentHandler.ts
packages/core/src/view/handler/ElbowEdgeHandler.ts
Replaced CURSOR references with values from EdgeHandlerConfig and HandleConfig. Removed CURSOR imports.
packages/core/src/view/handler/VertexHandler.ts Replaced CURSOR references with values from VertexHandlerConfig and HandleConfig. Removed CURSOR import.
packages/core/src/view/plugins/ConnectionHandler.ts Added cursorConnect instance property. Replaced CURSOR.CONNECT with this.cursorConnect.
packages/core/src/view/plugins/SelectionHandler.ts Replaced CURSOR references with values from EdgeHandlerConfig and VertexHandlerConfig. Removed import.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Handler (Edge/Vertex/Connection)
    participant Config (EdgeHandlerConfig/VertexHandlerConfig/HandleConfig)

    User->>Handler: Interacts with UI element (e.g., edge, vertex, handle)
    Handler->>Config: Retrieves cursor style property (e.g., cursorMovable)
    Handler->>User: Sets cursor style according to config value
Loading

Assessment against linked issues

Objective Addressed Explanation
Remove CURSOR enum and use configurable object(s) instead (#378)
Relocate cursor configuration to handler config objects and ensure configurability (#378)
Update all usages to reference new config properties instead of enum constants (#378)

Possibly related PRs

  • feat!: make edge bend points easier to manage #633: Refactors cursor and bend-related configurations in handler classes, moving from hardcoded or instance properties to centralized configuration objects, directly related to this PR's approach for cursor management.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6207f1e and 66348b6.

📒 Files selected for processing (9)
  • CHANGELOG.md (1 hunks)
  • packages/core/src/util/Constants.ts (0 hunks)
  • packages/core/src/view/handler/EdgeHandler.ts (4 hunks)
  • packages/core/src/view/handler/EdgeSegmentHandler.ts (2 hunks)
  • packages/core/src/view/handler/ElbowEdgeHandler.ts (3 hunks)
  • packages/core/src/view/handler/VertexHandler.ts (4 hunks)
  • packages/core/src/view/handler/config.ts (4 hunks)
  • packages/core/src/view/plugins/ConnectionHandler.ts (3 hunks)
  • packages/core/src/view/plugins/SelectionHandler.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/core/src/util/Constants.ts
🧰 Additional context used
🧬 Code Graph Analysis (5)
packages/core/src/view/handler/EdgeSegmentHandler.ts (1)
packages/core/src/view/handler/config.ts (1)
  • EdgeHandlerConfig (128-154)
packages/core/src/view/handler/ElbowEdgeHandler.ts (1)
packages/core/src/view/handler/config.ts (1)
  • EdgeHandlerConfig (128-154)
packages/core/src/view/handler/VertexHandler.ts (1)
packages/core/src/view/handler/config.ts (2)
  • VertexHandlerConfig (232-265)
  • HandleConfig (175-211)
packages/core/src/view/plugins/SelectionHandler.ts (1)
packages/core/src/view/handler/config.ts (2)
  • EdgeHandlerConfig (128-154)
  • VertexHandlerConfig (232-265)
packages/core/src/view/handler/EdgeHandler.ts (1)
packages/core/src/view/handler/config.ts (2)
  • EdgeHandlerConfig (128-154)
  • HandleConfig (175-211)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build
  • GitHub Check: build (macos-14)
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (22)
CHANGELOG.md (1)

28-32: Changelog documents CURSOR enum removal and config migration
The breaking-changes section correctly notes the removal of constants.CURSOR and points readers to the new locations for cursor configuration. This aligns with the code refactor.

packages/core/src/view/handler/ElbowEdgeHandler.ts (2)

26-26: Approve import of cursor config
Replacing the old CURSOR enum import with EdgeHandlerConfig (and retaining HandleConfig for label sizing) is correct. Both are used in this file (EdgeHandlerConfig for cursors and HandleConfig in redrawInnerBends).


69-69: Use configurable cursorTerminal for bend handles
The source and target bend handles now call bend.setCursor(EdgeHandlerConfig.cursorTerminal) instead of a hardcoded enum, centralizing the cursor style.

Also applies to: 87-87

packages/core/src/view/handler/EdgeSegmentHandler.ts (1)

310-310: Apply cursorTerminal from config to segment bends
Both the source and target segment handles correctly use EdgeHandlerConfig.cursorTerminal, replacing the removed enum constants.

Also applies to: 339-339

packages/core/src/view/plugins/SelectionHandler.ts (3)

51-51: Update import for cursor configuration
Removed the CURSOR enum import in favor of EdgeHandlerConfig and VertexHandlerConfig from handler/config.ts, matching the refactor.


1031-1031: Use cursorMovable for edges
Edges now use EdgeHandlerConfig.cursorMovable for the move cursor, replacing the old hardcoded CURSOR.MOVABLE_EDGE.


1033-1033: Use cursorMovable for vertices
Vertices now use VertexHandlerConfig.cursorMovable for the move cursor, replacing the old hardcoded CURSOR.MOVABLE_VERTEX.

packages/core/src/view/handler/VertexHandler.ts (4)

20-20: Remove CURSOR enum import, retain only NONE
Dropping CURSOR from the constants import and keeping only NONE is correct, since all cursor styles are now provided via HandleConfig and VertexHandlerConfig.


235-235: Set selection border cursor from config
Using VertexHandlerConfig.cursorMovable for the selection border cursor aligns with the new flexible cursor configuration system.


280-280: Use labelCursor from handle config for label sizers
Applying HandleConfig.labelCursor to the label handle ensures the handle’s cursor style is configurable.


296-296: Use cursorMovable for small vertex label handle
For small, non-resizable vertices, the label handle now correctly uses VertexHandlerConfig.cursorMovable, matching the global cursor settings.

packages/core/src/view/plugins/ConnectionHandler.ts (3)

374-379: Appropriate addition of configurable cursor property

This new cursorConnect property helps implement the breaking change from having fixed cursor values in a CURSOR enum to making them configurable, as mentioned in the PR description. The property is well-documented with proper JSDoc.


655-655: Correctly updated to use new configurable cursor property

This change replaces what was likely a reference to the removed CURSOR.CONNECT enum value with the new configurable this.cursorConnect property.


1241-1241: Correctly updated to use new configurable cursor property

This change replaces what was likely a reference to the removed CURSOR.CONNECT enum value with the new configurable this.cursorConnect property in the method that sets the cursor on the current state.

packages/core/src/view/handler/EdgeHandler.ts (4)

247-247: Correctly updated to use configurable cursor property

Changed from using the removed CURSOR.MOVABLE_EDGE enum value to the new configurable EdgeHandlerConfig.cursorMovable property.


296-296: Correctly updated to use configurable cursor property

Changed from using the removed CURSOR.LABEL_HANDLE enum value to the new configurable HandleConfig.labelCursor property.


540-542: Correctly updated to use configurable cursor properties

Changed from using the removed CURSOR.TERMINAL_HANDLE and CURSOR.BEND_HANDLE enum values to the new configurable EdgeHandlerConfig.cursorTerminal and EdgeHandlerConfig.cursorBend properties.


572-572: Correctly updated to use configurable cursor property

Changed from using the removed CURSOR.VIRTUAL_BEND_HANDLE enum value to the new configurable EdgeHandlerConfig.cursorVirtualBend property.

packages/core/src/view/handler/config.ts (4)

54-77: Well-defined cursor configuration properties for EdgeHandler

These new properties (cursorBend, cursorMovable, cursorTerminal, cursorVirtualBend) provide a configurable way to set cursor styles for different states in the EdgeHandler, replacing the fixed values from the removed CURSOR enum. Each property has appropriate documentation and default values.


133-139: Proper implementation of cursor properties in EdgeHandlerConfig

The cursor configurations are properly implemented in the EdgeHandlerConfig object with appropriate default values that match the common cursors used in diagram editing:

  • 'crosshair' for bend operations
  • 'move' for dragging edges
  • 'pointer' for terminal connections

These default values maintain the same user experience as before while making the cursors configurable.


182-187: Added label cursor configuration to HandleConfig

This addition to the HandleConfig object makes the label handle cursor configurable, consistent with the overall approach to making cursors configurable rather than fixed.


233-237: Added vertex cursor configuration to VertexHandlerConfig

This addition makes the cursor for movable vertices configurable via VertexHandlerConfig, consistent with the overall approach of the PR.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 4, 2025

@tbouffard tbouffard merged commit bc45f4c into main May 4, 2025
7 checks passed
@tbouffard tbouffard deleted the feat/378_configurable_cursors branch May 4, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review the list of declared enums and check if alternatives can be used instead

1 participant