mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Merge remote-tracking branch 'origin/stable'
# Conflicts: # src/services/search/services/search.js
This commit is contained in:
commit
5eb850bf59
@ -40,7 +40,12 @@ function initAttributeNameAutocomplete({ $el, attributeType, open }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function initLabelValueAutocomplete({ $el, open, nameCallback }) {
|
async function initLabelValueAutocomplete({ $el, open, nameCallback }) {
|
||||||
if (!$el.hasClass("aa-input")) {
|
if ($el.hasClass("aa-input")) {
|
||||||
|
// we reinit everytime because autocomplete seems to have a bug where it retains state from last
|
||||||
|
// open even though the value was resetted
|
||||||
|
$el.autocomplete('destroy');
|
||||||
|
}
|
||||||
|
|
||||||
const attributeName = nameCallback();
|
const attributeName = nameCallback();
|
||||||
|
|
||||||
if (attributeName.trim() === "") {
|
if (attributeName.trim() === "") {
|
||||||
@ -57,12 +62,13 @@ async function initLabelValueAutocomplete({ $el, open, nameCallback }) {
|
|||||||
$el.autocomplete({
|
$el.autocomplete({
|
||||||
appendTo: document.querySelector('body'),
|
appendTo: document.querySelector('body'),
|
||||||
hint: false,
|
hint: false,
|
||||||
openOnFocus: true,
|
openOnFocus: false, // handled manually
|
||||||
minLength: 0,
|
minLength: 0,
|
||||||
tabAutocomplete: false
|
tabAutocomplete: false
|
||||||
}, [{
|
}, [{
|
||||||
displayKey: 'value',
|
displayKey: 'value',
|
||||||
source: function (term, cb) {
|
cache: false,
|
||||||
|
source: async function (term, cb) {
|
||||||
term = term.toLowerCase();
|
term = term.toLowerCase();
|
||||||
|
|
||||||
const filtered = attributeValues.filter(attr => attr.value.toLowerCase().includes(term));
|
const filtered = attributeValues.filter(attr => attr.value.toLowerCase().includes(term));
|
||||||
@ -75,8 +81,7 @@ async function initLabelValueAutocomplete({ $el, open, nameCallback }) {
|
|||||||
if ($el.attr("readonly")) {
|
if ($el.attr("readonly")) {
|
||||||
$el.autocomplete('close');
|
$el.autocomplete('close');
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
$el.autocomplete("open");
|
$el.autocomplete("open");
|
||||||
|
@ -248,6 +248,8 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
|||||||
this.$rowValue = this.$widget.find('.attr-row-value');
|
this.$rowValue = this.$widget.find('.attr-row-value');
|
||||||
this.$inputValue = this.$widget.find('.attr-input-value');
|
this.$inputValue = this.$widget.find('.attr-input-value');
|
||||||
this.$inputValue.on('keyup', () => this.userEditedAttribute());
|
this.$inputValue.on('keyup', () => this.userEditedAttribute());
|
||||||
|
this.$inputValue.on('change', () => this.userEditedAttribute());
|
||||||
|
this.$inputValue.on('autocomplete:closed', () => this.userEditedAttribute());
|
||||||
this.$inputValue.on('focus', () => {
|
this.$inputValue.on('focus', () => {
|
||||||
attributeAutocompleteService.initLabelValueAutocomplete({
|
attributeAutocompleteService.initLabelValueAutocomplete({
|
||||||
$el: this.$inputValue,
|
$el: this.$inputValue,
|
||||||
|
@ -197,18 +197,18 @@ function highlightSearchResults(searchResults, highlightedTokens) {
|
|||||||
result.highlightedNotePathTitle = result.notePathTitle.replace('/[<\{\}]/g', '');
|
result.highlightedNotePathTitle = result.notePathTitle.replace('/[<\{\}]/g', '');
|
||||||
|
|
||||||
if (highlightedTokens.find(token => note.type.includes(token))) {
|
if (highlightedTokens.find(token => note.type.includes(token))) {
|
||||||
result.highlightedNotePathTitle += ` <type: ${note.type}>`;
|
result.highlightedNotePathTitle += ` "type: ${note.type}'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlightedTokens.find(token => note.mime.includes(token))) {
|
if (highlightedTokens.find(token => note.mime.includes(token))) {
|
||||||
result.highlightedNotePathTitle += ` <mime: ${note.mime}>`;
|
result.highlightedNotePathTitle += ` "mime: ${note.mime}'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const attr of note.attributes) {
|
for (const attr of note.attributes) {
|
||||||
if (highlightedTokens.find(token => attr.name.toLowerCase().includes(token)
|
if (highlightedTokens.find(token => attr.name.toLowerCase().includes(token)
|
||||||
|| attr.value.toLowerCase().includes(token))) {
|
|| attr.value.toLowerCase().includes(token))) {
|
||||||
|
|
||||||
result.highlightedNotePathTitle += ` <${formatAttribute(attr)}>`;
|
result.highlightedNotePathTitle += ` "${formatAttribute(attr)}'`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,8 +223,8 @@ function highlightSearchResults(searchResults, highlightedTokens) {
|
|||||||
|
|
||||||
for (const result of searchResults) {
|
for (const result of searchResults) {
|
||||||
result.highlightedNotePathTitle = result.highlightedNotePathTitle
|
result.highlightedNotePathTitle = result.highlightedNotePathTitle
|
||||||
.replace(/</g, "<small>")
|
.replace(/"/g, "<small>")
|
||||||
.replace(/>/g, "</small>")
|
.replace(/'/g, "</small>")
|
||||||
.replace(/{/g, "<b>")
|
.replace(/{/g, "<b>")
|
||||||
.replace(/}/g, "</b>");
|
.replace(/}/g, "</b>");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user