1403 Commits

Author SHA1 Message Date
Alois Klink
eb5d65fabc build(types): create types from config JSON Schema
Runs `pnpm --filter mermaid run types:build-config` to automatically
generate typescript types for `MermaidConfig` from the
JSON Schema file.
2023-07-06 03:53:40 +01:00
Alois Klink
7c3a73d4a8 build(types): add script to generate Config types
Add script `packages/mermaid/scripts/create-types-from-json-schema.mts`
to automatically generate the TypeScript definition for `MermaidConfig`
from the `MermaidConfig` JSON Schema at
`packages/mermaid/src/schemas/config.schema.yaml`.

To do this, we are using this library
[`json-schema-to-typescript`][1], which is also used by Webpack to
generate their types from their JSON Schema.

In order to make sure that this isn't a breaking change, the script
makes all fields **optional**, as that is what the original typescript
file has.

Additionally, I've put in some custom logic into the script, so that
the exact same order is used for the TypeScript file, to make the
`git diff` easier to review. In the future, we can remove this custom
logic, once we no longer need to worry about `git merge` conflicts.

[1]: https://github.com/bcherny/json-schema-to-typescript
2023-07-06 03:53:40 +01:00
Alois Klink
0230722d36 build(docs): build JSON Schema docs
Automatically build documentation for JSON Schema.

This is only built when running with `--vitepress`,
as it currently produces loads of markdown files, which I feel like
we shouldn't be committing.

This currently manually uses some internal `jsonschema2md` functions
so that we can manually control the Markdown output.
2023-07-06 03:53:40 +01:00
Alois Klink
52a1243da5 build: use vite to get default mermaid config
Adds a vitepress JsonSchema plugin that automatically loads
the Mermaid Config JSON Schema from a .schema.yaml file and
gets the default values from it.
2023-07-06 03:53:40 +01:00
Alois Klink
58b43976ff feat: add Mermaid Config in JSON Schema format
Add a JSON Schema file (in YAML) for the MermaidConfig.

This JSON Schema file follows [JSON Schema 2019-09][1], with some slight
modifications to work with:

- [json-schema-to-typescript][2]
  The `tsType` keyword is used to override the generated TypeScript
  type, when it doesn't match the JSON Schema type.

  This is used in two cases:
    - when the current type cannot be represented in JSON Schema
      (e.g. `FontCalculator`, which is a function)
    - when the JSON Schema type is narrower than the TypeScript type.
      Currently, many enums types are listed as `string` in TypeScript,
      but json-schema-to-typescript converts them to `"val1" | "val2"`.
      I've manually set them to `string | "val1" | "val2"` to avoid
      causing a breaking change in the TypeScript types. We should
      remove these in a future major version of TypeScript.
- [@adobe/jsonschema2md][3]
  The `meta:enum` keyword is used to add documentation for specific enum
  values.

[1]: https://json-schema.org/draft/2019-09/release-notes.html
[2]: https://www.npmjs.com/package/json-schema-to-typescript
[3]: https://www.npmjs.com/package/@adobe/jsonschema2md
2023-07-06 03:53:35 +01:00
Alois Klink
4372a54dba docs: add support for ``regexp`` code blocks
Currently, shiki doesn't support code-blocks that use the regexp
language, which means vitepress throws an error on them:

```regexp
^([1-9][0-9]*)(minute|hour|day|week|month)$
```

As a hack until shiki supports them, I've just modified them to get
converted into JavaScript RegEx literal code-blocks, e.g.:

```javascript
/^([1-9][0-9]*)(minute|hour|day|week|month)$/
```
2023-07-06 03:04:08 +01:00
Alois Klink
38013de711 fix(quadrant): make quadrant options optional
Make the types of the options in QuadrantChartConfig in the
MermaidConfig optional. All of these (except for the values in
`BaseDiagramConfig`) will be automatically set to their
default values, so they're optional from a user perspective.
2023-07-06 01:06:01 +01:00
Nikolay Rozhkov
c742ac71a4
Merge pull request #4598 from mermaid-js/sidv/fixDocsDev
Fix docs:dev
2023-07-05 14:05:27 +00:00
Sidharth Vinod
382026ed33
Fix docs:dev 2023-07-05 12:20:56 +05:30
Nikolay Rozhkov
9f5f0a6e66 Reduce sankey width 2023-07-05 01:49:58 +03:00
Nikolay Rozhkov
8449a44607 Sankey: Remove duplicated examples 2023-07-05 01:15:22 +03:00
Nikolay Rozhkov
d5021cab1d Remove double parsing 2023-07-03 18:57:26 +03:00
Sidharth Vinod
1b190b2892
Merge pull request #4551 from Yokozuna59/refactor-accessibility
refactor accessibility
2023-07-03 15:07:21 +00:00
Sidharth Vinod
6d7cd2b41f
Merge pull request #4580 from aloisklink/refactor/replace-enums
Remove all TypeScript enums and forbid them in ESLint
2023-07-03 07:26:39 +00:00
renovate[bot]
d6731a07db
Update all patch dependencies 2023-07-03 05:18:01 +00:00
Alois Klink
fbf79ffcc0 refactor: replace TypeScript enum with JS obj
[`const` assertions where added in TypeScript 3.4][1] and can be used
to create enum-like objects in plain JavaScript, that act like
TypeScript enums, but has none of the downsides of TypeScript enums.

