PANmedia / raptor-editor

Raptor, an HTML5 WYSIWYG content editor!
www.raptor-editor.com
GNU General Public License v3.0
533 stars 136 forks source link

Using selection programmatically #158

Closed compilando closed 10 years ago

compilando commented 10 years ago

Hello, I'm implementing an AJAX based app with Raptor as main editor.

In one custom button, I open a jQuery modal dialog, do some user stuff, and with the result, I insert some kind of metadata in Raptor document. (Somethind like a remote thesaurus)...

Then problem is that I have a "Selection Range" in Raptor (for example, a word), and in my modal window, the user can write in several input boxes. When it occurs, Raptor is losing it's selected area, because the user is selecting areas in other HTML element...

I'm thinking about saving the selection range in Raptor, do all my stuff, and restoring the selection range, but I'm not sure how to do it. I have the selection range captured, but I'm having problems in restoring it...

Can you help me?

Kind regards, Oscar

Petah commented 10 years ago

Hi,

You can call raptor.pause() and raptor.resume() which will make Raptor remember the selection for you. Similar to how the dialog button component works:

https://github.com/PANmedia/raptor-editor/blob/master/src/components/ui/dialog-button.js#L74-L81

compilando commented 10 years ago

Perfect. Thank you, your support is incredible, fast and clear... ;-)