Hi,
We're working on an online chat application and would like to integrate with the editor so users can compose messages. Our application requires that when a user presses Enter we send out the message from the editor. Currently FCKEditor treats Enter to insert <br>. So my questions are:
1. Is it possible to change the logic so Enter would call some callback?
2. Is it possible to change the logic so Ctrl + Enter would do what Enter does today (insert <br>) ?
thanks,
Joe
We're working on an online chat application and would like to integrate with the editor so users can compose messages. Our application requires that when a user presses Enter we send out the message from the editor. Currently FCKEditor treats Enter to insert <br>. So my questions are:
1. Is it possible to change the logic so Enter would call some callback?
2. Is it possible to change the logic so Ctrl + Enter would do what Enter does today (insert <br>) ?
thanks,
Joe
RE: changing behavior for the Enter key
If you put the following into a blank "fckplugin.js" and put that in a folder named say "fckonkeydown" in your plugin directory and then put FCKConfig.Plugins.Add('fckonkeydown') ; in your fckconfig.js, it should show you what's possible. It basically captures or intercepts the onkeydown event within the editor.
![:-)](http://b.cksource.com/a/2/img/smilies/icon_e_smile.gif)
I'm not sure if it's kosher or not but it seems to work...
This code is "rough around the edges"...
usual caveats apply...
-ps I added a ContentMaxLength plugin to the plugin tracker which utilizes the same stuff, so it updates on every keypress in IE.
/* fckplugin.js */
function FCKOnKeyDownFunction(){
alert('Hello Enter Key!');
}
function DocD_OnKeyDown()
{
var e = FCK.EditorWindow.event ;
var alreadyRun = false;
// alert(e.keyCode);
switch ( e.keyCode )
{
case 13 : // ENTER
if ( !(e.ctrlKey || e.altKey || e.shiftKey) )
{
e.cancelBubble = true ;
e.returnValue = false;
if (alreadyRun == false) {
FCKOnKeyDownFunction();
alreadyRun = true
}
return true;
}
else {
return true;
}
break ;
}
return true ;
}
var woot = function(e) {
var alreadyRun = false;
// checks if enter key alone was pressed, and if so, say hello!
if (e.which == 13 && !e.shiftKey && !e.ctrlKey && !e.altKey) {
if (alreadyRun == false) {
FCKOnKeyDownFunction();
alreadyRun = true
}
return false;
}
};
if (document.all) { // If Internet Explorer.
FCK.EditorDocument.attachEvent("onkeydown", DocD_OnKeyDown ) ;
} else { // If Gecko.
FCK.EditorDocument.addEventListener( 'keypress', woot, true ) ;
}
RE: changing behavior for the Enter key
RE: changing behavior for the Enter key
Sounds like a wonderful idea. Where would it go? I'm happy to add it, if I have the power...
![;-)](http://b.cksource.com/a/2/img/smilies/icon_e_wink.gif)
***
Happy almost-birthday Jesus!
RE: changing behavior for the Enter key
How about: http://wiki.fckeditor.net/
)
)
***
Ah thanks
RE: changing behavior for the Enter key
Ha ha.
.
![:-)](http://b.cksource.com/a/2/img/smilies/icon_e_smile.gif)
)
I know where the wiki is (although from my lack of contribution I could see why you'd remind me
My question was more of where on the wiki should I add it?
I was thinking under "Customization" and mabe adding "Code Snippits" or "Example Code" or some such. What do you think? Anyone? I'm open to suggestions. Really open.
***
Hehe. And most people have trouble with that whole concept. Grok on man, grok on...
RE: changing behavior for the Enter key
so what about "How to" section?
****
Do you mean this "grok"?
http://whatis.techtarget.com/definition ... 16,00.html
RE: changing behavior for the Enter key
Error: handleEnterFunction is not defined
Source File: /fckeditor/editor/plugins/fckonkeydown/fckplugin.js
Line: 45
Any idea why my function cannot be resolved?
RE: changing behavior for the Enter key
Also, I left out two lines in the gecko intercepter that stop the onkeydown event from propagating.
That func should read like this:
if (e.which == 13 && !e.shiftKey && !e.ctrlKey && !e.altKey) {
e.preventDefault();
e.stopPropagation();
if (alreadyRun == false) {
FCKOnKeyDownFunction();
alreadyRun = true
}
return false;
}
I've cleaned up a version of this and renamed it to denonkeydown (in case of name conflicts somewhere down the road) which I will submit as a plugin and add to the wiki at some point in the near future.
MTFBWY!
Using Content Max length for FCK 2.6
I am getting trouble in implementing Content Max Length plugin with FCK 2.6
it says FCK.EditorDocument is undefined.
I have just added the line " FCKConfig.Plugins.Add( 'ContentMaxLength' ) ;" in fckconfig.js
other than this, should i do anything?.
and also i am using php class for creating FCK editor not in js.
Please help. its very urgent.
Thanks in Advance,
Jasan