使い方
$("foo").insertAtCaret(text)
foo には、文字列を挿入したい textarea のセレクタを、引数 text に挿入したい文字列を設定します。
文字列はカーソル(キャレット)のある位置に挿入されるので、カーソルを置いてからボタンをクリックするなどのイベントと組み合わせて使います。
引数
text
挿入する文字列です。
サンプル
概要欄のラベル名の横に定型文というボタンを置き、そのボタンをクリックしたときに、カーソルのある位置に文字列が挿入されるようにする場合は、以下のようなコードを user.js に書きます。
$('#excerpt-label').after('<button id="mtapp-except-format-btn" class="button" style="margin-left: 3px;">定型文</button>');
$('#mtapp-except-format-btn').click(function(){
var text = "項目1 :
項目2 :
項目3 : ";
$('#excerpt').insertAtCaret(text);
return false;
});

なお、定型文のテキストは、以下のように mt:SetVarBlock タグを使えば、複数行の文字列でも簡単に設定することができます。
<mt:SetVarBlock name="formatStr">項目1 :
項目2 :
項目3 : </mt:SetVarBlock>
$('#excerpt-label').after('<button id="mtapp-except-format-btn" class="button" style="margin-left: 3px;">定型文</button>');
$('#mtapp-except-format-btn').click(function(){
$('#excerpt').insertAtCaret("<mt:Var name="formatStr" encode_js="1" />");
return false;
});