新版脚本修改

经验创意 · 326 次浏览
失落叶子云养猫 创建于 2022-04-30 12:58

if (activeDocument.selection[0].contents.indexOf("\n") != -1) {

} else {
    var lineArr = fieldToArray(activeDocument.selection[0]);
    tfTop = activeDocument.selection[0].top;
    tfLeft = activeDocument.selection[0].left;
    activeDocument.selection[0].contents = lineArr[0];
    var tr = activeDocument.selection[0].story.textRange;
    var vSpacing = tr.leading;
    for (var j = 1; j < lineArr.length; j += 1) {
        bob = activeDocument.selection[0].duplicate(activeDocument, ElementPlacement.PLACEATBEGINNING);
        bob.contents = lineArr[j];
        bob.top = tfTop - (vSpacing * j);
        bob.left = tfLeft;
        bob.selected = false;
    }
}

function fieldToArray(myField) {
    if (myField.typename == "TextFrame") {
        retChars = new Array("", "", "\r", "\n");
        var ct = 0;
        var tmpTxt = myField.contents.toString();
        for (var all in retChars) {
            tmpArr = tmpTxt.split(retChars[all]);
            ct += tmpArr.length;
        }
        ct += 1;
        while (ct > 0) {
            tmpTxt = tmpTxt.replace(/[\x03]|[\f]|[\r\n]|[\r]|[\n]/, "_:X:_");
            ct--;
        }
        return tmpTxt.split("_:X:_");
    }
}


回复内容
暂无回复
回复主贴