-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
P1Moderate IssueModerate Issue
Description
Steps to reproduce:
- Create BBCode string using the color tag:
[color=#ff0000]This text should be red[/color]
- Attempt to render it in BBob w/ React preset:
const plugins = [presetReact()];
export default function parse_bb(bbcode_input: string): JSX.Element {
return (<BBCode plugins={plugins}>
{bbcode_input}
</BBCode>);
}
...
//someComponent.tsx
parse_bb("[color=#ff0000]This text should be red[/color]");
Outputted error:
Error: The
style
prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.
Taking a look at the React BBob tag presets, it looks like the React preset only contains implementations for the b
, i
, u
, and s
tags. For color
, it falls back to the HTML5 tag preset. This would output the following tag:
<span style="color: #ff0000;">{content}</span>
Which works for HTML5, but React doesn't support inline style strings in JSX. Ideally, tags would be formatted like this:
<span style={{color: "#ff0000"}}>{content}</span>
I tried to create my own color
tag, but the documentation and examples don't make it very clear how to supply custom attributes to the created React component, besides its children. How can I do this?
JiLiZART
Metadata
Metadata
Assignees
Labels
P1Moderate IssueModerate Issue