i'm trying to get my head around how to customize the events that are triggered by toolbar buttons, and so far i'm just not getting it. i want to add the ability to save html created in the editor to the local hard drive - rather than submitting a form.
the first thing i tried to do (to figure out which bits of code were important), was to modify FCKSaveCommand.prototype.Execute in fck_othercommands.js to simply do something other than submit the form, but it's still trying to submit the form. i modified other methods related to other buttons (like preview), but nothing changes about behavior. so i'm not understanding how the chain of execution works.
i'll keep going through the forums and the wiki, but can somebody please point me in the right direction?
thanks.
the first thing i tried to do (to figure out which bits of code were important), was to modify FCKSaveCommand.prototype.Execute in fck_othercommands.js to simply do something other than submit the form, but it's still trying to submit the form. i modified other methods related to other buttons (like preview), but nothing changes about behavior. so i'm not understanding how the chain of execution works.
i'll keep going through the forums and the wiki, but can somebody please point me in the right direction?
thanks.
RE: need help with custom save command
RE: need help with custom save command
RE: need help with custom save command
ok, i'm in!
the wiki showed me how to run the source files directly for development (http://fckeditor.wikiwikiweb.de/Develop ... ompression)
one big step toward getting comfortable with developing with FCK.
sorry for the wasted bandwidth
RE: need help with custom save command
My first attempt to solve this was to write a onsubmit function for the form containing fckeditor together with FCKeditorAPI.GetInstance (or smthing similar) - this works as a simple solution.
Secondly, I wrote a new plugin for SaveAs/Open (custom filebrowser) adding a new button to the toolbar. Documentation on how to do this actually exists and is pretty good and easy to follow, just copy and paste .
At the moment I am trying to find a way to execute a toolbar command from my script.
Do anyone know how to do that...
RE: need help with custom save command
Here's the pointer you asked for...
... In the form
<form method="POST" name="FCKeditor1" action="http://localhost/cgi-bin/fckconnector.pl?FileUpload" OnSubmit="return MyCustomSave()">
...The javascript function
function MyCustomSave(){
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
oEditor.ExecuteNamedCommand('SaveAs', 'filename.html');
return false;
}
This will open up a saveas dialog (in IE anyway) but I am not sure how to save the edited content.
This at least saves the content of the initial value set in the form(on my IE at least)
Don't bother setting the value with the GetHTML function - it dont do the work for me...
Heres an idea though
- Maybe you could open a new window with a appropriate Content-type and hopefully the browser asks you to download !? .... just another stupid idea...
RE: need help with custom save command
This function should be called from onsubmit in your form-tag like. (could be called anyway you like though)
<form name="..." onsubmit="return MyCustomSave()">
...</form>
function MyCustomSave(){
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
var oWin = window.open('','_blank', 'left=0,top=0,width=600,height=600,scrollbars=0,toolbar=0,menubar=0,status=0,directories=0,location=0,resizable=1');
oWin.document.write(oEditor.GetHTML(true));
oWin.document.execCommand('SaveAs', true,'Filename');
oWin.close();
return false;
}
Please, if you have the opportunity, try this with both netscape, IE and such - so far I have tested it on my local dev-machineIE6.
Also. The function doesn't save the complete document with headers and such... needs s little work.
RE: need help with custom save command
If you want headers and such, try using a normal, blank html page in the popup, and setting the document.body.innerHTML to the content of the editor.
Or put it in an href and tell the user to do a right-click, "save as".