tags:

views:

83

answers:

1

Is it possible to add an event to the YUI rich text editor. I am trying to attach a kepress event to the YUI rich text editor module for drupal and am using jquery but am having no luck.

A: 

According to the API docs, this is possible, and from the look of it, even very conveniently. See here for the documentation front page.

Editor HTML Event Mapping

* beforeEditorMouseUp
* editorMouseUp
* beforeEditorMouseDown
* editorMouseDown
* beforeEditorClick
* editorClick
* beforeEditorDoubleClick
* editorDoubleClick
* beforeEditorKeyUp
* editorKeyUp
* beforeEditorKeyPress
* editorKeyPress
* beforeEditorKeyDown
* editorKeyDown
Pekka
hey thanks. I had looked at the documentation but perhaps I should have explained a little more than i did - sorry. I am using this through Drupal and have made my own module that interacts with the page. I just cant see how to act to an event from within my own modules javascript file.
David
I see. Sorry, I don't know enough about Drupal to know how your module sets up the editor, so it's difficult to tell how to address the editor instance (which is your question I assume).
Pekka
Yeah thats exaclty it. I can see from the dom that it is creating an iframe with the id 'edit-body_editor' but i am unsure how to actually get the event from the editor itself.
David
The JavaScript source code that your module produces should give you an instance name (a Javascript variable). Through that, you should be able to get hold of the keypress event, and bind a function of your own to it. At least, that's the usual way it works, I think YUI will behave the same way.
Pekka