schlechtenburg/packages/docs/lib/api/@schlechtenburg/core.md

490 lines
4.7 KiB
Markdown
Raw Normal View History

2022-03-21 23:58:05 +00:00
# @schlechtenburg/core
2022-03-21 00:53:25 +00:00
2022-03-21 23:58:05 +00:00
## SbMode
2022-03-21 00:53:25 +00:00
2022-03-22 20:07:05 +00:00
The mode the Schlechtenburg editor is currently in
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Type** `Enumeration`
2022-03-21 23:58:05 +00:00
- **Members**
2022-03-22 20:07:05 +00:00
- **Edit**: `undefined`
- **View**: `undefined`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
2022-03-21 23:58:05 +00:00
## IBlockData<T>
Schlechtenburg inputs and outputs a plain JS Object that can be JSON stringified. This is the
2022-03-22 20:07:05 +00:00
interface type for that data structure. `T` will be the data type of the specific block being
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Type** `Interface`
2022-03-21 23:58:05 +00:00
- **Members**
2022-03-22 20:07:05 +00:00
- **data**: `T`
- **id**: `string`
- **name**: `string`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
2022-03-21 23:58:05 +00:00
## IBlockDefinition<T>
Any Block that you create
2022-03-22 20:16:26 +00:00
- **Type** `Interface`
2022-03-21 23:58:05 +00:00
- **Members**
2022-03-22 20:07:05 +00:00
- **edit**: `Component`
- **getDefaultData**: `T`
- **icon**: `string`
- **name**: `string`
- **view**: `Component`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
2022-03-21 23:58:05 +00:00
## IBlockLibrary
Schlechtenburg maintains a library of blocks that are available
2022-03-22 20:16:26 +00:00
- **Type** `Interface`
2022-03-21 23:58:05 +00:00
## IBlockProps<T>
Any Block that you create
2022-03-22 20:16:26 +00:00
- **Type** `Interface`
2022-03-21 23:58:05 +00:00
- **Members**
2022-03-22 20:07:05 +00:00
- **blockId**: `string`
- **data**: `T`
- **onActivateNext**: `OnActivateNextCb`
- **onActivatePrevious**: `OnActivatePreviousCb`
- **onAppendBlock**: `OnAppendBlockCb`
- **onPrependBlock**: `OnPrependBlockCb`
- **onRemoveSelf**: `OnRemoveSelfCb`
- **onUpdate**: `OnUpdateSelfCb`
2022-03-22 20:16:26 +00:00
2022-03-22 20:07:05 +00:00
## ISbMainProps
2022-03-22 20:16:26 +00:00
- **Type** `Interface`
2022-03-22 20:07:05 +00:00
- **Members**
- **availableBlocks**: `undefined`
- **block**: `IBlockData`
- **mode**: `SbMode`
- **onUpdate**: `OnUpdateBlockCb`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
2022-03-21 23:58:05 +00:00
## ITreeNode
Schlechtenburg keeps track of the rendered block tree.
This is useful for e.g. the tree select component in the editor header.
2022-03-22 20:16:26 +00:00
- **Type** `Interface`
2022-03-21 23:58:05 +00:00
- **Members**
2022-03-22 20:07:05 +00:00
- **children**: `undefined`
- **icon**: `string`
- **id**: `string`
- **name**: `string`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
2022-03-21 23:58:05 +00:00
## OnActivateNextCb
2022-03-22 20:16:26 +00:00
- **Type** `Type alias`
2022-03-21 23:58:05 +00:00
## OnActivatePreviousCb
2022-03-22 20:16:26 +00:00
- **Type** `Type alias`
2022-03-21 23:58:05 +00:00
## OnAppendBlockCb
2022-03-22 20:16:26 +00:00
- **Type** `Type alias`
2022-03-21 23:58:05 +00:00
## OnPrependBlockCb
2022-03-22 20:16:26 +00:00
- **Type** `Type alias`
2022-03-21 23:58:05 +00:00
## OnRemoveSelfCb
2022-03-22 20:16:26 +00:00
- **Type** `Type alias`
2022-03-21 23:58:05 +00:00
## OnUpdateBlockCb
2022-03-22 20:16:26 +00:00
- **Type** `Type alias`
2022-03-21 23:58:05 +00:00
## OnUpdateSelfCb<T>
2022-03-22 20:16:26 +00:00
- **Type** `Type alias`
2022-03-21 23:58:05 +00:00
## SbBlock
Displays a Schlechtenburg block either the mode of the schlechtenburg instance.
You can use this to display child blocks inside your own blocks.
2022-03-22 20:16:26 +00:00
- **Type**: `Component`
2022-03-21 23:58:05 +00:00
### Props
#### block
The state for the block.
2022-03-22 20:16:26 +00:00
- **Type** `IBlockData<any>`
2022-03-21 23:58:05 +00:00
#### onUpdate
Called when the block should be updated.
2022-03-22 20:16:26 +00:00
- **Type** `OnUpdateBlockCb`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
#### onPrependBlock
Called when a sibling block should be inserted before the block
2022-03-22 20:16:26 +00:00
- **Type** `OnPrependBlockCb`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
#### onAppendBlock
Called when a sibling block should be inserted after the block
2022-03-22 20:16:26 +00:00
- **Type** `OnAppendBlockCb`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
#### onRemoveSelf
Called when the block should be removed
2022-03-22 20:16:26 +00:00
- **Type** `OnRemoveSelfCb`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
#### onActivatePrevious
Called when the previous sibling block should be activated
2022-03-22 20:16:26 +00:00
- **Type** `OnActivatePreviousCb`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
#### onActivateNext
Called when the next sibling block should be activated
2022-03-22 20:16:26 +00:00
- **Type** `OnActivateNextCb`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
## SbBlockOrdering
2022-03-22 20:16:26 +00:00
- **Type**: `Component`
2022-03-21 23:58:05 +00:00
### Props
#### orientation
2022-03-22 20:16:26 +00:00
- **Type** `string`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `null`
2022-03-21 23:58:05 +00:00
#### onRemove
2022-03-22 20:16:26 +00:00
- **Type** `func`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
#### onMoveBackward
2022-03-22 20:16:26 +00:00
- **Type** `func`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
#### onMoveForward
2022-03-22 20:16:26 +00:00
- **Type** `func`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
## SbBlockPicker
2022-03-22 20:16:26 +00:00
- **Type**: `Component`
2022-03-21 23:58:05 +00:00
### Props
#### onPickedBlock
2022-03-22 20:16:26 +00:00
- **Type** `func`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
## SbBlockPlaceholder
A placeholder for a block.
Displays a placeholder for a block, allowing the user to select a block to insert.
2022-03-22 20:16:26 +00:00
- **Type**: `Component`
2022-03-21 23:58:05 +00:00
### Props
#### onInsertBlock
Called when the user picked a block that should be inserted here.
2022-03-22 20:16:26 +00:00
- **Type** `func`
2022-03-21 23:58:05 +00:00
2022-03-22 20:16:26 +00:00
- **Default value** `() => {}`
2022-03-21 23:58:05 +00:00
## SbButton
A button in the schlechtenburg theme
2022-03-22 20:16:26 +00:00
- **Type**: `Component`
2022-03-21 23:58:05 +00:00
### Props
## SbMain
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-21 23:58:05 +00:00
## SbSelect
A select input in the schlechtenburg theme
2022-03-22 20:16:26 +00:00
- **Type**: `Component`
2022-03-21 23:58:05 +00:00
### Props
## SbToolbar
Toolbar in the schlechtenburg theme
2022-03-22 20:16:26 +00:00
- **Type**: `Component`
2022-03-21 23:58:05 +00:00
### Props
## SymActiveBlock
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-21 23:58:05 +00:00
## SymBlockDimensions
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-21 23:58:05 +00:00
## SymBlockLibrary
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-21 23:58:05 +00:00
## SymEditorDimensions
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-22 20:07:05 +00:00
## SymMode
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-21 23:58:05 +00:00
## blockProps
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-21 23:58:05 +00:00
## model
2022-03-22 20:16:26 +00:00
- **Type** `Variable`
2022-03-21 23:58:05 +00:00
## generateBlockId
2022-03-22 20:16:26 +00:00
- **Type** `Function`
2022-03-21 23:58:05 +00:00
## useActivation
2022-03-22 20:16:26 +00:00
- **Type** `Function`
2022-03-21 23:58:05 +00:00
## useBlockSizing
2022-03-22 20:16:26 +00:00
- **Type** `Function`
2022-03-21 23:58:05 +00:00
## useDynamicBlocks
2022-03-22 20:16:26 +00:00
- **Type** `Function`
2022-03-21 23:58:05 +00:00
## useResizeObserver
2022-03-22 20:16:26 +00:00
- **Type** `Function`