feat:add interface for cypress

This commit is contained in:
黄云飞
2022-03-16 17:18:27 +08:00
parent ffaf52fd27
commit 5ce95ef38d
3 changed files with 31 additions and 18 deletions
+6
View File
@@ -17,6 +17,7 @@ export class Command {
private static undo: Function
private static redo: Function
private static painter: Function
private static applyPainterStyle: Function
private static format: Function
private static font: Function
private static sizeAdd: Function
@@ -67,6 +68,7 @@ export class Command {
Command.undo = adapt.undo.bind(adapt)
Command.redo = adapt.redo.bind(adapt)
Command.painter = adapt.painter.bind(adapt)
Command.applyPainterStyle = adapt.applyPainterStyle.bind(adapt)
Command.format = adapt.format.bind(adapt)
Command.font = adapt.font.bind(adapt)
Command.sizeAdd = adapt.sizeAdd.bind(adapt)
@@ -149,6 +151,10 @@ export class Command {
return Command.painter()
}
public executeApplyPainterStyle() {
return Command.applyPainterStyle()
}
public executeFormat() {
return Command.format()
}
+4
View File
@@ -140,6 +140,10 @@ export class CommandAdapt {
this.draw.setPainterStyle(painterStyle)
}
public applyPainterStyle() {
this.canvasEvent.applyPainterStyle()
}
public format() {
const isReadonly = this.draw.isReadonly()
if (isReadonly) return
+6 -3
View File
@@ -68,11 +68,15 @@ export class CanvasEvent {
public setIsAllowDrag(payload: boolean) {
this.isAllowDrag = payload
if (payload === false) {
if (!payload) {
this.applyPainterStyle()
}
}
public applyPainterStyle() {
this.pageList.forEach(p => {
p.style.cursor = 'text'
})
// 应用格式刷样式
const painterStyle = this.draw.getPainterStyle()
if (!painterStyle) return
const selection = this.range.getSelection()
@@ -87,7 +91,6 @@ export class CanvasEvent {
this.draw.setPainterStyle(null)
this.draw.render({ isSetCursor: false })
}
}
public mousemove(evt: MouseEvent) {
if (!this.isAllowDrag || !this.mouseDownStartPosition) return