V2.0 update

## Features 

### Open
* Now returns the activeDocument after opening the file.

### JSLayer()
* Removed semicolon from output.

### Document
* Added FullName() which returns path to the .psd file.
* Changed Filename() to DumpFile(), as Filename was misleading.
* Dump function now saves the file as well,
to help reduce the frequency of de-syncs.
* Dump function now saves json files alongside the .psds
instead of in a separate data folder- encountered issues when using
the package as a module in go 1.11beta2.
* Added Save()

## Testing
* Added TestDocument_Save
* Added TestDocument_Dump

## Misc.
* Renamed pkgpath to pkgPath, to better fit go's standards.

## Fixes
* DoAction now runs correctly.
This commit is contained in:
Spencer
2018-07-24 20:23:48 -04:00
committed by Unknown
parent 2f335aec00
commit bf5e4f9b99
13 changed files with 171 additions and 54 deletions

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"log"
"strings"
)
// TextItem holds the text element of a TextLayer.
@@ -62,7 +61,7 @@ func (t *TextItem) SetText(txt string) {
return
}
var err error
lyr := strings.TrimRight(JSLayer(t.parent.Path()), ";")
lyr := JSLayer(t.parent.Path())
bndtext := "[[' + lyr.bounds[0] + ',' + lyr.bounds[1] + '],[' + lyr.bounds[2] + ',' + lyr.bounds[3] + ']]"
js := fmt.Sprintf(`%s.textItem.contents='%s';var lyr = %[1]s;stdout.writeln(('%[3]s').replace(/ px/g, ''));`,
lyr, txt, bndtext)
@@ -87,7 +86,7 @@ func (t *TextItem) SetSize(s float64) {
if t.size == s {
return
}
lyr := strings.TrimRight(JSLayer(t.parent.Path()), ";")
lyr := JSLayer(t.parent.Path())
js := fmt.Sprintf("%s.textItem.size=%f;", lyr, s)
_, err := DoJS("compilejs.jsx", js)
if err != nil {