@perlego-oss/text-highlighter
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -75,2 +75,3 @@ "use strict"; | ||
* @param {string} options.namespaceDataAttribute - Data attribute to identify highlights that belong to a particular highlight instance. | ||
* @param {boolean} options.highlightWhiteSpaceChars - Whether or not to deserialise highlights into the DOM when they only contain white space characters. | ||
* @param {Record<string, number>} options.priorities - Defines priorities for multiple highlighters, the keys | ||
@@ -125,5 +126,2 @@ * are the namespaces for highlighters and the values are the priorities | ||
console.log({ | ||
rangeRelativeToRootElement: rangeRelativeToRootElement | ||
}); | ||
var eventItems = []; | ||
@@ -339,2 +337,3 @@ (0, _dom["default"])(this.el).turnOffEventHandlers(eventItems); | ||
highlight; | ||
var highlightWhiteSpaceChars = self.options.highlightWhiteSpaceChars; | ||
var parentNode = self.el; | ||
@@ -359,3 +358,3 @@ | ||
if (visibleTextContent.length > 0) { | ||
if (visibleTextContent.length > 0 || highlightWhiteSpaceChars && node.textContent.length > 0) { | ||
hlNode = node.splitText(offsetWithinNode); | ||
@@ -362,0 +361,0 @@ hlNode.splitText(lengthInNode); |
@@ -104,2 +104,3 @@ "use strict"; | ||
* @param {boolean} [options.keepRange=false] - Whether or not to keep the highlight selection after highlights are created. If set to true then the selection will stay active. | ||
* @param {boolean} [options.highlightWhiteSpaceChars=false] - Whether or not to deserialise highlights into the DOM when they only contain white space characters. | ||
* @param {function} options.onRemoveHighlight - function called before highlight is removed. Highlight is | ||
@@ -146,2 +147,3 @@ * passed as param. Function should return true if highlight should be removed, or false - to prevent removal. | ||
keepRange: false, | ||
highlightWhiteSpaceChars: false, | ||
cancelProperty: "cancel", | ||
@@ -148,0 +150,0 @@ onRemoveHighlight: function onRemoveHighlight() { |
@@ -407,5 +407,2 @@ "use strict"; | ||
var currentNode = startNodeOrContainer.nextSibling; | ||
console.log({ | ||
currentNodeBeforeWhile: currentNode | ||
}); | ||
@@ -857,5 +854,2 @@ while (currentNode && !foundEndNodeSibling) { | ||
if (hasStartContainer && !hasEndContainer) { | ||
console.log({ | ||
range: range | ||
}); | ||
var endContainer = getLastDescendantTerminalNode(rootElement); | ||
@@ -869,5 +863,2 @@ var subRange = new Range(); | ||
if (!hasStartContainer && hasEndContainer) { | ||
console.log({ | ||
range: range | ||
}); | ||
var startContainer = getFirstDescendantTerminalNode(rootElement); | ||
@@ -874,0 +865,0 @@ |
{ | ||
"name": "@perlego-oss/text-highlighter", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "TextHighlighter allows you to highlight text on web pages.", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -19,3 +18,3 @@ "@babel/cli": "^7.12.10", | ||
"docdash": "^1.1.1", | ||
"eslint": "^6.2.2", | ||
"eslint": "^8.10.0", | ||
"eslint-config-prettier": "^6.1.0", | ||
@@ -27,3 +26,3 @@ "eslint-plugin-jest": "^22.15.2", | ||
"grunt-babel": "^8.0.0", | ||
"grunt-browserify": "^5.3.0", | ||
"grunt-browserify": "^6.0.0", | ||
"grunt-contrib-clean": "^0.6.0", | ||
@@ -36,3 +35,3 @@ "grunt-contrib-uglify": "^4.0.1", | ||
"jest": "^26.6.3", | ||
"jest-extended": "^0.11.2", | ||
"jest-extended": "^2.0.0", | ||
"jsdom": "^15.1.1", | ||
@@ -42,3 +41,3 @@ "load-grunt-tasks": "^5.1.0", | ||
"regenerator-runtime": "^0.13.3", | ||
"sanitize-html": "^1.20.1" | ||
"sanitize-html": "^2.6.1" | ||
}, | ||
@@ -45,0 +44,0 @@ "jest": { |
@@ -62,2 +62,3 @@ import { | ||
* @param {string} options.namespaceDataAttribute - Data attribute to identify highlights that belong to a particular highlight instance. | ||
* @param {boolean} options.highlightWhiteSpaceChars - Whether or not to deserialise highlights into the DOM when they only contain white space characters. | ||
* @param {Record<string, number>} options.priorities - Defines priorities for multiple highlighters, the keys | ||
@@ -105,3 +106,2 @@ * are the namespaces for highlighters and the values are the priorities | ||
} | ||
console.log({ rangeRelativeToRootElement }); | ||
@@ -324,2 +324,3 @@ let eventItems = []; | ||
const { highlightWhiteSpaceChars } = self.options; | ||
const parentNode = self.el; | ||
@@ -347,3 +348,6 @@ const { nodesAndOffsets } = findNodesAndOffsets( | ||
if (visibleTextContent.length > 0) { | ||
if ( | ||
visibleTextContent.length > 0 || | ||
(highlightWhiteSpaceChars && node.textContent.length > 0) | ||
) { | ||
hlNode = node.splitText(offsetWithinNode); | ||
@@ -350,0 +354,0 @@ hlNode.splitText(lengthInNode); |
@@ -75,2 +75,3 @@ import dom from "./utils/dom"; | ||
* @param {boolean} [options.keepRange=false] - Whether or not to keep the highlight selection after highlights are created. If set to true then the selection will stay active. | ||
* @param {boolean} [options.highlightWhiteSpaceChars=false] - Whether or not to deserialise highlights into the DOM when they only contain white space characters. | ||
* @param {function} options.onRemoveHighlight - function called before highlight is removed. Highlight is | ||
@@ -109,2 +110,3 @@ * passed as param. Function should return true if highlight should be removed, or false - to prevent removal. | ||
keepRange: false, | ||
highlightWhiteSpaceChars: false, | ||
cancelProperty: "cancel", | ||
@@ -111,0 +113,0 @@ onRemoveHighlight: function() { |
@@ -411,3 +411,2 @@ /** | ||
let currentNode = startNodeOrContainer.nextSibling; | ||
console.log({ currentNodeBeforeWhile: currentNode }); | ||
while (currentNode && !foundEndNodeSibling) { | ||
@@ -899,3 +898,2 @@ if (currentNode === endNode || currentNode.contains(endNode)) { | ||
if (hasStartContainer && !hasEndContainer) { | ||
console.log({ range }); | ||
const endContainer = getLastDescendantTerminalNode(rootElement); | ||
@@ -909,3 +907,2 @@ const subRange = new Range(); | ||
if (!hasStartContainer && hasEndContainer) { | ||
console.log({ range }); | ||
const startContainer = getFirstDescendantTerminalNode(rootElement); | ||
@@ -912,0 +909,0 @@ const subRange = new Range(); |
Sorry, the diff of this file is too big to display
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
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
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
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
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
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5553585
12
161896