Skip to content

Commit bee69ff

Browse files
committed
fix(web): narrow selectionColor type to string
1 parent 1f2f383 commit bee69ff

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

src/types/MarkdownTextProps.web.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { ColorValue } from 'react-native';
21
import type { CSSProperties, HTMLAttributes } from 'react';
32
import type { MarkdownStyle, Md4cFlags } from './MarkdownStyle';
43
import type {
@@ -70,7 +69,7 @@ export interface EnrichedMarkdownTextProps
7069
* Color of the text selection highlight.
7170
* @platform web
7271
*/
73-
selectionColor?: ColorValue;
72+
selectionColor?: string;
7473
/**
7574
* When false (default), removes trailing margin from the last element to
7675
* eliminate bottom spacing.

src/web/EnrichedMarkdownText.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type { ASTNode, RendererCallbacks, RenderCapabilities } from './types';
1818
import { indexTaskItems, markInlineImages } from './utils';
1919
import { loadKaTeX } from './katex';
2020
import type { KaTeXInstance } from './katex';
21-
import { normalizeColor } from '../styleUtils';
2221

2322
export const EnrichedMarkdownText = ({
2423
markdown,
@@ -103,21 +102,18 @@ export const EnrichedMarkdownText = ({
103102
[lastChildStyle]
104103
);
105104

106-
const wrapperStyle = useMemo<CSSProperties>(() => {
107-
const selectionColorCss = selectionColor
108-
? normalizeColor(String(selectionColor))
109-
: undefined;
110-
111-
return {
105+
const wrapperStyle = useMemo<CSSProperties>(
106+
() => ({
112107
display: 'flex',
113108
flexDirection: 'column',
114109
...(containerStyle as CSSProperties),
115110
...(selectable ? undefined : { userSelect: 'none' }),
116-
...(selectionColorCss != null
117-
? ({ ['--enrm-selection-bg']: selectionColorCss } as CSSProperties)
111+
...(selectionColor
112+
? ({ ['--enrm-selection-bg']: selectionColor } as CSSProperties)
118113
: null),
119-
};
120-
}, [containerStyle, selectable, selectionColor]);
114+
}),
115+
[containerStyle, selectable, selectionColor]
116+
);
121117

122118
const selectionStyle = selectionColor ? (
123119
<style>{`[data-enriched-markdown-text] ::selection {

0 commit comments

Comments
 (0)