@douyinfe/semi-json-viewer-core 2.83.0 → 2.84.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +29 -27
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -24,17 +24,17 @@ function createTokenizationSupport(supportComments) {
|
|
|
24
24
|
tokenize: (line, state) => tokenize(supportComments, line, state)
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
var TOKEN_DELIM_OBJECT = "
|
|
28
|
-
var TOKEN_DELIM_ARRAY = "
|
|
29
|
-
var TOKEN_DELIM_COLON = "
|
|
30
|
-
var TOKEN_DELIM_COMMA = "
|
|
31
|
-
var TOKEN_VALUE_BOOLEAN = "
|
|
32
|
-
var TOKEN_VALUE_NULL = "
|
|
33
|
-
var TOKEN_VALUE_STRING = "
|
|
34
|
-
var TOKEN_VALUE_NUMBER = "
|
|
35
|
-
var TOKEN_PROPERTY_NAME = "
|
|
36
|
-
var TOKEN_COMMENT_BLOCK = "
|
|
37
|
-
var TOKEN_COMMENT_LINE = "
|
|
27
|
+
var TOKEN_DELIM_OBJECT = "delimiter-bracket";
|
|
28
|
+
var TOKEN_DELIM_ARRAY = "delimiter-array";
|
|
29
|
+
var TOKEN_DELIM_COLON = "delimiter-colon";
|
|
30
|
+
var TOKEN_DELIM_COMMA = "delimiter-comma";
|
|
31
|
+
var TOKEN_VALUE_BOOLEAN = "keyword";
|
|
32
|
+
var TOKEN_VALUE_NULL = "keyword";
|
|
33
|
+
var TOKEN_VALUE_STRING = "string-value";
|
|
34
|
+
var TOKEN_VALUE_NUMBER = "number";
|
|
35
|
+
var TOKEN_PROPERTY_NAME = "string-key";
|
|
36
|
+
var TOKEN_COMMENT_BLOCK = "comment-block";
|
|
37
|
+
var TOKEN_COMMENT_LINE = "comment-line";
|
|
38
38
|
var ParentsStack = class _ParentsStack {
|
|
39
39
|
constructor(parent, type, depth) {
|
|
40
40
|
this.parent = parent;
|
|
@@ -422,7 +422,7 @@ var SelectionModel = class {
|
|
|
422
422
|
if (!node) return { row, col };
|
|
423
423
|
let lineElement;
|
|
424
424
|
if (node instanceof HTMLElement) {
|
|
425
|
-
lineElement = node.closest(
|
|
425
|
+
lineElement = node.closest(`.${this._view.prefixCls}-view-line`);
|
|
426
426
|
} else {
|
|
427
427
|
lineElement = getLineElement(node);
|
|
428
428
|
if (!lineElement) return { row, col };
|
|
@@ -1880,7 +1880,7 @@ var FoldWidget = class {
|
|
|
1880
1880
|
return svg;
|
|
1881
1881
|
}
|
|
1882
1882
|
_createFoldingIcon(lineNumber) {
|
|
1883
|
-
const foldingIconClass =
|
|
1883
|
+
const foldingIconClass = `${this._view.prefixCls}-folding-icon`;
|
|
1884
1884
|
const foldingIcon = elt("span", foldingIconClass);
|
|
1885
1885
|
const isCollapsed = this._foldingModel.isCollapsed(lineNumber);
|
|
1886
1886
|
foldingIcon.appendChild(this._createFoldSvg(isCollapsed));
|
|
@@ -1908,7 +1908,7 @@ var FoldWidget = class {
|
|
|
1908
1908
|
return foldingIcon;
|
|
1909
1909
|
}
|
|
1910
1910
|
removeAllFoldingIcons() {
|
|
1911
|
-
const foldingIconClass =
|
|
1911
|
+
const foldingIconClass = `${this._view.prefixCls}-folding-icon`;
|
|
1912
1912
|
const foldingIcons = this._view.lineScrollDom.querySelectorAll(`.${foldingIconClass}`);
|
|
1913
1913
|
foldingIcons.forEach((icon) => icon.remove());
|
|
1914
1914
|
}
|
|
@@ -3769,7 +3769,7 @@ var CompleteWidget = class {
|
|
|
3769
3769
|
return { x, y };
|
|
3770
3770
|
}
|
|
3771
3771
|
createCompleteContainer() {
|
|
3772
|
-
const className =
|
|
3772
|
+
const className = `${this._view.prefixCls}-complete-container`;
|
|
3773
3773
|
const container = elt("div", className);
|
|
3774
3774
|
setStyles(container, {
|
|
3775
3775
|
display: "none"
|
|
@@ -3777,7 +3777,7 @@ var CompleteWidget = class {
|
|
|
3777
3777
|
return container;
|
|
3778
3778
|
}
|
|
3779
3779
|
createSuggestionsContainer() {
|
|
3780
|
-
const className =
|
|
3780
|
+
const className = `${this._view.prefixCls}-complete-suggestions-container`;
|
|
3781
3781
|
const container = elt("div", className);
|
|
3782
3782
|
setStyles(container, {
|
|
3783
3783
|
maxHeight: "200px",
|
|
@@ -3838,7 +3838,7 @@ var CompleteWidget = class {
|
|
|
3838
3838
|
this.hide();
|
|
3839
3839
|
}
|
|
3840
3840
|
_renderCompletions() {
|
|
3841
|
-
const className =
|
|
3841
|
+
const className = `${this._view.prefixCls}-complete-suggestions-item`;
|
|
3842
3842
|
this._suggestionsContainer.innerHTML = this._suggestions.map(
|
|
3843
3843
|
(item, index) => `
|
|
3844
3844
|
<li class="${className}" style="background-color: ${index === this._selectedIndex ? "var(--semi-color-fill-0)" : "transparent"}" data-index="${index}">
|
|
@@ -3976,7 +3976,7 @@ var ErrorWidget = class {
|
|
|
3976
3976
|
const child = line.children[i];
|
|
3977
3977
|
offset += child.textContent?.length || 0;
|
|
3978
3978
|
if (offset > start.column && offset <= end.column) {
|
|
3979
|
-
const className =
|
|
3979
|
+
const className = `${this._view.prefixCls}-error`;
|
|
3980
3980
|
child.classList.add(className);
|
|
3981
3981
|
}
|
|
3982
3982
|
}
|
|
@@ -3989,6 +3989,7 @@ var ViewDOMBuilder = class {
|
|
|
3989
3989
|
this._lineHeight = lineHeight;
|
|
3990
3990
|
this._totalLines = totalLines;
|
|
3991
3991
|
this._options = options;
|
|
3992
|
+
this.prefixCls = options?.prefixCls || "semi-json-viewer";
|
|
3992
3993
|
}
|
|
3993
3994
|
createRenderContainer() {
|
|
3994
3995
|
const renderContainer = elt("div", "json-viewer-container");
|
|
@@ -4001,7 +4002,7 @@ var ViewDOMBuilder = class {
|
|
|
4001
4002
|
return renderContainer;
|
|
4002
4003
|
}
|
|
4003
4004
|
createLineNumberContainer() {
|
|
4004
|
-
const lineNumberClass =
|
|
4005
|
+
const lineNumberClass = `${this._options?.prefixCls}-line-number-container`;
|
|
4005
4006
|
const lineNumberContainer = elt("div", lineNumberClass);
|
|
4006
4007
|
setStyles(lineNumberContainer, {
|
|
4007
4008
|
position: "absolute",
|
|
@@ -4012,7 +4013,7 @@ var ViewDOMBuilder = class {
|
|
|
4012
4013
|
return lineNumberContainer;
|
|
4013
4014
|
}
|
|
4014
4015
|
createContentContainer() {
|
|
4015
|
-
const contentClass =
|
|
4016
|
+
const contentClass = `${this.prefixCls}-content-container`;
|
|
4016
4017
|
const contentContainer = elt("div", contentClass);
|
|
4017
4018
|
setStyles(contentContainer, {
|
|
4018
4019
|
position: "absolute",
|
|
@@ -4077,6 +4078,7 @@ var View = class {
|
|
|
4077
4078
|
this._lineHeight = options?.lineHeight || 20;
|
|
4078
4079
|
this._options = options;
|
|
4079
4080
|
this._customRenderRule = options?.customRenderRule || null;
|
|
4081
|
+
this.prefixCls = options?.prefixCls || "semi-json-viewer";
|
|
4080
4082
|
this._domBuilder = new ViewDOMBuilder(this._lineHeight, model.getLineCount(), options);
|
|
4081
4083
|
this._jsonViewerDom = this._domBuilder.createRenderContainer();
|
|
4082
4084
|
this._lineNumberDom = this._domBuilder.createLineNumberContainer();
|
|
@@ -4189,7 +4191,7 @@ var View = class {
|
|
|
4189
4191
|
this.onScroll(scrollTop);
|
|
4190
4192
|
}
|
|
4191
4193
|
createLineNumberElement(actualLineNumber, visibleLineNumber) {
|
|
4192
|
-
const lineNumberClass =
|
|
4194
|
+
const lineNumberClass = `${this.prefixCls}-line-number`;
|
|
4193
4195
|
const lineNumberElement = elt("div", lineNumberClass);
|
|
4194
4196
|
const rowDatum = this._scalingCellSizeAndPositionManager.getSizeAndPositionOfCell(visibleLineNumber);
|
|
4195
4197
|
setStyles(lineNumberElement, {
|
|
@@ -4213,7 +4215,7 @@ var View = class {
|
|
|
4213
4215
|
return lineNumberElement;
|
|
4214
4216
|
}
|
|
4215
4217
|
createLineContentElement(actualLineNumber, visibleLineNumber) {
|
|
4216
|
-
const lineElementClass =
|
|
4218
|
+
const lineElementClass = `${this.prefixCls}-view-line`;
|
|
4217
4219
|
const lineElement = elt("div", lineElementClass);
|
|
4218
4220
|
lineElement.setAttribute("data-line-element", "true");
|
|
4219
4221
|
const rowDatum = this._scalingCellSizeAndPositionManager.getSizeAndPositionOfCell(visibleLineNumber);
|
|
@@ -4356,7 +4358,7 @@ var View = class {
|
|
|
4356
4358
|
continue;
|
|
4357
4359
|
} else if (customElement !== null) {
|
|
4358
4360
|
const span2 = document.createElement("span");
|
|
4359
|
-
span2.className = token.scopes
|
|
4361
|
+
span2.className = `${this.prefixCls}-${token.scopes}`;
|
|
4360
4362
|
span2.textContent = content;
|
|
4361
4363
|
container.appendChild(span2);
|
|
4362
4364
|
this._customRenderMap.set(span2, customElement);
|
|
@@ -4364,7 +4366,7 @@ var View = class {
|
|
|
4364
4366
|
}
|
|
4365
4367
|
}
|
|
4366
4368
|
const span = document.createElement("span");
|
|
4367
|
-
span.className = token.scopes
|
|
4369
|
+
span.className = `${this.prefixCls}-${token.scopes}`;
|
|
4368
4370
|
span.textContent = content;
|
|
4369
4371
|
if (!this._options?.autoWrap) {
|
|
4370
4372
|
span.style.whiteSpace = "pre";
|
|
@@ -4384,7 +4386,7 @@ var View = class {
|
|
|
4384
4386
|
if (startIndex >= content.length || endIndex <= 0) continue;
|
|
4385
4387
|
if (startIndex > lastIndex) {
|
|
4386
4388
|
const normalSpan = document.createElement("span");
|
|
4387
|
-
normalSpan.className = tokenClass
|
|
4389
|
+
normalSpan.className = `${this.prefixCls}-${tokenClass}`;
|
|
4388
4390
|
normalSpan.textContent = content.substring(lastIndex, startIndex);
|
|
4389
4391
|
container.appendChild(normalSpan);
|
|
4390
4392
|
}
|
|
@@ -4392,7 +4394,7 @@ var View = class {
|
|
|
4392
4394
|
highlightSpan.textContent = content.substring(startIndex, endIndex);
|
|
4393
4395
|
const currentMatch = this._searchWidget.searchResults?.[this._searchWidget._currentResultIndex];
|
|
4394
4396
|
const isCurrentMatch = match.range.startLineNumber === currentMatch?.range.startLineNumber && match.range.endLineNumber === currentMatch?.range.endLineNumber && match.range.startColumn === currentMatch?.range.startColumn && match.range.endColumn === currentMatch?.range.endColumn;
|
|
4395
|
-
highlightSpan.className = `${tokenClass}
|
|
4397
|
+
highlightSpan.className = `${this.prefixCls}-${tokenClass} ${this.prefixCls}-search-result${isCurrentMatch ? ` ${this.prefixCls}-current-search-result` : ""}`;
|
|
4396
4398
|
highlightSpan.dataset.startColumn = match.range.startColumn.toString();
|
|
4397
4399
|
highlightSpan.dataset.endColumn = match.range.endColumn.toString();
|
|
4398
4400
|
container.appendChild(highlightSpan);
|
|
@@ -4400,7 +4402,7 @@ var View = class {
|
|
|
4400
4402
|
}
|
|
4401
4403
|
if (lastIndex < content.length) {
|
|
4402
4404
|
const remainingSpan = document.createElement("span");
|
|
4403
|
-
remainingSpan.className = tokenClass
|
|
4405
|
+
remainingSpan.className = `${this.prefixCls}-${tokenClass}`;
|
|
4404
4406
|
remainingSpan.textContent = content.substring(lastIndex);
|
|
4405
4407
|
container.appendChild(remainingSpan);
|
|
4406
4408
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-json-viewer-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.84.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
],
|
|
54
54
|
"author": "",
|
|
55
55
|
"license": "MIT",
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "85d5331857a631b0ec37f88bea34bfad34cb2dcb"
|
|
57
57
|
}
|