npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dt-react-monaco-editor

v2.0.0

Published

Monaco editor for React.

Readme

Monaco Editor React Components

NPM version NPM downloads

简体中文 | English

简介

提供 MonacoEditor 组件和 MonacoDiffEditor 组件,让在 React 中使用 Monaco Editor 更轻松。

安装

使用 npm

npm install dt-react-monaco-editor

或者使用 yarn

yarn add dt-react-monaco-editor

或者使用 pnpm

pnpm install dt-react-monaco-editor

集成

Monaco Editor 官方集成文档.

使用

MonacoEditor 组件

import { MonacoEditor } from 'dt-react-monaco-editor';

function App() {
    const editorRef = useRef();
    return (
        <MonacoEditor
            value=""
            language="javascript"
            style={{ height: 400, width: 600 }}
            onChange={(value) => {
                console.log(value);
            }}
            editorDidMount={(ins) => (editorRef.current = ins)}
        />
    );
}

MonacoDiffEditor 组件

import { MonacoDiffEditor } from 'dt-react-monaco-editor';

function App() {
    const editorRef = useRef();
    return (
        <MonacoDiffEditor
            original="const a = 1;"
            value="const a = 2;"
            language="sql"
            style={{ height: 400, width: 1200 }}
            onChange={(value) => {
                console.log(value);
            }}
            editorDidMount={(ins) => (editorRef.current = ins)}
        />
    );
}

属性

公共属性

公共属性在 MonacoEditorMonacoDiffEditor 上都可以使用。

  • theme 编辑器在渲染时应用的主题, 默认是 vs
  • language 编辑器的语言类型, 默认是 sql
  • syncvalue 属性变化时是否将新的 value 同步到编辑器中,如果 sync 属性是 true,编辑器就是受控的, 默认时 false
  • onChange 当编辑器的值变化时,触发这个回调。

MonacoEditor 属性

  • value 编辑器的值。
  • options Monaco Editor 的选项, 关联 monaco 接口IStandaloneEditorConstructionOptions
  • [deprecated] editorInstanceRef 获取 MonacoEditor 内部的 editor 实例。
  • onCursorSelection 当编辑器选中的内容发生变化时,触发这个回调。
  • onFocus 当编辑器聚焦时,触发这个回调。
  • onBlur 当编辑器失焦时,触发这个回调。
  • editorWillMount 在编辑器即将挂载时调用(类似于 React 的 componentWillMount)。
  • editorDidMount 当编辑器挂载完成时调用 (类似于 React 的 componentDidMount)。
  • editorWillUnMount 当编辑器即将销毁时调用 (类似于 React 的 componentWillUnmount)。

MonacoDiffEditor 属性

  • value modifiedEditor(右边的编辑器) 的值。
  • original originalEditor(左边的编辑器) 的值。
  • options Monaco DiffEditor 的选项, 关联 monaco 接口 IStandaloneDiffEditorConstructionOptions.
  • [deprecated] diffEditorInstanceRef 获取 MonacoDiffEditor 内部的 diffEditor 实例。
  • editorWillMount 在编辑器即将挂载时调用(类似于 React 的 componentWillMount)。
  • editorDidMount 当编辑器挂载完成时调用 (类似于 React 的 componentDidMount)。
  • editorWillUnMount 当编辑器即将销毁时调用 (类似于 React 的 componentWillUnmount)。

支持更多 SQL 语言功能

请看 monaco-sql-languages.

monaco-sql-languages 为大数据领域的多种 SQL 类型提供了高亮自动错误提示以及自动补全 功能,它支持按需引入并且很容易集成

更新日志