diff --git a/packages/docusaurus-plugin/src/theme/SoliveCodeBlock/index.tsx b/packages/docusaurus-plugin/src/theme/SoliveCodeBlock/index.tsx index b18e5ab..b2ad6a8 100644 --- a/packages/docusaurus-plugin/src/theme/SoliveCodeBlock/index.tsx +++ b/packages/docusaurus-plugin/src/theme/SoliveCodeBlock/index.tsx @@ -11,6 +11,10 @@ import resolveMeta from '../utils/resolve-meta'; import transformModel from '../utils/transform-model'; const PropsInfo = { + simple: { + type: 'boolean', + default: false, + }, width: { type: 'string', default: '90%', @@ -47,30 +51,50 @@ const PropsInfo = { function SoliveCodeBlock(props: SoliveCodeBlockProps) { const { metastring, children } = props; - const allProps = matchProps(metastring?.split('solive')[1] || '', PropsInfo); + const allProps = useMemo(() => matchProps(metastring?.split('solive')[1] || '', PropsInfo), [metastring]); const id = useMemo(() => uuidv4(), []); const modelInfos = useMemo(() => transformModel(resolveMeta(children)), [children]); + const state = useMemo(() => { + if (allProps.simple) { + return { + height: allProps.height, + id, + modelInfos, + fileNav: { open: false }, + console: { open: false }, + deploy: { open: false }, + disableValidation: true, + }; + } + + return { + fileNav: { + open: allProps.fileNavOpen, + }, + console: { + defaultVisible: allProps.consoleDefaultVisible, + open: allProps.consoleOpen, + triggerControl: allProps.consoleTriggerControl, + }, + deploy: { + defaultVisible: allProps.deployDefaultVisible, + open: allProps.deployOpen, + }, + height: allProps.height, + id, + modelInfos, + }; + }, [ + allProps, + id, + modelInfos, + ]); + return (
- +
); }