@@ -25,6 +25,23 @@ export default class ColorPaletteCanvasExtension {
2525 this . plugin . register ( ( ) => this . observer ?. disconnect ( ) )
2626 }
2727
28+ private updateCustomColorModStyleClasses ( ) {
29+ document . getElementById ( CUSTOM_COLORS_MOD_STYLES_ID ) ?. remove ( )
30+
31+ const customColorModStyle = document . createElement ( 'style' )
32+ customColorModStyle . id = CUSTOM_COLORS_MOD_STYLES_ID
33+ document . body . appendChild ( customColorModStyle )
34+
35+ for ( const colorId of this . getCustomColors ( ) ) {
36+ // Add mod-canvas-color-<colorId> style to the css
37+ customColorModStyle . innerHTML += `
38+ .mod-canvas-color-${ colorId } {
39+ --canvas-color: var(--canvas-color-${ colorId } );
40+ }
41+ `
42+ }
43+ }
44+
2845 private patchColorSelection ( canvas : Canvas ) {
2946 if ( this . observer ) this . observer . disconnect ( )
3047
@@ -68,23 +85,6 @@ export default class ColorPaletteCanvasExtension {
6885 return menuItem
6986 }
7087
71- private updateCustomColorModStyleClasses ( ) {
72- document . getElementById ( CUSTOM_COLORS_MOD_STYLES_ID ) ?. remove ( )
73-
74- const customColorModStyle = document . createElement ( 'style' )
75- customColorModStyle . id = CUSTOM_COLORS_MOD_STYLES_ID
76- document . body . appendChild ( customColorModStyle )
77-
78- for ( const colorId of this . getCustomColors ( ) ) {
79- // Add mod-canvas-color-<colorId> style to the css
80- customColorModStyle . innerHTML += `
81- .mod-canvas-color-${ colorId } {
82- --canvas-color: var(--canvas-color-${ colorId } );
83- }
84- `
85- }
86- }
87-
8888 private getCustomColors ( ) : string [ ] {
8989 const colors : string [ ] = [ ]
9090
0 commit comments