mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
added previous/next buttons to the find widget
This commit is contained in:
parent
82fcc97ed2
commit
37cb5f5e9a
14
package-lock.json
generated
14
package-lock.json
generated
@ -73,7 +73,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "16.2.7",
|
"electron": "16.2.8",
|
||||||
"electron-builder": "23.0.3",
|
"electron-builder": "23.0.3",
|
||||||
"electron-packager": "15.5.1",
|
"electron-packager": "15.5.1",
|
||||||
"electron-rebuild": "3.2.7",
|
"electron-rebuild": "3.2.7",
|
||||||
@ -3506,9 +3506,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/electron": {
|
"node_modules/electron": {
|
||||||
"version": "16.2.7",
|
"version": "16.2.8",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-16.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-16.2.8.tgz",
|
||||||
"integrity": "sha512-aZKF3b00+rqW/HGs8lJM5DhPNj+mOfCuhLSiFXV6J9dQCIRhctJTmToOrwXfbCxvXK8as8eQTNl5uSfnHmH6tA==",
|
"integrity": "sha512-KSOytY6SPLsh3iCziztqa/WgJyfDOKzCvNqku9gGIqSdT8CqtV66dTU1SOrKZQjRFLxHaF8LbyxUL1vwe4taqw==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@electron/get": "^1.13.0",
|
"@electron/get": "^1.13.0",
|
||||||
@ -13575,9 +13575,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "16.2.7",
|
"version": "16.2.8",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-16.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-16.2.8.tgz",
|
||||||
"integrity": "sha512-aZKF3b00+rqW/HGs8lJM5DhPNj+mOfCuhLSiFXV6J9dQCIRhctJTmToOrwXfbCxvXK8as8eQTNl5uSfnHmH6tA==",
|
"integrity": "sha512-KSOytY6SPLsh3iCziztqa/WgJyfDOKzCvNqku9gGIqSdT8CqtV66dTU1SOrKZQjRFLxHaF8LbyxUL1vwe4taqw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@electron/get": "^1.13.0",
|
"@electron/get": "^1.13.0",
|
||||||
"@types/node": "^14.6.2",
|
"@types/node": "^14.6.2",
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "16.2.7",
|
"electron": "16.2.8",
|
||||||
"electron-builder": "23.0.3",
|
"electron-builder": "23.0.3",
|
||||||
"electron-packager": "15.5.1",
|
"electron-packager": "15.5.1",
|
||||||
"electron-rebuild": "3.2.7",
|
"electron-rebuild": "3.2.7",
|
||||||
|
@ -34,8 +34,8 @@ const TPL = `
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.find-widget-search-term-input {
|
.find-widget-search-term-input-group {
|
||||||
max-width: 250px;
|
max-width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.find-widget-spacer {
|
.find-widget-spacer {
|
||||||
@ -44,7 +44,13 @@ const TPL = `
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="find-widget-box">
|
<div class="find-widget-box">
|
||||||
|
<div class="input-group find-widget-search-term-input-group">
|
||||||
<input type="text" class="form-control find-widget-search-term-input">
|
<input type="text" class="form-control find-widget-search-term-input">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-outline-secondary bx bxs-chevron-up find-widget-previous-button" type="button"></button>
|
||||||
|
<button class="btn btn-outline-secondary bx bxs-chevron-down find-widget-next-button" type="button"></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<label tabIndex="-1" class="form-check-label">
|
<label tabIndex="-1" class="form-check-label">
|
||||||
@ -93,6 +99,10 @@ export default class FindWidget extends NoteContextAwareWidget {
|
|||||||
this.$caseSensitiveCheckbox.change(() => this.performFind());
|
this.$caseSensitiveCheckbox.change(() => this.performFind());
|
||||||
this.$matchWordsCheckbox = this.$widget.find(".find-widget-match-words-checkbox");
|
this.$matchWordsCheckbox = this.$widget.find(".find-widget-match-words-checkbox");
|
||||||
this.$matchWordsCheckbox.change(() => this.performFind());
|
this.$matchWordsCheckbox.change(() => this.performFind());
|
||||||
|
this.$previousButton = this.$widget.find(".find-widget-previous-button");
|
||||||
|
this.$previousButton.on("click", () => this.findNext(-1));
|
||||||
|
this.$nextButton = this.$widget.find(".find-widget-next-button");
|
||||||
|
this.$nextButton.on("click", () => this.findNext(1));
|
||||||
this.$closeButton = this.$widget.find(".find-widget-close-button");
|
this.$closeButton = this.$widget.find(".find-widget-close-button");
|
||||||
this.$closeButton.on("click", () => this.closeSearch());
|
this.$closeButton.on("click", () => this.closeSearch());
|
||||||
|
|
||||||
@ -102,7 +112,7 @@ export default class FindWidget extends NoteContextAwareWidget {
|
|||||||
// whole input to find
|
// whole input to find
|
||||||
this.$input.select();
|
this.$input.select();
|
||||||
} else if (e.key === 'Enter' || e.key === 'F3') {
|
} else if (e.key === 'Enter' || e.key === 'F3') {
|
||||||
await this.findNext(e);
|
await this.findNext(e?.shiftKey ? -1 : 1);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
} else if (e.key === 'Escape') {
|
} else if (e.key === 'Escape') {
|
||||||
@ -135,7 +145,11 @@ export default class FindWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findNext(e) {
|
/**
|
||||||
|
* @param direction +1 for next, -1 for previous
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async findNext(direction) {
|
||||||
const searchTerm = this.$input.val();
|
const searchTerm = this.$input.val();
|
||||||
if (waitForEnter && this.searchTerm !== searchTerm) {
|
if (waitForEnter && this.searchTerm !== searchTerm) {
|
||||||
await this.performFind();
|
await this.performFind();
|
||||||
@ -144,7 +158,6 @@ export default class FindWidget extends NoteContextAwareWidget {
|
|||||||
const currentFound = parseInt(this.$currentFound.text()) - 1;
|
const currentFound = parseInt(this.$currentFound.text()) - 1;
|
||||||
|
|
||||||
if (totalFound > 0) {
|
if (totalFound > 0) {
|
||||||
const direction = e.shiftKey ? -1 : 1;
|
|
||||||
let nextFound = currentFound + direction;
|
let nextFound = currentFound + direction;
|
||||||
// Wrap around
|
// Wrap around
|
||||||
if (nextFound > totalFound - 1) {
|
if (nextFound > totalFound - 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user