Problem with the Richtext-Editor

Hello togehter,

first time in this forum-section, so i do not know what i have to expect :grin:.

Not sure if this issue is for this section or not.

I have noticed that the RTE has one major disadvantage. For example, if you want to send the entered text in the RTE using the “ENTER” key, this is not possible.

It is also clear to me why this is not possible since you can skip the line by pressing the ENTER key.

BUT…

If you want to bypass the system with the help of a key combination, for example, this is only possible to a limited extent.

In the IDEAL CASE, the “CRTL” key would be the best choice —> “CRTL” + “ENTER” ----> to complete the entry.

I found that both the “TAB” key and the key directly below “ESC” work in combination with the “ENTER” key, with the TAB + ENTER combination not a good choice.

Are there any other tips or advice?

I had the idea to modify the function of the “ENTER” key in the RTE by trying to simulate a permanent actuation of the button in question, so that the system assumes that not just the ENTER key but two keys are pressed to change the function of the “ENTER” key. Unfortunately, that didn’t quite work.

(setInterval) / (setTimeout) / (event.keyCode = 94) / (event.key.charCodeAt (0))

I have worked with all these means.

Ultimately, I stayed with the fact that I stick to the combination ----> [“°” + “ENTER”].

But it would be nice if you could use the “CRTL” button for this function, which has not been used yet.

I have also found this LINK …

https://www.wix.com/corvid/forum/community-discussion/chat-submit-by-enter

So as you can see, it is already a known problem, but still nothing has changed. :sleepy: :sleepy: :sleepy:

Hey :raised_hand_with_fingers_splayed:

Why do you think that pressing the Enter key won’t work? Did you try to use a combination to send the rich box value?

$w("#myElement").onKeyPress( (event) => {
  let ctrl = event.ctrlKey;
  
  if (ctrl && event.key === 'Enter') {
    // send the rich box value    
  }

});

Wix Realtime API Tutorial.

I’m not sure the event handler will register the two keys at the same time, try it out and let me know if it worked.

Ahmad

Ok, THX! I will check it out.

EIDIT:

Nope wether the ctrl either the alt-key do work.
Both keys without any reaction in the RichTextEditor.

But this one is good. → Wix Realtime API Tutorial . :grin: (have to study it)

So the onKeyPress doesn’t register two keys at the same time, right? I was hoping it does but it is what it is :unamused:

If you found a solution please keep me posted.

Yes, i found a way.
It works, but with another Key-Combination.

I wrote it already in my opening-post.

The key i am talking about is directly under the ESC-Button, which produces…

  • ^^^^^^^^^^ or °°°°°°°°°°°°°°°

ENTER+this key works.
Also the combination TAB+ENTER works, but this is not a good solution, you will see why by testing yourself the RTE.

So the best solution in for sending a post without pressing a generated button on the page, it’s the provided key on Keyboard, althogh the VERY BEST-SOLUTION would be the “CRTL+ENTER”-Kombination.

The CRTL-key is completely unused.

OK, why not adding a checkbox under the rich-box, that when checked the “Enter” key sends whatever in the box, and when not checked just create a new line? Many major companies implement this functionality in their apps. Just wondering :grin:

Yes, it is indeed an idea, but is it really effective?

For example:

I am writing some text and wanna send the message → i have setted my CHBOX to → send on ENTER. ok

But then it is no more possible to do an paragraph :sleepy:.
Or i have every time when i wanna do that to CHECK and UNCHECK the CHBOX.

It would be a solution for a comment-box → that’s possible
But it can’t be a solution for a Chat-Box.

I just wondering, WHY THE CTRL-BUTTON IS NOT IMPLEMENTED ?
This button is totaly free.

So i think there is no chance to use this button, until WIX has done some changes. Or i have to use the normal-text-box. I think in the normal text-box this feature will work, althougt i did not tested it yet.

Thanks for your suggested ideas, i appreciate it.

You’re right, and the onKeyPress event handler should be able to tell which keys are being pressed even if they were a combination.

You’re welcome :wink: Even tough I wasn’t helpful :grin:

Yes it was helpful. It let me understanding things better, just by doing a disscussion.
And i learn with every post of you.

That’s great to hear! Thanks for the compliment :blush:

So, for everybody who is interessted, and do not want to search for a custom solution in this shitty “RichTextField”, how to send Text without to press a created “send”-button on your page, instead doing it via KEYBOARD.

Here is the solution.

  1. The ENTER-Key in the RTF will just be recogniced by system in COMBINATION with ----> “TAB” or the key between “ESC” and “TAB”. Just this 2 keys are working.

  2. First i thought the TAB-KEY would not be the better choice, because, while pressing TAB+ENTER, the focus goes to menue of RTF (looses focus of textfield).

  3. Using the other mentioned key in combination with ENTER, also has his own problems (you can test all this things in a normal RTF or in my comment-box, where i have also integrated some special analysing tools, for better detecting, whats going on) :grin:

  4. Ok, at the end, i desided to use the “TAB”-key again, because i found a very simple way, how to solve it (after 3-DAYs of SEARCH xD).

This is the very important code-snipet, which allows to send a message out from the RTF without pressing a button on the page (with mouse), instead doing it with your keyboard.

if(pressedKey==="Enter"){console.log("ENTER pressed")
        saveComment()
        .then(()=>{
            $w('#TXT').value= " "   //setting value to "" in RTF
            $w('#dataset1').refresh()
            setTimeout(()=>{$w('#RTXT0').focus()},50)
            //back-focus to the RTF-text-field
        })
    }

An working example you will find here…(on the very bottom of the page)

https://russian-dima.wixsite.com/meinewebsite

By the way, i think this would not work in the RTF, because the ENTER-KEYS is not gonna be detected without a COMBINATION.

OK, why not adding a checkbox under the rich-box, that when checked the “Enter” key sends whatever in the box, and when not checked just create a new line? Many major companies implement this functionality in their apps. Just wondering :grin:

And i found some more ERRORs in the RTF.
For example the displaying of the value-length is also not correct (BUG).
I could fix it, but not to 100%.

You can test it in my last version of comment box on my main-site (and do not forget the analysing tools). :laughing: