From dbca50d9b0d74650c94481b86ff2c514e08d6fe7 Mon Sep 17 00:00:00 2001
From: SiriusXT <1160925501@qq.com>
Date: Fri, 1 Nov 2024 14:45:49 +0800
Subject: [PATCH] Make note-detail-empty always display autocompletion.
---
src/public/app/widgets/type_widgets/empty.js | 22 ++++++++------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/public/app/widgets/type_widgets/empty.js b/src/public/app/widgets/type_widgets/empty.js
index 0a7119b80..45da73e6e 100644
--- a/src/public/app/widgets/type_widgets/empty.js
+++ b/src/public/app/widgets/type_widgets/empty.js
@@ -18,10 +18,9 @@ const TPL = `
width: 130px;
text-align: center;
margin: 10px;
- padding; 10px;
border: 1px transparent solid;
}
-
+
.workspace-notes .workspace-note:hover {
cursor: pointer;
border: 1px solid var(--main-border-color);
@@ -33,14 +32,14 @@ const TPL = `
}
+
`;
export default class EmptyTypeWidget extends TypeWidget {
@@ -51,10 +50,12 @@ export default class EmptyTypeWidget extends TypeWidget {
this.$widget = $(TPL);
this.$autoComplete = this.$widget.find(".note-autocomplete");
+ this.$results = this.$widget.find(".note-detail-empty-results");
noteAutocompleteService.initNoteAutocomplete(this.$autoComplete, {
hideGoToSelectedNoteButton: true,
- allowCreatingNotes: true
+ allowCreatingNotes: true,
+ container: this.$results
})
.on('autocomplete:noteselected', function(event, suggestion, dataset) {
if (!suggestion.notePath) {
@@ -84,15 +85,10 @@ export default class EmptyTypeWidget extends TypeWidget {
);
}
- // Automatically trigger autocomplete on focus.
- this.$autoComplete.on('focus', () => {
- // simulate pressing down arrow to trigger autocomplete
- this.$autoComplete.trigger($.Event('keydown', { which: 40 })); // arrow down
- this.$autoComplete.trigger($.Event('keydown', { which: 38 })); // arrow up
- });
-
this.$autoComplete
.trigger('focus')
.trigger('select');
+
+ noteAutocompleteService.showRecentNotes(this.$autoComplete);
}
}