|
|
|
|
@ -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
|
|
|
|
|
|