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

Allow Style and Script tag, already set to fullpage: true, and allow whitelisttag #527

Closed
ostrichegret opened this issue Oct 21, 2020 · 3 comments
Labels
Milestone

Comments

@ostrichegret
Copy link

ostrichegret commented Oct 21, 2020

Hi @JiHong88 ,

After some tests, SunEditor is really great, better than the other editors I have tested.

It just I got a problem when pasting style and script tag.

I want to enable style and script tag for super admin usage,
When I set the fullPage to true, the setContent become blank ( not working )
and when I paste the content manually on code view mode:

<style>.test{color:'red'}</style><p class='test'>hello</p><script>alert('hello!')</script>

the content is changed to :

<!DOCTYPE html>
<html>
<head>
<style>
.test{color:'red'}</style>
</head>
<body data-new-gr-c-s-check-loaded="14.980.0" class="sun-editor-editable" contenteditable="true" spellcheck="false" >
<p class="test">hello</p>
</body>
</html>

and the output of the onchange only this:

<p class="test">hello</p>

Please help, my react code is this:
Thanks a lot for your help.

<SunEditor
                setOptions={{
                  fullPage: true,
                  iframeCSSFileName: 'https://cdn.jsdelivr.net/npm/suneditor@latest/dist/css/suneditor.min.css',
                  height: 400,

                  codeMirror:CodeMirror,
                  buttonList: [
                      ['undo', 'redo'],
                      ['font', 'fontSize', 'formatBlock'],
                      ['paragraphStyle'],
                      ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
                      ['fontColor', 'hiliteColor'],//'textStyle'
                      ['removeFormat'],
                      '/', // Line break
                      ['outdent', 'indent'],
                      ['align', 'horizontalRule', 'list', 'lineHeight'],
                      ['table', 'link', 'image'],//'video'
                      ['fullScreen', 'showBlocks', 'codeView'],
                      ['preview', 'print'],
                      //['save', 'template']
                  ],
                  addTagsWhitelist:"style|script",
                  attributesWhitelist:{
                      'all':'style'
                  }
        			   }}
                 enableToolbar={true}
                 setContents={"<style>.test{color:'red'}</style><p class='test'>hello</p><script>alert('hello!')</script>"}
                 onChange={(content) => {console.log(content)}}
              />

@yuera5196
Copy link

I have the same problem. Have you solved it

@JiHong88
Copy link
Owner

Hi,
When in iframe mode, setContents adds content only to the body area.
You need to add content to the head and body respectively.

editorInstance.core._wd.head, body

But, Since suneditor-react does not provide editor instance, we will add related functions.

@JiHong88 JiHong88 modified the milestones: 2.34.1, 2.25.0 Oct 28, 2020
JiHong88 added a commit that referenced this issue Nov 1, 2020
@JiHong88 JiHong88 modified the milestones: 2.34.2, 2.35.0 Nov 5, 2020
JiHong88 added a commit that referenced this issue Jan 12, 2021
@JiHong88
Copy link
Owner

The 2.35.0 version has been updated.
If this issue has not been resolved, please reopen this issue.
Thank you.

NickyTope pushed a commit to isw-kudos/SunEditor that referenced this issue Feb 11, 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

3 participants