Can Adobe .jsx scripts include other script files?

前端 未结 4 1213
猫巷女王i
猫巷女王i 2021-01-06 10:46

We\'re writing a bunch of .jsx scripts and in each I have to mock out some functions so I can use things like Array.map() and String.trim(), but I don\'t want to have to inc

4条回答
  •  忘掉有多难
    2021-01-06 11:09

    We're now using the $ helper available in Illustrator, and the $.evalFile() method. Pass it a path and it will evaluate the file and return the result.

    I created a little helper that I can include (minified, of course) at the top of my .jsx scripts so I can do Libraries.include("my-other-script") that will include, in my case, a file that's in my adobe_scripts root folder, in a directory called lib.

    // indexOf polyfill from https://gist.github.com/atk/1034425
    [].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b

    Minified version that I include:

    /**
     * Libraries.include(path) -- path must be relative to adobe_scripts/lib/
     * See: https://gist.github.com/jasonrhodes/5286526
     */
    [].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b

    See gist here: https://gist.github.com/jasonrhodes/5286526

提交回复
热议问题