Skip to content

Commit

Permalink
feat: add executePageScale api #906
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Nov 26, 2024
1 parent 1d01576 commit 2430bf7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/en/guide/command-execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,16 @@ Usage:
instance.command.executePageMode(pageMode: PageMode)
```

## executePageScale

Feature: Set page scale

Usage:

```javascript
instance.command.executePageScale(scale: number)
```

## executePageScaleRecovery

Feature: Restore the original zoom factor of the page
Expand Down
10 changes: 10 additions & 0 deletions docs/guide/command-execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,16 @@ instance.command.executeChangeImageDisplay(element: IElement, display: ImageDisp
instance.command.executePageMode(pageMode: PageMode)
```

## executePageScale

功能:设置缩放比例

用法:

```javascript
instance.command.executePageScale(scale: number)
```

## executePageScaleRecovery

功能:恢复页面原始缩放比例
Expand Down
2 changes: 2 additions & 0 deletions src/editor/core/command/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class Command {
public executeSaveAsImageElement: CommandAdapt['saveAsImageElement']
public executeChangeImageDisplay: CommandAdapt['changeImageDisplay']
public executePageMode: CommandAdapt['pageMode']
public executePageScale: CommandAdapt['pageScale']
public executePageScaleRecovery: CommandAdapt['pageScaleRecovery']
public executePageScaleMinus: CommandAdapt['pageScaleMinus']
public executePageScaleAdd: CommandAdapt['pageScaleAdd']
Expand Down Expand Up @@ -199,6 +200,7 @@ export class Command {
this.executeChangeImageDisplay = adapt.changeImageDisplay.bind(adapt)
// 页面模式、页面缩放、纸张大小、纸张方向、页边距
this.executePageMode = adapt.pageMode.bind(adapt)
this.executePageScale = adapt.pageScale.bind(adapt)
this.executePageScaleRecovery = adapt.pageScaleRecovery.bind(adapt)
this.executePageScaleMinus = adapt.pageScaleMinus.bind(adapt)
this.executePageScaleAdd = adapt.pageScaleAdd.bind(adapt)
Expand Down
5 changes: 5 additions & 0 deletions src/editor/core/command/CommandAdapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,11 @@ export class CommandAdapt {
this.draw.setPageMode(payload)
}

public pageScale(scale: number) {
if (scale === this.options.scale) return
this.draw.setPageScale(scale)
}

public pageScaleRecovery() {
const { scale } = this.options
if (scale !== 1) {
Expand Down

0 comments on commit 2430bf7

Please sign in to comment.