Initial api docs in vitepress
This commit is contained in:
parent
4f870c63a6
commit
fdb8ffcf2d
|
@ -15,7 +15,12 @@ export default defineConfig({
|
|||
text: 'API',
|
||||
activeMatch: `^/api/`,
|
||||
items: [
|
||||
{ text: '@schlechtenburg/standalone', link: '/api/@schlechtenburg/standalone' },
|
||||
{ text: '@schlechtenburg/core', link: '/api/@schlechtenburg/core' },
|
||||
{ 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' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
@ -34,7 +39,12 @@ export default defineConfig({
|
|||
{
|
||||
text: 'API',
|
||||
children: [
|
||||
{ text: 'Core', link: '/api/core' },
|
||||
{ text: '@schlechtenburg/standalone', link: '/api/@schlechtenburg/standalone' },
|
||||
{ text: '@schlechtenburg/core', link: '/api/@schlechtenburg/core' },
|
||||
{ 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' },
|
||||
],
|
||||
}
|
||||
],
|
||||
|
|
6
packages/docs/lib/api/@schlechtenburg/core.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/core.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
<script setup>
|
||||
import Package from '../Package'
|
||||
</script>
|
||||
|
||||
<Package name="@schlechtenburg/core" />
|
||||
|
6
packages/docs/lib/api/@schlechtenburg/heading.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/heading.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
<script setup>
|
||||
import Package from '../Package'
|
||||
</script>
|
||||
|
||||
<Package name="@schlechtenburg/heading" />
|
||||
|
6
packages/docs/lib/api/@schlechtenburg/image.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/image.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
<script setup>
|
||||
import Package from '../Package'
|
||||
</script>
|
||||
|
||||
<Package name="@schlechtenburg/image" />
|
||||
|
6
packages/docs/lib/api/@schlechtenburg/layout.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/layout.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
<script setup>
|
||||
import Package from '../Package'
|
||||
</script>
|
||||
|
||||
<Package name="@schlechtenburg/layout" />
|
||||
|
6
packages/docs/lib/api/@schlechtenburg/paragraph.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/paragraph.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
<script setup>
|
||||
import Package from '../Package'
|
||||
</script>
|
||||
|
||||
<Package name="@schlechtenburg/paragraph" />
|
||||
|
6
packages/docs/lib/api/@schlechtenburg/standalone.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/standalone.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
<script setup>
|
||||
import Package from '../Package'
|
||||
</script>
|
||||
|
||||
<Package name="@schlechtenburg/standalone" />
|
||||
|
|
@ -1,21 +1,28 @@
|
|||
import { defineComponent } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { ComponentDoc } from 'vue-docgen-api';
|
||||
import { DeclarationReflection } from 'typedoc';
|
||||
|
||||
import { getByName } from '../docs';
|
||||
import ComponentDocs from '../ComponentDocs';
|
||||
import TsDocs from '../TsDocs';
|
||||
import { getShortPackageName } from './package';
|
||||
import ComponentDocs from './ComponentDocs';
|
||||
import TSDocs from './TSDocs';
|
||||
|
||||
import './Package.scss';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Package',
|
||||
|
||||
setup() {
|
||||
const route = useRoute();
|
||||
const packageName = route.params.package;
|
||||
const docs = getByName(Array.isArray(packageName) ? packageName[0] : packageName);
|
||||
props: {
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
const packageName = props.name;
|
||||
const docs = getByName(getShortPackageName(Array.isArray(packageName) ? packageName[0] : packageName));
|
||||
if (!docs) {
|
||||
return () => <div>Unknown package name {packageName}</div>;
|
||||
}
|
||||
|
@ -31,7 +38,7 @@ export default defineComponent({
|
|||
return <ComponentDocs docs={componentDocs}></ComponentDocs>
|
||||
}
|
||||
|
||||
return <TsDocs docs={child}></TsDocs>
|
||||
return <TSDocs docs={child}></TSDocs>
|
||||
})}
|
||||
</main>;
|
||||
},
|
|
@ -7,12 +7,12 @@ import {
|
|||
TypeParameterReflection,
|
||||
} from 'typedoc';
|
||||
|
||||
import './TsDocs.scss';
|
||||
import './TSDocs.scss';
|
||||
|
||||
const getTypeParamString = (params: TypeParameterReflection[]) => `<${params.map(p => p.name).join(', ')}>`;
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TsDocs',
|
||||
name: 'TSDocs',
|
||||
|
||||
props: {
|
||||
docs: {
|
|
@ -5,14 +5,14 @@ import ExampleStandaloneEditor from '../ExampleStandaloneEditor'
|
|||
|
||||
# Examples
|
||||
|
||||
## Vue Component without wrapper
|
||||
## As a View Component
|
||||
|
||||
This documentation website already uses Vue under the hood, so Schlechtenburg can just imported as
|
||||
any other component:
|
||||
|
||||
<ExampleEditor></ExampleEditor>
|
||||
|
||||
## Wrapped with Vue
|
||||
## Standalone
|
||||
|
||||
`@schlechtenburg/standalone` gives you a wrapped version of the editor in case you don't have Vue
|
||||
already installed in your application
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
import { defineComponent } from 'vue';
|
||||
|
||||
import './Introduction.scss';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Introduction',
|
||||
|
||||
setup() {
|
||||
return () => <div class="introduction">Introduction</div>;
|
||||
},
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
export default [
|
||||
{
|
||||
name: 'home',
|
||||
path: '/',
|
||||
component: () => import('./pages/Introduction'),
|
||||
},
|
||||
{
|
||||
name: 'package',
|
||||
path: '/@schlechtenburg/:package',
|
||||
component: () => import('./pages/Package'),
|
||||
},
|
||||
]
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
defineComponent,
|
||||
ref,
|
||||
Ref,
|
||||
PropType,
|
||||
} from 'vue'
|
||||
import {
|
||||
|
@ -9,17 +10,17 @@ import {
|
|||
SbMain,
|
||||
SbMode,
|
||||
OnUpdateBlockCb,
|
||||
ISbMainProps,
|
||||
} from '@schlechtenburg/core';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export default function getWrapper({
|
||||
block,
|
||||
mode,
|
||||
availableBlocks,
|
||||
}) {
|
||||
return defineComponent({
|
||||
export default function getWrapper() {
|
||||
const refBlock: Ref<IBlockData<any>|null> = ref(null);
|
||||
const refMode = ref(SbMode.View);
|
||||
|
||||
const SchlechtenburgWrapper = defineComponent({
|
||||
name: 'SchlechtenburgWrapper',
|
||||
|
||||
props: {
|
||||
|
@ -47,15 +48,39 @@ export default function getWrapper({
|
|||
},
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
const refBlock = ref({ ...block });
|
||||
const refMode = ref({ ...block });
|
||||
setup(props: ISbMainProps) {
|
||||
refBlock.value = { ...(props.block) };
|
||||
refMode.value = props.mode;
|
||||
|
||||
if (!refBlock.value) {
|
||||
return () => <div class="sb-message sb-message_error">An Error occurred</div>;
|
||||
}
|
||||
|
||||
return () => <SbMain
|
||||
block={refBlock}
|
||||
block={refBlock.value as IBlockData<any>}
|
||||
availableBlocks={props.availableBlocks}
|
||||
mode={mode}
|
||||
mode={refMode.value}
|
||||
onUpdate={(newBlock: IBlockData<any>) => {
|
||||
refBlock.value = { ...newBlock };
|
||||
|
||||
}}
|
||||
/>
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
SchlechtenburgWrapper,
|
||||
getBlock() {
|
||||
return refBlock.value;
|
||||
},
|
||||
setBlock(block: IBlockData<any>) {
|
||||
refBlock.value = { ...block };
|
||||
},
|
||||
getMode() {
|
||||
return refMode.value;
|
||||
},
|
||||
setMode(mode: SbMode) {
|
||||
refMode.value = mode;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
import {
|
||||
createApp,
|
||||
} from 'vue'
|
||||
import {
|
||||
ISbMainProps,
|
||||
IBlockData,
|
||||
SbMain,
|
||||
} from '@schlechtenburg/core';
|
||||
import { createApp } from 'vue'
|
||||
import { ISbMainProps } from '@schlechtenburg/core';
|
||||
import getWrapper from './get-wrapper';
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -21,19 +16,25 @@ export const startSchlechtenburg = async (
|
|||
*/
|
||||
props:ISbMainProps,
|
||||
) => {
|
||||
let block = { ...props.block };
|
||||
const app = createApp(SbMain, {
|
||||
...props,
|
||||
onUpdate: (update: IBlockData<any>) => {
|
||||
block = update;
|
||||
props.onUpdate(update);
|
||||
},
|
||||
}as unknown as Record<string, unknown>);
|
||||
const {
|
||||
SchlechtenburgWrapper,
|
||||
getBlock,
|
||||
setBlock,
|
||||
getMode,
|
||||
setMode,
|
||||
} = getWrapper();
|
||||
|
||||
const app = createApp(
|
||||
SchlechtenburgWrapper,
|
||||
{ ...props, } as unknown as Record<string, unknown>,
|
||||
);
|
||||
app.mount(el);
|
||||
|
||||
return {
|
||||
getBlock() {
|
||||
return block;
|
||||
},
|
||||
app,
|
||||
getBlock,
|
||||
setBlock,
|
||||
getMode,
|
||||
setMode,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue