Skip to content

Commit

Permalink
Merge pull request #5923 from mermaid-js/sidv/refactorShapes
Browse files Browse the repository at this point in the history
Refactor shapes definition
  • Loading branch information
sidharthv96 authored Oct 9, 2024
2 parents c38d9a6 + 29b9d30 commit 463ba6e
Show file tree
Hide file tree
Showing 39 changed files with 545 additions and 352 deletions.
15 changes: 10 additions & 5 deletions docs/adding-new-shape.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ To add a new shape:
- **Example**:

```typescript
import { Node, RenderOptions } from '../../types.d.ts';
import { Node, RenderOptions } from '../../types.ts';

export const myNewShape = async (
parent: SVGAElement,
Expand All @@ -117,7 +117,7 @@ To add a new shape:

### 2. Register the Shape

- **Register the shape**: Add your shape to the `shapes` object in the main shapes module. This allows your shape to be recognized and used within the system.
- **Register the shape**: Add your shape to the `shapes` object in the [main shapes module](../rendering-util/rendering-elements/shapes.ts). This allows your shape to be recognized and used within the system.

- **Example**:

Expand All @@ -126,9 +126,14 @@ To add a new shape:
const shapes = {
...,
'my-new-shape': myNewShape,
// Shortened alias (if any).
'm-nsh': myNewShape
{
semanticName: 'My Shape',
name: 'Shape Name',
shortName: '<short-name>',
description: '<Description for the shape>',
aliases: ['<alias-one>', '<al-on>', '<alias-two>', '<al-two>'],
handler: myNewShape,
},
};
```

Expand Down
15 changes: 10 additions & 5 deletions packages/mermaid/src/docs/adding-new-shape.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ To add a new shape:
- **Example**:

```typescript
import { Node, RenderOptions } from '../../types.d.ts';
import { Node, RenderOptions } from '../../types.ts';

export const myNewShape = async (
parent: SVGAElement,
Expand All @@ -111,7 +111,7 @@ To add a new shape:

### 2. Register the Shape

- **Register the shape**: Add your shape to the `shapes` object in the main shapes module. This allows your shape to be recognized and used within the system.
- **Register the shape**: Add your shape to the `shapes` object in the [main shapes module](../rendering-util/rendering-elements/shapes.ts). This allows your shape to be recognized and used within the system.

- **Example**:

Expand All @@ -120,9 +120,14 @@ To add a new shape:
const shapes = {
...,
'my-new-shape': myNewShape,
// Shortened alias (if any).
'm-nsh': myNewShape
{
semanticName: 'My Shape',
name: 'Shape Name',
shortName: '<short-name>',
description: '<Description for the shape>',
aliases: ['<alias-one>', '<al-on>', '<alias-two>', '<al-two>'],
handler: myNewShape,
},
};
```

Expand Down
Loading

0 comments on commit 463ba6e

Please sign in to comment.