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

Customizing allowed tags in cleanHTML #203

Closed
Mistralys opened this issue Feb 7, 2020 · 7 comments
Closed

Customizing allowed tags in cleanHTML #203

Mistralys opened this issue Feb 7, 2020 · 7 comments
Labels
Milestone

Comments

@Mistralys
Copy link

Hello,

I am trying to filter pasted text to keep only a specific set of tags, and to offer the option to paste as plain text.

I saw that there is a whitelist of tags here, which is used when cleaning the pastedHTML:

https://github.com/JiHong88/SunEditor/blob/master/src/lib/util.js#L1080

It would be great if it was possible to influence this list somehow.

Alternatively, it would be great if we could modify the cleaned HTML before it is pasted. The onPaste event only allows cancelling the event, not modifying the HTML.

What do you think, would something like that be possible, or is there an existing way that I overlooked?

@JiHong88
Copy link
Owner

JiHong88 commented Feb 9, 2020

Hi @Mistralys

The whitelist is a list of tags that the editor allows.
Do you need the ability to keep certain tags only when pasting?

This means that the tags allowed by the editor and the tags allowed when pasting are different.

@Mistralys
Copy link
Author

Mistralys commented Feb 10, 2020

Hi @JiHong88,

yes, I want to keep only specific tags when pasting. You are right, that's different from the tags the editor allows, which do not necessarily have to be the same set of tags.

What I am trying to do with a whitelist when pasting is this:

  • Keep only specific tags when pasting (for example only <p> tags)
  • Be able to paste as plain text (possibly with an empty whitelist)

Ideally, it should be possible to change the whitelist on the fly, which I could easily implement if the onPaste event allowed modifying the HTML.

What do you think?

And thanks for the reply :)

@JiHong88
Copy link
Owner

Yes I can make related options.
Does making an immediate change mean making end user to change?

@Mistralys
Copy link
Author

Hi JiHong88,

thanks, that would be great!

What do you mean with the immediate change for end users?

@JiHong88
Copy link
Owner

No sorry, forget it.
I don't have enough English.
I'll update it by adding related options.

JiHong88 added a commit that referenced this issue Feb 16, 2020
add: options-addTagsWhitelist, pasteTagsWhitelist,
add: util-createTagsWhitelist,
modify: util-convertContentsForEditor, cleanHTML add whitelist argument
@JiHong88 JiHong88 added this to the 2.26.0 milestone Mar 4, 2020
@JiHong88 JiHong88 closed this as completed Mar 4, 2020
@Mistralys
Copy link
Author

Awesome, thanks a lot! Looks good :)

@JiHong88
Copy link
Owner

The 2.26.0 version has been updated.
If there is an issue, please register as a new issue.
Thank you.

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