FCKeditor – ツールバー設定編

FCKeditorの設置ができ、アップロード機能も動いた。

次にやっておきたいのはツールバーの設定だ。

例えば、一般ユーザ向けに「ソース」を公開してしまうと、タグを壊したり、望ましくないタグを埋め込まれたりする。
ツールバーから「ソース」を削除してしまうのがいいと思う。

また、編集結果をデータベースに保存する場合、「保存」は不用だ。

カスタム設定を使う

FCKeditorの基本的な設定は、FCKeditor/fckconfig.js で行っている。ツールバーに関しては、「Default」と「Basic」が設定されている。

この「Default」と「Basic」を参考にして、新しい名前でツールバーを定義すればいい。

しかし、FCKeditor/fckconfig.js を直接編集しなくてもいい方法がある。カスタム設定を使う方法だ。

まず、適当な場所にカスタム設定のファイルを作る。あきらは FCKeditor/behappy.config.js とした。

//======================================================================================================================
// BeHappy!
FCKConfig.Plugins.Add( 'simplecommands', null, FCKConfig.BasePath + 'plugins/' ) ;
FCKConfig.ToolbarSets["BeHappy!"] = [
['Preview'],
['Undo','Redo'],
['SelectAll','RemoveFormat'],
['OrderedList','UnorderedList'],
['Table','Rule','Smiley','SpecialChar'],
['Link','Unlink'],
['Image','Flash'],
['Find','Replace'],
['About'],
'/',
['StyleSimple','FontFormatSimple','FontNameSimple','FontSizeSimple'],
['TextColor','BGColor'],
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Outdent','Indent']
] ;

つぎに、FCKeditor を呼び出す部分で、このカスタム設定ファイルを指定する。

function on_load() {
//==================================================================
// FCK Editor
var oFCKeditor = new FCKeditor( 'contents' );
oFCKeditor.BasePath = '<?php echo PATH_FCKeditor; ?>';
oFCKeditor.Config['CustomConfigurationsPath'] = oFCKeditor.BasePath + 'behappy.config.js' ; // カスタム設定追加
oFCKeditor.Width = '800';
oFCKeditor.Height = '700';
oFCKeditor.Config['SkinPath'] = oFCKeditor.BasePath + 'editor/skins/silver/' ;
oFCKeditor.ToolbarSet = 'BeHappy!'; // カスタム設定追加
path = '<?php echo PATH_UPLOAD_CLIENT . $user_id . '/'; ?>';
connector = 'connectors/php/connector.php';
url = oFCKeditor.BasePath + 'editor/filemanager/browser/default/browser.html';
oFCKeditor.Config['LinkBrowserURL'] = url + '?Connector=' + connector + '&ServerPath=' + path;
oFCKeditor.Config['ImageBrowserURL'] = url + '?Connector=' + connector + '&ServerPath=' + path + '&Type=Image';
oFCKeditor.Config['FlashBrowserURL'] = url + '?Connector=' + connector + '&ServerPath=' + path + '&Type=Flash';
url = oFCKeditor.BasePath + 'editor/filemanager/upload/php/upload.php';
oFCKeditor.Config['LinkUploadURL'] = url + '?ServerPath=' + path;
oFCKeditor.Config['ImageUploadURL'] = url + '?ServerPath=' + path + '&Type=Image';
oFCKeditor.Config['FlashUploadURL'] = url + '?ServerPath=' + path + '&Type=Flash';
oFCKeditor.ReplaceTextarea();
}

1件のコメント

  1. はじめましてFCKEDITOR設置で苦しんでおります。

    不要なボタンをはずすということでfckeditor.jsの

    中のtoolbar の設定のところのBasic customなどの

    ところをはずしても一向にはずれません。

    サーバーはlinux 言語はPHP で開発しております。

    もし対応して頂けるならご連絡お待ちしております。

    もうこれだけで1週間以上かかっています。

    ソースや環境などもお渡しします。

yukihiro へ返信する コメントをキャンセル

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

*

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください