|
@@ -61,13 +61,20 @@ export class TextSelection {
|
|
|
this.pageViewer = options.pageViewer
|
|
|
|
|
|
this.handleTool = this.handleTool.bind(this)
|
|
|
+ this.handleToolMode = this.handleToolMode.bind(this)
|
|
|
this.handleMouseDown = this.handleMouseDown.bind(this)
|
|
|
this.handleMouseMove = this.handleMouseMove.bind(this)
|
|
|
this.handleMouseUp = this.handleMouseUp.bind(this)
|
|
|
|
|
|
+ this.toolMode = options.toolMode
|
|
|
this.tool = options.tool
|
|
|
this.color = options.color
|
|
|
this.eventBus._on('toolChanged', this.handleTool)
|
|
|
+ this.eventBus._on('toolModeChanged', this.handleToolMode)
|
|
|
+ }
|
|
|
+
|
|
|
+ handleToolMode(mode: string) {
|
|
|
+ this.toolMode = mode
|
|
|
}
|
|
|
|
|
|
handleTool ({
|
|
@@ -93,22 +100,20 @@ export class TextSelection {
|
|
|
return this._tool
|
|
|
}
|
|
|
|
|
|
- set tool (toolType) {
|
|
|
- if (toolType === this._tool) return
|
|
|
- if (!markupType.includes(toolType)) {
|
|
|
+ set tool (toolType: string) {
|
|
|
+ if ((toolType === this._tool && toolType !== '')) return
|
|
|
+ this._tool = toolType
|
|
|
+ if (!markupType.includes(toolType) || this.toolMode === 'editor') {
|
|
|
document.removeEventListener('mousedown', this.handleMouseDown)
|
|
|
document.removeEventListener('touchstart', this.handleMouseDown)
|
|
|
document.removeEventListener('mousemove', this.handleMouseMove)
|
|
|
document.removeEventListener('touchmove', this.handleMouseMove)
|
|
|
return
|
|
|
}
|
|
|
- if (!(markupType.includes(toolType) && markupType.includes(this.tool))) {
|
|
|
- document.addEventListener('mousedown', this.handleMouseDown)
|
|
|
- document.addEventListener('touchstart', this.handleMouseDown)
|
|
|
- document.addEventListener('mousemove', this.handleMouseMove)
|
|
|
- document.addEventListener('touchmove', this.handleMouseMove)
|
|
|
- }
|
|
|
- this._tool = toolType
|
|
|
+ document.addEventListener('mousedown', this.handleMouseDown)
|
|
|
+ document.addEventListener('touchstart', this.handleMouseDown)
|
|
|
+ document.addEventListener('mousemove', this.handleMouseMove)
|
|
|
+ document.addEventListener('touchmove', this.handleMouseMove)
|
|
|
}
|
|
|
|
|
|
testPoint(event: MouseEvent) {
|
|
@@ -152,6 +157,7 @@ export class TextSelection {
|
|
|
this.endPoint = point
|
|
|
} else {
|
|
|
this.container?.classList.remove('text')
|
|
|
+ return
|
|
|
}
|
|
|
if (!this.selecting) return
|
|
|
|