mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 07:01:31 +08:00 
			
		
		
		
	feat(note_language): support RTL in read-only text
This commit is contained in:
		
							parent
							
								
									115c3bbeb0
								
							
						
					
					
						commit
						ea3364ab09
					
				@ -35,8 +35,9 @@ export function getAvailableLocales() {
 | 
				
			|||||||
 * @param localeId the locale ID to search for.
 | 
					 * @param localeId the locale ID to search for.
 | 
				
			||||||
 * @returns the corresponding {@link Locale} or `null` if it was not found.
 | 
					 * @returns the corresponding {@link Locale} or `null` if it was not found.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export function getLocaleById(localeId: string ) {
 | 
					export function getLocaleById(localeId: string | null | undefined) {
 | 
				
			||||||
    return locales?.find((l) => l.id === localeId);
 | 
					    if (!localeId) return null;
 | 
				
			||||||
 | 
					    return locales?.find((l) => l.id === localeId) ?? null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const t = i18next.t;
 | 
					export const t = i18next.t;
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@ import { applySyntaxHighlight } from "../../services/syntax_highlight.js";
 | 
				
			|||||||
import { getMermaidConfig } from "../mermaid.js";
 | 
					import { getMermaidConfig } from "../mermaid.js";
 | 
				
			||||||
import type FNote from "../../entities/fnote.js";
 | 
					import type FNote from "../../entities/fnote.js";
 | 
				
			||||||
import type { EventData } from "../../components/app_context.js";
 | 
					import type { EventData } from "../../components/app_context.js";
 | 
				
			||||||
 | 
					import { getLocaleById } from "../../services/i18n.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TPL = `
 | 
					const TPL = `
 | 
				
			||||||
<div class="note-detail-readonly-text note-detail-printable">
 | 
					<div class="note-detail-readonly-text note-detail-printable">
 | 
				
			||||||
@ -100,6 +101,11 @@ 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");
 | 
				
			||||||
 | 
					        const correspondingLocale = getLocaleById(languageCode);
 | 
				
			||||||
 | 
					        const isRtl = correspondingLocale?.rtl;
 | 
				
			||||||
 | 
					        this.$content.attr("dir", isRtl ? "rtl" : "ltr");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const blob = await note.getBlob();
 | 
					        const blob = await note.getBlob();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$content.html(blob?.content ?? "");
 | 
					        this.$content.html(blob?.content ?? "");
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user