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
* Add pages for keyboard hotkeys, form input components;
* Add sections for command buses, element and link template customization, element decorations, exporting the canvas content;
* Add links to command bus topics from relevant components;
* Add `style-customization` example;
* Update feature screenshots, add separate screenshots for light/dark themes;
Copy file name to clipboardExpand all lines: docs/components/canvas.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,53 @@ title: <Canvas />
6
6
7
7
[`<Canvas />`](/docs/api/workspace/functions/Canvas) is a main component to display a scrollable canvas for the diagram with [elements](/docs/concepts/graph-model.md), [links](/docs/concepts/graph-model.md) and additional widgets.
8
8
9
+
## Customizing element and link appearance {#customization}
10
+
11
+
It is possible to customize how elements (nodes) and links (edges) are rendered on the canvas by providing `elementTemplateResolver` ([`TypedElementResolver`](/docs/api/workspace/type-aliases/TypedElementResolver.md)) and/or `linkTemplateResolver` ([`LinkTemplateResolver`](/docs/api/workspace/type-aliases/LinkTemplateResolver.md)) props to the `<Canvas />`.
12
+
13
+
An element or link template is an object with rendering function (returning a React component to display it) and additional rendering settings such as element shape, link markers, etc.
14
+
15
+
An **element template** is an [`ElementTemplate`](/docs/api/workspace/interfaces/ElementTemplate.md) object with rendering function (returning a React component to display the element) and additional settings, such as element shape (rectangular or elliptical).
16
+
17
+
A **link template** is a [`LinkTemplate`](/docs/api/workspace/interfaces/LinkTemplate.md) object with rendering function (returning a React component to display the link) and additional settings, such as link markers (mini-shapes on its endpoints, e.g. arrowheads) and path spline type (straight or smooth).
18
+
19
+
The library provides the following built-in templates:
20
+
21
+
| Template | Type | Description |
22
+
|----------------------|------|-------------|
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
+
|[`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
+
|[`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). |
27
+
28
+
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
+
30
+
### Element decorations
31
+
32
+
To further customize element rendering the library provides [`<ElementDecoration />`](/docs/api/workspace/functions/ElementDecoration.md) component to display a decoration over a canvas element. These decorations are rendered outside the element template content itself and does not contribute to the measured size of an element.
33
+
34
+
All decorations for a specific entity are rendered as children of a DOM element with `reactodia-element-decorators` CSS class which immediately follows each target canvas element in the DOM. Such parent DOM elements for the decorations have `transform: translate(...)`, `width` and `height` set to the same values as the target element to be able to layout decoration content via CSS:
35
+
36
+
```css
37
+
/* Position decoration to the left of the target canvas element */
38
+
.my-custom-decoration {
39
+
position: absolute;
40
+
top: 50%;
41
+
left: -10px;
42
+
transform: translate(-100%,-50%);
43
+
}
44
+
45
+
/* Show decoration on hover over it or target canvas element */
See complete [style customization example](/docs/examples/style-customization) with custom element and link templates, element decorations and more.
54
+
:::
55
+
9
56
## Getting the canvas instance
10
57
11
58
[`useCanvas()`](/docs/api/workspace/functions/useCanvas) hook called from a canvas widget can be used to get the [`CanvasApi`](/docs/api/workspace/interfaces/CanvasApi) instance from a context to read or subscribe to the canvas state or perform viewport-related effects:
@@ -99,6 +146,34 @@ function Example() {
99
146
render(<Example />);
100
147
```
101
148
149
+
## Exporting the canvas
150
+
151
+
It is possible to export a "snapshot" of currently rendered canvas content into an SVG (with HTML parts) or a raster image:
152
+
153
+
| Canvas API method | Description |
154
+
|-------------------|-------------|
155
+
|[`exportSvg()`](/docs/api/workspace/interfaces/CanvasApi.md#exportsvg)| Exports the diagram as a serialized into text SVG document with `<foreignObject>` HTML layers inside. (Can be opened by the browser but not with a pure SVG image editor.) |
156
+
|[`exportRaster()`](/docs/api/workspace/interfaces/CanvasApi.md#exportraster)| Exports the diagram as a rendered raster image (e.g. PNG, JPEG, etc) serialized into base64-encoded [data URL](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). |
157
+
158
+
:::note
159
+
When exporting into an SVG, the resulting document would include all diagram content as well as every CSS rule which applies to any DOM element inside the diagram content.
160
+
161
+
Diagram is always exported in the [light theme](/docs/concepts/design-system.mdx).
162
+
:::
163
+
164
+
To prevent being exported a DOM element can be marked with `data-reactodia-no-export` attribute or additional CSS selectors can be provided via `removeByCssSelectors` options to the export methods.
165
+
166
+
Printing the diagram can be achieved by exporting an SVG, writing it into a newly opened window and printing it:
The library provides a built-in [`toolbar`](/docs/components/toolbar.md) action component [`<ToolbarActionExport />`](/docs/api/workspace/functions/ToolbarActionExport.md) as a convenient way to export or print the diagram from the UI.
176
+
102
177
## Styles
103
178
104
179
The component look can be customized using the following CSS properties (see [design system](/docs/concepts/design-system.mdx) for more information):
@@ -111,3 +186,5 @@ The component look can be customized using the following CSS properties (see [de
111
186
|`--reactodia-canvas-underlay-color`| Semi-transparent color to place under components for improved readability when they are placed on the canvas. |
112
187
|`--reactodia-element-background-color`| Default background color for the graph elements displayed on the canvas. |
113
188
|`--reactodia-link-stroke-color`| Default stroke color for the graph links displayed on the canvas. |
189
+
|`--reactodia-monochrome-icon-filter`|[CSS filter](https://developer.mozilla.org/en-US/docs/Web/CSS/filter) for the monochrome [type style](/docs/components/workspace.md#customize-type-styles) icons. |
190
+
|`--reactodia-viewport-dock-margin`| Margin from the borders of the canvas for the viewport widgets. |
Copy file name to clipboardExpand all lines: docs/components/connections-menu.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ title: <ConnectionsMenu />
6
6
7
7
[`<ConnectionsMenu />`](/docs/api/workspace/functions/ConnectionsMenu) component is a [canvas widget](/docs/components/canvas.md) to explore and navigate the graph by adding connected entities to the diagram.
8
8
9
+
The component observes [`ConnectionsMenuTopic`](/docs/api/workspace/variables/ConnectionsMenuTopic.md)[command bus topic](/docs/concepts/event-system.md#command-bus).
Reactodia provides basic built-in components to edit entity or relation properties in a form:
8
+
9
+
| Form input component | Description |
10
+
|----------------------|-------------|
11
+
|[`<FormInputList />`](/docs/api/workspace/variables/FormInputList.md)| Form input to edit multiple values in a list of specified single value inputs. |
12
+
|[`<FormInputText />`](/docs/api/workspace/functions/FormInputText.md)| Form input to edit a single value as a plain string with an optional language. |
13
+
14
+
:::warning
15
+
Currently form input components are considered **unstable** so there might be breaking changes in their API in the future.
16
+
:::
17
+
18
+
### Example: overriding input to a multiline text field
Copy file name to clipboardExpand all lines: docs/components/instances-search.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ title: <InstancesSearch />
10
10
The same functionality is also available as `<SearchSectionEntities />`[unified search section](/docs/components/unified-search.md).
11
11
:::
12
12
13
+
The component observes [`InstancesSearchTopic`](/docs/api/workspace/variables/InstancesSearchTopic.md)[command bus topic](/docs/concepts/event-system.md#command-bus).
Copy file name to clipboardExpand all lines: docs/components/toolbar.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,75 @@ There are several built-in toolbar actions that can be displayed as menu items o
21
21
|[`<ToolbarActionLayout />`](/docs/api/workspace/functions/ToolbarActionLayout.md)| Performs the default [graph layout algorithm](/docs/concepts/graph-layout.md) on the diagram content. |
22
22
|[`<ToolbarLanguageSelector />`](/docs/api/workspace/functions/ToolbarLanguageSelector.md)| Displays a [data language](/docs/api/workspace/classes/DiagramModel.md#language) selector for the workspace. |
Copy file name to clipboardExpand all lines: docs/components/unified-search.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ title: <UnifiedSearch />
6
6
7
7
[`<UnifiedSearch />`](/docs/api/workspace/functions/UnifiedSearch.md) is a component to display a search input with a dropdown for results.
8
8
9
+
The component observes [`UnifiedSearchTopic`](/docs/api/workspace/variables/UnifiedSearchTopic.md)[command bus topic](/docs/concepts/event-system.md#command-bus).
10
+
9
11
## Search sections
10
12
11
13
One or many available search sections (providers) can be specified:
@@ -16,6 +18,8 @@ One or many available search sections (providers) can be specified:
16
18
|[`<SearchSectionEntities />`](/docs/api/workspace/functions/SearchSectionEntities.md)| Allows to lookup entities using [data provider](/docs/concepts/data-provider.md). |
17
19
|[`<SearchSectionLinkTypes />`](/docs/api/workspace/functions/SearchSectionLinkTypes.md)| Allows to lookup displayed link types and change their [visibility settings](/docs/api/workspace/classes/DiagramModel.md#getlinkvisibility). |
18
20
21
+
`<SearchSectionEntities />` component observes [`InstancesSearchTopic`](/docs/api/workspace/variables/InstancesSearchTopic.md)[command bus topic](/docs/concepts/event-system.md#command-bus).
22
+
19
23
## Implement a custom search section
20
24
21
25
[`useUnifiedSearchSection()`](/docs/api/workspace/functions/useUnifiedSearchSection.md) hook can be used to implement a custom search section:
Copy file name to clipboardExpand all lines: docs/components/visual-authoring.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,5 @@ title: <VisualAuthoring />
9
9
:::important
10
10
`<VisualAuthoring />` widget must be provided to the canvas to in order to display visual graph authoring UI.
11
11
:::
12
+
13
+
The component observes [`VisualAuthoringTopic`](/docs/api/workspace/variables/VisualAuthoringTopic.md)[command bus topic](/docs/concepts/event-system.md#command-bus).
Copy file name to clipboardExpand all lines: docs/components/workspace.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,3 +50,27 @@ function Example() {
50
50
);
51
51
}
52
52
```
53
+
54
+
## Customize type styles
55
+
56
+
Reactodia displays [entities](/docs/concepts/graph-model.md) in different places throughout the workspace components. It is possible to customize overall style based on entity types (accent color and icon) by providing a custom [`TypeStyleResolver`](/docs/api/workspace/type-aliases/TypeStyleResolver.md) to the `<Workspace typeStyleResolver={...} />`:
57
+
58
+
```tsx
59
+
<Reactodia.Workspace
60
+
typeStyleResolver={types=> {
61
+
if (types.includes('http://www.w3.org/2000/01/rdf-schema#Class')) {
0 commit comments