2
0

🐛 Fix new markdown parser on web runtime

This commit is contained in:
Baptiste Arnaud
2024-02-01 16:52:54 +01:00
parent 3e8e8829f1
commit 678e6d5c49
7 changed files with 41 additions and 67 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.2.37",
"version": "0.2.38",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",

View File

@@ -1,13 +1,11 @@
import type { TElement, TText, TDescendant } from '@udecode/plate-common'
import { PlateText, PlateTextProps } from './PlateText'
import { For, Match, Switch, JSXElement } from 'solid-js'
import { For, Match, Switch } from 'solid-js'
import { isDefined } from '@typebot.io/lib/utils'
import clsx from 'clsx'
type Props = {
element: TElement | TText
isUniqueChild?: boolean
inElement?: boolean
}
export const PlateElement = (props: Props) => (
@@ -33,7 +31,6 @@ export const PlateElement = (props: Props) => (
isUniqueChild={
(props.element.children as TDescendant[])?.length === 1
}
inElement={true}
/>
)}
</For>
@@ -48,7 +45,6 @@ export const PlateElement = (props: Props) => (
isUniqueChild={
(props.element.children as TDescendant[])?.length === 1
}
inElement={true}
/>
)}
</For>
@@ -63,7 +59,6 @@ export const PlateElement = (props: Props) => (
isUniqueChild={
(props.element.children as TDescendant[])?.length === 1
}
inElement={true}
/>
)}
</For>
@@ -78,17 +73,13 @@ export const PlateElement = (props: Props) => (
isUniqueChild={
(props.element.children as TDescendant[])?.length === 1
}
inElement={true}
/>
)}
</For>
</li>
</Match>
<Match when={true}>
<ElementRoot
element={props.element as TElement}
inElement={props.inElement ?? false}
>
<div data-element-type={props.element.type}>
<For each={props.element.children as TDescendant[]}>
{(child) => (
<PlateElement
@@ -96,39 +87,12 @@ export const PlateElement = (props: Props) => (
isUniqueChild={
(props.element.children as TDescendant[])?.length === 1
}
inElement={true}
/>
)}
</For>
</ElementRoot>
</div>
</Match>
</Switch>
</Match>
</Switch>
)
type ElementRootProps = {
element: TElement
inElement: boolean
children: JSXElement
}
const ElementRoot = (props: ElementRootProps) => {
return (
<Switch>
<Match when={props.inElement}>
<span data-element-type={props.element.type}>{props.children}</span>
</Match>
<Match when={!props.inElement}>
<div
data-element-type={props.element.type}
class={clsx(
props.element.type === 'variable' && 'flex flex-col gap-6'
)}
>
{props.children}
</div>
</Match>
</Switch>
)
}

View File

@@ -1,6 +1,6 @@
{
"name": "@typebot.io/nextjs",
"version": "0.2.37",
"version": "0.2.38",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.2.37",
"version": "0.2.38",
"description": "Convenient library to display typebots on your React app",
"main": "dist/index.js",
"types": "dist/index.d.ts",