vue-devui 1.6.22 → 1.6.24

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.
@@ -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, onBeforeUnmount, 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, 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";
@@ -6284,6 +6284,10 @@ const codeReviewProps = {
6284
6284
  },
6285
6285
  expandLoader: {
6286
6286
  type: Function
6287
+ },
6288
+ options: {
6289
+ type: Object,
6290
+ default: () => ({})
6287
6291
  }
6288
6292
  };
6289
6293
  const CodeReviewInjectionKey = Symbol("d-code-review");
@@ -6528,15 +6532,15 @@ function addClassToDiffCode(codeStrArr, theClassName) {
6528
6532
  });
6529
6533
  return newArray;
6530
6534
  }
6531
- function parseDiffCode(container, code, outputFormat, isAddCode = false) {
6535
+ function parseDiffCode(container, code, outputFormat, options, isAddCode = false) {
6532
6536
  var _a;
6533
6537
  const diff2HtmlUi = new Diff2HtmlUI(container, code, {
6534
6538
  drawFileList: false,
6535
6539
  matching: "lines",
6536
6540
  outputFormat,
6537
6541
  highlight: true,
6538
- diffStyle: "char",
6539
- rawTemplates: TemplateMap[outputFormat]
6542
+ rawTemplates: TemplateMap[outputFormat],
6543
+ ...options
6540
6544
  });
6541
6545
  if (outputFormat === "side-by-side") {
6542
6546
  let diffHtmlStr = diff2HtmlUi.diffHtml;
@@ -6800,6 +6804,15 @@ function findReferenceDomForDoubleColumn(parentNode, lineNumber, lineSide) {
6800
6804
  }
6801
6805
  }
6802
6806
  }
6807
+ function findParentTrNode(node) {
6808
+ if (!node) {
6809
+ return null;
6810
+ }
6811
+ if (node.tagName === "TR") {
6812
+ return node;
6813
+ }
6814
+ return findParentTrNode(node.parentElement);
6815
+ }
6803
6816
  function useCodeReviewExpand(reviewContentRef, props) {
6804
6817
  const { outputFormat, expandThreshold, expandLoader } = toRefs(props);
6805
6818
  const processSideBySide = () => {
@@ -6841,7 +6854,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
6841
6854
  }
6842
6855
  attachExpandUpDownButton(loadMoreLine.children[0], "down");
6843
6856
  };
6844
- const insertIncrementCodeForDoubleColumn = (code, direction, referenceDom) => {
6857
+ const insertIncrementCodeForDoubleColumn = (code, direction, referenceDom, options) => {
6845
6858
  if (!referenceDom) {
6846
6859
  return;
6847
6860
  }
@@ -6850,7 +6863,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
6850
6863
  }
6851
6864
  const prefix = "--- updated_at Jan 1, 2019, 0:0:0 AM\n+++ updated_at Jan 1, 2019, 0:0:0 AM\n";
6852
6865
  const container = document.createElement("div");
6853
- parseDiffCode(container, prefix + code, outputFormat.value, true);
6866
+ parseDiffCode(container, prefix + code, outputFormat.value, options, true);
6854
6867
  const trNodes = Array.from(container.querySelectorAll("tr"));
6855
6868
  const expandLine = trNodes.find((element) => {
6856
6869
  var _a;
@@ -6924,7 +6937,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
6924
6937
  }
6925
6938
  attachExpandUpDownButton(loadMoreLine.children[0], "down");
6926
6939
  };
6927
- const insertIncrementCode = (code, direction, referenceDom) => {
6940
+ const insertIncrementCode = (code, direction, referenceDom, options) => {
6928
6941
  if (!referenceDom) {
6929
6942
  return;
6930
6943
  }
@@ -6933,7 +6946,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
6933
6946
  }
6934
6947
  const prefix = "--- updated_at Jan 1, 2019, 0:0:0 AM\n+++ updated_at Jan 1, 2019, 0:0:0 AM\n";
6935
6948
  const container = document.createElement("div");
6936
- parseDiffCode(container, prefix + code, outputFormat.value, true);
6949
+ parseDiffCode(container, prefix + code, outputFormat.value, options, true);
6937
6950
  const trNodes = Array.from(container.querySelectorAll("tr"));
6938
6951
  const expandLine = trNodes.find((element) => {
6939
6952
  var _a;
@@ -6963,7 +6976,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
6963
6976
  }
6964
6977
  }
6965
6978
  };
6966
- const onExpandButtonClick = (e) => {
6979
+ const onExpandButtonClick = (e, options) => {
6967
6980
  var _a, _b;
6968
6981
  const composedPath = e.composedPath();
6969
6982
  const expandIconDom = composedPath.find((element) => {
@@ -6976,7 +6989,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
6976
6989
  const [leftLineStart, leftLineEnd, rightLineStart, rightLineEnd] = getLineNumberFromDataset(expandIconDom, expandThreshold.value);
6977
6990
  (_b = expandLoader == null ? void 0 : expandLoader.value) == null ? void 0 : _b.call(expandLoader, [leftLineStart, leftLineEnd, rightLineStart, rightLineEnd], (code) => {
6978
6991
  var _a2, _b2;
6979
- outputFormat.value === "line-by-line" ? insertIncrementCode(code, direction, (_a2 = expandIconDom.parentElement) == null ? void 0 : _a2.parentElement) : insertIncrementCodeForDoubleColumn(code, direction, (_b2 = expandIconDom.parentElement) == null ? void 0 : _b2.parentElement);
6992
+ outputFormat.value === "line-by-line" ? insertIncrementCode(code, direction, (_a2 = expandIconDom.parentElement) == null ? void 0 : _a2.parentElement, options) : insertIncrementCodeForDoubleColumn(code, direction, (_b2 = expandIconDom.parentElement) == null ? void 0 : _b2.parentElement, options);
6980
6993
  });
6981
6994
  }
6982
6995
  };
@@ -6995,14 +7008,14 @@ function useCodeReview(props, ctx) {
6995
7008
  diffFile.value = Diff2Html.parse(diff.value);
6996
7009
  nextTick(() => {
6997
7010
  if (inBrowser && !showBlob.value) {
6998
- parseDiffCode(reviewContentRef.value, diff.value, outputFormat.value);
7011
+ parseDiffCode(reviewContentRef.value, diff.value, outputFormat.value, props.options);
6999
7012
  allowExpand.value && insertExpandButton();
7000
7013
  ctx.emit("contentRefresh", JSON.parse(JSON.stringify(diffFile.value)));
7001
7014
  }
7002
7015
  });
7003
7016
  };
7004
7017
  const onContentClick = (e) => {
7005
- onExpandButtonClick(e);
7018
+ onExpandButtonClick(e, props.options);
7006
7019
  };
7007
7020
  watch(showBlob, initDiffContent);
7008
7021
  watch(outputFormat, initDiffContent);
@@ -7027,25 +7040,161 @@ function useCodeReviewFold(props, ctx) {
7027
7040
  });
7028
7041
  return { isFold, toggleFold };
7029
7042
  }
7043
+ function useCodeReviewLineSelection(reviewContentRef, props, mouseMoveCb, mouseupCb) {
7044
+ const ns2 = useNamespace("code-review");
7045
+ let dragging = false;
7046
+ let startTrNode;
7047
+ let trNodes;
7048
+ let isClickedLeft;
7049
+ let shouldClear;
7050
+ let isMouseMoved;
7051
+ const onMousedown = (e) => {
7052
+ if (e.button === 0) {
7053
+ const composedPath = e.composedPath();
7054
+ const lineNumberBox = composedPath.find(
7055
+ (item) => {
7056
+ var _a, _b;
7057
+ return ((_a = item.classList) == null ? void 0 : _a.contains("comment-icon-hover")) || ((_b = item.classList) == null ? void 0 : _b.contains("comment-icon"));
7058
+ }
7059
+ );
7060
+ trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr")).filter((item) => {
7061
+ var _a;
7062
+ return !((_a = item.classList) == null ? void 0 : _a.contains("expand-line"));
7063
+ });
7064
+ if (!lineNumberBox) {
7065
+ return;
7066
+ }
7067
+ const parentTrNode = findParentTrNode(e.target);
7068
+ if (parentTrNode && (parentTrNode == null ? void 0 : parentTrNode.classList.contains("expand-line"))) {
7069
+ return;
7070
+ }
7071
+ startTrNode = parentTrNode;
7072
+ if (props.outputFormat === "side-by-side") {
7073
+ isClickedLeft = composedPath.some((item) => {
7074
+ var _a;
7075
+ return (_a = item.classList) == null ? void 0 : _a.contains("d-code-left");
7076
+ });
7077
+ } else {
7078
+ isClickedLeft = void 0;
7079
+ }
7080
+ dragging = true;
7081
+ shouldClear = true;
7082
+ isMouseMoved = false;
7083
+ e.preventDefault();
7084
+ e.stopPropagation();
7085
+ document.addEventListener("mousemove", onMousemove);
7086
+ document.addEventListener("mouseup", onMouseup);
7087
+ }
7088
+ };
7089
+ function onMousemove(e) {
7090
+ if (!dragging) {
7091
+ return;
7092
+ }
7093
+ isMouseMoved = true;
7094
+ if (shouldClear) {
7095
+ clearCommentChecked();
7096
+ shouldClear = false;
7097
+ }
7098
+ const composedPath = e.composedPath();
7099
+ const inReviewContent = composedPath.some((item) => {
7100
+ var _a;
7101
+ return (_a = item.classList) == null ? void 0 : _a.contains(ns2.e("content"));
7102
+ });
7103
+ if (!inReviewContent) {
7104
+ return;
7105
+ }
7106
+ const endTrNode = findParentTrNode(e.target);
7107
+ if (!endTrNode) {
7108
+ return;
7109
+ }
7110
+ let startIndex = trNodes.indexOf(startTrNode);
7111
+ let endIndex = trNodes.indexOf(endTrNode);
7112
+ if (endIndex === -1) {
7113
+ return;
7114
+ }
7115
+ mouseMoveCb();
7116
+ if (startIndex > endIndex) {
7117
+ [startIndex, endIndex] = [endIndex, startIndex];
7118
+ }
7119
+ let position;
7120
+ if (isClickedLeft === void 0) {
7121
+ position = "all";
7122
+ } else if (isClickedLeft) {
7123
+ position = "left";
7124
+ } else {
7125
+ position = "right";
7126
+ }
7127
+ for (let i = 0; i < trNodes.length; i++) {
7128
+ if (i >= startIndex && i <= endIndex) {
7129
+ toggleCommentCheckedClass(trNodes[i], true, position);
7130
+ } else {
7131
+ toggleCommentCheckedClass(trNodes[i], false, position);
7132
+ }
7133
+ }
7134
+ }
7135
+ function onMouseup() {
7136
+ dragging = false;
7137
+ if (isMouseMoved) {
7138
+ mouseupCb();
7139
+ }
7140
+ document.removeEventListener("mouseup", onMouseup);
7141
+ document.removeEventListener("mousemove", onMousemove);
7142
+ }
7143
+ function clearCommentChecked() {
7144
+ for (let i = 0; i < trNodes.length; i++) {
7145
+ toggleCommentCheckedClass(trNodes[i], false, "all");
7146
+ }
7147
+ }
7148
+ function toggleCommentCheckedClass(trNode, isAddClass, position) {
7149
+ var _a;
7150
+ const tdNodes = Array.from(trNode.children);
7151
+ let toDoNodes;
7152
+ if (position === "all") {
7153
+ toDoNodes = tdNodes;
7154
+ } else if (position === "left") {
7155
+ toDoNodes = tdNodes.slice(0, 2);
7156
+ } else {
7157
+ toDoNodes = tdNodes.slice(2);
7158
+ }
7159
+ if ((position === "left" || position === "right") && isNaN(parseInt((_a = toDoNodes[0]) == null ? void 0 : _a.innerHTML))) {
7160
+ return;
7161
+ }
7162
+ toDoNodes.forEach((item) => {
7163
+ if (item.tagName === "TD") {
7164
+ if (isAddClass) {
7165
+ item.classList.add("comment-checked");
7166
+ } else {
7167
+ item.classList.remove("comment-checked");
7168
+ }
7169
+ }
7170
+ });
7171
+ }
7172
+ return { onMousedown };
7173
+ }
7030
7174
  function useCodeReviewComment(reviewContentRef, props, ctx) {
7031
7175
  const { outputFormat, allowComment, allowChecked } = toRefs(props);
7032
7176
  const ns2 = useNamespace("code-review");
7177
+ const { onMousedown } = useCodeReviewLineSelection(reviewContentRef, props, updateLineNumbers, afterCheckLines);
7033
7178
  const commentLeft = ref(-100);
7034
7179
  const commentTop = ref(-100);
7035
7180
  let currentLeftLineNumber = -1;
7036
7181
  let currentRightLineNumber = -1;
7037
7182
  let lastLineNumberContainer;
7038
7183
  let checkedLineNumberContainer = [];
7039
- let isShift = false;
7040
7184
  let currentLeftLineNumbers = [];
7041
7185
  let currentRightLineNumbers = [];
7042
7186
  let checkedLineCodeString = {};
7043
- watch(() => outputFormat.value, () => {
7044
- checkedLineNumberContainer = [];
7045
- currentLeftLineNumbers = [];
7046
- currentRightLineNumbers = [];
7047
- checkedLineCodeString = [];
7048
- });
7187
+ let allTrNodes = [];
7188
+ let afterCheckLinesEmitData;
7189
+ watch(
7190
+ () => outputFormat.value,
7191
+ () => {
7192
+ checkedLineNumberContainer = [];
7193
+ currentLeftLineNumbers = [];
7194
+ currentRightLineNumbers = [];
7195
+ checkedLineCodeString = [];
7196
+ }
7197
+ );
7049
7198
  const resetLeftTop = () => {
7050
7199
  commentLeft.value = -100;
7051
7200
  commentTop.value = -100;
@@ -7128,30 +7277,7 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7128
7277
  resetLeftTop();
7129
7278
  }
7130
7279
  };
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) => {
7280
+ const getLineNumbers = (currentNumber, currentNumbers) => {
7155
7281
  if (currentNumber === -1) {
7156
7282
  return currentNumbers;
7157
7283
  }
@@ -7160,26 +7286,27 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7160
7286
  }
7161
7287
  const numbers = [...currentNumbers];
7162
7288
  let max = Math.max(...numbers);
7163
- const min = Math.min(...numbers);
7289
+ let min = Math.min(...numbers);
7290
+ if (currentNumber < min) {
7291
+ min = currentNumber;
7292
+ }
7164
7293
  if (currentNumber > max) {
7165
7294
  max = currentNumber;
7166
7295
  }
7167
7296
  return Array.from({ length: max - min + 1 }, (_, i) => i + min);
7168
7297
  };
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);
7298
+ const getCommonClassAndJudge = () => {
7172
7299
  const checkedLine = [currentLeftLineNumbers, currentRightLineNumbers];
7173
7300
  return {
7174
- linenumberDom,
7301
+ linenumberDom: allTrNodes,
7175
7302
  checkedLine
7176
7303
  };
7177
7304
  };
7178
7305
  const addCommentCheckedClass = (Dom) => {
7179
7306
  !Dom.classList.contains("comment-checked") && Dom.classList.add("comment-checked");
7180
7307
  };
7181
- const addCommentClassSingle = (side) => {
7182
- const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
7308
+ function getSingleCheckedLineCode(shouldRenderClass) {
7309
+ const { linenumberDom, checkedLine } = getCommonClassAndJudge();
7183
7310
  const checkedCodeContent = [];
7184
7311
  for (let i = 0; i < linenumberDom.length; i++) {
7185
7312
  const lineNumberDomLeft = linenumberDom[i].children[0];
@@ -7189,25 +7316,29 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7189
7316
  const codeLineNumberRight = parseInt(lineNumberDomRight == null ? void 0 : lineNumberDomRight.innerText);
7190
7317
  if (checkedLine[0].includes(codeLineNumberLeft) || checkedLine[1].includes(codeLineNumberRight)) {
7191
7318
  checkedLineNumberContainer.push(linenumberDom[i]);
7192
- const codeNode = linenumberDom[i].nextSibling.nodeName === "#text" ? linenumberDom[i].nextSibling.nextSibling : linenumberDom[i].nextSibling;
7319
+ const codeNode = linenumberDom[i].nextElementSibling;
7193
7320
  checkedCodeContent.push(codeNode == null ? void 0 : codeNode.innerText);
7194
- addCommentCheckedClass(linenumberDom[i]);
7195
- addCommentCheckedClass(codeNode);
7321
+ if (shouldRenderClass) {
7322
+ addCommentCheckedClass(linenumberDom[i]);
7323
+ addCommentCheckedClass(codeNode);
7324
+ }
7196
7325
  }
7197
7326
  }
7198
7327
  }
7199
7328
  checkedLineCodeString = checkedCodeContent;
7200
- };
7201
- const addCommentClassDouble = (side) => {
7329
+ }
7330
+ function getDoubleCheckedLineCode(shouldRenderClass) {
7202
7331
  var _a;
7203
- const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
7332
+ const { linenumberDom, checkedLine } = getCommonClassAndJudge();
7204
7333
  const checkedCodeContentLeft = [];
7205
7334
  const checkedCodeContentRight = [];
7206
7335
  function checkedFunc(Dom) {
7207
7336
  checkedLineNumberContainer.push(Dom);
7208
- const codeNode = Dom.nextSibling.nodeName === "#text" ? Dom.nextSibling.nextSibling : Dom.nextSibling;
7209
- addCommentCheckedClass(Dom);
7210
- addCommentCheckedClass(codeNode);
7337
+ const codeNode = Dom.nextElementSibling;
7338
+ if (shouldRenderClass) {
7339
+ addCommentCheckedClass(Dom);
7340
+ addCommentCheckedClass(codeNode);
7341
+ }
7211
7342
  return codeNode == null ? void 0 : codeNode.innerText;
7212
7343
  }
7213
7344
  for (let i = 0; i < linenumberDom.length; i++) {
@@ -7223,38 +7354,53 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7223
7354
  }
7224
7355
  }
7225
7356
  checkedLineCodeString = { leftCode: checkedCodeContentLeft, rightCode: checkedCodeContentRight };
7226
- };
7227
- const updateCheckedLineClass = () => {
7228
- if (outputFormat.value === "line-by-line") {
7229
- addCommentClassSingle(outputFormat.value);
7230
- return;
7357
+ }
7358
+ function getCheckedLineCode(shouldRenderClass) {
7359
+ if (props.outputFormat === "line-by-line") {
7360
+ return getSingleCheckedLineCode(shouldRenderClass);
7231
7361
  }
7232
- addCommentClassDouble(outputFormat.value);
7362
+ getDoubleCheckedLineCode(shouldRenderClass);
7363
+ }
7364
+ function updateLineNumbers() {
7365
+ currentLeftLineNumbers = currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers);
7366
+ currentRightLineNumbers = currentRightLineNumber === -1 ? currentRightLineNumbers : getLineNumbers(currentRightLineNumber, currentRightLineNumbers);
7367
+ getCheckedLineCode(false);
7368
+ afterCheckLinesEmitData = {
7369
+ left: currentLeftLineNumber,
7370
+ right: currentRightLineNumber,
7371
+ details: {
7372
+ lefts: currentLeftLineNumbers,
7373
+ rights: currentRightLineNumbers,
7374
+ codes: checkedLineCodeString
7375
+ }
7376
+ };
7377
+ }
7378
+ const updateCheckedLineClass = () => {
7379
+ getCheckedLineCode(true);
7233
7380
  };
