http://www.saulmade.nl/FCKeditor/FCKPlugins.php
/*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* File Name: fckplugin.js
* Plugin to add some preset HTML
*
* File Authors:
* Paul Moers (http://www.saulmade.nl/FCKeditor/FCKPlugins.php)
*/
// insertHtmlObject constructor
var insertHtmlToolbarCommand = function()
{
}
// register the command
FCKCommands.RegisterCommand('insertHtml', new insertHtmlToolbarCommand());
// create the toolbar button
var insertHtmlButton = new FCKToolbarButton('insertHtml', FCKConfig.insertHtml_buttonTooltip || FCKLang.inserHTML_buttonTooltip);
insertHtmlButton.IconPath = FCKPlugins.Items['insertHtml'].Path + 'images/toolbarIcon_default.gif'; // or pick any other in folder 'images'
FCKToolbarItems.RegisterItem('insertHtml', insertHtmlButton);
// manage the plugins' button behavior
/*
insertHtmlToolbarCommand.prototype.GetState = function()
{
return FCK_TRISTATE_OFF;
}
*/
insertHtmlToolbarCommand.prototype.GetState = function()
{
// Disabled if not WYSIWYG.
if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || ! FCK.EditorWindow )
return FCK_TRISTATE_DISABLED ;
var path = new FCKElementPath( FCKSelection.GetBoundaryParentElement( true ) ) ;
var firstBlock = path.Block || path.BlockLimit ;
if ( !firstBlock || firstBlock.nodeName.toLowerCase() == 'body' )
return FCK_TRISTATE_OFF ;
// See if the first block has a blockquote parent.
for ( var i = 0 ; i < path.Elements.length ; i++ )
{
if ( path.Elements[i].nodeName.IEquals( 'blockquote' ) )
return FCK_TRISTATE_ON ;
}
return FCK_TRISTATE_OFF ;
}
// insertHtml's button click function
insertHtmlToolbarCommand.prototype.Execute = function()
{
if (FCKConfig.insertHtml_showDialog)
{
var dialog = new FCKDialogCommand('insertHtml', FCKLang.insertHtml_dialogTitle, FCKPlugins.Items['insertHtml'].Path + 'insertHtml.html', 200, 100);
dialog.Execute();
}
else
{
var txt = getSelectedText();
if(txt == ''){
//var selection = (FCK.EditorWindow.getSelection ? FCK.EditorWindow.getSelection() : FCK.EditorDocument.selection);
//txt = getSelectionHTML(selection, FCK);
FCK.Commands.GetCommand('Blockquote').Execute();
}
if(txt != ''){
FCK.InsertHtml('<blockquote><div>'+txt+'</div></blockquote>');
}
FCK.EditorWindow.parent.FCKUndo.SaveUndoStep();
}
}
// get selection text from anywhere on the page
function getSelectedText(){
var containerWindow = FCK.EditorWindow.parent.parent;
var containerDocument = containerWindow.document;
var txt = '{default value}';
if (containerWindow.getSelection){
txt = containerWindow.getSelection();
} else if (containerDocument.getSelection) {
txt = containerDocument.getSelection();
} else if (containerDocument.selection) {
txt = containerDocument.selection.createRange().text;
}
return txt;
}
// get HTML from selection
function getSelectionHTML(selection, editorInstance)
{
var range = (editorInstance.EditorWindow.parent.FCKBrowserInfo.IsIE ? selection.createRange() : selection.getRangeAt(selection.rangeCount - 1).cloneRange());
if (editorInstance.EditorWindow.parent.FCKBrowserInfo.IsIE)
{
return range.htmlText;
}
else
{
var clonedSelection = range.cloneContents();
var div = document.createElement('div');
div.appendChild(clonedSelection);
return div.innerHTML;
}
}

Re: some problem with a TRISTATE
var insertHtmlButton = new FCKToolbarButton('insertHtml', FCKConfig.insertHtml_buttonTooltip || FCKLang.inserHTML_buttonTooltip);I think 6th parameter 'contextSensitive' of a FCKToolbarButton(...) must be set to 'true'
var FCKToolbarButton = function( commandName, label, tooltip, style, sourceView, contextSensitive, icon ){...}So the code that works