How to submit CKEditor when Enter key is pressed

Community Driven Extensions Project
onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

24 Sep 2012, 18:33

Does any one know how to config CKEditor to submit the editor content when the Enter key is pressed?

Thanks,
Jonathan Ekwempu
TobiSoft Inc.

bornsilly
Posts: 27
Joined: 19 Mar 2010, 15:41
Location: Netherlands

24 Sep 2012, 19:02

Wonder why you would use CKEditor if you have no need for newlines?
PrimeFaces 3.3.4, Primefaces-extensions 0.6.0, JBoss 7.1, Mojarra 2.1.10

onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

24 Sep 2012, 20:40

I need that functionality for the editor.
Jonathan Ekwempu
TobiSoft Inc.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

26 Sep 2012, 21:14

You must register the on-enter handler by yourself with jquery (don't know if this works)
Then you could call the editor widget via: myEditorWidgetVar.fireEvent('save');
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

27 Sep 2012, 15:43

I know this can be done in the JavaScript version of CKEditor. Do you know how I can register the on-enter key in the JSF version?

Thanks
Last edited by onyii5119 on 27 Sep 2012, 17:45, edited 1 time in total.
Jonathan Ekwempu
TobiSoft Inc.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

27 Sep 2012, 16:31

Just post the JS example, i think its not hard to use it with the my JSF port ;)
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

30 Sep 2012, 23:55

Follow the link below:

http://cksource.com/forums/viewtopic.php?f=11&t=18485

That's really what I want to achieve.

Thanks.
Jonathan Ekwempu
TobiSoft Inc.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

01 Oct 2012, 09:30

myWidgetVar.instance.on('key', function(e) {
myWidgetVar.fireEvent('save');
});

should work. Otherwhise no idea. You can get the real ckeditor instance via myWidgetVar.instance.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

03 Oct 2012, 00:40

Does not work - JavaScript error. It seems as if the editor widgetVar does not return the editor reference. JavaScript does not recognize it as a variable.
Jonathan Ekwempu
TobiSoft Inc.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

03 Oct 2012, 02:08

<pe:ckEditor .... widgetVar="myEditor">
<pe:javascript event="initialize" execute="myEditor.instance.on('key', function(e) { myEditor.fireEvent('save'); });" />
</pe:ckEditor>


this works. But you must add if key == enter.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests