app.doScript(function(){
var KeepFormat=false;
var Delimiter="\r\r";
var Sel=app.activeDocument.selection;
var myDiag=app.dialogs.item("分割ペースト.jsx");
if (Sel.length==0) {
if (!myDiag.isValid) {
with (myDiag=app.dialogs.add({name:"分割ペースト.jsx"})){
with (dialogColumns.add()){
with (dialogRows.add()){
staticTexts.add({staticLabel:"区切り文字を入力"});
textEditboxes.add({editContents:"\\r\\r"});
}
staticTexts.add({staticLabel:"※改行は\\r 1行空きは\\r\\r タブは\\t \\は\\\\"});
}
}
}
if(!myDiag.show())exit();
with(myDiag.dialogColumns[0].dialogRows[0].textEditboxes[0]){
if (editContents=="") editContents="\\r\\r";
}
exit();
}
if (myDiag.isValid) {
Delimiter=eval("\""+myDiag.dialogColumns[0].dialogRows[0].textEditboxes[0].editContents+"\"");
}
var Sel0=app.activeDocument.selection[0];
if (!Sel0.hasOwnProperty("parentTextFrames")) exit();
var tempTF=app.activeDocument.textFrames.add();
var tempStory=tempTF.parentStory;
tempTF.insertionPoints[0].select();
app.paste();
if (tempStory.contents!=Delimiter) {
var n;
while ((n=tempTF.parentStory.contents.indexOf(Delimiter))==0){
tempStory.characters.itemByRange(0,Delimiter.length-1).getElements()[0].contents="";
}
if (n>-1) {
if (KeepFormat) {
tempStory.characters.itemByRange(0,n-1).duplicate(LocationOptions.AT_END,Sel0);
} else {
Sel0.contents=tempStory.characters.itemByRange(0,n-1).getElements()[0].contents;
}
tempStory.characters.itemByRange(0,n+Delimiter.length-1).getElements()[0].contents="";
if (tempStory.contents=="") tempStory.contents=Delimiter;
} else {
if (KeepFormat) {
tempStory.duplicate(LocationOptions.AT_END,Sel0);
} else {
Sel0.contents=tempStory.contents;
}
tempStory.contents=Delimiter;
}
tempStory.texts[0].select();
app.copy();
}
Sel0.select();
app.activeDocument.selection[0].insertionPoints.lastItem().select();
tempTF.remove();
},ScriptLanguage.JAVASCRIPT,[],UndoModes.ENTIRE_SCRIPT);
プロフィール
最近の記事