awg-editor v1.1.1
awg-editor
🚄 使用教程
安装
npm i install awg-editor or yarn add awg-editor使用
import { AwgEditor } from 'awg-editor'
const editor = AwgEditor.getInstance()
AwgEditor.initSuggestions(funName) // 创建代码补全提示
AwgEditor.initHover(hoverHints) // 创建鼠标悬浮提示
AwgEditor.initCodeEditor(dom) // 初始化编辑器📖 文档
Class: AwgEditor
基于monaco-editor的二次封装,实现快速定义自定义提示和鼠标悬浮提示
Implements
CodeEditor
Table of contents
Properties
Methods
Properties
hoverMap
• Private hoverMap: Map<string, IMarkdownString[]>
internal
Defined in
hoverTips
• Private hoverTips: null | IDisposable
Defined in
language
• language: string
Implementation of
CodeEditor.language
Defined in
suggestion
• Private suggestion: null | IDisposable
Defined in
instance
▪ Static instance: AwgEditor
Defined in
Methods
defineTheme
▸ defineTheme(): void
自定义编辑器主题,默认使用AWG项目的主题
Returns
void
Implementation of
CodeEditor.defineTheme
Defined in
dispose
▸ dispose(): void
取消原有的自定义提示与鼠标悬浮提示
Returns
void
Implementation of
CodeEditor.dispose
Defined in
formateHover
▸ formateHover(txt): string
提供简单的格式化鼠标悬浮提示的能力
Parameters
| Name | Type | Description |
|---|---|---|
txt | string | 格式化文字 |
Returns
string
格式化后的文字
Defined in
initCodeEditor
▸ initCodeEditor(editorDom): null | IStandaloneCodeEditor
初始化编辑器
Parameters
| Name | Type | Description |
|---|---|---|
editorDom | HTMLElement | monaco-editor的dom容器 |
Returns
null | IStandaloneCodeEditor
monaco-editor create实例
Implementation of
CodeEditor.initCodeEditor
Defined in
initHover
▸ initHover(params, formate?): void
初始化鼠标悬浮提示
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
params | HoverParams | HoverParams[] | undefined | 自定义鼠标悬浮提示参数 |
formate | boolean | true | 是否开启简单的提示格式化功能 |
Returns
void
Implementation of
CodeEditor.initHover
Defined in
initSuggestions
▸ initSuggestions(params): void
初始化自定义函数提示
Parameters
| Name | Type | Description |
|---|---|---|
params | string[] | SuggestionsParams[] | 自定义函数提示参数 |
Returns
void
Implementation of
CodeEditor.initSuggestions
Defined in
setLanguage
▸ setLanguage(lan): void
Parameters
| Name | Type | Description |
|---|---|---|
lan | string | 设置编辑器语言 |
Returns
void
Implementation of
CodeEditor.setLanguage
Defined in
getInstance
▸ Static getInstance(): AwgEditor
return(awgeditor)