-
Notifications
You must be signed in to change notification settings - Fork 523
Closed as not planned
Description
When I have a text block that contains spans with only whitespace inside of them, that whitespace does not get carried over into the portable text output of htmlToBlocks().
To Reproduce
In your browser console:
const { htmlToBlocks } = await import('https://esm.sh/@sanity/block-tools@3.42.1')
const { Schema } = await import ('https://esm.sh/@sanity/schema@3.42.1')
const blockType = Schema.compile({
types: [
{
type: 'array',
of: [{type: 'block'}]
}
]
}).get()
htmlToBlocks("a b", blockType) // portable text “ab”Expected behavior
The whitespace should be preserved. The workaround I'm using is:
htmlToBlocks("a<span> </span>b", blockType, {
rules: [
{
deserialize: (e, next, block) => {
if (e.localName === 'span' && e.textContent && !e.textContent.trim())
return { _type: 'span', marks: [], text: ' ' }
}
}
]
}) // portable text “a b”Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels