react-native-rich-editor icon indicating copy to clipboard operation
react-native-rich-editor copied to clipboard

List text gets bigger with every click of heading tag

Open tomgiam opened this issue 3 years ago • 5 comments

When I have a list (ordered or unordered) and I click on any of the Headings (e.g. h1, h3 etc.) The font gets bigger and bigger and the html contains multiple adjacent h1 or h3. It should toggle between h1 and h3 and not add more nested heading tags.

tomgiam avatar Sep 29 '20 20:09 tomgiam

@tomgiam I have faced an issue if I selected h1 or h3 it shows bold as active style did u face the issue

mohamed-ikram avatar Oct 03 '20 12:10 mohamed-ikram

@mohamed-ikram I have not seen that problem. The h1 and h3 text is bold, the html it produces is correct. If I click on return to go to a new line, any text I type there is no longer bold. Only the text on the same line as the h1 or h3 is bold.

tomgiam avatar Oct 03 '20 13:10 tomgiam

I am facing the same problem. @stulip, is it something that can be easily fixed? I am happy to help.

gontovnik avatar Oct 05 '21 21:10 gontovnik

@gontovnik you can try something like this. Whenever the text changes (onChange={this.handleChange}) read the html, replace any double heading tags with single heading tags and update the html (i.e. h1 tag immediately followed by another by h1 tag) and write it back. Same for ending tags and h3 tags.

tomgiam avatar Oct 10 '21 13:10 tomgiam

@gontovnik you can try something like this. Whenever the text changes (onChange={this.handleChange}) read the html, replace any double heading tags with single heading tags and update the html (i.e. h1 tag immediately followed by another by h1 tag) and write it back. Same for ending tags and h3 tags.

How do you write it back in the editor programmatically without resetting the cursor position? If I call the ref.setContentHTML function, it does solve the fontsize issue, but the cursor gets moved to the start on every keypress

mchriss avatar Nov 26 '22 18:11 mchriss