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

diff2html

Package Overview
Dependencies
Maintainers
1
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff2html - npm Package Compare versions

Comparing version 3.0.2 to 3.1.0

2

lib-esm/ui/js/diff2html-ui-base.d.ts

@@ -42,6 +42,4 @@ /// <reference types="highlight.js" />

private getHashTag;
private getSelectedText;
private isElement;
private isClipboardEvent;
}
//# sourceMappingURL=diff2html-ui-base.d.ts.map

@@ -28,4 +28,2 @@ var __assign = (this && this.__assign) || function () {

this.targetElement.innerHTML = this.diffHtml;
if (this.config.smartSelection)
this.smartSelection();
if (this.config.synchronisedScroll)

@@ -134,32 +132,3 @@ this.synchronisedScroll();

Diff2HtmlUI.prototype.smartSelection = function () {
var _this = this;
var body = document.getElementsByTagName('body')[0];
var diffTable = body.getElementsByClassName('d2h-diff-table')[0];
diffTable.addEventListener('mousedown', function (event) {
if (event === null || !_this.isElement(event.target))
return;
var table = event.target.closest('.d2h-diff-table');
if (table !== null) {
if (event.target.closest('.d2h-code-line,.d2h-code-side-line') !== null) {
table.classList.remove('selecting-left');
table.classList.add('selecting-right');
_this.currentSelectionColumnId = 1;
}
else if (event.target.closest('.d2h-code-linenumber,.d2h-code-side-linenumber') !== null) {
table.classList.remove('selecting-right');
table.classList.add('selecting-left');
_this.currentSelectionColumnId = 0;
}
}
});
diffTable.addEventListener('copy', function (event) {
if (!_this.isClipboardEvent(event))
return;
var clipboardData = event.clipboardData;
var text = _this.getSelectedText();
if (clipboardData === null || text === undefined)
return;
clipboardData.setData('text', text);
event.preventDefault();
});
console.warn('Smart selection is now enabled by default with CSS. No need to call this method anymore.');
};

@@ -178,24 +147,2 @@ Diff2HtmlUI.prototype.instanceOfIHighlightResult = function (object) {

};
Diff2HtmlUI.prototype.getSelectedText = function () {
var sel = window.getSelection();
if (sel === null)
return;
var range = sel.getRangeAt(0);
var doc = range.cloneContents();
var nodes = doc.querySelectorAll('tr');
var idx = this.currentSelectionColumnId;
var text = '';
if (nodes.length === 0) {
text = doc.textContent || '';
}
else {
nodes.forEach(function (tr, i) {
var td = tr.cells[tr.cells.length === 1 ? 0 : idx];
if (td === undefined || td.textContent === null)
return;
text += (i ? '\n' : '') + td.textContent.replace(/\r\n|\r|\n/g, '');
});
}
return text;
};
Diff2HtmlUI.prototype.isElement = function (arg) {

@@ -205,6 +152,2 @@ var _a;

};
Diff2HtmlUI.prototype.isClipboardEvent = function (arg) {
var _a;
return arg !== null && ((_a = arg) === null || _a === void 0 ? void 0 : _a.clipboardData) !== undefined;
};
return Diff2HtmlUI;

@@ -211,0 +154,0 @@ }());

@@ -42,6 +42,4 @@ /// <reference types="highlight.js" />

private getHashTag;
private getSelectedText;
private isElement;
private isClipboardEvent;
}
//# sourceMappingURL=diff2html-ui-base.d.ts.map

@@ -30,4 +30,2 @@ "use strict";

this.targetElement.innerHTML = this.diffHtml;
if (this.config.smartSelection)
this.smartSelection();
if (this.config.synchronisedScroll)

@@ -136,32 +134,3 @@ this.synchronisedScroll();

Diff2HtmlUI.prototype.smartSelection = function () {
var _this = this;
var body = document.getElementsByTagName('body')[0];
var diffTable = body.getElementsByClassName('d2h-diff-table')[0];
diffTable.addEventListener('mousedown', function (event) {
if (event === null || !_this.isElement(event.target))
return;
var table = event.target.closest('.d2h-diff-table');
if (table !== null) {
if (event.target.closest('.d2h-code-line,.d2h-code-side-line') !== null) {
table.classList.remove('selecting-left');
table.classList.add('selecting-right');
_this.currentSelectionColumnId = 1;
}
else if (event.target.closest('.d2h-code-linenumber,.d2h-code-side-linenumber') !== null) {
table.classList.remove('selecting-right');
table.classList.add('selecting-left');
_this.currentSelectionColumnId = 0;
}
}
});
diffTable.addEventListener('copy', function (event) {
if (!_this.isClipboardEvent(event))
return;
var clipboardData = event.clipboardData;
var text = _this.getSelectedText();
if (clipboardData === null || text === undefined)
return;
clipboardData.setData('text', text);
event.preventDefault();
});
console.warn('Smart selection is now enabled by default with CSS. No need to call this method anymore.');
};

@@ -180,24 +149,2 @@ Diff2HtmlUI.prototype.instanceOfIHighlightResult = function (object) {

};
Diff2HtmlUI.prototype.getSelectedText = function () {
var sel = window.getSelection();
if (sel === null)
return;
var range = sel.getRangeAt(0);
var doc = range.cloneContents();
var nodes = doc.querySelectorAll('tr');
var idx = this.currentSelectionColumnId;
var text = '';
if (nodes.length === 0) {
text = doc.textContent || '';
}
else {
nodes.forEach(function (tr, i) {
var td = tr.cells[tr.cells.length === 1 ? 0 : idx];
if (td === undefined || td.textContent === null)
return;
text += (i ? '\n' : '') + td.textContent.replace(/\r\n|\r|\n/g, '');
});
}
return text;
};
Diff2HtmlUI.prototype.isElement = function (arg) {

@@ -207,6 +154,2 @@ var _a;

};
Diff2HtmlUI.prototype.isClipboardEvent = function (arg) {
var _a;
return arg !== null && ((_a = arg) === null || _a === void 0 ? void 0 : _a.clipboardData) !== undefined;
};
return Diff2HtmlUI;

@@ -213,0 +156,0 @@ }());

2

package.json
{
"name": "diff2html",
"version": "3.0.2",
"version": "3.1.0",
"homepage": "https://diff2html.xyz",

@@ -5,0 +5,0 @@ "description": "Fast Diff to colorized HTML",

@@ -311,3 +311,2 @@ # diff2html

highlightCode(): void
smartSelection(): void
```

@@ -323,4 +322,2 @@

- `fileListStartVisible`: choose if the file summary list starts visible: `true` or `false`, default is `false`
- `smartSelection`: allow selection of the code without including line numbers of line prefixes: `true` or `false`,
default is `true`

@@ -327,0 +324,0 @@ > NOTE: All the options from Diff2Html are also valid configurations in Diff2HtmlUI

Sorry, the diff of this file is not supported yet

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 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

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