From a0ae2ba55eecd5d9d9c884263857d58a9e5b111a Mon Sep 17 00:00:00 2001 From: Wolf Oliver Date: Wed, 18 Nov 2020 06:10:10 +0100 Subject: [PATCH 1/5] don't jump to the next finding if the caret is placed somewhere else --- src/findInPage.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/findInPage.js b/src/findInPage.js index 0f5ec22..3c9a967 100644 --- a/src/findInPage.js +++ b/src/findInPage.js @@ -224,6 +224,10 @@ function removeElement () { function creatEventHandler () { this[documentKeydown] = (function (e) { if (!this[hasOpened]) return + + var selection = window.getSelection() + if(selection.focusNode && selection.focusNode !== this[findBox]) return + onKeydown.call(this, e) }).bind(this) this[events].push({ ele: document, name: 'keydown', fn: this[documentKeydown] }) From 47add27143f270a17f7ba8ac09b0e400c809af82 Mon Sep 17 00:00:00 2001 From: Wolf Oliver Date: Mon, 8 Feb 2021 20:03:55 +0200 Subject: [PATCH 2/5] fix Enter key handling after electron 11 upgrade --- src/findInPage.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/findInPage.js b/src/findInPage.js index 3c9a967..5cbc391 100644 --- a/src/findInPage.js +++ b/src/findInPage.js @@ -398,10 +398,15 @@ function onInput () { function onKeydown (e) { if (this[inComposition] || !e) return + let text; switch (e.code) { case 'Enter': + text = this[findInput].value + if (!text) return + e.shiftKey ? findKeep.call(this, false) : findKeep.call(this, true) + break case 'NumpadEnter': - let text = this[findInput].value + text = this[findInput].value if (!text) return e.shiftKey ? findKeep.call(this, false) : findKeep.call(this, true) break From 6ed3b3d71d4a4f89e766c6f4f907d3c143d52d59 Mon Sep 17 00:00:00 2001 From: Wolf Oliver Date: Tue, 9 Feb 2021 08:01:17 +0200 Subject: [PATCH 3/5] fix cycling by deactivating wrapInput function --- src/findInPage.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/findInPage.js b/src/findInPage.js index 5cbc391..cf40dc0 100644 --- a/src/findInPage.js +++ b/src/findInPage.js @@ -363,19 +363,19 @@ function focusInput (doBlur = false) { } function wrapInput (inputEle, caseEle, timeout = 50) { - inputEle.type = 'password' - caseEle.style['visibility'] = 'hidden' - - setTimeout(() => { - if (inputEle.type !== 'text') { - print('[FindInPage] wrapInput timeout..') - unwrapInput(inputEle, caseEle) - } - }, timeout) + // inputEle.type = 'password' + // caseEle.style['visibility'] = 'hidden' + + // setTimeout(() => { + // if (inputEle.type !== 'text') { + // print('[FindInPage] wrapInput timeout..') + // unwrapInput(inputEle, caseEle) + // } + // }, timeout) } function unwrapInput (inputEle, caseEle) { - inputEle.type = 'text' - caseEle.style['visibility'] = 'visible' + // inputEle.type = 'text' + // caseEle.style['visibility'] = 'visible' } function onInput () { From 66448cb96651af211ba0a8f9298f65a63eeddc32 Mon Sep 17 00:00:00 2001 From: Wolf Oliver Date: Thu, 11 Feb 2021 08:46:14 +0200 Subject: [PATCH 4/5] do not find the content of the search box itself --- src/findInPage.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/findInPage.js b/src/findInPage.js index cf40dc0..7df6786 100644 --- a/src/findInPage.js +++ b/src/findInPage.js @@ -364,18 +364,20 @@ function focusInput (doBlur = false) { function wrapInput (inputEle, caseEle, timeout = 50) { // inputEle.type = 'password' - // caseEle.style['visibility'] = 'hidden' - - // setTimeout(() => { - // if (inputEle.type !== 'text') { - // print('[FindInPage] wrapInput timeout..') - // unwrapInput(inputEle, caseEle) - // } - // }, timeout) + inputEle.style['visibility'] = 'hidden' + caseEle.style['visibility'] = 'hidden' + + setTimeout(() => { + if (inputEle.type !== 'text') { + print('[FindInPage] wrapInput timeout..') + unwrapInput(inputEle, caseEle) + } + }, timeout) } function unwrapInput (inputEle, caseEle) { // inputEle.type = 'text' - // caseEle.style['visibility'] = 'visible' + inputEle.style['visibility'] = 'visible' + caseEle.style['visibility'] = 'visible' } function onInput () { From 673d672021a18afb144139e1445aa76be9c4b574 Mon Sep 17 00:00:00 2001 From: Wolf Oliver Date: Wed, 17 Mar 2021 19:34:29 +0200 Subject: [PATCH 5/5] make typing in search box more fluent --- src/findInPage.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/findInPage.js b/src/findInPage.js index 7df6786..a0d22a2 100644 --- a/src/findInPage.js +++ b/src/findInPage.js @@ -381,8 +381,14 @@ function unwrapInput (inputEle, caseEle) { } function onInput () { - setTimeout(() => { + this.previousInputTimeouts = this.previousInputTimeouts || [] + this.previousInputTimeouts.push(setTimeout(() => { if (this[inComposition]) return + + while(this.previousInputTimeouts.length) { + clearTimeout(this.previousInputTimeouts.shift()) + } + this[action] = 'input' let text = this[findInput].value if (text && text !== this[lastText]) { @@ -395,7 +401,7 @@ function onInput () { lockNext.call(this) focusInput.call(this, true) } - }, 50) + }, 50)) } function onKeydown (e) {