docs: update API documentation for initialData and renderer props

This commit is contained in:
Abhinav Kumar
2025-07-05 13:31:00 +05:30
parent afa495caab
commit ab7f2e6999
2 changed files with 34 additions and 4 deletions

View File

@@ -5,7 +5,15 @@
| `initialData` | [`object`](/docs/api/initialData) | The initial data that Isoflow will render. If `undefined`, isoflow loads a blank scene. | `undefined` |
| `width` | `number` \| `string` | Width of the Isoflow renderer as a CSS value. | `100%` |
| `height` | `number` \| `string` | Height of the Isoflow renderer as a CSS value. | `100%` |
| `onModelUpdate` | `function` | A callback that is triggered whenever an item is added, updated or removed from the Model. The callback is called with the updated Model as the first argument. | `undefined` |
| `onModelUpdated` | `function` | A callback that is triggered whenever an item is added, updated or removed from the Model. The callback is called with the updated Model as the first argument. | `undefined` |
| `enableDebugTools` | `boolean` | Enables extra tools for debugging purposes. | `false` |
| `editorMode` | `"EXPLORABLE_READONLY"` \| `"NON_INTERACTIVE"` \| `"EDITABLE"` | Enables / disables editor features. | `"EDITABLE"` |
| `mainMenuOptions` | `("ACTION.OPEN" \| "EXPORT.JSON" \| "EXPORT.PNG" \| "ACTION.CLEAR_CANVAS" \| "LINK.GITHUB" \| "LINK.DISCORD" \| "VERSION")[]` | Shows / hides options in the main menu. If `[]` is passed, the menu is hidden. | All enabled |
| `mainMenuOptions` | `("ACTION.OPEN" \| "EXPORT.JSON" \| "EXPORT.PNG" \| "ACTION.CLEAR_CANVAS" \| "LINK.GITHUB" \| "LINK.DISCORD" \| "VERSION")[]` | Shows / hides options in the main menu. If `[]` is passed, the menu is hidden. | All enabled |
| `renderer` | [`RendererProps`](#rendererprops) | Configuration for the renderer component. | `undefined` |
## RendererProps
| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `showGrid` | `boolean` | Controls whether the grid is visible. | `undefined` |
| `backgroundColor` | `string` | Sets the background color of the renderer. | `undefined` |

View File

@@ -11,7 +11,8 @@ The `initialData` object contains the following properties:
| `colors` | [`Color[]`](#color) | `[]` |
| `items` | [`Item[]`](#item) | `[]` |
| `views` | [`View[]`](#view) | `[]` |
| `fitToScreen` | `boolean` | `false` |
| `fitToView` | `boolean` | `false` |
| `view` | `string \| undefined` | `undefined` |
## Example payload
An example payload can be found here on [CodeSandbox](https://codesandbox.io/p/sandbox/github/markmanx/isoflow/tree/main).
@@ -161,6 +162,27 @@ ref:
}
```
## `fitToView`
```js
boolean
```
**Notes on fitToView:**
- When set to `true`, the scene will automatically fit to the viewport when loaded.
- This is useful for ensuring the entire diagram is visible when the component first renders.
## `view`
```js
string | undefined
```
**Notes on view:**
- Specifies which view to display initially by providing the view's `id`.
- If `undefined`, no specific view will be selected on load.
- The view must exist in the `views` array for this to work.
## Validation
The `initialData` object is validated before Isoflow renders the scene, and an error is thrown if invalid data is detected.
@@ -168,4 +190,4 @@ Examples of common errors are as follows:
- A `ConnectorAnchor` references an `Item` that does not exist.
- An `Item` references an `Icon` that does not exist.
- A `Rectangle` has a `from` but not a `to` property.
- A `Connector` has less than 2 anchors.
- A `Connector` has less than 2 anchors.