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>
- 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
Remove the `StyleMap` class. It is not used anymore since the
introduction of the `CellStateStyle` interface.
Changes in `CellStateStyle`
- remove `defaultEdge` and `defaultVertex` that have been introduced by
mistake. They have never been used.
- rename `autosize` into `autoSize` for naming consistency. All
properties use camelCase.
- change types from "number" to "boolean" + fix default management in
the Shape classes
- `backgroundOutline`
- `absoluteArcSize`
Other `CellStateStyle` changes: remove a property in favor of another
property
The following properties were introduced by mistake while removing
mxConstants.STYLE_* references in
707605cedd (2021-05-02). Their counterpart
was used in `mxGraph` and is used in all
`maxGraph` examples
- `backgroundColor` in favor of `labelBackgroundColor`. The
`STYLE_LABEL_BACKGROUNDCOLOR` constant was replaced by
'backgroundColor' instead of 'labelBackgroundColor'
- `loop` in favor of `loopStyle`. The `STYLE_LOOP` constant was replaced
by 'loop' instead of 'loopStyle'
Other types that changed
- `CellStateStyle`: better type guidance for the `indicatorShape`
property
- `CanvasState`: order properties alphabetically + add JSDoc on some
properties
- Rename `ArrowType` into `ArrowValue` for consistency with other types
(they all end with the 'Value' post-fix)
Documentation update
- CHANGELOG.md: mention the breaking changes
- Initiate a specific document to help migration from mxGraph: start by
adding the changes on style
--------------------------------------------------------------------------------
**BREAKING CHANGES**: some `CellStateStyle` properties and types have
been removed/renamed.
The horizontal value was considered as true only if was set to true.
It is now also considered as true when set to undefined, as everywhere
else in maxGraph.
SwimLanes.stories.js: update configuration to display nodes.
This update is just a starting point. There is still much to do to match the previous mxGraph example.
Previously, when setting startFill/endFill, the display was inverted
comparing to the configuration.
The marker was filled when set to false, not filled when set to true.
When not set, the marker was filled, which is the expected default.
The issue came from a wrong condition to manage the default value and
was reproduced with the Markers Story.
In addition to the code fix, update the Markers.stories.js to fix style
configurations
- use number instead of string for markers size
- use boolean instead of number for start/end fill
`StyleSheet.getCellStyle` didn't keep the properties of the default
style when `baseStyleNames` was set in the `cellStyle` parameter.
The JSDoc was incorrect (it came from mxGraph) about how the style is
computed, in particular about the default style. It probably leads to
the erroneous implementation during migration. It is now fixed and
clearly describe the rules followed to merge style properties.
The 'Stylesheet' story has been updated to correctly use the maxGraph
API. It also includes more examples involving `baseStyleNames` to
show the 'properties merge' in action.
The `align` and `verticalAlign` values passed to the constructor weren't
set, so the overlay position was always set to
the default one.
The `align` and `verticalAlign` properties are now using the AlignValue
and VAlignValue types respectively instead of
defining inline types. This improves the consistent in the whole code.
To demonstrate the fix, the Overlays story now set 'align' and
'verticalAlign' randomly.
Also introduce `jest` to test the fix and the whole
implementation of the changed method. Types check support is provided by
`ts-jest`. As maxGraph uses a lot of browser objects, also setup
`jest-jsdom-environment`.
Root and all package.json files
- Fix license, version and authors
- Remove the non-relevant .npmignore file at the project. It was designed for mxgraph, the whole directory structure
changed, and we don't plan to publish the root package
`core` package
- Generate type definition and javascript files for ESM output
- dedicated folder for `esm` and `types` in the `dist` folder to clearly separate concerns
- exported in the package.json
- Add npm script for `npm pack` configuration
- Drop the `postinstall` npm script that built the `core` bundle. It would have been run when the package is installed
in dependent projects at dependencies install. And it would have failed as it tries to build the project from TypeScript
sources that are not available in the npm package.
fix: ConstraintHandler now loads image as everywhere else in the code using `Client.imageBasePath`
Using import doesn't work as the image is not available in the npm package. It generated error like this in ViteJS
project:
Failed to resolve import "../../../images/point.gif" from "../core/dist/esm/view/handler/ConstraintHandler.js". Does the file exist?
This gif import had been introduced to make `Anchors.stories.js` retrieve the gif file. Configuring `imageBasePath` as
already done in other stories fixes the issue.
Don't export EditorCodec and StylesheetCodec as they generate errors.
This is a temporary solution to avoid error in dependent project (at least, with ViteJS projects).
* reorganised directories; removed mx prefix
* reduced directory hierarchies; removed mx prefix; type fixes
* convert remaining javascript to ts
* fix/add types
* add type defs
* type updates; moved codecs to where they're used
* reorganise constants into enums+type additions
* removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc
* removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc
* removed "Function:" prefixes from comments, as they aren't needed in JSDoc
* minor changes
* convert code example blocks to markdown
* module casing updates
* converted parameter function documentation to JSDoc
* documentation+type updates
* removed react subdir (for now)
* reorganised various `utils` functions into different files
* type updates/bugfixes/workarounds
* rename Rubberband and CellEditor to be *Handler to match the other plugins
* move codec classes to where they're used to reduce cyclic dependencies
* move codec classes to where they're used to reduce cyclic dependencies
* type updates/reorganize layout file structure
* renamed various files for consistency
* import fixes
* renamed GraphHandler SelectionHander and various fixes
* convert EventObject parameters to objects
* add basic better-docs config
* update better-docs config
* bugfix for shared variables in Graph persisting across instances
* fixed accessing handlers in examples; renamed Model to GraphModel
* fixed accessing handlers in examples; renamed Model to GraphModel
* restored selection model
* bugfix
* renamed getModel to getDataModel
* changed to use graph.batchUpdate() to reduce lines of code
* changed to use graph.batchUpdate() to reduce lines of code
* finished annotations+added TypeDoc
* convert remaining Cell[] instances to CellArray
* convert NaturalDocs links to JSDoc