react-native-rich-editor
react-native-rich-editor copied to clipboard
How to avoid divs
Hi,
is there a way to have div
-free html content produced by the editor? All other tags are meaningful and indicate a specific feature, but div
s aren't, except for newlines which may as well be replaced by br
s.
IMO, there should be a setting to turn this off if not by default. For now I'm stripping them out manually.
@sadikyalcin would you mind sharing your code? I've been messing around with regexes but they can't quite replicate the actual view, there are too many edge cases even for my limited toolbar (bold, lists and hr). I always end up adding some extra <br>
here and there.
@sadikyalcin would you mind sharing your code? I've been messing around with regexes but they can't quite replicate the actual view, there are too many edge cases even for my limited toolbar (bold, lists and hr). I always end up adding some extra
<br>
here and there.
Regexes never worked properly for me as well. Simple replaceAll
with the below gave me the best result.
let body = html.replaceAll('<div></div>', '');
body = body.replaceAll('<div>', '');
body = body.replaceAll('</div>', '');
do you have any other solution?