Skip to content

Commit f94a603

Browse files
committed
Add strict mode and license declaration for bundlers
1 parent 0948e6d commit f94a603

File tree

10 files changed

+33
-10
lines changed

10 files changed

+33
-10
lines changed

code-input.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
/**
22
* **code-input** is a library which lets you create custom HTML `<code-input>`
33
* elements that act like `<textarea>` elements but support syntax-highlighted
4-
* code, implemented using any typical syntax highlighting library. [MIT-Licensed]
5-
*
4+
* code, implemented using any typical syntax highlighting library.
5+
*
6+
* License of whole library for bundlers:
7+
*
8+
* Copyright 2021-2025 Oliver Geer and contributors
9+
* @license MIT
10+
*
611
* **<https://github.com/WebCoder49/code-input>**
712
*/
13+
"use strict";
814

915

1016
var codeInput = {
@@ -121,7 +127,7 @@ var codeInput = {
121127
// Add waiting code-input elements wanting this template from queue
122128
if (templateName in codeInput.templateNotYetRegisteredQueue) {
123129
for (let i in codeInput.templateNotYetRegisteredQueue[templateName]) {
124-
elem = codeInput.templateNotYetRegisteredQueue[templateName][i];
130+
const elem = codeInput.templateNotYetRegisteredQueue[templateName][i];
125131
elem.template = template;
126132
codeInput.runOnceWindowLoaded((function(elem) { elem.connectedCallback(); }).bind(null, elem), elem);
127133
// Bind sets elem as first parameter of function
@@ -135,7 +141,7 @@ var codeInput = {
135141
// Add elements with default template from queue
136142
if (undefined in codeInput.templateNotYetRegisteredQueue) {
137143
for (let i in codeInput.templateNotYetRegisteredQueue[undefined]) {
138-
elem = codeInput.templateNotYetRegisteredQueue[undefined][i];
144+
const elem = codeInput.templateNotYetRegisteredQueue[undefined][i];
139145
elem.template = template;
140146
codeInput.runOnceWindowLoaded((function(elem) { elem.connectedCallback(); }).bind(null, elem), elem);
141147
// Bind sets elem as first parameter of function

plugins/auto-close-brackets.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* is activated for.
44
* Files: auto-close-brackets.js
55
*/
6+
"use strict";
7+
68
codeInput.plugins.AutoCloseBrackets = class extends codeInput.Plugin {
79
bracketPairs = [];
810
bracketsOpenedStack = []; // Each item [closing bracket string, opening bracket location] Innermost at right so can know which brackets should be ignored when retyped
@@ -58,4 +60,4 @@ codeInput.plugins.AutoCloseBrackets = class extends codeInput.Plugin {
5860
}
5961
}
6062
}
61-
}
63+
}

plugins/autocomplete.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Display a popup under the caret using the text in the code-input element. This works well with autocomplete suggestions.
33
* Files: autocomplete.js / autocomplete.css
44
*/
5+
"use strict";
6+
57
codeInput.plugins.Autocomplete = class extends codeInput.Plugin {
68
/**
79
* Pass in a function to create a plugin that displays the popup that takes in (popup element, textarea, textarea.selectionEnd).
@@ -85,4 +87,4 @@ codeInput.plugins.Autocomplete = class extends codeInput.Plugin {
8587
return {"top": afterSpan.offsetTop - textarea.scrollTop, "left": afterSpan.offsetLeft - textarea.scrollLeft};
8688
}
8789
updatePopupCallback = function() {};
88-
}
90+
}

plugins/autodetect.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* autodetect capabilities. Works with highlight.js only.
44
* Files: autodetect.js
55
*/
6+
"use strict";
7+
68
codeInput.plugins.Autodetect = class extends codeInput.Plugin {
79
constructor() {
810
super([]); // No observed attributes
@@ -25,4 +27,4 @@ codeInput.plugins.Autodetect = class extends codeInput.Plugin {
2527
codeInput.setAttribute("language", lang);
2628
}
2729
}
28-
}
30+
}

plugins/find-and-replace.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Add Find-and-Replace (Ctrl+F for find, Ctrl+H for replace by default) functionality to the code editor.
33
* Files: find-and-replace.js / find-and-replace.css
44
*/
5+
"use strict";
6+
57
codeInput.plugins.FindAndReplace = class extends codeInput.Plugin {
68
useCtrlF = false;
79
useCtrlH = false;

plugins/go-to-line.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* Add basic Go-To-Line (Ctrl+G by default) functionality to the code editor.
33
* Files: go-to-line.js / go-to-line.css
44
*/
5+
"use strict";
6+
57
codeInput.plugins.GoToLine = class extends codeInput.Plugin {
68
useCtrlG = false;
79

plugins/indent.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* possible to indent/unindent multiple lines using Tab/Shift+Tab
44
* Files: indent.js
55
*/
6+
"use strict";
7+
68
codeInput.plugins.Indent = class extends codeInput.Plugin {
79

810
bracketPairs = {}; // No bracket-auto-indentation used when {}

plugins/select-token-callbacks.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* gain a CSS class while selected, or trigger JavaScript callbacks.
44
* Files: select-token-callbacks.js
55
*/
6+
"use strict";
7+
68
codeInput.plugins.SelectTokenCallbacks = class extends codeInput.Plugin {
79
/**
810
* Set up the behaviour of tokens text-selected in the `<code-input>` element, and the exact definition of a token being text-selected.
@@ -286,4 +288,4 @@ codeInput.plugins.SelectTokenCallbacks.SelectedTokenState = class {
286288
endIndex -= childText.length;
287289
}
288290
}
289-
}
291+
}

plugins/special-chars.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Render special characters and control characters as a symbol with their hex code.
33
* Files: special-chars.js, special-chars.css
44
*/
5+
"use strict";
56

67
codeInput.plugins.SpecialChars = class extends codeInput.Plugin {
78
specialCharRegExp;
@@ -189,4 +190,4 @@ codeInput.plugins.SpecialChars = class extends codeInput.Plugin {
189190

190191
return width;
191192
}
192-
}
193+
}

plugins/test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* codeInput.registerTemplate("syntax-highlighted", codeInput.templates.hljs(hljs, [new codeInput.plugins.Test()]));
99
* ```
1010
*/
11+
"use strict";
12+
1113
codeInput.plugins.Test = class extends codeInput.Plugin {
1214
constructor() {
1315
super(["testattr"]);
@@ -33,4 +35,4 @@ codeInput.plugins.Test = class extends codeInput.Plugin {
3335
attributeChanged(codeInput, name, oldValue, newValue) {
3436
console.log(codeInput, name, ":", oldValue, ">", newValue);
3537
}
36-
}
38+
}

0 commit comments

Comments
 (0)