mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
book and search fixes
This commit is contained in:
parent
eacefeb08b
commit
34bc02965f
@ -3,24 +3,24 @@ import toastService from "../services/toast.js";
|
|||||||
import server from "../services/server.js";
|
import server from "../services/server.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<style>
|
<div>
|
||||||
.search-results {
|
<style>
|
||||||
padding: 0 5px 5px 15px;
|
.search-results {
|
||||||
flex-basis: 40%;
|
padding: 0 5px 5px 15px;
|
||||||
flex-grow: 1;
|
flex-basis: 40%;
|
||||||
flex-shrink: 1;
|
flex-grow: 1;
|
||||||
margin-top: 10px;
|
flex-shrink: 1;
|
||||||
display: none;
|
margin-top: 10px;
|
||||||
overflow: auto;
|
display: none;
|
||||||
border-bottom: 2px solid var(--main-border-color);
|
overflow: auto;
|
||||||
}
|
border-bottom: 2px solid var(--main-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results ul {
|
||||||
|
padding: 5px 5px 5px 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
.search-results ul {
|
|
||||||
padding: 5px 5px 5px 15px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="search-results">
|
|
||||||
<strong>Search results:</strong>
|
<strong>Search results:</strong>
|
||||||
|
|
||||||
<ul class="search-results-inner"></ul>
|
<ul class="search-results-inner"></ul>
|
||||||
@ -29,15 +29,17 @@ const TPL = `
|
|||||||
|
|
||||||
export default class SearchResultsWidget extends BasicWidget {
|
export default class SearchResultsWidget extends BasicWidget {
|
||||||
doRender() {
|
doRender() {
|
||||||
const $widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
this.$searchResults = $widget.find(".search-results");
|
this.$searchResults = this.$widget;
|
||||||
this.$searchResultsInner = $widget.find(".search-results-inner");
|
this.$searchResultsInner = this.$widget.find(".search-results-inner");
|
||||||
|
|
||||||
return $widget;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchForResultsListener({searchText}) {
|
async searchForResultsListener({searchText}) {
|
||||||
|
this.toggle(true);
|
||||||
|
|
||||||
const response = await server.get('search/' + encodeURIComponent(searchText));
|
const response = await server.get('search/' + encodeURIComponent(searchText));
|
||||||
|
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
|
@ -193,7 +193,7 @@ export default class BookTypeWidget extends TypeWidget {
|
|||||||
this.$content.find('.note-book-content').css("max-height", ZOOMS[zoomLevel].height);
|
this.$content.find('.note-book-content').css("max-height", ZOOMS[zoomLevel].height);
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh() {
|
async doRefresh(note) {
|
||||||
this.$content.empty();
|
this.$content.empty();
|
||||||
this.$help.hide();
|
this.$help.hide();
|
||||||
|
|
||||||
@ -208,10 +208,10 @@ export default class BookTypeWidget extends TypeWidget {
|
|||||||
.append(' if you want to add some text.'))
|
.append(' if you want to add some text.'))
|
||||||
}
|
}
|
||||||
|
|
||||||
const zoomLevel = parseInt(await this.tabContext.note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel();
|
const zoomLevel = parseInt(await note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel();
|
||||||
this.setZoom(zoomLevel);
|
this.setZoom(zoomLevel);
|
||||||
|
|
||||||
await this.renderIntoElement(this.tabContext.note, this.$content);
|
await this.renderIntoElement(note, this.$content);
|
||||||
}
|
}
|
||||||
|
|
||||||
async renderIntoElement(note, $container) {
|
async renderIntoElement(note, $container) {
|
||||||
|
@ -4,15 +4,24 @@ export default class TypeWidget extends TabAwareWidget {
|
|||||||
// for overriding
|
// for overriding
|
||||||
static getType() {}
|
static getType() {}
|
||||||
|
|
||||||
doRefresh() {}
|
/**
|
||||||
|
* @param {NoteFull} note
|
||||||
|
*/
|
||||||
|
doRefresh(note) {}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
if (!this.tabContext.note || this.tabContext.note.type !== this.constructor.getType()) {
|
const note = this.tabContext.note;
|
||||||
|
const widgetType = this.constructor.getType();
|
||||||
|
|
||||||
|
if (!note
|
||||||
|
|| (note.type !== widgetType
|
||||||
|
&& (note.type !== 'text' || widgetType !== 'book') // text can be rendered as book if it does not have content
|
||||||
|
&& (widgetType !== 'protected-session' || !note.isProtected))) {
|
||||||
this.toggle(false);
|
this.toggle(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doRefresh();
|
this.doRefresh(note);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user