我使用了create-cep-extension,这是一个基于create-react-app的npm。它构建了可在任何Adobe CC应用程序中使用的自举扩展程序/面板。我在Adobe Premiere Pro(PPRO)中使用我的。我不知道如何将props传递给index.jsx中的函数。此jsx文件是Adobe的jsx,与react jsx文件无关,看起来也不像。我认为这基本上是javascript的旧版本。
我可以使用以下命令访问jsx文件并在其中运行代码:
loadExtendscript('./extendscript/index.jsx');
我无法以这种方式传递任何道具。
我还可以使用以下命令对PPRO执行通用jsx命令:
evalExtendscript('alert(app.version)')
这是我在实际的jsx文件中使用的典型命令,但同样我无法弄清楚如何访问index.jsx中的函数并将属性传递给它。
这是我要工作的代码:
main.js
let profileObj = {
message: 'ExendScript connected'
};
if (inCEPEnvironment()) {
evalExtendscript('parseObj(' + JSON.stringify(profileObj) + ')')
.then(result => alert(result))
.catch(error => alert(error))
}
index.jsx
function parseObj(obj){
alert(obj.message);
// alert('hello');
};
在过去的两周里,我尝试了所有我能想到的一切,但没有成功。
这里是create-cep-extension文档的链接,其中显示了“ evalExtendscript”和“ loadExtendscript”的示例: https://github.com/fusepilot/create-cep-extension
答案 0 :(得分:1)
您需要使用资源内的<ScriptPath>
标签在清单中添加jsx脚本路径:
<DispatchInfoList>
<Extension Id="com.your.extension.id">
<DispatchInfo >
<Resources>
<ScriptPath>./extendscript/index.jsx</ScriptPath>
然后,您可以访问index.jsx
内的所有文件和包含的文件:
var myParam1 = 25;
var myParam2 = 52;
evalScript(`myFunction(${myParam1}, ${myParam2})`)