Better link handling

This commit is contained in:
Benjamin Bädorf 2022-03-22 21:16:26 +01:00
parent 44c32f89ee
commit fb9baa1d88
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
10 changed files with 119 additions and 389 deletions

View file

@ -5,11 +5,7 @@ const generateComponentDoc = (docs) => `
${docs.description || ''} ${docs.description || ''}
- **Type** - **Type**: \`Component\`
\`\`\`
Component
\`\`\`
### Props ### Props
@ -19,35 +15,30 @@ ${(docs.props || []).map(prop => `
${prop.description || ''} ${prop.description || ''}
${prop.type ? ` ${prop.type ? `
- **Type** - **Type** \`${prop.type.name}\`
\`\`\`
${prop.type.name}
\`\`\`
` : ''} ` : ''}
${prop.defaultValue ? ` ${prop.defaultValue ? `
- **Default value** - **Default value** \`${prop.defaultValue.value}\`
\`\`\`
${prop.defaultValue.value}
\`\`\`
` : ''} ` : ''}
`).join('\n')} `).join('\n')}
`; `;
const generateMembersDocs = (children) => children ? `
- **Members**
${(children)
.map((child) => ` - **${child.name}**: \`${child.type?.name}\``)
.join('\n')}
` : '';
const generateTSDocs = (docs) => ` const generateTSDocs = (docs) => `
## ${docs.name}${docs.typeParameters ? getTypeParamString(docs.typeParameters) : ''} ## ${docs.name}${docs.typeParameters ? getTypeParamString(docs.typeParameters) : ''}
${docs.comment?.shortText || ''} ${docs.comment?.shortText || ''}
- **Type** - **Type** \`${docs.kindString}\`
\`\`\`
${docs.kindString}
\`\`\`
- **Members** ${generateMembersDocs(docs.children)}
${(docs.children || [])
.map((child) => ` - **${child.name}**: \`${child.type?.name}\``)
.join('\n')}
`; `;
const generateChildren = ( const generateChildren = (

View file

@ -18,7 +18,7 @@ export default defineConfig({
{ {
text: 'Guide', text: 'Guide',
activeMatch: '^/guide/', activeMatch: '^/guide/',
link: '/guide/introduction' link: '/guide/why'
}, },
{ {
text: 'API', text: 'API',
@ -35,22 +35,18 @@ export default defineConfig({
text: 'Getting Started', text: 'Getting Started',
children: [ children: [
{ text: 'Why Schlechtenburg?', link: '/guide/why' }, { text: 'Why Schlechtenburg?', link: '/guide/why' },
{ text: 'Examples', link: '/guide/examples' },
{ text: 'Installation', link: '/guide/installation' }, { text: 'Installation', link: '/guide/installation' },
{ text: 'Examples', link: '/guide/examples' },
], ],
} }
], ],
'/api/': [ '/api/': [
{ {
text: 'API', text: 'API',
children: [ children: DOCS_PACKAGES.map((name) => ({
{ text: '@schlechtenburg/standalone', link: '/api/@schlechtenburg/standalone' }, text: `@schlechtenburg/${name}`,
{ text: '@schlechtenburg/core', link: '/api/@schlechtenburg/core' }, link: `/api/@schlechtenburg/${name}`,
{ text: '@schlechtenburg/layout', link: '/api/@schlechtenburg/layout' }, })),
{ text: '@schlechtenburg/heading', link: '/api/@schlechtenburg/heading' },
{ text: '@schlechtenburg/paragraph', link: '/api/@schlechtenburg/paragraph' },
{ text: '@schlechtenburg/image', link: '/api/@schlechtenburg/image' },
],
} }
], ],
'/': false, '/': false,

View file

@ -4,38 +4,34 @@
The mode the Schlechtenburg editor is currently in The mode the Schlechtenburg editor is currently in
- **Type** - **Type** `Enumeration`
```
Enumeration
```
- **Members** - **Members**
- **Edit**: `undefined` - **Edit**: `undefined`
- **View**: `undefined` - **View**: `undefined`
## IBlockData<T> ## IBlockData<T>
Schlechtenburg inputs and outputs a plain JS Object that can be JSON stringified. This is the Schlechtenburg inputs and outputs a plain JS Object that can be JSON stringified. This is the
interface type for that data structure. `T` will be the data type of the specific block being interface type for that data structure. `T` will be the data type of the specific block being
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **data**: `T` - **data**: `T`
- **id**: `string` - **id**: `string`
- **name**: `string` - **name**: `string`
## IBlockDefinition<T> ## IBlockDefinition<T>
Any Block that you create Any Block that you create
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **edit**: `Component` - **edit**: `Component`
@ -44,26 +40,21 @@ Any Block that you create
- **name**: `string` - **name**: `string`
- **view**: `Component` - **view**: `Component`
## IBlockLibrary ## IBlockLibrary
Schlechtenburg maintains a library of blocks that are available Schlechtenburg maintains a library of blocks that are available
- **Type** - **Type** `Interface`
```
Interface
```
- **Members**
## IBlockProps<T> ## IBlockProps<T>
Any Block that you create Any Block that you create
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **blockId**: `string` - **blockId**: `string`
@ -75,14 +66,13 @@ Any Block that you create
- **onRemoveSelf**: `OnRemoveSelfCb` - **onRemoveSelf**: `OnRemoveSelfCb`
- **onUpdate**: `OnUpdateSelfCb` - **onUpdate**: `OnUpdateSelfCb`
## ISbMainProps ## ISbMainProps
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **availableBlocks**: `undefined` - **availableBlocks**: `undefined`
@ -90,15 +80,14 @@ Any Block that you create
- **mode**: `SbMode` - **mode**: `SbMode`
- **onUpdate**: `OnUpdateBlockCb` - **onUpdate**: `OnUpdateBlockCb`
## ITreeNode ## ITreeNode
Schlechtenburg keeps track of the rendered block tree. Schlechtenburg keeps track of the rendered block tree.
This is useful for e.g. the tree select component in the editor header. This is useful for e.g. the tree select component in the editor header.
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **children**: `undefined` - **children**: `undefined`
@ -106,88 +95,61 @@ This is useful for e.g. the tree select component in the editor header.
- **id**: `string` - **id**: `string`
- **name**: `string` - **name**: `string`
## OnActivateNextCb ## OnActivateNextCb
- **Type** - **Type** `Type alias`
```
Type alias
```
- **Members**
## OnActivatePreviousCb ## OnActivatePreviousCb
- **Type** - **Type** `Type alias`
```
Type alias
```
- **Members**
## OnAppendBlockCb ## OnAppendBlockCb
- **Type** - **Type** `Type alias`
```
Type alias
```
- **Members**
## OnPrependBlockCb ## OnPrependBlockCb
- **Type** - **Type** `Type alias`
```
Type alias
```
- **Members**
## OnRemoveSelfCb ## OnRemoveSelfCb
- **Type** - **Type** `Type alias`
```
Type alias
```
- **Members**
## OnUpdateBlockCb ## OnUpdateBlockCb
- **Type** - **Type** `Type alias`
```
Type alias
```
- **Members**
## OnUpdateSelfCb<T> ## OnUpdateSelfCb<T>
- **Type** - **Type** `Type alias`
```
Type alias
```
- **Members**
## SbBlock ## SbBlock
@ -195,11 +157,7 @@ This is useful for e.g. the tree select component in the editor header.
Displays a Schlechtenburg block either the mode of the schlechtenburg instance. Displays a Schlechtenburg block either the mode of the schlechtenburg instance.
You can use this to display child blocks inside your own blocks. You can use this to display child blocks inside your own blocks.
- **Type** - **Type**: `Component`
```
Component
```
### Props ### Props
@ -209,10 +167,7 @@ You can use this to display child blocks inside your own blocks.
The state for the block. The state for the block.
- **Type** - **Type** `IBlockData<any>`
```
IBlockData<any>
```
@ -223,16 +178,10 @@ The state for the block.
Called when the block should be updated. Called when the block should be updated.
- **Type** - **Type** `OnUpdateBlockCb`
```
OnUpdateBlockCb
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -242,16 +191,10 @@ Called when the block should be updated.
Called when a sibling block should be inserted before the block Called when a sibling block should be inserted before the block
- **Type** - **Type** `OnPrependBlockCb`
```
OnPrependBlockCb
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -261,16 +204,10 @@ Called when a sibling block should be inserted before the block
Called when a sibling block should be inserted after the block Called when a sibling block should be inserted after the block
- **Type** - **Type** `OnAppendBlockCb`
```
OnAppendBlockCb
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -280,16 +217,10 @@ Called when a sibling block should be inserted after the block
Called when the block should be removed Called when the block should be removed
- **Type** - **Type** `OnRemoveSelfCb`
```
OnRemoveSelfCb
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -299,16 +230,10 @@ Called when the block should be removed
Called when the previous sibling block should be activated Called when the previous sibling block should be activated
- **Type** - **Type** `OnActivatePreviousCb`
```
OnActivatePreviousCb
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -318,16 +243,10 @@ Called when the previous sibling block should be activated
Called when the next sibling block should be activated Called when the next sibling block should be activated
- **Type** - **Type** `OnActivateNextCb`
```
OnActivateNextCb
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -336,11 +255,7 @@ Called when the next sibling block should be activated
- **Type** - **Type**: `Component`
```
Component
```
### Props ### Props
@ -350,16 +265,10 @@ Called when the next sibling block should be activated
- **Type** - **Type** `string`
```
string
```
- **Default value** - **Default value** `null`
```
null
```
@ -369,16 +278,10 @@ Called when the next sibling block should be activated
- **Type** - **Type** `func`
```
func
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -388,16 +291,10 @@ Called when the next sibling block should be activated
- **Type** - **Type** `func`
```
func
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -407,16 +304,10 @@ Called when the next sibling block should be activated
- **Type** - **Type** `func`
```
func
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -425,11 +316,7 @@ Called when the next sibling block should be activated
- **Type** - **Type**: `Component`
```
Component
```
### Props ### Props
@ -439,16 +326,10 @@ Called when the next sibling block should be activated
- **Type** - **Type** `func`
```
func
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -458,11 +339,7 @@ Called when the next sibling block should be activated
A placeholder for a block. A placeholder for a block.
Displays a placeholder for a block, allowing the user to select a block to insert. Displays a placeholder for a block, allowing the user to select a block to insert.
- **Type** - **Type**: `Component`
```
Component
```
### Props ### Props
@ -472,16 +349,10 @@ Displays a placeholder for a block, allowing the user to select a block to inser
Called when the user picked a block that should be inserted here. Called when the user picked a block that should be inserted here.
- **Type** - **Type** `func`
```
func
```
- **Default value** - **Default value** `() => {}`
```
() => {}
```
@ -490,11 +361,7 @@ Called when the user picked a block that should be inserted here.
A button in the schlechtenburg theme A button in the schlechtenburg theme
- **Type** - **Type**: `Component`
```
Component
```
### Props ### Props
@ -504,23 +371,15 @@ A button in the schlechtenburg theme
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## SbSelect ## SbSelect
A select input in the schlechtenburg theme A select input in the schlechtenburg theme
- **Type** - **Type**: `Component`
```
Component
```
### Props ### Props
@ -530,11 +389,7 @@ A select input in the schlechtenburg theme
Toolbar in the schlechtenburg theme Toolbar in the schlechtenburg theme
- **Type** - **Type**: `Component`
```
Component
```
### Props ### Props
@ -544,141 +399,92 @@ Toolbar in the schlechtenburg theme
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## SymBlockDimensions ## SymBlockDimensions
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## SymBlockLibrary ## SymBlockLibrary
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## SymEditorDimensions ## SymEditorDimensions
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## SymMode ## SymMode
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## blockProps ## blockProps
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## model ## model
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## generateBlockId ## generateBlockId
- **Type** - **Type** `Function`
```
Function
```
- **Members**
## useActivation ## useActivation
- **Type** - **Type** `Function`
```
Function
```
- **Members**
## useBlockSizing ## useBlockSizing
- **Type** - **Type** `Function`
```
Function
```
- **Members**
## useDynamicBlocks ## useDynamicBlocks
- **Type** - **Type** `Function`
```
Function
```
- **Members**
## useResizeObserver ## useResizeObserver
- **Type** - **Type** `Function`
```
Function
```
- **Members**

View file

@ -4,47 +4,33 @@
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **align**: `string` - **align**: `string`
- **level**: `number` - **level**: `number`
- **value**: `string` - **value**: `string`
## default ## default
- **Type** - **Type** `Property`
```
Property
```
- **Members**
## name ## name
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## getDefaultData ## getDefaultData
- **Type** - **Type** `Function`
```
Function
```
- **Members**

View file

@ -4,47 +4,33 @@
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **alt**: `string` - **alt**: `string`
- **description**: `IBlockData` - **description**: `IBlockData`
- **src**: `string` - **src**: `string`
## default ## default
- **Type** - **Type** `Property`
```
Property
```
- **Members**
## name ## name
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## getDefaultData ## getDefaultData
- **Type** - **Type** `Function`
```
Function
```
- **Members**

View file

@ -4,46 +4,32 @@
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **children**: `undefined` - **children**: `undefined`
- **orientation**: `string` - **orientation**: `string`
## default ## default
- **Type** - **Type** `Property`
```
Property
```
- **Members**
## name ## name
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## getDefaultData ## getDefaultData
- **Type** - **Type** `Function`
```
Function
```
- **Members**

View file

@ -4,46 +4,32 @@
- **Type** - **Type** `Interface`
```
Interface
```
- **Members** - **Members**
- **align**: `string` - **align**: `string`
- **value**: `string` - **value**: `string`
## default ## default
- **Type** - **Type** `Property`
```
Property
```
- **Members**
## name ## name
- **Type** - **Type** `Variable`
```
Variable
```
- **Members**
## getDefaultData ## getDefaultData
- **Type** - **Type** `Function`
```
Function
```
- **Members**

View file

@ -4,9 +4,4 @@
- **Type** - **Type** `Function`
```
Function
```
- **Members**

View file

@ -1,3 +0,0 @@
# Introduction

View file

@ -1,5 +1,6 @@
<script setup> <script setup>
import ExampleEditor from './ExampleEditor' import { withBase } from 'vitepress';
import ExampleEditor from './ExampleEditor';
</script> </script>
# Yet another WYSIWYG editor # Yet another WYSIWYG editor
@ -11,9 +12,9 @@ It inputs and outputs a tree of JSON-serializable data.
This is still in the Proof-of-concept phase. This is still in the Proof-of-concept phase.
<div class="cta-row"> <div class="cta-row">
<a href="/schlechtenburg/guide/why" class="button button_cta">Why Schlechtenburg?</a> <a :href="withBase('/guide/why')" class="button button_cta">Why Schlechtenburg?</a>
<a href="/schlechtenburg/guide/introduction" class="button">Get Started</a> <a :href="withBase('guide/introduction')" class="button">Get Started</a>
<a href="/schlechtenburg/api" class="button">See the API docs</a> <a :href="withBase('api')" class="button">See the API docs</a>
</div> </div>
<ExampleEditor></ExampleEditor> <ExampleEditor></ExampleEditor>