Skip to content

Commit 3cbc49d

Browse files
committed
applied biome and changed ci
1 parent 2e7f704 commit 3cbc49d

File tree

24 files changed

+604
-524
lines changed

24 files changed

+604
-524
lines changed

.github/workflows/validate-structure.yml renamed to .github/workflows/validate-plugins.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Validate Folder Structure
1+
name: Validate Plugins
22

33
on:
44
push:
@@ -7,7 +7,8 @@ on:
77
branches: ["**"]
88

99
jobs:
10-
check-structure:
10+
validate-structure:
11+
name: Validate File Structure
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout Repository
@@ -20,3 +21,17 @@ jobs:
2021

2122
- name: Run Folder Structure Check
2223
run: node validate-structure.mjs
24+
linting:
25+
name: Linting
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Biome
32+
uses: biomejs/setup-biome@v2
33+
with:
34+
version: latest
35+
36+
- name: Run Biome
37+
run: biome ci .

manifest.json

+66-66
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
[
2-
{
3-
"title": "Bulk labeling for text spans",
4-
"description": "Assigns labels to all occurrences of the selected text at once",
5-
"path": "bulk-labeling",
6-
"private": false
7-
},
8-
{
9-
"title": "Text area word count",
10-
"description": "Validates the length of a text area based on its word count",
11-
"path": "count-words-in-textarea",
12-
"private": false
13-
},
14-
{
15-
"title": "Connect to LLM backend",
16-
"description": "Sends prompts to an LLM URL",
17-
"path": "llm-backend",
18-
"private": false
19-
},
20-
{
21-
"title": "Markdown to HTML",
22-
"description": "Converts markdown to HTML format",
23-
"path": "markdown-to-html",
24-
"private": false
25-
},
26-
{
27-
"title": "Text span overlap validation",
28-
"description": "Prevents overlap of text spans",
29-
"path": "ner-text-span-overlap-validation",
30-
"private": false
31-
},
32-
{
33-
"title": "Spam and bot detection",
34-
"description": "Pauses an annotator if bot behavior in detected",
35-
"path": "pausing-annotator",
36-
"private": false
37-
},
38-
{
39-
"title": "Data visualization",
40-
"description": "Display a Plotly chart to annotators",
41-
"path": "plotly",
42-
"private": false
43-
},
44-
{
45-
"title": "Redact annotator PII",
46-
"description": "Anonymize the annotator to reduce bias",
47-
"path": "redact-pii",
48-
"private": false
49-
},
50-
{
51-
"title": "Dynamic image swap",
52-
"description": "Changes active image based on conditions",
53-
"path": "different-images-per-label",
54-
"private": false
55-
},
56-
{
57-
"title": "Spellcheck",
58-
"description": "Validates misspelled text",
59-
"path": "spellcheck",
60-
"private": false
61-
},
62-
{
63-
"title": "Validate JSON",
64-
"description": "Checks that the introduced text is a valid JSON",
65-
"path": "validate-json-in-textarea",
66-
"private": false
67-
}
2+
{
3+
"title": "Bulk labeling for text spans",
4+
"description": "Assigns labels to all occurrences of the selected text at once",
5+
"path": "bulk-labeling",
6+
"private": false
7+
},
8+
{
9+
"title": "Text area word count",
10+
"description": "Validates the length of a text area based on its word count",
11+
"path": "count-words-in-textarea",
12+
"private": false
13+
},
14+
{
15+
"title": "Connect to LLM backend",
16+
"description": "Sends prompts to an LLM URL",
17+
"path": "llm-backend",
18+
"private": false
19+
},
20+
{
21+
"title": "Markdown to HTML",
22+
"description": "Converts markdown to HTML format",
23+
"path": "markdown-to-html",
24+
"private": false
25+
},
26+
{
27+
"title": "Text span overlap validation",
28+
"description": "Prevents overlap of text spans",
29+
"path": "ner-text-span-overlap-validation",
30+
"private": false
31+
},
32+
{
33+
"title": "Spam and bot detection",
34+
"description": "Pauses an annotator if bot behavior in detected",
35+
"path": "pausing-annotator",
36+
"private": false
37+
},
38+
{
39+
"title": "Data visualization",
40+
"description": "Display a Plotly chart to annotators",
41+
"path": "plotly",
42+
"private": false
43+
},
44+
{
45+
"title": "Redact annotator PII",
46+
"description": "Anonymize the annotator to reduce bias",
47+
"path": "redact-pii",
48+
"private": false
49+
},
50+
{
51+
"title": "Dynamic image swap",
52+
"description": "Changes active image based on conditions",
53+
"path": "different-images-per-label",
54+
"private": false
55+
},
56+
{
57+
"title": "Spellcheck",
58+
"description": "Validates misspelled text",
59+
"path": "spellcheck",
60+
"private": false
61+
},
62+
{
63+
"title": "Validate JSON",
64+
"description": "Checks that the introduced text is a valid JSON",
65+
"path": "validate-json-in-textarea",
66+
"private": false
67+
}
6868
]

