Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ This package is a maintained fork of [`suren-atoyan/monaco-react`](https://githu
## Installation

```bash
yarn add @willbooster/monaco-react monaco-editor
yarn add @willbooster/monaco-react
```

`react`, `react-dom`, and `monaco-editor` are peer dependencies. This package supports React 19.x, Node.js 24 or newer, and is tested with Next.js 16.
`react` and `react-dom` are peer dependencies. This package supports React 19.x, Node.js 24 or newer, and is tested with Next.js 16.

## Usage

Expand All @@ -34,13 +34,14 @@ export default function Page() {
## API

```tsx
import Editor, { DiffEditor, loader, useMonaco } from '@willbooster/monaco-react';
import Editor, { DiffEditor, loader, shikiToMonaco, useMonaco } from '@willbooster/monaco-react';
```

- `Editor`: Monaco standalone code editor component.
- `DiffEditor`: Monaco standalone diff editor component.
- `useMonaco`: React hook returning the initialized Monaco instance.
- `loader`: the `@willbooster/monaco-loader` instance used by the components.
- `shikiToMonaco`: Adapter for registering a Shiki highlighter with Monaco.

### Editor

Expand All @@ -65,6 +66,18 @@ import Editor, { DiffEditor, loader, useMonaco } from '@willbooster/monaco-react
<DiffEditor height="90vh" language="typescript" original="const value = 1;" modified="const value = 2;" />
```

### Shiki Integration

```tsx
import Editor, { shikiToMonaco } from '@willbooster/monaco-react';

<Editor
beforeMount={(monaco) => {
shikiToMonaco(highlighter, monaco);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The highlighter variable is used in the example but is not defined or initialized. This might be confusing for users unfamiliar with Shiki's initialization process. It would be helpful to add a comment or a brief initialization snippet to clarify where highlighter comes from.

Suggested change
shikiToMonaco(highlighter, monaco);
// highlighter is an instance created by Shiki's getHighlighter
shikiToMonaco(highlighter, monaco);

}}
/>;
```

### Loader Configuration

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.
Expand Down
Loading
Loading