|
@@ -66,6 +66,7 @@ export default class TextSelection {
|
|
|
this.handleToolMode = this.handleToolMode.bind(this)
|
|
|
this.handleMouseDown = this.handleMouseDown.bind(this)
|
|
|
this.handleMouseMove = this.handleMouseMove.bind(this)
|
|
|
+ this.handleDobuleClick = this.handleDobuleClick.bind(this)
|
|
|
this.handleMouseUp = this.handleMouseUp.bind(this)
|
|
|
this.handleKeyDown = this.handleKeyDown.bind(this)
|
|
|
this.handleTextPopup = this.handleTextPopup.bind(this)
|
|
@@ -87,6 +88,7 @@ export default class TextSelection {
|
|
|
document.removeEventListener('touchstart', this.handleMouseDown)
|
|
|
document.removeEventListener('mousemove', this.handleMouseMove)
|
|
|
document.removeEventListener('touchmove', this.handleMouseMove)
|
|
|
+ document.removeEventListener('dblclick', this.handleDobuleClick)
|
|
|
|
|
|
if (this.toolMode === 'view' || this.toolMode === 'annotation') {
|
|
|
document.addEventListener('keydown', this.handleKeyDown)
|
|
@@ -94,6 +96,7 @@ export default class TextSelection {
|
|
|
document.addEventListener('touchstart', this.handleMouseDown)
|
|
|
document.addEventListener('mousemove', this.handleMouseMove)
|
|
|
document.addEventListener('touchmove', this.handleMouseMove)
|
|
|
+ document.addEventListener('dblclick', this.handleDobuleClick)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -129,6 +132,7 @@ export default class TextSelection {
|
|
|
document.removeEventListener('touchstart', this.handleMouseDown)
|
|
|
document.removeEventListener('mousemove', this.handleMouseMove)
|
|
|
document.removeEventListener('touchmove', this.handleMouseMove)
|
|
|
+ document.removeEventListener('dblclick', this.handleDobuleClick)
|
|
|
this._tool = toolType
|
|
|
return
|
|
|
}
|
|
@@ -138,6 +142,7 @@ export default class TextSelection {
|
|
|
document.addEventListener('touchstart', this.handleMouseDown)
|
|
|
document.addEventListener('mousemove', this.handleMouseMove)
|
|
|
document.addEventListener('touchmove', this.handleMouseMove)
|
|
|
+ document.addEventListener('dblclick', this.handleDobuleClick)
|
|
|
}
|
|
|
this._tool = toolType
|
|
|
}
|
|
@@ -215,6 +220,8 @@ export default class TextSelection {
|
|
|
textPtr: this.#textPtr,
|
|
|
point
|
|
|
})
|
|
|
+ const startPoint = this.startPoint
|
|
|
+ if (startPoint && (startPoint.x === point.x || startPoint.y === point.y)) return
|
|
|
if (isText) {
|
|
|
this.container?.classList.add('text')
|
|
|
this.endPoint = point
|
|
@@ -234,6 +241,39 @@ export default class TextSelection {
|
|
|
this.updateSelection()
|
|
|
}
|
|
|
|
|
|
+ async handleDobuleClick(event: MouseEvent) {
|
|
|
+ event.stopPropagation()
|
|
|
+ event.preventDefault()
|
|
|
+ const inPage = this.testPoint(event)
|
|
|
+ if (!inPage || document.querySelector('.annotationContainer .outline-container')) {
|
|
|
+ this.container?.classList.remove('text')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const { x, y } = inPage
|
|
|
+ const point = getInitialPoint({ x, y }, this.viewport, this.scale)
|
|
|
+
|
|
|
+ const isText = await this.messageHandler.sendWithPromise('GetCharIndexAtPos', {
|
|
|
+ pagePtr: this.#pagePtr,
|
|
|
+ textPtr: this.#textPtr,
|
|
|
+ point
|
|
|
+ })
|
|
|
+
|
|
|
+ if (!isText) return
|
|
|
+
|
|
|
+ const selection = await this.messageHandler.sendWithPromise('GetSelectionForWordAtPos', {
|
|
|
+ pagePtr: this.#pagePtr,
|
|
|
+ textPtr: this.#textPtr,
|
|
|
+ start: point,
|
|
|
+ end: point
|
|
|
+ })
|
|
|
+ this._selection = selection
|
|
|
+ this.updateSelection()
|
|
|
+
|
|
|
+ if (this._selection && this.textContainer) {
|
|
|
+ this.showTextPopup()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
handleMouseUp() {
|
|
|
if (this.selecting && this._selection && markupTypeNotNull.includes(this.tool)) {
|
|
|
const annotationData = {
|
|
@@ -362,6 +402,7 @@ export default class TextSelection {
|
|
|
document.removeEventListener('touchmove', this.handleMouseMove)
|
|
|
document.removeEventListener('mouseup', this.handleMouseUp)
|
|
|
document.removeEventListener('touchend', this.handleMouseUp)
|
|
|
+ document.removeEventListener('dblclick', this.handleDobuleClick)
|
|
|
|
|
|
this.eventBus._off('toolChanged', this.handleTool)
|
|
|
this.eventBus._off('toolModeChanged', this.handleToolMode)
|