需要帮助将 props 从 React 中的 js 文件传递到 jsx (adobe jsx) 文件



我使用了create-cep-extension,这是一个基于create-react-app构建的npm。它构建了一个可在任何Adobe CC应用程序中工作的引导扩展/面板。我在Adobe Premiere Pro(PPRO)中使用我的。我不知道如何将 props 传递给 index.jsx 中的函数。这个jsx文件是Adobe的jsx,它与反应jsx文件无关,看起来一点都不像。我认为它基本上是一个非常旧的javascript版本。

我可以访问 jsx 文件并使用以下命令运行其中的代码:

loadExtendscript('./extendscript/index.jsx');

不过,我不能以这种方式传递任何道具。

我还可以使用以下命令对 PPRO 执行通用 jsx 命令:

evalExtendscript('alert(app.version)')

这是我在实际的jsx文件中使用的典型命令,但我再次无法弄清楚如何访问index.jsx中的函数并将props传递给它。

这是我想使用的代码:

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

您需要在清单中添加 jsx 脚本路径,使用资源中的<ScriptPath>标记:

<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})`)

最新更新