diff --git a/README.md b/README.md
index f32878b0..a7acd24d 100644
--- a/README.md
+++ b/README.md
@@ -102,7 +102,7 @@ import {
| | Required props | Optional props |
| ---------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| **All** | **`children`** (string/element): React node
**`url`** (string): URL of the shared page | **`disabled`** (bool): Disables click action and adds "disabled" class
**`disabledStyle`** (object, default=`{ opacity: 0.6 }`): Disabled style
**`windowWidth`, `windowHeight`** (number, different default for all share buttons): opened window dimensions
**`beforeOnClick`** (`() => Promise`/`() => void`): Takes a function that returns a Promise to be fulfilled before calling `onClick`. If you do not return promise, `onClick` is called immediately.
**`openShareDialogOnClick`** (boolean): Open dialog on click. Defaults to `true` except on EmailShareButton
**`onShareWindowClose`** (`() => void`): Takes a function to be called after closing share dialog.
**`resetButtonStyle`** (boolean, default=`true`): Reset `button` element style. Preferred to be set to `false` if you want to customize the button style. |
+| **All** | **`children`** (string/element): React node
**`url`** (string): URL of the shared page | **`disabled`** (bool): Disables click action and adds "disabled" class
**`disabledStyle`** (object, default=`{ opacity: 0.6 }`): Disabled style
**`windowWidth`, `windowHeight`** (number, different default for all share buttons): opened window dimensions
**`beforeOnClick`** (`() => Promise`/`() => void`): Takes a function that returns a Promise to be fulfilled before calling `onClick`. If you do not return promise, `onClick` is called immediately.
**`openShareDialogOnClick`** (boolean): Open dialog on click. Defaults to `true` except on EmailShareButton
**`onShareWindowClose`** (`() => void`): Takes a function to be called after closing share dialog.
**`resetButtonStyle`** (boolean, default=`true`): Reset `button` element style. Preferred to be set to `false` if you want to customize the button style.
**`hasBlankTarget`** (boolean, default=`false`): Open up share window in a new tab if set to `true`. |
| EmailShareButton | - | **`subject`** (string): Title of the shared page
**`body`** (string): Email, will be prepended to the url.
**`separator`** (string, default=`" "`): Separates body from the url |
| FacebookShareButton | - | **`quote`** (string): A quote to be shared along with the link.
**`hashtag`** (string): A hashtag specified by the developer to be added to the shared content. People will still have the opportunity to remove this hashtag in the dialog. The hashtag should include the hash symbol. |
| FacebookMessengerShareButton | **`appId`** (string): Facebook application id | **`redirectUri`** (string): The URL to redirect to after sharing (default: the shared url).
**`to`** (string): A user ID of a recipient. Once the dialog comes up, the sender can specify additional people as recipients. |
diff --git a/src/ShareButton.tsx b/src/ShareButton.tsx
index fbc8de2c..098aa84e 100644
--- a/src/ShareButton.tsx
+++ b/src/ShareButton.tsx
@@ -21,6 +21,7 @@ const getBoxPositionOnScreenCenter = (width: number, height: number) => ({
function windowOpen(
url: string,
{ height, width, ...configRest }: { height: number; width: number; [key: string]: any },
+ hasBlankTarget: boolean,
onClose?: (dialog: Window | null) => void,
) {
const config: { [key: string]: string | number } = {
@@ -38,13 +39,18 @@ function windowOpen(
...configRest,
};
- const shareDialog = window.open(
- url,
- '',
- Object.keys(config)
- .map(key => `${key}=${config[key]}`)
- .join(', '),
- );
+ let shareDialog: Window;
+ if (hasBlankTarget) {
+ shareDialog = window.open(url, '_blank') as Window;
+ } else {
+ shareDialog = window.open(
+ url,
+ '',
+ Object.keys(config)
+ .map(key => `${key}=${config[key]}`)
+ .join(', '),
+ ) as Window;
+ }
if (onClose) {
const interval = window.setInterval(() => {
@@ -98,6 +104,7 @@ interface CustomProps {
*/
onShareWindowClose?: () => void;
resetButtonStyle?: boolean;
+ hasBlankTarget?: boolean;
}
export type Props = Omit<
@@ -119,6 +126,7 @@ export default class ShareButton extends Component extends Component) => {
@@ -187,6 +195,7 @@ export default class ShareButton extends Component