Skip to content

Commit

Permalink
🐛 (textBubble) Fix variable parsing when starting or finishing by spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Nov 14, 2023
1 parent 8f224e3 commit 23625ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/builder/src/assets/styles/plate.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.slate-inline-code {
background-color: #805ad5;
background-color: #a1a1aa;
color: white;
padding: 0.125rem 0.25rem;
border-radius: 0.35rem;
font-size: small;
}

.slate-variable {
Expand Down
22 changes: 21 additions & 1 deletion packages/bot-engine/parseBubbleBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ const applyElementStyleToDescendants = (
})

const convertMarkdownToRichText = (text: string): TDescendant[] => {
const spacesBefore = text.match(/^[\s]+/)
const spacesAfter = text.match(/[\s]+$/)
const plugins = [createDeserializeMdPlugin()]
return deserializeMd(createPlateEditor({ plugins }) as unknown as any, text)
return [
...(spacesBefore?.at(0)
? [
{
type: 'p',
text: spacesBefore.at(0),
},
]
: []),
...deserializeMd(createPlateEditor({ plugins }) as unknown as any, text),
...(spacesAfter?.at(0)
? [
{
type: 'p',
text: spacesAfter.at(0),
},
]
: []),
]
}

0 comments on commit 23625ad

Please sign in to comment.