Commit Graph

55 Commits (728776b3e69d2370f235629a4ef68032af2fd100)

Author SHA1 Message Date
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 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
Анатолий Майоров 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 ca1914b582
refactor(style)!: rename/remove properties and types (#165)
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.
2023-01-30 11:44:06 +01:00
Thomas Bouffard 6fc05a3876
refactor: simplify fontStyle code checking binary mask (#174)
Introduce the `styleUtils.matchBinaryMask` function to remove
duplication in the code checking binary mask on `fontStyle`.
2023-01-17 12:08:32 +01:00
Thomas Bouffard 171c8f8134
fix: SwimlaneMixin handles the 'style.horizontal' `undefined` value (#156)
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.
2023-01-06 16:59:18 +01:00
Thomas Bouffard 3fff754cd6
fix: correctly manage the markers fill style (#157)
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
2023-01-06 16:53:54 +01:00
Filip Wróbel a247b38268
fix: use the right convertPoints function in Stories (#166)
Changed `mathUtils` -> `styleUtils` in affected stories.
2023-01-06 14:16:46 +01:00
Thomas Bouffard 5a346079b5
fix: consider default style when computing effective style properties (#152)
`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.
2022-12-17 09:16:26 +01:00
Thomas Bouffard b7a322b36f
fix: CellOverlay constructor use all parameters to set properties (#159)
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`.
2022-12-16 16:51:51 +01:00
Анатолий Майоров 9428ba2a4a
fix: DynamicLoading story, Codec and parseXml (#125)
Fix `DynamicLoading` story
Restored backward compatibility when using `parseXml`
Possible fix for `Codec.decode` method issue
2022-10-28 15:37:02 +02:00
Thomas Bouffard f08b041c3d
Merge pull request #121 from mayorovad/overlays-stories-fix
Fix stories with overlays usage
2022-10-10 07:14:30 +02:00
Thomas Bouffard a617bb644a
Merge pull request #113 from mayorovad/visibility-story-fix
Fixed `Visibility` story
2022-10-09 20:05:57 +02:00
Anatoliy Mayorov eee2fc8509 Fix stories with overlays usage 2022-10-06 10:58:33 +03:00
mayorovad 38117aefb2 Fixed Guides story 2022-10-04 11:47:03 +03:00
mayorovad 699fbc9590 Fixed Visibility story 2022-10-03 11:07:39 +03:00
Junsik Shim ec7a525ea0 Change CellArray to cellArrayUtils. 2022-09-17 18:58:30 +09:00
Junsik Shim 722021006d Fix CellArray related warnings. #96 2022-09-17 18:57:00 +09:00
Thomas Bouffard f9d757548e
doc: update copyright and license in source file headers (#100)
Ensure that all source files contain the Apache-2.0 license and that the 'maxGraph Contributors' are mentioned.
2022-08-30 17:36:33 +02:00
Thomas Bouffard 893ad44ff2
chore: improve the configuration to build the npm package (#87)
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).
2022-07-05 08:08:25 +02:00
Junsik Shim 8f80956d0e Changed baseStyleName to baseStyleNames. 2022-05-08 18:18:53 +09:00
Junsik Shim 91d9c13286 Changed baseStyleName to baseStyleNames. 2022-05-08 18:05:22 +09:00
Junsik Shim b51504d7bb Changed the type of cell style from string to CellStyle. 2022-04-17 15:58:35 +09:00
Junsik Shim b2bb10ea7e Fixed the 'Anchors' example. 2022-01-22 13:08:56 +09:00
Dave Morrissey 73f5a5979c started refactor of currently unused stories in `stashed` folder 2022-01-18 18:46:56 +11:00
Dave Morrissey 413796ad32
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70)
* 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
2022-01-08 12:49:35 +11:00
Junsik Shim 74b67a60a4 Fixed some errors. 2021-10-20 10:28:27 +09:00
Junsik Shim 570dfaab7b Fix Anchors story. 2021-10-18 10:21:31 +09:00
Junsik Shim eda54946bb Fixing stories... 2021-09-12 23:39:02 +09:00
Junsik Shim e3562c8a08 Fixing stories... 2021-09-10 14:17:59 +09:00
Junsik Shim a7429b2a54 Trying to run HelloWorld... 2021-09-09 10:14:59 +09:00
Junsik Shim 65d800d5be Trying to run HelloWorld... 2021-09-08 10:05:28 +09:00
Junsik Shim 2482ec10e9 Trying to run HelloWorld... 2021-09-07 21:21:22 +09:00
Junsik Shim bdc50a9f48 Refactored everything... 2021-09-07 18:07:27 +09:00
Junsik Shim 4316d4f5e5 - Trying to get the stories working... 2021-09-01 23:04:33 +09:00
Junsik Shim 0adb9fa1d3 - Refactored the stories for storybook to work 2021-08-30 23:20:26 +09:00
mcyph 62c9dd8e34 fixed utils references 2021-07-31 19:55:25 +10:00
mcyph 92e446acb2 conversions to typescript and type fixes 2021-07-12 22:13:45 +10:00
mcyph 960813ca1b conversions to typescript and type fixes 2021-06-13 16:13:43 +10:00
mcyph f76a172cae started refactoring+reorganising core to not have mx prefix, and breaking up mxGraph into smaller classes for easier maintenance 2021-06-06 23:04:44 +10:00
mcyph 7cac8a2a86 bugfixes 2021-05-02 23:59:43 +10:00
mcyph fe7ac7e84d bugfixes 2021-05-02 23:56:17 +10:00
mcyph 707605cedd removed all mxConstants.STYLE_* references, now referring to keys directly 2021-05-02 16:04:34 +10:00
Junsik Shim 6658ff658f - Exports everything in mxConstants separately. 2021-04-30 20:05:49 +09:00
Junsik Shim aef7586beb - Removed unused imports. 2021-04-27 21:52:02 +09:00
Junsik Shim c5899e0955 - Removed mxUtils.indexOf(). 2021-04-27 21:40:09 +09:00
Junsik Shim 654736d23d - Removed mxUtils.bind(). 2021-04-27 21:23:17 +09:00
mcyph 2bcacecc7e various bugfixes 2021-04-25 20:47:53 +10:00
Junsik Shim e95ab5679d - Add more images.
- Convert the rest examples.
- src/ is removed.
2021-04-25 12:39:40 +09:00
Junsik Shim b5b12a225a - Add more images.
- Convert more examples.
2021-04-24 21:33:15 +09:00