feat:add interface for cypress
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -68,27 +68,30 @@ export class CanvasEvent {
|
||||
|
||||
public setIsAllowDrag(payload: boolean) {
|
||||
this.isAllowDrag = payload
|
||||
if (payload === false) {
|
||||
this.pageList.forEach(p => {
|
||||
p.style.cursor = 'text'
|
||||
})
|
||||
// 应用格式刷样式
|
||||
const painterStyle = this.draw.getPainterStyle()
|
||||
if (!painterStyle) return
|
||||
const selection = this.range.getSelection()
|
||||
if (!selection) return
|
||||
const painterStyleKeys = Object.keys(painterStyle)
|
||||
selection.forEach(s => {
|
||||
painterStyleKeys.forEach(pKey => {
|
||||
const key = pKey as keyof typeof ElementStyleKey
|
||||
s[key] = painterStyle[key] as any
|
||||
})
|
||||
})
|
||||
this.draw.setPainterStyle(null)
|
||||
this.draw.render({ isSetCursor: 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()
|
||||
if (!selection) return
|
||||
const painterStyleKeys = Object.keys(painterStyle)
|
||||
selection.forEach(s => {
|
||||
painterStyleKeys.forEach(pKey => {
|
||||
const key = pKey as keyof typeof ElementStyleKey
|
||||
s[key] = painterStyle[key] as any
|
||||
})
|
||||
})
|
||||
this.draw.setPainterStyle(null)
|
||||
this.draw.render({ isSetCursor: false })
|
||||
}
|
||||
|
||||
public mousemove(evt: MouseEvent) {
|
||||
if (!this.isAllowDrag || !this.mouseDownStartPosition) return
|
||||
const target = evt.target as HTMLDivElement
|
||||
|
||||
Reference in New Issue
Block a user