HendrixString / adobe-cep-react-create

Create Adobe-CEP extension with React, Material-UI, Native Node modules, Webpack, Babel and ExtendScript
Apache License 2.0
125 stars 27 forks source link

How do you use CSinterface file ? #2

Closed jieliu218 closed 5 years ago

HendrixString commented 5 years ago

hi @jieliu218 , the file is being loaded on startup. look at the session-src folder as one of the managers use it

Yiddishe-Kop commented 5 years ago

Hi (from Jerusalem 🖐)! I'm building a CEP panel for InDesign with React. So far everything is working amazing. But I can't find a way to access CSinterface from React. I saw you did manange, but how?

Thanks! תודה רבה!!!

HendrixString commented 5 years ago

@newgraph hi,

you just have to instantiate it from wherever you like:

var interface = new CSInterface()

also see, https://github.com/HendrixString/adobe-cep-react-create/blob/master/src/session-src/src/ScriptLoader.js#L12

this is accessible via the Session object

Yiddishe-Kop commented 5 years ago

you just have to instantiate it from wherever you like:

That doesn't work - React throws a build error 'CSInterface' is not defined.

I got around this issue by adding the CSInterface object to the global window object, so it is accessible from within the React app. Probably not the most legitimate way... but it works...

HendrixString commented 5 years ago

a build or runtime error ? CSInterface.js is included in the main html file and therefore should be fine for usage. I do use it inside the session object. basically, it works for me when used and tested inside the adobe product. I do recommend using the version I published as it also gives you infrastructure for evaluating host jsx files for adobe products.