I am making a text editor and I need to detect where browsers create line breaks due to element’s width limits. I found that the Rect API can be used for this purpose but it’s not compatible with textarea since it is a replaced element.
I have come to a split: Do I go with a textarea + a hidden div or a content editable div?
Textarea + hidden div:
Pros:
- Easier to maintain
- I can simply replicate its content with a hidden div with the same styling to be able to use the Rect API
Content editable div
Pros:
- No need to maintain two elements
Cons:
- More complicated to maintain
- Need to replace div tags created by the return key with br tags