@snack-uikit/code-editor 0.5.2-preview-764c2b6c.0 → 0.5.2-preview-76dd9d31.0

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 CHANGED
@@ -36,6 +36,11 @@
36
36
  | onMount | `OnMount` | - | Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void An event is emitted when the editor is mounted It gets the editor instance as a first argument and the monaco instance as a second Defaults to "noop" |
37
37
  | onChange | `OnChange` | - | Signature: function(value: string \| undefined, ev: monaco.editor.IModelContentChangedEvent) => void An event is emitted when the content of the current model is changed |
38
38
  | onValidate | `OnValidate` | - | Signature: function(markers: monaco.editor.IMarker[]) => void An event is emitted when the content of the current model is changed and the current model markers are ready Defaults to "noop" |
39
+ ## asyncCodeEditor
40
+ ### Props
41
+ | name | type | default value | description |
42
+ |------|------|---------------|-------------|
43
+ | configLoader* | `() => Promise<{ paths?: { vs?: string; }; 'vs/nls'?: { availableLanguages?: object; }; monaco?: typeof import("/Users/alssmirnov/p/snack-uikit/node_modules/monaco-editor/esm/vs/editor/editor.api"); }>` | - | |
39
44
 
40
45
 
41
46
  [//]: DOCUMENTATION_SECTION_END
@@ -0,0 +1,9 @@
1
+ import { loader } from '@monaco-editor/react';
2
+ import { CodeEditor } from './CodeEditor';
3
+ type LoaderConfig = Parameters<(typeof loader)['config']>[0];
4
+ export declare const asyncCodeEditor: (opts: {
5
+ configLoader: () => Promise<LoaderConfig>;
6
+ }) => Promise<{
7
+ default: typeof CodeEditor;
8
+ }>;
9
+ export {};
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) {
5
+ return value instanceof P ? value : new P(function (resolve) {
6
+ resolve(value);
7
+ });
8
+ }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) {
11
+ try {
12
+ step(generator.next(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ }
17
+ function rejected(value) {
18
+ try {
19
+ step(generator["throw"](value));
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ }
24
+ function step(result) {
25
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
26
+ }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", {
31
+ value: true
32
+ });
33
+ exports.asyncCodeEditor = void 0;
34
+ const react_1 = require("@monaco-editor/react");
35
+ const CodeEditor_1 = require("./CodeEditor");
36
+ const asyncCodeEditor = opts => __awaiter(void 0, void 0, void 0, function* () {
37
+ const {
38
+ configLoader
39
+ } = opts;
40
+ const config = yield configLoader();
41
+ react_1.loader.config(config);
42
+ return {
43
+ default: CodeEditor_1.CodeEditor
44
+ };
45
+ });
46
+ exports.asyncCodeEditor = asyncCodeEditor;
@@ -1,2 +1,3 @@
1
1
  export * from './CodeEditor';
2
2
  export * from './types';
3
+ export * from './asyncLoader';
@@ -23,4 +23,5 @@ Object.defineProperty(exports, "__esModule", {
23
23
  value: true
24
24
  });
25
25
  __exportStar(require("./CodeEditor"), exports);
26
- __exportStar(require("./types"), exports);
26
+ __exportStar(require("./types"), exports);
27
+ __exportStar(require("./asyncLoader"), exports);
@@ -0,0 +1,9 @@
1
+ import { loader } from '@monaco-editor/react';
2
+ import { CodeEditor } from './CodeEditor';
3
+ type LoaderConfig = Parameters<(typeof loader)['config']>[0];
4
+ export declare const asyncCodeEditor: (opts: {
5
+ configLoader: () => Promise<LoaderConfig>;
6
+ }) => Promise<{
7
+ default: typeof CodeEditor;
8
+ }>;
9
+ export {};
@@ -0,0 +1,17 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { loader } from '@monaco-editor/react';
11
+ import { CodeEditor } from './CodeEditor';
12
+ export const asyncCodeEditor = (opts) => __awaiter(void 0, void 0, void 0, function* () {
13
+ const { configLoader } = opts;
14
+ const config = yield configLoader();
15
+ loader.config(config);
16
+ return { default: CodeEditor };
17
+ });
@@ -1,2 +1,3 @@
1
1
  export * from './CodeEditor';
2
2
  export * from './types';
3
+ export * from './asyncLoader';
@@ -1,2 +1,3 @@
1
1
  export * from './CodeEditor';
2
2
  export * from './types';
3
+ export * from './asyncLoader';
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.5.2-preview-764c2b6c.0",
7
+ "version": "0.5.2-preview-76dd9d31.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "@types/chroma-js": "2.4.4"
48
48
  },
49
- "gitHead": "94362d8761d20e89d81c91a7272051da3109ae93"
49
+ "gitHead": "77dd00305b277c6ffee68e32451d536d8da2dca2"
50
50
  }
@@ -0,0 +1,14 @@
1
+ import { loader } from '@monaco-editor/react';
2
+
3
+ import { CodeEditor } from './CodeEditor';
4
+
5
+ type LoaderConfig = Parameters<(typeof loader)['config']>[0];
6
+
7
+ export const asyncCodeEditor = async (opts: { configLoader: () => Promise<LoaderConfig> }) => {
8
+ const { configLoader } = opts;
9
+ const config = await configLoader();
10
+
11
+ loader.config(config);
12
+
13
+ return { default: CodeEditor };
14
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './CodeEditor';
2
2
  export * from './types';
3
+ export * from './asyncLoader';