diff --git a/docs/en/guide/command-execute.md b/docs/en/guide/command-execute.md index 2c5c6a8..77960df 100644 --- a/docs/en/guide/command-execute.md +++ b/docs/en/guide/command-execute.md @@ -89,6 +89,16 @@ Usage: instance.command.executeForceUpdate(options?: IForceUpdateOption) ``` +## executeBlur + +Feature: Set editor blur + +Usage: + +```javascript +instance.command.executeBlur() +``` + ## executeUndo Feature: Undo diff --git a/docs/guide/command-execute.md b/docs/guide/command-execute.md index 251a4f1..d39b46e 100644 --- a/docs/guide/command-execute.md +++ b/docs/guide/command-execute.md @@ -89,6 +89,16 @@ instance.command.executeSetRange(startIndex: number , endIndex: number) instance.command.executeForceUpdate(options?: IForceUpdateOption) ``` +## executeBlur + +功能:设置编辑器失焦 + +用法: + +```javascript +instance.command.executeBlur() +``` + ## executeUndo 功能:撤销 @@ -842,4 +852,4 @@ instance.command.executeSetControlValue(payload: ISetControlValueOption) ```javascript instance.command.executeSetControlExtension(payload: ISetControlExtensionOption) -``` \ No newline at end of file +``` diff --git a/src/editor/core/command/Command.ts b/src/editor/core/command/Command.ts index d0f0f56..792e035 100644 --- a/src/editor/core/command/Command.ts +++ b/src/editor/core/command/Command.ts @@ -10,6 +10,7 @@ export class Command { public executeBackspace: CommandAdapt['backspace'] public executeSetRange: CommandAdapt['setRange'] public executeForceUpdate: CommandAdapt['forceUpdate'] + public executeBlur: CommandAdapt['blur'] public executeUndo: CommandAdapt['undo'] public executeRedo: CommandAdapt['redo'] public executePainter: CommandAdapt['painter'] @@ -112,6 +113,7 @@ export class Command { this.executeBackspace = adapt.backspace.bind(adapt) this.executeSetRange = adapt.setRange.bind(adapt) this.executeForceUpdate = adapt.forceUpdate.bind(adapt) + this.executeBlur = adapt.blur.bind(adapt) // 撤销、重做、格式刷、清除格式 this.executeUndo = adapt.undo.bind(adapt) this.executeRedo = adapt.redo.bind(adapt) diff --git a/src/editor/core/command/CommandAdapt.ts b/src/editor/core/command/CommandAdapt.ts index fc0b97f..56f9781 100644 --- a/src/editor/core/command/CommandAdapt.ts +++ b/src/editor/core/command/CommandAdapt.ts @@ -172,6 +172,11 @@ export class CommandAdapt { }) } + public blur() { + this.range.clearRange() + this.draw.getCursor().recoveryCursor() + } + public undo() { const isReadonly = this.draw.isReadonly() if (isReadonly) return