in the FCKeditor 2.2 distribution under test cases there is test ( 010.html ) which uses the following code to reset the toolbar:
function SetToolbar( toolbarName )
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
var oToolbarSet = oEditor.ToolbarSet ;
// Reset the state of all items in the current toolbar.
for ( var i = 0 ; i < oToolbarSet.Toolbars.length ; i++ )
{
if ( oToolbarSet.Toolbars[i].Items )
{
for ( var j = 0 ; j < oToolbarSet.Toolbars[i].Items.length ; j++ )
oToolbarSet.Toolbars[i].Items[j].State = FCK_UNKNOWN ;
}
}
// Reset the array of toolbat items that are active only on WYSIWYG mode.
oToolbarSet.ItemsWysiwygOnly = new Array() ;
// Reset the array of toolbar items that are sensitive to the cursor position.
oToolbarSet.ItemsContextSensitive = new Array() ;
// Remove all items from the DOM.
oToolbarSet.DOMElement.innerHTML = '' ;
// Load the new toolbar.
oToolbarSet.Name = toolbarName ;
oToolbarSet.Load( toolbarName ) ;
}
I have implemented this code in my project, but there is a bug (which is also demonstable in the test case):
If you switch from Default to Basic, then back to Default again, the drop-down menus (Style, Format, Font, Size) no longer work. It seems that the selection is lost.
**Note: this bug only occurs if you switch toolbar sets from Default to Basic and then back to Default.
function SetToolbar( toolbarName )
{
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
var oToolbarSet = oEditor.ToolbarSet ;
// Reset the state of all items in the current toolbar.
for ( var i = 0 ; i < oToolbarSet.Toolbars.length ; i++ )
{
if ( oToolbarSet.Toolbars[i].Items )
{
for ( var j = 0 ; j < oToolbarSet.Toolbars[i].Items.length ; j++ )
oToolbarSet.Toolbars[i].Items[j].State = FCK_UNKNOWN ;
}
}
// Reset the array of toolbat items that are active only on WYSIWYG mode.
oToolbarSet.ItemsWysiwygOnly = new Array() ;
// Reset the array of toolbar items that are sensitive to the cursor position.
oToolbarSet.ItemsContextSensitive = new Array() ;
// Remove all items from the DOM.
oToolbarSet.DOMElement.innerHTML = '' ;
// Load the new toolbar.
oToolbarSet.Name = toolbarName ;
oToolbarSet.Load( toolbarName ) ;
}
I have implemented this code in my project, but there is a bug (which is also demonstable in the test case):
If you switch from Default to Basic, then back to Default again, the drop-down menus (Style, Format, Font, Size) no longer work. It seems that the selection is lost.
**Note: this bug only occurs if you switch toolbar sets from Default to Basic and then back to Default.