mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 00:05:50 +01:00
converted more keyboard actions
This commit is contained in:
@@ -20,19 +20,19 @@ const helpText = `
|
||||
</p>`;
|
||||
|
||||
const TPL = `
|
||||
<style>
|
||||
.search-box {
|
||||
display: none;
|
||||
padding: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.search-text {
|
||||
border: 1px solid var(--main-border-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="search-box">
|
||||
<style>
|
||||
.search-box {
|
||||
display: none;
|
||||
padding: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.search-text {
|
||||
border: 1px solid var(--main-border-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input name="search-text" class="search-text form-control"
|
||||
@@ -58,14 +58,14 @@ const TPL = `
|
||||
|
||||
export default class SearchBoxWidget extends BasicWidget {
|
||||
doRender() {
|
||||
const $widget = $(TPL);
|
||||
this.$widget = $(TPL);
|
||||
|
||||
this.$searchBox = $widget.find(".search-box");
|
||||
this.$closeSearchButton = $widget.find(".close-search-button");
|
||||
this.$searchInput = $widget.find("input[name='search-text']");
|
||||
this.$resetSearchButton = $widget.find(".reset-search-button");
|
||||
this.$doSearchButton = $widget.find(".do-search-button");
|
||||
this.$saveSearchButton = $widget.find(".save-search-button");
|
||||
this.$searchBox = this.$widget;
|
||||
this.$closeSearchButton = this.$widget.find(".close-search-button");
|
||||
this.$searchInput = this.$widget.find("input[name='search-text']");
|
||||
this.$resetSearchButton = this.$widget.find(".reset-search-button");
|
||||
this.$doSearchButton = this.$widget.find(".do-search-button");
|
||||
this.$saveSearchButton = this.$widget.find(".save-search-button");
|
||||
|
||||
this.$searchInput.on('keyup',e => {
|
||||
const searchText = this.$searchInput.val();
|
||||
@@ -87,7 +87,7 @@ export default class SearchBoxWidget extends BasicWidget {
|
||||
|
||||
this.$closeSearchButton.on('click', () => this.hideSearchListener());
|
||||
|
||||
return $widget;
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
doSearch(searchText) {
|
||||
@@ -171,7 +171,19 @@ export default class SearchBoxWidget extends BasicWidget {
|
||||
}
|
||||
}
|
||||
|
||||
searchNotesListener() {
|
||||
this.toggleSearchListener();
|
||||
}
|
||||
|
||||
resetSearchListener() {
|
||||
this.$searchInput.val("");
|
||||
}
|
||||
|
||||
searchInSubtreeListener({noteId}) {
|
||||
noteId = noteId || appContext.getActiveTabNoteId();
|
||||
|
||||
this.toggle(true);
|
||||
|
||||
this.$searchInput.val(`@in=${noteId} @text*=*`);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@ import libraryLoader from "../../services/library_loader.js";
|
||||
import treeService from '../../services/tree.js';
|
||||
import noteAutocompleteService from '../../services/note_autocomplete.js';
|
||||
import mimeTypesService from '../../services/mime_types.js';
|
||||
import TabAwareWidget from "../tab_aware_widget.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
import utils from "../../services/utils.js";
|
||||
import linkService from "../../services/link.js";
|
||||
import appContext from "../../services/app_context.js";
|
||||
import noteDetailService from "../../services/note_detail.js";
|
||||
|
||||
const ENABLE_INSPECTOR = false;
|
||||
|
||||
@@ -189,6 +192,31 @@ class TextTypeWidget extends TypeWidget {
|
||||
scrollToTop() {
|
||||
this.$widget.scrollTop(0);
|
||||
}
|
||||
|
||||
insertDateTimeToTextListener() {
|
||||
const date = new Date();
|
||||
const dateString = utils.formatDateTime(date);
|
||||
|
||||
this.addTextToEditor(dateString);
|
||||
}
|
||||
|
||||
async addLinkToEditor(linkTitle, linkHref) {
|
||||
await this.initialized;
|
||||
|
||||
this.textEditor.model.change(writer => {
|
||||
const insertPosition = this.textEditor.model.document.selection.getFirstPosition();
|
||||
writer.insertText(linkTitle, {linkHref: linkHref}, insertPosition);
|
||||
});
|
||||
}
|
||||
|
||||
async addTextToEditor(text) {
|
||||
await this.initialized;
|
||||
|
||||
this.textEditor.model.change(writer => {
|
||||
const insertPosition = this.textEditor.model.document.selection.getFirstPosition();
|
||||
writer.insertText(text, insertPosition);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default TextTypeWidget;
|
||||
Reference in New Issue
Block a user