Disabling a toolbar button can be done through the FCKeditor API, see http://wiki.fckeditor.net/Developer%27s ... script_API and by overwriting the Execute command of the button you want diabled:
FCKeditorAPI.GetInstance(yourFCKeditorInstanceName).Commands.GetCommand(commandName).Execute = function(){return false;};
Where the attribute of GetInstance is the instancename of your editor and the attribute of GetCommand is the buttonName/commandName.
The different commandNames can be found in the file 'editor/_source/internals/fckcommands.js' and for ease of use I have extracted them to list them here:
DocProps, Templates, Link, Unlink, Anchor, BulletedList, NumberedList, About, Find, Replace, Image, Flash, SpecialChar, Smiley, Table, TableProp, TableCellProp, UniversalKey, Style, FontName, FontSize, FontFormat, Source, Preview, Save, NewPage, PageBreak, TextColor, BGColor, PasteText, PasteWord, TableInsertRow, TableDeleteRows, TableInsertColumn, TableDeleteColumns, TableInsertCell, TableDeleteCells, TableMergeCells, TableSplitCell, TableDelete, Form, Checkbox, Radio, TextField, Textarea, HiddenField, Button, Select, ImageButton, SpellCheck, FitWindow, Undo, Redo
So for example to disable a command by default (i.e. onload of the editor), copy the code below and put it in the page that creates the editor. Replace 'FCKeditor1' with the instanceName you chose for your editor. Then pick your command and fill it in in the GetCommand method (replace 'FitWindow'). When you now visit your webpage containing the FCKeditor, the command should be disabled.
<script type="text/javascript">
function FCKeditor_OnComplete( editorInstance )
{
FCKeditorAPI.GetInstance('FCKeditor1').Commands.GetCommand('FitWindow').Execute = function(){return false;};
}
</script>
You can also first trigger the command before you disable it, see the HOWTO on trigering commands: https://sourceforge.net/forum/message.p ... id=3877940
Wed, 10/25/2006 - 01:56
#1
RE: HOWTO - disable toolbar buttons
and changing the .Execute function doesn't really disable the button, the button will look enabled so that's bad user experience.
You could do it better this way:
<script type="text/javascript">
function FCKeditor_OnComplete( editorInstance )
{
var oCommand = editorInstance.Commands.GetCommand('FitWindow') ;
oCommand.Execute = function(){return false;} ;
oCommand.GetState = function(){return FCK_TRISTATE_DISABLED;} ;
}
</script>
But as I said in another reply, for this specific case it's just easier to adjust the width and height of the editor instead of loading it and then forcing it to resize itself again.
RE: HOWTO - disable toolbar buttons
Overwriting the Execute method this way DOES disable the button, but indeed, the buttons still looks enabled. I do not know of a way to set it to look disabled. Your suggestion will only tell FCKeditor itself that the code is disabled, but it still looks enabled.
RE: HOWTO - disable toolbar buttons
FCKeditorAPI.GetInstance('FCKeditor1').EditorWindow.parent.FCKToolbarItems.LoadedItems[commandName].Disable();
to disable a button onload of the editor do
function FCKeditor_OnComplete( editorInstance )
{
editorInstance.EditorWindow.parent.FCKToolbarItems.LoadedItems[commandName].Disable();
}
For the commandNames, see the first message in this thread.
RE: HOWTO - disable toolbar buttons
To disable the whole toolbarset and the editorArea I have written a function, see http://www.saulmade.nl/FCKeditor/FCKSnippets.php
But should you want to reach all buttons from the toolbar yourself, you can do this by reading out our toolbarSet Config variable to get the itemNames and then find the actual buttons on the FCKToolbarItems.LoadedItems Object:
for (i = 0; set = editorInstance.Config.ToolbarSets[editorInstance.EditorWindow.parent.FCKToolbarSet.Name][i]; i++)
{
if (set != "/")
{
for (j = 0; itemName = set[j]; j++)
{
if (itemName != "-")
{
editorInstance.EditorWindow.parent.FCKToolbarItems.LoadedItems[itemName].Disable();
}
}
}
}
Don't use the FCKToolbarItems.LoadedItems, beacuse when you would then have plugins activated but not in your toolbarset, the script would throw an error when it reaches the plugin's button...
So don't do :
for (itemName in editorInstance.EditorWindow.parent.FCKToolbarItems.LoadedItems)
{
editorInstance.EditorWindow.parent.FCKToolbarItems.LoadedItems[itemName].Disable();
}
RE: HOWTO - disable toolbar buttons
I've been trying to disable certain toolbar options on FCKeditor dynamically. I tried both of the approaches mentioned above. But when I try the 'Disable()' option, it seems to disable the feature only temporarily. If I click anywhere inside the editor, the feature is enabled again. The other approach of overriding the 'Execute' and 'GetState' methods of the command to disable seem to work more permanently. Has anybody else had a similar experience with the 'Disable' command before?
I would prefer using 'Disable' as its the recommended way. But I'm not sure why the feature gets enabled again after clicking inside the text area. In either case, I'm calling the disabling mechanism inside the 'FCKeditor_OnComplete' method. I would appreciate any feedback /comments regarding this.
I'm using version 2.4.2 of FCKeditor.
thanks,
Satchit
RE: HOWTO - disable toolbar buttons
You can disable the state changing of the button with:
editorInstance.EditorWindow.parent.FCKToolbarItems.LoadedItems[commandName]._UIButton.ChangeState = function(){};
Not sure there is a better way to do it though. I thought you could do something with setting the state of the button to FCK_TRISTATE_OFF (editorInstance.EditorWindow.parent.FCKToolbarItems.LoadedItems[commandName]._UIButton.ChangeState( FCK_TRISTATE_OFF );), but testing shows this doesn't help. So no idea what this off state is... I guess a button has to define it's behavior for the off state, otherwise it defaults to its on state behavior (?)
Re: HOWTO - disable toolbar buttons
At this point (while loading) the toolbar is enabled (not all the content loaded), so If the user click on the save button the form submits, but not all the content was loaded.
How can I prevent this behavior. FCKeditor_OnComplete is useless because this happens before.
Thanks
Re: RE: HOWTO - disable toolbar buttons
Any luck with FCK_TRISTATE_OFF? I am trying to remove(hide) a button withouth changing fckconfig.js and i belive FCK_TRISTATE_OFF is the way to do it ...I think i am not using it right...
how to enable ckeditor toolbar options?
I am using ckeditor in my project. Its working fine in all browsers, but a small issue in Google Chrome - Editor will open properly on first click, After closing the pop up and try the editor on second time without loading the page , I can't type text in the editor.
I somehow managed to resolve this issue using this javascript.
<script type="text/javascript">
$(document).ready( function() {
var instance = CKEDITOR.instances['lessonContent'];
if(instance) {
CKEDITOR.remove(instance);
}
CKEDITOR.config.startupMode = 'source';
});
</script>
but toolbar buttons are disabled now.
Can you please help me how to enable toolbar options here?
Thanks in adv
What you did is not the right
What you did is not the right method -- you are now opening CKEditor in Source mode. When you are in Source mode, toolbar buttons are disabled because they apply to WYSIWYG mode. You simply cannot use their features in Source mode, as Source is supposed to work on raw HTML code.
This always works in this way, see for example the demo on our website. If you click the Source button, you go into Source mode and the buttons become disabled.
Documentation Manager, CKSource
See CKEditor 5 docs, CKEditor 4 docs, CKEditor 3 docs, CKFinder 3 docs, CKFinder 2 docs for help.
Visit the new CKEditor SDK for samples showcasing editor features to try out and download!
Ok then. I am back to square
Ok then. I am back to square 1 now.
My issue is when I open ckeditor 2nd time in chrome without reloading page (using ajax) then ckeditor gets disabled.
Issue is similar to this
http://bugs.jqueryui.com/ticket/7888#comment:2
I am not able to find solution for it. Any idea what it is happening?
I tried to change it to WYSIWYG mode but no outcome.
How to
How to disable buttons and ebable if i click on other button.
I explain if you don't click on form's button you can click on radio button, etc. How i can do this please