New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@astii/code-editor

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astii/code-editor

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

code-editor

a JS code editor based on codeMirror, support code autoCompletion, which can be used with @astii/expression-sandbox

Install

npm install @astii/code-editor --save

or

yarn add @astii/code-editor

Usage

import React, { useState, useRef } from 'react'
import ReactDOM from 'react-dom/client'
import { CodeEditor, CodeEditorConfig } from '@astii/code-editor'
import styles from "./index.less"

const App = () => {
    const [value, setValue] = useState<string>('')
    const editorRef = useRef()
    const [completions, setCompletions] = useState([
        {
            label: "inputValue",
            detail: "izssf",
            docs: "sfsdfsf",
            properties: [
            {
                label: "a",
                detail: "asfs"
            }
            ]
        },
        {
            label: "@unction",
            docs: "sfjhbsf12424323是否会被生机勃发",
        }
    ])

    const onChange = (value) => {
        setValue(value)
    }

    const onClick = () => {
        const text = "sfsfsfs";
        editorRef.current.insertDoc(text);  //insert doc to position of cursor
        editorRef.current.getDoc();  //get doc
    };

    return (
        <div>
            <CodeEditor
                ref={editorRef}
                className={styles.wrap}
                value={value}
                completions={completions}
                onChange={onChange}
            />
            <button type="button" onClick={onClick}>
                insert
            </button>
        </div>
  );
}

const root = ReactDOM.createRoot(document.getElementById('root') as Element)
root.render(<App />)

Keywords

FAQs

Package last updated on 01 Feb 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc