@xh/hoist 79.0.0-SNAPSHOT.1765824728801 → 79.0.0-SNAPSHOT.1765828263630
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.
|
@@ -11,10 +11,17 @@ import {
|
|
|
11
11
|
foldGutter,
|
|
12
12
|
foldKeymap,
|
|
13
13
|
indentOnInput,
|
|
14
|
-
LanguageDescription,
|
|
15
14
|
LanguageSupport,
|
|
16
15
|
syntaxHighlighting
|
|
17
16
|
} from '@codemirror/language';
|
|
17
|
+
// Import the languages you want to support
|
|
18
|
+
import {javascript} from '@codemirror/lang-javascript';
|
|
19
|
+
import {python} from '@codemirror/lang-python';
|
|
20
|
+
import {html} from '@codemirror/lang-html';
|
|
21
|
+
import {css} from '@codemirror/lang-css';
|
|
22
|
+
import {json} from '@codemirror/lang-json';
|
|
23
|
+
import {sql} from '@codemirror/lang-sql';
|
|
24
|
+
|
|
18
25
|
import {linter, lintGutter} from '@codemirror/lint';
|
|
19
26
|
import {highlightSelectionMatches, search} from '@codemirror/search';
|
|
20
27
|
import {
|
|
@@ -51,10 +58,20 @@ import {action, bindable, makeObservable, observable} from '@xh/hoist/mobx';
|
|
|
51
58
|
import {withDefault} from '@xh/hoist/utils/js';
|
|
52
59
|
import {getLayoutProps} from '@xh/hoist/utils/react';
|
|
53
60
|
import classNames from 'classnames';
|
|
54
|
-
import {compact,
|
|
61
|
+
import {compact, isEmpty, isFunction, isObject} from 'lodash';
|
|
55
62
|
import {ReactElement} from 'react';
|
|
56
63
|
import './CodeInput.scss';
|
|
57
|
-
|
|
64
|
+
// Map of supported language aliases to CodeMirror factories
|
|
65
|
+
const LANGUAGE_EXTENSIONS: Record<string, () => LanguageSupport> = {
|
|
66
|
+
js: javascript,
|
|
67
|
+
javascript: javascript,
|
|
68
|
+
py: python,
|
|
69
|
+
python: python,
|
|
70
|
+
html: html,
|
|
71
|
+
css: css,
|
|
72
|
+
json: json,
|
|
73
|
+
sql: sql
|
|
74
|
+
};
|
|
58
75
|
|
|
59
76
|
export interface CodeInputProps extends HoistProps, HoistInputProps, LayoutProps {
|
|
60
77
|
/** True to focus the control on render. */
|
|
@@ -485,13 +502,14 @@ class CodeInputModel extends HoistInputModel {
|
|
|
485
502
|
}
|
|
486
503
|
|
|
487
504
|
private async getLanguageExtensionAsync(lang: string): Promise<LanguageSupport> {
|
|
505
|
+
if (!lang) return null;
|
|
506
|
+
const langFactory = LANGUAGE_EXTENSIONS[lang.toLowerCase()];
|
|
507
|
+
if (!langFactory) {
|
|
508
|
+
console.warn(`Language not found: ${lang}`);
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
488
511
|
try {
|
|
489
|
-
|
|
490
|
-
languages,
|
|
491
|
-
it => includes(it.alias, lang) || it.name.toLowerCase() === lang.toLowerCase()
|
|
492
|
-
);
|
|
493
|
-
if (!langDesc) return null;
|
|
494
|
-
return await langDesc.load();
|
|
512
|
+
return langFactory();
|
|
495
513
|
} catch (err) {
|
|
496
514
|
console.error(`Failed to load language: ${lang}`, err);
|
|
497
515
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "79.0.0-SNAPSHOT.
|
|
3
|
+
"version": "79.0.0-SNAPSHOT.1765828263630",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|
|
@@ -34,8 +34,13 @@
|
|
|
34
34
|
"@blueprintjs/datetime": "^5.3.7",
|
|
35
35
|
"@blueprintjs/datetime2": "^2.3.7",
|
|
36
36
|
"@codemirror/commands": "6.9.0",
|
|
37
|
+
"@codemirror/lang-css": "^6.2.0",
|
|
38
|
+
"@codemirror/lang-html": "^6.2.0",
|
|
39
|
+
"@codemirror/lang-javascript": "^6.2.4",
|
|
40
|
+
"@codemirror/lang-json": "^6.0.1",
|
|
41
|
+
"@codemirror/lang-python": "^6.2.0",
|
|
42
|
+
"@codemirror/lang-sql": "^6.2.0",
|
|
37
43
|
"@codemirror/language": "6.11.3",
|
|
38
|
-
"@codemirror/language-data": "6.5.2",
|
|
39
44
|
"@codemirror/lint": "6.9.0",
|
|
40
45
|
"@codemirror/search": "6.5.11",
|
|
41
46
|
"@codemirror/view": "6.38.6",
|