-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
Copy pathmain.js
39 lines (34 loc) · 1.06 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const {Rectangle, Color, Text, Artboard} = require("scenegraph");
const {alert} = require("./lib/dialogs.js");
const { appLanguage } = require("application");
const strings = require("./strings.json");
let selections = [];
async function selectTextsFunction(selection) {
selections = [];
for (let i = 0; i < selection.items.length; i++) {
let node = selection.items[i];
digIntoGroup(node);
}
selection.items = null;
selection.items = selections;
if (selections.length > 0) {
alert(strings[appLanguage].yay_title, selections.length + strings[appLanguage].yay_body);
} else {
alert(strings[appLanguage].whoops_title, [strings[appLanguage].whoops_body]);
}
}
function digIntoGroup(node) {
if (node.constructor.name === "Group") {
node.children.forEach(function (childNode) {
digIntoGroup(childNode);
});
}
if (node.constructor.name === "Text" && node) {
selections.push(node);
}
}
module.exports = {
commands: {
selectTexts: selectTextsFunction
}
};