2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-08 17:22:26 +03:00

feat: react, vue3 and vanilla examples (#242)

* feat: react, vue3 and vanilla examples

* fix: vue3 example

* Create rare-worms-tease.md

* fix: vue3 types

* fix: vue3 ts checks

* fix: vue3 render types

* fix: vue3 component types
This commit is contained in:
Nikolay Kost
2024-07-12 03:35:51 +03:00
committed by GitHub
parent 1490bd6a8b
commit 16ad5216db
63 changed files with 2389 additions and 226 deletions
+10 -5
View File
@@ -5,14 +5,19 @@ import { render } from './render';
const content = (children: ReactNode, plugins?: BBobPlugins, options?: BBobCoreOptions) =>
React.Children.map(children,
(child) =>
(typeof child === 'string' ? render(child, plugins, options) : child)
(child) => {
if (typeof child === 'string') {
return render(child, plugins, options)
}
return child
}
);
export type BBobReactComponentProps = {
children: ReactNode
container: string
componentProps: Record<string, unknown>
container?: string
componentProps?: Record<string, unknown>
plugins?: BBobPlugins
options?: BBobCoreOptions
}
@@ -23,7 +28,7 @@ const Component = ({
children,
plugins = [],
options = {},
}: BBobReactComponentProps) => React.createElement(
}: BBobReactComponentProps): React.JSX.Element => React.createElement(
container,
componentProps,
content(children, plugins, options),
+4 -2
View File
@@ -24,7 +24,9 @@ const toAST = (
) =>
core(plugins).process(source, {
...options,
render: (input) => htmlrender(input, { stripTags: true }),
render: (input) => {
return htmlrender(input, { stripTags: true })
},
}).tree;
const isContentEmpty = (content: TagNodeTree) => {
@@ -65,7 +67,7 @@ function renderToReactNodes(nodes?: BBobCoreTagNodeTree | TagNodeTree) {
const prevArr = arr; // stupid eslint
const prevNode = lastIdx >= 0 ? prevArr[lastIdx] : null;
if (prevArr[lastIdx] && prevNode !== null && !isEOL(String(prevNode))) {
if (prevArr[lastIdx] && isStringNode(prevArr[lastIdx]) && prevNode !== null && !isEOL(String(prevNode))) {
prevArr[lastIdx] += String(node);
return prevArr;