@istock/editor / Exports / CommandEditor
Class: CommandEditor
Table of contents
Constructors
Properties
Accessors
Methods
- #createEvent
- #eventHandle
- #getNewNodeId
- #getNewVNodes
- #handleBlur
- #handleCommandInput
- #handleCompositionEnd
- #handleCompositionStart
- #handleCompositionUpdate
- #handleFocus
- #handleInput
- #handleKeydown
- #handleKeyup
- #initEvent
- #reDoInput
- #unDoInput
- #updateNodeToHtml
- destroy
- getCursorOffsetText
- handleCommandInput
- handleCommandInputAppend
- onMount
- syncVNodeAndHtml
Constructors
constructor
• new CommandEditor(commandInput): CommandEditor
Parameters
| Name | Type |
|---|---|
commandInput | HTMLElement |
Returns
Defined in
command-editor.ts:54
Properties
#autoNodeId
• Private #autoNodeId: number = 0
Defined in
command-editor.ts:34
#commandInput
• Private Readonly #commandInput: HTMLElement
Defined in
command-editor.ts:32
#cursor
• Private Readonly #cursor: CommandEditorCursor
Defined in
command-editor.ts:38
#editorParser
• Private Readonly #editorParser: CommandEditorParser
Defined in
command-editor.ts:37
#historyIndex
• Private #historyIndex: number = 0
Defined in
command-editor.ts:40
#historys
• Private #historys: [string, number][] = []
Defined in
command-editor.ts:39
#inputComposing
• Private #inputComposing: boolean = false
Defined in
command-editor.ts:33
#tokenizer
• Private Readonly #tokenizer: Tokenizer
Defined in
command-editor.ts:36
#vNodes
• Private #vNodes: TCommandEditorContentNode[] = []
Defined in
command-editor.ts:35
Accessors
commandInput
• get commandInput(): HTMLElement
Returns
HTMLElement
Defined in
command-editor.ts:42
input
• get input(): string
Returns
string
Defined in
command-editor.ts:46
vNodes
• get vNodes(): TCommandEditorContentNode[]
Returns
Defined in
command-editor.ts:50
Methods
#createEvent
▸ #createEvent(name, action?, event?): void
创建自定义事件
Parameters
| Name | Type |
|---|---|
name | string |
action? | ECommandEditorActionTypes |
event? | Event |
Returns
void
Defined in
command-editor.ts:362
#eventHandle
▸ #eventHandle<T>(method): void
Type parameters
| Name | Type |
|---|---|
T | extends "addEventListener" | "removeEventListener" |
Parameters
| Name | Type |
|---|---|
method | T |
Returns
void
Defined in
command-editor.ts:71
#getNewNodeId
▸ #getNewNodeId(): number
Returns
number
Defined in
command-editor.ts:97
#getNewVNodes
▸ #getNewVNodes(tokens, vNodes): TCommandEditorContentNode[]
简单对比生成最新虚拟节点数据
Parameters
| Name | Type |
|---|---|
tokens | TToken[] |
vNodes | TCommandEditorContentNode[] |
Returns
Defined in
command-editor.ts:335
#handleBlur
▸ #handleBlur(_event): void
Parameters
| Name | Type |
|---|---|
_event | FocusEvent |
Returns
void
Defined in
command-editor.ts:102
#handleCommandInput
▸ #handleCommandInput(event, config?): void
命令输入处理
Parameters
| Name | Type |
|---|---|
event | Event |
config? | Object |
config.newLine? | boolean |
Returns
void
Defined in
command-editor.ts:234
#handleCompositionEnd
▸ #handleCompositionEnd(event): void
Parameters
| Name | Type |
|---|---|
event | CompositionEvent |
Returns
void
Defined in
command-editor.ts:222
#handleCompositionStart
▸ #handleCompositionStart(_event): void
处理中文输入问题
Parameters
| Name | Type |
|---|---|
_event | CompositionEvent |
Returns
void
Defined in
command-editor.ts:214
#handleCompositionUpdate
▸ #handleCompositionUpdate(_event): void
Parameters
| Name | Type |
|---|---|
_event | CompositionEvent |
Returns
void
Defined in
command-editor.ts:218
#handleFocus
▸ #handleFocus(_event): void
Parameters
| Name | Type |
|---|---|
_event | FocusEvent |
Returns
void
Defined in
command-editor.ts:101
#handleInput
▸ #handleInput(event): void
输入处理
Parameters
| Name | Type |
|---|---|
event | Event |
Returns
void
Defined in
command-editor.ts:110
#handleKeydown
▸ #handleKeydown(event): void
快捷键处理
Parameters
| Name | Type |
|---|---|
event | KeyboardEvent |
Returns
void
Defined in
command-editor.ts:122
#handleKeyup
▸ #handleKeyup(_event): void
Parameters
| Name | Type |
|---|---|
_event | KeyboardEvent |
Returns
void
Defined in
command-editor.ts:116
#initEvent
▸ #initEvent(): void
Returns
void
Defined in
command-editor.ts:67
#reDoInput
▸ #reDoInput(event): void
撤销输入操作
Parameters
| Name | Type |
|---|---|
event | KeyboardEvent |
Returns
void
Defined in
command-editor.ts:194
#unDoInput
▸ #unDoInput(event): void
撤销输入操作
Parameters
| Name | Type |
|---|---|
event | KeyboardEvent |
Returns
void
Defined in
command-editor.ts:174
#updateNodeToHtml
▸ #updateNodeToHtml(vNodes, offsetText?, options?): void
更新vNode节点到html
Parameters
| Name | Type | Default value |
|---|---|---|
vNodes | TCommandEditorContentNode[] | undefined |
offsetText | string | '' |
options | TCommandEditorInputOption | {} |
Returns
void
Defined in
command-editor.ts:307
destroy
▸ destroy(): void
销毁时解绑事件
Returns
void
Defined in
command-editor.ts:376
getCursorOffsetText
▸ getCursorOffsetText(): string
获取光标前面字符串
Returns
string
Defined in
command-editor.ts:295
handleCommandInput
▸ handleCommandInput(input, offsetText?, options?): void
处理input输入字符串
Parameters
| Name | Type |
|---|---|
input | string |
offsetText | string |
options | TCommandEditorInputOption |
Returns
void
Defined in
command-editor.ts:252
handleCommandInputAppend
▸ handleCommandInputAppend(str): void
向后追加字符串
Parameters
| Name | Type |
|---|---|
str | string |
Returns
void
Defined in
command-editor.ts:268
onMount
▸ onMount(): void
Returns
void
Defined in
command-editor.ts:62
syncVNodeAndHtml
▸ syncVNodeAndHtml(vNodes): void
同步节点数据及更新到html
Parameters
| Name | Type |
|---|---|
vNodes | TCommandEditorContentNode[] |
Returns
void
Defined in
command-editor.ts:286