Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Img and P tags are not working in preview of MdEditor: #560

Open
arvi9 opened this issue Aug 5, 2023 · 3 comments
Open

Img and P tags are not working in preview of MdEditor: #560

arvi9 opened this issue Aug 5, 2023 · 3 comments

Comments

@arvi9
Copy link

arvi9 commented Aug 5, 2023

<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>
@arvi9 arvi9 changed the title Img and P Tags are not working Img and P tags are not working in preview of MdEditor: Aug 5, 2023
@jaywcjlove
Copy link
Member

@arvi9 You can remove the rehypeSanitize plugin.

@arvi9
Copy link
Author

arvi9 commented Aug 7, 2023

It works if I remove the rehypeSanitize plugin. But my app is vulnerable to XSS attack Xss attack. I only have to allow some important tag which is must requered i.e. Imag and P tag for image and paragraph alignment. Kindly provide the solution .

@arvi9
Copy link
Author

arvi9 commented Sep 14, 2023

It works if I remove the rehypeSanitize plugin. But my app is vulnerable to XSS attack Xss attack. I only have to allow some important tag which is must requered i.e. Imag and P tag for image and paragraph alignment. Kindly provide the solution .

Please provide the solution. I am awaiting for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants