feat: cancel painter style setting #453

pr675
Hufe921 2 years ago
parent 86f4cf5cda
commit 51427c7dc4

@ -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 = {}

@ -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) {
instance.command.executePainter({ isFirstClick = false
isDblclick: false painterTimeout = window.setTimeout(() => {
}) console.log('painter-click')
isFirstClick = true
instance.command.executePainter({
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
}) })

Loading…
Cancel
Save