@@ -6,39 +6,8 @@ import {
66 DEFAULT_SETTINGS ,
77} from "./settings" ;
88
9- // Add styles for the excluded folders list
10- // TODO: Move this to a styles.css file
11- const EXCLUDED_FOLDERS_STYLES = `
12- .excluded-folders-list {
13- margin-bottom: 1em;
14- }
15-
16- .excluded-folder-item {
17- display: flex;
18- justify-content: space-between;
19- align-items: center;
20- background-color: var(--background-secondary);
21- border-radius: 4px;
22- padding: 4px 8px;
23- margin-bottom: 6px;
24- }
25-
26- .excluded-folder-remove {
27- cursor: pointer;
28- border: none;
29- background: transparent;
30- color: var(--text-muted);
31- padding: 0 4px;
32- font-size: 14px;
33- }
34-
35- .excluded-folder-remove:hover {
36- color: var(--text-error);
37- }` ;
38-
399export default class ChangelogPlugin extends Plugin {
4010 settings : ChangelogSettings = DEFAULT_SETTINGS ;
41- private styleEl : HTMLStyleElement ;
4211
4312 async onload ( ) {
4413 await this . loadSettings ( ) ;
@@ -50,20 +19,28 @@ export default class ChangelogPlugin extends Plugin {
5019 callback : ( ) => this . updateChangelog ( ) ,
5120 } ) ;
5221
53- // Add styles for the excluded folders feature
54- this . styleEl = document . createElement ( "style" ) ;
55- this . styleEl . textContent = EXCLUDED_FOLDERS_STYLES ;
56- document . head . appendChild ( this . styleEl ) ;
22+ this . loadStyles ( ) ;
5723
5824 this . onVaultChange = debounce ( this . onVaultChange . bind ( this ) , 200 ) ;
5925 this . enableAutoUpdate ( ) ;
6026 }
6127
6228 onunload ( ) {
63- // Remove styles when plugin is disabled
64- if ( this . styleEl && this . styleEl . parentNode ) {
65- this . styleEl . parentNode . removeChild ( this . styleEl ) ;
66- }
29+ // Cleanup happens automatically
30+ }
31+
32+ async loadStyles ( ) {
33+ const cssFile = await this . app . vault . adapter . read (
34+ this . manifest . dir + "/styles.css" ,
35+ ) ;
36+ this . registerStyles ( cssFile ) ;
37+ }
38+
39+ registerStyles ( cssText : string ) {
40+ const styleEl = document . createElement ( "style" ) ;
41+ styleEl . textContent = cssText ;
42+ this . register ( ( ) => styleEl . remove ( ) ) ;
43+ document . head . appendChild ( styleEl ) ;
6744 }
6845
6946 enableAutoUpdate ( ) {
0 commit comments