VaguelySerious / react-quill

A Quill component for React.
https://zenoamaro.github.io/react-quill/
MIT License
47 stars 15 forks source link

Expose getSemanticHTML method to event handlers #1

Closed generalov-epm closed 3 months ago

generalov-epm commented 5 months ago

This PR is about exposing the getSemanticHTML method to event handlers.

<ReactQuill
  onBlur={(range, source, editor) => {
    console.log(editor.getSemanticHTML());
  }}
  // other props
/>

The getSemanticHTML method returns the semantic HTML representation. This result is different from the editor.getHTML() method which returns just the editor contents.

Example:

<!-- getHTML() -->
<ol>
<li data-list="bullet"><span class="ql-ui" contenteditable="false"></span>one</li>
<li data-list="bullet"><span class="ql-ui" contenteditable="false"></span>two</li>
</ol>
<!-- getSemanticHTML() -->
<ul>
<li>one</li>
<li>two</li>
</ul>
v1kt0r1337 commented 5 months ago

Was about to create an issue related to bullet lists no longer working, but it seems like this PR might solve it.

xxxjinn commented 3 months ago

If this PR can resolve the bullet lists issue, could you please merge it? I'm using the react-quill-new library for my project. 😭😭

sayinmehmet47 commented 3 months ago

If this PR merges and resolves our issue with bullets being converted to numbers, I would greatly appreciate it. @VaguelySerious 🚀

VaguelySerious commented 3 months ago

@generalov-epm Thanks for making this! And thanks for pinging me @sayinmehmet47, I didn't see the PR at first. This looks good to me

sayinmehmet47 commented 3 months ago

@VaguelySerious you are great thanks to react very fast :)

VaguelySerious commented 3 months ago

Published as react-quill-new@3.3.0

sayinmehmet47 commented 3 months ago

Unfortunately, this pull request did not resolve my issue. When I enter a bullet list, it is still added as ol instead of ul in the HTML.

Here similiar bug that opened

https://github.com/slab/quill/issues/4141

image

VaguelySerious commented 3 months ago

@sayinmehmet47 It seems very likely then that this is an issue with Quill itself, as we're just proxying the the getSemanticHTML method. This issue is still open and seems to be the most relevant, but it doesn't get at the issue of .getSemanticHTML directly, so it might be worth opening a new issue with your specific reproduction steps.