Skip to content

Commit ab92213

Browse files
authored
Update docs for v0.28: (#1)
* Write a proper "concept" pages for graph model, data provider, event system, command history and workspace context; * Add "concept" pages for the design system and i18n; * Provide info on styling in the "component" doc pages; * Add example for getting a `CanvasApi` instance; * Add example for opening the `ConnectionsMenu``; * Add example for the `InstancesSearch``; * Add example for the `Navigator``; * Add example for custom search section for `UnifiedSearch`; * Separate `Rdf` playground into `RDF Explorer` and `Graph Authoring`; * Fix styles for layout panels; * Change docs status sign from alpha to beta; * Update `ExampleMetadata` for the next version; * Use "reactodia.github.io" to fetch example graph (org ontology); * Use source map loader to include resolve Reactodia source in the debugger; * Update dependency to @reactodia/[email protected].
1 parent 2769b92 commit ab92213

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3057
-320
lines changed

docs/components/canvas.md

+57-8
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,63 @@
22
title: Canvas
33
---
44

5-
# Canvas Components
5+
# Canvas and widgets
66

77
[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.
88

9-
## Hooks
9+
## Getting the canvas instance
1010

11-
[useCanvas()](/docs/api/workspace/functions/useCanvas) hook called from a canvas widget, [SharedCanvasState.findAnyCanvas()](/docs/api/workspace/classes/SharedCanvasState.md#findanycanvas) or [SharedCanvasState.findAllCanvases()](/docs/api/workspace/classes/SharedCanvasState.md#findallcanvases) methods can be used to get the [CanvasApi](/docs/api/workspace/interfaces/CanvasApi) instance to read or subscribe to the canvas state or perform viewport-related effects.
11+
[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:
12+
13+
```ts
14+
function MyWidget() {
15+
const {canvas} = Reactodia.useCanvas();
16+
// Use canvas here
17+
}
18+
```
19+
20+
Alternatively, with [SharedCanvasState.findAnyCanvas()](/docs/api/workspace/classes/SharedCanvasState.md#findanycanvas) or [SharedCanvasState.findAllCanvases()](/docs/api/workspace/classes/SharedCanvasState.md#findallcanvases) methods it is possible to get canvas instance outside the canvas component:
21+
22+
```ts
23+
function NonWidgetComponent {
24+
const {view} = React.useWorkspace();
25+
26+
const canvas = view.findAnyCanvas();
27+
if (canvas) {
28+
// Use canvas here (could be any if there are several of them)
29+
}
30+
31+
for (const canvas of view.findAllCanvases()) {
32+
// Use each canvas mounted in the workspace
33+
}
34+
}
35+
```
1236

1337
## Canvas widgets
1438

15-
To define a custom canvas widget, the target React component should be marked by [defineCanvasWidget()](/docs/api/workspace/functions/defineCanvasWidget) function to define its attachment layer.
39+
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.
40+
41+
There are multiple canvas layers to place widgets on, from top one to the bottom:
42+
43+
| Layer name | [Coordinate type](/docs/concepts/canvas-coordinates.md) | Description |
44+
|----------------|-------------------|-------------|
45+
| `viewport` | client (viewport) | Topmost layer, does not scale or scroll with the diagram. |
46+
| `overElements` | paper | Displayed over both elements and links, scales and scrolls with the diagram. |
47+
| `overLinks` | paper | Displayed under elements but over links, scales and scrolls with the diagram. |
1648

1749
### Example: custom viewport widget
1850

1951
```tsx live noInline
2052
function CustomSelectAllWidget() {
2153
const {model} = Reactodia.useWorkspace();
2254
return (
23-
<div style={{position: 'absolute', right: '10px', top: '10px'}}>
55+
<Reactodia.ViewportDock dock='ne'>
2456
<button type='button'
2557
className='reactodia-btn reactodia-btn-default'
2658
onClick={() => model.setSelection([...model.elements])}>
2759
Select All
2860
</button>
29-
</div>
61+
</Reactodia.ViewportDock>
3062
);
3163
}
3264

@@ -40,10 +72,14 @@ function Example() {
4072

4173
const {onMount} = Reactodia.useLoadedWorkspace(async ({context, signal}) => {
4274
const {model, view, performLayout} = context;
43-
const dataProvider = new Reactodia.EmptyDataProvider();
44-
await model.createNewDiagram({dataProvider, signal});
4575
model.createElement('http://example.com/entity1');
4676
model.createElement('http://example.com/entity2');
77+
model.createLinks({
78+
sourceId: 'http://example.com/entity1',
79+
targetId: 'http://example.com/entity2',
80+
linkTypeId: 'http://example.com/connectedTo',
81+
properties: {},
82+
});
4783
await performLayout({signal});
4884
}, []);
4985

@@ -62,3 +98,16 @@ function Example() {
6298

6399
render(<Example />);
64100
```
101+
102+
## Styles
103+
104+
The component look can be customized using the following CSS properties (see [design system](/docs/concepts/design-system.mdx) for more information):
105+
106+
| Property | Description |
107+
|----------|-------------|
108+
| `--reactodia-canvas-background-color` | Background color for the canvas. |
109+
| `--reactodia-canvas-box-shadow` | Box shadow for the UI components layered on top of the canvas. |
110+
| `--reactodia-canvas-overlay-color` | Semi-transparent color to place over canvas content when displaying a modal on top. |
111+
| `--reactodia-canvas-underlay-color` | Semi-transparent color to place under components for improved readability when they are placed on the canvas. |
112+
| `--reactodia-element-background-color` | Default background color for the graph elements displayed on the canvas. |
113+
| `--reactodia-link-stroke-color` | Default stroke color for the graph links displayed on the canvas. |

docs/components/class-tree.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ Element type graph is loaded from [data provider](/docs/concepts/data-provider.m
77
In [graph authoring](/docs/concepts/graph-authoring.md) mode, the class tree can be used to create entity elements that are instances of the displayed types.
88

99
:::tip
10-
1110
The same functionality is also available as `SearchSectionElementTypes` [unified search section](/docs/components/unified-search.md).
12-
1311
:::
1412

1513
```tsx live
1614
function Example() {
17-
const GRAPH_DATA =
18-
'https://raw.githubusercontent.com/reactodia/reactodia-workspace/' +
19-
'master/examples/resources/orgOntology.ttl';
15+
const GRAPH_DATA = 'https://reactodia.github.io/resources/orgOntology.ttl';
2016

2117
const {defaultLayout} = Reactodia.useWorker(Layouts);
2218

@@ -41,3 +37,14 @@ function Example() {
4137
);
4238
}
4339
```
40+
41+
## Styles
42+
43+
The component look can be customized using the following CSS properties (see [design system](/docs/concepts/design-system.mdx) for more information):
44+
45+
| Property | Description |
46+
|----------|-------------|
47+
| `--reactodia-tree-background-color-active` | Background color for a selected tree item. |
48+
| `--reactodia-tree-background-color-focus` | Background color for a hovered over tree item. |
49+
| `--reactodia-tree-border-color-active` | Border color for a selected tree item. |
50+
| `--reactodia-tree-border-color-focus` | Border color for a hovered over tree item. |

docs/components/connections-menu.md

+41
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
11
# Connections Menu
22

33
[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.
4+
5+
### Example: opening a connections menu on load
6+
7+
```tsx live
8+
function Example() {
9+
const GRAPH_DATA = 'https://reactodia.github.io/resources/orgOntology.ttl';
10+
11+
const {defaultLayout} = Reactodia.useWorker(Layouts);
12+
13+
const [connectionsMenuCommands] = React.useState(() =>
14+
new Reactodia.EventSource<ConnectionsMenuCommands>()
15+
);
16+
17+
const {onMount} = Reactodia.useLoadedWorkspace(async ({context, signal}) => {
18+
const {model, view, performLayout} = context;
19+
20+
const response = await fetch(GRAPH_DATA, {signal});
21+
const graphData = new N3.Parser().parse(await response.text());
22+
const dataProvider = new Reactodia.RdfDataProvider({acceptBlankNodes: false});
23+
dataProvider.addGraph(graphData);
24+
await model.importLayout({dataProvider, signal});
25+
26+
const target = model.createElement('http://www.w3.org/ns/org#Organization');
27+
await model.requestElementData([target.iri]);
28+
29+
connectionsMenuCommands.trigger('show', {targets: [target]});
30+
}, []);
31+
32+
return (
33+
<div className='reactodia-live-editor'>
34+
<Reactodia.Workspace ref={onMount}
35+
defaultLayout={defaultLayout}>
36+
<Reactodia.DefaultWorkspace
37+
search={null}
38+
connectionsMenuCommands={connectionsMenuCommands}
39+
/>
40+
</Reactodia.Workspace>
41+
</div>
42+
);
43+
}
44+
```

docs/components/dialog.md

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ title: Dialog
66

77
It is possible to show a dialog either attached to target [element](/docs/concepts/graph-model.md), [link](/docs/concepts/graph-model.md) or as a modal over the canvas viewport itself.
88

9+
## Showing a dialog
10+
911
The following methods and properties from [OverlayController](/docs/api/workspace/classes/OverlayController) (accessible from [workspace context](/docs/concepts/workspace-context.md)) provide means to interact with the dialogs:
1012

1113
| Method or property | Description |
@@ -53,3 +55,13 @@ function Example() {
5355
);
5456
}
5557
```
58+
59+
## Styles
60+
61+
The component look can be customized using the following CSS properties (see [design system](/docs/concepts/design-system.mdx) for more information):
62+
63+
| Property | Description |
64+
|----------|-------------|
65+
| `--reactodia-dialog-border-color` | Border color for the dialog (uses the base border color if not set). |
66+
| `--reactodia-dialog-border-radius` | Border radius for the dialog (uses the base border radius if not set). |
67+
| `--reactodia-dialog-border-width` | Border width for the dialog (uses the base border width if not set). |

docs/components/drop-on-canvas.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Drop on Canvas
22

3-
[DropOnCanvas](/docs/api/workspace/functions/DropOnCanvas) component is a [canvas widget](/docs/components/canvas.md) to allow creating entity elements on the diagram by dragging then dropping a URL (IRI) to the canvas.
3+
[DropOnCanvas](/docs/api/workspace/functions/DropOnCanvas) component is a [canvas widget](/docs/components/canvas.md) to allow creating entity elements on the diagram by dragging then dropping a [URL (IRI)](/docs/concepts/data-provider.md#iri-and-rdf) to the canvas.

docs/components/instances-search.md

+40-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,45 @@
33
[InstancesSearch](/docs/api/workspace/functions/InstancesSearch.md) is a component to search for entities by various filter criteria using [data provider lookup](/docs/concepts/data-provider.md) and add them as elements to the diagram.
44

55
:::tip
6-
76
The same functionality is also available as `SearchSectionEntities` [unified search section](/docs/components/unified-search.md).
8-
97
:::
8+
9+
```tsx live
10+
function Example() {
11+
const GRAPH_DATA = 'https://reactodia.github.io/resources/orgOntology.ttl';
12+
13+
const {defaultLayout} = Reactodia.useWorker(Layouts);
14+
15+
const [instancesSearchCommands] = React.useState(() =>
16+
new Reactodia.EventSource<InstancesSearchCommands>()
17+
);
18+
19+
const {onMount} = Reactodia.useLoadedWorkspace(async ({context, signal}) => {
20+
const {model, performLayout} = context;
21+
22+
const response = await fetch(GRAPH_DATA, {signal});
23+
const graphData = new N3.Parser().parse(await response.text());
24+
const dataProvider = new Reactodia.RdfDataProvider({acceptBlankNodes: false});
25+
dataProvider.addGraph(graphData);
26+
await model.createNewDiagram({dataProvider, signal});
27+
28+
instancesSearchCommands.trigger('setCriteria', {
29+
criteria: {
30+
refElement: 'http://www.w3.org/ns/org#Organization',
31+
refElementLink: 'http://www.w3.org/2000/01/rdf-schema#domain',
32+
}
33+
});
34+
}, []);
35+
36+
return (
37+
<div className='reactodia-live-editor'>
38+
<Reactodia.Workspace ref={onMount}
39+
defaultLayout={defaultLayout}>
40+
<Reactodia.WorkspaceRoot>
41+
<Reactodia.InstancesSearch commands={instancesSearchCommands} />
42+
</Reactodia.WorkspaceRoot>
43+
</Reactodia.Workspace>
44+
</div>
45+
);
46+
}
47+
```

docs/components/layout-panels.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Reactodia provides layout panel components to display a row or a column of resiz
1717
```tsx live
1818
function SomeLayout() {
1919
return (
20-
<div style={{height: '300px'}}>
20+
<Reactodia.WorkspaceRoot style={{height: '300px'}}>
2121
<Reactodia.WorkspaceLayoutRow>
2222
<Reactodia.WorkspaceLayoutColumn>
2323
<Reactodia.WorkspaceLayoutItem heading='First'>
@@ -39,7 +39,7 @@ function SomeLayout() {
3939
</Reactodia.WorkspaceLayoutItem>
4040
</Reactodia.WorkspaceLayoutColumn>
4141
</Reactodia.WorkspaceLayoutRow>
42-
</div>
42+
</Reactodia.WorkspaceRoot>
4343
)
4444
}
4545
```

docs/components/link-types-toolbox.md

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
[LinkTypesToolbox](/docs/api/workspace/functions/LinkTypesToolbox.md) is a component to display incoming and outgoing [link types](/docs/api/workspace/type-aliases/LinkTypeIri.md) from selected elements, toggle their visibility and initiate the [lookup](/docs/components/instances-search.md) for connected entities.
44

55
:::tip
6-
76
The same functionality is also available as `SearchSectionLinkTypes` [unified search section](/docs/components/unified-search.md).
8-
97
:::

docs/components/navigator.md

+60
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
11
# Navigator
22

33
[Navigator](/docs/api/workspace/functions/Navigator) component is a [canvas widget](/docs/components/canvas.md) to display a minimap of the diagram contents.
4+
5+
```tsx live
6+
function Example() {
7+
const GRAPH_DATA = 'https://reactodia.github.io/resources/orgOntology.ttl';
8+
9+
const {defaultLayout} = Reactodia.useWorker(Layouts);
10+
11+
const {onMount} = Reactodia.useLoadedWorkspace(async ({context, signal}) => {
12+
const {model, view, performLayout} = context;
13+
14+
const response = await fetch(GRAPH_DATA, {signal});
15+
const graphData = new N3.Parser().parse(await response.text());
16+
const dataProvider = new Reactodia.RdfDataProvider({acceptBlankNodes: false});
17+
dataProvider.addGraph(graphData);
18+
await model.importLayout({dataProvider, signal});
19+
20+
const first = model.createElement('http://www.w3.org/ns/org#Organization');
21+
const second = model.createElement('http://www.w3.org/ns/org#FormalOrganization');
22+
await Promise.all([
23+
model.requestElementData([first.iri, second.iri]),
24+
model.requestLinks(),
25+
]);
26+
await performLayout({signal});
27+
}, []);
28+
29+
return (
30+
<div className='reactodia-live-editor'>
31+
<Reactodia.Workspace ref={onMount}
32+
defaultLayout={defaultLayout}>
33+
<Reactodia.DefaultWorkspace
34+
menu={null}
35+
search={null}
36+
actions={null}
37+
navigator={{
38+
expanded: true,
39+
viewportFill: 'lightgreen',
40+
viewportStroke: {color: 'green'},
41+
}}
42+
/>
43+
</Reactodia.Workspace>
44+
</div>
45+
);
46+
}
47+
```
48+
49+
## Styles
50+
51+
The component look can be customized using the following CSS properties (see [design system](/docs/concepts/design-system.mdx) for more information):
52+
53+
| Property | Description |
54+
|----------|-------------|
55+
| `--reactodia-navigator-background-fill` | Background color on the minimap outside the scrollable pane area. |
56+
| `--reactodia-navigator-scrollable-pane-fill` | Background color on the minimap for the scrollable pane area. |
57+
| `--reactodia-navigator-viewport-fill` | Background color on the minimap for the viewport area. |
58+
| `--reactodia-navigator-viewport-stroke-color` | Stroke color for the viewport area border. |
59+
| `--reactodia-navigator-viewport-stroke-width` | Stroke width for the viewport area border. |
60+
| `--reactodia-navigator-viewport-stroke-dash` | Stroke dash for the viewport area border. |
61+
| `--reactodia-navigator-overflow-stroke-color` | Stroke color for the viewport area overflow border (displayed when the viewport is cutoff at the minimap border). |
62+
| `--reactodia-navigator-overflow-stroke-width` | Stroke width for the viewport area overflow border (displayed when the viewport is cutoff at the minimap border). |
63+
| `--reactodia-navigator-overflow-stroke-dash` | Stroke dash for the viewport area overflow border (displayed when the viewport is cutoff at the minimap border). |

docs/components/selection.md

+10
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,13 @@ There are several built-in link actions that can be used:
3636
| [LinkActionDelete](/docs/api/workspace/functions/LinkActionDelete.md) | Deletes [the relation](/docs/concepts/graph-authoring.md). |
3737
| [LinkActionMoveEndpoint](/docs/api/workspace/functions/LinkActionMoveEndpoint.md) | Displays a handle which allows to [change the relation](/docs/concepts/graph-authoring.md) by moving its endpoint (source or target) to another entity. |
3838
| [LinkActionRename](/docs/api/workspace/functions/LinkActionRename.md) | Starts [renaming a link](/docs/api/workspace/interfaces/RenameLinkProvider.md) (change the label on the diagram only). |
39+
40+
## Styles
41+
42+
The component look can be customized using the following CSS properties (see [design system](/docs/concepts/design-system.mdx) for more information):
43+
44+
| Property | Description |
45+
|----------|-------------|
46+
| `--reactodia-selection-icon-filter` | [CSS filter](https://developer.mozilla.org/en-US/docs/Web/CSS/filter) for the element selection action icons. |
47+
| `--reactodia-selection-multiple-box-shadow` | Box shadow for the selection rectangle with multiple elements. |
48+
| `--reactodia-selection-single-box-shadow` | Box shadow for the selection rectangle with a single element. |

docs/components/toolbar.md

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[Toolbar](/docs/api/workspace/functions/Toolbar) component is a [canvas widget](/docs/components/canvas.md) to display a simple toolbar with a an optional dropdown menu.
44

5+
## Toolbar actions
6+
57
There are several built-in toolbar actions that can be displayed as menu items or quick action buttons:
68
| Action component | Description |
79
|------------------|-------------|
@@ -14,3 +16,11 @@ There are several built-in toolbar actions that can be displayed as menu items o
1416
| [ToolbarActionRedo](/docs/api/workspace/functions/ToolbarActionRedo.md) | Performs a [redo](/docs/api/workspace/interfaces/CommandHistory.md#redo) for a command from the [command history](/docs/concepts/command-history.md). |
1517
| [ToolbarActionLayout](/docs/api/workspace/functions/ToolbarActionLayout.md) | Performs the default [graph layout algorithm](/docs/concepts/layout-workers.md) on the diagram content. |
1618
| [ToolbarLanguageSelector](/docs/api/workspace/functions/ToolbarLanguageSelector.md) | Displays a [data language](/docs/api/workspace/classes/DiagramModel.md#language) selector for the workspace. |
19+
20+
## Styles
21+
22+
The component look can be customized using the following CSS properties (see [design system](/docs/concepts/design-system.mdx) for more information):
23+
24+
| Property | Description |
25+
|----------|-------------|
26+
| `--reactodia-toolbar-height` | Default height for the toolbar and the menu toggle. |

0 commit comments

Comments
 (0)