mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
feat(note_language): refresh rtl for read-only notes
This commit is contained in:
parent
24c2b54bc9
commit
3d600c885a
@ -5,6 +5,7 @@ import linkService from "../../services/link.js";
|
|||||||
import contentRenderer from "../../services/content_renderer.js";
|
import contentRenderer from "../../services/content_renderer.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
import options from "../../services/options.js";
|
import options from "../../services/options.js";
|
||||||
|
import attributes from "../../services/attributes.js";
|
||||||
|
|
||||||
export default class AbstractTextTypeWidget extends TypeWidget {
|
export default class AbstractTextTypeWidget extends TypeWidget {
|
||||||
doRender() {
|
doRender() {
|
||||||
@ -117,5 +118,16 @@ export default class AbstractTextTypeWidget extends TypeWidget {
|
|||||||
if (loadResults.isOptionReloaded("codeBlockWordWrap")) {
|
if (loadResults.isOptionReloaded("codeBlockWordWrap")) {
|
||||||
this.refreshCodeBlockOptions();
|
this.refreshCodeBlockOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loadResults.getAttributeRows().find((attr) =>
|
||||||
|
attr.type === "label" &&
|
||||||
|
attr.name === "language" &&
|
||||||
|
attributes.isAffecting(attr, this.note)))
|
||||||
|
{
|
||||||
|
await this.onLanguageChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onLanguageChanged() { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import toast from "../../services/toast.js";
|
|||||||
import { getMermaidConfig } from "../mermaid.js";
|
import { getMermaidConfig } from "../mermaid.js";
|
||||||
import { normalizeMimeTypeForCKEditor } from "../../services/mime_type_definitions.js";
|
import { normalizeMimeTypeForCKEditor } from "../../services/mime_type_definitions.js";
|
||||||
import { buildConfig, buildToolbarConfig } from "./ckeditor/toolbars.js";
|
import { buildConfig, buildToolbarConfig } from "./ckeditor/toolbars.js";
|
||||||
import attributes from "../../services/attributes.js";
|
|
||||||
|
|
||||||
const ENABLE_INSPECTOR = false;
|
const ENABLE_INSPECTOR = false;
|
||||||
|
|
||||||
@ -506,16 +505,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
this.watchdog.editor.setData(data);
|
this.watchdog.editor.setData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async entitiesReloadedEvent(e) {
|
async onLanguageChanged() {
|
||||||
if (e.loadResults.getAttributeRows().find((attr) =>
|
await this.reinitialize();
|
||||||
attr.type === "label" &&
|
|
||||||
attr.name === "language" &&
|
|
||||||
attributes.isAffecting(attr, this.note)))
|
|
||||||
{
|
|
||||||
await this.reinitialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.entitiesReloadedEvent(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,10 +101,7 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
// (see https://github.com/zadam/trilium/issues/1590 for example of such conflict)
|
// (see https://github.com/zadam/trilium/issues/1590 for example of such conflict)
|
||||||
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
||||||
|
|
||||||
const languageCode = note.getLabelValue("language");
|
this.onLanguageChanged();
|
||||||
const correspondingLocale = getLocaleById(languageCode);
|
|
||||||
const isRtl = correspondingLocale?.rtl;
|
|
||||||
this.$widget.attr("dir", isRtl ? "rtl" : "ltr");
|
|
||||||
|
|
||||||
const blob = await note.getBlob();
|
const blob = await note.getBlob();
|
||||||
|
|
||||||
@ -159,4 +156,12 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
|
|
||||||
resolve(this.$content);
|
resolve(this.$content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onLanguageChanged(): Promise<void> {
|
||||||
|
const languageCode = this.note?.getLabelValue("language");
|
||||||
|
const correspondingLocale = getLocaleById(languageCode);
|
||||||
|
const isRtl = correspondingLocale?.rtl;
|
||||||
|
this.$widget.attr("dir", isRtl ? "rtl" : "ltr");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user