@stevekwak, here’s the case:
function createModify() {
const panel = document.createElement("panel");
let footer = document.createElement("footer");
panel.appendChild(footer);
let editButton = document.createElement("button");
editButton.textContent = "Modify";
editButton.onclick = async (e) => {
const value = await doAsync();
try {
require("application").editDocument(() => { scenegraph.root.pluginData = { value }; } );
} catch (ex) {
console.log("Failed", ex); // Failed [Error: Panel plugin edits must be initiated from a supported UI event]
}
};
footer.appendChild(editButton);
return panel;
}
function doAsync() {
return new Promise((resolve, reject) => {
setTimeout(() => { resolve("value"); }, 1000);
});
}