react-obfuscate
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -6,7 +6,7 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports["default"] = void 0; | ||
var _react = _interopRequireWildcard(require("react")); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } | ||
@@ -136,5 +136,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
obfuscate = _this$props.obfuscate, | ||
obfuscateChildren = _this$props.obfuscateChildren, | ||
linkText = _this$props.linkText, | ||
style = _this$props.style, | ||
others = _objectWithoutProperties(_this$props, ["element", "children", "tel", "sms", "facetime", "email", "href", "headers", "obfuscate", "linkText", "style"]); | ||
others = _objectWithoutProperties(_this$props, ["element", "children", "tel", "sms", "facetime", "email", "href", "headers", "obfuscate", "obfuscateChildren", "linkText", "style"]); | ||
@@ -145,6 +146,6 @@ var propsList = children || tel || sms || facetime || email || href; | ||
unicodeBidi: 'bidi-override', | ||
direction: humanInteraction === true || obfuscate === false ? 'ltr' : 'rtl' | ||
direction: humanInteraction === true || obfuscate === false || obfuscateChildren === false ? 'ltr' : 'rtl' | ||
}); | ||
var link = humanInteraction === true || obfuscate === false || _typeof(children) === 'object' // Allow child elements | ||
var link = humanInteraction === true || obfuscate === false || _typeof(children) === 'object' || obfuscateChildren === false // Allow child elements | ||
? propsList : this.reverse(propsList); | ||
@@ -164,3 +165,3 @@ var clickProps = Element === 'a' ? { | ||
return _react.default.createElement(Element, props, link); | ||
return _react["default"].createElement(Element, props, link); | ||
} | ||
@@ -172,2 +173,2 @@ }]); | ||
exports.default = Obfuscate; | ||
exports["default"] = Obfuscate; |
{ | ||
"name": "react-obfuscate", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"description": "An intelligent React component to obfuscate any contact link", | ||
@@ -9,3 +9,3 @@ "main": "dist/obfuscate.js", | ||
], | ||
"author": "Coston Perkins <coston.perkins@ua.edu> (https://coston.io)", | ||
"author": "Coston Perkins <costonperkins@me.com> (https://coston.io)", | ||
"homepage": "https://github.com/coston/react-obfuscate", | ||
@@ -24,3 +24,3 @@ "repository": { | ||
"scripts": { | ||
"dev": "next", | ||
"start": "next", | ||
"build": "babel -d dist src", | ||
@@ -31,3 +31,2 @@ "build-site": "next build", | ||
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"", | ||
"start": "next start", | ||
"test": "jest", | ||
@@ -34,0 +33,0 @@ "test:watch": "jest --watch", |
@@ -33,4 +33,4 @@ # react-obfuscate | ||
```js | ||
import React from 'react' | ||
import Obfuscate from 'react-obfuscate' | ||
import React from "react"; | ||
import Obfuscate from "react-obfuscate"; | ||
@@ -41,14 +41,14 @@ export default () => ( | ||
<br /> | ||
Email:{' '} | ||
Email:{" "} | ||
<Obfuscate | ||
email="coston.perkins@ua.edu" | ||
email="hello@coston.io" | ||
headers={{ | ||
cc: 'dade@zero-cool.af', | ||
bcc: 'smith@machina.net', | ||
subject: 'react-obfuscate', | ||
body: 'Down with the machines!' | ||
cc: "dade@zero-cool.af", | ||
bcc: "smith@machina.net", | ||
subject: "react-obfuscate", | ||
body: "Down with the machines!" | ||
}} | ||
/> | ||
</p> | ||
) | ||
); | ||
``` | ||
@@ -62,4 +62,10 @@ | ||
<p> | ||
Phone: <a href="obfuscated" style="direction: rtl; unicode-bidi: bidi-override;">4321-454-502</a><br> | ||
Email: <a href="obfuscated" style="direction: rtl; unicode-bidi: bidi-override;">looc.notsoc@olleh</a> | ||
Phone: | ||
<a href="obfuscated" style="direction: rtl; unicode-bidi: bidi-override;" | ||
>4321-454-502</a | ||
><br /> | ||
Email: | ||
<a href="obfuscated" style="direction: rtl; unicode-bidi: bidi-override;" | ||
>oi.notsoc@olleh</a | ||
> | ||
</p> | ||
@@ -73,3 +79,3 @@ ``` | ||
Phone: <a href="tel:205-454-1234">205-454-1234</a><br> | ||
Email: <a href="mailto:hello@coston.cool&subject=Question%20from%20the%20website&cc=friend@coston.cool">hello@coston.cool</a> | ||
Email: <a href="mailto:hello@coston.io?cc=kate%40acidburn.af&bcc=tanderson%40metacortex.net&subject=react-obfuscate&body=Down%20with%20the%20machines!">hello@coston.io</a> | ||
</p> | ||
@@ -91,17 +97,18 @@ ``` | ||
| Prop | Type | Argument | Default | Description | | ||
| --------- | ---------- | ---------- | ------------ | -------------------------------------------------------------- | | ||
| linkText | `string` | `optional` | `obfuscated` | add custom pre-interaction href attribute placeholder text | | ||
| obfuscate | `boolean` | `optional` | `true` | set to false to disable obfuscation | | ||
| element | `string` | `optional` | `'a'` | use if you want to override the default `a` tag | | ||
| onClick | `function` | `optional` | `null` | called prior to setting location (e.g. for analytics tracking) | | ||
| Prop | Type | Argument | Default | Description | | ||
| ----------------- | ---------- | ---------- | ------------ | -------------------------------------------------------------- | | ||
| linkText | `string` | `optional` | `obfuscated` | add custom pre-interaction href attribute placeholder text | | ||
| obfuscate | `boolean` | `optional` | `true` | set to false to disable obfuscation | | ||
| obfuscateChildren | `boolean` | `optional` | `true` | set to false to disable obfuscation of children | | ||
| element | `string` | `optional` | `'a'` | use if you want to override the default `a` tag | | ||
| onClick | `function` | `optional` | `null` | called prior to setting location (e.g. for analytics tracking) | | ||
## Development | ||
```bash | ||
npm run dev | ||
npm start | ||
``` | ||
## Consecutive Obfuscate/inline elements | ||
react-obfuscate is an inline element. Using consecutive inline elements inside a block element causes an issue with the `bidi-override` reversal on Chrome. To prevent this, | ||
@@ -111,7 +118,8 @@ add any text between the elements, wrap `<Obfuscate/>` with another element (like `<span>`), or add `style={{display:'inline-block'}}` to prevent any issues. | ||
Example Case: | ||
```js | ||
<address> | ||
<Obfuscate style={{display:'inline-block'}} email="-mail@mailbox.org" /> | ||
<br /> | ||
<Obfuscate style={{display:'inline-block'}} tel="+69 111 222 333" /> | ||
<Obfuscate style={{ display: "inline-block" }} email="-mail@mailbox.org" /> | ||
<br /> | ||
<Obfuscate style={{ display: "inline-block" }} tel="+69 111 222 333" /> | ||
</address> | ||
@@ -121,9 +129,9 @@ ``` | ||
## Obfuscating custom elements with the `element` prop | ||
With the `element` prop, users can obfuscate any element, like paragraphs or headers. Changing the dom element also removes the href and onClick props. Custom styling is required due to handling of right-to-left direction styles. Usually, adding `style={{textAlign:'left'}}` will suffice. | ||
Example Case: | ||
```js | ||
<Obfuscate | ||
element='p' | ||
style={{textAlign:'left'}}> | ||
<Obfuscate element="p" style={{ textAlign: "left" }}> | ||
This paragraph is more secret than others. | ||
@@ -137,10 +145,9 @@ </Obfuscate> | ||
* [coston](https://github.com/coston) | ||
* [bostrom](https://github.com/bostrom) | ||
* [timmygee](https://github.com/timmygee) | ||
* [mic](https://github.com/mic) | ||
* [ravinggenius](https://github.com/ravinggenius) | ||
* [charlesbdudley](https://github.com/charlesbdudley) | ||
- [coston](https://github.com/coston) | ||
- [bostrom](https://github.com/bostrom) | ||
- [timmygee](https://github.com/timmygee) | ||
- [mic](https://github.com/mic) | ||
- [ravinggenius](https://github.com/ravinggenius) | ||
- [charlesbdudley](https://github.com/charlesbdudley) | ||
## Contributing | ||
@@ -147,0 +154,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17661
138
152