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