Skip to content

Commit f1280a7

Browse files
committed
Release v2.6.7
1 parent dfae3fe commit f1280a7

File tree

3 files changed

+181
-2
lines changed

3 files changed

+181
-2
lines changed

docs/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Aiming to be [more <mark>flexible</mark>, <mark>lightweight</mark>,
1111
[HTML forms](interface/forms), the [`<textarea>` JavaScript interface](interface/js), more languages and
1212
more use cases.
1313

14-
*code-input.js is free, libre, open source software under the MIT (AKA Expat) license.* **Download it [from the Git repository](https://github.com/WebCoder49/code-input/tree/v2.6.6), [in a ZIP archive](/release/code-input-js-v2.6.6.zip), [in a TAR.GZ archive](/release/code-input-js-v2.6.6.tar.gz), or from `@webcoder49/code-input` on the NPM registry ([Yarn](https://yarnpkg.com/package?name=@webcoder49/code-input), [NPM](https://npmjs.com/package/@webcoder49/code-input), etc.).**
14+
*code-input.js is free, libre, open source software under the MIT (AKA Expat) license.* **Download it [from the Git repository](https://github.com/WebCoder49/code-input/tree/v2.6.7), [in a ZIP archive](/release/code-input-js-v2.6.7.zip), [in a TAR.GZ archive](/release/code-input-js-v2.6.7.tar.gz), or from `@webcoder49/code-input` on the NPM registry ([Yarn](https://yarnpkg.com/package?name=@webcoder49/code-input), [NPM](https://npmjs.com/package/@webcoder49/code-input), etc.).**
1515

1616
## Get Started with a Demo
1717

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@webcoder49/code-input",
3-
"version": "2.6.6",
3+
"version": "2.6.7",
44
"description": "An editable &lt;textarea&gt; that supports *any* syntax highlighting algorithm, for code or something else. Also, added plugins.",
55
"browser": "code-input.js",
66
"exports": {

tests/css.html

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>code-input should be global</title>
5+
6+
<meta charset="utf-8"/>
7+
8+
<!--Import Prism-->
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css">
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js" data-manual></script><!--Remove data-manual if also using Prism normally-->
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
12+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
13+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css">
14+
<script src="prism-match-braces-compatibility.js"></script>
15+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/match-braces/prism-match-braces.min.css">
16+
17+
<!--Import Highlight.JS-->
18+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
19+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/xml.min.js"></script>
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/css.min.js"></script>
22+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/javascript.min.js"></script>
23+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/python.min.js"></script>
24+
25+
26+
<!--Import code-input-->
27+
<link rel="stylesheet" href="../code-input.css">
28+
<script src="../code-input.js"></script>
29+
30+
<!--Import code-input plugins-->
31+
<script src="../plugins/auto-close-brackets.js"></script>
32+
<script src="../plugins/autocomplete.js"></script>
33+
<script src="../plugins/autodetect.js"></script>
34+
<link rel="stylesheet" href="../plugins/autocomplete.css">
35+
<script src="../plugins/find-and-replace.js"></script>
36+
<link rel="stylesheet" href="../plugins/find-and-replace.css">
37+
<script src="../plugins/go-to-line.js"></script>
38+
<link rel="stylesheet" href="../plugins/go-to-line.css">
39+
<script src="../plugins/indent.js"></script>
40+
<link rel="stylesheet" href="../plugins/prism-line-numbers.css">
41+
<script src="../plugins/select-token-callbacks.js"></script>
42+
<script src="../plugins/special-chars.js"></script>
43+
<link rel="stylesheet" href="../plugins/special-chars.css">
44+
45+
<!--Register templates-->
46+
<style>
47+
body > textarea, body > code-input {
48+
color: white;
49+
background: black;
50+
}
51+
</style>
52+
53+
</head>
54+
<body>
55+
<style>
56+
* {
57+
box-sizing: border-box;
58+
}
59+
</style>
60+
<textarea dir="rtl" placeholder="textarea rtl"></textarea>
61+
<textarea dir="ltr" placeholder="textarea ltr"></textarea>
62+
<code-input dir="rtl" template="prism" language="markdown"><textarea data-code-input-fallback placeholder="prism rtl"></textarea></code-input>
63+
<code-input dir="ltr" template="prism" language="markdown"><textarea data-code-input-fallback placeholder="prism ltr"></textarea></code-input>
64+
<code-input dir="rtl" template="hljs" language="markdown"><textarea data-code-input-fallback placeholder="hljs rtl"></textarea></code-input>
65+
<code-input dir="ltr" template="hljs" language="markdown"><textarea data-code-input-fallback placeholder="hljs ltr"></textarea></code-input>
66+
<code-input dir="rtl" template="prism+" language="markdown" class="line-numbers"><textarea data-code-input-fallback placeholder="prism rtl"></textarea></code-input>
67+
<code-input dir="ltr" template="prism+" language="markdown" class="line-numbers"><textarea data-code-input-fallback placeholder="prism ltr"></textarea></code-input>
68+
<code-input dir="rtl" template="hljs+" language="markdown"><textarea data-code-input-fallback placeholder="hljs rtl"></textarea></code-input>
69+
<code-input dir="ltr" template="hljs+" language="markdown"><textarea data-code-input-fallback placeholder="hljs ltr"></textarea></code-input>
70+
71+
<script>
72+
// codeInput.registerTemplate("hljs", new codeInput.templates.Hljs(hljs, []));
73+
// codeInput.registerTemplate("prism", new codeInput.templates.Prism(Prism, []));
74+
75+
// Attribution: Translated by Oliver Geer with some help from English Wiktionary
76+
let findAndReplaceTranslations = {
77+
start: "Buscar términos en su código.",
78+
none: "No hay sucesos",
79+
oneFound: "1 suceso encontrado.",
80+
matchIndex: (index, count) => `${index} de ${count} sucesos.`,
81+
error: (message) => `Error: ${message}`,
82+
infiniteLoopError: "Causa un ciclo infinito",
83+
closeDialog: "Cerrar el Diálogo y Regresar al Editor",
84+
findPlaceholder: "Buscar",
85+
findCaseSensitive: "Prestar atención a las minúsculas/mayúsculas",
86+
findRegExp: "Utilizar expresión regular de JavaScript",
87+
replaceTitle: "Reemplazar",
88+
replacePlaceholder: "Reemplazar con",
89+
findNext: "Buscar Suceso Próximo",
90+
findPrevious: "Buscar Suceso Previo",
91+
replaceActionShort: "Reemplazar",
92+
replaceAction: "Reemplazar este Suceso",
93+
replaceAllActionShort: "Reemplazar Todos",
94+
replaceAllAction: "Reemplazar Todos los Sucesos"
95+
};
96+
let goToLineTranslations = {
97+
closeDialog: "Cerrar el Diálogo y Regresar al Editor",
98+
input: "Línea:Columno o Línea luego Retorno",
99+
guidanceFormat: "Formato incorrecto. Ingresa un número de línea (por ej. 1) o un número de línea luego dos puntos luego un número de columno (por ej. 1:3).",
100+
guidanceLineRange: (current, max) => `Número de línea (actualmente ${current}) debería ser entre 1 y ${max}.`,
101+
guidanceColumnRange: (line, current, max) => `En la línea número ${line}, número de columno (actualmente ${current}) debería ser entre 1 y ${max}.`,
102+
guidanceValidLine: (line) => `Tecla Retorno para ir a línea número ${line}.`,
103+
guidanceValidColumn: (line, column) => `Tecla Retorno para ir a línea número ${line}, columno número ${column}.`,
104+
};
105+
let indentTranslations = {
106+
tabForIndentation: "Tabulador y Mayús-Tabulador actualmente para la indentación. Tecla Escape para activar la navegación por el teclado.",
107+
tabForNavigation: "Tabulador y Mayús-Tabulador actualmente para la navegación por el teclado. Tecla para activar la indentación.",
108+
};
109+
110+
codeInput.registerTemplate("hljs+", new codeInput.templates.Hljs(hljs, [
111+
new codeInput.plugins.AutoCloseBrackets(),
112+
new codeInput.plugins.Autocomplete(function(popupElem, textarea, selectionEnd) {
113+
if(textarea.value.substring(selectionEnd-5, selectionEnd) == "popup") {
114+
// Show popup
115+
popupElem.style.display = "block";
116+
popupElem.innerHTML = "Here's your popup!";
117+
} else {
118+
popupElem.style.display = "none";
119+
}
120+
}),
121+
new codeInput.plugins.Autodetect(),
122+
new codeInput.plugins.FindAndReplace(true, true, findAndReplaceTranslations),
123+
new codeInput.plugins.GoToLine(true, goToLineTranslations),
124+
new codeInput.plugins.Indent(true, 2, {"(": ")", "[": "]", "{": "}"}, true, indentTranslations),
125+
new codeInput.plugins.SelectTokenCallbacks(codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks.createClassSynchronisation("in-selection"), false, true, true, true, true, false),
126+
//new codeInput.plugins.SpecialChars(true),
127+
]));
128+
codeInput.registerTemplate("prism+", new codeInput.templates.Prism(Prism, [
129+
new codeInput.plugins.AutoCloseBrackets(),
130+
new codeInput.plugins.Autocomplete(function(popupElem, textarea, selectionEnd) {
131+
if(textarea.value.substring(selectionEnd-5, selectionEnd) == "popup") {
132+
// Show popup
133+
popupElem.style.display = "block";
134+
popupElem.innerHTML = "Here's your popup!";
135+
} else {
136+
popupElem.style.display = "none";
137+
}
138+
}),
139+
new codeInput.plugins.FindAndReplace(true, true, findAndReplaceTranslations),
140+
new codeInput.plugins.GoToLine(true, goToLineTranslations),
141+
new codeInput.plugins.Indent(true, 2, {"(": ")", "[": "]", "{": "}"}, true, indentTranslations),
142+
new codeInput.plugins.SelectTokenCallbacks(new codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks(selectBrace, deselectAllBraces), true),
143+
//new codeInput.plugins.SpecialChars(true),
144+
]));
145+
</script>
146+
147+
<script>
148+
rtl = `# ערך מומלץ ערך מומלץ
149+
150+
**לוטרת** הים היא יונק ימי קטן יחסית, חבר במשפחת הסמורים, שחי לחופיו הצפוניים והמזרחיים של האוקיינוס השקט.
151+
152+
ההגנה מפני קור אצל לוטרת הים מבוססת על שכבה עבה של פרווה, שהיא מהצפופות בעולם החי,
153+
וזאת בשונה ממרבית היונקים הימיים הנסמכים על שכבת שומן. CC-BY-SA he.wikipedia.org אף שהיא מסוגלת להלך על היבשה, מבלה לוטרת הים את מרבית זמנה באוקיינוס הפתוח.
154+
155+
# مقالة اليوم المختارة
156+
157+
**الواقعية في الأدب الإسبا**ني هي حركة أدبية شكلت جزءًا من الواقعية، وهو تيار ثقافي ظهر في أوروبا في منتصف القرن التاسع عشر عقب اضمحلال اتجاهات الرومانسية.
158+
159+
ظهر سابقًا في فرنسا سنة 1850 حيث تطورت أصوله التي كانت موجودة بالفعل في الرومانسية، وخصوصًا في الأدب الذي يتناول العادات والتقاليد. CC-BY-SA ar.wikipedia.org التي كانت تعج بكل ما هو خيالي وجمالي خلاب، وعمدوا إلى الملاحظة الموضوعية للأشخاص والمجتمع والأحداث المعاصرة في محاولة منهم إلى تقديم صورة واضحة للمجتمع آنذاك.`;
160+
ltr = `# From today's featured article
161+
162+
CC-BY-SA en.wikipedia.org: History is the systematic study of the past with its main focus on the human past.
163+
164+
Historians analyse and interpret primary and secondary sources to construct narratives about what happened and explain why it happened. RTL: مقالة اليوم المختارة They engage in source criticism to assess the authenticity, content, and reliability of these sources.
165+
166+
# निर्वाचित लेख
167+
168+
CC-BY-SA hi.wikipedia.org: **ग्लेशियर नेशनल पार्क** अमेरिकी राष्ट्रीय उद्यान है, जो कि कनाडा-संयुक्त राज्य अमेरिका की सीमा पर स्थित है। उद्यान संयुक्त राज्य के उत्तर-पश्चिमी मोंटाना राज्य
169+
170+
में स्थित है और कनाडा की ओर अल्बर्टा और ब्रिटिश कोलम्बिया प्रांतों से सटा हुआ है। उद्यान दस लाख एकड़ RTL: ערך מומלץ ערך מומלץ (4,000 किमी2) से अधिक क्षेत्र में फैला हुआ है और इसमें दो पर्वत श्रृंखला (रॉकी पर्वत की उप-श्रेणियाँ), 130 से अधिक नामित झीलें...`;
171+
const elems = document.querySelectorAll("body > code-input, body > textarea");
172+
for(let i = 0; i < elems.length; i++) {
173+
let dir = elems[i].getAttribute("dir");
174+
if(dir == "rtl") elems[i].value = rtl;
175+
else elems[i].value = ltr;
176+
}
177+
</script>
178+
</body>
179+
</html>

0 commit comments

Comments
 (0)