-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standalone editor: Decouple DarkColorHandler (#2144)
- Loading branch information
1 parent
165d4ea
commit c4a53df
Showing
5 changed files
with
68 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages-content-model/roosterjs-content-model-types/lib/context/ColorManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Represents a combination of color key, light color and dark color, parsed from existing color value | ||
*/ | ||
export interface Colors { | ||
/** | ||
* Light mode color value | ||
*/ | ||
lightModeColor: string; | ||
|
||
/** | ||
* Dark mode color value, if found, otherwise undefined | ||
*/ | ||
darkModeColor?: string; | ||
} | ||
|
||
/** | ||
* A handler object for dark color, used for variable-based dark color solution | ||
*/ | ||
export interface ColorManager { | ||
/** | ||
* Given a light mode color value and an optional dark mode color value, register this color | ||
* so that editor can handle it, then return the CSS color value for current color mode. | ||
* @param lightModeColor Light mode color value | ||
* @param isDarkMode Whether current color mode is dark mode | ||
*/ | ||
registerColor(lightModeColor: string, isDarkMode: boolean): string; | ||
|
||
/** | ||
* Parse an existing color value, if it is in variable-based color format, extract color key, | ||
* light color and query related dark color if any | ||
* @param color The color string to parse | ||
* @param isInDarkMode Whether current content is in dark mode. When set to true, if the color value is not in dark var format, | ||
* we will treat is as a dark mode color and try to find a matched dark mode color. | ||
*/ | ||
parseColorValue(color: string | null | undefined, isInDarkMode?: boolean): Colors; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters