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
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`
The default edge and vertex styles are always defined. Updating the
signature of the two methods returning default styles simplifies the
code for callers, who don't have to deal with "undefined" values.
Improve the ts-example
- rely on no `undefined` style
- bump vite from 3.2.3 to 4.3.1 and increase the file size warning
- improve the use of types
- better explain why we cannot use enum to define the 'edgeStyle'
CellStyle property
BREAKING CHANGE: `Stylesheet.getDefaultVertexStyle` and
`Stylesheet.getDefaultEdgeStyle` no longer return `undefined`.
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.
Helper functions involving "style in the string form" have been removed
from `styleUtils`. Styles are defined using the `CellStateStyle` and it
is no longer necessary to process strings.
Removed functions
- addStylename
- getStylename
- getStylenames
- indexOfStylename
- removeStylename
- removeAllStylenames
- setStyle
**BREAKING CHANGES**: some `styleUtils` functions have been removed.
The former mxGraph tags have been removed. List them in the changelog
for history.
Also update the project status in the README as there is no more
blocking issue for a first release.