mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
feat(note_language): initialize CKEditor with right language
This commit is contained in:
@@ -148,6 +148,9 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
typeWidget.spacedUpdate = this.spacedUpdate;
|
typeWidget.spacedUpdate = this.spacedUpdate;
|
||||||
typeWidget.setParent(this);
|
typeWidget.setParent(this);
|
||||||
|
|
||||||
|
if (this.noteContext) {
|
||||||
|
typeWidget.setNoteContextEvent({ noteContext: this.noteContext });
|
||||||
|
}
|
||||||
const $renderedWidget = typeWidget.render();
|
const $renderedWidget = typeWidget.render();
|
||||||
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
|
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
||||||
logInfo("Creating new CKEditor");
|
logInfo("Creating new CKEditor");
|
||||||
|
|
||||||
const editor = await editorClass.create(elementOrData, {
|
const finalConfig = {
|
||||||
...editorConfig,
|
...editorConfig,
|
||||||
...buildConfig(),
|
...buildConfig(),
|
||||||
...buildToolbarConfig(isClassicEditor),
|
...buildToolbarConfig(isClassicEditor),
|
||||||
@@ -195,7 +195,17 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
classes: true,
|
classes: true,
|
||||||
attributes: true
|
attributes: true
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
const contentLanguage = this.note.getLabelValue("language");
|
||||||
|
if (contentLanguage) {
|
||||||
|
finalConfig.language = {
|
||||||
|
ui: (typeof finalConfig.language === "string" ? finalConfig.language : "en"),
|
||||||
|
content: contentLanguage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const editor = await editorClass.create(elementOrData, finalConfig);
|
||||||
|
|
||||||
const notificationsPlugin = editor.plugins.get("Notification");
|
const notificationsPlugin = editor.plugins.get("Notification");
|
||||||
notificationsPlugin.on("show:warning", (evt, data) => {
|
notificationsPlugin.on("show:warning", (evt, data) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user