From c9178e2b0bb0e8bf34c54fb122df406256038ec2 Mon Sep 17 00:00:00 2001
From: Rajat Parashar <parasharrajat@users.noreply.github.com>
Date: Tue, 30 Nov 2021 21:11:13 +0530
Subject: [PATCH 1/2] Replace usages of clipboard module from RN-web to
 Clipboard lib

---
 package-lock.json                                       | 5 ++---
 package.json                                            | 2 +-
 src/components/CommunicationsLink.js                    | 2 +-
 src/components/CopyTextToClipboard.js                   | 2 +-
 src/libs/Clipboard/index.js                             | 4 ----
 src/libs/Clipboard/index.native.js                      | 3 ---
 src/pages/home/report/ContextMenu/ContextMenuActions.js | 2 +-
 7 files changed, 6 insertions(+), 14 deletions(-)
 delete mode 100644 src/libs/Clipboard/index.js
 delete mode 100644 src/libs/Clipboard/index.native.js

diff --git a/package-lock.json b/package-lock.json
index c8f2158bc8d3..286bd23b2c94 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6129,9 +6129,8 @@
       "integrity": "sha512-ael2f1onoPF3vF7YqHGWy7NnafzGu+yp88BbFbP0ydoCP2xGSUzmZVw0zakPTC040Id+JQ9WeFczujMkDy6jYQ=="
     },
     "@react-native-community/clipboard": {
-      "version": "1.5.1",
-      "resolved": "https://registry.npmjs.org/@react-native-community/clipboard/-/clipboard-1.5.1.tgz",
-      "integrity": "sha512-AHAmrkLEH5UtPaDiRqoULERHh3oNv7Dgs0bTC0hO5Z2GdNokAMPT5w8ci8aMcRemcwbtdHjxChgtjbeA38GBdA=="
+      "version": "git+https://github.com/Expensify/clipboard.git#6ffc501ef8689cbdb566506e1cfe0b4fdb7b80c8",
+      "from": "git+https://github.com/Expensify/clipboard.git#6ffc501ef8689cbdb566506e1cfe0b4fdb7b80c8"
     },
     "@react-native-community/datetimepicker": {
       "version": "3.5.2",
diff --git a/package.json b/package.json
index cc01313cda7d..c1ecad42e9db 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,7 @@
     "@onfido/react-native-sdk": "^1.3.3",
     "@react-native-async-storage/async-storage": "^1.15.5",
     "@react-native-community/cli": "4.13.1",
-    "@react-native-community/clipboard": "^1.5.1",
+    "@react-native-community/clipboard": "git+https://github.com/Expensify/clipboard.git#6ffc501ef8689cbdb566506e1cfe0b4fdb7b80c8",
     "@react-native-community/datetimepicker": "^3.5.2",
     "@react-native-community/netinfo": "^5.9.10",
     "@react-native-community/progress-bar-android": "^1.0.4",
diff --git a/src/components/CommunicationsLink.js b/src/components/CommunicationsLink.js
index e8f2de75259d..220142b80b2d 100644
--- a/src/components/CommunicationsLink.js
+++ b/src/components/CommunicationsLink.js
@@ -1,10 +1,10 @@
 import React from 'react';
 import {View, Pressable, Linking} from 'react-native';
 import PropTypes from 'prop-types';
+import Clipboard from '@react-native-community/clipboard';
 import styles from '../styles/styles';
 import compose from '../libs/compose';
 import * as Expensicons from './Icon/Expensicons';
-import Clipboard from '../libs/Clipboard';
 import ContextMenuItem from './ContextMenuItem';
 import withLocalize, {withLocalizePropTypes} from './withLocalize';
 import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';
diff --git a/src/components/CopyTextToClipboard.js b/src/components/CopyTextToClipboard.js
index b7c6b3a04d81..1733b524a94c 100644
--- a/src/components/CopyTextToClipboard.js
+++ b/src/components/CopyTextToClipboard.js
@@ -1,8 +1,8 @@
 import React from 'react';
 import PropTypes from 'prop-types';
+import Clipboard from '@react-native-community/clipboard';
 import Text from './Text';
 import * as Expensicons from './Icon/Expensicons';
-import Clipboard from '../libs/Clipboard';
 import Icon from './Icon';
 import styles from '../styles/styles';
 import themeColors from '../styles/themes/default';
diff --git a/src/libs/Clipboard/index.js b/src/libs/Clipboard/index.js
deleted file mode 100644
index 808e75b765ee..000000000000
--- a/src/libs/Clipboard/index.js
+++ /dev/null
@@ -1,4 +0,0 @@
-// on Web/desktop this import will be replaced with `react-native-web`
-import {Clipboard} from 'react-native-web';
-
-export default Clipboard;
diff --git a/src/libs/Clipboard/index.native.js b/src/libs/Clipboard/index.native.js
deleted file mode 100644
index db249165a421..000000000000
--- a/src/libs/Clipboard/index.native.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import Clipboard from '@react-native-community/clipboard';
-
-export default Clipboard;
diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js
index b1359504180d..61da8317660d 100644
--- a/src/pages/home/report/ContextMenu/ContextMenuActions.js
+++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js
@@ -1,9 +1,9 @@
 import _ from 'underscore';
 import lodashGet from 'lodash/get';
 import Str from 'expensify-common/lib/str';
+import Clipboard from '@react-native-community/clipboard';
 import * as Expensicons from '../../../../components/Icon/Expensicons';
 import * as Report from '../../../../libs/actions/Report';
-import Clipboard from '../../../../libs/Clipboard';
 import * as ReportUtils from '../../../../libs/reportUtils';
 import ReportActionComposeFocusManager from '../../../../libs/ReportActionComposeFocusManager';
 import {hideContextMenu, showDeleteModal} from './ReportActionContextMenu';

From f9e8a592cb7845101631d48d2380bc77bb9d65f0 Mon Sep 17 00:00:00 2001
From: Rajat Parashar <parasharrajat@users.noreply.github.com>
Date: Tue, 30 Nov 2021 21:16:47 +0530
Subject: [PATCH 2/2] Copy Markdown support

---
 src/pages/home/report/ContextMenu/ContextMenuActions.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js
index 61da8317660d..de818fbc92b0 100644
--- a/src/pages/home/report/ContextMenu/ContextMenuActions.js
+++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js
@@ -54,9 +54,9 @@ export default [
                 ? reportAction.isAttachment
                 : ReportUtils.isReportMessageAttachment(text);
             if (!isAttachment) {
-                Clipboard.setString(text);
+                Clipboard.setHTML(html, text);
             } else {
-                Clipboard.setString(html);
+                Clipboard.setString(text);
             }
             if (closePopover) {
                 hideContextMenu(true, ReportActionComposeFocusManager.focus);
