Open garretthyder opened 6 years ago
We may want to look at the Grammarly extension to get some ideas as they have a really nice in-textarea highlight with tooltip that contains replace actions.
There's also the 'contenteditable' path as mentioned on GP ticket https://github.com/GlotPress/GlotPress-WP/issues/166
If we can use a library is better to have less custom code untested a lot but we will find something :-)
Agreed a library is going to be best, hopefully something lightweight. We'll want to avoid WYSIWYG editors and maybe contenteditable now that I look at it more since both support injecting markup (Bold, Italics, etc) which affects the integrity of the string as we shouldn't be injecting markup that's not already present.
This ticket will house the efforts for introducing in-Textarea highlighting for spaces, terms and other items.
Originally the idea stems from this GlotPress issue; https://github.com/GlotPress/GlotPress-WP/issues/863
This is quite an involved implementation as we'd probably have to retrofit the textarea with a complimentary div which visually replaces the textarea to support highlighting. We could potentially use a library like this - https://codersblock.com/blog/highlight-text-inside-a-textarea/
Some ideas for what should be highlighted in the text area are;
In some cases such as the term highlight and the trailing ... highlight we can take advantage of the 'Fix Warning' functionality being built for 1.5 in #145 so that on-click those highlights can execute replace logic.