plugins/bulk-labeling/data.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"data": {
3-
"text": [
4-
"Opossums, commonly known as possums in North America, are marsupials found primarily in the Americas. The most well-known species is the Virginia opossum (Didelphis virginiana), which ranges from Central America and the eastern United States to southern Canada. These adaptable creatures are known for their ability to thrive in a variety of environments, including both rural and urban areas. Opossums are also found in South America, where different species inhabit a range of ecosystems, from tropical rainforests to temperate forests.",
5-
"Opossums are highly adaptable in terms of habitat, often residing in woodlands, farmland, and even suburban backyards. They typically seek shelter in hollow trees, abandoned burrows, or any dark, enclosed space they can find. Opossums are nocturnal and omnivorous, with a diet that includes fruits, insects, small animals, and even carrion. Their opportunistic feeding habits contribute to their resilience and ability to live in close proximity to human settlements.",
6-
"In terms of behavior, opossums are solitary and nomadic, often moving to different locations in search of food. They are known for their unique defense mechanism of 'playing dead' or 'playing possum' when threatened, which involves mimicking the appearance and smell of a sick or dead animal to deter predators. Opossums have relatively short lifespans, typically living only 2 to 4 years in the wild. Despite their short lives, they reproduce quickly, with females giving birth to large litters of up to 20 young, although not all offspring typically survive to maturity.",
7-
"In popular culture, opossums often appear as symbols of resilience and survival due to their hardy nature and ability to adapt to various environments. They are sometimes depicted in a comical or misunderstood light, given their nocturnal habits and somewhat disheveled appearance. Despite this, they play a crucial role in the ecosystem by controlling insect and rodent populations and cleaning up carrion. Opossums have been featured in various forms of media, from cartoons and children's books to movies, often emphasizing their unique behaviors and survival strategies."
8-
]
9-
}
2+
"data": {
3+
"text": [
4+
"Opossums, commonly known as possums in North America, are marsupials found primarily in the Americas. The most well-known species is the Virginia opossum (Didelphis virginiana), which ranges from Central America and the eastern United States to southern Canada. These adaptable creatures are known for their ability to thrive in a variety of environments, including both rural and urban areas. Opossums are also found in South America, where different species inhabit a range of ecosystems, from tropical rainforests to temperate forests.",
5+
"Opossums are highly adaptable in terms of habitat, often residing in woodlands, farmland, and even suburban backyards. They typically seek shelter in hollow trees, abandoned burrows, or any dark, enclosed space they can find. Opossums are nocturnal and omnivorous, with a diet that includes fruits, insects, small animals, and even carrion. Their opportunistic feeding habits contribute to their resilience and ability to live in close proximity to human settlements.",
6+
"In terms of behavior, opossums are solitary and nomadic, often moving to different locations in search of food. They are known for their unique defense mechanism of 'playing dead' or 'playing possum' when threatened, which involves mimicking the appearance and smell of a sick or dead animal to deter predators. Opossums have relatively short lifespans, typically living only 2 to 4 years in the wild. Despite their short lives, they reproduce quickly, with females giving birth to large litters of up to 20 young, although not all offspring typically survive to maturity.",
7+
"In popular culture, opossums often appear as symbols of resilience and survival due to their hardy nature and ability to adapt to various environments. They are sometimes depicted in a comical or misunderstood light, given their nocturnal habits and somewhat disheveled appearance. Despite this, they play a crucial role in the ecosystem by controlling insect and rodent populations and cleaning up carrion. Opossums have been featured in various forms of media, from cartoons and children's books to movies, often emphasizing their unique behaviors and survival strategies."
8+
]
9+
}
1010
}

