Skip to content

Commit a1523e2

Browse files
committed
feat: htmlStyle for interactive examples components
1 parent de2b5ba commit a1523e2

11 files changed

Lines changed: 109 additions & 1 deletion

docs/docs/fundamentals/your-first-editor.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,13 @@ Here's that editor running live on this page. Select some text and hit **Bold**
198198
notice the button turns green whenever the cursor sits on bold text. Switch to
199199
the **Code** tab to see the exact source.
200200

201+
:::note
202+
203+
The `htmlStyle` you'll spot in the Code tab is only there to make the rendered
204+
text match these docs' color palette, so
205+
don't worry about it here. If want to learn more, see
206+
[Styling the input](/core-functionalities/styling-the-input).
207+
208+
:::
209+
201210
<InteractiveExample src={FirstEditorSrc} component={FirstEditor} />

docs/src/examples/BasicStylesEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from 'react-native-enriched-html';
66
import { useRef, useState } from 'react';
77
import { View, StyleSheet, Pressable, Text } from 'react-native';
8+
import { htmlStyle } from './htmlStyle';
89

910
export default function App() {
1011
const ref = useRef<EnrichedTextInputInstance>(null);
@@ -71,6 +72,7 @@ export default function App() {
7172
<EnrichedTextInput
7273
ref={ref}
7374
style={styles.input}
75+
htmlStyle={htmlStyle}
7476
placeholder="Type something here..."
7577
onChangeState={e => setState(e.nativeEvent)}
7678
/>

docs/src/examples/FirstEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from 'react-native-enriched-html';
66
import { useRef, useState } from 'react';
77
import { View, StyleSheet, Pressable, Text } from 'react-native';
8+
import { htmlStyle } from './htmlStyle';
89

910
export default function App() {
1011
const ref = useRef<EnrichedTextInputInstance>(null);
@@ -15,6 +16,7 @@ export default function App() {
1516
<EnrichedTextInput
1617
ref={ref}
1718
style={styles.input}
19+
htmlStyle={htmlStyle}
1820
placeholder="Type something here..."
1921
onChangeState={e => setState(e.nativeEvent)}
2022
/>

docs/src/examples/ImagesEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EnrichedTextInput } from 'react-native-enriched-html';
22
import type { EnrichedTextInputInstance } from 'react-native-enriched-html';
33
import { useRef } from 'react';
44
import { View, StyleSheet, Pressable, Text } from 'react-native';
5+
import { htmlStyle } from './htmlStyle';
56

67
export default function App() {
78
const ref = useRef<EnrichedTextInputInstance>(null);
@@ -23,6 +24,7 @@ export default function App() {
2324
<EnrichedTextInput
2425
ref={ref}
2526
style={styles.input}
27+
htmlStyle={htmlStyle}
2628
placeholder="Place the cursor, then insert an image below..."
2729
/>
2830
<View style={styles.row}>

docs/src/examples/LinksEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from 'react-native-enriched-html';
66
import { useRef, useState } from 'react';
77
import { View, StyleSheet, Pressable, Text } from 'react-native';
8+
import { htmlStyle } from './htmlStyle';
89

910
// Autolink any "issue-123" style token.
1011
const linkRegex = /issue-\d+/g;
@@ -33,6 +34,7 @@ export default function App() {
3334
<EnrichedTextInput
3435
ref={ref}
3536
style={styles.input}
37+
htmlStyle={htmlStyle}
3638
placeholder="Type issue-123, or select text below..."
3739
linkRegex={linkRegex}
3840
onChangeSelection={e => setSelection(e.nativeEvent)}

docs/src/examples/ListsEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from 'react-native-enriched-html';
66
import { useRef, useState } from 'react';
77
import { View, StyleSheet, Pressable, Text } from 'react-native';
8+
import { htmlStyle } from './htmlStyle';
89

910
export default function App() {
1011
const ref = useRef<EnrichedTextInputInstance>(null);
@@ -52,6 +53,7 @@ export default function App() {
5253
<EnrichedTextInput
5354
ref={ref}
5455
style={styles.input}
56+
htmlStyle={htmlStyle}
5557
placeholder="Type a few lines, then turn them into a list..."
5658
onChangeState={e => setState(e.nativeEvent)}
5759
/>

docs/src/examples/MentionEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EnrichedTextInput } from 'react-native-enriched-html';
22
import type { EnrichedTextInputInstance } from 'react-native-enriched-html';
33
import { useRef } from 'react';
44
import { View, StyleSheet, Pressable, Text } from 'react-native';
5+
import { htmlStyle } from './htmlStyle';
56

67
const user = { id: '1', name: 'John' };
78

@@ -18,6 +19,7 @@ export default function App() {
1819
<EnrichedTextInput
1920
ref={ref}
2021
style={styles.input}
22+
htmlStyle={htmlStyle}
2123
placeholder="Type '@', then tap the button below..."
2224
/>
2325
<Pressable style={styles.button} onPress={insertMention}>

docs/src/examples/RenderingEditor.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from 'react-native-enriched-html';
66
import { useRef, useState } from 'react';
77
import { View, StyleSheet, Pressable, Text } from 'react-native';
8+
import { htmlStyle, enrichedTextHtmlStyle } from './htmlStyle';
89

910
export default function App() {
1011
const ref = useRef<EnrichedTextInputInstance>(null);
@@ -43,6 +44,7 @@ export default function App() {
4344
<EnrichedTextInput
4445
ref={ref}
4546
style={styles.input}
47+
htmlStyle={htmlStyle}
4648
placeholder="Type something here..."
4749
onChangeState={e => setState(e.nativeEvent)}
4850
/>
@@ -72,7 +74,10 @@ export default function App() {
7274
<Text style={styles.renderText}>Render ↓</Text>
7375
</Pressable>
7476

75-
<EnrichedText style={styles.viewer} selectable>
77+
<EnrichedText
78+
style={styles.viewer}
79+
htmlStyle={enrichedTextHtmlStyle}
80+
selectable>
7681
{html}
7782
</EnrichedText>
7883
</View>

docs/src/examples/TextAlignmentEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from 'react-native-enriched-html';
66
import { useRef, useState } from 'react';
77
import { View, StyleSheet, Pressable, Text } from 'react-native';
8+
import { htmlStyle } from './htmlStyle';
89

910
const alignments = ['left', 'center', 'right', 'justify'] as const;
1011

@@ -32,6 +33,7 @@ export default function App() {
3233
<EnrichedTextInput
3334
ref={ref}
3435
style={styles.input}
36+
htmlStyle={htmlStyle}
3537
placeholder="Type a paragraph, then align it below..."
3638
onChangeState={e => setState(e.nativeEvent)}
3739
/>

docs/src/examples/TextShortcutsEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EnrichedTextInput } from 'react-native-enriched-html';
22
import type { EnrichedTextInputInstance } from 'react-native-enriched-html';
33
import { useRef } from 'react';
44
import { View, StyleSheet } from 'react-native';
5+
import { htmlStyle } from './htmlStyle';
56

67
export default function App() {
78
const ref = useRef<EnrichedTextInputInstance>(null);
@@ -11,6 +12,7 @@ export default function App() {
1112
<EnrichedTextInput
1213
ref={ref}
1314
style={styles.input}
15+
htmlStyle={htmlStyle}
1416
// Two shortcuts, one of each kind:
1517
// - '# ' at the start of a paragraph turns the line into an H1 (paragraph style)
1618
// - '**text**' wraps the delimited text in bold (inline style)

0 commit comments

Comments
 (0)