feat: cancel painter style setting #453
This commit is contained in:
@@ -248,6 +248,11 @@ export class CommandAdapt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public painter(options: IPainterOption) {
|
public painter(options: IPainterOption) {
|
||||||
|
// 如果单击且已经有样式设置则取消设置
|
||||||
|
if (!options.isDblclick && this.draw.getPainterStyle()) {
|
||||||
|
this.canvasEvent.clearPainterStyle()
|
||||||
|
return
|
||||||
|
}
|
||||||
const selection = this.range.getSelection()
|
const selection = this.range.getSelection()
|
||||||
if (!selection) return
|
if (!selection) return
|
||||||
const painterStyle: IElementStyle = {}
|
const painterStyle: IElementStyle = {}
|
||||||
|
|||||||
+16
-2
@@ -96,14 +96,28 @@ window.onload = function () {
|
|||||||
const painterDom = document.querySelector<HTMLDivElement>(
|
const painterDom = document.querySelector<HTMLDivElement>(
|
||||||
'.menu-item__painter'
|
'.menu-item__painter'
|
||||||
)!
|
)!
|
||||||
|
|
||||||
|
let isFirstClick = true
|
||||||
|
let painterTimeout: number
|
||||||
painterDom.onclick = function () {
|
painterDom.onclick = function () {
|
||||||
console.log('painter')
|
if (isFirstClick) {
|
||||||
|
isFirstClick = false
|
||||||
|
painterTimeout = window.setTimeout(() => {
|
||||||
|
console.log('painter-click')
|
||||||
|
isFirstClick = true
|
||||||
instance.command.executePainter({
|
instance.command.executePainter({
|
||||||
isDblclick: false
|
isDblclick: false
|
||||||
})
|
})
|
||||||
|
}, 200)
|
||||||
|
} else {
|
||||||
|
window.clearTimeout(painterTimeout)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
painterDom.ondblclick = function () {
|
painterDom.ondblclick = function () {
|
||||||
console.log('painter')
|
console.log('painter-dblclick')
|
||||||
|
isFirstClick = true
|
||||||
|
window.clearTimeout(painterTimeout)
|
||||||
instance.command.executePainter({
|
instance.command.executePainter({
|
||||||
isDblclick: true
|
isDblclick: true
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user