Skip to content

Commit a0295f3

Browse files
Merge pull request #43 from williamtroup/4.5.0
4.5.0
2 parents c11be41 + cc137bc commit a0295f3

File tree

87 files changed

+357
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+357
-270
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
JsonTree.js
33

44
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=JsonTree.js%2C%20a%20free%20JavaScript%json%20treeview&url=https://github.com/williamtroup/JsonTree.js&hashtags=javascript,treeview,json)
5-
[![npm](https://img.shields.io/badge/npmjs-v4.4.0-blue)](https://www.npmjs.com/package/jjsontree.js)
6-
[![nuget](https://img.shields.io/badge/nuget-v4.4.0-purple)](https://www.nuget.org/packages/jJsonTree.js/)
5+
[![npm](https://img.shields.io/badge/npmjs-v4.5.0-blue)](https://www.npmjs.com/package/jjsontree.js)
6+
[![nuget](https://img.shields.io/badge/nuget-v4.5.0-purple)](https://www.nuget.org/packages/jJsonTree.js/)
77
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/JsonTree.js/blob/main/LICENSE.txt)
88
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/JsonTree.js/discussions)
99
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://william-troup.com/)
1010
</h1>
1111

1212
> <p align="center">🔗 A lightweight JavaScript library that generates customizable tree views to better visualize, and edit, JSON data.</p>
13-
> <p align="center">v4.4.0</p>
13+
> <p align="center">v4.5.0</p>
1414
<br />
1515
1616
![JsonTree.js](docs/images/main.png)
@@ -173,8 +173,8 @@ Or, you can download the latest zipped up version [here](https://www.william-tro
173173
Or, you can also use the following CDN links:
174174

175175
```markdown
176-
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.4.0/dist/jsontree.min.js
177-
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.4.0/dist/jsontree.js.min.css
176+
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.5.0/dist/jsontree.min.js
177+
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.5.0/dist/jsontree.js.min.css
178178
```
179179
<br>
180180
<br>

README_NUGET.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# JsonTree.js v4.4.0
1+
# JsonTree.js v4.5.0
22

33
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=JsonTree.js%2C%20a%20free%20JavaScript%json%20treeview&url=https://github.com/williamtroup/JsonTree.js&hashtags=javascript,treeview,json)
4-
[![npm](https://img.shields.io/badge/npmjs-v4.4.0-blue)](https://www.npmjs.com/package/jjsontree.js)
5-
[![nuget](https://img.shields.io/badge/nuget-v4.4.0-purple)](https://www.nuget.org/packages/jJsonTree.js/)
4+
[![npm](https://img.shields.io/badge/npmjs-v4.5.0-blue)](https://www.npmjs.com/package/jjsontree.js)
5+
[![nuget](https://img.shields.io/badge/nuget-v4.5.0-purple)](https://www.nuget.org/packages/jJsonTree.js/)
66
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/JsonTree.js/blob/main/LICENSE.txt)
77
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/JsonTree.js/discussions)
88
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://william-troup.com/)
@@ -152,8 +152,8 @@ Or, you can download the latest zipped up version [here](https://www.william-tro
152152
Or, you can also use the following CDN links:
153153

154154
```markdown
155-
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.4.0/dist/jsontree.min.js
156-
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.4.0/dist/jsontree.js.min.css
155+
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.5.0/dist/jsontree.min.js
156+
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@4.5.0/dist/jsontree.js.min.css
157157
```
158158

159159

dist/jsontree.esm.js

Lines changed: 88 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ var Convert2;
245245
n = parseFloat(t);
246246
} else if (Is.definedNumber(e) && !isNaN(+t)) {
247247
n = parseInt(t);
248-
} else if (Is.definedString(e)) {
248+
} else if (Is.definedStringAny(e)) {
249249
n = t;
250250
} else if (Is.definedDate(e)) {
251251
n = new Date(t);
@@ -364,7 +364,7 @@ var Convert2;
364364
Convert.stringToBoolean = stringToBoolean;
365365
function stringToParsedValue(e, t) {
366366
let n = null;
367-
if (Is.definedString(e)) {
367+
if (Is.definedString(e) && e.trim() !== "") {
368368
const o = parseFloat(e);
369369
if (t.parse.stringsToBooleans && Is.String.boolean(e)) {
370370
n = Convert.stringToBoolean(e);
@@ -383,8 +383,45 @@ var Convert2;
383383
return n;
384384
}
385385
Convert.stringToParsedValue = stringToParsedValue;
386+
function symbolToSpacedOutString(e) {
387+
let t = e.toString();
388+
if (t.indexOf("()") === -1) {
389+
t = t.replace("(", `(${" "}`).replace(")", `${" "})`);
390+
} else {
391+
t = t.replace("()", "");
392+
}
393+
return t;
394+
}
395+
Convert.symbolToSpacedOutString = symbolToSpacedOutString;
386396
})(Convert2 || (Convert2 = {}));
387397

398+
var Str;
399+
400+
(e => {
401+
function t(e, t = 1, n = "0") {
402+
const o = e.toString();
403+
let l = o;
404+
if (o.length < t) {
405+
const e = t - o.length + 1;
406+
l = `${Array(e).join(n)}${o}`;
407+
}
408+
return l;
409+
}
410+
e.padNumber = t;
411+
function n(e) {
412+
return `${e.charAt(0).toUpperCase()}${e.slice(1)}`;
413+
}
414+
e.capitalizeFirstLetter = n;
415+
function o(e, t, n) {
416+
let o = e;
417+
if (t > 0 && o.length > t) {
418+
o = `${o.substring(0, t)}${" "}${n}${" "}`;
419+
}
420+
return o;
421+
}
422+
e.getMaximumLengthDisplay = o;
423+
})(Str || (Str = {}));
424+
388425
var Default;
389426

390427
(e => {
@@ -439,20 +476,23 @@ var Default;
439476
return n;
440477
}
441478
e.getStringOrArray = c;
442-
function d(e, t) {
443-
let n;
444-
let o = false;
445-
const l = e.toString().split("(");
446-
const r = l[0].split(" ");
447-
const i = "()";
448-
n = `${r.join(" ")}${i}`;
449-
if (n.trim() === i) {
450-
n = `${t.text.functionText}${i}`;
451-
o = true;
479+
function d(e, t, n) {
480+
const o = e.toString();
481+
const l = o.substring(0, o.indexOf(")") + 1);
482+
let r = l.trim();
483+
let i = false;
484+
if (l[0] === "(") {
485+
r = `${t.text.functionText}${r}`;
486+
i = true;
487+
}
488+
if (!i) {
489+
r = Str.getMaximumLengthDisplay(r, n.maximum.functionLength, t.text.ellipsisText);
490+
} else {
491+
r = Str.getMaximumLengthDisplay(r, n.maximum.lambdaLength, t.text.ellipsisText);
452492
}
453493
return {
454-
name: n,
455-
isLambda: o
494+
name: r,
495+
isLambda: i
456496
};
457497
}
458498
e.getFunctionName = d;
@@ -610,33 +650,6 @@ var DomElement;
610650
e.getStyleValueByName = d;
611651
})(DomElement || (DomElement = {}));
612652

613-
var Str;
614-
615-
(e => {
616-
function t(e, t = 1, n = "0") {
617-
const o = e.toString();
618-
let l = o;
619-
if (o.length < t) {
620-
const e = t - o.length + 1;
621-
l = `${Array(e).join(n)}${o}`;
622-
}
623-
return l;
624-
}
625-
e.padNumber = t;
626-
function n(e) {
627-
return `${e.charAt(0).toUpperCase()}${e.slice(1)}`;
628-
}
629-
e.capitalizeFirstLetter = n;
630-
function o(e, t, n) {
631-
let o = e;
632-
if (t > 0 && o.length > t) {
633-
o = `${o.substring(0, t)}${" "}${n}${" "}`;
634-
}
635-
return o;
636-
}
637-
e.getMaximumLengthDisplay = o;
638-
})(Str || (Str = {}));
639-
640653
var DateTime;
641654

642655
(e => {
@@ -797,6 +810,7 @@ var Binding;
797810
t.rootName = Default.getString(t.rootName, "root");
798811
t.emptyStringValue = Default.getString(t.emptyStringValue, "");
799812
t.expandIconType = Default.getString(t.expandIconType, "arrow");
813+
t.openUrlsInSameWindow = Default.getBoolean(t.openUrlsInSameWindow, false);
800814
t.maximum = l(t);
801815
t.paging = r(t);
802816
t.title = i(t);
@@ -823,6 +837,8 @@ var Binding;
823837
e.maximum.bigIntLength = Default.getNumber(e.maximum.bigIntLength, 0);
824838
e.maximum.inspectionLevels = Default.getNumber(e.maximum.inspectionLevels, 10);
825839
e.maximum.propertyNameLength = Default.getNumber(e.maximum.propertyNameLength, 0);
840+
e.maximum.functionLength = Default.getNumber(e.maximum.functionLength, 0);
841+
e.maximum.lambdaLength = Default.getNumber(e.maximum.lambdaLength, 0);
826842
return e.maximum;
827843
}
828844
function r(e) {
@@ -1504,6 +1520,7 @@ var ContextMenu;
15041520
}
15051521
function s(t, n, o, l, r, i, a) {
15061522
const s = DomElement.create(n, "div", i > 1 ? "contents-column-multiple" : "contents-column");
1523+
const c = o._currentView.currentColumnBuildingIndex;
15071524
if (!Is.defined(t)) {
15081525
const t = DomElement.create(s, "div", "no-json");
15091526
DomElement.createWithHTML(t, "span", "no-json-text", e.text.noJsonToViewText);
@@ -1512,7 +1529,7 @@ var ContextMenu;
15121529
n.onclick = () => M(o);
15131530
}
15141531
} else {
1515-
s.onscroll = () => d(s, o, o._currentView.currentColumnBuildingIndex);
1532+
s.onscroll = () => d(s, o, c);
15161533
if (o.paging.enabled && Is.definedNumber(l)) {
15171534
s.setAttribute(Constants.JSONTREE_JS_ATTRIBUTE_ARRAY_INDEX_NAME, l.toString());
15181535
}
@@ -1531,13 +1548,13 @@ var ContextMenu;
15311548
i = DomElement.create(s, "div", "contents-column-lines");
15321549
e = i;
15331550
}
1534-
const c = {
1551+
const p = {
15351552
column: s,
15361553
lineNumbers: n,
15371554
lines: i,
15381555
controlButtons: null
15391556
};
1540-
o._currentView.currentContentColumns.push(c);
1557+
o._currentView.currentContentColumns.push(p);
15411558
o._currentView.currentColumnBuildingIndex = o._currentView.currentContentColumns.length - 1;
15421559
if (Is.definedArray(t)) {
15431560
q(e, o, t, "array");
@@ -1635,28 +1652,22 @@ var ContextMenu;
16351652
const l = e.scrollLeft;
16361653
const r = t._currentView.currentContentColumns.length;
16371654
if (t.controlPanel.enabled) {
1638-
const e = t._currentView.currentContentColumns[n].controlButtons;
1639-
if (Is.defined(e)) {
1640-
e.style.top = `${t._currentView.currentContentColumns[n].column.scrollTop}px`;
1641-
e.style.right = `-${t._currentView.currentContentColumns[n].column.scrollLeft}px`;
1655+
const e = t._currentView.currentContentColumns[n];
1656+
if (Is.defined(e.controlButtons)) {
1657+
e.controlButtons.style.top = `${e.column.scrollTop}px`;
1658+
e.controlButtons.style.right = `-${e.column.scrollLeft}px`;
16421659
}
16431660
}
1644-
if (t.paging.synchronizeScrolling) {
1645-
for (let e = 0; e < r; e++) {
1646-
if (n !== e) {
1647-
t._currentView.currentContentColumns[e].column.scrollTop = o;
1648-
t._currentView.currentContentColumns[e].column.scrollLeft = l;
1661+
for (let n = 0; n < r; n++) {
1662+
const r = t._currentView.currentContentColumns[n];
1663+
if (r.column !== e) {
1664+
if (t.paging.synchronizeScrolling) {
1665+
r.column.scrollTop = o;
1666+
r.column.scrollLeft = l;
16491667
}
1650-
}
1651-
}
1652-
if (t.controlPanel.enabled) {
1653-
for (let e = 0; e < r; e++) {
1654-
if (n !== e) {
1655-
const n = t._currentView.currentContentColumns[e].controlButtons;
1656-
if (Is.defined(n)) {
1657-
n.style.top = `${t._currentView.currentContentColumns[e].column.scrollTop}px`;
1658-
n.style.right = `-${t._currentView.currentContentColumns[e].column.scrollLeft}px`;
1659-
}
1668+
if (t.controlPanel.enabled && Is.defined(r.controlButtons)) {
1669+
r.controlButtons.style.top = `${r.column.scrollTop}px`;
1670+
r.controlButtons.style.right = `-${r.column.scrollLeft}px`;
16601671
}
16611672
}
16621673
}
@@ -2459,7 +2470,7 @@ var ContextMenu;
24592470
T = true;
24602471
}
24612472
} else if (Is.definedFunction(r)) {
2462-
const t = Default.getFunctionName(r, e);
2473+
const t = Default.getFunctionName(r, e, o);
24632474
if (t.isLambda) {
24642475
y = "lambda";
24652476
if (!o.ignore.lambdaValues) {
@@ -2568,7 +2579,13 @@ var ContextMenu;
25682579
w = o.allowEditing.urlValues && !c;
25692580
if (o.showUrlOpenButtons) {
25702581
v = DomElement.createWithHTML(g, "span", o.showValueColors ? "open-button-color" : "open-button", `${e.text.openText}${" "}${e.text.openSymbolText}`);
2571-
v.onclick = () => window.open(r);
2582+
v.onclick = () => {
2583+
if (o.openUrlsInSameWindow) {
2584+
window.location = r;
2585+
} else {
2586+
window.open(r);
2587+
}
2588+
};
25722589
}
25732590
te(o, t, l, r, x, a, w, v);
25742591
Trigger.customEvent(o.events.onUrlRender, o._currentView.element, x);
@@ -2642,7 +2659,7 @@ var ContextMenu;
26422659
y = "symbol";
26432660
if (!o.ignore.symbolValues) {
26442661
p = o.showValueColors ? `${y} value` : "value";
2645-
x = DomElement.createWithHTML(g, "span", p, r.toString());
2662+
x = DomElement.createWithHTML(g, "span", p, Convert2.symbolToSpacedOutString(r));
26462663
w = o.allowEditing.symbolValues && !c;
26472664
te(o, t, l, r, x, a, w);
26482665
Trigger.customEvent(o.events.onSymbolRender, o._currentView.element, x);
@@ -3435,7 +3452,10 @@ var ContextMenu;
34353452
function Ve(e, l) {
34363453
o = Be(e);
34373454
if (l.shortcutKeysEnabled && n === 1 && t.hasOwnProperty(l._currentView.element.id) && !l._currentView.editMode) {
3438-
if (Be(e) && e.code === "F11") {
3455+
if (Be(e) && e.code === "KeyC") {
3456+
e.preventDefault();
3457+
v(l, l.data);
3458+
} else if (Be(e) && e.code === "F11") {
34393459
e.preventDefault();
34403460
V(l);
34413461
} else if (e.code === "ArrowLeft") {
@@ -3652,7 +3672,7 @@ var ContextMenu;
36523672
return e;
36533673
},
36543674
getVersion: function() {
3655-
return "4.4.0";
3675+
return "4.5.0";
36563676
}
36573677
};
36583678
(() => {

dist/jsontree.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)