[1]: https://devblogs.microsoft.com/typescript/announcing-typescript-3-4/#const-assertions
2023-07-02 23:56:42 +01:00
Alois Klink
b989ff5362 fix: change sankey config types to be unions
Replace the TypeScript `enum {a = "a", b = "b"}` types with
TypeScript's literal types (e.g. `"a" | "b"`).

This is because TypeScript enums are
[_not_ a type-level addition to JavaScript][1], and even the official
TypeScript docs say to be careful when using.

[1]: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#enums
2023-07-02 23:44:19 +01:00
Yokozuna59
406df57f81
Merge branch 'develop' into refactor-accessibility 2023-07-02 10:24:21 +02:00
Sidharth Vinod
dfc466514d
Merge branch 'develop' into feature/1838_actor_creation_destruction 2023-07-02 13:36:04 +05:30
Sidharth Vinod
2a1759aab4
Merge branch 'develop' into refactor-accessibility 2023-07-02 13:04:09 +05:30
renovate[bot]
b55a9328f4
Update all patch dependencies 2023-07-02 05:07:56 +00:00
Sidharth Vinod
19325777e5
Merge branch 'develop' into feature/1838_actor_creation_destruction 2023-07-02 10:32:59 +05:30
Sidharth Vinod
afb979f32b
Merge branch 'develop' into feature/4492_sankey-diagrams 2023-07-02 09:55:45 +05:30
Nikolay Rozhkov
abb7bb23d6 More detailed sankey docs 2023-07-02 02:34:22 +03:00
Nikolay Rozhkov
084b765e9f Added tests for colors and fully setup cypress in Docker 2023-07-02 01:10:06 +03:00
Ibrahim Wassouf
4570f824f7 Fix relative link to theme variables list 2023-07-01 15:45:48 -03:00
Nikolay Rozhkov
a62719826a Docker+Cypress, better run, removed unused syntax
Added cypress container (from their official image),
may be reconsidered later to choose our own
The only minor problem is node JS version mistmatch
package.json 18.16.0
docker-compose mermaid 18.16.1
docker-compose cypress 18.16.0

Host option in cypress docker container must be removed
in favor of possible configuration option.
http://localhost:9000 are currently hard-coded, that is bad

Updated ./run script with better documentation
and added some styles too it as well

Started sankey.spec.js as an example
2023-07-01 16:17:25 +03:00
Nikolay Rozhkov
cd7fce4e4d Merge branch 'develop' into feature/4492_sankey-diagrams 2023-06-30 22:58:56 +03:00
Sidharth Vinod
1645bf0479
Merge branch 'develop' into pr/Valentine14th/4466
* develop:
  Add threshold
  Updated mermaid version to 10.2.4
  update latest news section
2023-07-01 00:29:43 +05:30
Knut Sveidqvist
02d4be23cf Merge remote-tracking branch 'origin/develop' into develop 2023-06-30 13:25:32 +02:00
Knut Sveidqvist
04b11d1ba6 Merge branch 'release/10.2.4' 2023-06-30 13:24:43 +02:00
Knut Sveidqvist
453b337e6e Updated mermaid version to 10.2.4 2023-06-30 13:10:22 +02:00
Sidharth Vinod
3fe0c8b13d
Merge branch 'develop' into feature/1838_actor_creation_destruction 2023-06-30 16:00:24 +05:30
Pascal Knecht
a1dfc3dac9
Fix Typo 2023-06-30 11:59:40 +02:00
Nikolay Rozhkov
b2f6858ff7 Prettier 2023-06-29 20:23:10 +03:00
Nikolay Rozhkov
06cb0c3be9 Fixed package json 2023-06-29 20:22:06 +03:00
Nikolay Rozhkov
9177350a39 Fixed double quotes, docs, demo and added more examples to run script 2023-06-29 20:16:25 +03:00
Nikolay Rozhkov
e24dce10a2 Added sankey documentation 2023-06-29 19:51:46 +03:00
Nikolay Rozhkov
e7ad294283 Merge branch 'develop' into feature/4492_sankey-diagrams 2023-06-29 16:50:38 +03:00
Nikolay Rozhkov
95a436595e Let it be as it was in dev branch 2023-06-29 16:44:33 +03:00
Nikolay Rozhkov
8e3f8b1a57 Fixes after review 2023-06-29 15:39:50 +03:00
Nikolay Rozhkov
408c32781e Contributors fetching failure must not hinder docs development 2023-06-29 15:24:14 +03:00
Nikolay Rozhkov
a712e61888 Loading avatars in parallel & started sankey documentation 2023-06-29 15:24:14 +03:00
Sidharth Vinod
562910e831
Merge pull request #4532 from tomperr/fix/4519-namespace-lose-members
fix(class): keep members in namespace classes
2023-06-29 11:57:22 +05:30
Sidharth Vinod
47db1a3c9f
Cleanup 2023-06-29 10:36:21 +05:30
Alex Mooney
491f8c1259
Clean up some spacing in examples 2023-06-28 15:14:28 -07:00
Alex Mooney
83bda9febd
Correct the Gantt milestones example 2023-06-28 14:37:08 -07:00
Sidharth Vinod
6aae7450aa
Merge pull request #4557 from nienow/patch-1
Add Standard Notes extension in integrations page
2023-06-28 13:05:22 +05:30
Sidharth Vinod
c042c4a5ef
Merge pull request #4553 from tomperr/fix/4550-chaining-style
fix(flowchart): allow multiple vertices with style
2023-06-28 13:02:55 +05:30
Random Bits
777f6d9749
Add Standard Notes extension in integrations page 2023-06-27 21:28:36 -05:00