feat: add zone change listener

This commit is contained in:
Hufe921
2023-04-04 19:57:33 +08:00
parent 72e97b7883
commit 86871c310b
3 changed files with 16 additions and 3 deletions
+4 -1
View File
@@ -7,7 +7,8 @@ import {
IPageSizeChange,
IRangeStyleChange,
ISaved,
IVisiblePageNoListChange
IVisiblePageNoListChange,
IZoneChange
} from '../../interface/Listener'
export class Listener {
@@ -21,6 +22,7 @@ export class Listener {
public contentChange: IContentChange | null
public controlChange: IControlChange | null
public pageModeChange: IPageModeChange | null
public zoneChange: IZoneChange | null
constructor() {
this.rangeStyleChange = null
@@ -32,6 +34,7 @@ export class Listener {
this.contentChange = null
this.controlChange = null
this.pageModeChange = null
this.zoneChange = null
}
}
+8
View File
@@ -1,6 +1,7 @@
import { EDITOR_PREFIX } from '../../dataset/constant/Editor'
import { EditorZone } from '../../dataset/enum/Editor'
import { IEditorOption } from '../../interface/Editor'
import { nextTick } from '../../utils'
import { Draw } from '../draw/Draw'
import { I18n } from '../i18n/I18n'
@@ -53,6 +54,13 @@ export class Zone {
})
// 指示器
this.drawZoneIndicator()
// 回调
nextTick(() => {
const listener = this.draw.getListener()
if (listener.zoneChange) {
listener.zoneChange(payload)
}
})
}
public drawZoneIndicator() {
+3 -1
View File
@@ -1,4 +1,4 @@
import { ElementType, PageMode } from '..'
import { EditorZone, ElementType, PageMode } from '..'
import { RowFlex } from '../dataset/enum/Row'
import { IControl } from './Control'
import { IEditorResult } from './Editor'
@@ -38,3 +38,5 @@ export type IContentChange = () => void
export type IControlChange = (payload: IControl | null) => void
export type IPageModeChange = (payload: PageMode) => void
export type IZoneChange = (payload: EditorZone) => void