From 6b30e3ca9d48cb45cfe082b55dcf11c8287c36ee Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Wed, 29 Nov 2023 20:07:05 +0800 Subject: [PATCH] feat: add set active zone api --- docs/en/guide/command-execute.md | 10 ++++++++++ docs/guide/command-execute.md | 10 ++++++++++ src/editor/core/command/Command.ts | 2 ++ src/editor/core/command/CommandAdapt.ts | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/docs/en/guide/command-execute.md b/docs/en/guide/command-execute.md index 964d216..33186ea 100644 --- a/docs/en/guide/command-execute.md +++ b/docs/en/guide/command-execute.md @@ -862,6 +862,16 @@ Usage: instance.command.executeLocationGroup(groupId: string) ``` +## executeSetZone + +Feature: Set active zone (header, main, footer) + +Usage: + +```javascript +instance.command.executeSetZone(zone: EditorZone) +``` + ## executeSetControlValue Feature: Set control value diff --git a/docs/guide/command-execute.md b/docs/guide/command-execute.md index 5676d05..52d13fe 100644 --- a/docs/guide/command-execute.md +++ b/docs/guide/command-execute.md @@ -862,6 +862,16 @@ instance.command.executeDeleteGroup(groupId: string) instance.command.executeLocationGroup(groupId: string) ``` +## executeSetZone + +功能:设置激活区域(页眉、正文、页脚) + +用法: + +```javascript +instance.command.executeSetZone(zone: EditorZone) +``` + ## executeSetControlValue 功能:设置控件值 diff --git a/src/editor/core/command/Command.ts b/src/editor/core/command/Command.ts index 7b7e950..7c50c67 100644 --- a/src/editor/core/command/Command.ts +++ b/src/editor/core/command/Command.ts @@ -85,6 +85,7 @@ export class Command { public executeSetGroup: CommandAdapt['setGroup'] public executeDeleteGroup: CommandAdapt['deleteGroup'] public executeLocationGroup: CommandAdapt['locationGroup'] + public executeSetZone: CommandAdapt['setZone'] public executeSetControlValue: CommandAdapt['setControlValue'] public executeSetControlExtension: CommandAdapt['setControlExtension'] public getCatalog: CommandAdapt['getCatalog'] @@ -198,6 +199,7 @@ export class Command { this.executeSetGroup = adapt.setGroup.bind(adapt) this.executeDeleteGroup = adapt.deleteGroup.bind(adapt) this.executeLocationGroup = adapt.locationGroup.bind(adapt) + this.executeSetZone = adapt.setZone.bind(adapt) // 获取 this.getImage = adapt.getImage.bind(adapt) this.getOptions = adapt.getOptions.bind(adapt) diff --git a/src/editor/core/command/CommandAdapt.ts b/src/editor/core/command/CommandAdapt.ts index 580c09a..d0e2387 100644 --- a/src/editor/core/command/CommandAdapt.ts +++ b/src/editor/core/command/CommandAdapt.ts @@ -6,6 +6,7 @@ import { ControlComponent, ImageDisplay } from '../../dataset/enum/Control' import { EditorContext, EditorMode, + EditorZone, PageMode, PaperDirection } from '../../dataset/enum/Editor' @@ -2174,6 +2175,10 @@ export class CommandAdapt { }) } + public setZone(zone: EditorZone) { + this.draw.getZone().setZone(zone) + } + public getControlValue( payload: IGetControlValueOption ): IGetControlValueResult | null {