mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-30 12:13:52 +08:00 
			
		
		
		
	feat(code): update theme automatically when changed
This commit is contained in:
		
							parent
							
								
									d41b780f43
								
							
						
					
					
						commit
						f0d2fbc882
					
				| @ -3,6 +3,7 @@ import type FNote from "../../entities/fnote.js"; | |||||||
| import options from "../../services/options.js"; | import options from "../../services/options.js"; | ||||||
| import TypeWidget from "./type_widget.js"; | import TypeWidget from "./type_widget.js"; | ||||||
| import CodeMirror, { type EditorConfig } from "@triliumnext/codemirror"; | import CodeMirror, { type EditorConfig } from "@triliumnext/codemirror"; | ||||||
|  | import type { EventData } from "../../components/app_context.js"; | ||||||
| 
 | 
 | ||||||
| export const DEFAULT_PREFIX = "default:"; | export const DEFAULT_PREFIX = "default:"; | ||||||
| 
 | 
 | ||||||
| @ -103,4 +104,17 @@ export default class AbstractCodeTypeWidget extends TypeWidget { | |||||||
|             // });
 |             // });
 | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { | ||||||
|  |         if (loadResults.isOptionReloaded("codeNoteTheme")) { | ||||||
|  |             const themeId = options.get("codeNoteTheme"); | ||||||
|  |             if (themeId?.startsWith(DEFAULT_PREFIX)) { | ||||||
|  |                 const theme = getThemeById(themeId.substring(DEFAULT_PREFIX.length)); | ||||||
|  |                 if (theme) { | ||||||
|  |                     await this.codeEditor.setTheme(theme); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran