Skip to content

Commit

Permalink
adding menu back for annotations sample
Browse files Browse the repository at this point in the history
  • Loading branch information
akbarbmirza committed Dec 9, 2024
1 parent f7dbfcc commit 43898d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 15 additions & 5 deletions annotations/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,18 @@ function createAltTextAnnotations(selection, label) {
showAnnotationNotification(count, skipped);
}

if (figma.currentPage.selection.length) {
createAltTextAnnotations(figma.currentPage.selection);
} else {
createAltTextAnnotations([figma.currentPage]);
}
// runs plugin from menu commands
figma.on("run", ({ command }) => {
switch (command) {
case "all-images":
createAltTextAnnotations([figma.currentPage]);
figma.closePlugin();
break;
case "selection":
createAltTextAnnotations(figma.currentPage.selection);
figma.closePlugin();
default:
// do nothing
break;
}
});
6 changes: 5 additions & 1 deletion annotations/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"ui": "ui.html",
"networkAccess": {
"allowedDomains": ["none"]
}
},
"menu": [
{ "name": "Annotate images in selection", "command": "selection" },
{ "name": "Annotate all images on page", "command": "all-images" }
]
}

0 comments on commit 43898d6

Please sign in to comment.