@xh/hoist 79.0.0-SNAPSHOT.1765846193322 → 79.0.0-SNAPSHOT.1765854402334

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,9 +11,11 @@ import {
11
11
  foldGutter,
12
12
  foldKeymap,
13
13
  indentOnInput,
14
+ LanguageDescription,
14
15
  LanguageSupport,
15
16
  syntaxHighlighting
16
17
  } from '@codemirror/language';
18
+ import {languages} from '@codemirror/language-data';
17
19
  import {linter, lintGutter} from '@codemirror/lint';
18
20
  import {highlightSelectionMatches, search} from '@codemirror/search';
19
21
  import {
@@ -35,7 +37,6 @@ import {
35
37
  ViewPlugin,
36
38
  ViewUpdate
37
39
  } from '@codemirror/view';
38
- import {oneDark} from './impl/one-dark';
39
40
  import {HoistInputModel, HoistInputProps, useHoistInputModel} from '@xh/hoist/cmp/input';
40
41
  import {box, div, filler, fragment, frame, hbox, label, span, vbox} from '@xh/hoist/cmp/layout';
41
42
  import {hoistCmp, HoistProps, LayoutProps, managed, PlainObject, XH} from '@xh/hoist/core';
@@ -50,14 +51,11 @@ import {action, bindable, makeObservable, observable} from '@xh/hoist/mobx';
50
51
  import {withDefault} from '@xh/hoist/utils/js';
51
52
  import {getLayoutProps} from '@xh/hoist/utils/react';
52
53
  import classNames from 'classnames';
53
- import {compact, isEmpty, isFunction, isObject} from 'lodash';
54
+ import {compact, find, includes, isEmpty, isFunction, isObject} from 'lodash';
54
55
  import {ReactElement} from 'react';
55
56
  import './CodeInput.scss';
56
- import {javascript} from '@codemirror/lang-javascript';
57
- import {json} from '@codemirror/lang-json';
58
- import {html} from '@codemirror/lang-html';
59
- import {sql} from '@codemirror/lang-sql';
60
- import {css} from '@codemirror/lang-css';
57
+ import {githubLight, githubDark} from '@uiw/codemirror-theme-github';
58
+
61
59
  export interface CodeInputProps extends HoistProps, HoistInputProps, LayoutProps {
62
60
  /** True to focus the control on render. */
63
61
  autoFocus?: boolean;
@@ -477,9 +475,9 @@ class CodeInputModel extends HoistInputModel {
477
475
  extensions.push(highlightActiveLine(), highlightActiveLineGutter());
478
476
  if (autoFocus) extensions.push(this.autofocusExtension);
479
477
  if (language) {
480
- const langExt = this.getLanguageExtension(language);
478
+ const langExt = this.getLanguageExtensionAsync(language);
481
479
  if (langExt) {
482
- extensions.push(langExt);
480
+ extensions.push(await langExt);
483
481
  } else {
484
482
  console.warn('Failed to load language:', language);
485
483
  }
@@ -488,28 +486,17 @@ class CodeInputModel extends HoistInputModel {
488
486
  }
489
487
 
490
488
  private getThemeExtension() {
491
- const lightTheme = EditorView.theme({}, {dark: false});
492
- return XH.darkTheme ? oneDark : lightTheme;
489
+ return XH.darkTheme ? githubDark : githubLight;
493
490
  }
494
491
 
495
- private LANGUAGE_EXTENSIONS: Record<string, () => LanguageSupport> = {
496
- js: javascript,
497
- javascript: javascript,
498
- html: html,
499
- css: css,
500
- json: json,
501
- sql: sql
502
- };
503
-
504
- private getLanguageExtension(lang: string): LanguageSupport {
505
- if (!lang) return null;
506
- const extFactory = this.LANGUAGE_EXTENSIONS[lang.toLowerCase()];
507
- if (!extFactory) {
508
- console.warn(`Language not found: ${lang}`);
509
- return null;
510
- }
492
+ private async getLanguageExtensionAsync(lang: string): Promise<LanguageSupport> {
511
493
  try {
512
- return extFactory(); // returns a LanguageSupport instance
494
+ const langDesc: LanguageDescription | undefined = find(
495
+ languages,
496
+ it => includes(it.alias, lang) || it.name.toLowerCase() === lang.toLowerCase()
497
+ );
498
+ if (!langDesc) return null;
499
+ return await langDesc.load();
513
500
  } catch (err) {
514
501
  console.error(`Failed to load language: ${lang}`, err);
515
502
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "79.0.0-SNAPSHOT.1765846193322",
3
+ "version": "79.0.0-SNAPSHOT.1765854402334",
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,12 +34,8 @@
34
34
  "@blueprintjs/datetime": "^5.3.7",
35
35
  "@blueprintjs/datetime2": "^2.3.7",
36
36
  "@codemirror/commands": "6.10.0",
37
- "@codemirror/lang-css": "6.3.1",
38
- "@codemirror/lang-html": "6.4.11",
39
- "@codemirror/lang-javascript": "6.2.4",
40
- "@codemirror/lang-json": "6.0.2",
41
- "@codemirror/lang-sql": "6.10.0",
42
37
  "@codemirror/language": "6.11.3",
38
+ "@codemirror/language-data": "6.5.2",
43
39
  "@codemirror/lint": "6.9.2",
44
40
  "@codemirror/search": "6.5.11",
45
41
  "@codemirror/view": "6.39.4",
@@ -53,6 +49,7 @@
53
49
  "@onsenui/fastclick": "~1.1.1",
54
50
  "@popperjs/core": "~2.11.0",
55
51
  "@seznam/compose-react-refs": "~1.0.5",
52
+ "@uiw/codemirror-theme-github": "^4.25.4",
56
53
  "ajv": "~8.17.1",
57
54
  "classnames": "~2.5.1",
58
55
  "clipboard-copy": "~4.0.1",