mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 15:09:01 +01:00
feat(note_language): reinitialize editor when switching between RTL and LTR notes
This commit is contained in:
parent
ea3364ab09
commit
51813099b3
@ -202,6 +202,9 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
ui: (typeof finalConfig.language === "string" ? finalConfig.language : "en"),
|
ui: (typeof finalConfig.language === "string" ? finalConfig.language : "en"),
|
||||||
content: contentLanguage
|
content: contentLanguage
|
||||||
}
|
}
|
||||||
|
this.contentLanguage = contentLanguage;
|
||||||
|
} else {
|
||||||
|
this.contentLanguage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const editor = await editorClass.create(elementOrData, finalConfig);
|
const editor = await editorClass.create(elementOrData, finalConfig);
|
||||||
@ -278,7 +281,15 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
async doRefresh(note) {
|
async doRefresh(note) {
|
||||||
const blob = await note.getBlob();
|
const blob = await note.getBlob();
|
||||||
|
|
||||||
await this.spacedUpdate.allowUpdateWithoutChange(() => this.watchdog.editor.setData(blob.content || ""));
|
await this.spacedUpdate.allowUpdateWithoutChange(async () => {
|
||||||
|
const data = blob.content || "";
|
||||||
|
const newContentLanguage = this.note.getLabelValue("language");
|
||||||
|
if (this.contentLanguage !== newContentLanguage) {
|
||||||
|
await this.reinitialize(data);
|
||||||
|
} else {
|
||||||
|
this.watchdog.editor.setData(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getData() {
|
getData() {
|
||||||
@ -482,12 +493,14 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
this.refreshIncludedNote(this.$editor, noteId);
|
this.refreshIncludedNote(this.$editor, noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async reinitialize() {
|
async reinitialize(data = null) {
|
||||||
if (!this.watchdog) {
|
if (!this.watchdog) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = this.watchdog.editor.getData();
|
if (!data) {
|
||||||
|
data = this.watchdog.editor.getData();
|
||||||
|
}
|
||||||
this.watchdog.destroy();
|
this.watchdog.destroy();
|
||||||
await this.createEditor();
|
await this.createEditor();
|
||||||
this.watchdog.editor.setData(data);
|
this.watchdog.editor.setData(data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user