@willbooster/monaco-react 0.0.0-semantically-released
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/LICENSE +22 -0
- package/README.md +86 -0
- package/dist/index.cjs +618 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +231 -0
- package/dist/index.d.ts +231 -0
- package/dist/index.js +581 -0
- package/dist/index.js.map +1 -0
- package/package.json +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WillBooster
|
|
4
|
+
Copyright (c) 2018 Suren Atoyan
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @willbooster/monaco-react
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@willbooster/monaco-react)
|
|
4
|
+
[](https://www.npmjs.com/package/@willbooster/monaco-react)
|
|
5
|
+
[](https://github.com/WillBooster/monaco-react/actions/workflows/test.yml)
|
|
6
|
+
|
|
7
|
+
React components for [Monaco Editor](https://microsoft.github.io/monaco-editor/), powered by [`@willbooster/monaco-loader`](https://github.com/WillBooster/monaco-loader).
|
|
8
|
+
|
|
9
|
+
This package is a maintained fork of [`suren-atoyan/monaco-react`](https://github.com/suren-atoyan/monaco-react) published as `@willbooster/monaco-react`.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @willbooster/monaco-react monaco-editor
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`react`, `react-dom`, and `monaco-editor` are peer dependencies. React 16.8 through 19 are supported.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
'use client';
|
|
23
|
+
|
|
24
|
+
import Editor from '@willbooster/monaco-react';
|
|
25
|
+
|
|
26
|
+
export default function Page() {
|
|
27
|
+
return <Editor height="90vh" defaultLanguage="typescript" defaultValue="const answer = 42;" />;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`Editor`, `DiffEditor`, and `useMonaco` use React client-side hooks. In Next.js App Router projects, import and render them from a Client Component.
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import Editor, { DiffEditor, loader, useMonaco } from '@willbooster/monaco-react';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- `Editor`: Monaco standalone code editor component.
|
|
40
|
+
- `DiffEditor`: Monaco standalone diff editor component.
|
|
41
|
+
- `useMonaco`: React hook returning the initialized Monaco instance.
|
|
42
|
+
- `loader`: the `@willbooster/monaco-loader` instance used by the components.
|
|
43
|
+
|
|
44
|
+
### Editor
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<Editor
|
|
48
|
+
height="90vh"
|
|
49
|
+
defaultLanguage="javascript"
|
|
50
|
+
defaultValue="// hello"
|
|
51
|
+
onMount={(editor, monaco) => {
|
|
52
|
+
editor.focus();
|
|
53
|
+
monaco.editor.setTheme('vs-dark');
|
|
54
|
+
}}
|
|
55
|
+
onChange={(value) => {
|
|
56
|
+
console.log(value);
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### DiffEditor
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<DiffEditor height="90vh" language="typescript" original="const value = 1;" modified="const value = 2;" />
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Loader Configuration
|
|
68
|
+
|
|
69
|
+
By default Monaco is loaded from the CDN configured by `@willbooster/monaco-loader`. You can provide your own Monaco instance or loader paths before rendering an editor.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import * as monaco from 'monaco-editor';
|
|
73
|
+
import { loader } from '@willbooster/monaco-react';
|
|
74
|
+
|
|
75
|
+
loader.config({ monaco });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
yarn install
|
|
82
|
+
yarn check-for-ai
|
|
83
|
+
yarn test
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`yarn test` runs unit tests, builds the library, builds the Next.js e2e app, and runs Playwright against it.
|