Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-anchorify-text

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-anchorify-text - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

3

CHANGELOG.md
## Change Log
### Ver 2.3.0
* Update `Babel` from 6.x to 7.x.
### Ver 2.2.0

@@ -4,0 +7,0 @@ * Update `React` from 15.x to 16.x.

13

karma.conf.js

@@ -38,5 +38,12 @@ // Karma configuration

['babelify', {
presets : [
'env',
'react'
presets: [
['@babel/env',{ 'useBuiltIns': 'usage'}],
'@babel/react'
],
plugins: [
['@babel/plugin-proposal-decorators', { 'legacy': true }],
'@babel/plugin-proposal-function-sent',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-throw-expressions'
]

@@ -43,0 +50,0 @@ }

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,30 +6,51 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
require("core-js/modules/es7.symbol.async-iterator");
var _react = require('react');
require("core-js/modules/es6.symbol");
var _react2 = _interopRequireDefault(_react);
require("core-js/modules/es6.object.define-property");
var _propTypes = require('prop-types');
require("core-js/modules/es6.object.create");
var _propTypes2 = _interopRequireDefault(_propTypes);
require("core-js/modules/es6.object.set-prototype-of");
var _linkifyIt = require('linkify-it');
require("core-js/modules/web.dom.iterable");
var _linkifyIt2 = _interopRequireDefault(_linkifyIt);
require("core-js/modules/es6.array.for-each");
var _tlds = require('tlds');
require("core-js/modules/es6.regexp.match");
var _tlds2 = _interopRequireDefault(_tlds);
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _linkifyIt = _interopRequireDefault(require("linkify-it"));
var _tlds = _interopRequireDefault(require("tlds"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var AnchorifyText = function (_React$Component) {
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var AnchorifyText =
/*#__PURE__*/
function (_React$Component) {
_inherits(AnchorifyText, _React$Component);

@@ -40,24 +61,22 @@

return _possibleConstructorReturn(this, (AnchorifyText.__proto__ || Object.getPrototypeOf(AnchorifyText)).call(this, props));
return _possibleConstructorReturn(this, _getPrototypeOf(AnchorifyText).call(this, props));
}
_createClass(AnchorifyText, [{
key: 'render',
key: "render",
value: function render() {
var content = this.anchorify(this.props.text);
return _react2.default.createElement(
'span',
null,
content
);
return _react.default.createElement("span", null, content);
}
}, {
key: 'anchorify',
key: "anchorify",
value: function anchorify(text) {
var _this2 = this;
var _this = this;
var matches = this.props.linkify.match(text);
if (matches === null) {
return text;
}
var last = 0;

@@ -68,27 +87,32 @@ var result = [];

var keyMatch = 'anchorify-text-match' + i;
if (last < match.index) {
result.push(_react2.default.createElement(
'span',
{ key: keyBefore },
text.slice(last, match.index)
));
result.push(_react.default.createElement("span", {
key: keyBefore
}, text.slice(last, match.index)));
}
if (_react2.default.Children.count(_this2.props.children) === 1) {
result.push(_react2.default.cloneElement(_this2.props.children, { url: match.url, key: keyMatch, match: match }));
if (_react.default.Children.count(_this.props.children) === 1) {
result.push(_react.default.cloneElement(_this.props.children, {
url: match.url,
key: keyMatch,
match: match
}));
} else {
result.push(_react2.default.createElement(
'a',
{ key: keyMatch, href: match.url, target: _this2.props.target },
match.raw
));
result.push(_react.default.createElement("a", {
key: keyMatch,
href: match.url,
target: _this.props.target
}, match.raw));
}
last = match.lastIndex;
});
if (last < text.length) {
result.push(_react2.default.createElement(
'span',
{ key: 'anchorify-text-last' },
text.slice(last)
));
result.push(_react.default.createElement("span", {
key: 'anchorify-text-last'
}, text.slice(last)));
}
return result;

@@ -99,15 +123,14 @@ }

return AnchorifyText;
}(_react2.default.Component);
}(_react.default.Component);
AnchorifyText.propTypes = {
text: _propTypes2.default.string.isRequired,
linkify: _propTypes2.default.object,
target: _propTypes2.default.string
text: _propTypes.default.string.isRequired,
linkify: _propTypes.default.object,
target: _propTypes.default.string
};
AnchorifyText.defaultProps = {
linkify: new _linkifyIt2.default().tlds(_tlds2.default),
linkify: new _linkifyIt.default().tlds(_tlds.default),
target: '_blank'
};
exports.default = AnchorifyText;
var _default = AnchorifyText;
exports.default = _default;

@@ -1,13 +0,15 @@

'use strict';
"use strict";
require("core-js/modules/es6.object.define-property");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _AnchorifyText = require('./components/AnchorifyText');
var _AnchorifyText = _interopRequireDefault(require("./components/AnchorifyText"));
var _AnchorifyText2 = _interopRequireDefault(_AnchorifyText);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _AnchorifyText2.default;
var _default = _AnchorifyText.default;
exports.default = _default;
{
"name": "react-anchorify-text",
"version": "2.2.0",
"version": "2.3.0",
"description": "React component which render text with anchored url(s)",

@@ -33,37 +33,42 @@ "main": "lib/index.js",

"devDependencies": {
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-eslint": "^8.0.2",
"babel-preset-react": "^6.3.13",
"babelify": "^8.0.0",
"browser-sync": "^2.9.12",
"browserify": "^14.4.0",
"chai": "^4.0.1",
"eslint": "^4.12.1",
"eslint-plugin-react": "^7.0.1",
"karma": "^1.7.0",
"karma-browserify": "^5.1.1",
"@babel/cli": "^7.1.0",
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.1.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^9.0.0",
"babelify": "^10.0.0",
"browser-sync": "^2.24.7",
"browserify": "^16.2.2",
"chai": "^4.1.2",
"eslint": "^5.6.0",
"eslint-plugin-react": "^7.11.1",
"karma": "^3.0.0",
"karma-browserify": "^5.3.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.1.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "1.0.1",
"karma-firefox-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.1.0",
"karma-mocha": "^1.3.0",
"karma-safari-launcher": "^1.0.0",
"karma-spec-reporter": "0.0.31",
"mocha": "^4.0.1",
"react": "^16.2.0",
"react-addons-test-utils": "^15.5.1",
"react-dom": "^16.2.0",
"rimraf": "^2.5.0",
"watchify": "^3.6.0"
"karma-spec-reporter": "0.0.32",
"mocha": "^5.2.0",
"react": "^16.5.2",
"react-addons-test-utils": "^15.6.2",
"react-dom": "^16.5.2",
"rimraf": "^2.6.2",
"watchify": "^3.11.0"
},
"dependencies": {
"babel-preset-env": "^1.6.1",
"linkify-it": "^2.0.0",
"prop-types": "^15.5.10",
"tlds": "^1.145.0"
"linkify-it": "^2.0.3",
"prop-types": "^15.6.2",
"tlds": "^1.203.1"
},
"peerDependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0"
"react": "^16.5.2",
"react-dom": "^16.5.2"
},

@@ -77,4 +82,11 @@ "browserify": {

"presets": [
"env",
"react"
["@babel/env",{ "useBuiltIns": "usage"}],
"@babel/react"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
]

@@ -81,0 +93,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc