mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 02:42:27 +08:00
feat(note_language): set language attribute for note
This commit is contained in:
parent
dbea35f9f3
commit
bccfeed431
@ -4,6 +4,7 @@ import { getAvailableLocales, type Locale } from "../services/i18n.js";
|
||||
import { t } from "i18next";
|
||||
import type { EventData } from "../components/app_context.js";
|
||||
import type FNote from "../entities/fnote.js";
|
||||
import attributes from "../services/attributes.js";
|
||||
|
||||
const TPL = `\
|
||||
<div class="dropdown note-language-widget">
|
||||
@ -54,7 +55,11 @@ export default class NoteLanguageWidget extends NoteContextAwareWidget {
|
||||
const $link = $('<a class="dropdown-item">')
|
||||
.attr("data-language", locale.id)
|
||||
.append('<span class="check">✓</span> ')
|
||||
.append($title);
|
||||
.append($title)
|
||||
.on("click", () => {
|
||||
const languageId = $link.attr("data-language") ?? "";
|
||||
this.save(languageId);
|
||||
})
|
||||
this.$noteLanguageDropdown.append($link);
|
||||
} else {
|
||||
this.$noteLanguageDropdown.append('<div class="dropdown-divider"></div>');
|
||||
@ -62,6 +67,16 @@ export default class NoteLanguageWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
}
|
||||
|
||||
async save(languageId: string) {
|
||||
if (!this.note) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (languageId) {
|
||||
attributes.setLabel(this.note.noteId, "language", languageId);
|
||||
}
|
||||
}
|
||||
|
||||
async refreshWithNote(note: FNote) {
|
||||
this.$noteLanguageDesc.text(t("note_language.not_set"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user