-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Copy and Dismiss Button in RN Android Red Box
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
- Loading branch information
Siqi Liu
authored and
Facebook Github Bot 5
committed
Jun 30, 2016
1 parent
ca0c6db
commit dc3fce0
Showing
10 changed files
with
229 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* 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(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
dc3fce0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, well done!