Socket
Socket
Sign inDemoInstall

react-highlight-words

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-highlight-words - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

29

dist/main.js

@@ -99,2 +99,3 @@ module.exports =

className: _propTypes2['default'].string,
findChunks: _propTypes2['default'].func,
highlightClassName: _propTypes2['default'].string,

@@ -125,2 +126,3 @@ highlightStyle: _propTypes2['default'].object,

var className = _ref.className;
var findChunks = _ref.findChunks;
var _ref$highlightClassName = _ref.highlightClassName;

@@ -142,2 +144,3 @@ var highlightClassName = _ref$highlightClassName === undefined ? '' : _ref$highlightClassName;

caseSensitive: caseSensitive,
findChunks: findChunks,
sanitize: sanitize,

@@ -300,2 +303,4 @@ searchWords: searchWords,

caseSensitive = _ref$caseSensitive === undefined ? false : _ref$caseSensitive,
_ref$findChunks = _ref.findChunks,
findChunks = _ref$findChunks === undefined ? defaultFindChunks : _ref$findChunks,
sanitize = _ref.sanitize,

@@ -314,3 +319,3 @@ searchWords = _ref.searchWords,

}),
totalLength: textToHighlight.length
totalLength: textToHighlight ? textToHighlight.length : 0
});

@@ -355,3 +360,3 @@ };

*/
var findChunks = exports.findChunks = function findChunks(_ref3) {
var defaultFindChunks = function defaultFindChunks(_ref3) {
var autoEscape = _ref3.autoEscape,

@@ -380,6 +385,14 @@ caseSensitive = _ref3.caseSensitive,

while (match = regex.exec(textToHighlight)) {
chunks.push({
start: match.index,
end: regex.lastIndex
});
var start = match.index;
var end = regex.lastIndex;
// We do not return zero-length matches
if (end > start) {
chunks.push({ start: start, end: end });
}
// Prevent browsers like Firefox from getting stuck in an infinite loop
// See http://www.regexguru.com/2008/04/watch-out-for-zero-length-matches/
if (match.index == regex.lastIndex) {
regex.lastIndex++;
}
}

@@ -390,2 +403,5 @@

};
// Allow the findChunks to be overridden in findAll,
// but for backwards compatibility we export as the old name
exports.findChunks = defaultFindChunks;

@@ -399,2 +415,3 @@ /**

*/
var fillInChunks = exports.fillInChunks = function fillInChunks(_ref4) {

@@ -401,0 +418,0 @@ var chunksToHighlight = _ref4.chunksToHighlight,

{
"name": "react-highlight-words",
"version": "0.10.0",
"version": "0.11.0",
"description": "React component to highlight words within a larger body of text",

@@ -8,4 +8,4 @@ "main": "dist/main.js",

"build": "npm run build:website && npm run build:dist",
"build:website": "npm run clean:website && NODE_ENV=production webpack --config webpack.config.website.js -p --bail",
"build:dist": "npm run clean:dist && NODE_ENV=production webpack --config webpack.config.dist.js --bail",
"build:website": "npm run clean:website && cross-env NODE_ENV=production webpack --config webpack.config.website.js -p --bail",
"build:dist": "npm run clean:dist && cross-env NODE_ENV=production webpack --config webpack.config.dist.js --bail",
"clean": "npm run clean:website && npm run clean:dist",

@@ -20,3 +20,3 @@ "clean:website": "rimraf build",

"start": "webpack-dev-server --hot --inline --config webpack.config.dev.js",
"test": "NODE_ENV=test karma start",
"test": "cross-env NODE_ENV=test karma start",
"watch": "watch 'clear && npm run lint -s && npm run test -s' src"

@@ -70,2 +70,3 @@ },

"babel-plugin-react-transform": "^1.1.1",
"cross-env": "^5.1.3",
"css-loader": "^0.23.0",

@@ -101,3 +102,3 @@ "cssnext": "^1.8.4",

"dependencies": {
"highlight-words-core": "^1.1.0",
"highlight-words-core": "^1.2.0",
"prop-types": "^15.5.8"

@@ -104,0 +105,0 @@ },

@@ -15,2 +15,3 @@ <img src="https://cloud.githubusercontent.com/assets/29597/11913937/0d2dcd78-a629-11e5-83e7-6a17b6d765a5.png" width="260" height="260">

searchWords={['and', 'or', 'the']}
autoEscape={true}
textToHighlight="The dog is chasing the cat. Or perhaps they're just playing?"

@@ -31,5 +32,6 @@ />

| activeStyle | Object | | The inline style to be applied to an active match. Use along with `activeIndex` |
| autoEscape | Boolean | | Escape characters which are meaningful in regular expressions |
| autoEscape | Boolean | | Escape characters in `searchWords` which are meaningful in regular expressions |
| className | String | | CSS class name applied to the outer/wrapper `<span>` |
| caseSensitive | Boolean | | Search should be case sensitive; defaults to `false` |
| findChunks | Function | | Use a custom function to search for matching chunks. This makes it possible to use arbitrary logic when looking for matches; see the default `findChunks` function in [highlight-words-core](https://github.com/bvaughn/highlight-words-core) for signature |
| highlightClassName | String | | CSS class name applied to highlighted text |

@@ -39,3 +41,3 @@ | highlightStyle | Object | | Inline styles applied to highlighted text |

| sanitize | Function | | Process each search word and text to highlight before comparing (eg remove accents); signature `(text: string): string` |
| searchWords | Array<String> | ✓ | Array of search words |
| searchWords | Array<String> | ✓ | Array of search words. The search terms are treated as RegExps unless `autoEscape` is set. |
| textToHighlight | String | ✓ | Text to highlight matches in |

@@ -42,0 +44,0 @@ | unhighlightClassName | String | | CSS class name applied to unhighlighted text |

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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