vue-devui 1.6.20 → 1.6.21
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/breadcrumb/index.es.js +6 -2
- package/breadcrumb/index.umd.js +2 -2
- package/category-search/index.es.js +6 -2
- package/category-search/index.umd.js +17 -17
- package/code-review/index.es.js +185 -9
- package/code-review/index.umd.js +27 -27
- package/code-review/style.css +1 -1
- package/data-grid/index.es.js +6 -2
- package/data-grid/index.umd.js +11 -11
- package/dropdown/index.es.js +6 -2
- package/dropdown/index.umd.js +2 -2
- package/editor-md/index.es.js +6 -2
- package/editor-md/index.umd.js +35 -35
- package/global.d.ts +0 -1
- package/package.json +1 -1
- package/pagination/index.es.js +6 -2
- package/pagination/index.umd.js +12 -12
- package/style.css +1 -1
- package/table/index.es.js +6 -2
- package/table/index.umd.js +11 -11
- package/tree/index.es.js +2 -2
- package/tree/index.umd.js +1 -1
- package/types/code-review/src/code-review-types.d.ts +4 -0
- package/types/code-review/src/composables/use-code-review-comment.d.ts +3 -0
- package/vue-devui.es.js +193 -13
- package/vue-devui.umd.js +82 -82
package/code-review/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, computed, nextTick, unref, withModifiers, Comment, Text, Fragment, h, inject, withDirectives, cloneVNode, onMounted, provide, Teleport, createTextVNode, vShow } from "vue";
|
|
1
|
+
import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, computed, nextTick, unref, withModifiers, Comment, Text, Fragment, h, inject, withDirectives, cloneVNode, onMounted, provide, Teleport, createTextVNode, onBeforeUnmount, vShow } from "vue";
|
|
2
2
|
import { offset, flip, arrow, computePosition } from "@floating-ui/dom";
|
|
3
3
|
import Clipboard from "clipboard";
|
|
4
4
|
import * as Diff2Html from "diff2html";
|
|
@@ -6258,6 +6258,10 @@ const codeReviewProps = {
|
|
|
6258
6258
|
type: Boolean,
|
|
6259
6259
|
default: true
|
|
6260
6260
|
},
|
|
6261
|
+
allowChecked: {
|
|
6262
|
+
type: Boolean,
|
|
6263
|
+
default: false
|
|
6264
|
+
},
|
|
6261
6265
|
allowExpand: {
|
|
6262
6266
|
type: Boolean,
|
|
6263
6267
|
default: true
|
|
@@ -6513,6 +6517,17 @@ function updateExpandLineCount(expandDom, newExpandDom) {
|
|
|
6513
6517
|
const newChangedNumRight = parseInt((curMatches == null ? void 0 : curMatches[4]) || "") + parseInt((newMatches == null ? void 0 : newMatches[4]) || "");
|
|
6514
6518
|
expandDom.children[1].children[0].innerText = `@@ -${(newMatches == null ? void 0 : newMatches[1]) || 0},${newChangedNumLeft} +${(newMatches == null ? void 0 : newMatches[3]) || 0},${newChangedNumRight} @@`;
|
|
6515
6519
|
}
|
|
6520
|
+
function addClassToDiffCode(codeStrArr, theClassName) {
|
|
6521
|
+
if (!codeStrArr || codeStrArr.length === 0) {
|
|
6522
|
+
return null;
|
|
6523
|
+
}
|
|
6524
|
+
const newArray = codeStrArr.map((item) => {
|
|
6525
|
+
const classNames = item == null ? void 0 : item.match(/class="([^"]+)"/)[1].split(" ");
|
|
6526
|
+
classNames.push(theClassName);
|
|
6527
|
+
return item.replace(/class="([^"]+)"/, `class="${classNames.join(" ")}"`);
|
|
6528
|
+
});
|
|
6529
|
+
return newArray;
|
|
6530
|
+
}
|
|
6516
6531
|
function parseDiffCode(container, code, outputFormat, isAddCode = false) {
|
|
6517
6532
|
var _a;
|
|
6518
6533
|
const diff2HtmlUi = new Diff2HtmlUI(container, code, {
|
|
@@ -6532,8 +6547,10 @@ function parseDiffCode(container, code, outputFormat, isAddCode = false) {
|
|
|
6532
6547
|
let newTrStr = "";
|
|
6533
6548
|
const offset2 = trListLength / 2;
|
|
6534
6549
|
for (let i = 0; i < trListLength / 2; i++) {
|
|
6535
|
-
|
|
6536
|
-
|
|
6550
|
+
let leftTdList = trList[i].match(TableTdReg);
|
|
6551
|
+
let rightTdList = trList[i + offset2].match(TableTdReg);
|
|
6552
|
+
leftTdList = addClassToDiffCode(leftTdList, "d-code-left");
|
|
6553
|
+
rightTdList = addClassToDiffCode(rightTdList, "d-code-right");
|
|
6537
6554
|
newTrStr += `<tr>${leftTdList == null ? void 0 : leftTdList.join("")}${rightTdList == null ? void 0 : rightTdList.join("")}</tr>`;
|
|
6538
6555
|
}
|
|
6539
6556
|
const tbodyAttr = ((_a = diffHtmlStr.match(TableTbodyAttrReg)) == null ? void 0 : _a[1]) || "";
|
|
@@ -7010,13 +7027,24 @@ function useCodeReviewFold(props, ctx) {
|
|
|
7010
7027
|
return { isFold, toggleFold };
|
|
7011
7028
|
}
|
|
7012
7029
|
function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
7013
|
-
const { outputFormat, allowComment } = toRefs(props);
|
|
7030
|
+
const { outputFormat, allowComment, allowChecked } = toRefs(props);
|
|
7014
7031
|
const ns2 = useNamespace("code-review");
|
|
7015
7032
|
const commentLeft = ref(-100);
|
|
7016
7033
|
const commentTop = ref(-100);
|
|
7017
7034
|
let currentLeftLineNumber = -1;
|
|
7018
7035
|
let currentRightLineNumber = -1;
|
|
7019
7036
|
let lastLineNumberContainer;
|
|
7037
|
+
let checkedLineNumberContainer = [];
|
|
7038
|
+
let isShift = false;
|
|
7039
|
+
let currentLeftLineNumbers = [];
|
|
7040
|
+
let currentRightLineNumbers = [];
|
|
7041
|
+
let checkedLineCodeString = {};
|
|
7042
|
+
watch(() => outputFormat.value, () => {
|
|
7043
|
+
checkedLineNumberContainer = [];
|
|
7044
|
+
currentLeftLineNumbers = [];
|
|
7045
|
+
currentRightLineNumbers = [];
|
|
7046
|
+
checkedLineCodeString = [];
|
|
7047
|
+
});
|
|
7020
7048
|
const resetLeftTop = () => {
|
|
7021
7049
|
commentLeft.value = -100;
|
|
7022
7050
|
commentTop.value = -100;
|
|
@@ -7099,6 +7127,141 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
|
7099
7127
|
resetLeftTop();
|
|
7100
7128
|
}
|
|
7101
7129
|
};
|
|
7130
|
+
function commentKeyDown(e) {
|
|
7131
|
+
switch (e.key) {
|
|
7132
|
+
case "Shift":
|
|
7133
|
+
isShift = true;
|
|
7134
|
+
break;
|
|
7135
|
+
}
|
|
7136
|
+
}
|
|
7137
|
+
function commentKeyUp(e) {
|
|
7138
|
+
e.preventDefault();
|
|
7139
|
+
switch (e.key) {
|
|
7140
|
+
case "Shift":
|
|
7141
|
+
isShift = false;
|
|
7142
|
+
break;
|
|
7143
|
+
}
|
|
7144
|
+
}
|
|
7145
|
+
const unCommentKeyDown = () => {
|
|
7146
|
+
document.removeEventListener("keydown", commentKeyDown);
|
|
7147
|
+
document.removeEventListener("keyup", commentKeyUp);
|
|
7148
|
+
};
|
|
7149
|
+
const onCommentKeyDown = () => {
|
|
7150
|
+
document.addEventListener("keydown", commentKeyDown);
|
|
7151
|
+
document.addEventListener("keyup", commentKeyUp);
|
|
7152
|
+
};
|
|
7153
|
+
const getLineNumbers = (currentNumber, currentNumbers, e) => {
|
|
7154
|
+
if (currentNumber === -1) {
|
|
7155
|
+
return currentNumbers;
|
|
7156
|
+
}
|
|
7157
|
+
if (currentNumbers.length === 0) {
|
|
7158
|
+
return [currentNumber];
|
|
7159
|
+
}
|
|
7160
|
+
const numbers = [...currentNumbers];
|
|
7161
|
+
let max = Math.max(...numbers);
|
|
7162
|
+
const min = Math.min(...numbers);
|
|
7163
|
+
if (currentNumber > max) {
|
|
7164
|
+
max = currentNumber;
|
|
7165
|
+
}
|
|
7166
|
+
return Array.from({ length: max - min + 1 }, (_, i) => i + min);
|
|
7167
|
+
};
|
|
7168
|
+
const getCommonClassAndJudge = (side) => {
|
|
7169
|
+
const lineClassName = side === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
|
|
7170
|
+
const linenumberDom = reviewContentRef.value.querySelectorAll(lineClassName);
|
|
7171
|
+
const checkedLine = [currentLeftLineNumbers, currentRightLineNumbers];
|
|
7172
|
+
return {
|
|
7173
|
+
linenumberDom,
|
|
7174
|
+
checkedLine
|
|
7175
|
+
};
|
|
7176
|
+
};
|
|
7177
|
+
const addCommentCheckedClass = (Dom) => {
|
|
7178
|
+
!Dom.classList.contains("comment-checked") && Dom.classList.add("comment-checked");
|
|
7179
|
+
};
|
|
7180
|
+
const addCommentClassSingle = (side) => {
|
|
7181
|
+
const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
|
|
7182
|
+
const checkedCodeContent = [];
|
|
7183
|
+
for (let i = 0; i < linenumberDom.length; i++) {
|
|
7184
|
+
const lineNumberDomLeft = linenumberDom[i].children[0];
|
|
7185
|
+
const lineNumberDomRight = linenumberDom[i].children[1];
|
|
7186
|
+
if (lineNumberDomLeft || lineNumberDomRight) {
|
|
7187
|
+
const codeLineNumberLeft = parseInt(lineNumberDomLeft == null ? void 0 : lineNumberDomLeft.innerText);
|
|
7188
|
+
const codeLineNumberRight = parseInt(lineNumberDomRight == null ? void 0 : lineNumberDomRight.innerText);
|
|
7189
|
+
if (checkedLine[0].includes(codeLineNumberLeft) || checkedLine[1].includes(codeLineNumberRight)) {
|
|
7190
|
+
checkedLineNumberContainer.push(linenumberDom[i]);
|
|
7191
|
+
const codeNode = linenumberDom[i].nextSibling.nodeName === "#text" ? linenumberDom[i].nextSibling.nextSibling : linenumberDom[i].nextSibling;
|
|
7192
|
+
checkedCodeContent.push(codeNode == null ? void 0 : codeNode.innerText);
|
|
7193
|
+
addCommentCheckedClass(linenumberDom[i]);
|
|
7194
|
+
addCommentCheckedClass(codeNode);
|
|
7195
|
+
}
|
|
7196
|
+
}
|
|
7197
|
+
}
|
|
7198
|
+
checkedLineCodeString = checkedCodeContent;
|
|
7199
|
+
};
|
|
7200
|
+
const addCommentClassDouble = (side) => {
|
|
7201
|
+
var _a;
|
|
7202
|
+
const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
|
|
7203
|
+
const checkedCodeContentLeft = [];
|
|
7204
|
+
const checkedCodeContentRight = [];
|
|
7205
|
+
function checkedFunc(Dom) {
|
|
7206
|
+
checkedLineNumberContainer.push(Dom);
|
|
7207
|
+
const codeNode = Dom.nextSibling.nodeName === "#text" ? Dom.nextSibling.nextSibling : Dom.nextSibling;
|
|
7208
|
+
addCommentCheckedClass(Dom);
|
|
7209
|
+
addCommentCheckedClass(codeNode);
|
|
7210
|
+
return codeNode == null ? void 0 : codeNode.innerText;
|
|
7211
|
+
}
|
|
7212
|
+
for (let i = 0; i < linenumberDom.length; i++) {
|
|
7213
|
+
const codeLineNumber = parseInt((_a = linenumberDom[i]) == null ? void 0 : _a.innerHTML);
|
|
7214
|
+
if (linenumberDom[i].classList.contains("d-code-left") && checkedLine[0].includes(codeLineNumber)) {
|
|
7215
|
+
const lineNumText = checkedFunc(linenumberDom[i]);
|
|
7216
|
+
checkedCodeContentLeft.push(lineNumText);
|
|
7217
|
+
continue;
|
|
7218
|
+
}
|
|
7219
|
+
if (linenumberDom[i].classList.contains("d-code-right") && checkedLine[1].includes(codeLineNumber)) {
|
|
7220
|
+
const lineNumText = checkedFunc(linenumberDom[i]);
|
|
7221
|
+
checkedCodeContentRight.push(lineNumText);
|
|
7222
|
+
}
|
|
7223
|
+
}
|
|
7224
|
+
checkedLineCodeString = { leftCode: checkedCodeContentLeft, rightCode: checkedCodeContentRight };
|
|
7225
|
+
};
|
|
7226
|
+
const updateCheckedLineClass = () => {
|
|
7227
|
+
if (outputFormat.value === "line-by-line") {
|
|
7228
|
+
addCommentClassSingle(outputFormat.value);
|
|
7229
|
+
return;
|
|
7230
|
+
}
|
|
7231
|
+
addCommentClassDouble(outputFormat.value);
|
|
7232
|
+
};
|
|
7233
|
+
const resetCommentClass = () => {
|
|
7234
|
+
for (let i = 0; i < checkedLineNumberContainer.length; i++) {
|
|
7235
|
+
checkedLineNumberContainer[i].classList.remove("comment-checked");
|
|
7236
|
+
const codeNode = checkedLineNumberContainer[i].nextSibling.nodeName === "#text" ? checkedLineNumberContainer[i].nextSibling.nextSibling : checkedLineNumberContainer[i].nextSibling;
|
|
7237
|
+
codeNode == null ? void 0 : codeNode.classList.remove("comment-checked");
|
|
7238
|
+
}
|
|
7239
|
+
checkedLineNumberContainer = [];
|
|
7240
|
+
};
|
|
7241
|
+
const commentShiftClick = (e) => {
|
|
7242
|
+
currentLeftLineNumbers = currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers);
|
|
7243
|
+
currentRightLineNumbers = currentRightLineNumber === -1 ? currentRightLineNumbers : getLineNumbers(currentRightLineNumber, currentRightLineNumbers);
|
|
7244
|
+
updateCheckedLineClass();
|
|
7245
|
+
};
|
|
7246
|
+
const commentClick = (e) => {
|
|
7247
|
+
let obj = { left: currentLeftLineNumber, right: currentRightLineNumber };
|
|
7248
|
+
if (currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1 && allowChecked.value) {
|
|
7249
|
+
const maxCurrentLeftLineNumber = currentLeftLineNumbers[currentLeftLineNumbers.length - 1];
|
|
7250
|
+
const maxCurrentRightLineNumber = currentRightLineNumbers[currentRightLineNumbers.length - 1];
|
|
7251
|
+
if (maxCurrentLeftLineNumber === currentLeftLineNumber || maxCurrentRightLineNumber === currentRightLineNumber) {
|
|
7252
|
+
obj = { left: currentLeftLineNumber, right: currentRightLineNumber, details: {
|
|
7253
|
+
lefts: currentLeftLineNumbers,
|
|
7254
|
+
rights: currentRightLineNumbers,
|
|
7255
|
+
codes: checkedLineCodeString
|
|
7256
|
+
} };
|
|
7257
|
+
} else {
|
|
7258
|
+
currentLeftLineNumbers = [];
|
|
7259
|
+
currentRightLineNumbers = [];
|
|
7260
|
+
resetCommentClass();
|
|
7261
|
+
}
|
|
7262
|
+
}
|
|
7263
|
+
ctx.emit("addComment", obj);
|
|
7264
|
+
};
|
|
7102
7265
|
const onCommentIconClick = (e) => {
|
|
7103
7266
|
if (e) {
|
|
7104
7267
|
const composedPath = e.composedPath();
|
|
@@ -7112,9 +7275,11 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
|
7112
7275
|
return;
|
|
7113
7276
|
}
|
|
7114
7277
|
}
|
|
7115
|
-
if (
|
|
7116
|
-
;
|
|
7117
|
-
|
|
7278
|
+
if (isShift && allowChecked.value) {
|
|
7279
|
+
commentShiftClick();
|
|
7280
|
+
return;
|
|
7281
|
+
}
|
|
7282
|
+
commentClick();
|
|
7118
7283
|
};
|
|
7119
7284
|
const insertComment = (lineNumber, lineSide, commentDom) => {
|
|
7120
7285
|
if (outputFormat.value === "line-by-line") {
|
|
@@ -7163,8 +7328,11 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
|
7163
7328
|
commentLeft,
|
|
7164
7329
|
commentTop,
|
|
7165
7330
|
mouseEvent,
|
|
7331
|
+
updateCheckedLineClass,
|
|
7166
7332
|
onCommentMouseLeave,
|
|
7167
7333
|
onCommentIconClick,
|
|
7334
|
+
onCommentKeyDown,
|
|
7335
|
+
unCommentKeyDown,
|
|
7168
7336
|
insertComment,
|
|
7169
7337
|
removeComment
|
|
7170
7338
|
};
|
|
@@ -7195,15 +7363,23 @@ var CodeReview = defineComponent({
|
|
|
7195
7363
|
mouseEvent,
|
|
7196
7364
|
onCommentMouseLeave,
|
|
7197
7365
|
onCommentIconClick,
|
|
7366
|
+
onCommentKeyDown,
|
|
7367
|
+
unCommentKeyDown,
|
|
7198
7368
|
insertComment,
|
|
7199
|
-
removeComment
|
|
7369
|
+
removeComment,
|
|
7370
|
+
updateCheckedLineClass
|
|
7200
7371
|
} = useCodeReviewComment(reviewContentRef, props, ctx);
|
|
7201
7372
|
onMounted(() => {
|
|
7202
7373
|
ctx.emit("afterViewInit", {
|
|
7203
7374
|
toggleFold,
|
|
7204
7375
|
insertComment,
|
|
7205
|
-
removeComment
|
|
7376
|
+
removeComment,
|
|
7377
|
+
updateCheckedLineClass
|
|
7206
7378
|
});
|
|
7379
|
+
onCommentKeyDown();
|
|
7380
|
+
});
|
|
7381
|
+
onBeforeUnmount(() => {
|
|
7382
|
+
unCommentKeyDown();
|
|
7207
7383
|
});
|
|
7208
7384
|
provide(CodeReviewInjectionKey, {
|
|
7209
7385
|
diffType,
|