7234
7381
  const resetCommentClass = () => {
7235
7382
  for (let i = 0; i < checkedLineNumberContainer.length; i++) {
7236
7383
  checkedLineNumberContainer[i].classList.remove("comment-checked");
7237
- const codeNode = checkedLineNumberContainer[i].nextSibling.nodeName === "#text" ? checkedLineNumberContainer[i].nextSibling.nextSibling : checkedLineNumberContainer[i].nextSibling;
7384
+ const codeNode = checkedLineNumberContainer[i].nextElementSibling;
7238
7385
  codeNode == null ? void 0 : codeNode.classList.remove("comment-checked");
7239
7386
  }
7240
7387
  checkedLineNumberContainer = [];
7241
7388
  };
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) => {
7389
+ const commentClick = () => {
7248
7390
  let obj = { left: currentLeftLineNumber, right: currentRightLineNumber };
7249
- if (currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1 && allowChecked.value) {
7391
+ if ((currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1) && allowChecked.value) {
7250
7392
  const maxCurrentLeftLineNumber = currentLeftLineNumbers[currentLeftLineNumbers.length - 1];
7251
7393
  const maxCurrentRightLineNumber = currentRightLineNumbers[currentRightLineNumbers.length - 1];
7252
7394
  if (maxCurrentLeftLineNumber === currentLeftLineNumber || maxCurrentRightLineNumber === currentRightLineNumber) {
7253
- obj = { left: currentLeftLineNumber, right: currentRightLineNumber, details: {
7254
- lefts: currentLeftLineNumbers,
7255
- rights: currentRightLineNumbers,
7256
- codes: checkedLineCodeString
7257
- } };
7395
+ obj = {
7396
+ left: currentLeftLineNumber,
7397
+ right: currentRightLineNumber,
7398
+ details: {
7399
+ lefts: currentLeftLineNumbers,
7400
+ rights: currentRightLineNumbers,
7401
+ codes: checkedLineCodeString
7402
+ }
7403
+ };
7258
7404
  } else {
7259
7405
  currentLeftLineNumbers = [];
7260
7406
  currentRightLineNumbers = [];
@@ -7263,6 +7409,9 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7263
7409
  }
7264
7410
  ctx.emit("addComment", obj);
7265
7411
  };
7412
+ function afterCheckLines() {
7413
+ ctx.emit("afterCheckLines", afterCheckLinesEmitData);
7414
+ }
7266
7415
  const onCommentIconClick = (e) => {
7267
7416
  if (e) {
7268
7417
  const composedPath = e.composedPath();
@@ -7276,10 +7425,6 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7276
7425
  return;
7277
7426
  }
7278
7427
  }
7279
- if (isShift && allowChecked.value) {
7280
- commentShiftClick();
7281
- return;
7282
- }
7283
7428
  commentClick();
7284
7429
  };
7285
7430
  const insertComment = (lineNumber, lineSide, commentDom) => {
@@ -7320,7 +7465,25 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7320
7465
  }
7321
7466
  }
7322
7467
  };
