🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@lsky/react-monaco-editor

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lsky/react-monaco-editor

<!-- logo --> <!-- logo -->

latest
Source
npmnpm
Version
1.0.0-rc.9
Version published
Maintainers
1
Created
Source

logo

react-monaco-editor

Monaco Editor for React

Installing


$ yarn add @lsky/react-monaco-editor

Example

Editor


import React from 'react';
import examples from '@src/examples'
// component
import MonacoEditor from '@lsky/react-monaco-editor'


class Index extends React.Component {
  render() {
    return (
      <div style={{ padding: '20px' }}>
        <h2>Monaco Editor base example</h2>
        <MonacoEditor
          width={800}
          height={500}
          language="javascript"
          value={examples['javascript']}
          onChange={(value) => {
            console.log('editor value: ', value)
          }}
          editorDidMount={(editor, monaco) => {
            console.log("editor instance: ", editor)
            console.log("monaco: ", monaco)
          }}
        />
      </div>
    )
  }
}


export default Index

Diff


import React from 'react'
import { DiffEditor } from '@lsky/react-monaco-editor'
import { diffExamples } from '@src/example'


class Index extends React.PureComponent {
  render() {
    return (
      <DiffEditor
        width={600}
        height={400}
        original={diffExamples.original}
        modified={diffExamples.modified}
        language="markdown"
      />
    )
  }
}


export default Index

monaco Instance

import { monaco } from '@lsky/react-monaco-editor'

monaco.init()
  .then(monacoInstance => {
    // then
  })

Development

To build the example locally, run:


git clone https://github.com/lsky-walt/react-monaco-editor.git

cd react-monaco-editor

yarn install

yarn start

Monaco Editor

Props

NameTypeDefaultDescription
valuestringnulleditor value
widthnumbernulleditor width
heightnumbernulleditor height
languagestringnulleditor language
themestringvsvs, vs-dark, active4d, clouds, chrome, monokai, solarized-dark, solarized-light, MonacoTheme
optionsobjectnullIEditorOptions
loadingReact.ReactNodenullloading ??
linenumbernullline number
modelOptionsArraynullmonaco.editor.createModel(value, language, ...modelOptions)
borderedbooleantrueneed bordered ?
styleobjectnulleditor outer container style
onChangefunc(value) => voidtriggered when the editor value changes
monacoWillMountfunc(monaco) => voidtriggered when the monaco will mounted
editorDidMountfunc(editor, monaco) => voidtriggered when the editor did mounted
cdnConfig{ monaco: string, monacoLoader: string }{ monaco: "https://unpkg.com/monaco-editor@0.24.0/min/vs", monacoLoader: "https://unpkg.com/monaco-editor@0.24.0/min/vs/loader.js" }custom cdn

Diff Editor

Props

NameTypeDefaultDescription
originalstringnulldiff editor original value
modifiedstringnulldiff editor modified value
widthnumbernulldiff editor width
heightnumbernulldiff editor height
languagestringnulldiff editor language
originalLanguagestringnulldiff editor original language
modifiedLanguagestringnulldiff editor modified language
themestringvsvs, vs-dark, active4d, clouds, chrome, monokai, solarized-dark, solarized-light, MonacoTheme
optionsobjectnullIDiffEditorOptions
styleobjectnulldiff editor outer container style
monacoWillMountfunc(monaco) => voidtriggered when the monaco will mounted
editorDidMountfunc(original: MonacoEditor.editor.ITextModel, modified: MonacoEditor.editor.ITextModel, editor: MonacoEditor.editor) => voidtriggered when the diff editor did mounted
onChange(value: string) => voidnullmodified model content change
cdnConfig{ monaco: string, monacoLoader: string }{ monaco: "https://unpkg.com/monaco-editor@0.24.0/min/vs", monacoLoader: "https://unpkg.com/monaco-editor@0.24.0/min/vs/loader.js" }custom cdn

Keywords

monaco-editor

FAQs

Package last updated on 11 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts