Last active
March 14, 2018 21:48
-
-
Save undavide/258a87a0359a3f9c9eb00f265a2df5e5 to your computer and use it in GitHub Desktop.
Passing a JSON string from the JSX back to the panel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JS file (panel) | |
// ... | |
csInterface.evalScript('getDocumentInfo()', function(res) { | |
var resObj = JSON.parse(res); | |
// you have now access to the same docInfo object | |
}); | |
// JSX file (Photoshop) | |
function getDocumentInfo() { | |
//... I just make up data here... | |
var docInfo = { | |
numberOfLayers : 4, | |
layerNames : ['Background', 'Curves 1', 'Retouch', 'Curves 2'], | |
colors : { | |
background : '#828282', | |
foreground : '#7d2555' | |
} | |
} | |
return JSON.stringify(docInfo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment