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

video html element will be dropped when i use the setHTML method #1710

Closed
Znuoya opened this issue Jul 29, 2021 · 1 comment
Closed

video html element will be dropped when i use the setHTML method #1710

Znuoya opened this issue Jul 29, 2021 · 1 comment
Labels
Milestone

Comments

@Znuoya
Copy link

Znuoya commented Jul 29, 2021

Describe the bug

As the title, video tag will be dropped in the setHTML method

To Reproduce

Steps to reproduce the behavior:

  1. set the initial html string:
<div>
<h2>视频示例</h2>
<video controls="controls" width="500" height="250">
<source src="https://xxxx.mp4" type="video/mp4" /></video>
</div>
  1. Render Editor with
<Editor
    height="auto"
     language="zh-CN"
     hideModeSwitch={true}
     ref={fileEditorRef}
     onChange={handleMarkdownChange}
/>
  1. use the setHTML method: fileEditorRef.current?.getInstance().setHTML(the above html string)
  2. render result will only show the H2 ELEMENT, but the video ELEMENT IS DROPPED.

Expected behavior

can show the video tag

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [iOS]
  • Browser [chrome]
  • Version [3.0.1]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

Add any other context about the problem here.

@js87zz
Copy link
Contributor

js87zz commented Sep 7, 2021

@Znuoya
The bug has been fixed in v3.1.0. Thanks for wating.
You can use video as below.

const customHTMLRenderer = {
  htmlBlock: {
    video(node) {
      return [
        { type: 'openTag', tagName: 'video', outerNewLine: true, attributes: node.attrs },
        { type: 'html', content: node.childrenHTML },
        { type: 'closeTag', tagName: 'video', outerNewLine: true },
      ];
    }
  }
}

<Editor
    height="auto"
    customHTMLRenderer={customHTMLRenderer}
    // ...
/>

@js87zz js87zz closed this as completed Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants