GithubHelp home page GithubHelp logo

stater-test's Introduction

基于monaco-editor简单的二次封装

类的主要功能为:提供快速创建自定义代码提示与鼠标悬浮提示

Api:

api 描述 参数 返回值
getInstance 类的静态方法,用来获取实例,不要使用new方法去创建实例,使用getInstance保持单例调 AwgEditor
initSuggestions 实例方法用来创建代码补全提示 params :string[]|SuggestionsParams[] 代码补全提示参数 void
initHover 实例方法用来创建鼠标悬浮提示 params: HoverParams]|HoverParams[] hover提示参数,formate:boolean 是否开启简单的格式化提示,默认值true void
dispose 实例方法用来销毁上一次创建的提示,用于存在多次调用提示的情况 void

type:

SuggestionsParams:{
    
    label:string 用户输入配置字符
    text:string 补全内容
    detail:string 提示描述
    kind:'KeyWord' | 'Function '| 'Snippet' 提示类型
}

HoverParams: {
    type:string 提示类型,默认method
    value:string 提示内容
    key:悬浮关键词
}

使用:

import { MonacoCodeEditor } from './editorTools/CodeEditor'
const dom = document.querySelector('#container')
const editor = MonacoCodeEditor.getInstance()
editor.initSuggestions(funName) // 创建代码补全提示
editor.initHover(hoverHints) // 创建鼠标悬浮提示
editor.initCodeEditor(dom) // 初始化编辑器

注:在vue中不建议在组件mounted创建提示,这样可以避免多次创建提示

stater-test's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.