2
0

🐛 (textBubble) Fix variable parsing when starting or finishing by spaces

This commit is contained in:
Baptiste Arnaud
2023-11-14 15:14:36 +01:00
parent 8f224e3293
commit 23625ad214
2 changed files with 23 additions and 2 deletions

View File

@ -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 {

View File

@ -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),
},
]
: []),
]
}