Skip to content

Commit 186fdcc

Browse files
committed
[FIX] Replace Functionality upon Enter
1 parent 82710e1 commit 186fdcc

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@
121121
<div class="dropdown-item">
122122
<div style="display: flex;">
123123
<div style="margin: 5px;">
124-
<button class="button is-small is-primary" onclick="findAndReplace()">Replace</button>
124+
<button class="button is-small is-primary" id="replaceButton" onclick="findAndReplace()">Replace</button>
125125
</div>
126126

127127
<div style="margin: 5px;">
128-
<button class="button is-small is-primary" onclick="findAndReplace(true)">Replace All</button>
128+
<button class="button is-small is-primary" id="replaceAllButton" onclick="findAndReplace(true)">Replace All</button>
129129
</div>
130130
</div>
131131
</div>

javascript/tooltip.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ function findAndReplace(all = false) {
101101
}
102102
}
103103

104+
document.getElementById("replaceTerm")
105+
.addEventListener("keyup", function (event) {
106+
event.preventDefault();
107+
if (event.key === "Enter") {
108+
document.getElementById("replaceButton").click();
109+
}
110+
});
111+
104112
// this function is activated on mouseup after user has highlighted text
105113
function addShareTool(a, previousSelection) {
106114
// if annotation mode on

0 commit comments

Comments
 (0)