Img and P tags are not working in preview of MdEditor:
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 201
- Avg merge
- 12m
- Merged PRs (30d)
- 1
Description
<p align="center">
<img width="600" height="200" src="https://www.python.org/python-.png">
</p>
Img and P tags are not working in preview of MdEditor:
<div data-color-mode="dark">
<MDEditor
value={value}
onChange={(value)=>{setValue(value)}}
preview="edit"
commands={[...commands.getCommands(), uploadImage, help]}
previewOptions={{
linkTarget: '_blank',
rehypePlugins: [
[
rehypeSanitize,
{
...defaultSchema,
attributes: {
...defaultSchema.attributes,
span: [
// @ts-ignore
...(defaultSchema.attributes.span || []),
// List of all allowed tokens:
['className', 'math', 'math-inline'],
],
code: [['className']],
img: [...(defaultSchema.attributes.img || []), ["width",
"height",
"src",
"alt",
"style"]],
},
},
],
],
}}
height={400}
highlightEnable={true}
enableScroll={true}
textareaProps={{
placeholder: 'Please enter Markdown text',
}}
/>
</div>
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the MDEditor preview configuration in the issue, especially the rehypeSanitize schema and its img attributes, and reproduce the supplied JSX example. Trace how the preview handles the img and p tags; done means both tags render correctly with the shown configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100