Skip to content

Commit 1fae618

Browse files
committed
Merge branch 'main' into @kacperzolkiewski/feat-on-image-press
2 parents 9b23270 + 2251fc6 commit 1fae618

30 files changed

Lines changed: 78 additions & 54 deletions

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121

2222
## Installation
2323

24-
Check out the detailed [installation instructions](https://enriched.swmansion.com/html/).
24+
Check out the detailed [installation instructions](https://docs.swmansion.com/react-native-enriched-html/#installation).
2525

2626
## Compatibility
2727

2828
At the moment, the library offers stable support for iOS, Android and Web.
2929

30-
The full list of compatible React Native versions is available [here](https://enriched.swmansion.com/html/).
30+
The full list of compatible React Native versions is available [here](https://docs.swmansion.com/react-native-enriched-html/misc/compatibility/#supported-react-native-versions).
3131

3232
## Documentation
3333

34-
To find more about `react-native-enriched-html` including usage guides, API references, known limitations or our contributing guide, visit the official [documentation](https://enriched.swmansion.com/html/).
34+
To find more about `react-native-enriched-html` including usage guides, API references, known limitations or our contributing guide, visit the official [documentation](https://docs.swmansion.com/react-native-enriched-html/).
3535

3636
## Examples
3737

3838
The source code for the example mobile and web apps is under the [`apps`](https://github.com/software-mansion/react-native-enriched-html/tree/main/apps) directory.
39-
You can also see the live preview of the library's capabilities by visiting the [official documentation](https://enriched.swmansion.com/html/) filled with interactive examples.
39+
You can also see the live preview of the library's capabilities by visiting the [official documentation](https://docs.swmansion.com/react-native-enriched-html/) filled with interactive examples.
4040

4141
## License
4242

apps/example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,7 @@ PODS:
18451845
- React-utils (= 0.86.0)
18461846
- ReactNativeDependencies
18471847
- ReactNativeDependencies (0.86.0)
1848-
- ReactNativeEnrichedHtml (1.1.0):
1848+
- ReactNativeEnrichedHtml (1.1.1):
18491849
- hermes-engine
18501850
- RCTRequired
18511851
- RCTTypeSafety
@@ -2182,7 +2182,7 @@ SPEC CHECKSUMS:
21822182
ReactCodegen: ee39bbc365b4791c9b5183b52c533ebf586e1d8d
21832183
ReactCommon: 4d01bfb533b93a2103329dfefc74db6a9e272888
21842184
ReactNativeDependencies: fa0a54b3f5319ae0e3b9aff32bfee7a424b88e66
2185-
ReactNativeEnrichedHtml: 2905798b4a734822d13c6b46f49ad69834358923
2185+
ReactNativeEnrichedHtml: c91b96b287fc5f413f1e2f066c9dba8dec5e9acf
21862186
Yoga: fe50ab299e578f397fef753cf309c6703a4db29b
21872187

21882188
PODFILE CHECKSUM: 88c10840d02e9884b2dc3f457d5120f83ac3803b

docs/src/examples/EmojiEditor.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export default function App() {
3232

3333
const suggestions = useMemo(() => {
3434
if (!open) return [];
35-
// A trailing ":" (as in ":smile:") is part of the query - drop it.
36-
const q = query.replace(/:$/, '').toLowerCase();
37-
return EMOJIS.filter(emoji => emoji.shortcode.startsWith(q));
35+
return EMOJIS.filter(emoji =>
36+
emoji.shortcode.startsWith(query.toLowerCase())
37+
);
3838
}, [open, query]);
3939

4040
const openPicker = () => {
@@ -50,6 +50,16 @@ export default function App() {
5050
const updateQuery = ({ text }: OnChangeMentionEvent) => {
5151
setOpen(true);
5252
setQuery(text);
53+
54+
if (text.endsWith(':')) {
55+
const strippedQuery = text.slice(0, text.length - 1).toLowerCase();
56+
const autoChosenEmoji = EMOJIS.find(
57+
emoji => emoji.shortcode === strippedQuery
58+
);
59+
if (autoChosenEmoji) {
60+
pick(autoChosenEmoji);
61+
}
62+
}
5363
};
5464

5565
const pick = (emoji: Emoji) => {
@@ -61,7 +71,7 @@ export default function App() {
6171
};
6272

6373
return (
64-
<View style={styles.container}>
74+
<View>
6575
<EnrichedTextInput
6676
ref={ref}
6777
style={styles.input}
@@ -102,16 +112,20 @@ const htmlStyle: HtmlStyle = {
102112
};
103113

104114
const styles = StyleSheet.create({
105-
container: { gap: 8 },
106115
input: {
107116
fontSize: 18,
108117
color: '#232736',
109118
padding: 12,
119+
marginBottom: 186,
110120
borderRadius: 12,
111121
minHeight: 96,
112122
backgroundColor: '#eef0ff',
113123
},
114124
picker: {
125+
position: 'absolute',
126+
top: '100%',
127+
marginTop: -170,
128+
width: '100%',
115129
borderWidth: 1,
116130
borderColor: '#dfe3f5',
117131
borderRadius: 12,

docs/src/examples/MentionOnlyEditor.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function App() {
7070
};
7171

7272
return (
73-
<View style={styles.container}>
73+
<View>
7474
<EnrichedTextInput
7575
ref={ref}
7676
style={styles.input}
@@ -118,16 +118,20 @@ const htmlStyle: HtmlStyle = {
118118
};
119119

120120
const styles = StyleSheet.create({
121-
container: { gap: 8 },
122121
input: {
123122
fontSize: 18,
124123
color: '#232736',
125124
padding: 12,
125+
marginBottom: 192,
126126
borderRadius: 12,
127127
minHeight: 96,
128128
backgroundColor: '#eef0ff',
129129
},
130130
picker: {
131+
position: 'absolute',
132+
top: '100%',
133+
marginTop: -176,
134+
width: '100%',
131135
borderWidth: 1,
132136
borderColor: '#dfe3f5',
133137
borderRadius: 12,

docs/src/examples/TextAlignmentEditor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export default function App() {
2020
<Pressable
2121
key={alignment}
2222
style={[styles.button, isActive && styles.buttonActive]}
23-
onPress={() => ref.current?.setTextAlignment(alignment)}>
23+
onPress={() => {
24+
const alignmentToSet = isActive ? 'auto' : alignment;
25+
ref.current?.setTextAlignment(alignmentToSet);
26+
}}>
2427
<Text style={[styles.text, isActive && styles.textActive]}>
2528
{alignment}
2629
</Text>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-enriched-html",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "HTML-based Rich Text solution for React Native",
55
"source": "./src/index.tsx",
66
"main": "./lib/module/index.js",

src/web/EnrichedText.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import { buildMentionRulesCSS } from './styleConversion/buildMentionRulesCSS';
1717
import { sanitizeHtml } from './sanitization/htmlSanitizer';
1818
import { prepareHtmlForWeb } from './normalization/prepareHtmlForWeb';
1919
import { INLINE_IMAGE_CSS_VARIABLES } from './styleConversion/inlineImageCSSVariables';
20-
import { useImageErrorFallback } from './useImageErrorFallback';
21-
import { usePressInteractions } from './usePressInteractions';
20+
import { useImageErrorFallback } from './htmlExtensions/useImageErrorFallback';
21+
import { usePressInteractions } from './htmlExtensions/usePressInteractions';
2222
import { useEllipsizeMode } from './ellipsizeMode/useEllipsizeMode';
23-
import { adaptWebToNativeEvent } from './adaptWebToNativeEvent';
24-
import { useStableRef } from './useStableRef';
25-
import { assertBrowserEnvironment } from './assertBrowserEnvironment';
26-
import { useOrderedListMarkerWidth } from './useOrderedListMarkerWidth';
23+
import { adaptWebToNativeEvent } from './nativeMappers/adaptWebToNativeEvent';
24+
import { useStableRef } from './utils/useStableRef';
25+
import { assertBrowserEnvironment } from './utils/assertBrowserEnvironment';
26+
import { useOrderedListMarkerWidth } from './htmlExtensions/useOrderedListMarkerWidth';
2727

2828
export const EnrichedText = memo(
2929
({

src/web/EnrichedTextInput.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import type {
1212
EnrichedTextInputInstance,
1313
EnrichedTextInputProps,
1414
} from '../types';
15-
import { adaptWebToNativeEvent } from './adaptWebToNativeEvent';
15+
import { adaptWebToNativeEvent } from './nativeMappers/adaptWebToNativeEvent';
1616
import {
1717
tiptapPosToNativePos,
1818
nativePosToTiptapPos,
1919
nativeLeafText,
20-
} from './positionMapping';
20+
} from './nativeMappers/positionMapping';
2121
import {
2222
useEditor,
2323
EditorContent,
@@ -29,11 +29,11 @@ import Paragraph from '@tiptap/extension-paragraph';
2929
import Text from '@tiptap/extension-text';
3030
import History from '@tiptap/extension-history';
3131
import { Placeholder } from '@tiptap/extensions/placeholder';
32-
import { useOnChangeHtml } from './useOnChangeHtml';
33-
import { useOnChangeText } from './useOnChangeText';
34-
import { useOnChangeState } from './useOnChangeState';
35-
import { useOnLinkDetected } from './useOnLinkDetected';
36-
import type { LinkEmitterState } from './emitLinkDetected';
32+
import { useOnChangeHtml } from './tiptapWatchers/useOnChangeHtml';
33+
import { useOnChangeText } from './tiptapWatchers/useOnChangeText';
34+
import { useOnChangeState } from './tiptapWatchers/useOnChangeState';
35+
import { useOnLinkDetected } from './tiptapWatchers/useOnLinkDetected';
36+
import type { LinkEmitterState } from './tiptapWatchers/emitLinkDetected';
3737
import {
3838
prepareHtmlForTiptap,
3939
normalizeHtmlFromTiptap,
@@ -68,7 +68,7 @@ import { StrictMarksPlugin } from './pmPlugins/StrictMarksPlugin';
6868
import { MergeAdjacentSameKindBlocksPlugin } from './pmPlugins/MergeAdjacentSameKindBlocksPlugin';
6969
import { OrderedListMarkerWidthPlugin } from './pmPlugins/OrderedListMarkerWidthPlugin';
7070
import { StripMarksInCodeBlockPlugin } from './pmPlugins/StripMarksInCodeBlockPlugin';
71-
import { handleClipboardPasteImages } from './pasteImages';
71+
import { handleClipboardPasteImages } from './utils/pasteImages';
7272
import {
7373
MentionPlugin,
7474
setMention,
@@ -78,15 +78,15 @@ import {
7878
import { StripMarksOnImagePlugin } from './pmPlugins/StripMarksOnImagePlugin';
7979
import { ShortcutPlugin } from './pmPlugins/ShortcutPlugin';
8080
import { TextShortcutsPlugin } from './pmPlugins/TextShortcutsPlugin';
81-
import { returnKeyTypeToEnterKeyHint } from './returnKeyTypeToEnterKeyHint';
81+
import { returnKeyTypeToEnterKeyHint } from './nativeMappers/returnKeyTypeToEnterKeyHint';
8282
import { ENRICHED_TEXT_INPUT_CLASSNAME } from './constants/classNames';
8383
import { AutolinkPlugin } from './pmPlugins/AutolinkPlugin';
84-
import { useStableRef } from './useStableRef';
84+
import { useStableRef } from './utils/useStableRef';
8585
import {
8686
checkMentionAttributes,
8787
sanitizeMentionAttributes,
8888
} from './sanitization/htmlSanitizer';
89-
import { assertBrowserEnvironment } from './assertBrowserEnvironment';
89+
import { assertBrowserEnvironment } from './utils/assertBrowserEnvironment';
9090

9191
function runFocused(
9292
editor: Editor,

src/web/__tests__/assertBrowserEnvironment.dom.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertBrowserEnvironment } from '../assertBrowserEnvironment';
1+
import { assertBrowserEnvironment } from '../utils/assertBrowserEnvironment';
22

33
describe('assertBrowserEnvironment', () => {
44
// jsdom provides a full DOM, so the browser APIs are present by default.

src/web/__tests__/assertBrowserEnvironment.ssr.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @jest-environment node
33
*/
44
// Because of the docblock above, jsdom test environment does not exist here
5-
import { assertBrowserEnvironment } from '../assertBrowserEnvironment';
5+
import { assertBrowserEnvironment } from '../utils/assertBrowserEnvironment';
66

77
describe('assertBrowserEnvironment', () => {
88
test('throws when DOM is missing', () => {

0 commit comments

Comments
 (0)