Skip to content

Commit

Permalink
Merge pull request #44958 from software-mansion-labs/@Skalakid/bump-r…
Browse files Browse the repository at this point in the history
…eact-native-live-markdown

Bump react-native-live-markdown
  • Loading branch information
mountiny committed Jul 11, 2024
2 parents cbd7d39 + d860cbe commit 9025880
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 33 deletions.
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ PODS:
- RNGoogleSignin (10.0.1):
- GoogleSignIn (~> 7.0)
- React-Core
- RNLiveMarkdown (0.1.91):
- RNLiveMarkdown (0.1.103):
- glog
- hermes-engine
- RCT-Folly (= 2022.05.16.00)
Expand All @@ -1889,9 +1889,9 @@ PODS:
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNLiveMarkdown/common (= 0.1.91)
- RNLiveMarkdown/common (= 0.1.103)
- Yoga
- RNLiveMarkdown/common (0.1.91):
- RNLiveMarkdown/common (0.1.103):
- glog
- hermes-engine
- RCT-Folly (= 2022.05.16.00)
Expand Down Expand Up @@ -2614,7 +2614,7 @@ SPEC CHECKSUMS:
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
RNGestureHandler: 74b7b3d06d667ba0bbf41da7718f2607ae0dfe8f
RNGoogleSignin: ccaa4a81582cf713eea562c5dd9dc1961a715fd0
RNLiveMarkdown: 24fbb7370eefee2f325fb64cfe904b111ffcd81b
RNLiveMarkdown: f12157fc91b72e19705c9cc8c98034c4c1669d5a
RNLocalize: d4b8af4e442d4bcca54e68fc687a2129b4d71a81
rnmapbox-maps: df8fe93dbd251f25022f4023d31bc04160d4d65c
RNPermissions: 0b61d30d21acbeafe25baaa47d9bae40a0c65216
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@dotlottie/react-player": "^1.6.3",
"@expensify/react-native-live-markdown": "0.1.91",
"@expensify/react-native-live-markdown": "0.1.103",
"@expo/metro-runtime": "~3.1.1",
"@formatjs/intl-datetimeformat": "^6.10.0",
"@formatjs/intl-listformat": "^7.2.2",
Expand Down Expand Up @@ -109,7 +109,7 @@
"date-fns-tz": "^2.0.0",
"dom-serializer": "^0.2.2",
"domhandler": "^4.3.0",
"expensify-common": "2.0.26",
"expensify-common": "2.0.35",
"expo": "^50.0.3",
"expo-av": "~13.10.4",
"expo-image": "1.11.0",
Expand Down
13 changes: 0 additions & 13 deletions patches/@expensify+react-native-live-markdown+0.1.91.patch

This file was deleted.

15 changes: 9 additions & 6 deletions src/hooks/useHtmlPaste/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useNavigation} from '@react-navigation/native';
import {useCallback, useEffect} from 'react';
import type {ClipboardEvent as PasteEvent} from 'react';
import Parser from '@libs/Parser';
import type UseHtmlPaste from './types';

Expand All @@ -20,8 +21,10 @@ const insertAtCaret = (target: HTMLElement, text: string) => {
range.setEnd(node, node.length);
selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);

// Dispatch paste event to simulate real browser behavior
target.dispatchEvent(new Event('paste', {bubbles: true}));
// Dispatch paste event to make Markdown Input properly set cursor position
const pasteEvent = new ClipboardEvent('paste', {bubbles: true, cancelable: true});
(pasteEvent as unknown as PasteEvent<HTMLElement>).isDefaultPrevented = () => false;
target.dispatchEvent(pasteEvent);
// Dispatch input event to trigger Markdown Input to parse the new text
target.dispatchEvent(new Event('input', {bubbles: true}));
} else {
Expand Down Expand Up @@ -142,18 +145,18 @@ const useHtmlPaste: UseHtmlPaste = (textInputRef, preHtmlPasteCallback, removeLi
let unsubscribeFocus: () => void;
let unsubscribeBlur: () => void;
if (removeListenerOnScreenBlur) {
unsubscribeFocus = navigation.addListener('focus', () => document.addEventListener('paste', handlePaste));
unsubscribeBlur = navigation.addListener('blur', () => document.removeEventListener('paste', handlePaste));
unsubscribeFocus = navigation.addListener('focus', () => document.addEventListener('paste', handlePaste, true));
unsubscribeBlur = navigation.addListener('blur', () => document.removeEventListener('paste', handlePaste, true));
}

document.addEventListener('paste', handlePaste);
document.addEventListener('paste', handlePaste, true);

return () => {
if (removeListenerOnScreenBlur) {
unsubscribeFocus();
unsubscribeBlur();
}
document.removeEventListener('paste', handlePaste);
document.removeEventListener('paste', handlePaste, true);
};
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);
Expand Down

0 comments on commit 9025880

Please sign in to comment.