7323
- const mouseEvent = allowComment.value ? { onMousemove: onMouseMove, onMouseleave } : {};
7468
+ const clearCheckedLines = () => {
7469
+ currentLeftLineNumbers = [];
7470
+ currentRightLineNumbers = [];
7471
+ checkedLineCodeString = [];
7472
+ resetCommentClass();
7473
+ };
7474
+ const handleMouseDown = (e) => {
7475
+ const lineClassName = props.outputFormat === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
7476
+ allTrNodes = reviewContentRef.value.querySelectorAll(lineClassName);
7477
+ onMousedown(e);
7478
+ };
7479
+ const mouseEvent = {};
7480
+ if (allowComment.value) {
7481
+ mouseEvent.onMousemove = onMouseMove;
7482
+ mouseEvent.onMouseleave = onMouseleave;
7483
+ }
7484
+ if (props.allowChecked) {
7485
+ mouseEvent.onMousedown = handleMouseDown;
7486
+ }
7324
7487
  window.addEventListener("scroll", resetLeftTop);
7325
7488
  onUnmounted(() => {
7326
7489
  window.removeEventListener("scroll", resetLeftTop);
@@ -7330,10 +7493,9 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7330
7493
  commentTop,
7331
7494
  mouseEvent,
7332
7495
  updateCheckedLineClass,
7496
+ clearCheckedLines,
7333
7497
  onCommentMouseLeave,
7334
7498
  onCommentIconClick,
7335
- onCommentKeyDown,
7336
- unCommentKeyDown,
7337
7499
  insertComment,
7338
7500
  removeComment
7339
7501
  };
@@ -7342,7 +7504,7 @@ var codeReview = "";
7342
7504
  var CodeReview = defineComponent({
7343
7505
  name: "DCodeReview",
7344
7506
  props: codeReviewProps,
7345
- emits: ["foldChange", "addComment", "afterViewInit", "contentRefresh"],
7507
+ emits: ["foldChange", "addComment", "afterViewInit", "contentRefresh", "afterCheckLines"],
7346
7508
  setup(props, ctx) {
7347
7509
  const ns2 = useNamespace("code-review");
7348
7510
  const {
@@ -7364,23 +7526,19 @@ var CodeReview = defineComponent({
7364
7526
  mouseEvent,
7365
7527
  onCommentMouseLeave,
7366
7528
  onCommentIconClick,
7367
- onCommentKeyDown,
7368
- unCommentKeyDown,
7369
7529
  insertComment,
7370
7530
  removeComment,
7371
- updateCheckedLineClass
7531
+ updateCheckedLineClass,
7532
+ clearCheckedLines
7372
7533
  } = useCodeReviewComment(reviewContentRef, props, ctx);
7373
7534
  onMounted(() => {
7374
7535
  ctx.emit("afterViewInit", {
7375
7536
  toggleFold,
7376
7537
  insertComment,
7377
7538
  removeComment,
7378
- updateCheckedLineClass
7539
+ updateCheckedLineClass,
7540
+ clearCheckedLines
7379
7541
  });
7380
- onCommentKeyDown();
7381
- });
7382
- onBeforeUnmount(() => {
7383
- unCommentKeyDown();
7384
7542
  });
7385
7543
  provide(CodeReviewInjectionKey, {
7386
7544
  diffType,