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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dt-react-monaco-editor

v0.4.5

Published

Monaco editor for React.

Downloads

21

Readme

:house: 简述

基于开源 monaco-editor,根据业务使用场景进行二次封装,极大的降低了使用成本,使编辑器部分代码可控性更高。

功能

  • 除了 monaco-editor 自带的 language 外,还支持多种自定义的 language,如下表

| language | 描述 | 关键字自动补全 | 语法错误提示 | 语法高亮 | | :--- | :----: | :---: | :---: |----: | | dtsql | 通用的 sql language | yes ✅ | yes ✅ | yes ✅ |
| dtflink | flink sql language | yes ✅ | yes ✅ | yes ✅ |
| dtPython2 | python2 language | yes ✅ | yes ✅ | yes ✅ |
| dtPython3 | python3 language | yes ✅ | yes ✅ | yes ✅ |
| dtGreenplum | greenplum sql language | yes ✅ | no ❌ | yes ✅ |

  • 支持通过 props 传递的方式自定义自动补全项需要高亮的关键字

:eyes: 在线预览

https://DTStack.github.io/dt-react-monaco-editor/

:zap: 安装

使用 npm

npm i dt-react-monaco-editor --save

使用 yarn

yarn dt-react-monaco-editor --save

使用 pnpm

pnpm install dt-react-monaco-editor --save

:book: 如何使用

安装 monaco-editor-webpack-plugin

pnpm install monaco-editor-webpack-plugin

如果使用 monaco-editor-webpack-plugin 打包,那么还需要安装

pnpm install monaco-editor

webpack 配置部分

const monacoEditorWebpackPlugin = require('monaco-editor-webpack-plugin')
module.exports = {
    module: {
        rules: [
            // 打包 dt-react-monaco-editor 自定义语言的 worker 文件
            {
                test: /\.worker.[jt]s$/,
                include: (input: string) => {
                    return input.includes('dt-react-monaco-editor/lib/languages')
                }
                loader: 'worker-loader',
            },
        ]
    },
    plugins: [
        // 打包 monaco-editor 自带的 worker 文件并且自动注入 monaco 所需的环境变量
        new monacoEditorWebpackPlugin({
            features: [...],
            languages: [...],
        }),
    ]
}

monaco-editor-webpack-plugin 详细配置请看官方文档 monaco-editor-webpack-plugin

使用示例

    import { Editor } from 'dt-react-monaco-editor'
    <Editor
        value='select * from table_name'
        language="dtsql"
        options={{ readOnly: false }}
    />

依赖版本对照表

| dt-react-monaco-editor | monaco-editor | monaco-editor-webpack-plugin | webpack | | :--- | :----: | :---: | ---: | | <=0.1.4 | 0.13.1 | 1.4.0 | <=4.x | | >=0.3.0 | 0.30.1 | 6.0.0 | 5.x |

:wrench: 本地开发

clone & install dependencies

git clone 
pnpm install

启动本地服务器

pnpm storybook

静态服务部署构建

pnpm build-storybook

:blue_book: 相关资料