Commit Graph

188 Commits (development)

Author SHA1 Message Date
Thomas Bouffard c45b78a4da
test: check XML import/export of style.baseStyleNames (#315)
Ensure that the array is correctly converted.
2024-01-26 11:49:25 +01:00
Thomas Bouffard 8779a7468b
refactor: remove side effects when registering default style elements (#311)
Explicitly call the elements to remove the side effects in
`CellRenderer` and `StyleRegistry`.
This prepares the possibility to mark the library as "side effects free"
and will allow to changes the defaults in the future.
2024-01-20 18:10:59 +01:00
Thomas Bouffard b6c2c3b56b chore(release): prepare version 0.7.0 2024-01-20 17:19:53 +01:00
Thomas Bouffard c46a72b58d
fix: import/decode the XML Graph model when the code is minified (#309)
Create a dedicated example with webpack to reproduce the problem. Names
used to retrieve the codecs are set directly in the codecs at
initialization to not depend on the actual constructor names.

This changes also partially fixe the export/encode. The Geometry is not
correctly encoded. More work is needed to make this work, probably by
modifying the way Codecs are registered and retrieved.
2024-01-20 14:49:47 +01:00
Thomas Bouffard a0ea2b99fc
fix: remove extra "implements" clause in `MaxPopupMenu` (#310)
This clause has been introduced in 61648e4 and seems not needed.
2024-01-20 13:52:43 +01:00
Thomas Bouffard 5ddc8f5af2
feat: declare exports in package.json (#306)
It lets use `moduleResolution=bundler` in TypeScript applications.
In particular, it lets use it with Storybook and ts-example in this
repository.
2024-01-18 07:44:23 +01:00
jkarkoszka a68c94e892
fix: always correctly position the child vertex of an edge (#307)
The position was incorrect for child using relative geometry.
Introduce a new const to avoid overriding other const with the
same name defined before.
This side effect had been introduced during the migration from mxGraph.
2024-01-18 07:41:21 +01:00
Thomas Bouffard 835bfe7ce9
feat: allow to load an XML-stored model produced by `mxGraph` (#300)
Implementation relies on both the declaration of aliases and the
introduction of dedicated codecs.
`Codec.getCodecByName` now takes aliases into account, so that importing
is fully functional.
The code of some `CodecRegistry` and `Codec` methods has been simplified
(check for nullity of method parameters).

The cell style is converted thanks to a specific utility function that
can serve as an example for those wishing to migrate their applications
from mxGraph to maxGraph.

test
- The `Codec` example has been restored from the stashed directory. It
is now available as a story written in TypeScript.
- The `ModelChecker` utility class was previously used only to validate
the imported model after import from the maxGraph model. It is now
shared and also used in mxGraph import tests. It has also been enhanced
to check the total number of cells in the model.
2024-01-16 11:03:56 +01:00
Thomas Bouffard 851ea38d38
docs: improve `MaxLog` JSDoc and type definition (#301) 2024-01-10 07:57:36 +01:00
Thomas Bouffard 20c31f9bc6
fix: define CellStyle.portConstraintRotation as boolean (#299)
It was incorrectly defined as DIRECTION after the migration from
mxGraph.

Also improve the type signature and JSDoc of
mathUtils.getPortConstraints which is the only function that uses the
`portConstraintRotation` property in maxGraph.
2024-01-10 07:56:55 +01:00
Thomas Bouffard 77a7359985
fix: ensure decode works without encode first (#297)
Declare generic `ObjectCodec` for `Cell` properties that are defined as
XML node. Codecs are currently only registered automatically during
encode/export, so for now, they have to be registered to be available
during decode/import.

Also improve some methods signatures in base Codec objects (use specific
types instead of `any`).
2024-01-09 06:01:45 +01:00
Thomas Bouffard 728776b3e6
ci: upload test coverage results (#298)
Also rename the artifact storing all examples for clarity.
2023-12-29 07:24:34 +01:00
Thomas Bouffard 7544da2da3 chore(release): prepare version 0.6.0
Also improve the release procedure.
2023-12-22 08:26:38 +01:00
Dave Morrissey 63f002c263
feat: restore remaining non-"Editor" examples to Storybook (#150)
Converted the following remaining "stashed" examples to Storybook:
  - GraphLayout
  - HtmlLabel
  - MenuStyle
  - ShowRegion
  - Scrollbars (is starting to display, but appears to have a bug where `<g>` elements are inserted outside of the `<svg>` element)
  - Wires

The examples are still not fully working. As the mxGraph examples were previously migrated to nextjs/react, some original code may not have been ported correctly.


Additional changes in @maxgraph/core:
  - Fixes the default parameters in `MaxPopupMenu` and `Morphing` to restore the original `mxGraph` behavior.
  - Graph: add new "create*" factory methods to ease the extension:
    - createEdgeHandlerInstance(state: CellState): EdgeHandler
    - createGraphDataModel(): GraphDataModel
    - createSelectionModel()

---------

Co-authored-by: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com>
2023-12-22 06:54:34 +01:00
Thomas Bouffard d5c60b120f
docs: improve the getting started documentation (#292)
The changes are based on recent feedback from newcomers.

Also
  - improve the link to the mxGraph documentation.
  - README bundled in the npm package: add a link to GitHub repository
  README to guide people to the getting started information.
2023-12-21 07:58:27 +01:00
TravisAdsitt 164d10a437
fix: correcly call 'isEdge' in CellEditorHandler (#286)
`isEdge` is not a model function but rather a function of the cell.
2023-12-18 16:05:06 +01:00
Thomas Bouffard 99ffdfa29b
feat: add `ModelXmlSerializer` to import/export the model (#290)
This class was previously only available in test. It simplifies maxGraph
model import/export as:
  - it hides `Codec` and `HTMLElement` management
  - it registers codecs automagically
2023-12-18 15:53:43 +01:00
Thomas Bouffard f9b2d7d19a
refactor!: move codecs to dedicated files and reduce side effects (#289)
Previously, codec classes were defined and registered in the same file
as the class they targeted. This prevented efficient tree-shaking: as
soon as the target class was imported (e.g. `StyleSheet`), the
corresponding codec was also imported (`StyleSheetCodec`). As a result,
a large amount of codec code (and dependent code) was present in
applications incorporating maxGraph, even if they didn't use the codec
function. As there are currently many problems with the codec function
that make it almost unusable, this was a great waste.

Codecs are no longer registered by default, which reduces side effects
and coupling.
It also greatly improves tree-shaking.
For example, in the `ts-example` application included in this repository
which doesn't use the "codec" feature, the size of the minified
`maxGraph` chunk goes from `568.58 kB` to `467.90 kB`, which corresponds
to a size reduction of `17.7%`!


BREAKING CHANGE: Codecs supplied by `maxGraph` are no longer registered
by default. They MUST be registered before performing an `encode` or
`decode`. You can use one of the following functions to register codecs:
  - `registerAllCodecs`
  - `registerCoreCodecs`
  - `registerEditorCodecs`
2023-12-13 17:39:40 +01:00
Thomas Bouffard 871e1c37d5
test: refactor graph initialization (#288)
Use the graph initialization util function in the "serialization" tests.
2023-12-11 08:54:15 +01:00
Thomas Bouffard 3041ca337e
docs: improve JSDoc of codec classes (#287)
In addition, apply minor refactoring
  - Codec.decodeCell: improve signature (default value)
  - ObjectCodec
    - use Codec type instead of value in import
    - simplify implementation of ObjectCodec.isNumericAttribute
2023-12-11 08:42:29 +01:00
Thomas Bouffard 8d6f0e107c
test: execute tests serially to speed up test execution (#284)
By default, `jest` runs tests in parallel. However, with the current
configuration of `ts-jest`, all workers run `tsc` in parallel, which is
very slow and consumes a lot of resources. This is what takes the
longest.
By running `jest` serially, `tsc` runs before starting the first test,
then all subsequent tests run faster. This will probably be improved by
customizing the configuration of `jest` or with future versions of
`ts-jest`.
2023-12-10 10:22:07 +01:00
Thomas Bouffard 9463e1e21e chore(release): prepare version 0.5.0
Also improve the documentation of the release procedure.
2023-12-07 16:57:36 +01:00
Thomas Bouffard ffd5036054
fix(robustness): prevent errors when a plugin is not loaded (#272)
Add guards to prevent accessing properties and methods on undefined
instances when a plugin is not loaded.
Also fix and improve the JSDoc of the `EdgeHandler` and `Guide` classes.
2023-12-07 16:10:33 +01:00
Mohammed Imran 8d6727a411
feat(types): improve partial-autocomplete and type inference (#265)
Update types with partial-autocomplete and value type for better type
inference.
2023-12-06 15:12:42 +01:00
Thomas Bouffard 17f31fcc5c
chore: clean before pack (#270)
This simplifies the release procedure. No manual cleaning is required,
this reduces the risk of errors.
2023-12-03 21:50:14 +01:00
Thomas Bouffard ac48ea0d86
chore!: only include ESM in the npm package (#266)
Get rid of the UMD bundle: not pratical, not minimified so not ready for
production, nor for reuse.
This lets remove the webpack build which was not used anymore.

- core build: everything is done with tsc and simplify pack
- remove webpack configuration
- Move typedoc in the package where it is used (make it easier to detect
usage)
- remove unused dependencies: 
  - better-docs (use typedoc instead)
  - webpack loaders (css, file, style, url)
  - babel
  - circular-dependency-plugin (webpack plugin)
  - webpack
  - cross-env
- core build: tsc only

BREAKING CHANGE: the UMD bundle is no more provided in the npm package
2023-12-03 16:51:40 +01:00
Thomas Bouffard 6e6009aebd
docs: build the user documentation with Docusaurus (#264)
Initiate the website with Docusaurus v3.
Setup the site and includes the content that was already available in
the `docs` package.
The currently implementation mainly uses the default theme available
when using the Docusaurus scaffolding. It was initiated with:
`npx create-docusaurus@3.0.0 my-website classic`
2023-11-27 18:53:52 +01:00
Thomas Bouffard b008f46be5 chore(release): prepare version 0.4.1 2023-10-30 07:36:17 +01:00
Thomas Bouffard fe7f1a8123
chore: migrate to storybook v7 (#230)
- Migrate the existing stories to work with storybook v7.
- Use the `vite` builder. The startup time decrease from 40 seconds
(best time with v6) to 1 second (worst time with v7)
- Webpack is no more used, `vite` now manages everything
- Add support for writing stories in TypeScript. It also detect existing
import errors in the existing stories written in JS
- Migrate the Toolbar story to TypeScript to demonstrate it works. As
part of the migration, fix how CellStyle is set in the story (easily
detected thanks to types checking)
- Detect wrong imports in stories and fix them
- The storybook mini-site can be built (previously the build always
failed and storybook could only be used in development mode)
- Add support for Node 18

Other changes
- core: simplify the "dev" script:
- There is no need to invoke webpack as the UMD bundle is no longer used
by stories.
- Instead, call `tsc` watch which is faster, so code changes are visible
faster in stories
- "Build" GitHub workflow:
- Build storybook mini-site and attach all examples as artifact to help
reviewing Pull Requests
- Lint at the end, this is more important to check the build and
examples first
2023-10-12 23:41:37 +02:00
Eric Redekopp f09abdf53a
fix: make 'movable' style attribute behave as expected (#248)
The 'movable' style attribute of cells had the opposite effect as what
would be expected. When set to false, cells could be moved, and when true,
cells couldn't be moved.
This is something that got lost in translation in the conversion from mxGraph.
Previously, it assumed that if 'movable' had any value, it must be the string "0". This
attribute got changed to a boolean in Typescript, but it looks like the
check never got updated leading to this strange behaviour.

The fix is fairly simple.
If 'movable' is undefined, then we assume that it's true.
If not, then we check it like a regular boolean.
2023-10-12 10:23:32 +02:00
Thomas Bouffard 54c82230c1
test: improve HierarchicalLayout tests (#245)
Also check that the layout change the position of the cells.
2023-10-10 06:21:22 +02:00
Thomas Bouffard 3758ac4dce
chore: review private property in package.json files (#244)
Remove versioning for private packages are they are not supposed to be
consumed outside the project.
Explicitly mark public packages.
2023-09-15 12:31:22 +02:00
Thomas Bouffard e175937f02 chore(release): prepare version 0.4.0 2023-09-14 15:10:05 +02:00
Thomas Bouffard 7556b72415
fix: use configurable path for `errorImage` (#241)
The default path of `errorImage` hard coded the context instead of using
`Client.imageBasePath` as everywhere else.
This seemed to be a migration mistake (the original code using the
configurable path was commented).
2023-09-14 15:02:24 +02:00
Franz Ritter efb5b4bdf9
fix: allow `HierarchicalLayout` to manage circular dependencies (#233)
Uncomment the isAncestor method GraphHierachyNode, which is used by
HiearchlLayout. The uncommented implementation makes sure, that a
circular dependency is detected and resolved. Using the default
isAncestor does not work at this point, because the parent nodes of the
child nodes in the graph are not set.

The problem was unintentionally introduced during the initial refactoring of
the mxGraph code in 413796a.
The idea of the author was to remove an useless comment but they left an
extra /** behind which commented the isAncestor method.
2023-09-14 14:49:07 +02:00
Анатолий Майоров e3b61cdc21
feat: add Manhattan connector EdgeStyle and demo (#232)
Add Manhattan connector edge style and demo for it in Storybook.
Code is based on https://github.com/mwangm/mxgraph-manhattan-connector
Ported code to Typescript, refactored it and placed to `EdgeStyle.ts`.
2023-09-14 14:42:25 +02:00
Thomas Bouffard e5a28b3f30
docs: add JSDoc to CellStyle.baseStyleNames (#222) 2023-08-28 08:36:11 +02:00
Thomas Bouffard e48f3fa052
docs: improve JSDoc of TooltipHandler (#219) 2023-08-28 08:34:44 +02:00
Thomas Bouffard 92759df232
feat: include default css and images in the npm package (#225)
Providing these resources simplify the `maxGraph` integration.

Use the default CSS in ts-example to illustrate how to override defaults
Initiate a documentation to start guiding users.
2023-07-13 12:25:10 +02:00
Thomas Bouffard 03f59aa130
refactor: improve examples in README and ts-example (#223)
ts-example
  - improve the position of the ellipse labels
  - introduce a shared style for ellipse vertices
  - bump vite from 4.3.9 to 4.4.2
  - work when not deployed in the "root" context of the site

README
  - improve the position of the ellipse label
  - display rounded orthogonal edge
  - fix the style configuration to match the rendering shown in the gif
2023-07-10 07:07:19 +02:00
Thomas Bouffard c422ca35ee chore(release): prepare version 0.3.0 2023-07-07 12:19:14 +02:00
Thomas Bouffard e82abd6da3
feat: improve the EdgeMixin type (#212)
The methods defined in the `EdgeMixin` type were not documented.
The signature of the `insertEdge` method was using a spread `any`
parameter, so it provided no guidance nor guard.
Instead, the type now declares the various form of the methods with the
right signature.
2023-07-07 07:56:01 +02:00
Thomas Bouffard cdd8830b5c
feat: improve the VertexMixin type (#211)
The methods defined in the `VertexMixin` type were not documented.
The signature of the `insertVertex` method was using a spread `any`
parameter, so it provided no guidance nor guard.

Instead, the type now declares the various form of the methods with the
right signature.
2023-07-07 07:41:49 +02:00
Thomas Bouffard 4a79be5499
docs: add keywords in package.json (#216)
For the `@maxgraph/core` package.
2023-07-07 07:39:30 +02:00
Thomas Bouffard d5c1d4dc21
docs(release): add task for the "examples" repository (#215)
Also improve the main README
  - improve the paragraph about how to build the npm package locally
  - use the "application" wording instead "project" when required
  - highlight mxGraph and maxGraph
2023-07-07 07:06:09 +02:00
Thomas Bouffard 711db920da
fix: export EditorToolbarCodec and StylesheetCodec (#218)
These 2 classes were previously not exported as they generated runtime
errors when applications integrating `maxGraph` used the Vite dev
server.

Bump vite from 4.3.1 to 4.3.9. This is probably what fixed the problem.
No need to export Stylesheet and EditorToolbar as default as they are
already exported.
2023-07-07 06:54:31 +02:00
Thomas Bouffard d7646d6405
docs: improve JSDoc of GraphLayout and CompositeLayout (#217)
Improve wording
Remove references to mxGraph code
Use modern JS code in examples
2023-07-06 16:59:45 +02:00
Thomas Bouffard 992f3af63d
feat: add GraphDataModel.batchUpdate method (#213)
The method already exists in the `Graph` class. It needs to be made
available in `GraphDataModel` as well, to simplify the transaction
syntax.
Start using it in some places to simplify the syntax and also use
`Graph.batchUpdate`.
2023-07-06 07:02:20 +02:00
Thomas Bouffard 0c7a68bcc1
fix: compute the current style of ShadowRoot element (#214)
`ShadowRoot` element cannot be passed to the `window.getComputedStyle`
method.
Otherwise, errors occur, in particular, it prevents the mouse and
gesture events to be propagated.
2023-07-06 06:50:51 +02:00
Thomas Bouffard fd0d47ad4a
refactor!: remove unused CellMap type (#210) 2023-07-03 11:13:10 +02:00