athena-ui-js 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -3
- package/docs/styling.md +123 -103
- package/package.json +8 -1
- package/src/athena-ui.js +5 -1
- package/src/code.js +9 -0
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/codeDiff.js +119 -0
- package/src/libs/core/codeLanguages.js +277 -0
- package/src/libs/core/i18n.js +56 -0
- package/src/libs/hephaestus/codeGenerator/codeEditor.js +1037 -0
- package/src/libs/hephaestus/codeGenerator/codeGenerator.js +286 -0
- package/src/libs/hephaestus/widgetGrid/widgetGrid.js +870 -0
- package/src/res/themes/default/style.css +471 -0
- package/src/res/themes/tokens.css +52 -0
- package/types/athena-ui.d.ts +103 -99
- package/types/code.d.ts +4 -0
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/core/codeDiff.d.ts +32 -0
- package/types/libs/core/codeLanguages.d.ts +58 -0
- package/types/libs/core/gridLayout.d.ts +45 -45
- package/types/libs/hephaestus/codeGenerator/codeEditor.d.ts +60 -0
- package/types/libs/hephaestus/codeGenerator/codeGenerator.d.ts +99 -0
- package/types/libs/hephaestus/widgetGrid/widgetGrid.d.ts +117 -117
- package/types/widgets.d.ts +2 -2
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
//Tokenizers for code highlighting (no DOM): a language is a plain object, applications add their own with registerLanguage().
|
|
2
|
+
//LICENCE: MIT
|
|
3
|
+
//Repository: https://github.com/csabatibortoth/athena-ui
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A language: an ordered list of rules. The text is scanned once; at every position the first rule that matches wins.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {object} CodeLanguage
|
|
9
|
+
* @property {string} name
|
|
10
|
+
* @property {string} [label] shown in the label of a code block (default: the name)
|
|
11
|
+
* @property {string[]} [aliases] other names ("js" for "javascript")
|
|
12
|
+
* @property {{type: string, pattern: RegExp, inner?: (text: string) => {type: string|null, text: string}[]}[]} rules `type` becomes the class `tok-<type>`;
|
|
13
|
+
* the pattern must use non-capturing groups only; `inner` splits a match into smaller tokens (a tag into name and attributes)
|
|
14
|
+
* @property {boolean} [ignoreCase] the rules are case-insensitive (SQL)
|
|
15
|
+
* @property {boolean} [multiline] ^ and $ match at every line (YAML, C# preprocessor lines)
|
|
16
|
+
* @property {string} [lineComment] used by the editor to comment lines ("//")
|
|
17
|
+
* @property {[string, string]} [blockComment]
|
|
18
|
+
* @property {string[]} [pairs] characters the editor closes: ["()", "[]", "{}", "\"\"", "''"]
|
|
19
|
+
* @property {RegExp} [indentAfter] a line that matches this makes the next line one level deeper (/[{(\[:]\s*$/)
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const languages = new Map();
|
|
23
|
+
const compiled = new WeakMap();
|
|
24
|
+
|
|
25
|
+
/** Registers a language (and its aliases). */
|
|
26
|
+
export function registerLanguage(language) {
|
|
27
|
+
if (typeof language?.name !== "string" || !Array.isArray(language.rules)) throw new TypeError("Athena UI: a language needs a name and rules");
|
|
28
|
+
for (const rule of language.rules) {
|
|
29
|
+
if (typeof rule?.type !== "string" || !(rule.pattern instanceof RegExp)) throw new TypeError(`Athena UI: a rule of "${language.name}" needs a type and a pattern`);
|
|
30
|
+
}
|
|
31
|
+
for (const name of [language.name, ...(language.aliases ?? [])]) languages.set(name.toLowerCase(), language);
|
|
32
|
+
compiled.delete(language);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The language registered under a name or alias, or undefined. */
|
|
36
|
+
export const getLanguage = name => (typeof name === "string" ? languages.get(name.toLowerCase()) : name && typeof name === "object" ? name : undefined);
|
|
37
|
+
|
|
38
|
+
/** The names of the registered languages (no aliases). */
|
|
39
|
+
export const getLanguages = () => [...new Set(languages.values())].map(language => language.name);
|
|
40
|
+
|
|
41
|
+
function compile(language) {
|
|
42
|
+
if (compiled.has(language)) return compiled.get(language);
|
|
43
|
+
const groups = [];
|
|
44
|
+
let index = 1;
|
|
45
|
+
const sources = language.rules.map(rule => {
|
|
46
|
+
groups.push(index);
|
|
47
|
+
index += new RegExp(`${rule.pattern.source}|`).exec("").length; // the group of the rule and the groups inside it
|
|
48
|
+
return `(${rule.pattern.source})`;
|
|
49
|
+
});
|
|
50
|
+
const result = { groups, expression: new RegExp(sources.join("|"), `g${language.ignoreCase ? "i" : ""}${language.multiline ? "m" : ""}`) };
|
|
51
|
+
compiled.set(language, result);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const MAX_LENGTH = 3_000_000;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Splits text into tokens: [{ type, text }]. `type` is null for plain text. Concatenating the texts gives the input back.
|
|
59
|
+
* An unknown language, or a text that is too long, gives one plain token.
|
|
60
|
+
*/
|
|
61
|
+
export function tokenize(text, language) {
|
|
62
|
+
const source = String(text ?? "");
|
|
63
|
+
const lang = getLanguage(language);
|
|
64
|
+
if (!lang || source.length > MAX_LENGTH) return source ? [{ type: null, text: source }] : [];
|
|
65
|
+
const { groups, expression } = compile(lang);
|
|
66
|
+
const tokens = [];
|
|
67
|
+
const push = (type, value) => {
|
|
68
|
+
if (!value) return;
|
|
69
|
+
const last = tokens.at(-1);
|
|
70
|
+
if (last && last.type === type) last.text += value;
|
|
71
|
+
else tokens.push({ type, text: value });
|
|
72
|
+
};
|
|
73
|
+
expression.lastIndex = 0;
|
|
74
|
+
let position = 0;
|
|
75
|
+
let match;
|
|
76
|
+
while ((match = expression.exec(source))) {
|
|
77
|
+
if (match[0] === "") {
|
|
78
|
+
expression.lastIndex++;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const rule = lang.rules[groups.findLastIndex(start => match[start] !== undefined)];
|
|
82
|
+
push(null, source.slice(position, match.index));
|
|
83
|
+
if (rule.inner) for (const part of rule.inner(match[0])) push(part.type, part.text);
|
|
84
|
+
else push(rule.type, match[0]);
|
|
85
|
+
position = match.index + match[0].length;
|
|
86
|
+
}
|
|
87
|
+
push(null, source.slice(position));
|
|
88
|
+
return tokens;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* ------------------LANGUAGES------------------- */
|
|
92
|
+
|
|
93
|
+
const words = list => new RegExp(`\\b(?:${list.join("|")})\\b`);
|
|
94
|
+
const rule = (type, pattern) => ({ type, pattern });
|
|
95
|
+
|
|
96
|
+
const STRING_DOUBLE = /"(?:[^"\\\n]|\\[\s\S])*"?/;
|
|
97
|
+
const STRING_SINGLE = /'(?:[^'\\\n]|\\[\s\S])*'?/;
|
|
98
|
+
const NUMBER_C = /\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMuUlL]*)\b|\.\d+/;
|
|
99
|
+
const PUNCTUATION = /[{}()[\];,.]/;
|
|
100
|
+
const OPERATOR = /[=+\-*/%<>!&|^~?:]+/;
|
|
101
|
+
|
|
102
|
+
const JS_KEYWORDS = ["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "export", "extends", "finally", "for", "function", "if", "import", "in", "instanceof",
|
|
103
|
+
"let", "new", "of", "return", "static", "super", "switch", "throw", "try", "typeof", "var", "void", "while", "with", "yield", "async", "await", "from", "as", "get", "set"];
|
|
104
|
+
const TS_KEYWORDS = ["interface", "type", "enum", "implements", "namespace", "declare", "readonly", "abstract", "public", "private", "protected", "keyof", "infer", "satisfies", "is", "module", "override"];
|
|
105
|
+
const TS_TYPES = ["string", "number", "boolean", "any", "unknown", "never", "void", "object", "symbol", "bigint"];
|
|
106
|
+
|
|
107
|
+
const jsRules = (keywords, types = []) => [
|
|
108
|
+
rule("comment", /\/\/[^\n]*|\/\*[\s\S]*?(?:\*\/|$)/),
|
|
109
|
+
rule("string", new RegExp(`${STRING_DOUBLE.source}|${STRING_SINGLE.source}|\`(?:[^\`\\\\]|\\\\[\\s\\S])*\`?`)),
|
|
110
|
+
rule("string", /(?<=(?:^|[=(:,[!&|?{};]|\breturn)\s*)\/(?![*/])(?:[^/\\\n[]|\\.|\[(?:[^\]\\\n]|\\.)*\])+\/[a-z]*/),
|
|
111
|
+
rule("number", NUMBER_C),
|
|
112
|
+
rule("keyword", words(keywords)),
|
|
113
|
+
...(types.length ? [rule("type", words(types))] : []),
|
|
114
|
+
rule("literal", words(["true", "false", "null", "undefined", "NaN", "Infinity", "this"])),
|
|
115
|
+
rule("function", /[A-Za-z_$][\w$]*(?=\s*\()/),
|
|
116
|
+
rule("type", /\b[A-Z][\w$]*\b/),
|
|
117
|
+
rule("punctuation", PUNCTUATION),
|
|
118
|
+
rule("operator", OPERATOR)
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
const jsBase = { lineComment: "//", blockComment: ["/*", "*/"], pairs: ["()", "[]", "{}", "\"\"", "''", "``"], indentAfter: /[{([]\s*$/ };
|
|
122
|
+
|
|
123
|
+
const HTML_TAG_PARTS = text => {
|
|
124
|
+
const out = [];
|
|
125
|
+
const part = /^<\/?[\w:-]+|\/?>$|"[^"]*"|'[^']*'|[^\s"'<>/=]+(?=\s*=)|=|[^\s"'<>/=]+|\s+|[\s\S]/g;
|
|
126
|
+
for (const [piece] of text.matchAll(part)) {
|
|
127
|
+
let type = null;
|
|
128
|
+
if (/^<\/?[\w:-]+$/.test(piece) || /^\/?>$/.test(piece)) type = "tag";
|
|
129
|
+
else if (/^["']/.test(piece)) type = "string";
|
|
130
|
+
else if (piece === "=") type = "punctuation";
|
|
131
|
+
else if (/^[^\s]/.test(piece)) type = "attribute";
|
|
132
|
+
out.push({ type, text: piece });
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const SQL_KEYWORDS = ["select", "from", "where", "and", "or", "not", "in", "is", "null", "like", "between", "exists", "insert", "into", "values", "update", "set", "delete", "create", "alter", "drop",
|
|
138
|
+
"table", "view", "index", "database", "schema", "join", "inner", "left", "right", "full", "outer", "cross", "on", "using", "group", "by", "order", "having", "limit", "offset", "union", "all", "distinct",
|
|
139
|
+
"as", "case", "when", "then", "else", "end", "with", "primary", "key", "foreign", "references", "constraint", "default", "unique", "check", "asc", "desc", "begin", "commit", "rollback", "transaction",
|
|
140
|
+
"grant", "revoke", "top", "over", "partition", "returning", "cascade", "if", "truncate", "explain", "declare", "exec", "execute", "procedure", "function", "trigger", "add", "column"];
|
|
141
|
+
const SQL_TYPES = ["int", "integer", "bigint", "smallint", "tinyint", "decimal", "numeric", "float", "real", "double", "varchar", "nvarchar", "char", "nchar", "text", "date", "datetime", "datetime2", "timestamp",
|
|
142
|
+
"time", "boolean", "bit", "uuid", "uniqueidentifier", "blob", "json", "jsonb", "money", "serial"];
|
|
143
|
+
|
|
144
|
+
const SHELL_KEYWORDS = ["if", "then", "else", "elif", "fi", "for", "in", "do", "done", "while", "until", "case", "esac", "function", "select", "return", "exit", "break", "continue", "local", "export", "readonly", "declare", "unset", "shift", "source", "time"];
|
|
145
|
+
const SHELL_BUILTINS = ["echo", "cd", "pwd", "ls", "cat", "grep", "sed", "awk", "mkdir", "rm", "cp", "mv", "chmod", "chown", "curl", "wget", "git", "npm", "node", "docker", "kubectl", "sudo", "ssh", "tar", "printf", "read", "test", "true", "false", "eval", "exec", "trap", "set"];
|
|
146
|
+
|
|
147
|
+
const CS_KEYWORDS = ["abstract", "as", "base", "break", "case", "catch", "checked", "class", "const", "continue", "default", "delegate", "do", "else", "enum", "event", "explicit", "extern", "finally", "fixed",
|
|
148
|
+
"for", "foreach", "goto", "if", "implicit", "in", "interface", "internal", "is", "lock", "namespace", "new", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref",
|
|
149
|
+
"return", "sealed", "sizeof", "stackalloc", "static", "struct", "switch", "this", "throw", "try", "typeof", "unchecked", "unsafe", "using", "virtual", "volatile", "while", "async", "await", "var", "record",
|
|
150
|
+
"init", "get", "set", "where", "yield", "when", "partial", "required", "with", "global"];
|
|
151
|
+
const CS_TYPES = ["bool", "byte", "sbyte", "char", "decimal", "double", "float", "int", "uint", "long", "ulong", "short", "ushort", "object", "string", "void", "dynamic", "nint", "nuint"];
|
|
152
|
+
|
|
153
|
+
const PY_KEYWORDS = ["and", "as", "assert", "async", "await", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda",
|
|
154
|
+
"nonlocal", "not", "or", "pass", "raise", "return", "try", "while", "with", "yield"];
|
|
155
|
+
const PY_BUILTINS = ["print", "len", "range", "list", "dict", "set", "tuple", "str", "int", "float", "bool", "type", "isinstance", "open", "enumerate", "zip", "map", "filter", "sorted", "sum", "min", "max", "abs", "super", "self", "cls"];
|
|
156
|
+
|
|
157
|
+
const BUILT_IN = [
|
|
158
|
+
{
|
|
159
|
+
name: "javascript", label: "JavaScript", aliases: ["js", "mjs", "jsx"], ...jsBase, rules: jsRules(JS_KEYWORDS)
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "typescript", label: "TypeScript", aliases: ["ts", "tsx"], ...jsBase, rules: jsRules([...JS_KEYWORDS, ...TS_KEYWORDS], TS_TYPES)
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "json", label: "JSON", aliases: ["jsonc"], pairs: ["[]", "{}", "\"\""], indentAfter: /[{[]\s*$/,
|
|
166
|
+
rules: [
|
|
167
|
+
rule("comment", /\/\/[^\n]*|\/\*[\s\S]*?(?:\*\/|$)/),
|
|
168
|
+
rule("property", /"(?:[^"\\\n]|\\.)*"(?=\s*:)/),
|
|
169
|
+
rule("string", STRING_DOUBLE),
|
|
170
|
+
rule("number", /-?\b\d+\.?\d*(?:[eE][+-]?\d+)?\b/),
|
|
171
|
+
rule("literal", words(["true", "false", "null"])),
|
|
172
|
+
rule("punctuation", /[{}[\],:]/)
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "html", label: "HTML", aliases: ["xml", "svg", "xhtml"], blockComment: ["<!--", "-->"], pairs: ["\"\"", "''"], indentAfter: /<[a-z][^>/]*>\s*$/i,
|
|
177
|
+
rules: [
|
|
178
|
+
rule("comment", /<!--[\s\S]*?(?:-->|$)/),
|
|
179
|
+
rule("meta", /<![A-Za-z][^>]*>|<\?[\s\S]*?(?:\?>|$)/),
|
|
180
|
+
{ type: "tag", pattern: /<\/?[A-Za-z][\w:-]*(?:\s+[^\s"'<>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'<>]+))?)*\s*\/?>/, inner: HTML_TAG_PARTS },
|
|
181
|
+
rule("entity", /&(?:#\d+|#x[\da-fA-F]+|\w+);/)
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "css", label: "CSS", aliases: ["scss", "less"], blockComment: ["/*", "*/"], pairs: ["()", "[]", "{}", "\"\"", "''"], indentAfter: /\{\s*$/,
|
|
186
|
+
rules: [
|
|
187
|
+
rule("comment", /\/\*[\s\S]*?(?:\*\/|$)/),
|
|
188
|
+
rule("string", new RegExp(`${STRING_DOUBLE.source}|${STRING_SINGLE.source}`)),
|
|
189
|
+
rule("meta", /@[\w-]+/),
|
|
190
|
+
rule("variable", /--[\w-]+/),
|
|
191
|
+
rule("number", /#[\da-fA-F]{3,8}\b|-?(?:\d+\.?\d*|\.\d+)(?:%|[a-zA-Z]+)?/),
|
|
192
|
+
rule("property", /[-\w]+(?=\s*:\s*[^;{}]*[;}])/),
|
|
193
|
+
rule("selector", /[.#][-\w]+|::?[-\w]+|\*/),
|
|
194
|
+
rule("function", /[-\w]+(?=\()/),
|
|
195
|
+
rule("keyword", /!important\b/),
|
|
196
|
+
rule("punctuation", /[{}()[\];,:>+~]/)
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "sql", label: "SQL", aliases: ["tsql", "mysql", "postgres", "postgresql"], ignoreCase: true, lineComment: "--", blockComment: ["/*", "*/"], pairs: ["()", "''", "\"\""], indentAfter: /\(\s*$/,
|
|
201
|
+
rules: [
|
|
202
|
+
rule("comment", /--[^\n]*|\/\*[\s\S]*?(?:\*\/|$)/),
|
|
203
|
+
rule("string", /'(?:[^']|'')*'?/),
|
|
204
|
+
rule("variable", /"[^"\n]*"?|`[^`\n]*`?|\[[^\]\n]*\]|[@:][\w]+/),
|
|
205
|
+
rule("number", /\b\d+\.?\d*\b/),
|
|
206
|
+
rule("keyword", words(SQL_KEYWORDS)),
|
|
207
|
+
rule("type", words(SQL_TYPES)),
|
|
208
|
+
rule("function", /\b[A-Za-z_]\w*(?=\s*\()/),
|
|
209
|
+
rule("operator", /[=<>!+\-*/%|&^~]+/),
|
|
210
|
+
rule("punctuation", /[();,.]/)
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "shell", label: "Shell", aliases: ["sh", "bash", "zsh", "shellscript"], lineComment: "#", pairs: ["()", "[]", "{}", "\"\"", "''", "``"], indentAfter: /(?:\b(?:then|do|else)|[{(])\s*$/,
|
|
215
|
+
rules: [
|
|
216
|
+
rule("comment", /(?<=^|\s)#[^\n]*/),
|
|
217
|
+
rule("string", /"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/),
|
|
218
|
+
rule("variable", /\$(?:\w+|\{[^}\n]*\}?|\([^)\n]*\)?|[@*#?$!-])/),
|
|
219
|
+
rule("keyword", words(SHELL_KEYWORDS)),
|
|
220
|
+
rule("function", words(SHELL_BUILTINS)),
|
|
221
|
+
rule("attribute", /(?<=\s)--?[A-Za-z][\w-]*/),
|
|
222
|
+
rule("number", /\b\d+\b/),
|
|
223
|
+
rule("operator", /[|&;<>=!]+/)
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "yaml", label: "YAML", aliases: ["yml"], multiline: true, lineComment: "#", pairs: ["[]", "{}", "\"\"", "''"], indentAfter: /:\s*$/,
|
|
228
|
+
rules: [
|
|
229
|
+
rule("comment", /(?<=^|\s)#[^\n]*/),
|
|
230
|
+
rule("meta", /^(?:---|\.\.\.)(?=\s|$)/),
|
|
231
|
+
rule("property", /(?<=^[ \t-]*)(?:"[^"\n]*"|'[^'\n]*'|[^\s#:[\]{},"'-][^:\n#]*?)(?=\s*:(?:\s|$))/),
|
|
232
|
+
rule("string", /"(?:[^"\\\n]|\\.)*"?|'(?:[^'\n]|'')*'?/),
|
|
233
|
+
rule("variable", /[&*!][\w-]+/),
|
|
234
|
+
rule("number", /(?<=[\s:[,-]|^)-?\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?(?=\s|$|[,\]}])/),
|
|
235
|
+
rule("literal", /(?<=[\s:[,-]|^)(?:true|false|null|yes|no|on|off|~)(?=\s|$|[,\]}])/i),
|
|
236
|
+
rule("punctuation", /[[\]{},|>]|(?<=^|\s)-(?=\s)/)
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "csharp", label: "C#", aliases: ["cs", "c#", "dotnet"], lineComment: "//", blockComment: ["/*", "*/"], pairs: ["()", "[]", "{}", "\"\"", "''"], indentAfter: /[{([]\s*$/, multiline: true,
|
|
241
|
+
rules: [
|
|
242
|
+
rule("comment", /\/\/[^\n]*|\/\*[\s\S]*?(?:\*\/|$)/),
|
|
243
|
+
rule("meta", /^[ \t]*#[a-z]+[^\n]*/),
|
|
244
|
+
rule("string", /@"(?:[^"]|"")*"?|[$@]{0,2}"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/),
|
|
245
|
+
rule("number", NUMBER_C),
|
|
246
|
+
rule("keyword", words(CS_KEYWORDS)),
|
|
247
|
+
rule("type", words(CS_TYPES)),
|
|
248
|
+
rule("literal", words(["true", "false", "null"])),
|
|
249
|
+
rule("function", /[A-Za-z_]\w*(?=\s*[(<][^;{)]*\)?\s*[{;=(]|\()/),
|
|
250
|
+
rule("type", /\b[A-Z]\w*\b/),
|
|
251
|
+
rule("punctuation", PUNCTUATION),
|
|
252
|
+
rule("operator", OPERATOR)
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: "python", label: "Python", aliases: ["py", "python3"], multiline: true, lineComment: "#", pairs: ["()", "[]", "{}", "\"\"", "''"], indentAfter: /:\s*$/,
|
|
257
|
+
rules: [
|
|
258
|
+
rule("comment", /#[^\n]*/),
|
|
259
|
+
rule("string", /[rRbBfFuU]{0,2}(?:"""[\s\S]*?(?:"""|$)|'''[\s\S]*?(?:'''|$)|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?)/),
|
|
260
|
+
rule("meta", /^[ \t]*@[\w.]+/),
|
|
261
|
+
rule("number", /\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?j?)\b|\.\d+/),
|
|
262
|
+
rule("function", /(?<=\bdef\s+)\w+/),
|
|
263
|
+
rule("type", /(?<=\bclass\s+)\w+/),
|
|
264
|
+
rule("keyword", words(PY_KEYWORDS)),
|
|
265
|
+
rule("literal", words(["True", "False", "None"])),
|
|
266
|
+
rule("builtin", words(PY_BUILTINS)),
|
|
267
|
+
rule("function", /[A-Za-z_]\w*(?=\s*\()/),
|
|
268
|
+
rule("punctuation", /[{}()[\];,.:]/),
|
|
269
|
+
rule("operator", /[=+\-*/%<>!&|^~@]+/)
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
for (const language of BUILT_IN) registerLanguage(language);
|
|
275
|
+
|
|
276
|
+
/** The token types the default theme gives a colour to: the classes are `tok-<type>`. */
|
|
277
|
+
export const TOKEN_TYPES = ["comment", "string", "number", "keyword", "literal", "function", "type", "property", "tag", "attribute", "variable", "selector", "meta", "entity", "builtin", "operator", "punctuation"];
|
package/src/libs/core/i18n.js
CHANGED
|
@@ -37,6 +37,34 @@ const messages = {
|
|
|
37
37
|
"widget.position": "Column {x}, row {y}, {w} wide, {h} high.",
|
|
38
38
|
"widget.added": "{title} added.",
|
|
39
39
|
"widget.removed": "{title} removed.",
|
|
40
|
+
"code.copy": "Copy",
|
|
41
|
+
"code.copied": "Copied",
|
|
42
|
+
"code.copyFailed": "Copy failed",
|
|
43
|
+
"code.diff": "Differences",
|
|
44
|
+
"code.original": "Original",
|
|
45
|
+
"code.modified": "Modified",
|
|
46
|
+
"code.unchanged": "{count} unchanged lines",
|
|
47
|
+
"code.removed": "removed",
|
|
48
|
+
"code.added": "added",
|
|
49
|
+
"code.noChanges": "No differences.",
|
|
50
|
+
"code.editorLabel": "Code editor",
|
|
51
|
+
"code.escapeHint": "Press Escape, then Tab, to leave the editor.",
|
|
52
|
+
"code.tabLeaves": "The next Tab key leaves the editor.",
|
|
53
|
+
"code.find": "Find",
|
|
54
|
+
"code.replaceWith": "Replace with",
|
|
55
|
+
"code.next": "Next match",
|
|
56
|
+
"code.previous": "Previous match",
|
|
57
|
+
"code.replaceOne": "Replace",
|
|
58
|
+
"code.replaceAll": "Replace all",
|
|
59
|
+
"code.close": "Close",
|
|
60
|
+
"code.matchCase": "Match case",
|
|
61
|
+
"code.useRegex": "Regular expression",
|
|
62
|
+
"code.matches": "{current} of {total}",
|
|
63
|
+
"code.noMatches": "No matches",
|
|
64
|
+
"code.invalidPattern": "Invalid pattern",
|
|
65
|
+
"code.position": "Line {line}, column {column}",
|
|
66
|
+
"code.marker": "Line {line}: {message}",
|
|
67
|
+
"code.suggestions": "Suggestions",
|
|
40
68
|
"range.preset": "Range",
|
|
41
69
|
"range.custom": "Custom",
|
|
42
70
|
"range.last15m": "Last 15 minutes",
|
|
@@ -150,6 +178,34 @@ const messages = {
|
|
|
150
178
|
"widget.position": "{x}. oszlop, {y}. sor, {w} széles, {h} magas.",
|
|
151
179
|
"widget.added": "{title} hozzáadva.",
|
|
152
180
|
"widget.removed": "{title} eltávolítva.",
|
|
181
|
+
"code.copy": "Másolás",
|
|
182
|
+
"code.copied": "Másolva",
|
|
183
|
+
"code.copyFailed": "A másolás nem sikerült",
|
|
184
|
+
"code.diff": "Különbségek",
|
|
185
|
+
"code.original": "Eredeti",
|
|
186
|
+
"code.modified": "Módosított",
|
|
187
|
+
"code.unchanged": "{count} változatlan sor",
|
|
188
|
+
"code.removed": "törölve",
|
|
189
|
+
"code.added": "hozzáadva",
|
|
190
|
+
"code.noChanges": "Nincs különbség.",
|
|
191
|
+
"code.editorLabel": "Kódszerkesztő",
|
|
192
|
+
"code.escapeHint": "A szerkesztőből az Escape, majd a Tab billentyűvel lehet kilépni.",
|
|
193
|
+
"code.tabLeaves": "A következő Tab kilép a szerkesztőből.",
|
|
194
|
+
"code.find": "Keresés",
|
|
195
|
+
"code.replaceWith": "Csere erre",
|
|
196
|
+
"code.next": "Következő találat",
|
|
197
|
+
"code.previous": "Előző találat",
|
|
198
|
+
"code.replaceOne": "Csere",
|
|
199
|
+
"code.replaceAll": "Összes cseréje",
|
|
200
|
+
"code.close": "Bezárás",
|
|
201
|
+
"code.matchCase": "Kis- és nagybetű",
|
|
202
|
+
"code.useRegex": "Reguláris kifejezés",
|
|
203
|
+
"code.matches": "{current} / {total}",
|
|
204
|
+
"code.noMatches": "Nincs találat",
|
|
205
|
+
"code.invalidPattern": "Érvénytelen minta",
|
|
206
|
+
"code.position": "{line}. sor, {column}. oszlop",
|
|
207
|
+
"code.marker": "{line}. sor: {message}",
|
|
208
|
+
"code.suggestions": "Javaslatok",
|
|
153
209
|
"range.preset": "Időszak",
|
|
154
210
|
"range.custom": "Egyéni",
|
|
155
211
|
"range.last15m": "Utolsó 15 perc",
|