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

Add an API method for setting HTML content #4135

Open
ianef opened this issue Apr 24, 2024 · 2 comments
Open

Add an API method for setting HTML content #4135

ianef opened this issue Apr 24, 2024 · 2 comments
Labels

Comments

@ianef
Copy link

ianef commented Apr 24, 2024

There is no API method for setting HTML content via code. You can retrieve HTML content with getSemanticHTML() but there is not way of setting this via the API. You can set plain text with setText() but that renders all HTML tags as plain text.

As a workaround you can do the following:

quill.root.innerHTML = myHtmlContent;

But this is unpleasant and could be easily implemented in the API with a setSemanticHTML(string) method. Named as such for consistency with the get method. However you may want to add range parameters etc. which would involve a more complex implementation.

Version 2.0.0

@luin
Copy link
Member

luin commented Apr 28, 2024

Hi you can use quill.setContents() together with quill.clipboard.convert(). Here's an example: Playground

@luin luin added the question label Apr 28, 2024
@ianef
Copy link
Author

ianef commented May 2, 2024

Many thanks @luin, that works for me, but it's not very intuitive or obvious. I think at least there should be something in the documentation to indicate how to do this, or simply implement your code in a method as I suggested.

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