I did my basic plugin code and If i select my plugin in XD it doesn’t show the panel UI and in developer console I see this " " . What am I missing ?
Here is my code :
const {
Text,
Color
} = require("scenegraph");
const fs = require("uxp").storage.localFileSystem;
async function bgImage() {
const {
selection
} = require(“scenegraph”);
const bgImg = await fs.getFileForOpening({
allowMultiple: true,
types: fileTypes.images
});
if (bgImg.length === 0) {
console.log(“please select an image”)
}
selection.insertionParent.addChild(bgImg);
bgImg.placeInParentCoordinates({
x: 0,
y: 0
}, selection.insertionParent.localCenterPoint);
return bgImg;
}
async function fgImage() {
const {
selection
} = require(“scenegraph”);
const fgImg = await fs.getFileForOpening({
allowMultiple: true,
types: fileTypes.images
});
if (fgImg.length === 0) {
console.log(“please select an image”)
}
selection.insertionParent.addChild(fgImg);
fgImg.placeInParentCoordinates({
x: 0,
y: 0
}, selection.insertionParent.localCenterPoint);
return fgImg;
}
async function createText(text, {
color = “blue”
} = {}) {
const {
selection
} = require(“scenegraph”);
const newText = new Text();
newText.text = text;
newText.fill = new Color(color);
selection.insertionParent.addChild(newText);
newText.placeInParentCoordinates({
x: 0,
y: 0
}, selection.insertionParent.localCenterPoint);
return newText;
}
let panel;
function create() {
const HTML = < style > #title {
font - size: 14 px;
font - weight: Bold;
}.break {
flex - wrap: wrap;
}
label.row > * {
margin: auto;margin - bottom: 10 px;
}
label.row > span {
color: #8E8E8E; width: auto; text-align: left; font-size: 9px; } label.row input { flex: 1 1 auto; } label.row input[type= number] {
flex - basis: 32 px;
}
label.row input[type = text] {
flex - basis: 32 px;
}
div input[type = checkbox] {
flex: 0 0 20 px;
}
form footer > * {
position: relative;left: 8 px;
} < /style> <form method="dialog" id="main"> <label class="row" id="title"> <span font-size="20px">Quick Parallax</span > < /label> </br > < div class = "row break" > < label class = "row"
id = "bg" > < span > Select Background < /span> <button id="bg-b" type="submit" uxp-variant="cta">Select</button > < /label> </br > < div class = "row break" > < label class = "row"
id = "fg" > < span > Select Foreground < /span> <button id="fg-b" type="submit" uxp-variant="cta">Select</button > < /label> </br > < div class = "row break" > < label class = "row"
id = "txt" > < span > Foreground Text < /span> <input type="text" uxp-quiet="true" id="txt_bx" value="" placeholder=""/ > < /label> </br > < /div> </div > < footer > < button id = "ok"
type = "submit"
uxp - variant = "cta" > Create < /button> <button id="cancel" type="submit" uxp-variant="cta" background-color:"#E54C4C" >Cancel</button > < /footer> </form > ;
panel = document.createElement(“div”);
panel.innerHTML = HTML;
panel.querySelector("#bg-b").addEventListener(bgImage);
panel.querySelector("#fg-b").addEventListener(fgImage);
panel.querySelector(“ok”).addEventListener(createText);
return panel;
}
function show(event) {
// create panel the first time it’s shown
if (!panel) {
panel = create();
event.node.appendChild(panel);
}
}
function hide(event) {
// in this example, we don’t need to do anything when XD hides our panel
}
function update(selection, root) {
console.log(selection.items);
}
module.exports = {
panels: {
Name: {
show,
hide,
update
}
}
};