vue-devui 1.6.20 → 1.6.22
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 +186 -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 +11 -11
- package/editor-md/index.umd.js +40 -44
- 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/types/editor-md/src/icons-config.d.ts +1 -1
- package/vue-devui.es.js +199 -22
- package/vue-devui.umd.js +85 -89
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, {
|
|
@@ -6520,6 +6535,7 @@ function parseDiffCode(container, code, outputFormat, isAddCode = false) {
|
|
|
6520
6535
|
matching: "lines",
|
|
6521
6536
|
outputFormat,
|
|
6522
6537
|
highlight: true,
|
|
6538
|
+
diffStyle: "char",
|
|
6523
6539
|
rawTemplates: TemplateMap[outputFormat]
|
|
6524
6540
|
});
|
|
6525
6541
|
if (outputFormat === "side-by-side") {
|
|
@@ -6532,8 +6548,10 @@ function parseDiffCode(container, code, outputFormat, isAddCode = false) {
|
|
|
6532
6548
|
let newTrStr = "";
|
|
6533
6549
|
const offset2 = trListLength / 2;
|
|
6534
6550
|
for (let i = 0; i < trListLength / 2; i++) {
|
|
6535
|
-
|
|
6536
|
-
|
|
6551
|
+
let leftTdList = trList[i].match(TableTdReg);
|
|
6552
|
+
let rightTdList = trList[i + offset2].match(TableTdReg);
|
|
6553
|
+
leftTdList = addClassToDiffCode(leftTdList, "d-code-left");
|
|
6554
|
+
rightTdList = addClassToDiffCode(rightTdList, "d-code-right");
|
|
6537
6555
|
newTrStr += `<tr>${leftTdList == null ? void 0 : leftTdList.join("")}${rightTdList == null ? void 0 : rightTdList.join("")}</tr>`;
|
|
6538
6556
|
}
|
|
6539
6557
|
const tbodyAttr = ((_a = diffHtmlStr.match(TableTbodyAttrReg)) == null ? void 0 : _a[1]) || "";
|
|
@@ -7010,13 +7028,24 @@ function useCodeReviewFold(props, ctx) {
|
|
|
7010
7028
|
return { isFold, toggleFold };
|
|
7011
7029
|
}
|
|
7012
7030
|
function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
7013
|
-
const { outputFormat, allowComment } = toRefs(props);
|
|
7031
|
+
const { outputFormat, allowComment, allowChecked } = toRefs(props);
|
|
7014
7032
|
const ns2 = useNamespace("code-review");
|
|
7015
7033
|
const commentLeft = ref(-100);
|
|
7016
7034
|
const commentTop = ref(-100);
|
|
7017
7035
|
let currentLeftLineNumber = -1;
|
|
7018
7036
|
let currentRightLineNumber = -1;
|
|
7019
7037
|
let lastLineNumberContainer;
|
|
7038
|
+
let checkedLineNumberContainer = [];
|
|
7039
|
+
let isShift = false;
|
|
7040
|
+
let currentLeftLineNumbers = [];
|
|
7041
|
+
let currentRightLineNumbers = [];
|
|
7042
|
+
let checkedLineCodeString = {};
|
|
7043
|
+
watch(() => outputFormat.value, () => {
|
|
7044
|
+
checkedLineNumberContainer = [];
|
|
7045
|
+
currentLeftLineNumbers = [];
|
|
7046
|
+
currentRightLineNumbers = [];
|
|
7047
|
+
checkedLineCodeString = [];
|
|
7048
|
+
});
|
|
7020
7049
|
const resetLeftTop = () => {
|
|
7021
7050
|
commentLeft.value = -100;
|
|
7022
7051
|
commentTop.value = -100;
|
|
@@ -7099,6 +7128,141 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
|
7099
7128
|
resetLeftTop();
|
|
7100
7129
|
}
|
|
7101
7130
|
};
|
|
7131
|
+
function commentKeyDown(e) {
|
|
7132
|
+
switch (e.key) {
|
|
7133
|
+
case "Shift":
|
|
7134
|
+
isShift = true;
|
|
7135
|
+
break;
|
|
7136
|
+
}
|
|
7137
|
+
}
|
|
7138
|
+
function commentKeyUp(e) {
|
|
7139
|
+
e.preventDefault();
|
|
7140
|
+
switch (e.key) {
|
|
7141
|
+
case "Shift":
|
|
7142
|
+
isShift = false;
|
|
7143
|
+
break;
|
|
7144
|
+
}
|
|
7145
|
+
}
|
|
7146
|
+
const unCommentKeyDown = () => {
|
|
7147
|
+
document.removeEventListener("keydown", commentKeyDown);
|
|
7148
|
+
document.removeEventListener("keyup", commentKeyUp);
|
|
7149
|
+
};
|
|
7150
|
+
const onCommentKeyDown = () => {
|
|
7151
|
+
document.addEventListener("keydown", commentKeyDown);
|
|
7152
|
+
document.addEventListener("keyup", commentKeyUp);
|
|
7153
|
+
};
|
|
7154
|
+
const getLineNumbers = (currentNumber, currentNumbers, e) => {
|
|
7155
|
+
if (currentNumber === -1) {
|
|
7156
|
+
return currentNumbers;
|
|
7157
|
+
}
|
|
7158
|
+
if (currentNumbers.length === 0) {
|
|
7159
|
+
return [currentNumber];
|
|
7160
|
+
}
|
|
7161
|
+
const numbers = [...currentNumbers];
|
|
7162
|
+
let max = Math.max(...numbers);
|
|
7163
|
+
const min = Math.min(...numbers);
|
|
7164
|
+
if (currentNumber > max) {
|
|
7165
|
+
max = currentNumber;
|
|
7166
|
+
}
|
|
7167
|
+
return Array.from({ length: max - min + 1 }, (_, i) => i + min);
|
|
7168
|
+
};
|
|
7169
|
+
const getCommonClassAndJudge = (side) => {
|
|
7170
|
+
const lineClassName = side === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
|
|
7171
|
+
const linenumberDom = reviewContentRef.value.querySelectorAll(lineClassName);
|
|
7172
|
+
const checkedLine = [currentLeftLineNumbers, currentRightLineNumbers];
|
|
7173
|
+
return {
|
|
7174
|
+
linenumberDom,
|
|
7175
|
+
checkedLine
|
|
7176
|
+
};
|
|
7177
|
+
};
|
|
7178
|
+
const addCommentCheckedClass = (Dom) => {
|
|
7179
|
+
!Dom.classList.contains("comment-checked") && Dom.classList.add("comment-checked");
|
|
7180
|
+
};
|
|
7181
|
+
const addCommentClassSingle = (side) => {
|
|
7182
|
+
const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
|
|
7183
|
+
const checkedCodeContent = [];
|
|
7184
|
+
for (let i = 0; i < linenumberDom.length; i++) {
|
|
7185
|
+
const lineNumberDomLeft = linenumberDom[i].children[0];
|
|
7186
|
+
const lineNumberDomRight = linenumberDom[i].children[1];
|
|
7187
|
+
if (lineNumberDomLeft || lineNumberDomRight) {
|
|
7188
|
+
const codeLineNumberLeft = parseInt(lineNumberDomLeft == null ? void 0 : lineNumberDomLeft.innerText);
|
|
7189
|
+
const codeLineNumberRight = parseInt(lineNumberDomRight == null ? void 0 : lineNumberDomRight.innerText);
|
|
7190
|
+
if (checkedLine[0].includes(codeLineNumberLeft) || checkedLine[1].includes(codeLineNumberRight)) {
|
|
7191
|
+
checkedLineNumberContainer.push(linenumberDom[i]);
|
|
7192
|
+
const codeNode = linenumberDom[i].nextSibling.nodeName === "#text" ? linenumberDom[i].nextSibling.nextSibling : linenumberDom[i].nextSibling;
|
|
7193
|
+
checkedCodeContent.push(codeNode == null ? void 0 : codeNode.innerText);
|
|
7194
|
+
addCommentCheckedClass(linenumberDom[i]);
|
|
7195
|
+
addCommentCheckedClass(codeNode);
|
|
7196
|
+
}
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
7199
|
+
checkedLineCodeString = checkedCodeContent;
|
|
7200
|
+
};
|
|
7201
|
+
const addCommentClassDouble = (side) => {
|
|
7202
|
+
var _a;
|
|
7203
|
+
const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
|
|
7204
|
+
const checkedCodeContentLeft = [];
|
|
7205
|
+
const checkedCodeContentRight = [];
|
|
7206
|
+
function checkedFunc(Dom) {
|
|
7207
|
+
checkedLineNumberContainer.push(Dom);
|
|
7208
|
+
const codeNode = Dom.nextSibling.nodeName === "#text" ? Dom.nextSibling.nextSibling : Dom.nextSibling;
|
|
7209
|
+
addCommentCheckedClass(Dom);
|
|
7210
|
+
addCommentCheckedClass(codeNode);
|
|
7211
|
+
return codeNode == null ? void 0 : codeNode.innerText;
|
|
7212
|
+
}
|
|
7213
|
+
for (let i = 0; i < linenumberDom.length; i++) {
|
|
7214
|
+
const codeLineNumber = parseInt((_a = linenumberDom[i]) == null ? void 0 : _a.innerHTML);
|
|
7215
|
+
if (linenumberDom[i].classList.contains("d-code-left") && checkedLine[0].includes(codeLineNumber)) {
|
|
7216
|
+
const lineNumText = checkedFunc(linenumberDom[i]);
|
|
7217
|
+
checkedCodeContentLeft.push(lineNumText);
|
|
7218
|
+
continue;
|
|
7219
|
+
}
|
|
7220
|
+
if (linenumberDom[i].classList.contains("d-code-right") && checkedLine[1].includes(codeLineNumber)) {
|
|
7221
|
+
const lineNumText = checkedFunc(linenumberDom[i]);
|
|
7222
|
+
checkedCodeContentRight.push(lineNumText);
|
|
7223
|
+
}
|
|
7224
|
+
}
|
|
7225
|
+
checkedLineCodeString = { leftCode: checkedCodeContentLeft, rightCode: checkedCodeContentRight };
|
|
7226
|
+
};
|
|
7227
|
+
const updateCheckedLineClass = () => {
|
|
7228
|
+
if (outputFormat.value === "line-by-line") {
|
|
7229
|
+
addCommentClassSingle(outputFormat.value);
|
|
7230
|
+
return;
|
|
7231
|
+
}
|
|
7232
|
+
addCommentClassDouble(outputFormat.value);
|
|
7233
|
+
};
|
|
7234
|
+
const resetCommentClass = () => {
|
|
7235
|
+
for (let i = 0; i < checkedLineNumberContainer.length; i++) {
|
|
7236
|
+
checkedLineNumberContainer[i].classList.remove("comment-checked");
|
|
7237
|
+
const codeNode = checkedLineNumberContainer[i].nextSibling.nodeName === "#text" ? checkedLineNumberContainer[i].nextSibling.nextSibling : checkedLineNumberContainer[i].nextSibling;
|
|
7238
|
+
codeNode == null ? void 0 : codeNode.classList.remove("comment-checked");
|
|
7239
|
+
}
|
|
7240
|
+
checkedLineNumberContainer = [];
|
|
7241
|
+
};
|
|
7242
|
+
const commentShiftClick = (e) => {
|
|
7243
|
+
currentLeftLineNumbers = currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers);
|
|
7244
|
+
currentRightLineNumbers = currentRightLineNumber === -1 ? currentRightLineNumbers : getLineNumbers(currentRightLineNumber, currentRightLineNumbers);
|
|
7245
|
+
updateCheckedLineClass();
|
|
7246
|
+
};
|
|
7247
|
+
const commentClick = (e) => {
|
|
7248
|
+
let obj = { left: currentLeftLineNumber, right: currentRightLineNumber };
|
|
7249
|
+
if (currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1 && allowChecked.value) {
|
|
7250
|
+
const maxCurrentLeftLineNumber = currentLeftLineNumbers[currentLeftLineNumbers.length - 1];
|
|
7251
|
+
const maxCurrentRightLineNumber = currentRightLineNumbers[currentRightLineNumbers.length - 1];
|
|
7252
|
+
if (maxCurrentLeftLineNumber === currentLeftLineNumber || maxCurrentRightLineNumber === currentRightLineNumber) {
|
|
7253
|
+
obj = { left: currentLeftLineNumber, right: currentRightLineNumber, details: {
|
|
7254
|
+
lefts: currentLeftLineNumbers,
|
|
7255
|
+
rights: currentRightLineNumbers,
|
|
7256
|
+
codes: checkedLineCodeString
|
|
7257
|
+
} };
|
|
7258
|
+
} else {
|
|
7259
|
+
currentLeftLineNumbers = [];
|
|
7260
|
+
currentRightLineNumbers = [];
|
|
7261
|
+
resetCommentClass();
|
|
7262
|
+
}
|
|
7263
|
+
}
|
|
7264
|
+
ctx.emit("addComment", obj);
|
|
7265
|
+
};
|
|
7102
7266
|
const onCommentIconClick = (e) => {
|
|
7103
7267
|
if (e) {
|
|
7104
7268
|
const composedPath = e.composedPath();
|
|
@@ -7112,9 +7276,11 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
|
7112
7276
|
return;
|
|
7113
7277
|
}
|
|
7114
7278
|
}
|
|
7115
|
-
if (
|
|
7116
|
-
;
|
|
7117
|
-
|
|
7279
|
+
if (isShift && allowChecked.value) {
|
|
7280
|
+
commentShiftClick();
|
|
7281
|
+
return;
|
|
7282
|
+
}
|
|
7283
|
+
commentClick();
|
|
7118
7284
|
};
|
|
7119
7285
|
const insertComment = (lineNumber, lineSide, commentDom) => {
|
|
7120
7286
|
if (outputFormat.value === "line-by-line") {
|
|
@@ -7163,8 +7329,11 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
|
|
|
7163
7329
|
commentLeft,
|
|
7164
7330
|
commentTop,
|
|
7165
7331
|
mouseEvent,
|
|
7332
|
+
updateCheckedLineClass,
|
|
7166
7333
|
onCommentMouseLeave,
|
|
7167
7334
|
onCommentIconClick,
|
|
7335
|
+
onCommentKeyDown,
|
|
7336
|
+
unCommentKeyDown,
|
|
7168
7337
|
insertComment,
|
|
7169
7338
|
removeComment
|
|
7170
7339
|
};
|
|
@@ -7195,15 +7364,23 @@ var CodeReview = defineComponent({
|
|
|
7195
7364
|
mouseEvent,
|
|
7196
7365
|
onCommentMouseLeave,
|
|
7197
7366
|
onCommentIconClick,
|
|
7367
|
+
onCommentKeyDown,
|
|
7368
|
+
unCommentKeyDown,
|
|
7198
7369
|
insertComment,
|
|
7199
|
-
removeComment
|
|
7370
|
+
removeComment,
|
|
7371
|
+
updateCheckedLineClass
|
|
7200
7372
|
} = useCodeReviewComment(reviewContentRef, props, ctx);
|
|
7201
7373
|
onMounted(() => {
|
|
7202
7374
|
ctx.emit("afterViewInit", {
|
|
7203
7375
|
toggleFold,
|
|
7204
7376
|
insertComment,
|
|
7205
|
-
removeComment
|
|
7377
|
+
removeComment,
|
|
7378
|
+
updateCheckedLineClass
|
|
7206
7379
|
});
|
|
7380
|
+
onCommentKeyDown();
|
|
7381
|
+
});
|
|
7382
|
+
onBeforeUnmount(() => {
|
|
7383
|
+
unCommentKeyDown();
|
|
7207
7384
|
});
|
|
7208
7385
|
provide(CodeReviewInjectionKey, {
|
|
7209
7386
|
diffType,
|