🚑 Fix inline variable parsing on new line issue
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.2.38",
|
"version": "0.2.39",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import type { TElement, TText, TDescendant } from '@udecode/plate-common'
|
import type { TElement, TText, TDescendant } from '@udecode/plate-common'
|
||||||
import { PlateText, PlateTextProps } from './PlateText'
|
import { PlateText, PlateTextProps } from './PlateText'
|
||||||
import { For, Match, Switch } from 'solid-js'
|
import { For, JSXElement, Match, Switch } from 'solid-js'
|
||||||
import { isDefined } from '@typebot.io/lib/utils'
|
import { isDefined } from '@typebot.io/lib/utils'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
element: TElement | TText
|
element: TElement | TText
|
||||||
isUniqueChild?: boolean
|
isUniqueChild?: boolean
|
||||||
|
insideInlineVariable?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PlateElement = (props: Props) => (
|
export const PlateElement = (props: Props) => (
|
||||||
@@ -79,7 +80,10 @@ export const PlateElement = (props: Props) => (
|
|||||||
</li>
|
</li>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={true}>
|
<Match when={true}>
|
||||||
<div data-element-type={props.element.type}>
|
<ElementRoot
|
||||||
|
element={props.element as TElement}
|
||||||
|
insideInlineVariable={props.insideInlineVariable ?? false}
|
||||||
|
>
|
||||||
<For each={props.element.children as TDescendant[]}>
|
<For each={props.element.children as TDescendant[]}>
|
||||||
{(child) => (
|
{(child) => (
|
||||||
<PlateElement
|
<PlateElement
|
||||||
@@ -87,12 +91,38 @@ export const PlateElement = (props: Props) => (
|
|||||||
isUniqueChild={
|
isUniqueChild={
|
||||||
(props.element.children as TDescendant[])?.length === 1
|
(props.element.children as TDescendant[])?.length === 1
|
||||||
}
|
}
|
||||||
|
insideInlineVariable={
|
||||||
|
props.element.type === 'inline-variable'
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
</div>
|
</ElementRoot>
|
||||||
</Match>
|
</Match>
|
||||||
</Switch>
|
</Switch>
|
||||||
</Match>
|
</Match>
|
||||||
</Switch>
|
</Switch>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ElementRootProps = {
|
||||||
|
element: TElement
|
||||||
|
children: JSXElement
|
||||||
|
insideInlineVariable?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const ElementRoot = (props: ElementRootProps) => {
|
||||||
|
return (
|
||||||
|
<Switch>
|
||||||
|
<Match
|
||||||
|
when={
|
||||||
|
props.element.type === 'inline-variable' || props.insideInlineVariable
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span data-element-type={props.element.type}>{props.children}</span>
|
||||||
|
</Match>
|
||||||
|
<Match when={true}>
|
||||||
|
<div data-element-type={props.element.type}>{props.children}</div>
|
||||||
|
</Match>
|
||||||
|
</Switch>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/nextjs",
|
"name": "@typebot.io/nextjs",
|
||||||
"version": "0.2.38",
|
"version": "0.2.39",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.2.38",
|
"version": "0.2.39",
|
||||||
"description": "Convenient library to display typebots on your React app",
|
"description": "Convenient library to display typebots on your React app",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user