plugins/bulk-labeling/plugin.js

+26-18
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@
33
*/
44

55
// It will be triggered when a text selection happens
6-
LSI.on('entityCreate', region => {
7-
if (window.BULK_REGIONS) return;
6+
LSI.on("entityCreate", (region) => {
7+
if (window.BULK_REGIONS) return;
88

9-
window.BULK_REGIONS = true;
10-
setTimeout(() => window.BULK_REGIONS = false, 1000);
9+
window.BULK_REGIONS = true;
10+
setTimeout(() => (window.BULK_REGIONS = false), 1000);
1111

12-
setTimeout(() => {
13-
// Find all the text regions matching the selection
14-
region.object._value.matchAll(new RegExp(region.text, "gi")).forEach(m => {
15-
if (m.index === region.startOffset) return;
12+
setTimeout(() => {
13+
// Find all the text regions matching the selection
14+
region.object._value
15+
.matchAll(new RegExp(region.text, "gi"))
16+
.forEach((m) => {
17+
if (m.index === region.startOffset) return;
1618

17-
// Include them in the results as new selections
18-
Htx.annotationStore.selected.createResult(
19-
{ text: region.text, start: "/span[1]/text()[1]", startOffset: m.index, end: "/span[1]/text()[1]", endOffset: m.index + region.text.length },
20-
{ labels: [...region.labeling.value.labels] },
21-
region.labeling.from_name,
22-
region.object,
23-
)
24-
})
25-
Htx.annotationStore.selected.updateObjects()
26-
}, 100);
19+
// Include them in the results as new selections
20+
Htx.annotationStore.selected.createResult(
21+
{
22+
text: region.text,
23+
start: "/span[1]/text()[1]",
24+
startOffset: m.index,
25+
end: "/span[1]/text()[1]",
26+
endOffset: m.index + region.text.length,
27+
},
28+
{ labels: [...region.labeling.value.labels] },
29+
region.labeling.from_name,
30+
region.object,
31+
);
32+
});
33+
Htx.annotationStore.selected.updateObjects();
34+
}, 100);
2735
});
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"data": {
3-
"text": "The quick brown fox jumps over the lazy dog."
4-
}
2+
"data": {
3+
"text": "The quick brown fox jumps over the lazy dog."
4+
}
55
}

plugins/count-words-in-textarea/plugin.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55
let dismissed = false;
66

77
LSI.on("beforeSaveAnnotation", (store, annotation) => {
8-
const textAreaResult = annotation.results.find(r => r.type === 'textarea' && r.from_name.name === 'textarea');
8+
const textAreaResult = annotation.results.find(
9+
(r) => r.type === "textarea" && r.from_name.name === "textarea",
10+
);
911

10-
if (textAreaResult) {
11-
words = textAreaResult.value.text[0]
12-
word_count = words.split(" ").length;
12+
if (textAreaResult) {
13+
words = textAreaResult.value.text[0];
14+
word_count = words.split(" ").length;
1315

14-
if (word_count > 10) {
15-
Htx.showModal("Word count is " + word_count + ". Please reduce to 10 or less.");
16-
dismissed = true;
17-
return false; // Block submission
18-
}
19-
}
16+
if (word_count > 10) {
17+
Htx.showModal(
18+
"Word count is " + word_count + ". Please reduce to 10 or less.",
19+
);
20+
dismissed = true;
21+
return false; // Block submission
22+
}
23+
}
2024

21-
return true; // Allow submission
25+
return true; // Allow submission
2226
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"data": {
3-
"image": "/static/plugins/different-images-per-label/img/demo-sample.png"
4-
}
2+
"data": {
3+
"image": "/static/plugins/different-images-per-label/img/demo-sample.png"
4+
}
55
}

plugins/different-images-per-label/plugin.js

+34-32
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,48 @@
33
* depending on the class label selected
44
*/
55

6-
const IMG_ID = 'img_uniq'
6+
const IMG_ID = "img_uniq";
77
// TODO: use your own keys and values here for label lookup and data objects to display
8-
const imagesRoot = '/static/plugins/different-images-per-label/img'
8+
const imagesRoot = "/static/plugins/different-images-per-label/img";
99
const images = {
10-
'Addressee': `${imagesRoot}/demo-addressee.jpg`,
11-
'Account number': `${imagesRoot}/demo-routing-number.png`,
12-
'Routing number': `${imagesRoot}/demo-routing-number.png`,
13-
'Signature': `${imagesRoot}/demo-sign.jpg`,
14-
'Amount': `${imagesRoot}/demo-amount.jpg`,
15-
'Watermark': `${imagesRoot}/demo-watermark.png`,
16-
'Date': `${imagesRoot}/demo-date.png`,
17-
'Correction': `${imagesRoot}/demo-correction.jpg`,
18-
}
10+
Addressee: `${imagesRoot}/demo-addressee.jpg`,
11+
"Account number": `${imagesRoot}/demo-routing-number.png`,
12+
"Routing number": `${imagesRoot}/demo-routing-number.png`,
13+
Signature: `${imagesRoot}/demo-sign.jpg`,
14+
Amount: `${imagesRoot}/demo-amount.jpg`,
15+
Watermark: `${imagesRoot}/demo-watermark.png`,
16+
Date: `${imagesRoot}/demo-date.png`,
17+
Correction: `${imagesRoot}/demo-correction.jpg`,
18+
};
1919

2020
function appendCheckImg() {
21-
let imageEl = window[IMG_ID]
22-
if (!imageEl) {
23-
imageEl = document.createElement('img');
24-
imageEl.id = IMG_ID
21+
let imageEl = window[IMG_ID];
22+
if (!imageEl) {
23+
imageEl = document.createElement("img");
24+
imageEl.id = IMG_ID;
2525

26-
const labelingInterface = document.querySelector('.lsf-main-view__annotation');
27-
if (labelingInterface) {
28-
labelingInterface.insertAdjacentElement('beforeend', imageEl);
29-
} else {
30-
console.error('Labeling interface element not found.');
31-
}
32-
}
26+
const labelingInterface = document.querySelector(
27+
".lsf-main-view__annotation",
28+
);
29+
if (labelingInterface) {
30+
labelingInterface.insertAdjacentElement("beforeend", imageEl);
31+
} else {
32+
console.error("Labeling interface element not found.");
33+
}
34+
}
3335

34-
// `label` is an actual tag name from config
35-
const labels = LSI.annotation.names.get('label').children
36+
// `label` is an actual tag name from config
37+
const labels = LSI.annotation.names.get("label").children;
3638

37-
// If you will have more Labels in a future adjust the logic
38-
document.querySelectorAll('.lsf-label_clickable').forEach(
39-
(lbl, index) => lbl.addEventListener('click', () => {
40-
const src = images[labels[index].value]
39+
// If you will have more Labels in a future adjust the logic
40+
document.querySelectorAll(".lsf-label_clickable").forEach((lbl, index) =>
41+
lbl.addEventListener("click", () => {
42+
const src = images[labels[index].value];
4143

42-
// if there are no images with this key image will just have an empty src
43-
imageEl.src = src
44-
})
45-
)
44+
// if there are no images with this key image will just have an empty src
45+
imageEl.src = src;
46+
}),
47+
);
4648
}
4749

4850
appendCheckImg();

0 commit comments

Comments
 (0)