0.0.3 • Published 3 years ago

ciqtek-editor v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

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

Api:

api描述参数返回值
getInstance类的静态方法,用来获取实例,不要使用new方法去创建实例,使用getInstance保持单例调AwgEditor
initSuggestions实例方法用来创建代码补全提示params :string[]|SuggestionsParams[] 代码补全提示参数void
initHover实例方法用来创建鼠标悬浮提示params: HoverParams]|HoverParams[] hover提示参数,formate:boolean 是否开启简单的格式化提示,默认值truevoid
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创建提示,这样可以避免多次创建提示