2009-03-17 15 views
4

私はFCKEditorを使用するサイトを持っています。私は信じられないほどシンプルなプラグインを作りたいと思っています。ユーザーがテキストを選択してからMyPluginIconを押すと、エディタは特定のクラスのスパンタグ内のテキストを囲みます。FCKEditor - 簡単なプラグインを作る方法?

だからそれだけで太字や斜体ボタンのようだが、用:

<span class="blah">EtcEtc</span>

私はJSの専門家から遠く離れていますので、プラグインがコピーするために私が探してきました。私はFCK wikiを見てきましたが、私が見つけたすべてのプラグインは本当に複雑です(ファイルブラウザなど)。 スーパーシンプル FCKプラグイン私は自分のプラグインをベースにすることができますか?

ありがとうございます!

答えて

5

自分の質問に答える!うまくいけば、将来誰かがこれを見つけたら助けになるだろう。

私はここからの基本的なファイル使用:私が見つけ-と-置き換え自分の名前の「netnoi」、およびアイコン(16×16)を作るために、アイコンの行をコメント解除 http://www.iondev.lu/fckeditor/netnoi.txt

を。

そしてここからそれをインストールする方法の手順: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Customization/Plug-ins

は、プラグインディレクトリが正しいことを確認してください - drupalの中でプラグインフォルダは、FCKは、デフォルトのインストールとは異なります。

編集:明らかにnetnoi.txtが欠落しています。ここに私が使ったものがあります:

/*** 
* Create blank command 
*/ 
var FCKPixelCaps_command = function() 
{ 

} 

/*** 
* Add Execute prototype 
*/ 
FCKPixelCaps_command.prototype.Execute = function() 
{ 
     // get whatever is selected in the FCKeditor window 
     var selection = FCK.EditorDocument.getSelection(); 

     // if there is a selection, add tags around it 
     if(selection.length > 0) 
     { 
       FCK.InsertHtml('<span class="caps">' + selection + '</span>'); 
     } else { 
       // for debugging reasons, I added this alert so I see if nothing is selected 
       alert('nothing selected'); 
     } 
} 

/*** 
* Add GetState prototype 
* - This is one of the lines I can't explain 
*/ 
FCKPixelCaps_command.prototype.GetState = function() 
{ 
     return; 
} 

// register the command so it can be use by a button later 
FCKCommands.RegisterCommand('PixelCaps_command' , new FCKPixelCaps_command()) ; 

/*** 
* Create the toolbar button. 
*/ 

// create a button with the label "Netnoi" that calls the netnoi_command 
var oPixelCaps = new FCKToolbarButton('PixelCaps_command', 'Pixels & Pulp Caps') ; 
oPixelCaps.IconPath = FCKConfig.PluginsPath + 'PixelCaps/caps.gif' ; 

// register the item so it can added to a toolbar 
FCKToolbarItems.RegisterItem('PixelCaps', oPixelCaps) ; 
+0

あなた自身で解決してうれしい! – Ascalonian

関連する問題