vue-devui 1.5.7 → 1.5.8
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/alert/index.es.js +13 -3
- package/alert/index.umd.js +11 -1
- package/avatar/index.es.js +10 -2
- package/avatar/index.umd.js +9 -1
- package/code-editor/index.es.js +13 -12
- package/code-editor/index.umd.js +5 -5
- package/code-review/index.es.js +357 -8
- package/code-review/index.umd.js +74 -19
- package/code-review/style.css +1 -1
- package/git-graph/index.es.js +6061 -0
- package/git-graph/index.umd.js +32 -0
- package/git-graph/package.json +8 -0
- package/global.d.ts +1 -0
- package/nuxt/components/GitGraph.js +2 -0
- package/nuxt/components/gitGraphProps.js +2 -0
- package/package.json +2 -1
- package/pagination/index.es.js +7 -1
- package/pagination/index.umd.js +7 -1
- package/select/index.es.js +7 -1
- package/select/index.umd.js +7 -1
- package/style.css +1 -1
- package/time-select/index.es.js +7 -1
- package/time-select/index.umd.js +7 -1
- package/types/avatar/src/components/icon-body.d.ts +1 -1
- package/types/code-editor/src/code-editor-types.d.ts +1 -1
- package/types/code-editor/src/code-editor.d.ts +1 -1
- package/types/code-editor/src/composables/use-code-editor.d.ts +2 -2
- package/types/code-review/src/code-review-types.d.ts +16 -0
- package/types/code-review/src/code-review.d.ts +10 -1
- package/types/code-review/src/components/code-review-icons.d.ts +4 -0
- package/types/code-review/src/composables/use-code-review-comment.d.ts +13 -0
- package/types/code-review/src/composables/use-code-review-expand.d.ts +5 -0
- package/types/code-review/src/composables/use-code-review.d.ts +2 -0
- package/types/code-review/src/const.d.ts +2 -0
- package/types/code-review/src/utils.d.ts +7 -0
- package/types/git-graph/index.d.ts +11 -0
- package/types/git-graph/src/git-graph-class.d.ts +43 -0
- package/types/git-graph/src/git-graph-types.d.ts +84 -0
- package/types/git-graph/src/git-graph.d.ts +10 -0
- package/types/git-graph/src/use-git-graph.d.ts +6 -0
- package/types/vue-devui.d.ts +2 -1
- package/vue-devui.es.js +1025 -29
- package/vue-devui.umd.js +139 -61
package/code-review/index.es.js
CHANGED
|
@@ -6106,6 +6106,88 @@ function CopyIcon() {
|
|
|
6106
6106
|
"fill-rule": "nonzero"
|
|
6107
6107
|
}, null)])]);
|
|
6108
6108
|
}
|
|
6109
|
+
function CommentIcon() {
|
|
6110
|
+
return createVNode("svg", {
|
|
6111
|
+
"width": "12px",
|
|
6112
|
+
"height": "12px",
|
|
6113
|
+
"viewBox": "0 0 16 16",
|
|
6114
|
+
"version": "1.1",
|
|
6115
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
6116
|
+
}, [createVNode("g", {
|
|
6117
|
+
"stroke": "none",
|
|
6118
|
+
"stroke-width": "1",
|
|
6119
|
+
"fill": "none",
|
|
6120
|
+
"fill-rule": "evenodd"
|
|
6121
|
+
}, [createVNode("path", {
|
|
6122
|
+
"d": `M14,1 C15.1045695,1 16,1.8954305 16,3 L16,11 C16,12.1045695 15.1045695,13 14,13 L11,13 L8,16 L5,13 L2,13
|
|
6123
|
+
C0.8954305,13 0,12.1045695 0,11 L0,3 C0,1.8954305 0.8954305,1 2,1 L14,1 Z M14,3 L2,3 L2,11 L5,11 C5.47149598,11
|
|
6124
|
+
5.92582641,11.1664898 6.28439337,11.4669131 L6.41421356,11.5857864 L8,13.171 L9.58578644,11.5857864
|
|
6125
|
+
C9.91918444,11.2523884 10.3581707,11.0488544 10.8241472,11.0077406 L11,11 L14,11 L14,3 Z M8,6 C8.55228475,6
|
|
6126
|
+
9,6.44771525 9,7 C9,7.55228475 8.55228475,8 8,8 C7.44771525,8 7,7.55228475 7,7 C7,6.44771525 7.44771525,6
|
|
6127
|
+
8,6 Z M11,6 C11.5522847,6 12,6.44771525 12,7 C12,7.55228475 11.5522847,8 11,8 C10.4477153,8 10,7.55228475
|
|
6128
|
+
10,7 C10,6.44771525 10.4477153,6 11,6 Z M5,6 C5.55228475,6 6,6.44771525 6,7 C6,7.55228475 5.55228475,8
|
|
6129
|
+
5,8 C4.44771525,8 4,7.55228475 4,7 C4,6.44771525 4.44771525,6 5,6 Z`,
|
|
6130
|
+
"fill": "#5e7ce0",
|
|
6131
|
+
"fill-rule": "nonzero"
|
|
6132
|
+
}, null)])]);
|
|
6133
|
+
}
|
|
6134
|
+
function UpExpandIcon() {
|
|
6135
|
+
return `<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
6136
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
6137
|
+
<g transform="translate(-1365.000000,-11.000000)">
|
|
6138
|
+
<g transform="translate(1365.000000,11.000000)">
|
|
6139
|
+
<rect x="0" y="0" width="16" height="16"></rect>
|
|
6140
|
+
<g
|
|
6141
|
+
transform="translate(8.000000, 8.000000) scale(1, -1) translate(-8.000000, -8.000000) translate(1.000000, 4.000000)"
|
|
6142
|
+
fill="#71757F">
|
|
6143
|
+
<path
|
|
6144
|
+
d='M0.5,0 L13.5,0 C13.7761424,0 14,0.223857625 14,0.5 C14,0.776142375 13.7761424,1 13.5,1 L0.5,1 C0.223857625,1
|
|
6145
|
+
0,0.776142375 0,0.5 C0,0.223857625 0.223857625,0 0.5,0 Z'></path>
|
|
6146
|
+
<polygon
|
|
6147
|
+
transform="translate(7.000000, 5.5000000) scale(1, -1) translate(-7.000000, -5.5000000)"
|
|
6148
|
+
points="7 3 10 8 4 8"></polygon>
|
|
6149
|
+
</g>
|
|
6150
|
+
</g>
|
|
6151
|
+
</g>
|
|
6152
|
+
</g>
|
|
6153
|
+
</svg>`;
|
|
6154
|
+
}
|
|
6155
|
+
function DownExpandIcon() {
|
|
6156
|
+
return `<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
6157
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
6158
|
+
<g transform="translate(-1344.000000,-11.000000)">
|
|
6159
|
+
<g transform="translate(1344.000000,11.000000)">
|
|
6160
|
+
<rect x="0" y="0" width="16" height="16"></rect>
|
|
6161
|
+
<g transform="translate(1.000000, 5.000000)" fill="#71757F">
|
|
6162
|
+
<path
|
|
6163
|
+
d="M0.5,0 L13.5,0 C13.7761424,0 14,0.223857625 14,0.5 C14,0.776142375 13.7761424,1 13.5,1 L0.5,1 C0.223857625,1
|
|
6164
|
+
0,0.776142375 0,0.5 C0,0.223857625 0.223857625,0 0.5,0 Z"></path>
|
|
6165
|
+
<polygon
|
|
6166
|
+
transform="translate(7.000000,5.500000) scale(1, -1) translate(-7.000000, -5.500000)"
|
|
6167
|
+
points="7 3 10 8 4 8"></polygon>
|
|
6168
|
+
</g>
|
|
6169
|
+
</g>
|
|
6170
|
+
</g>
|
|
6171
|
+
</g>
|
|
6172
|
+
</svg>`;
|
|
6173
|
+
}
|
|
6174
|
+
function AllExpandIcon() {
|
|
6175
|
+
return `<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
6176
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
6177
|
+
<g transform="translate(-1301.000000,-11.000000)">
|
|
6178
|
+
<rect x="1301" y="11" width="16" height="16"></rect>
|
|
6179
|
+
<path
|
|
6180
|
+
d="M1302.5,18 L1315.5,18 C1315.77614,18 1316,18.2238576 1316,18.5 1316,18.7761424 1315.77614,19 1315.5,19 L1302.5,19
|
|
6181
|
+
C1302.22386,19 1302,18.7761424 1302,18.5 C1302,18.2238576 1302.22386,18 1302.5,18 Z" fill="#71757F"></path>
|
|
6182
|
+
<polygon fill="#71757F" points="1309 11 1312 16 1306 16"></polygon>
|
|
6183
|
+
<polygon
|
|
6184
|
+
fill="#71757F"
|
|
6185
|
+
transform="translate(1309.000000, 23.500000) scale(1, -1) translate(-1309.000000, -23.500000)"
|
|
6186
|
+
points="1309 21 1312 26 1306 26"></polygon>
|
|
6187
|
+
</g>
|
|
6188
|
+
</g>
|
|
6189
|
+
</svg>`;
|
|
6190
|
+
}
|
|
6109
6191
|
const codeReviewProps = {
|
|
6110
6192
|
diff: {
|
|
6111
6193
|
type: String,
|
|
@@ -6119,6 +6201,10 @@ const codeReviewProps = {
|
|
|
6119
6201
|
outputFormat: {
|
|
6120
6202
|
type: String,
|
|
6121
6203
|
default: "line-by-line"
|
|
6204
|
+
},
|
|
6205
|
+
expandAllThreshold: {
|
|
6206
|
+
type: Number,
|
|
6207
|
+
default: 50
|
|
6122
6208
|
}
|
|
6123
6209
|
};
|
|
6124
6210
|
const CodeReviewInjectionKey = Symbol("d-code-review");
|
|
@@ -6208,17 +6294,159 @@ var CodeReviewHeader = defineComponent({
|
|
|
6208
6294
|
}, [rootCtx.slots.headOperate()])]);
|
|
6209
6295
|
}
|
|
6210
6296
|
});
|
|
6297
|
+
const ExpandLineReg = /^@@ -(\d+),(\d+) \+(\d+),(\d+) @@/;
|
|
6298
|
+
const FirstLineReg = /^@@ -[0,1](?!\d)/;
|
|
6299
|
+
function notEmptyNode(node) {
|
|
6300
|
+
const classes = node.classList;
|
|
6301
|
+
return !classes.contains("d2h-info") && !classes.contains("d2h-emptyplaceholder") && !classes.contains("comment-cell");
|
|
6302
|
+
}
|
|
6303
|
+
function insertNode(parent, child) {
|
|
6304
|
+
if (parent.firstChild) {
|
|
6305
|
+
parent.insertBefore(child, parent.firstChild);
|
|
6306
|
+
} else {
|
|
6307
|
+
parent.appendChild(child);
|
|
6308
|
+
}
|
|
6309
|
+
}
|
|
6310
|
+
function addExpandButton(parentNode, className, icon) {
|
|
6311
|
+
const expandButton = document.createElement("div");
|
|
6312
|
+
expandButton.innerHTML = icon;
|
|
6313
|
+
expandButton.classList.add("expand-icon");
|
|
6314
|
+
expandButton.classList.add(className);
|
|
6315
|
+
insertNode(parentNode, expandButton);
|
|
6316
|
+
}
|
|
6317
|
+
function attachExpandUpDownButton(parentNode, direction) {
|
|
6318
|
+
var _a;
|
|
6319
|
+
const expandDirectionMap = {
|
|
6320
|
+
up: "up-expand",
|
|
6321
|
+
down: "down-expand",
|
|
6322
|
+
all: "all-expand"
|
|
6323
|
+
};
|
|
6324
|
+
const expandDirectionIconMap = {
|
|
6325
|
+
up: UpExpandIcon,
|
|
6326
|
+
down: DownExpandIcon,
|
|
6327
|
+
all: AllExpandIcon
|
|
6328
|
+
};
|
|
6329
|
+
parentNode.classList.add("expand-icon-wrapper");
|
|
6330
|
+
if (direction === "updown") {
|
|
6331
|
+
addExpandButton(parentNode, "up-expand", UpExpandIcon());
|
|
6332
|
+
addExpandButton(parentNode, "down-expand", DownExpandIcon());
|
|
6333
|
+
} else {
|
|
6334
|
+
addExpandButton(parentNode, expandDirectionMap[direction], (_a = expandDirectionIconMap[direction]) == null ? void 0 : _a.call(expandDirectionIconMap));
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
function addCommentToPage(lineHost, commentDom, lineSide) {
|
|
6338
|
+
var _a, _b;
|
|
6339
|
+
const newLine = document.createElement("tr");
|
|
6340
|
+
const newCell = document.createElement("td");
|
|
6341
|
+
newCell.classList.add("comment-cell");
|
|
6342
|
+
newCell.style.width = "100%";
|
|
6343
|
+
newCell.setAttribute("colspan", "2");
|
|
6344
|
+
newCell.appendChild(commentDom);
|
|
6345
|
+
newLine.classList.add("comment-block");
|
|
6346
|
+
newLine.classList.add(lineSide);
|
|
6347
|
+
newLine.appendChild(newCell);
|
|
6348
|
+
if (lineHost.nextElementSibling) {
|
|
6349
|
+
(_a = lineHost.parentElement) == null ? void 0 : _a.insertBefore(newLine, lineHost.nextElementSibling);
|
|
6350
|
+
} else {
|
|
6351
|
+
(_b = lineHost.parentElement) == null ? void 0 : _b.appendChild(newLine);
|
|
6352
|
+
}
|
|
6353
|
+
}
|
|
6354
|
+
function useCodeReviewExpand(reviewContentRef, expandAllThreshold, outputFormat) {
|
|
6355
|
+
const processSideBySide = () => {
|
|
6356
|
+
const [leftTable, rightTable] = reviewContentRef.value.querySelectorAll("table");
|
|
6357
|
+
const trNodes = Array.from(leftTable.querySelectorAll("tr"));
|
|
6358
|
+
const totalLines = trNodes.length;
|
|
6359
|
+
for (const index2 in trNodes) {
|
|
6360
|
+
const lineIndex = parseInt(index2);
|
|
6361
|
+
const lineChildren = Array.from(trNodes[lineIndex].children);
|
|
6362
|
+
const lineNumberBox = lineChildren[0];
|
|
6363
|
+
const lineContentBox = lineChildren[1];
|
|
6364
|
+
const lineClassList = lineContentBox.classList.value;
|
|
6365
|
+
const lineContent = lineContentBox.innerText.trim();
|
|
6366
|
+
if (lineContent.match(ExpandLineReg) && !FirstLineReg.test(lineContent) && lineClassList && lineClassList.includes("d2h-info")) {
|
|
6367
|
+
const nextLineIndex = lineIndex + 1;
|
|
6368
|
+
const prevLineIndex = lineIndex - 1;
|
|
6369
|
+
if (lineIndex === 0 && nextLineIndex in trNodes) {
|
|
6370
|
+
attachExpandUpDownButton(lineNumberBox, "up");
|
|
6371
|
+
} else if (lineIndex > 0 && lineIndex < totalLines - 1 && nextLineIndex in trNodes && prevLineIndex in trNodes) {
|
|
6372
|
+
const preLineChildren = Array.from(trNodes[prevLineIndex].children);
|
|
6373
|
+
const nextLineChildren = Array.from(trNodes[nextLineIndex].children);
|
|
6374
|
+
const isExpandAll = parseInt(nextLineChildren[0].innerText) - parseInt(preLineChildren[0].innerText) - 1 < expandAllThreshold;
|
|
6375
|
+
attachExpandUpDownButton(lineNumberBox, isExpandAll ? "all" : "updown");
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
}
|
|
6379
|
+
const endLine = trNodes[0].cloneNode(true);
|
|
6380
|
+
if (Object.prototype.hasOwnProperty.call(endLine.children[0].children, 0)) {
|
|
6381
|
+
endLine.children[0].removeChild(endLine.children[0].children[0]);
|
|
6382
|
+
}
|
|
6383
|
+
endLine.children[1].innerText = "";
|
|
6384
|
+
const leftEndLine = endLine.cloneNode(true);
|
|
6385
|
+
const rightEndLint = endLine.cloneNode(true);
|
|
6386
|
+
attachExpandUpDownButton(leftEndLine.children[0], "down");
|
|
6387
|
+
leftTable.tBodies[0].appendChild(leftEndLine);
|
|
6388
|
+
rightTable.tBodies[0].appendChild(rightEndLint);
|
|
6389
|
+
};
|
|
6390
|
+
const processLineByLine = () => {
|
|
6391
|
+
var _a;
|
|
6392
|
+
const trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr"));
|
|
6393
|
+
const totalLines = trNodes.length;
|
|
6394
|
+
for (const index2 in trNodes) {
|
|
6395
|
+
const lineIndex = parseInt(index2);
|
|
6396
|
+
const tdNodes = Array.from(trNodes[lineIndex].children);
|
|
6397
|
+
const lineNumberBox = tdNodes[0];
|
|
6398
|
+
const lineContentBox = tdNodes[1];
|
|
6399
|
+
if (!lineContentBox) {
|
|
6400
|
+
continue;
|
|
6401
|
+
}
|
|
6402
|
+
const lineClassList = lineContentBox.classList.value;
|
|
6403
|
+
const lineContent = lineContentBox.innerText.trim();
|
|
6404
|
+
if (lineContent.match(ExpandLineReg) && !FirstLineReg.test(lineContent) && lineClassList && lineClassList.includes("d2h-info")) {
|
|
6405
|
+
const nextLineIndex = lineIndex + 1;
|
|
6406
|
+
const prevLineIndex = lineIndex - 1;
|
|
6407
|
+
if (lineIndex === 0 && nextLineIndex in trNodes) {
|
|
6408
|
+
attachExpandUpDownButton(lineNumberBox, "up");
|
|
6409
|
+
} else if (lineIndex > 0 && lineIndex < totalLines - 1 && nextLineIndex in trNodes && prevLineIndex in trNodes) {
|
|
6410
|
+
const prevTdNodes = Array.from(trNodes[prevLineIndex].children);
|
|
6411
|
+
const prevLineNumber = parseInt(prevTdNodes[0].children[0].innerText);
|
|
6412
|
+
const nextTdNodes = Array.from(trNodes[nextLineIndex].children);
|
|
6413
|
+
const nextLineNumber = parseInt(nextTdNodes[0].children[0].innerText);
|
|
6414
|
+
const isExpandAll = nextLineNumber - prevLineNumber - 1 < expandAllThreshold;
|
|
6415
|
+
attachExpandUpDownButton(lineNumberBox, isExpandAll ? "all" : "updown");
|
|
6416
|
+
}
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6419
|
+
const loadMoreLine = trNodes[0].cloneNode(true);
|
|
6420
|
+
loadMoreLine.children[0].removeChild(loadMoreLine.children[0].children[0]);
|
|
6421
|
+
loadMoreLine.children[1].innerText = "";
|
|
6422
|
+
loadMoreLine.children[1].style.height = "20px";
|
|
6423
|
+
const lastTrNode = trNodes[totalLines - 1].children;
|
|
6424
|
+
const leftLineStart = parseInt(lastTrNode[0].children[0].innerText) + 1;
|
|
6425
|
+
const rightLineStart = parseInt(lastTrNode[0].children[1].innerText) + 1;
|
|
6426
|
+
if (leftLineStart && rightLineStart) {
|
|
6427
|
+
attachExpandUpDownButton(loadMoreLine.children[0], "down");
|
|
6428
|
+
}
|
|
6429
|
+
(_a = trNodes[0].parentElement) == null ? void 0 : _a.appendChild(loadMoreLine);
|
|
6430
|
+
};
|
|
6431
|
+
const insertExpandButton = () => {
|
|
6432
|
+
outputFormat === "side-by-side" ? processSideBySide() : processLineByLine();
|
|
6433
|
+
};
|
|
6434
|
+
return { insertExpandButton };
|
|
6435
|
+
}
|
|
6211
6436
|
function useCodeReview(props, ctx) {
|
|
6212
|
-
const { diff, fold, outputFormat } = toRefs(props);
|
|
6437
|
+
const { diff, fold, outputFormat, expandAllThreshold } = toRefs(props);
|
|
6213
6438
|
const renderHtml = ref("");
|
|
6214
6439
|
const isFold = ref(fold.value);
|
|
6440
|
+
const reviewContentRef = ref();
|
|
6215
6441
|
const diffFile = Diff2Html.parse(diff.value);
|
|
6442
|
+
const { insertExpandButton } = useCodeReviewExpand(reviewContentRef, expandAllThreshold.value, outputFormat.value);
|
|
6216
6443
|
const initDiffContent = () => {
|
|
6217
6444
|
renderHtml.value = Diff2Html.html(diffFile, {
|
|
6218
6445
|
drawFileList: false,
|
|
6219
6446
|
matching: "lines",
|
|
6220
6447
|
outputFormat: outputFormat.value
|
|
6221
6448
|
});
|
|
6449
|
+
nextTick(insertExpandButton);
|
|
6222
6450
|
};
|
|
6223
6451
|
const toggleFold = (status) => {
|
|
6224
6452
|
if (status !== void 0) {
|
|
@@ -6241,21 +6469,130 @@ function useCodeReview(props, ctx) {
|
|
|
6241
6469
|
initDiffContent();
|
|
6242
6470
|
}
|
|
6243
6471
|
});
|
|
6244
|
-
provide(CodeReviewInjectionKey, { diffInfo: diffFile[0], isFold, rootCtx: ctx });
|
|
6245
|
-
|
|
6246
|
-
|
|
6472
|
+
provide(CodeReviewInjectionKey, { reviewContentRef, diffInfo: diffFile[0], isFold, rootCtx: ctx });
|
|
6473
|
+
return { renderHtml, isFold, reviewContentRef, toggleFold };
|
|
6474
|
+
}
|
|
6475
|
+
function useCodeReviewComment(reviewContentRef, ctx) {
|
|
6476
|
+
const ns2 = useNamespace("code-review");
|
|
6477
|
+
const commentLeft = ref(-100);
|
|
6478
|
+
const commentTop = ref(-100);
|
|
6479
|
+
let currentLeftLineNumber = -1;
|
|
6480
|
+
let currentRightLineNumber = -1;
|
|
6481
|
+
const resetLeftTop = () => {
|
|
6482
|
+
commentLeft.value = -100;
|
|
6483
|
+
commentTop.value = -100;
|
|
6484
|
+
currentLeftLineNumber = -1;
|
|
6485
|
+
currentRightLineNumber = -1;
|
|
6486
|
+
};
|
|
6487
|
+
const onMouseEnter = (e) => {
|
|
6488
|
+
e.currentTarget.getBoundingClientRect();
|
|
6489
|
+
};
|
|
6490
|
+
const onMouseMove = (e) => {
|
|
6491
|
+
var _a, _b;
|
|
6492
|
+
const composedPath = e.composedPath();
|
|
6493
|
+
const trNode = composedPath.find((item) => item.tagName === "TR");
|
|
6494
|
+
if (trNode) {
|
|
6495
|
+
const lineNumberContainer = Array.from(trNode.children)[0];
|
|
6496
|
+
if (notEmptyNode(lineNumberContainer)) {
|
|
6497
|
+
const { top, left } = lineNumberContainer.getBoundingClientRect();
|
|
6498
|
+
commentLeft.value = left;
|
|
6499
|
+
commentTop.value = top;
|
|
6500
|
+
currentLeftLineNumber = parseInt((_a = lineNumberContainer.children[0]) == null ? void 0 : _a.innerText) || -1;
|
|
6501
|
+
currentRightLineNumber = parseInt((_b = lineNumberContainer.children[1]) == null ? void 0 : _b.innerText) || -1;
|
|
6502
|
+
} else {
|
|
6503
|
+
resetLeftTop();
|
|
6504
|
+
}
|
|
6505
|
+
}
|
|
6506
|
+
};
|
|
6507
|
+
const onMouseleave = (e) => {
|
|
6508
|
+
var _a;
|
|
6509
|
+
if (!((_a = e.relatedTarget) == null ? void 0 : _a.classList.contains("comment-icon"))) {
|
|
6510
|
+
resetLeftTop();
|
|
6511
|
+
}
|
|
6512
|
+
};
|
|
6513
|
+
const onCommentMouseLeave = (e) => {
|
|
6514
|
+
var _a;
|
|
6515
|
+
if (!((_a = e.relatedTarget) == null ? void 0 : _a.classList.contains(ns2.e("content")))) {
|
|
6516
|
+
resetLeftTop();
|
|
6517
|
+
}
|
|
6518
|
+
};
|
|
6519
|
+
const onCommentIconClick = () => {
|
|
6520
|
+
ctx.emit("addComment", { left: currentLeftLineNumber, right: currentRightLineNumber });
|
|
6521
|
+
};
|
|
6522
|
+
const findReferenceDom = (lineNumber, lineSide) => {
|
|
6523
|
+
var _a, _b, _c, _d;
|
|
6524
|
+
const trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr"));
|
|
6525
|
+
for (const index2 in trNodes) {
|
|
6526
|
+
const lineIndex = parseInt(index2);
|
|
6527
|
+
const lineNumberBox = Array.from(trNodes[lineIndex].children)[0];
|
|
6528
|
+
if (notEmptyNode(lineNumberBox)) {
|
|
6529
|
+
const oldLineNumber = parseInt((_b = (_a = lineNumberBox.children[0]) == null ? void 0 : _a.innerText) != null ? _b : -1);
|
|
6530
|
+
const newLineNumber = parseInt((_d = (_c = lineNumberBox.children[1]) == null ? void 0 : _c.innerText) != null ? _d : -1);
|
|
6531
|
+
if (lineSide === "left" && oldLineNumber === lineNumber || lineSide === "right" && newLineNumber === lineNumber) {
|
|
6532
|
+
return trNodes[lineIndex];
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6535
|
+
}
|
|
6536
|
+
};
|
|
6537
|
+
const insertComment = (lineNumber, lineSide, commentDom) => {
|
|
6538
|
+
const lineHost = findReferenceDom(lineNumber, lineSide);
|
|
6539
|
+
lineHost && addCommentToPage(lineHost, commentDom, lineSide);
|
|
6540
|
+
};
|
|
6541
|
+
const removeComment = (lineNumber, lineSide) => {
|
|
6542
|
+
const lineHost = findReferenceDom(lineNumber, lineSide);
|
|
6543
|
+
let nextLineHost = lineHost == null ? void 0 : lineHost.nextElementSibling;
|
|
6544
|
+
while (nextLineHost) {
|
|
6545
|
+
const classList = nextLineHost == null ? void 0 : nextLineHost.classList;
|
|
6546
|
+
if ((classList == null ? void 0 : classList.contains("comment-block")) && classList.contains(lineSide)) {
|
|
6547
|
+
nextLineHost.remove();
|
|
6548
|
+
return;
|
|
6549
|
+
}
|
|
6550
|
+
nextLineHost = nextLineHost.nextElementSibling;
|
|
6551
|
+
}
|
|
6552
|
+
};
|
|
6553
|
+
return {
|
|
6554
|
+
commentLeft,
|
|
6555
|
+
commentTop,
|
|
6556
|
+
onMouseEnter,
|
|
6557
|
+
onMouseMove,
|
|
6558
|
+
onMouseleave,
|
|
6559
|
+
onCommentMouseLeave,
|
|
6560
|
+
onCommentIconClick,
|
|
6561
|
+
insertComment,
|
|
6562
|
+
removeComment
|
|
6563
|
+
};
|
|
6247
6564
|
}
|
|
6248
6565
|
var codeReview = "";
|
|
6249
6566
|
var CodeReview = defineComponent({
|
|
6250
6567
|
name: "DCodeReview",
|
|
6251
6568
|
props: codeReviewProps,
|
|
6252
|
-
emits: ["foldChange"],
|
|
6569
|
+
emits: ["foldChange", "addComment", "afterViewInit"],
|
|
6253
6570
|
setup(props, ctx) {
|
|
6254
6571
|
const ns2 = useNamespace("code-review");
|
|
6255
6572
|
const {
|
|
6256
6573
|
renderHtml,
|
|
6257
|
-
isFold
|
|
6574
|
+
isFold,
|
|
6575
|
+
reviewContentRef,
|
|
6576
|
+
toggleFold
|
|
6258
6577
|
} = useCodeReview(props, ctx);
|
|
6578
|
+
const {
|
|
6579
|
+
commentLeft,
|
|
6580
|
+
commentTop,
|
|
6581
|
+
onMouseEnter,
|
|
6582
|
+
onMouseMove,
|
|
6583
|
+
onMouseleave,
|
|
6584
|
+
onCommentMouseLeave,
|
|
6585
|
+
onCommentIconClick,
|
|
6586
|
+
insertComment,
|
|
6587
|
+
removeComment
|
|
6588
|
+
} = useCodeReviewComment(reviewContentRef, ctx);
|
|
6589
|
+
onMounted(() => {
|
|
6590
|
+
ctx.emit("afterViewInit", {
|
|
6591
|
+
toggleFold,
|
|
6592
|
+
insertComment,
|
|
6593
|
+
removeComment
|
|
6594
|
+
});
|
|
6595
|
+
});
|
|
6259
6596
|
return () => createVNode("div", {
|
|
6260
6597
|
"class": ns2.b()
|
|
6261
6598
|
}, [createVNode(CodeReviewHeader, {
|
|
@@ -6264,8 +6601,20 @@ var CodeReview = defineComponent({
|
|
|
6264
6601
|
"class": [ns2.e("content"), {
|
|
6265
6602
|
"hide-content": isFold.value
|
|
6266
6603
|
}],
|
|
6267
|
-
"innerHTML": renderHtml.value
|
|
6268
|
-
|
|
6604
|
+
"innerHTML": renderHtml.value,
|
|
6605
|
+
"ref": reviewContentRef,
|
|
6606
|
+
"onMouseenter": onMouseEnter,
|
|
6607
|
+
"onMousemove": onMouseMove,
|
|
6608
|
+
"onMouseleave": onMouseleave
|
|
6609
|
+
}, null), createVNode("div", {
|
|
6610
|
+
"class": "comment-icon",
|
|
6611
|
+
"style": {
|
|
6612
|
+
left: commentLeft.value + "px",
|
|
6613
|
+
top: commentTop.value + "px"
|
|
6614
|
+
},
|
|
6615
|
+
"onClick": onCommentIconClick,
|
|
6616
|
+
"onMouseleave": onCommentMouseLeave
|
|
6617
|
+
}, [createVNode(CommentIcon, null, null)])]);
|
|
6269
6618
|
}
|
|
6270
6619
|
});
|
|
6271
6620
|
var index = {
|