Commit Graph

700 Commits (a68c94e8927dfab1ca4b78c5b46e103217ac7fb2)

Author SHA1 Message Date
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 41a3fbfd55
ci: automate npm publish (#305)
Add a workflow that performs the publishing when a new Git tag is
pushed.
2024-01-14 16:28:29 +01:00
dependabot[bot] eb1e866ede
chore(deps): bump follow-redirects from 1.15.3 to 1.15.4 (#304) 2024-01-10 09:32:11 +00: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 7c94e0c3af
ci: automate the creation of the draft GitHub release (#303)
Provide a template that will ease the GitHub release writing.
This will also ensure that the content of all release notes is
consistent.
2024-01-10 06:41:09 +01:00
Thomas Bouffard 2cd17f1a3e
docs: skip release of the examples repository (#302)
The release process of the "examples" repository is directly documented
and managed in the repository.
This makes the 2 repositories more independent, and provides more
flexibility.
2024-01-10 06:11:44 +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 9a7b2b463d
fix: make the DynamicLoading story work again (#296)
Fix Story by using `ModelXmlSerializer` to ensure that codecs are
correctly registered. Also move the code of the story to TypeScript to
better detect the errors.

In addition:
  - update `DynamicStyle.stories.js` to improve comments and the code.
- change the `moduleResolution` to `node` in tsconfig to work in all
IDE. This is a temporary change.
2024-01-08 18:49:27 +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
dependabot[bot] a9c1ab6000
chore(deps-gha): bump actions/upload-artifact from 3 to 4 (#291)
Also update the name of the artifact by using a dedicated name per OS

With actions/upload-artifact@v4, it is not possible to upload to the same named Artifact multiple times.
2023-12-18 15:54:31 +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 1507490c72
docs(release): improve the "examples repository update" paragraph (#285)
Changes are based on the feedback collected during the  `0.5.0` release:
  - Use Dependabot to update `maxGraph`
  - Fix link to GitHub releases.
2023-12-11 08:49:27 +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
dependabot[bot] e1e7c19e3d
chore(deps-dev): bump ansi-regex from 5.0.0 to 5.0.1 (#278) 2023-12-07 15:35:44 +00: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
dependabot[bot] 0e7bd5fece
chore(deps-dev): bump semver from 5.7.1 to 5.7.2 (#277) 2023-12-06 03:55:53 +00:00
dependabot[bot] 23ec0bf9c1
chore(deps): bump word-wrap from 1.2.3 to 1.2.5 (#276) 2023-12-06 03:55:09 +00:00
dependabot[bot] 4aa3ac0e12
chore(deps-dev): bump json5 from 1.0.1 to 1.0.2 (#275) 2023-12-06 03:54:45 +00:00
dependabot[bot] 76f3f2e389
chore(deps-dev): bump vite from 4.4.11 to 4.4.12 (#281) 2023-12-06 03:47:56 +00:00
Thomas Bouffard 12e50b48a5
ci: update modified files that trigger workflow execution (#280)
Some recently deleted files were still listed, while the package-lock.json file had not been added.
2023-12-04 04:13:32 +01:00
Thomas Bouffard d9b85945f8
chore: use npm workspaces (#273)
`maxGraph` was using `lerna` v4 to build and only used its "build
workspaces" support, not the "publishing" support as we only published a
single package and it is done manually, without using `lerna`.
The support for packages in `lerna` was removed in version 7. See
https://github.com/lerna/lerna/releases/tag/7.0.0 and
https://lerna.js.org/docs/legacy-package-management.
So, start using npm workspaces as we don't need to manage the publishing
of several packages for now.

This will allow to do more reproducible builds by locking dependencies
with a `package-lock.json` file. This didn't work well with `lerna` v4
and had been disabled.
2023-12-04 03:25:41 +01:00
Thomas Bouffard 068a50f35c
docs: remove extra "markdown-page" page (#274)
This page is an example from the Docusaurus initialization. It has been
kept by mistake.
2023-12-04 02:35:28 +01:00
Thomas Bouffard d46e99a114
docs: improve the migration guide from mxGraph (#271)
Provide various improvements
  - fix `InternalEvent`
  - improve `Client`
  - improve explanations about plugins
  - removed `mxUtils` methods
  - removed `isVisible` methods

Also use more admonitions.
2023-12-04 00:57:50 +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 9e6c854aa8
ci: use macos-13 in GitHub workflows (#269)
Build with a more recent version to better suit developers' machines,
which usually use a recent operating system.
2023-12-01 09:51:11 +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 3e9b9b8e77
chore: build with Node 18 (#263) 2023-11-16 14:39:08 +01:00
Thomas Bouffard f58ec67e5f
refactor: simplify the code of `ts-example` (#255)
Replicate the improvements done in the `maxgraph-integration-examples`
repository:
- introduce function to simplify the main file
- Remove out dated comments
- Simplify the code and use "type" imports when possible
2023-11-16 11:53:47 +01:00
Tim Nelson 43e84c49e8
docs: improve instructions for setting up a dev environment (#262)
There was missing information in the documentation.
Add `npm pack` command to instructions for setting up a dev environment.
2023-11-09 10:40:07 +01:00
Thomas Bouffard dc939142dc docs: add release dates in CHANGELOG 2023-10-30 07:38:39 +01:00
Thomas Bouffard b008f46be5 chore(release): prepare version 0.4.1 2023-10-30 07:36:17 +01:00
dependabot[bot] af16274eb1
chore(deps-gha): bump actions/setup-node from 3 to 4 (#258) 2023-10-30 06:19:15 +00: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 a0b762c707
docs: describe the security policy (#242) 2023-09-14 15:03:14 +02:00