vue-devui 1.6.26 → 1.6.28

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/vue-devui.es.js CHANGED
@@ -17526,34 +17526,144 @@ function findParentTrNode(node) {
17526
17526
  function getFullNumberList(min, max) {
17527
17527
  return Array.from({ length: max - min + 1 }, (_, i) => i + min);
17528
17528
  }
17529
- function getLineNumbers(trNodes, outputFormat, side) {
17529
+ function clearCommentChecked(checkedTdNodes) {
17530
+ for (let i = 0; i < checkedTdNodes.length; i++) {
17531
+ checkedTdNodes[i].classList.remove("comment-checked");
17532
+ }
17533
+ }
17534
+ function parseCodeToSingle(container, code, options) {
17535
+ const diff2HtmlUi = new Diff2HtmlUI(container, code, {
17536
+ drawFileList: false,
17537
+ outputFormat: "line-by-line",
17538
+ highlight: true,
17539
+ rawTemplates: TemplateMap["line-by-line"],
17540
+ ...options
17541
+ });
17542
+ diff2HtmlUi.draw();
17543
+ }
17544
+ function generateNumberTdObj(tdNodes) {
17545
+ const lineNumber = parseInt(tdNodes[0].innerText) || -1;
17546
+ if (lineNumber !== -1) {
17547
+ return { [lineNumber]: tdNodes };
17548
+ }
17549
+ }
17550
+ function getLineNumberTdMap(trNodes) {
17551
+ const left = {};
17552
+ const right = {};
17553
+ for (let i = 0; i < trNodes.length; i++) {
17554
+ const tdNodes = Array.from(trNodes[i].children);
17555
+ Object.assign(left, generateNumberTdObj(tdNodes.slice(0, 2)));
17556
+ Object.assign(right, generateNumberTdObj(tdNodes.slice(2)));
17557
+ }
17558
+ return { left, right };
17559
+ }
17560
+ function getLineNumberMap(trNodes) {
17530
17561
  var _a, _b;
17531
- const leftNumbers = [];
17532
- const rightNumbers = [];
17562
+ const result2 = [];
17533
17563
  for (let i = 0; i < trNodes.length; i++) {
17534
- const itemTrNode = trNodes[i];
17535
- if (outputFormat === "line-by-line") {
17536
- const lineNumberTdNode = Array.from(itemTrNode.children)[0];
17537
- const leftLineNumber = parseInt((_a = lineNumberTdNode.children[0]) == null ? void 0 : _a.innerText);
17538
- const rightLineNumber = parseInt((_b = lineNumberTdNode.children[1]) == null ? void 0 : _b.innerText);
17539
- leftLineNumber && leftNumbers.push(leftLineNumber);
17540
- rightLineNumber && rightNumbers.push(leftLineNumber);
17564
+ const lineNumberNodes = trNodes[i].children[0].children;
17565
+ if (lineNumberNodes.length === 2) {
17566
+ const left = parseInt((_a = lineNumberNodes[0]) == null ? void 0 : _a.innerText) || -1;
17567
+ const right = parseInt((_b = lineNumberNodes[1]) == null ? void 0 : _b.innerText) || -1;
17568
+ result2.push({ left, right });
17569
+ }
17570
+ }
17571
+ return result2;
17572
+ }
17573
+ function getDoubleCheckedNumberAndCodes(checkedTdNodes) {
17574
+ const lefts = [];
17575
+ const rights = [];
17576
+ const leftCode = [];
17577
+ const rightCode = [];
17578
+ const leftNumberNodes = [];
17579
+ const rightNumberNodes = [];
17580
+ for (let i = 0; i < checkedTdNodes.length; i++) {
17581
+ const itemTdNode = checkedTdNodes[i];
17582
+ if (itemTdNode.classList.contains("d-code-left")) {
17583
+ if (itemTdNode.classList.contains("d2h-code-side-linenumber")) {
17584
+ leftNumberNodes.push(itemTdNode);
17585
+ } else {
17586
+ leftCode.push(itemTdNode.innerText);
17587
+ }
17541
17588
  } else {
17542
- const tdNodes = Array.from(itemTrNode.children);
17543
- const lineNumberTdNode = tdNodes[side === "left" ? 0 : 2];
17544
- if (lineNumberTdNode && notEmptyNode(lineNumberTdNode)) {
17545
- const lineNumber = parseInt(lineNumberTdNode.innerText);
17546
- if (lineNumber) {
17547
- side === "left" ? leftNumbers.push(lineNumber) : rightNumbers.push(lineNumber);
17548
- }
17589
+ if (itemTdNode.classList.contains("d2h-code-side-linenumber")) {
17590
+ rightNumberNodes.push(itemTdNode);
17591
+ } else {
17592
+ rightCode.push(itemTdNode.innerText);
17549
17593
  }
17550
17594
  }
17551
17595
  }
17552
- const lefts = leftNumbers.length ? getFullNumberList(leftNumbers[0], leftNumbers[leftNumbers.length - 1]) : leftNumbers;
17553
- const rights = rightNumbers.length ? getFullNumberList(rightNumbers[0], rightNumbers[rightNumbers.length - 1]) : rightNumbers;
17554
- return { lefts, rights };
17596
+ if (leftNumberNodes.length) {
17597
+ const leftMinNum = parseInt(leftNumberNodes[0].innerText);
17598
+ const leftMaxNum = parseInt(leftNumberNodes[leftNumberNodes.length - 1].innerText);
17599
+ lefts.push(...getFullNumberList(leftMinNum, leftMaxNum));
17600
+ }
17601
+ if (rightNumberNodes.length) {
17602
+ const rightMinNum = parseInt(rightNumberNodes[0].innerText);
17603
+ const rightMaxNum = parseInt(rightNumberNodes[rightNumberNodes.length - 1].innerText);
17604
+ rights.push(...getFullNumberList(rightMinNum, rightMaxNum));
17605
+ }
17606
+ return { lefts, rights, codes: { leftCode, rightCode } };
17607
+ }
17608
+ function getSingleCheckedNumberAndCode(checkedTdNodes) {
17609
+ const lefts = [];
17610
+ const rights = [];
17611
+ const codes = [];
17612
+ const leftNumbers = [];
17613
+ const rightNumbers = [];
17614
+ for (let i = 0; i < checkedTdNodes.length; i++) {
17615
+ const itemTdNode = checkedTdNodes[i];
17616
+ if (itemTdNode.classList.contains("d2h-code-linenumber")) {
17617
+ const numberChildren = itemTdNode.children;
17618
+ const leftNum = parseInt(numberChildren[0].innerText);
17619
+ const rightNum = parseInt(numberChildren[1].innerText);
17620
+ !isNaN(leftNum) && leftNumbers.push(leftNum);
17621
+ !isNaN(rightNum) && rightNumbers.push(rightNum);
17622
+ } else {
17623
+ codes.push(itemTdNode.innerText);
17624
+ }
17625
+ }
17626
+ lefts.push(...getFullNumberList(leftNumbers[0], leftNumbers[leftNumbers.length - 1]));
17627
+ rights.push(...getFullNumberList(rightNumbers[0], rightNumbers[rightNumbers.length - 1]));
17628
+ return { lefts, rights, codes };
17629
+ }
17630
+ function addCommentCheckedForDouble(trNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum) {
17631
+ const [leftNumTd, leftCodeTd, rightNumTd, rightCodeTd] = trNode.children;
17632
+ const leftNum = parseInt(leftNumTd.innerText);
17633
+ const rightNum = parseInt(rightNumTd.innerText);
17634
+ const result2 = [];
17635
+ if (!isNaN(leftNum) && leftNum >= leftMinNum && leftNum <= leftMaxNum) {
17636
+ if (!leftNumTd.classList.contains("comment-checked")) {
17637
+ leftNumTd.classList.add("comment-checked");
17638
+ leftCodeTd.classList.add("comment-checked");
17639
+ }
17640
+ result2.push(leftNumTd, leftCodeTd);
17641
+ }
17642
+ if (!isNaN(rightNum) && rightNum >= rightMinNum && rightNum <= rightMaxNum) {
17643
+ if (!rightNumTd.classList.contains("comment-checked")) {
17644
+ rightNumTd.classList.add("comment-checked");
17645
+ rightCodeTd.classList.add("comment-checked");
17646
+ }
17647
+ result2.push(rightNumTd, rightCodeTd);
17648
+ }
17649
+ return result2;
17555
17650
  }
17556
- function useCodeReviewExpand(reviewContentRef, props) {
17651
+ function addCommentCheckedForSingle(trNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum) {
17652
+ const [numTd, codeTd] = trNode.children;
17653
+ const [leftNumNode, rightNumNode] = numTd.children;
17654
+ const leftNum = parseInt(leftNumNode.innerText);
17655
+ const rightNum = parseInt(rightNumNode.innerText);
17656
+ const result2 = [];
17657
+ if (!isNaN(leftNum) && leftNum >= leftMinNum && leftNum <= leftMaxNum || !isNaN(rightNum) && rightNum >= rightMinNum && rightNum <= rightMaxNum) {
17658
+ if (!numTd.classList.contains("comment-checked")) {
17659
+ numTd.classList.add("comment-checked");
17660
+ codeTd.classList.add("comment-checked");
17661
+ }
17662
+ result2.push(numTd, codeTd);
17663
+ }
17664
+ return result2;
17665
+ }
17666
+ function useCodeReviewExpand(reviewContentRef, props, updateLineNumberMap, updateCheckedLine) {
17557
17667
  const { outputFormat, expandThreshold, expandLoader } = toRefs(props);
17558
17668
  const processSideBySide = () => {
17559
17669
  var _a;
@@ -17613,7 +17723,9 @@ function useCodeReviewExpand(reviewContentRef, props) {
17613
17723
  return;
17614
17724
  }
17615
17725
  const trNodesToBeInserted = trNodes.filter((element) => element !== expandLine);
17726
+ updateLineNumberMap(referenceDom.dataset, prefix + code, direction);
17616
17727
  insertIncrementLineToPage(referenceDom, trNodesToBeInserted, direction);
17728
+ updateCheckedLine(referenceDom.dataset, direction);
17617
17729
  const removedExpandLine = ifRemoveExpandLineForDoubleColumn(referenceDom, expandLine, direction);
17618
17730
  if (removedExpandLine) {
17619
17731
  return;
@@ -17697,6 +17809,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17697
17809
  }
17698
17810
  const trNodesToBeInserted = trNodes.filter((element) => element.children[0].children.length === 2);
17699
17811
  insertIncrementLineToPage(referenceDom, trNodesToBeInserted, direction);
17812
+ updateCheckedLine(referenceDom.dataset, direction);
17700
17813
  const removedExpandLine = ifRemoveExpandLine(referenceDom, expandLine, direction);
17701
17814
  if (removedExpandLine) {
17702
17815
  return;
@@ -17738,12 +17851,11 @@ function useCodeReviewExpand(reviewContentRef, props) {
17738
17851
  };
17739
17852
  return { insertExpandButton, onExpandButtonClick };
17740
17853
  }
17741
- function useCodeReview(props, ctx2) {
17854
+ function useCodeReview(props, ctx2, reviewContentRef, updateLineNumberMap, updateCheckedLine) {
17742
17855
  const { diff, outputFormat, allowExpand, showBlob } = toRefs(props);
17743
17856
  const renderHtml = ref("");
17744
- const reviewContentRef = ref();
17745
17857
  const diffFile = ref([]);
17746
- const { insertExpandButton, onExpandButtonClick } = useCodeReviewExpand(reviewContentRef, props);
17858
+ const { insertExpandButton, onExpandButtonClick } = useCodeReviewExpand(reviewContentRef, props, updateLineNumberMap, updateCheckedLine);
17747
17859
  const initDiffContent = () => {
17748
17860
  diffFile.value = Diff2Html.parse(diff.value);
17749
17861
  nextTick(() => {
@@ -17760,7 +17872,7 @@ function useCodeReview(props, ctx2) {
17760
17872
  watch(showBlob, initDiffContent);
17761
17873
  watch(outputFormat, initDiffContent);
17762
17874
  watch(diff, initDiffContent, { immediate: true });
17763
- return { renderHtml, reviewContentRef, diffFile, onContentClick };
17875
+ return { renderHtml, diffFile, onContentClick };
17764
17876
  }
17765
17877
  function useCodeReviewFold(props, ctx2) {
17766
17878
  const { fold } = toRefs(props);
@@ -17785,38 +17897,52 @@ function useCodeReviewLineSelection(reviewContentRef, props, afterMouseup) {
17785
17897
  let dragging = false;
17786
17898
  let startTrNode;
17787
17899
  let trNodes;
17788
- let isClickedLeft;
17900
+ let allTdNodes = [];
17789
17901
  let shouldClear;
17790
17902
  let isMouseMoved;
17791
- let checkedTrNodes = [];
17903
+ let leftRightLineNumberArr = [];
17904
+ let leftNumberTdMap = {};
17905
+ let rightNumberTdMap = {};
17906
+ let checkedTdNodes = [];
17907
+ let startPosition;
17908
+ let leftMinNum;
17909
+ let leftMaxNum;
17910
+ let rightMinNum;
17911
+ let rightMaxNum;
17792
17912
  const onMousedown2 = (e) => {
17913
+ var _a;
17793
17914
  if (e.button === 0) {
17794
17915
  const composedPath = e.composedPath();
17795
17916
  const lineNumberBox = composedPath.find(
17796
17917
  (item) => {
17797
- var _a, _b;
17798
- return ((_a = item.classList) == null ? void 0 : _a.contains("comment-icon-hover")) || ((_b = item.classList) == null ? void 0 : _b.contains("comment-icon"));
17918
+ var _a2, _b;
17919
+ return ((_a2 = item.classList) == null ? void 0 : _a2.contains("comment-icon-hover")) || ((_b = item.classList) == null ? void 0 : _b.contains("comment-icon"));
17799
17920
  }
17800
17921
  );
17801
17922
  trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr")).filter((item) => {
17802
- var _a;
17803
- return !((_a = item.classList) == null ? void 0 : _a.contains("expand-line"));
17923
+ var _a2;
17924
+ return !((_a2 = item.classList) == null ? void 0 : _a2.contains("expand-line"));
17804
17925
  });
17805
17926
  if (!lineNumberBox) {
17806
17927
  return;
17807
17928
  }
17808
17929
  const parentTrNode = findParentTrNode(e.target);
17809
- if (parentTrNode && (parentTrNode == null ? void 0 : parentTrNode.classList.contains("expand-line"))) {
17930
+ if (parentTrNode && ((_a = parentTrNode == null ? void 0 : parentTrNode.classList) == null ? void 0 : _a.contains("expand-line"))) {
17810
17931
  return;
17811
17932
  }
17812
17933
  startTrNode = parentTrNode;
17934
+ allTdNodes = [];
17935
+ for (let i = 0; i < trNodes.length; i++) {
17936
+ allTdNodes.push(...trNodes[i].children);
17937
+ }
17813
17938
  if (props.outputFormat === "side-by-side") {
17814
- isClickedLeft = composedPath.some((item) => {
17815
- var _a;
17816
- return (_a = item.classList) == null ? void 0 : _a.contains("d-code-left");
17817
- });
17818
- } else {
17819
- isClickedLeft = void 0;
17939
+ const { left, right } = getLineNumberTdMap(trNodes);
17940
+ leftNumberTdMap = left;
17941
+ rightNumberTdMap = right;
17942
+ startPosition = composedPath.some((item) => {
17943
+ var _a2;
17944
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains("d-code-left");
17945
+ }) ? "left" : "right";
17820
17946
  }
17821
17947
  dragging = true;
17822
17948
  shouldClear = true;
@@ -17828,115 +17954,181 @@ function useCodeReviewLineSelection(reviewContentRef, props, afterMouseup) {
17828
17954
  }
17829
17955
  };
17830
17956
  function onMousemove(e) {
17957
+ var _a, _b;
17831
17958
  if (!dragging) {
17832
17959
  return;
17833
17960
  }
17834
- isMouseMoved = true;
17835
17961
  if (shouldClear) {
17836
- clearCommentChecked();
17962
+ clearCommentChecked(checkedTdNodes);
17837
17963
  shouldClear = false;
17838
17964
  }
17839
17965
  const composedPath = e.composedPath();
17840
17966
  const inReviewContent = composedPath.some((item) => {
17841
- var _a;
17842
- return (_a = item.classList) == null ? void 0 : _a.contains(ns2.e("content"));
17967
+ var _a2;
17968
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains(ns2.e("content"));
17843
17969
  });
17844
17970
  if (!inReviewContent) {
17845
17971
  return;
17846
17972
  }
17847
17973
  const endTrNode = findParentTrNode(e.target);
17974
+ let endPosition;
17975
+ if (props.outputFormat === "side-by-side") {
17976
+ if (composedPath.some((item) => {
17977
+ var _a2;
17978
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains("d-code-left");
17979
+ })) {
17980
+ endPosition = "left";
17981
+ }
17982
+ if (composedPath.some((item) => {
17983
+ var _a2;
17984
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains("d-code-right");
17985
+ })) {
17986
+ endPosition = "right";
17987
+ }
17988
+ }
17848
17989
  if (!endTrNode) {
17849
17990
  return;
17850
17991
  }
17851
- let startIndex = trNodes.indexOf(startTrNode);
17852
- let endIndex = trNodes.indexOf(endTrNode);
17853
- if (endIndex === -1) {
17992
+ isMouseMoved = true;
17993
+ const endTrChildren = endTrNode.children;
17994
+ if (endPosition === "left" && isNaN(parseInt((_a = endTrChildren[0]) == null ? void 0 : _a.innerText)) || endPosition === "right" && isNaN(parseInt((_b = endTrChildren[2]) == null ? void 0 : _b.innerText))) {
17854
17995
  return;
17855
17996
  }
17856
- if (startIndex > endIndex) {
17857
- [startIndex, endIndex] = [endIndex, startIndex];
17997
+ checkedTdNodes = [];
17998
+ if (props.outputFormat === "line-by-line") {
17999
+ let startIndex = trNodes.indexOf(startTrNode);
18000
+ let endIndex = trNodes.indexOf(endTrNode);
18001
+ if (endIndex === -1) {
18002
+ return;
18003
+ }
18004
+ if (startIndex > endIndex) {
18005
+ [startIndex, endIndex] = [endIndex, startIndex];
18006
+ }
18007
+ for (let i = 0; i < trNodes.length; i++) {
18008
+ const tdNodes = Array.from(trNodes[i].children);
18009
+ if (i >= startIndex && i <= endIndex) {
18010
+ checkedTdNodes.push(...tdNodes);
18011
+ }
18012
+ }
17858
18013
  }
17859
- let position;
17860
- if (isClickedLeft === void 0) {
17861
- position = "all";
17862
- } else if (isClickedLeft) {
17863
- position = "left";
17864
- } else {
17865
- position = "right";
18014
+ if (props.outputFormat === "side-by-side") {
18015
+ const startNum = parseInt(startTrNode.children[startPosition === "left" ? 0 : 2].innerText);
18016
+ let sIndex = leftRightLineNumberArr.findIndex((item) => item[startPosition] === startNum);
18017
+ const endNum = parseInt(endTrNode.children[endPosition === "left" ? 0 : 2].innerText);
18018
+ let eIndex = leftRightLineNumberArr.findIndex((item) => item[endPosition] === endNum);
18019
+ if (sIndex > eIndex) {
18020
+ [sIndex, eIndex] = [eIndex, sIndex];
18021
+ }
18022
+ const tempArr = leftRightLineNumberArr.slice(sIndex, eIndex + 1);
18023
+ for (let i = 0; i < tempArr.length; i++) {
18024
+ const { left, right } = tempArr[i];
18025
+ if (left !== -1) {
18026
+ checkedTdNodes.push(...leftNumberTdMap[left]);
18027
+ }
18028
+ if (right !== -1) {
18029
+ checkedTdNodes.push(...rightNumberTdMap[right]);
18030
+ }
18031
+ }
17866
18032
  }
17867
- checkedTrNodes = [];
17868
- for (let i = 0; i < trNodes.length; i++) {
17869
- if (i >= startIndex && i <= endIndex) {
17870
- toggleCommentCheckedClass(trNodes[i], true, position);
17871
- checkedTrNodes.push(trNodes[i]);
18033
+ for (let i = 0; i < allTdNodes.length; i++) {
18034
+ if (checkedTdNodes.includes(allTdNodes[i])) {
18035
+ allTdNodes[i].classList.add("comment-checked");
17872
18036
  } else {
17873
- toggleCommentCheckedClass(trNodes[i], false, position);
18037
+ allTdNodes[i].classList.remove("comment-checked");
17874
18038
  }
17875
18039
  }
17876
18040
  }
17877
18041
  function onMouseup() {
17878
18042
  dragging = false;
17879
18043
  if (isMouseMoved) {
17880
- afterMouseup(getLineNumbers(checkedTrNodes, props.outputFormat, isClickedLeft ? "left" : "right"));
18044
+ let details;
18045
+ if (props.outputFormat === "side-by-side") {
18046
+ details = getDoubleCheckedNumberAndCodes(checkedTdNodes);
18047
+ } else {
18048
+ details = getSingleCheckedNumberAndCode(checkedTdNodes);
18049
+ }
18050
+ leftMinNum = details.lefts[0];
18051
+ leftMaxNum = details.lefts[details.lefts.length - 1];
18052
+ rightMinNum = details.rights[0];
18053
+ rightMaxNum = details.rights[details.rights.length - 1];
18054
+ afterMouseup(details);
17881
18055
  }
17882
18056
  document.removeEventListener("mouseup", onMouseup);
17883
18057
  document.removeEventListener("mousemove", onMousemove);
17884
18058
  }
17885
- function clearCommentChecked() {
17886
- for (let i = 0; i < trNodes.length; i++) {
17887
- toggleCommentCheckedClass(trNodes[i], false, "all");
18059
+ const getCheckedLineDetails = () => {
18060
+ if (checkedTdNodes.length) {
18061
+ return props.outputFormat === "side-by-side" ? getDoubleCheckedNumberAndCodes(checkedTdNodes) : getSingleCheckedNumberAndCode(checkedTdNodes);
17888
18062
  }
17889
- }
17890
- function toggleCommentCheckedClass(trNode, isAddClass, position) {
17891
- var _a;
17892
- const tdNodes = Array.from(trNode.children);
17893
- let toDoNodes;
17894
- if (position === "all") {
17895
- toDoNodes = tdNodes;
17896
- } else if (position === "left") {
17897
- toDoNodes = tdNodes.slice(0, 2);
18063
+ };
18064
+ const clearCommentClass = () => {
18065
+ clearCommentChecked(checkedTdNodes);
18066
+ checkedTdNodes = [];
18067
+ };
18068
+ const updateLineNumberMap = (expandLineNumberInfo, newCode, direction) => {
18069
+ const container = document.createElement("div");
18070
+ parseCodeToSingle(container, newCode, props.options);
18071
+ const { prevL, prevR, nextL, nextR } = expandLineNumberInfo;
18072
+ const arr = getLineNumberMap(Array.from(container.querySelectorAll("tr")));
18073
+ if (direction === "down") {
18074
+ const preLeft = Number(prevL) - 1;
18075
+ const preRight = Number(prevR) - 1;
18076
+ const index2 = leftRightLineNumberArr.findIndex((item) => item.left === preLeft && item.right === preRight);
18077
+ leftRightLineNumberArr.splice(index2 + 1, 0, ...arr);
17898
18078
  } else {
17899
- toDoNodes = tdNodes.slice(2);
18079
+ const nextLeft = Number(nextL) + 1;
18080
+ const nextRight = Number(nextR) + 1;
18081
+ const index2 = leftRightLineNumberArr.findIndex((item) => item.left === nextLeft && item.right === nextRight);
18082
+ leftRightLineNumberArr.splice(index2, 0, ...arr);
17900
18083
  }
17901
- if ((position === "left" || position === "right") && isNaN(parseInt((_a = toDoNodes[0]) == null ? void 0 : _a.innerHTML))) {
18084
+ };
18085
+ const updateCheckedLine = (expandLineNumberInfo, direction) => {
18086
+ const allTrNodes = Array.from(reviewContentRef.value.querySelectorAll("tr")).filter((item) => {
18087
+ var _a;
18088
+ return !((_a = item.classList) == null ? void 0 : _a.contains("expand-line"));
18089
+ });
18090
+ const { prevL, nextL } = expandLineNumberInfo;
18091
+ const num = direction === "down" ? Number(prevL) : Number(nextL);
18092
+ if (!checkedTdNodes.length || num < leftMinNum || num > leftMaxNum) {
17902
18093
  return;
17903
18094
  }
17904
- toDoNodes.forEach((item) => {
17905
- if (item.tagName === "TD") {
17906
- if (isAddClass) {
17907
- item.classList.add("comment-checked");
17908
- } else {
17909
- item.classList.remove("comment-checked");
17910
- }
18095
+ checkedTdNodes = [];
18096
+ for (let i = 0; i < allTrNodes.length; i++) {
18097
+ const itemTrNode = allTrNodes[i];
18098
+ if (props.outputFormat === "side-by-side") {
18099
+ checkedTdNodes.push(...addCommentCheckedForDouble(itemTrNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum));
18100
+ } else {
18101
+ checkedTdNodes.push(...addCommentCheckedForSingle(itemTrNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum));
17911
18102
  }
17912
- });
17913
- }
17914
- return { onMousedown: onMousedown2 };
18103
+ }
18104
+ };
18105
+ watch(
18106
+ [() => props.outputFormat, () => props.allowChecked],
18107
+ () => {
18108
+ if (props.allowChecked && props.outputFormat === "side-by-side") {
18109
+ const container = document.createElement("div");
18110
+ parseCodeToSingle(container, props.diff, props.options);
18111
+ leftRightLineNumberArr = getLineNumberMap(Array.from(container.querySelectorAll("tr")));
18112
+ }
18113
+ },
18114
+ { immediate: true }
18115
+ );
18116
+ return { onMousedown: onMousedown2, updateLineNumberMap, getCheckedLineDetails, clearCommentClass, updateCheckedLine };
17915
18117
  }
17916
18118
  function useCodeReviewComment(reviewContentRef, props, ctx2) {
17917
18119
  const { outputFormat, allowComment, allowChecked } = toRefs(props);
17918
18120
  const ns2 = useNamespace$1("code-review");
17919
- const { onMousedown: onMousedown2 } = useCodeReviewLineSelection(reviewContentRef, props, afterMouseup);
18121
+ const { onMousedown: onMousedown2, updateLineNumberMap, getCheckedLineDetails, clearCommentClass, updateCheckedLine } = useCodeReviewLineSelection(
18122
+ reviewContentRef,
18123
+ props,
18124
+ afterMouseup
18125
+ );
17920
18126
  const commentLeft = ref(-100);
17921
18127
  const commentTop = ref(-100);
17922
18128
  let currentLeftLineNumber = -1;
17923
18129
  let currentRightLineNumber = -1;
18130
+ let currentPosition;
17924
18131
  let lastLineNumberContainer;
17925
- let checkedLineNumberContainer = [];
17926
- let currentLeftLineNumbers = [];
17927
- let currentRightLineNumbers = [];
17928
- let checkedLineCodeString = {};
17929
- let allTrNodes = [];
17930
- let afterCheckLinesEmitData;
17931
- watch(
17932
- () => outputFormat.value,
17933
- () => {
17934
- checkedLineNumberContainer = [];
17935
- currentLeftLineNumbers = [];
17936
- currentRightLineNumbers = [];
17937
- checkedLineCodeString = [];
17938
- }
17939
- );
17940
18132
  const resetLeftTop = () => {
17941
18133
  commentLeft.value = -100;
17942
18134
  commentTop.value = -100;
@@ -17986,6 +18178,8 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17986
18178
  commentLeft.value = left;
17987
18179
  commentTop.value = top;
17988
18180
  currentLeftLineNumber = parseInt(leftLineNumberContainer.innerText);
18181
+ currentRightLineNumber = parseInt(rightLineNumberContainer.innerText || "-1");
18182
+ currentPosition = "left";
17989
18183
  } else {
17990
18184
  resetLeftTop();
17991
18185
  }
@@ -17999,7 +18193,9 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17999
18193
  const { top, left } = rightLineNumberContainer.getBoundingClientRect();
18000
18194
  commentLeft.value = left;
18001
18195
  commentTop.value = top;
18196
+ currentLeftLineNumber = parseInt(leftLineNumberContainer.innerText || "-1");
18002
18197
  currentRightLineNumber = parseInt(rightLineNumberContainer.innerText);
18198
+ currentPosition = "right";
18003
18199
  } else {
18004
18200
  resetLeftTop();
18005
18201
  }
@@ -18019,128 +18215,23 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18019
18215
  resetLeftTop();
18020
18216
  }
18021
18217
  };
18022
- const getCommonClassAndJudge = () => {
18023
- const checkedLine = [currentLeftLineNumbers, currentRightLineNumbers];
18024
- return {
18025
- linenumberDom: allTrNodes,
18026
- checkedLine
18027
- };
18028
- };
18029
- const addCommentCheckedClass = (Dom) => {
18030
- !Dom.classList.contains("comment-checked") && Dom.classList.add("comment-checked");
18031
- };
18032
- function getSingleCheckedLineCode(shouldRenderClass) {
18033
- const { linenumberDom, checkedLine } = getCommonClassAndJudge();
18034
- const checkedCodeContent = [];
18035
- for (let i = 0; i < linenumberDom.length; i++) {
18036
- const lineNumberDomLeft = linenumberDom[i].children[0];
18037
- const lineNumberDomRight = linenumberDom[i].children[1];
18038
- if (lineNumberDomLeft || lineNumberDomRight) {
18039
- const codeLineNumberLeft = parseInt(lineNumberDomLeft == null ? void 0 : lineNumberDomLeft.innerText);
18040
- const codeLineNumberRight = parseInt(lineNumberDomRight == null ? void 0 : lineNumberDomRight.innerText);
18041
- if (checkedLine[0].includes(codeLineNumberLeft) || checkedLine[1].includes(codeLineNumberRight)) {
18042
- checkedLineNumberContainer.push(linenumberDom[i]);
18043
- const codeNode = linenumberDom[i].nextElementSibling;
18044
- checkedCodeContent.push(codeNode == null ? void 0 : codeNode.innerText);
18045
- if (shouldRenderClass) {
18046
- addCommentCheckedClass(linenumberDom[i]);
18047
- addCommentCheckedClass(codeNode);
18048
- }
18049
- }
18050
- }
18051
- }
18052
- checkedLineCodeString = checkedCodeContent;
18053
- }
18054
- function getDoubleCheckedLineCode(shouldRenderClass) {
18055
- var _a;
18056
- const { linenumberDom, checkedLine } = getCommonClassAndJudge();
18057
- const checkedCodeContentLeft = [];
18058
- const checkedCodeContentRight = [];
18059
- function checkedFunc(Dom) {
18060
- checkedLineNumberContainer.push(Dom);
18061
- const codeNode = Dom.nextElementSibling;
18062
- if (shouldRenderClass) {
18063
- addCommentCheckedClass(Dom);
18064
- addCommentCheckedClass(codeNode);
18065
- }
18066
- return codeNode == null ? void 0 : codeNode.innerText;
18067
- }
18068
- for (let i = 0; i < linenumberDom.length; i++) {
18069
- const codeLineNumber = parseInt((_a = linenumberDom[i]) == null ? void 0 : _a.innerHTML);
18070
- if (linenumberDom[i].classList.contains("d-code-left") && checkedLine[0].includes(codeLineNumber)) {
18071
- const lineNumText = checkedFunc(linenumberDom[i]);
18072
- checkedCodeContentLeft.push(lineNumText);
18073
- continue;
18074
- }
18075
- if (linenumberDom[i].classList.contains("d-code-right") && checkedLine[1].includes(codeLineNumber)) {
18076
- const lineNumText = checkedFunc(linenumberDom[i]);
18077
- checkedCodeContentRight.push(lineNumText);
18078
- }
18079
- }
18080
- checkedLineCodeString = { leftCode: checkedCodeContentLeft, rightCode: checkedCodeContentRight };
18081
- }
18082
- function getCheckedLineCode(shouldRenderClass) {
18083
- if (props.outputFormat === "line-by-line") {
18084
- return getSingleCheckedLineCode(shouldRenderClass);
18085
- }
18086
- getDoubleCheckedLineCode(shouldRenderClass);
18087
- }
18088
- function updateLineNumbers({ lefts, rights }) {
18089
- currentLeftLineNumbers = lefts;
18090
- currentRightLineNumbers = rights;
18091
- getCheckedLineCode(false);
18092
- afterCheckLinesEmitData = {
18093
- left: currentLeftLineNumber,
18094
- right: currentRightLineNumber,
18095
- details: {
18096
- lefts: currentLeftLineNumbers,
18097
- rights: currentRightLineNumbers,
18098
- codes: checkedLineCodeString
18099
- }
18100
- };
18101
- }
18102
- const updateCheckedLineClass = () => {
18103
- const lineClassName = props.outputFormat === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
18104
- allTrNodes = reviewContentRef.value.querySelectorAll(lineClassName);
18105
- getCheckedLineCode(true);
18106
- };
18107
- const resetCommentClass = () => {
18108
- for (let i = 0; i < checkedLineNumberContainer.length; i++) {
18109
- checkedLineNumberContainer[i].classList.remove("comment-checked");
18110
- const codeNode = checkedLineNumberContainer[i].nextElementSibling;
18111
- codeNode == null ? void 0 : codeNode.classList.remove("comment-checked");
18112
- }
18113
- checkedLineNumberContainer = [];
18114
- };
18115
18218
  const commentClick = () => {
18116
- let obj = { left: currentLeftLineNumber, right: currentRightLineNumber };
18117
- if ((currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1) && allowChecked.value) {
18118
- const maxCurrentLeftLineNumber = currentLeftLineNumbers[currentLeftLineNumbers.length - 1];
18119
- const maxCurrentRightLineNumber = currentRightLineNumbers[currentRightLineNumbers.length - 1];
18120
- if (maxCurrentLeftLineNumber === currentLeftLineNumber || maxCurrentRightLineNumber === currentRightLineNumber) {
18121
- obj = {
18122
- left: currentLeftLineNumber,
18123
- right: currentRightLineNumber,
18124
- details: {
18125
- lefts: currentLeftLineNumbers,
18126
- rights: currentRightLineNumbers,
18127
- codes: checkedLineCodeString
18128
- }
18129
- };
18219
+ let obj = { left: currentLeftLineNumber, right: currentRightLineNumber, position: currentPosition };
18220
+ const checkedLineDetails = getCheckedLineDetails();
18221
+ if (checkedLineDetails && allowChecked.value) {
18222
+ const { lefts, rights } = checkedLineDetails;
18223
+ const maxCheckedLeftLineNumber = lefts[lefts.length - 1];
18224
+ const maxCheckedRightLineNumber = rights[rights.length - 1];
18225
+ if (maxCheckedLeftLineNumber === currentLeftLineNumber || maxCheckedRightLineNumber === currentRightLineNumber) {
18226
+ obj.details = checkedLineDetails;
18130
18227
  } else {
18131
- currentLeftLineNumbers = [];
18132
- currentRightLineNumbers = [];
18133
- resetCommentClass();
18228
+ clearCommentClass();
18134
18229
  }
18135
18230
  }
18136
18231
  ctx2.emit("addComment", obj);
18137
18232
  };
18138
- function afterCheckLines() {
18139
- ctx2.emit("afterCheckLines", afterCheckLinesEmitData);
18140
- }
18141
- function afterMouseup(lineNumbers) {
18142
- updateLineNumbers(lineNumbers);
18143
- afterCheckLines();
18233
+ function afterMouseup(details) {
18234
+ ctx2.emit("afterCheckLines", { left: currentLeftLineNumber, right: currentRightLineNumber, position: currentPosition, details });
18144
18235
  }
18145
18236
  const onCommentIconClick = (e) => {
18146
18237
  if (e) {
@@ -18196,15 +18287,7 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18196
18287
  }
18197
18288
  };
18198
18289
  const clearCheckedLines = () => {
18199
- currentLeftLineNumbers = [];
18200
- currentRightLineNumbers = [];
18201
- checkedLineCodeString = [];
18202
- resetCommentClass();
18203
- };
18204
- const handleMouseDown = (e) => {
18205
- const lineClassName = props.outputFormat === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
18206
- allTrNodes = reviewContentRef.value.querySelectorAll(lineClassName);
18207
- onMousedown2(e);
18290
+ clearCommentClass();
18208
18291
  };
18209
18292
  const mouseEvent = {};
18210
18293
  if (allowComment.value) {
@@ -18212,7 +18295,7 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18212
18295
  mouseEvent.onMouseleave = onMouseleave;
18213
18296
  }
18214
18297
  if (props.allowChecked) {
18215
- mouseEvent.onMousedown = handleMouseDown;
18298
+ mouseEvent.onMousedown = onMousedown2;
18216
18299
  }
18217
18300
  window.addEventListener("scroll", resetLeftTop);
18218
18301
  onUnmounted(() => {
@@ -18222,12 +18305,13 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18222
18305
  commentLeft,
18223
18306
  commentTop,
18224
18307
  mouseEvent,
18225
- updateCheckedLineClass,
18226
18308
  clearCheckedLines,
18227
18309
  onCommentMouseLeave,
18228
18310
  onCommentIconClick,
18229
18311
  insertComment,
18230
- removeComment
18312
+ removeComment,
18313
+ updateLineNumberMap,
18314
+ updateCheckedLine
18231
18315
  };
18232
18316
  }
18233
18317
  var codeReview = "";
@@ -18240,16 +18324,7 @@ var CodeReview = defineComponent({
18240
18324
  const {
18241
18325
  diffType
18242
18326
  } = toRefs(props);
18243
- const {
18244
- renderHtml,
18245
- reviewContentRef,
18246
- diffFile,
18247
- onContentClick
18248
- } = useCodeReview(props, ctx2);
18249
- const {
18250
- isFold,
18251
- toggleFold
18252
- } = useCodeReviewFold(props, ctx2);
18327
+ const reviewContentRef = ref();
18253
18328
  const {
18254
18329
  commentLeft,
18255
18330
  commentTop,
@@ -18258,15 +18333,24 @@ var CodeReview = defineComponent({
18258
18333
  onCommentIconClick,
18259
18334
  insertComment,
18260
18335
  removeComment,
18261
- updateCheckedLineClass,
18262
- clearCheckedLines
18336
+ clearCheckedLines,
18337
+ updateLineNumberMap,
18338
+ updateCheckedLine
18263
18339
  } = useCodeReviewComment(reviewContentRef, props, ctx2);
18340
+ const {
18341
+ renderHtml,
18342
+ diffFile,
18343
+ onContentClick
18344
+ } = useCodeReview(props, ctx2, reviewContentRef, updateLineNumberMap, updateCheckedLine);
18345
+ const {
18346
+ isFold,
18347
+ toggleFold
18348
+ } = useCodeReviewFold(props, ctx2);
18264
18349
  onMounted(() => {
18265
18350
  ctx2.emit("afterViewInit", {
18266
18351
  toggleFold,
18267
18352
  insertComment,
18268
18353
  removeComment,
18269
- updateCheckedLineClass,
18270
18354
  clearCheckedLines
18271
18355
  });
18272
18356
  });
@@ -35985,6 +36069,23 @@ function useEditorMd(props, ctx2) {
35985
36069
  setTimeout(() => {
35986
36070
  ctx2.emit("contentChange", editorIns.getValue());
35987
36071
  }, 100);
36072
+ containerRef.value.addEventListener("keydown", (e) => {
36073
+ let keyCombination = "";
36074
+ if (e.ctrlKey) {
36075
+ keyCombination += "Ctrl-";
36076
+ }
36077
+ if (e.altKey) {
36078
+ keyCombination += "Alt-";
36079
+ }
36080
+ if (e.shiftKey) {
36081
+ keyCombination += "Shift-";
36082
+ }
36083
+ keyCombination += e.key.toUpperCase();
36084
+ if (shortKeys[keyCombination] && typeof shortKeys[keyCombination] === "function") {
36085
+ e.preventDefault();
36086
+ shortKeys[keyCombination]();
36087
+ }
36088
+ });
35988
36089
  };
35989
36090
  const onPaste = (e) => {
35990
36091
  const clipboardData = e.clipboardData;
@@ -54305,7 +54406,7 @@ const installs = [
54305
54406
  VirtualListInstall
54306
54407
  ];
54307
54408
  var vueDevui = {
54308
- version: "1.6.26",
54409
+ version: "1.6.28",
54309
54410
  install(app) {
54310
54411
  installs.forEach((p) => app.use(p));
54311
54412
  }