日本語情報が少なかったのでまとめました。
https://itunes.apple.com/jp/app/textexpander-3-+-custom-keyboard/id917416298?mt=8&uo=4&at=11lqq9
基本的には最後に書いた文が展開されます。
"Java" + "Script" + " result";
TextExpander.appendOutput()を使うと複数回に分けて出力結果に追加できます。
TextExpander.appendOutput("Java");
TextExpander.appendOutput("Script");
TextExpander.appendOutput(" result");
TextExpanderオブジェクトのプロパティ
TextExpanderオブジェクトにはappendOutputの他にもプロパティがあります。*1
参考:Working With AppleScript and Shell Script Snippets – TextExpander
appendOutput
先述の通り、出力結果に追加します。
ignoreOutput
出力結果に何も出力したくない場合trueを設定します(初期値はfalse)。
例えば時刻を設定するだけのスニペットを作りたい場合などに使えます。
TextExpander.ignoreOutput = true
triggeringAbbreviation
Abbreviation(スニペット名、スニペット編集画面の上側に入力する展開元文字列)を取得します。
TextExpander.triggeringAbbreviation;
baseDate
展開した時点での日時を取得します。
TextExpander.baseDate;
またDate型のメソッドが使えます。
TextExpander.baseDate.getFullYear();
adjustedDate
マクロの日時を設定します(初期値はbaseDate)
TextExpander.adjustedDate = (new Date()).setDate(TextExpander.baseDate.getDate() + 3);
'%Y.%m.%d';
またスニペットのネストを利用すると他のスニペットで利用できます。
TextExpander.adjustedDate = (new Date()).setDate(TextExpander.baseDate.getDate() + 3);
TextExpander.ignoreOutput = true;
として他のスニペットで
%snippet:3Dadd% %Y.%m.%d
を登録すると展開結果が2015.01.04となります。
pasteboardText
ペーストボードの文字列を取得します。
TextExpander.pasteboardText;
expansionContext
スニペットが展開されたアプリケーションのbundle identifierを取得します。
TextExpander.expansionContext;
filledValues
fill-inで入力された値を取得します。
a = '%filltext:name=hoge%';
TextExpander.filledValues['hoge'];
使用可能なオブジェクト
Working With AppleScript and Shell Script Snippets – TextExpanderによると、OS XではJavaScriptを拡張したJavaScript for Automation (JSA)が使えますが、iOSではPlain old JavaScriptだけだそうです。
具体的にどんなオブジェクトが使えるか判然としなかった調べました。
Object.getOwnPropertyNames(this).sort();
Array,ArrayBuffer,Boolean,DataView,Date,Error,EvalError,Float32Array,Float64Array,Function,Infinity,Int16Array,Int32Array,Int8Array,JSON,Map,Math,NaN,Number,Object,Promise,RangeError,ReferenceError,RegExp,Set,String,SyntaxError,TextExpander,TypeError,URIError,Uint16Array,Uint32Array,Uint8Array,Uint8ClampedArray,WeakMap,console,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,escape,eval,isFinite,isNaN,parseFloat,parseInt,undefined,unescape
文字列操作、数学関数、正規表現、URLエンコードなどローカルで行いたい処理はおおよそ可能です。
一方、windowやXMLHttpRequestなどWEB系のオブジェクトは使えないので外部との通信を行うのは無理そうです。