Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(options: GOptions = Object.create(null)) {
this.options = deepMerge(defaultOptions, { ...this.defaultOptions, ...options });
this.init();
}
export const applyColorMode = (theme: RemirrorTheme, mode: string): RemirrorTheme => {
if (!mode) {
return theme;
}
const modes = get('colors.modes', theme, {});
return deepMerge(theme, { colors: get(mode, modes, {}) });
};
const disableMergeWithEmotion = disableMerge.includes('emotion');
const outer = useRemirrorTheme();
const emotionTheme = useEmotionTheme();
const [colorMode, setColorMode] = useState(initialColorMode ?? outer.colorMode);
const parentEmotionTheme = isRoot(outer) && !disableMergeWithEmotion ? emotionTheme : {};
const parent = disableMergeWithParent
? hasParent(outer)
? outer.parent
: Object.create(null)
: isRoot(outer) && disableMergeWithBase
? Object.create(null)
: outer.theme;
const themeWithoutColorMode: RemirrorTheme = deepMerge(
parentEmotionTheme,
parent,
isFunction(themeProp) ? themeProp(parent) : themeProp,
);
const theme = applyColorMode(themeWithoutColorMode, colorMode);
const [get, colorModes] = useMemo(() => [getFactory(theme), getColorModes(theme)], [theme]);
const value = {
...defaultRemirrorThemeValue,
...(withoutEmotion
? withoutEmotionProps
: {
sxx: (...args: Parameters) =>
defaultRemirrorThemeValue.sx(...args)(theme),
}),