I happen to be writing an example answering this very question for the 2nd edition of Professional Photoshop Scripting" (shameless ) like exactly now, this afternoon
You have your manifest with multiple objects in the entrypoints
array, right? They all have their own id
, let’s say for simplicity three of them: "pFirst"
, "pSecond"
, and "pThird"
.
At this point, add to index.html
three wrapper <div>
s, each one with the content for a panel. Give them id
s (except the first one, which doesn’t need it). They don’t need to match the ones in the Manifest, but it’s easier.
<body>
<div id="pFirst"> <!-- Panel 1 stuff --> <div>
<div id="pSecond"> <!-- Panel 2 stuff --> <div>
<div id="pThird"> <!-- Panel 3 stuff --> <div>
</body>
Cool. In main.js
, add the entrypoints.setup()
const { entrypoints } = require("uxp");
entrypoints.setup({
// Object containing Panels
panels: {
"pFirst": { // <- must match the manifest id for panel #1
// Lifecycle events
show(body) {
let content = document.querySelector("pFirst");
body.appendChild(content);
},
},
"pSecond": { // <- must match the manifest id for panel #2
// Lifecycle events
show(body) {
let content = document.querySelector("pSecond");
body.appendChild(content);
},
},
"pThird": { // <- must match the manifest id for panel #3
// Lifecycle events
show(body) {
let content = document.querySelector("pThird");
body.appendChild(content);
},
},
});
This links distributes, so to speak, the content from index.html
into the three panels.
Please note, the hide()
lifecycle callback doesn’t work at all, and show()
only fires once at creation, hence there are no concerns about appending duplicate content—otherwise you should removeChild()
in the hide()
.
Bonus: actually, the first show()
is not needed, the 1st panel will load its content anyway according to my tests.
Hope this helps!
(there’s more in the , double )
Cheers,
—Davide