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

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,6 +11,7 @@ import {
11
11
  foldGutter,
12
12
  foldKeymap,
13
13
  indentOnInput,
14
+ LanguageSupport,
14
15
  syntaxHighlighting
15
16
  } from '@codemirror/language';
16
17
  import {linter, lintGutter} from '@codemirror/lint';
@@ -53,10 +54,10 @@ import {compact, isEmpty, isFunction, isObject} from 'lodash';
53
54
  import {ReactElement} from 'react';
54
55
  import './CodeInput.scss';
55
56
  import {javascript} from '@codemirror/lang-javascript';
56
- // import {json} from '@codemirror/lang-json';
57
- // import {html} from '@codemirror/lang-html';
58
- // import {sql} from '@codemirror/lang-sql';
59
- // import {css} from '@codemirror/lang-css';
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';
60
61
  export interface CodeInputProps extends HoistProps, HoistInputProps, LayoutProps {
61
62
  /** True to focus the control on render. */
62
63
  autoFocus?: boolean;
@@ -418,6 +419,7 @@ class CodeInputModel extends HoistInputModel {
418
419
  const {
419
420
  autoFocus,
420
421
  readonly,
422
+ language,
421
423
  highlightActiveLine: propsHighlightActiveLine,
422
424
  linter: propsLinter,
423
425
  lineNumbers: propsLineNumbers = true,
@@ -442,7 +444,6 @@ class CodeInputModel extends HoistInputModel {
442
444
  indentOnInput(),
443
445
  autocompletion(),
444
446
  history(),
445
- javascript(),
446
447
  // Linter
447
448
  propsLinter
448
449
  ? linter(async view => {
@@ -475,14 +476,14 @@ class CodeInputModel extends HoistInputModel {
475
476
  if (propsHighlightActiveLine)
476
477
  extensions.push(highlightActiveLine(), highlightActiveLineGutter());
477
478
  if (autoFocus) extensions.push(this.autofocusExtension);
478
- // if (language) {
479
- // const langExt = this.getLanguageExtension(language);
480
- // if (langExt) {
481
- // extensions.push(langExt);
482
- // } else {
483
- // console.warn('Failed to load language:', language);
484
- // }
485
- // }
479
+ if (language) {
480
+ const langExt = this.getLanguageExtension(language);
481
+ if (langExt) {
482
+ extensions.push(langExt);
483
+ } else {
484
+ console.warn('Failed to load language:', language);
485
+ }
486
+ }
486
487
  return extensions.filter(it => !isEmpty(it));
487
488
  }
488
489
 
@@ -491,29 +492,29 @@ class CodeInputModel extends HoistInputModel {
491
492
  return XH.darkTheme ? oneDark : lightTheme;
492
493
  }
493
494
 
494
- // private LANGUAGE_EXTENSIONS: Record<string, () => LanguageSupport> = {
495
- // js: javascript,
496
- // javascript: javascript,
497
- // html: html,
498
- // css: css,
499
- // json: json,
500
- // sql: sql
501
- // };
502
-
503
- // private getLanguageExtension(lang: string): LanguageSupport {
504
- // if (!lang) return null;
505
- // const extFactory = this.LANGUAGE_EXTENSIONS[lang.toLowerCase()];
506
- // if (!extFactory) {
507
- // console.warn(`Language not found: ${lang}`);
508
- // return null;
509
- // }
510
- // try {
511
- // return extFactory(); // returns a LanguageSupport instance
512
- // } catch (err) {
513
- // console.error(`Failed to load language: ${lang}`, err);
514
- // return null;
515
- // }
516
- // }
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
+ }
511
+ try {
512
+ return extFactory(); // returns a LanguageSupport instance
513
+ } catch (err) {
514
+ console.error(`Failed to load language: ${lang}`, err);
515
+ return null;
516
+ }
517
+ }
517
518
 
518
519
  private autofocusExtension = ViewPlugin.fromClass(
519
520
  class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "79.0.0-SNAPSHOT.1765845531181",
3
+ "version": "79.0.0-SNAPSHOT.1765846193322",
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",