refactor: remove reference to legacy insert cells methods by tbouffard · Pull Request #876 · maxGraph/maxGraph · GitHub
Skip to content

refactor: remove reference to legacy insert cells methods#876

Merged
tbouffard merged 3 commits into
mainfrom
refactor/remove_ref_to_legacy_insert_cell_methods
Jul 20, 2025
Merged

refactor: remove reference to legacy insert cells methods#876
tbouffard merged 3 commits into
mainfrom
refactor/remove_ref_to_legacy_insert_cell_methods

Conversation

@tbouffard

@tbouffard tbouffard commented Jul 16, 2025

Copy link
Copy Markdown
Member

These legacy methods have a large number of parameters, are hard to read and hard to evolve.

So, to prepare the deprecation of these methods, use the new methods that take a single object parameter in code, examples and documentation.
The storybook stories will be updated later.

Also simplify some calls by not always setting the parent when it was set to the default parent (this is the default
value, so no need to pass it in this case), nor setting an empty string value (same result as not setting it).

In addition, apply various JSDoc improvements.

Notes

Covers #856

Summary by CodeRabbit

  • Documentation

    • Updated all code examples and documentation to use a new object-based parameter style for insertVertex and insertEdge methods, replacing the previous positional argument approach.
    • Clarified npm package compatibility, specifying ES2020 standard and support for both CommonJS and ES Module formats.
    • Enhanced documentation on default cell styles and introduced the ignoreDefaultStyle flag.
    • Added important usage notes about vertex position and size requirements.
    • Improved and modernized code snippets, added important usage notes, and enhanced formatting for clarity.
  • Refactor

    • Refactored test and example code to adopt the new object-based API for graph element insertion, simplifying usage and improving consistency.
  • Style

    • Modernized example code syntax throughout documentation and comments for better readability and maintainability.

These legacy methods have a large number of parameters, are hard to read and hard to evolve.

So, to prepare the deprecation of these methods, use the new methods that take a single object parameter in code, examples and documentation.
The storybook stories will be updated later.

Also simplify some calls by not always setting the parent when it was set to the default parent (this is the default
value, so no need to pass it in this case), nor setting an empty string value (same result as not setting it).

In addition, apply various JSDoc improvements.
@tbouffard tbouffard added the refactor Code refactoring label Jul 16, 2025
@coderabbitai

coderabbitai Bot commented Jul 16, 2025

Copy link
Copy Markdown

@tbouffard tbouffard marked this pull request as ready for review July 16, 2025 16:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/core/src/editor/Editor.ts (1)

286-294: Showcase the leaner call by omitting parent when it’s the default.

Since the surrounding paragraph explains that the new API relieves the caller from passing the default parent, the example could be further simplified:

-const parent = editor.graph.getDefaultParent();
 ...
-editor.graph.insertVertex({parent, value: userObject, position: [20, 20], size: [80, 30]});
+editor.graph.insertVertex({value: userObject, position: [20, 20], size: [80, 30]});

Not critical, but it keeps the documentation perfectly aligned with the stated goal of the refactor.

packages/website/docs/manual/cells.md (1)

112-120: Typo: replace “ommited” with “omitted”.

-    baseStyleNames: ['defaultVertex'], // This can be ommited, as it is the default style applied for vertices
+    baseStyleNames: ['defaultVertex'], // This can be omitted, as it is the default style applied for vertices

Comment thread packages/core/src/view/mixins/CellsMixin.type.ts
@sonarqubecloud

Copy link
Copy Markdown

@tbouffard tbouffard merged commit af6c3be into main Jul 20, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/remove_ref_to_legacy_insert_cell_methods branch July 20, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant