mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 17:45:59 +00:00
dc3fce06ea
Summary: Add "Copy" and "Dismiss" button when the RN Android redbox is shown, consistent with that in RN iOS. - "Copy" button copies all the messages shown in the redbox to the host system clipboard, the solution is posting redbox messages to packager and the the packager copies the messages onto the host clipboard. - "Dismiss" button always exits the redbox dialog. - Add shortcut as "Dismiss (ESC)" and "Reload (R, R). Notice: Copy button is only supported on Mac OS by now (warning in packager on other platforms), because it's not easy for us to test on Windows or Linux. Will put the codes for other platforms on Github issues, hoping anyone could help test and add this feature, then send us a pull request. Redbox Dialog in RN Android before: {F61310489} Redbox Dialog in RN Android now: {F61659189} Follow-up: - We can adjust the button styles in redboxes. - We can consider to add shortcut for "Copy" button. Reviewed By: foghina Differential Revision: D3392155 fbshipit-source-id: fc5dc2186718cac8706fb3c17d336160e61e3f4e
29 lines
822 B
JavaScript
29 lines
822 B
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
'use strict';
|
|
|
|
const copyToClipBoard = require('../util/copyToClipBoard');
|
|
var chalk = require('chalk');
|
|
|
|
/**
|
|
* Handle the request from JS to copy contents onto host system clipboard.
|
|
* This is only supported on Mac for now.
|
|
*/
|
|
module.exports = function(req, res, next) {
|
|
if (req.url === '/copy-to-clipboard') {
|
|
var ret = copyToClipBoard(req.rawBody);
|
|
if (!ret) {
|
|
console.warn(chalk.red('Copy button is not supported on this platform!'));
|
|
}
|
|
res.end('OK');
|
|
} else {
|
|
next();
|
|
}
|
|
};
|