mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +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 utils from "../../services/utils.js"; | ||||
| import options from "../../services/options.js"; | ||||
| import attributes from "../../services/attributes.js"; | ||||
| 
 | ||||
| export default class AbstractTextTypeWidget extends TypeWidget { | ||||
|     doRender() { | ||||
| @ -117,5 +118,16 @@ export default class AbstractTextTypeWidget extends TypeWidget { | ||||
|         if (loadResults.isOptionReloaded("codeBlockWordWrap")) { | ||||
|             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 { normalizeMimeTypeForCKEditor } from "../../services/mime_type_definitions.js"; | ||||
| import { buildConfig, buildToolbarConfig } from "./ckeditor/toolbars.js"; | ||||
| import attributes from "../../services/attributes.js"; | ||||
| 
 | ||||
| const ENABLE_INSPECTOR = false; | ||||
| 
 | ||||
| @ -506,16 +505,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { | ||||
|         this.watchdog.editor.setData(data); | ||||
|     } | ||||
| 
 | ||||
|     async entitiesReloadedEvent(e) { | ||||
|         if (e.loadResults.getAttributeRows().find((attr) => | ||||
|             attr.type === "label" && | ||||
|             attr.name === "language" && | ||||
|             attributes.isAffecting(attr, this.note))) | ||||
|         { | ||||
|     async onLanguageChanged() { | ||||
|         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)
 | ||||
|         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); | ||||
| 
 | ||||
|         const languageCode = note.getLabelValue("language"); | ||||
|         const correspondingLocale = getLocaleById(languageCode); | ||||
|         const isRtl = correspondingLocale?.rtl; | ||||
|         this.$widget.attr("dir", isRtl ? "rtl" : "ltr"); | ||||
|         this.onLanguageChanged(); | ||||
| 
 | ||||
|         const blob = await note.getBlob(); | ||||
| 
 | ||||
| @ -159,4 +156,12 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget { | ||||
| 
 | ||||
|         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
	 Elian Doran
						Elian Doran