@willbooster/monaco-react 1.0.3 → 1.0.5
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 +4 -3
- package/dist/DiffEditor/DiffEditor.cjs +3 -0
- package/dist/DiffEditor/DiffEditor.cjs.map +1 -0
- package/dist/DiffEditor/DiffEditor.d.ts +5 -0
- package/dist/DiffEditor/DiffEditor.d.ts.map +1 -0
- package/dist/DiffEditor/DiffEditor.js +3 -0
- package/dist/DiffEditor/DiffEditor.js.map +1 -0
- package/dist/DiffEditor/index.cjs +2 -0
- package/dist/DiffEditor/index.cjs.map +1 -0
- package/dist/DiffEditor/index.d.ts +5 -0
- package/dist/DiffEditor/index.d.ts.map +1 -0
- package/dist/DiffEditor/index.js +2 -0
- package/dist/DiffEditor/index.js.map +1 -0
- package/dist/DiffEditor/index.spec.d.ts +2 -0
- package/dist/DiffEditor/index.spec.d.ts.map +1 -0
- package/dist/DiffEditor/types.d.ts +101 -0
- package/dist/DiffEditor/types.d.ts.map +1 -0
- package/dist/Editor/Editor.cjs +3 -0
- package/dist/Editor/Editor.cjs.map +1 -0
- package/dist/Editor/Editor.d.ts +5 -0
- package/dist/Editor/Editor.d.ts.map +1 -0
- package/dist/Editor/Editor.js +3 -0
- package/dist/Editor/Editor.js.map +1 -0
- package/dist/Editor/index.cjs +2 -0
- package/dist/Editor/index.cjs.map +1 -0
- package/dist/Editor/index.d.ts +5 -0
- package/dist/Editor/index.d.ts.map +1 -0
- package/dist/Editor/index.js +2 -0
- package/dist/Editor/index.js.map +1 -0
- package/dist/Editor/index.spec.d.ts +2 -0
- package/dist/Editor/index.spec.d.ts.map +1 -0
- package/dist/Editor/types.d.ts +116 -0
- package/dist/Editor/types.d.ts.map +1 -0
- package/dist/Loading/Loading.cjs +2 -0
- package/dist/Loading/Loading.cjs.map +1 -0
- package/dist/Loading/Loading.d.ts +4 -0
- package/dist/Loading/Loading.d.ts.map +1 -0
- package/dist/Loading/Loading.js +2 -0
- package/dist/Loading/Loading.js.map +1 -0
- package/dist/Loading/index.cjs +2 -0
- package/dist/Loading/index.cjs.map +1 -0
- package/dist/Loading/index.d.ts +3 -0
- package/dist/Loading/index.d.ts.map +1 -0
- package/dist/Loading/index.js +2 -0
- package/dist/Loading/index.js.map +1 -0
- package/dist/Loading/index.spec.d.ts +2 -0
- package/dist/Loading/index.spec.d.ts.map +1 -0
- package/dist/Loading/styles.cjs +2 -0
- package/dist/Loading/styles.cjs.map +1 -0
- package/dist/Loading/styles.d.ts +4 -0
- package/dist/Loading/styles.d.ts.map +1 -0
- package/dist/Loading/styles.js +2 -0
- package/dist/Loading/styles.js.map +1 -0
- package/dist/MonacoContainer/MonacoContainer.cjs +2 -0
- package/dist/MonacoContainer/MonacoContainer.cjs.map +1 -0
- package/dist/MonacoContainer/MonacoContainer.d.ts +5 -0
- package/dist/MonacoContainer/MonacoContainer.d.ts.map +1 -0
- package/dist/MonacoContainer/MonacoContainer.js +2 -0
- package/dist/MonacoContainer/MonacoContainer.js.map +1 -0
- package/dist/MonacoContainer/index.cjs +2 -0
- package/dist/MonacoContainer/index.cjs.map +1 -0
- package/dist/MonacoContainer/index.d.ts +4 -0
- package/dist/MonacoContainer/index.d.ts.map +1 -0
- package/dist/MonacoContainer/index.js +2 -0
- package/dist/MonacoContainer/index.js.map +1 -0
- package/dist/MonacoContainer/index.spec.d.ts +2 -0
- package/dist/MonacoContainer/index.spec.d.ts.map +1 -0
- package/dist/MonacoContainer/styles.cjs +2 -0
- package/dist/MonacoContainer/styles.cjs.map +1 -0
- package/dist/MonacoContainer/styles.d.ts +4 -0
- package/dist/MonacoContainer/styles.d.ts.map +1 -0
- package/dist/MonacoContainer/styles.js +2 -0
- package/dist/MonacoContainer/styles.js.map +1 -0
- package/dist/MonacoContainer/types.d.ts +11 -0
- package/dist/MonacoContainer/types.d.ts.map +1 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.cjs +2 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.cjs.map +1 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +2 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/dist/hooks/useMonaco/index.cjs +2 -0
- package/dist/hooks/useMonaco/index.cjs.map +1 -0
- package/dist/hooks/useMonaco/index.d.ts +4 -0
- package/dist/hooks/useMonaco/index.d.ts.map +1 -0
- package/dist/hooks/useMonaco/index.js +2 -0
- package/dist/hooks/useMonaco/index.js.map +1 -0
- package/dist/hooks/useMount/index.cjs +2 -0
- package/dist/hooks/useMount/index.cjs.map +1 -0
- package/dist/hooks/useMount/index.d.ts +4 -0
- package/dist/hooks/useMount/index.d.ts.map +1 -0
- package/dist/hooks/useMount/index.js +2 -0
- package/dist/hooks/useMount/index.js.map +1 -0
- package/dist/hooks/usePrevious/index.cjs +2 -0
- package/dist/hooks/usePrevious/index.cjs.map +1 -0
- package/dist/hooks/usePrevious/index.d.ts +3 -0
- package/dist/hooks/usePrevious/index.d.ts.map +1 -0
- package/dist/hooks/usePrevious/index.js +2 -0
- package/dist/hooks/usePrevious/index.js.map +1 -0
- package/dist/hooks/useUpdate/index.cjs +2 -0
- package/dist/hooks/useUpdate/index.cjs.map +1 -0
- package/dist/hooks/useUpdate/index.d.ts +4 -0
- package/dist/hooks/useUpdate/index.d.ts.map +1 -0
- package/dist/hooks/useUpdate/index.js +2 -0
- package/dist/hooks/useUpdate/index.js.map +1 -0
- package/dist/index.cjs +3 -625
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -231
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -588
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.ts +20 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +9 -14
- package/dist/index.d.cts +0 -231
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# @willbooster/monaco-react
|
|
2
2
|
|
|
3
|
+
[](https://github.com/WillBooster/monaco-react/actions/workflows/test.yml)
|
|
4
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
3
5
|
[](https://www.npmjs.com/package/@willbooster/monaco-react)
|
|
4
6
|
[](https://www.npmjs.com/package/@willbooster/monaco-react)
|
|
5
|
-
[](https://github.com/WillBooster/monaco-react/actions/workflows/test.yml)
|
|
6
7
|
|
|
7
8
|
React components for [Monaco Editor](https://microsoft.github.io/monaco-editor/), powered by [`@willbooster/monaco-loader`](https://github.com/WillBooster/monaco-loader).
|
|
8
9
|
|
|
@@ -11,10 +12,10 @@ This package is a maintained fork of [`suren-atoyan/monaco-react`](https://githu
|
|
|
11
12
|
## Installation
|
|
12
13
|
|
|
13
14
|
```bash
|
|
14
|
-
yarn add @willbooster/monaco-react
|
|
15
|
+
yarn add @willbooster/monaco-react
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
`react
|
|
18
|
+
`react` and `react-dom` are peer dependencies. `monaco-editor` is a direct dependency for Monaco type resolution. This package supports React 19.x, Node.js 24 or newer, and is tested with Next.js 16.
|
|
18
19
|
|
|
19
20
|
## Usage
|
|
20
21
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("@willbooster/monaco-loader"),n=require("../MonacoContainer/index.cjs"),o=require("../hooks/useMount/index.cjs"),u=require("../hooks/useUpdate/index.cjs"),i=require("../utils/index.cjs"),l=require("react/jsx-runtime");module.exports=function({original:a,modified:d,language:c,originalLanguage:s,modifiedLanguage:g,originalModelPath:M,modifiedModelPath:f,keepCurrentOriginalModel:p=!1,keepCurrentModifiedModel:h=!1,theme:m="light",loading:x="Loading...",options:v={},height:O="100%",width:C="100%",className:E,wrapperProps:j={},beforeMount:q=i.noop,onMount:R=i.noop}){const[k,b]=r.useState(!1),[L,w]=r.useState(!0),P=r.useRef(null),y=r.useRef(null),S=r.useRef(null),D=r.useRef(R),V=r.useRef(q),_=r.useRef(!1);o(()=>{const e=t.init();return e.then(e=>(y.current=e)&&w(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>P.current?function(){const e=P.current,r=null==e?void 0:e.getModel();var t,n;null==e||e.setModel(null),null==e||e.dispose(),p||null!=r&&r.original.isDisposed()||null==r||null==(t=r.original)||t.dispose();h||null!=r&&r.modified.isDisposed()||null==r||null==(n=r.modified)||n.dispose();P.current=null,_.current=!1,b(!1)}():e.cancel()}),u(()=>{if(P.current&&y.current){const e=P.current.getOriginalEditor(),r=i.getOrCreateModel(y.current,a||"",s||c||"text",M||"");r!==e.getModel()&&e.setModel(r)}},[M],k),u(()=>{if(P.current&&y.current){const e=P.current.getModifiedEditor(),r=i.getOrCreateModel(y.current,d||"",g||c||"text",f||"");r!==e.getModel()&&e.setModel(r)}},[f],k),u(()=>{const e=P.current.getModifiedEditor();e.getOption(y.current.editor.EditorOption.readOnly)?e.setValue(d||""):d!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:d||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[d],k),u(()=>{var e;null==(e=P.current)||null==(e=e.getModel())||e.original.setValue(a||"")},[a],k),u(()=>{const{original:e,modified:r}=P.current.getModel();y.current.editor.setModelLanguage(e,s||c||"text"),y.current.editor.setModelLanguage(r,g||c||"text")},[c,s,g],k),u(()=>{var e;null==(e=y.current)||e.editor.setTheme(m)},[m],k),u(()=>{var e;null==(e=P.current)||e.updateOptions(v)},[v],k);const N=r.useCallback(()=>{var e;if(!y.current)return;V.current(y.current);const r=i.getOrCreateModel(y.current,a||"",s||c||"text",M||""),t=i.getOrCreateModel(y.current,d||"",g||c||"text",f||"");null==(e=P.current)||e.setModel({original:r,modified:t})},[c,d,g,a,s,M,f]),T=r.useCallback(()=>{var r;!_.current&&S.current&&(P.current=y.current.editor.createDiffEditor(S.current,e.objectSpread2({automaticLayout:!0},v)),N(),null==(r=y.current)||r.editor.setTheme(m),b(!0),_.current=!0)},[v,m,N]);return r.useEffect(()=>{k&&D.current(P.current,y.current)},[k]),r.useEffect(()=>{L||k||T()},[L,k,T]),l.jsx(n,{width:C,height:O,isEditorReady:k,loading:x,_ref:S,className:E,wrapperProps:j})};
|
|
3
|
+
//# sourceMappingURL=DiffEditor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiffEditor.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { DiffEditorProps } from './types';
|
|
3
|
+
declare function DiffEditor({ original, modified, language, originalLanguage, modifiedLanguage, originalModelPath, modifiedModelPath, keepCurrentOriginalModel, keepCurrentModifiedModel, theme, loading, options, height, width, className, wrapperProps, beforeMount, onMount }: DiffEditorProps): ReactElement;
|
|
4
|
+
export default DiffEditor;
|
|
5
|
+
//# sourceMappingURL=DiffEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiffEditor.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/DiffEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAGjE,iBAAS,UAAU,CAAC,EAClB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAgC,EAChC,wBAAgC,EAChC,KAAe,EACf,OAAsB,EACtB,OAAY,EACZ,MAAe,EACf,KAAc,EACd,SAAS,EACT,YAAiB,EACjB,WAAkB,EAClB,OAAc,EACf,EAAE,eAAe,GAAG,YAAY,CA0MhC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";import i from"@willbooster/monaco-loader";import l from"../MonacoContainer/index.js";import u from"../hooks/useMount/index.js";import d from"../hooks/useUpdate/index.js";import{noop as a,getOrCreateModel as c}from"../utils/index.js";import{jsx as s}from"react/jsx-runtime";function g({original:g,modified:p,language:m,originalLanguage:f,modifiedLanguage:M,originalModelPath:h,modifiedModelPath:x,keepCurrentOriginalModel:v=!1,keepCurrentModifiedModel:j=!1,theme:E="light",loading:L="Loading...",options:O={},height:k="100%",width:w="100%",className:P,wrapperProps:b={},beforeMount:y=a,onMount:C=a}){const[D,V]=r(!1),[_,N]=r(!0),R=t(null),S=t(null),T=t(null),U=t(C),z=t(y),B=t(!1);u(()=>{const e=i.init();return e.then(e=>(S.current=e)&&N(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>R.current?function(){const e=R.current,r=null==e?void 0:e.getModel();var t,n;null==e||e.setModel(null),null==e||e.dispose(),v||null!=r&&r.original.isDisposed()||null==r||null==(t=r.original)||t.dispose();j||null!=r&&r.modified.isDisposed()||null==r||null==(n=r.modified)||n.dispose();R.current=null,B.current=!1,V(!1)}():e.cancel()}),d(()=>{if(R.current&&S.current){const e=R.current.getOriginalEditor(),r=c(S.current,g||"",f||m||"text",h||"");r!==e.getModel()&&e.setModel(r)}},[h],D),d(()=>{if(R.current&&S.current){const e=R.current.getModifiedEditor(),r=c(S.current,p||"",M||m||"text",x||"");r!==e.getModel()&&e.setModel(r)}},[x],D),d(()=>{const e=R.current.getModifiedEditor();e.getOption(S.current.editor.EditorOption.readOnly)?e.setValue(p||""):p!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:p||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[p],D),d(()=>{var e;null==(e=R.current)||null==(e=e.getModel())||e.original.setValue(g||"")},[g],D),d(()=>{const{original:e,modified:r}=R.current.getModel();S.current.editor.setModelLanguage(e,f||m||"text"),S.current.editor.setModelLanguage(r,M||m||"text")},[m,f,M],D),d(()=>{var e;null==(e=S.current)||e.editor.setTheme(E)},[E],D),d(()=>{var e;null==(e=R.current)||e.updateOptions(O)},[O],D);const F=n(()=>{var e;if(!S.current)return;z.current(S.current);const r=c(S.current,g||"",f||m||"text",h||""),t=c(S.current,p||"",M||m||"text",x||"");null==(e=R.current)||e.setModel({original:r,modified:t})},[m,p,M,g,f,h,x]),H=n(()=>{var r;!B.current&&T.current&&(R.current=S.current.editor.createDiffEditor(T.current,e({automaticLayout:!0},O)),F(),null==(r=S.current)||r.editor.setTheme(E),V(!0),B.current=!0)},[O,E,F]);return o(()=>{D&&U.current(R.current,S.current)},[D]),o(()=>{_||D||H()},[_,D,H]),s(l,{width:w,height:k,isEditorReady:D,loading:L,_ref:T,className:P,wrapperProps:b})}export{g as default};
|
|
3
|
+
//# sourceMappingURL=DiffEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiffEditor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/DiffEditor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n"],"names":["index","memo","DiffEditor"],"mappings":"kEAMAA,EAAeC,EAAAA,KAAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/index.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,SAAS,CAAC;;AAExB,wBAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/DiffEditor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n"],"names":["index","memo","DiffEditor"],"mappings":"4DAMA,IAAAA,EAAeC,EAAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/index.spec.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { Monaco } from '..';
|
|
4
|
+
export type MonacoDiffEditor = editor.IStandaloneDiffEditor;
|
|
5
|
+
export type DiffOnMount = (editor: MonacoDiffEditor, monaco: Monaco) => void;
|
|
6
|
+
export type DiffBeforeMount = (monaco: Monaco) => void;
|
|
7
|
+
export interface DiffEditorProps {
|
|
8
|
+
/**
|
|
9
|
+
* The original source (left one) value
|
|
10
|
+
*/
|
|
11
|
+
original?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The modified source (right one) value
|
|
14
|
+
*/
|
|
15
|
+
modified?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Language for the both models - original and modified
|
|
18
|
+
*/
|
|
19
|
+
language?: string;
|
|
20
|
+
/**
|
|
21
|
+
* This prop gives you the opportunity to specify the language of the
|
|
22
|
+
* original source separately, otherwise, it will get the value of the language property
|
|
23
|
+
*/
|
|
24
|
+
originalLanguage?: string;
|
|
25
|
+
/**
|
|
26
|
+
* This prop gives you the opportunity to specify the language of the
|
|
27
|
+
* modified source separately, otherwise, it will get the value of language property
|
|
28
|
+
*/
|
|
29
|
+
modifiedLanguage?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Path for the "original" model
|
|
32
|
+
* Will be passed as a third argument to `.createModel` method
|
|
33
|
+
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(originalModelPath))`
|
|
34
|
+
*/
|
|
35
|
+
originalModelPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Path for the "modified" model
|
|
38
|
+
* Will be passed as a third argument to `.createModel` method
|
|
39
|
+
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(modifiedModelPath))`
|
|
40
|
+
*/
|
|
41
|
+
modifiedModelPath?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Indicator whether to dispose the current original model when the DiffEditor is unmounted or not
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
keepCurrentOriginalModel?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Indicator whether to dispose the current modified model when the DiffEditor is unmounted or not
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
keepCurrentModifiedModel?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The theme for the monaco
|
|
54
|
+
* Available options "vs-dark" | "light"
|
|
55
|
+
* Define new themes by `monaco.editor.defineTheme`
|
|
56
|
+
* @default "light"
|
|
57
|
+
*/
|
|
58
|
+
theme?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The loading screen before the editor will be mounted
|
|
61
|
+
* @default "loading..."
|
|
62
|
+
*/
|
|
63
|
+
loading?: ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* IDiffEditorConstructionOptions
|
|
66
|
+
*/
|
|
67
|
+
options?: editor.IDiffEditorConstructionOptions;
|
|
68
|
+
/**
|
|
69
|
+
* Width of the editor wrapper
|
|
70
|
+
* @default "100%"
|
|
71
|
+
*/
|
|
72
|
+
width?: number | string;
|
|
73
|
+
/**
|
|
74
|
+
* Height of the editor wrapper
|
|
75
|
+
* @default "100%"
|
|
76
|
+
*/
|
|
77
|
+
height?: number | string;
|
|
78
|
+
/**
|
|
79
|
+
* Class name for the editor container
|
|
80
|
+
*/
|
|
81
|
+
className?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Props applied to the wrapper element
|
|
84
|
+
*/
|
|
85
|
+
wrapperProps?: object;
|
|
86
|
+
/**
|
|
87
|
+
* Signature: function(monaco: Monaco) => void
|
|
88
|
+
* An event is emitted before the editor is mounted
|
|
89
|
+
* It gets the monaco instance as a first argument
|
|
90
|
+
* Defaults to "noop"
|
|
91
|
+
*/
|
|
92
|
+
beforeMount?: DiffBeforeMount;
|
|
93
|
+
/**
|
|
94
|
+
* Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void
|
|
95
|
+
* An event is emitted when the editor is mounted
|
|
96
|
+
* It gets the editor instance as a first argument and the monaco instance as a second
|
|
97
|
+
* Defaults to "noop"
|
|
98
|
+
*/
|
|
99
|
+
onMount?: DiffOnMount;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/DiffEditor/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAEjC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAE7E,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,8BAA8B,CAAC;IAEhD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("react"),t=require("@willbooster/monaco-loader"),n=require("../hooks/useMount/index.cjs"),u=require("../hooks/useUpdate/index.cjs"),o=require("../hooks/usePrevious/index.cjs"),c=require("../utils/index.cjs"),i=require("../MonacoContainer/index.cjs"),l=require("react/jsx-runtime");const a=new Map;module.exports=function({defaultValue:s,defaultLanguage:d,defaultPath:v,value:g,language:p,path:f,theme:h="light",line:M,loading:w="Loading...",options:R={},overrideServices:m={},saveViewState:x=!0,keepCurrentModel:S=!1,width:V="100%",height:j="100%",className:q,wrapperProps:C={},beforeMount:k=c.noop,onMount:E=c.noop,onChange:L,onValidate:O=c.noop}){const[b,P]=r.useState(!1),[y,_]=r.useState(!0),D=r.useRef(null),N=r.useRef(void 0),T=r.useRef(null),U=r.useRef(E),z=r.useRef(k),B=r.useRef(void 0),F=r.useRef(g),H=o(f),A=r.useRef(!1),G=r.useRef(!1);n(()=>{const e=t.init();return e.then(e=>(D.current=e)&&_(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>N.current?function(){var e,r;null==(e=B.current)||e.dispose(),S?x&&a.set(f,N.current.saveViewState()):null==(r=N.current.getModel())||r.dispose();N.current.dispose(),N.current=void 0,A.current=!1,P(!1)}():e.cancel()}),u(()=>{var e;const r=c.getOrCreateModel(D.current,s||g||"",d||p||"",f||v||"");var t,n,u;r!==(null==(e=N.current)?void 0:e.getModel())&&(x&&a.set(H,null==(t=N.current)?void 0:t.saveViewState()),null==(n=N.current)||n.setModel(r),x&&(null==(u=N.current)||u.restoreViewState(a.get(f))))},[f],b),u(()=>{var e;null==(e=N.current)||e.updateOptions(R)},[R],b),u(()=>{N.current&&void 0!==g&&(N.current.getOption(D.current.editor.EditorOption.readOnly)?N.current.setValue(g):g!==N.current.getValue()&&(G.current=!0,N.current.executeEdits("",[{range:N.current.getModel().getFullModelRange(),text:g,forceMoveMarkers:!0}]),N.current.pushUndoStop(),G.current=!1))},[g],b),u(()=>{var e;const r=null==(e=N.current)?void 0:e.getModel();var t;b&&r&&p&&(null==(t=D.current)||t.editor.setModelLanguage(r,p))},[p,b],b),u(()=>{var e;void 0!==M&&(null==(e=N.current)||e.revealLine(M))},[M],b),u(()=>{var e;null==(e=D.current)||e.editor.setTheme(h)},[h],b);const I=r.useCallback(()=>{if(T.current&&D.current&&!A.current){z.current(D.current);const r=f||v,t=c.getOrCreateModel(D.current,g||s||"",d||p||"",r||""),n=D.current.editor.create(T.current,e.objectSpread2({model:t,automaticLayout:!0},R),m);N.current=n,x&&n.restoreViewState(a.get(r)),D.current.editor.setTheme(h),void 0!==M&&n.revealLine(M),P(!0),A.current=!0}},[s,d,v,g,p,f,R,m,x,h,M]);return r.useEffect(()=>{b&&U.current(N.current,D.current)},[b]),r.useEffect(()=>{y||b||I()},[y,b,I]),F.current=g,r.useEffect(()=>{var e,r;b&&L&&(null==(e=B.current)||e.dispose(),B.current=null==(r=N.current)?void 0:r.onDidChangeModelContent(e=>{G.current||L(N.current.getValue(),e)}))},[b,L]),r.useEffect(()=>{if(b){const e=D.current.editor.onDidChangeMarkers(e=>{var r;const t=null==(r=N.current.getModel())?void 0:r.uri;if(t){if(e.find(e=>e.path===t.path)){const e=D.current.editor.getModelMarkers({resource:t});null==O||O(e)}}});return()=>{null==e||e.dispose()}}return()=>{}},[b,O]),l.jsx(i,{width:V,height:j,isEditorReady:b,loading:w,_ref:T,className:q,wrapperProps:C})};
|
|
3
|
+
//# sourceMappingURL=Editor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Editor.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { EditorProps } from './types';
|
|
3
|
+
declare function Editor({ defaultValue, defaultLanguage, defaultPath, value, language, path, theme, line, loading, options, overrideServices, saveViewState, keepCurrentModel, width, height, className, wrapperProps, beforeMount, onMount, onChange, onValidate }: EditorProps): ReactElement;
|
|
4
|
+
export default Editor;
|
|
5
|
+
//# sourceMappingURL=Editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/Editor/Editor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,iBAAS,MAAM,CAAC,EACd,YAAY,EACZ,eAAe,EACf,WAAW,EACX,KAAK,EACL,QAAQ,EACR,IAAI,EAEJ,KAAe,EACf,IAAI,EACJ,OAAsB,EACtB,OAAY,EACZ,gBAAqB,EACrB,aAAoB,EACpB,gBAAwB,EAExB,KAAc,EACd,MAAe,EACf,SAAS,EACT,YAAiB,EAEjB,WAAkB,EAClB,OAAc,EACd,QAAQ,EACR,UAAiB,EAClB,EAAE,WAAW,GAAG,YAAY,CA8O5B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";import u from"@willbooster/monaco-loader";import i from"../hooks/useMount/index.js";import l from"../hooks/useUpdate/index.js";import a from"../hooks/usePrevious/index.js";import{noop as c,getOrCreateModel as s}from"../utils/index.js";import d from"../MonacoContainer/index.js";import{jsx as p}from"react/jsx-runtime";const v=new Map;function g({defaultValue:g,defaultLanguage:m,defaultPath:f,value:h,language:M,path:w,theme:V="light",line:x,loading:j="Loading...",options:S={},overrideServices:k={},saveViewState:C=!0,keepCurrentModel:L=!1,width:P="100%",height:b="100%",className:y,wrapperProps:O={},beforeMount:E=c,onMount:_=c,onChange:D,onValidate:N=c}){const[R,T]=r(!1),[U,z]=r(!0),B=t(null),F=t(void 0),H=t(null),q=t(_),A=t(E),G=t(void 0),I=t(h),J=a(w),K=t(!1),Q=t(!1);i(()=>{const e=u.init();return e.then(e=>(B.current=e)&&z(!1)).catch(e=>"cancelation"!==(null==e?void 0:e.type)&&console.error("Monaco initialization: error:",e)),()=>F.current?function(){var e,r;null==(e=G.current)||e.dispose(),L?C&&v.set(w,F.current.saveViewState()):null==(r=F.current.getModel())||r.dispose();F.current.dispose(),F.current=void 0,K.current=!1,T(!1)}():e.cancel()}),l(()=>{var e;const r=s(B.current,g||h||"",m||M||"",w||f||"");var t,n,o;r!==(null==(e=F.current)?void 0:e.getModel())&&(C&&v.set(J,null==(t=F.current)?void 0:t.saveViewState()),null==(n=F.current)||n.setModel(r),C&&(null==(o=F.current)||o.restoreViewState(v.get(w))))},[w],R),l(()=>{var e;null==(e=F.current)||e.updateOptions(S)},[S],R),l(()=>{F.current&&void 0!==h&&(F.current.getOption(B.current.editor.EditorOption.readOnly)?F.current.setValue(h):h!==F.current.getValue()&&(Q.current=!0,F.current.executeEdits("",[{range:F.current.getModel().getFullModelRange(),text:h,forceMoveMarkers:!0}]),F.current.pushUndoStop(),Q.current=!1))},[h],R),l(()=>{var e;const r=null==(e=F.current)?void 0:e.getModel();var t;R&&r&&M&&(null==(t=B.current)||t.editor.setModelLanguage(r,M))},[M,R],R),l(()=>{var e;void 0!==x&&(null==(e=F.current)||e.revealLine(x))},[x],R),l(()=>{var e;null==(e=B.current)||e.editor.setTheme(V)},[V],R);const W=n(()=>{if(H.current&&B.current&&!K.current){A.current(B.current);const r=w||f,t=s(B.current,h||g||"",m||M||"",r||""),n=B.current.editor.create(H.current,e({model:t,automaticLayout:!0},S),k);F.current=n,C&&n.restoreViewState(v.get(r)),B.current.editor.setTheme(V),void 0!==x&&n.revealLine(x),T(!0),K.current=!0}},[g,m,f,h,M,w,S,k,C,V,x]);return o(()=>{R&&q.current(F.current,B.current)},[R]),o(()=>{U||R||W()},[U,R,W]),I.current=h,o(()=>{var e,r;R&&D&&(null==(e=G.current)||e.dispose(),G.current=null==(r=F.current)?void 0:r.onDidChangeModelContent(e=>{Q.current||D(F.current.getValue(),e)}))},[R,D]),o(()=>{if(R){const e=B.current.editor.onDidChangeMarkers(e=>{var r;const t=null==(r=F.current.getModel())?void 0:r.uri;if(t){if(e.find(e=>e.path===t.path)){const e=B.current.editor.getModelMarkers({resource:t});null==N||N(e)}}});return()=>{null==e||e.dispose()}}return()=>{}},[R,N]),p(d,{width:P,height:b,isEditorReady:R,loading:j,_ref:H,className:y,wrapperProps:O})}export{g as default};
|
|
3
|
+
//# sourceMappingURL=Editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Editor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n"],"names":["Editor","memo"],"mappings":"8DAMAA,EAAeC,EAAAA,KAAKD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Editor/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,cAAc,SAAS,CAAC;;AAExB,wBAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Editor/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport Editor from './Editor';\n\nexport * from './types';\n\nexport default memo(Editor);\n"],"names":["Editor","memo"],"mappings":"wDAMA,IAAAA,EAAeC,EAAKD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/Editor/index.spec.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { editor } from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
2
|
+
import type { Monaco } from '..';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
export type OnMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => void;
|
|
5
|
+
export type BeforeMount = (monaco: Monaco) => void;
|
|
6
|
+
export type OnChange = (value: string | undefined, ev: editor.IModelContentChangedEvent) => void;
|
|
7
|
+
export type OnValidate = (markers: editor.IMarker[]) => void;
|
|
8
|
+
export interface EditorProps {
|
|
9
|
+
/**
|
|
10
|
+
* Default value of the current model
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Default language of the current model
|
|
15
|
+
*/
|
|
16
|
+
defaultLanguage?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Default path of the current model
|
|
19
|
+
* Will be passed as the third argument to `.createModel` method
|
|
20
|
+
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath))`
|
|
21
|
+
*/
|
|
22
|
+
defaultPath?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Value of the current model
|
|
25
|
+
*/
|
|
26
|
+
value?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Language of the current model
|
|
29
|
+
*/
|
|
30
|
+
language?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Path of the current model
|
|
33
|
+
* Will be passed as the third argument to `.createModel` method
|
|
34
|
+
* `monaco.editor.createModel(..., ..., monaco.Uri.parse(defaultPath))`
|
|
35
|
+
*/
|
|
36
|
+
path?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The theme for the monaco
|
|
39
|
+
* Available options "vs-dark" | "light"
|
|
40
|
+
* Define new themes by `monaco.editor.defineTheme`
|
|
41
|
+
* @default "light"
|
|
42
|
+
*/
|
|
43
|
+
theme?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The line to jump on it
|
|
46
|
+
*/
|
|
47
|
+
line?: number;
|
|
48
|
+
/**
|
|
49
|
+
* The loading screen before the editor will be mounted
|
|
50
|
+
* @default "Loading..."
|
|
51
|
+
*/
|
|
52
|
+
loading?: ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* IStandaloneEditorConstructionOptions
|
|
55
|
+
*/
|
|
56
|
+
options?: editor.IStandaloneEditorConstructionOptions;
|
|
57
|
+
/**
|
|
58
|
+
* IEditorOverrideServices
|
|
59
|
+
*/
|
|
60
|
+
overrideServices?: editor.IEditorOverrideServices;
|
|
61
|
+
/**
|
|
62
|
+
* Indicator whether to save the models' view states between model changes or not
|
|
63
|
+
* Defaults to true
|
|
64
|
+
*/
|
|
65
|
+
saveViewState?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Indicator whether to dispose the current model when the Editor is unmounted or not
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
keepCurrentModel?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Width of the editor wrapper
|
|
73
|
+
* @default "100%"
|
|
74
|
+
*/
|
|
75
|
+
width?: number | string;
|
|
76
|
+
/**
|
|
77
|
+
* Height of the editor wrapper
|
|
78
|
+
* @default "100%"
|
|
79
|
+
*/
|
|
80
|
+
height?: number | string;
|
|
81
|
+
/**
|
|
82
|
+
* Class name for the editor container
|
|
83
|
+
*/
|
|
84
|
+
className?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Props applied to the wrapper element
|
|
87
|
+
*/
|
|
88
|
+
wrapperProps?: object;
|
|
89
|
+
/**
|
|
90
|
+
* Signature: function(monaco: Monaco) => void
|
|
91
|
+
* An event is emitted before the editor is mounted
|
|
92
|
+
* It gets the monaco instance as a first argument
|
|
93
|
+
* Defaults to "noop"
|
|
94
|
+
*/
|
|
95
|
+
beforeMount?: BeforeMount;
|
|
96
|
+
/**
|
|
97
|
+
* Signature: function(editor: monaco.editor.IStandaloneCodeEditor, monaco: Monaco) => void
|
|
98
|
+
* An event is emitted when the editor is mounted
|
|
99
|
+
* It gets the editor instance as a first argument and the monaco instance as a second
|
|
100
|
+
* Defaults to "noop"
|
|
101
|
+
*/
|
|
102
|
+
onMount?: OnMount;
|
|
103
|
+
/**
|
|
104
|
+
* Signature: function(value: string | undefined, ev: monaco.editor.IModelContentChangedEvent) => void
|
|
105
|
+
* An event is emitted when the content of the current model is changed
|
|
106
|
+
*/
|
|
107
|
+
onChange?: OnChange;
|
|
108
|
+
/**
|
|
109
|
+
* Signature: function(markers: monaco.editor.IMarker[]) => void
|
|
110
|
+
* An event is emitted when the content of the current model is changed
|
|
111
|
+
* and the current model markers are ready
|
|
112
|
+
* Defaults to "noop"
|
|
113
|
+
*/
|
|
114
|
+
onValidate?: OnValidate;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Editor/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,qBAAqB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAErF,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,yBAAyB,KAAK,IAAI,CAAC;AAEjG,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,oCAAoC,CAAC;IAEtD;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,uBAAuB,CAAC;IAElD;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loading.cjs","sources":["../../src/Loading/Loading.tsx"],"sourcesContent":["import type { PropsWithChildren, ReactElement } from 'react';\n\nimport styles from './styles';\n\nfunction Loading({ children }: PropsWithChildren): ReactElement {\n return <div style={styles.container}>{children}</div>;\n}\n\nexport default Loading;\n"],"names":["children","_jsx","style","styles","container"],"mappings":"yFAIA,UAAiBA,SAAEA,IACjB,OAAOC,EAAAA,IAAA,MAAA,CAAKC,MAAOC,EAAOC,UAAUJ,SAAEA,GACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loading.d.ts","sourceRoot":"","sources":["../../src/Loading/Loading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI7D,iBAAS,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAE9D;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loading.js","sources":["../../src/Loading/Loading.tsx"],"sourcesContent":["import type { PropsWithChildren, ReactElement } from 'react';\n\nimport styles from './styles';\n\nfunction Loading({ children }: PropsWithChildren): ReactElement {\n return <div style={styles.container}>{children}</div>;\n}\n\nexport default Loading;\n"],"names":["Loading","children","_jsx","style","styles","container"],"mappings":"mEAIA,SAASA,GAAQC,SAAEA,IACjB,OAAOC,EAAA,MAAA,CAAKC,MAAOC,EAAOC,UAAUJ,SAAEA,GACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Loading/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/Loading/index.spec.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.cjs","sources":["../../src/Loading/styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n container: {\n display: 'flex',\n height: '100%',\n width: '100%',\n justifyContent: 'center',\n alignItems: 'center',\n },\n};\n\nexport default styles;\n"],"names":["container","display","height","width","justifyContent","alignItems"],"mappings":"4BAE8C,CAC5CA,UAAW,CACTC,QAAS,OACTC,OAAQ,OACRC,MAAO,OACPC,eAAgB,SAChBC,WAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/Loading/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAQzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../src/Loading/styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n container: {\n display: 'flex',\n height: '100%',\n width: '100%',\n justifyContent: 'center',\n alignItems: 'center',\n },\n};\n\nexport default styles;\n"],"names":["styles","container","display","height","width","justifyContent","alignItems"],"mappings":"AAEA,MAAMA,EAAwC,CAC5CC,UAAW,CACTC,QAAS,OACTC,OAAQ,OACRC,MAAO,OACPC,eAAgB,SAChBC,WAAY"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("../_virtual/_rollupPluginBabelHelpers.cjs"),r=require("./styles.cjs"),i=require("../Loading/Loading.cjs"),t=require("react/jsx-runtime");module.exports=function({width:s,height:a,isEditorReady:d,loading:c,_ref:l,className:o,wrapperProps:p}){return t.jsxs("section",e.objectSpread2(e.objectSpread2({style:e.objectSpread2(e.objectSpread2({},r.wrapper),{},{width:s,height:a})},p),{},{children:[!d&&t.jsx(i,{children:c}),t.jsx("div",{ref:l,style:e.objectSpread2(e.objectSpread2({},r.fullWidth),!d&&r.hide),className:o})]}))};
|
|
2
|
+
//# sourceMappingURL=MonacoContainer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoContainer.cjs","sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\n\nimport styles from './styles';\nimport Loading from '../Loading';\nimport type { ContainerProps } from './types';\n\n// ** forwardref render functions do not support proptypes or defaultprops **\n// one of the reasons why we use a separate prop for passing ref instead of using forwardref\n\nfunction MonacoContainer({\n width,\n height,\n isEditorReady,\n loading,\n _ref,\n className,\n wrapperProps,\n}: ContainerProps): ReactElement {\n return (\n <section style={{ ...styles.wrapper, width, height }} {...wrapperProps}>\n {!isEditorReady && <Loading>{loading}</Loading>}\n <div ref={_ref} style={{ ...styles.fullWidth, ...(!isEditorReady && styles.hide) }} className={className} />\n </section>\n );\n}\n\nexport default MonacoContainer;\n"],"names":["width","height","isEditorReady","loading","_ref","className","wrapperProps","_jsxs","_objectSpread","style","styles","wrapper","children","_jsx","Loading","ref","fullWidth","hide"],"mappings":"oLASA,UAAyBA,MACvBA,EAAKC,OACLA,EAAMC,cACNA,EAAaC,QACbA,EAAOC,KACPA,EAAIC,UACJA,EAASC,aACTA,IAEA,OACEC,OAAA,UAAAC,EAAAA,cAAAA,gBAAA,CAASC,MAAKD,EAAAA,cAAAA,gBAAA,CAAA,EAAOE,EAAOC,SAAO,GAAA,CAAEX,QAAOC,YAAcK,GAAY,GAAA,CAAAM,WAClEV,GAAiBW,EAAAA,IAACC,EAAO,CAAAF,SAAET,IAC7BU,EAAAA,IAAA,MAAA,CAAKE,IAAKX,EAAMK,MAAKD,EAAAA,cAAAA,EAAAA,iBAAOE,EAAOM,YAAgBd,GAAiBQ,EAAOO,MAASZ,UAAWA,OAGrG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { ContainerProps } from './types';
|
|
3
|
+
declare function MonacoContainer({ width, height, isEditorReady, loading, _ref, className, wrapperProps }: ContainerProps): ReactElement;
|
|
4
|
+
export default MonacoContainer;
|
|
5
|
+
//# sourceMappingURL=MonacoContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoContainer.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C,iBAAS,eAAe,CAAC,EACvB,KAAK,EACL,MAAM,EACN,aAAa,EACb,OAAO,EACP,IAAI,EACJ,SAAS,EACT,YAAY,EACb,EAAE,cAAc,GAAG,YAAY,CAO/B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{objectSpread2 as r}from"../_virtual/_rollupPluginBabelHelpers.js";import e from"./styles.js";import i from"../Loading/Loading.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";function s({width:s,height:a,isEditorReady:l,loading:d,_ref:p,className:m,wrapperProps:n}){return t("section",r(r({style:r(r({},e.wrapper),{},{width:s,height:a})},n),{},{children:[!l&&o(i,{children:d}),o("div",{ref:p,style:r(r({},e.fullWidth),!l&&e.hide),className:m})]}))}export{s as default};
|
|
2
|
+
//# sourceMappingURL=MonacoContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoContainer.js","sources":["../../src/MonacoContainer/MonacoContainer.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\n\nimport styles from './styles';\nimport Loading from '../Loading';\nimport type { ContainerProps } from './types';\n\n// ** forwardref render functions do not support proptypes or defaultprops **\n// one of the reasons why we use a separate prop for passing ref instead of using forwardref\n\nfunction MonacoContainer({\n width,\n height,\n isEditorReady,\n loading,\n _ref,\n className,\n wrapperProps,\n}: ContainerProps): ReactElement {\n return (\n <section style={{ ...styles.wrapper, width, height }} {...wrapperProps}>\n {!isEditorReady && <Loading>{loading}</Loading>}\n <div ref={_ref} style={{ ...styles.fullWidth, ...(!isEditorReady && styles.hide) }} className={className} />\n </section>\n );\n}\n\nexport default MonacoContainer;\n"],"names":["MonacoContainer","width","height","isEditorReady","loading","_ref","className","wrapperProps","_jsxs","_objectSpread","style","styles","wrapper","children","_jsx","Loading","ref","fullWidth","hide"],"mappings":"2LASA,SAASA,GAAgBC,MACvBA,EAAKC,OACLA,EAAMC,cACNA,EAAaC,QACbA,EAAOC,KACPA,EAAIC,UACJA,EAASC,aACTA,IAEA,OACEC,EAAA,UAAAC,EAAAA,EAAA,CAASC,MAAKD,EAAAA,EAAA,CAAA,EAAOE,EAAOC,SAAO,GAAA,CAAEX,QAAOC,YAAcK,GAAY,GAAA,CAAAM,WAClEV,GAAiBW,EAACC,EAAO,CAAAF,SAAET,IAC7BU,EAAA,MAAA,CAAKE,IAAKX,EAAMK,MAAKD,EAAAA,KAAOE,EAAOM,YAAgBd,GAAiBQ,EAAOO,MAASZ,UAAWA,OAGrG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/MonacoContainer/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n"],"names":["MonacoContainer","memo"],"mappings":"uEAIAA,EAAeC,EAAAA,KAAKD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/index.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAC;;AAEhD,wBAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/MonacoContainer/index.ts"],"sourcesContent":["import { memo } from 'react';\n\nimport MonacoContainer from './MonacoContainer';\n\nexport default memo(MonacoContainer);\n"],"names":["MonacoContainer","memo"],"mappings":"iEAIA,IAAAA,EAAeC,EAAKD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/index.spec.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.cjs","sources":["../../src/MonacoContainer/styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n wrapper: {\n display: 'flex',\n position: 'relative',\n textAlign: 'initial',\n },\n fullWidth: {\n width: '100%',\n },\n hide: {\n display: 'none',\n },\n};\n\nexport default styles;\n"],"names":["wrapper","display","position","textAlign","fullWidth","width","hide"],"mappings":"4BAE8C,CAC5CA,QAAS,CACPC,QAAS,OACTC,SAAU,WACVC,UAAW,WAEbC,UAAW,CACTC,MAAO,QAETC,KAAM,CACJL,QAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/MonacoContainer/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAYzC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../src/MonacoContainer/styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nconst styles: Record<string, CSSProperties> = {\n wrapper: {\n display: 'flex',\n position: 'relative',\n textAlign: 'initial',\n },\n fullWidth: {\n width: '100%',\n },\n hide: {\n display: 'none',\n },\n};\n\nexport default styles;\n"],"names":["styles","wrapper","display","position","textAlign","fullWidth","width","hide"],"mappings":"AAEA,MAAMA,EAAwC,CAC5CC,QAAS,CACPC,QAAS,OACTC,SAAU,WACVC,UAAW,WAEbC,UAAW,CACTC,MAAO,QAETC,KAAM,CACJL,QAAS"}
|