Skip to content

Build your personal knowledge base with Trilium Notes

added note properties widget

zadam6068bd7c4478
diff --git a/db/demo.zip b/db/demo.zip
index 9fc33e2b4a..b811a56be7 100644
Binary files a/db/demo.zip and b/db/demo.zip differ
diff --git a/src/public/app/layouts/desktop_extra_window_layout.js b/src/public/app/layouts/desktop_extra_window_layout.js
index 2d5a78202a..e6f91cfc80 100644
--- a/src/public/app/layouts/desktop_extra_window_layout.js
+++ b/src/public/app/layouts/desktop_extra_window_layout.js
@@ -19,6 +19,7 @@ import NoteListWidget from "../widgets/note_list.js";
import SqlResultWidget from "../widgets/sql_result.js";
import FilePropertiesWidget from "../widgets/type_property_widgets/file_properties.js";
import ImagePropertiesWidget from "../widgets/type_property_widgets/image_properties.js";
+import NotePropertiesWidget from "../widgets/type_property_widgets/note_properties.js";
export default class DesktopExtraWindowLayout {
constructor(customWidgets) {
@@ -50,6 +51,7 @@ export default class DesktopExtraWindowLayout {
.child(
new TabCachingWidget(() => new CollapsibleSectionContainer()
.child(new SearchDefinitionWidget())
+ .child(new NotePropertiesWidget())
.child(new FilePropertiesWidget())
.child(new ImagePropertiesWidget())
.child(new PromotedAttributesWidget())
diff --git a/src/public/app/layouts/desktop_main_window_layout.js b/src/public/app/layouts/desktop_main_window_layout.js
index 25d3adfc92..734d1dd9e6 100644
--- a/src/public/app/layouts/desktop_main_window_layout.js
+++ b/src/public/app/layouts/desktop_main_window_layout.js
@@ -30,6 +30,7 @@ import SqlResultWidget from "../widgets/sql_result.js";
import SqlTableSchemasWidget from "../widgets/sql_table_schemas.js";
import FilePropertiesWidget from "../widgets/type_property_widgets/file_properties.js";
import ImagePropertiesWidget from "../widgets/type_property_widgets/image_properties.js";
+import NotePropertiesWidget from "../widgets/type_property_widgets/note_properties.js";
const RIGHT_PANE_CSS = `
<style>
@@ -161,6 +162,7 @@ export default class DesktopMainWindowLayout {
.child(
new TabCachingWidget(() => new CollapsibleSectionContainer()
.child(new SearchDefinitionWidget())
+ .child(new NotePropertiesWidget())
.child(new FilePropertiesWidget())
.child(new ImagePropertiesWidget())
.child(new PromotedAttributesWidget())
diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js
index cd9cc493cb..7f8a2f1acf 100644
--- a/src/public/app/services/link.js
+++ b/src/public/app/services/link.js
@@ -90,7 +90,7 @@ function goToLink(e) {
|| $link.hasClass("ck-link-actions__preview") // within edit link dialog single click suffices
) {
const address = $link.attr('href');
-console.log("address", address);
+
if (address) {
if (address.toLowerCase().startsWith('http')) {
window.open(address, '_blank');
diff --git a/src/public/app/widgets/type_property_widgets/file_properties.js b/src/public/app/widgets/type_property_widgets/file_properties.js
index a68f70ea5c..4bd58932a3 100644
--- a/src/public/app/widgets/type_property_widgets/file_properties.js
+++ b/src/public/app/widgets/type_property_widgets/file_properties.js
@@ -52,8 +52,7 @@ const TPL = `
</td>
</tr>
</table>
-</div>\`;
-`;
+</div>`;
export default class FilePropertiesWidget extends TabAwareWidget {
static getType() { return "file"; }
diff --git a/src/public/app/widgets/type_property_widgets/note_properties.js b/src/public/app/widgets/type_property_widgets/note_properties.js
new file mode 100644
index 0000000000..e5a9f11747
--- /dev/null
+++ b/src/public/app/widgets/type_property_widgets/note_properties.js
@@ -0,0 +1,40 @@
+import TabAwareWidget from "../tab_aware_widget.js";
+
+const TPL = `
+<div class="note-properties-widget">
+ <style>
+ .note-properties-widget {
+ padding: 12px;
+ color: var(--muted-text-color);
+ }
+ </style>
+
+ This note was originally taken from: <a class="page-url external"></a>
+</div>`;
+
+export default class NotePropertiesWidget extends TabAwareWidget {
+ static getType() { return "note-properties"; }
+
+ renderTitle(note) {
+ return {
+ show: !!note.getLabelValue('pageUrl'),
+ activate: true,
+ $title: 'Info'
+ };
+ }
+
+ doRender() {
+ this.$widget = $(TPL);
+ this.contentSized();
+
+ this.$pageUrl = this.$widget.find('.page-url');
+ }
+
+ async refreshWithNote(note) {
+ const pageUrl = note.getLabelValue('pageUrl');
+
+ this.$pageUrl
+ .attr('href', pageUrl)
+ .text(pageUrl);
+ }
+}
diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js
index b955d03659..196042ae9a 100644
--- a/src/services/search/services/search.js
+++ b/src/services/search/services/search.js
@@ -205,7 +205,9 @@ function highlightSearchResults(searchResults, highlightedTokens) {
}
for (const attr of note.attributes) {
- if (highlightedTokens.find(token => attr.name.includes(token) || attr.value.includes(token))) {
+ if (highlightedTokens.find(token => attr.name.toLowerCase().includes(token)
+ || attr.value.toLowerCase().includes(token))) {
+
result.highlightedNotePathTitle += ` <${formatAttribute(attr)}>`;
}
}