I need help with interacting with selected text within the rich text editor on the WeWeb platform. What I want is for the user to be able to select a fragment of the text and then send that fragment to ChatGPT.
Could someone guide me on how to implement this functionality? I am looking for the best way to capture the text selection and send the selected content to an integration with ChatGPT.
Here is an image example of what I am looking to achieve:
You can achieve that with custom code. Youâll need to use the getSelection() method.
There is a few ways to trigger that. You can listen to new selection, mouseup event, or keyup.
Let me point you to @GeovanyFerreira new video about just that! Itâs not in english but you can follow through what he does
Yes, @GeovanyFerreira answered my question yesterday in a community here in Brazil and made an incredible tutorial that solved my challenge! I am very grateful to him.
Unfortunately, there are still other posts in the community that werenât as lucky as I was and remain unanswered for quite some time, even with many views:
It would be very helpful for the community if the Weweb team could share a tutorial on rich text, addressing how to insert text at the cursor position and how to replace paragraphs with another paragraph suggested by ChatGPT. These are basic functionalities for anyone looking to develop text, chat, and copywriting platforms that use artificial intelligence, like ChatGPT.
I emphasize the importance of this due to the increasing demand for applications integrated with ChatGPT.
Would it be possible for the Weweb team to produce a tutorial?
Also, I want to highlight the great contribution of the Weweb team with this incredible platform that has achieved so much.
Hello there, thank you @GeovanyFerreira for this awesome tutorial
Do you have a solution to do the same when the user selects text with the keyboard ?
I tried to use the âkeyUpâ workflow from the page to use the âreturn window.getSelection().toString().trim();â javascript, but it seems this code doesnât work there (it is executed, but returns ââ ).