You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+
name: Node.js CI
5
+
6
+
on:
7
+
push:
8
+
branches: [ "main" ]
9
+
pull_request:
10
+
branches: [ "main" ]
11
+
12
+
jobs:
13
+
build:
14
+
runs-on: ubuntu-latest
15
+
16
+
strategy:
17
+
matrix:
18
+
node-version: [22.x]
19
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+
name: Deploy to GitHub pages
5
+
6
+
on:
7
+
# Allows you to run this workflow manually from the Actions tab
8
+
workflow_dispatch:
9
+
10
+
jobs:
11
+
build:
12
+
runs-on: ubuntu-latest
13
+
steps:
14
+
- uses: actions/checkout@v4
15
+
- name: Setup Node.js
16
+
uses: actions/setup-node@v4
17
+
with:
18
+
node-version: 22.x
19
+
cache: 'npm'
20
+
- run: npm ci
21
+
- run: npm run typecheck
22
+
- run: npm run build
23
+
- name: Archive build artifacts
24
+
uses: actions/upload-pages-artifact@v3
25
+
with:
26
+
path: build
27
+
28
+
deploy:
29
+
# Add a dependency to the build job
30
+
needs: build
31
+
32
+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
33
+
permissions:
34
+
pages: write # to deploy to Pages
35
+
id-token: write # to verify the deployment originates from an appropriate source
36
+
37
+
# Deploy to the github-pages environment
38
+
environment:
39
+
name: github-pages
40
+
url: ${{ steps.deployment.outputs.page_url }}
41
+
42
+
# Specify runner + deployment step
43
+
runs-on: ubuntu-latest
44
+
steps:
45
+
- name: Deploy to GitHub Pages
46
+
id: deployment
47
+
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
[`<AnnotationSupport />`](/docs/api/workspace/functions/AnnotationSupport.md) component is a [canvas widget](/docs/components/canvas.md#widgets) to provide UI for the [annotation](/docs/concepts/graph-model.md#annotations) elements and links.
8
+
9
+
:::important
10
+
`<AnnotationSupport />` widget must be provided to the canvas to in order to enable annotation UI features such as creating a new annotation with [`<SelectionActionAnnotate />`](/docs/components/selection.md#selecting-elements), linking annotation to an element with [`<SelectionActionEstablishLink />`](/docs/components/selection.md#selecting-elements) or [`<LinkActionMoveEndpoint />`](/docs/components/selection.md#selecting-links).
11
+
:::
12
+
13
+
The component observes [`AnnotationTopic`](/docs/api/workspace/variables/AnnotationTopic.md)[command bus topic](/docs/concepts/event-system.md#command-bus).
@@ -23,7 +23,9 @@ The library provides the following built-in templates:
23
23
|[`StandardTemplate`](/docs/api/workspace/variables/StandardTemplate.md)| element | Default (fallback) template for an element; supports single entity elements and [entity groups](/docs/concepts/graph-model.md#data-graph).<br />Uses [`StandardEntity`](/docs/api/workspace/functions/StandardEntity.md) and [`StandardEntityGroup`](/docs/api/workspace/functions/StandardEntityGroup.md) components to render elements. |
24
24
|[`ClassicTemplate`](/docs/api/workspace/variables/ClassicTemplate.md)| element | Element template component with classic "look and feel" which was used for elements before v0.8; does not support entity groups.<br />Uses [`ClassicEntity`](/docs/api/workspace/functions/ClassicEntity.md) component to render elements. |
25
25
|[`RoundTemplate`](/docs/api/workspace/variables/RoundTemplate.md)| element | Basic element template with an round (elliptical) shape; does not support entity groups.<br />Uses [`RoundEntity`](/docs/api/workspace/functions/RoundEntity.md) component to render elements. |
26
-
|[`DefaultLinkTemplate`](/docs/api/workspace/variables/DefaultLinkTemplate.md)| link | Default (fallback) template for a link; supports single relation links and [relation groups](/docs/concepts/graph-model.md#data-graph).<br />Uses [`DefaultLink`](/docs/api/workspace/functions/DefaultLink.md) component to render links which uses [`LinkPath`](/docs/api/workspace/functions/LinkPath.md), [`LinkLabel`](/docs/api/workspace/functions/LinkLabel.md) and [`LinkVertices`](/docs/api/workspace/functions/LinkVertices.md) components inside to display the link connection itself, the labels and vertices (to change link geometry). |
26
+
|[`StandardLinkTemplate`](/docs/api/workspace/variables/StandardLinkTemplate.md)| link | Default (fallback) template for a link; supports single relation links and [relation groups](/docs/concepts/graph-model.md#data-graph).<br />Uses [`StandardRelation`](/docs/api/workspace/functions/StandardRelation.md) component to render links which uses [`LinkPath`](/docs/api/workspace/functions/LinkPath.md), [`LinkLabel`](/docs/api/workspace/functions/LinkLabel.md) and [`LinkVertices`](/docs/api/workspace/functions/LinkVertices.md) components inside to display the link connection itself, the labels and vertices (to change link geometry). |
27
+
|[`NoteTemplate`](/docs/api/workspace/variables/NoteTemplate.md)| element | Default template for [annotation elements](/docs/concepts/graph-model.md#annotations).<br />Uses [`NoteAnnotation`](/docs/api/workspace/functions/NoteAnnotation.md) component to render a user-resizable note with editable text content and style. |
28
+
|[`NoteLinkTemplate`](/docs/api/workspace/variables/NoteLinkTemplate.md)| link | Default template for [annotation links](/docs/concepts/graph-model.md#annotations).<br />Uses [`NoteLink`](/docs/api/workspace/functions/NoteLink.md) component to render a [basic link](/docs/api/workspace/functions/BasicLink.md) with an optional label if the link was [renamed](/docs/api/workspace/interfaces/RenameLinkProvider.md). |
27
29
28
30
Additionally, it is possible to override how the link are routed (how default path geometry is computed) on the canvas by providing `linkRouter` ([`LinkRouter`](/docs/api/workspace/interfaces/LinkRouter.md)) prop to the `<Canvas />`. By default, the [`DefaultLinkRouter`](/docs/api/workspace/classes/DefaultLinkRouter.md) is used which moves apart multiple links between same elements and displays self-links (where target is equal to source) as loops.
29
31
@@ -81,25 +83,63 @@ function NonWidgetComponent {
81
83
}
82
84
```
83
85
84
-
## Canvas widgets
86
+
## Widgets
85
87
86
-
Canvas widget is an instance of any React component type which is marked by [defineCanvasWidget()](/docs/api/workspace/functions/defineCanvasWidget) function with metadata such as its attachment layer i.e. where the component should be displayed in relation to other canvas content.
88
+
Canvas widget is any React component placed as a child to [`<Canvas />`](/docs/api/workspace/functions/Canvas).
87
89
88
90
There are multiple canvas layers to place widgets on, from top one to the bottom:
89
91
90
-
| Layer name |[Coordinate type](/docs/concepts/canvas-coordinates.md)| Description |
|`viewport`| client (viewport) | ❌ | ❌ | Top layer, placed over all diagram content and other layers. |
95
+
|`overElements`| scrollable pane | ❌ | ✔ | Placed over both elements and links. |
96
+
|`overLinks`| scrollable pane | ❌ | ✔ | Placed under elements but over links (including its geometry and labels). |
97
+
|`overLinkGeometry`| scrollable pane | ❌ | ✔ | Placed under link labels but over link geometry (paths). |
98
+
|`underlay`| scrollable pane | ❌ | ✔ | Bottom layer, placed under all diagram content and other layers. |
95
99
96
-
### Example: custom viewport widget
100
+
By default, every child component (widget) is placed at `viewport` layer over canvas viewport. However, [`<CanvasPlaceAt />`](/docs/api/workspace/functions/CanvasPlaceAt.md) can be used to display its children at a different layer:
101
+
102
+
```tsx
103
+
function MyWidget() {
104
+
return (
105
+
<>
106
+
<div>
107
+
{/* This will be displayer over viewport */}
108
+
</div>
109
+
<Reactodia.CanvasPlaceAtlayer='overLinkGeometry'>
110
+
{/* ... render additonal link decorations ... */}
111
+
</Reactodia.CanvasPlaceAt>
112
+
<Reactodia.CanvasPlaceAtlayer='underlay'>
113
+
{/* ... render additional background content */}
114
+
</Reactodia.CanvasPlaceAt>
115
+
</>
116
+
);
117
+
}
118
+
119
+
...
120
+
return (
121
+
<Reactodia.Workspaceref={onMount}
122
+
defaultLayout={defaultLayout}>
123
+
<Reactodia.WorkspaceRoot>
124
+
<Reactodia.Canvas>
125
+
<MyWidget />
126
+
</Reactodia.Canvas>
127
+
</Reactodia.WorkspaceRoot>
128
+
</Reactodia.Workspace>
129
+
);
130
+
```
131
+
132
+
:::warning
133
+
`<CanvasPlaceAt />` cannot be nested into itself, otherwise an error will be thrown.
### Example: placing components at [canvas coordinates](/docs/concepts/canvas-coordinates.md)
189
+
190
+
When placing a component at non-`viewport` layer, it is usually neccessary to position it based on other [diagram cells](/docs/concepts/graph-model.md). In that cases the widget needs to subscribe to canvas content and transform changes (including canvas total size, scale and origin point).
191
+
192
+
```tsx live noInline
193
+
function OverlayAndUnderlay() {
194
+
const {canvas, model} =Reactodia.useCanvas();
195
+
196
+
// Update on canvas transform changes (change scale, size or origin)
0 commit comments