Skip to content

Commit 3d38a64

Browse files
committed
Add plugins (2)
1 parent adeccc3 commit 3d38a64

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

plugins/autodetect.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
codeInput.plugins.Test = class extends codeInput.Plugin {
2+
/* Runs before code is highlighted; Params: codeInput element) */
3+
beforeHighlight(codeInput) {
4+
console.log(codeInput, "before highlight");
5+
}
6+
/* Runs after code is highlighted; Params: codeInput element) */
7+
afterHighlight(codeInput) {
8+
console.log(codeInput, "after highlight");
9+
}
10+
/* Runs before elements are added into a `code-input`; Params: codeInput element) */
11+
beforeElementsAdded(codeInput) {
12+
console.log(codeInput, "before elements added");
13+
}
14+
/* Runs after elements are added into a `code-input` (useful for adding events to the textarea); Params: codeInput element) */
15+
afterElementsAdded(codeInput) {
16+
console.log(codeInput, "after elements added");
17+
}
18+
/* Runs when an attribute of a `code-input` is changed (you must add the attribute name to observedAttributes); Params: codeInput element, name attribute name, oldValue previous value of attribute, newValue changed value of attribute) */
19+
attributeChanged(codeInput, name, oldValue, newValue) {
20+
if(name == "testattr") {
21+
console.log(codeInput, "testattr:", oldValue, ">", newValue);
22+
}
23+
}
24+
observedAttributes = ["testattr"]
25+
}

plugins/test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
codeInput.plugins.Test = class extends codeInput.Plugin {
2+
/* Runs before code is highlighted; Params: codeInput element) */
3+
beforeHighlight(codeInput) {
4+
console.log(codeInput, "before highlight");
5+
}
6+
/* Runs after code is highlighted; Params: codeInput element) */
7+
afterHighlight(codeInput) {
8+
console.log(codeInput, "after highlight");
9+
}
10+
/* Runs before elements are added into a `code-input`; Params: codeInput element) */
11+
beforeElementsAdded(codeInput) {
12+
console.log(codeInput, "before elements added");
13+
}
14+
/* Runs after elements are added into a `code-input` (useful for adding events to the textarea); Params: codeInput element) */
15+
afterElementsAdded(codeInput) {
16+
console.log(codeInput, "after elements added");
17+
}
18+
/* Runs when an attribute of a `code-input` is changed (you must add the attribute name to observedAttributes); Params: codeInput element, name attribute name, oldValue previous value of attribute, newValue changed value of attribute) */
19+
attributeChanged(codeInput, name, oldValue, newValue) {
20+
if(name == "testattr") {
21+
console.log(codeInput, "testattr:", oldValue, ">", newValue);
22+
}
23+
}
24+
observedAttributes = ["testattr"]
25+
}

0 commit comments

Comments
 (0)