vue-devui 1.6.27 → 1.6.29

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,145 @@ 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
+ var _a;
17546
+ const lineNumber = ((_a = tdNodes[0]) == null ? void 0 : _a.innerText) ? parseInt(tdNodes[0].innerText) : -1;
17547
+ if (lineNumber !== -1) {
17548
+ return { [lineNumber]: tdNodes };
17549
+ }
17550
+ }
17551
+ function getLineNumberTdMap(trNodes) {
17552
+ const left = {};
17553
+ const right = {};
17554
+ for (let i = 0; i < trNodes.length; i++) {
17555
+ const tdNodes = Array.from(trNodes[i].children);
17556
+ Object.assign(left, generateNumberTdObj(tdNodes.slice(0, 2)));
17557
+ Object.assign(right, generateNumberTdObj(tdNodes.slice(2)));
17558
+ }
17559
+ return { left, right };
17560
+ }
17561
+ function getLineNumberMap(trNodes) {
17530
17562
  var _a, _b;
17531
- const leftNumbers = [];
17532
- const rightNumbers = [];
17563
+ const result2 = [];
17533
17564
  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(rightLineNumber);
17565
+ const lineNumberNodes = trNodes[i].children[0].children;
17566
+ if (lineNumberNodes.length === 2) {
17567
+ const left = parseInt((_a = lineNumberNodes[0]) == null ? void 0 : _a.innerText) || -1;
17568
+ const right = parseInt((_b = lineNumberNodes[1]) == null ? void 0 : _b.innerText) || -1;
17569
+ result2.push({ left, right });
17570
+ }
17571
+ }
17572
+ return result2;
17573
+ }
17574
+ function getDoubleCheckedNumberAndCodes(checkedTdNodes) {
17575
+ const lefts = [];
17576
+ const rights = [];
17577
+ const leftCode = [];
17578
+ const rightCode = [];
17579
+ const leftNumberNodes = [];
17580
+ const rightNumberNodes = [];
17581
+ for (let i = 0; i < checkedTdNodes.length; i++) {
17582
+ const itemTdNode = checkedTdNodes[i];
17583
+ if (itemTdNode.classList.contains("d-code-left")) {
17584
+ if (itemTdNode.classList.contains("d2h-code-side-linenumber")) {
17585
+ leftNumberNodes.push(itemTdNode);
17586
+ } else {
17587
+ leftCode.push(itemTdNode.innerText);
17588
+ }
17541
17589
  } 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
- }
17590
+ if (itemTdNode.classList.contains("d2h-code-side-linenumber")) {
17591
+ rightNumberNodes.push(itemTdNode);
17592
+ } else {
17593
+ rightCode.push(itemTdNode.innerText);
17549
17594
  }
17550
17595
  }
17551
17596
  }
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 };
17597
+ if (leftNumberNodes.length) {
17598
+ const leftMinNum = parseInt(leftNumberNodes[0].innerText);
17599
+ const leftMaxNum = parseInt(leftNumberNodes[leftNumberNodes.length - 1].innerText);
17600
+ lefts.push(...getFullNumberList(leftMinNum, leftMaxNum));
17601
+ }
17602
+ if (rightNumberNodes.length) {
17603
+ const rightMinNum = parseInt(rightNumberNodes[0].innerText);
17604
+ const rightMaxNum = parseInt(rightNumberNodes[rightNumberNodes.length - 1].innerText);
17605
+ rights.push(...getFullNumberList(rightMinNum, rightMaxNum));
17606
+ }
17607
+ return { lefts, rights, codes: { leftCode, rightCode } };
17608
+ }
17609
+ function getSingleCheckedNumberAndCode(checkedTdNodes) {
17610
+ const lefts = [];
17611
+ const rights = [];
17612
+ const codes = [];
17613
+ const leftNumbers = [];
17614
+ const rightNumbers = [];
17615
+ for (let i = 0; i < checkedTdNodes.length; i++) {
17616
+ const itemTdNode = checkedTdNodes[i];
17617
+ if (itemTdNode.classList.contains("d2h-code-linenumber")) {
17618
+ const numberChildren = itemTdNode.children;
17619
+ const leftNum = parseInt(numberChildren[0].innerText);
17620
+ const rightNum = parseInt(numberChildren[1].innerText);
17621
+ !isNaN(leftNum) && leftNumbers.push(leftNum);
17622
+ !isNaN(rightNum) && rightNumbers.push(rightNum);
17623
+ } else {
17624
+ codes.push(itemTdNode.innerText);
17625
+ }
17626
+ }
17627
+ lefts.push(...getFullNumberList(leftNumbers[0], leftNumbers[leftNumbers.length - 1]));
17628
+ rights.push(...getFullNumberList(rightNumbers[0], rightNumbers[rightNumbers.length - 1]));
17629
+ return { lefts, rights, codes };
17630
+ }
17631
+ function addCommentCheckedForDouble(trNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum) {
17632
+ const [leftNumTd, leftCodeTd, rightNumTd, rightCodeTd] = trNode.children;
17633
+ const leftNum = parseInt(leftNumTd.innerText);
17634
+ const rightNum = parseInt(rightNumTd.innerText);
17635
+ const result2 = [];
17636
+ if (!isNaN(leftNum) && leftNum >= leftMinNum && leftNum <= leftMaxNum) {
17637
+ if (!leftNumTd.classList.contains("comment-checked")) {
17638
+ leftNumTd.classList.add("comment-checked");
17639
+ leftCodeTd.classList.add("comment-checked");
17640
+ }
17641
+ result2.push(leftNumTd, leftCodeTd);
17642
+ }
17643
+ if (!isNaN(rightNum) && rightNum >= rightMinNum && rightNum <= rightMaxNum) {
17644
+ if (!rightNumTd.classList.contains("comment-checked")) {
17645
+ rightNumTd.classList.add("comment-checked");
17646
+ rightCodeTd.classList.add("comment-checked");
17647
+ }
17648
+ result2.push(rightNumTd, rightCodeTd);
17649
+ }
17650
+ return result2;
17651
+ }
17652
+ function addCommentCheckedForSingle(trNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum) {
17653
+ const [numTd, codeTd] = trNode.children;
17654
+ const [leftNumNode, rightNumNode] = numTd.children;
17655
+ const leftNum = parseInt(leftNumNode.innerText);
17656
+ const rightNum = parseInt(rightNumNode.innerText);
17657
+ const result2 = [];
17658
+ if (!isNaN(leftNum) && leftNum >= leftMinNum && leftNum <= leftMaxNum || !isNaN(rightNum) && rightNum >= rightMinNum && rightNum <= rightMaxNum) {
17659
+ if (!numTd.classList.contains("comment-checked")) {
17660
+ numTd.classList.add("comment-checked");
17661
+ codeTd.classList.add("comment-checked");
17662
+ }
17663
+ result2.push(numTd, codeTd);
17664
+ }
17665
+ return result2;
17555
17666
  }
17556
- function useCodeReviewExpand(reviewContentRef, props) {
17667
+ function useCodeReviewExpand(reviewContentRef, props, updateLineNumberMap, updateCheckedLine) {
17557
17668
  const { outputFormat, expandThreshold, expandLoader } = toRefs(props);
17558
17669
  const processSideBySide = () => {
17559
17670
  var _a;
@@ -17613,7 +17724,9 @@ function useCodeReviewExpand(reviewContentRef, props) {
17613
17724
  return;
17614
17725
  }
17615
17726
  const trNodesToBeInserted = trNodes.filter((element) => element !== expandLine);
17727
+ updateLineNumberMap(referenceDom.dataset, prefix + code, direction);
17616
17728
  insertIncrementLineToPage(referenceDom, trNodesToBeInserted, direction);
17729
+ updateCheckedLine(referenceDom.dataset, direction);
17617
17730
  const removedExpandLine = ifRemoveExpandLineForDoubleColumn(referenceDom, expandLine, direction);
17618
17731
  if (removedExpandLine) {
17619
17732
  return;
@@ -17697,6 +17810,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17697
17810
  }
17698
17811
  const trNodesToBeInserted = trNodes.filter((element) => element.children[0].children.length === 2);
17699
17812
  insertIncrementLineToPage(referenceDom, trNodesToBeInserted, direction);
17813
+ updateCheckedLine(referenceDom.dataset, direction);
17700
17814
  const removedExpandLine = ifRemoveExpandLine(referenceDom, expandLine, direction);
17701
17815
  if (removedExpandLine) {
17702
17816
  return;
@@ -17738,12 +17852,11 @@ function useCodeReviewExpand(reviewContentRef, props) {
17738
17852
  };
17739
17853
  return { insertExpandButton, onExpandButtonClick };
17740
17854
  }
17741
- function useCodeReview(props, ctx2) {
17855
+ function useCodeReview(props, ctx2, reviewContentRef, updateLineNumberMap, updateCheckedLine) {
17742
17856
  const { diff, outputFormat, allowExpand, showBlob } = toRefs(props);
17743
17857
  const renderHtml = ref("");
17744
- const reviewContentRef = ref();
17745
17858
  const diffFile = ref([]);
17746
- const { insertExpandButton, onExpandButtonClick } = useCodeReviewExpand(reviewContentRef, props);
17859
+ const { insertExpandButton, onExpandButtonClick } = useCodeReviewExpand(reviewContentRef, props, updateLineNumberMap, updateCheckedLine);
17747
17860
  const initDiffContent = () => {
17748
17861
  diffFile.value = Diff2Html.parse(diff.value);
17749
17862
  nextTick(() => {
@@ -17760,7 +17873,7 @@ function useCodeReview(props, ctx2) {
17760
17873
  watch(showBlob, initDiffContent);
17761
17874
  watch(outputFormat, initDiffContent);
17762
17875
  watch(diff, initDiffContent, { immediate: true });
17763
- return { renderHtml, reviewContentRef, diffFile, onContentClick };
17876
+ return { renderHtml, diffFile, onContentClick };
17764
17877
  }
17765
17878
  function useCodeReviewFold(props, ctx2) {
17766
17879
  const { fold } = toRefs(props);
@@ -17785,38 +17898,52 @@ function useCodeReviewLineSelection(reviewContentRef, props, afterMouseup) {
17785
17898
  let dragging = false;
17786
17899
  let startTrNode;
17787
17900
  let trNodes;
17788
- let isClickedLeft;
17901
+ let allTdNodes = [];
17789
17902
  let shouldClear;
17790
17903
  let isMouseMoved;
17791
- let checkedTrNodes = [];
17904
+ let leftRightLineNumberArr = [];
17905
+ let leftNumberTdMap = {};
17906
+ let rightNumberTdMap = {};
17907
+ let checkedTdNodes = [];
17908
+ let startPosition;
17909
+ let leftMinNum;
17910
+ let leftMaxNum;
17911
+ let rightMinNum;
17912
+ let rightMaxNum;
17792
17913
  const onMousedown2 = (e) => {
17914
+ var _a;
17793
17915
  if (e.button === 0) {
17794
17916
  const composedPath = e.composedPath();
17795
17917
  const lineNumberBox = composedPath.find(
17796
17918
  (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"));
17919
+ var _a2, _b;
17920
+ return ((_a2 = item.classList) == null ? void 0 : _a2.contains("comment-icon-hover")) || ((_b = item.classList) == null ? void 0 : _b.contains("comment-icon"));
17799
17921
  }
17800
17922
  );
17801
17923
  trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr")).filter((item) => {
17802
- var _a;
17803
- return !((_a = item.classList) == null ? void 0 : _a.contains("expand-line"));
17924
+ var _a2;
17925
+ return !((_a2 = item.classList) == null ? void 0 : _a2.contains("expand-line"));
17804
17926
  });
17805
17927
  if (!lineNumberBox) {
17806
17928
  return;
17807
17929
  }
17808
17930
  const parentTrNode = findParentTrNode(e.target);
17809
- if (parentTrNode && (parentTrNode == null ? void 0 : parentTrNode.classList.contains("expand-line"))) {
17931
+ if (parentTrNode && ((_a = parentTrNode == null ? void 0 : parentTrNode.classList) == null ? void 0 : _a.contains("expand-line"))) {
17810
17932
  return;
17811
17933
  }
17812
17934
  startTrNode = parentTrNode;
17935
+ allTdNodes = [];
17936
+ for (let i = 0; i < trNodes.length; i++) {
17937
+ allTdNodes.push(...trNodes[i].children);
17938
+ }
17813
17939
  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;
17940
+ const { left, right } = getLineNumberTdMap(trNodes);
17941
+ leftNumberTdMap = left;
17942
+ rightNumberTdMap = right;
17943
+ startPosition = composedPath.some((item) => {
17944
+ var _a2;
17945
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains("d-code-left");
17946
+ }) ? "left" : "right";
17820
17947
  }
17821
17948
  dragging = true;
17822
17949
  shouldClear = true;
@@ -17828,115 +17955,181 @@ function useCodeReviewLineSelection(reviewContentRef, props, afterMouseup) {
17828
17955
  }
17829
17956
  };
17830
17957
  function onMousemove(e) {
17958
+ var _a, _b;
17831
17959
  if (!dragging) {
17832
17960
  return;
17833
17961
  }
17834
- isMouseMoved = true;
17835
17962
  if (shouldClear) {
17836
- clearCommentChecked();
17963
+ clearCommentChecked(checkedTdNodes);
17837
17964
  shouldClear = false;
17838
17965
  }
17839
17966
  const composedPath = e.composedPath();
17840
17967
  const inReviewContent = composedPath.some((item) => {
17841
- var _a;
17842
- return (_a = item.classList) == null ? void 0 : _a.contains(ns2.e("content"));
17968
+ var _a2;
17969
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains(ns2.e("content"));
17843
17970
  });
17844
17971
  if (!inReviewContent) {
17845
17972
  return;
17846
17973
  }
17847
17974
  const endTrNode = findParentTrNode(e.target);
17975
+ let endPosition;
17976
+ if (props.outputFormat === "side-by-side") {
17977
+ if (composedPath.some((item) => {
17978
+ var _a2;
17979
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains("d-code-left");
17980
+ })) {
17981
+ endPosition = "left";
17982
+ }
17983
+ if (composedPath.some((item) => {
17984
+ var _a2;
17985
+ return (_a2 = item.classList) == null ? void 0 : _a2.contains("d-code-right");
17986
+ })) {
17987
+ endPosition = "right";
17988
+ }
17989
+ }
17848
17990
  if (!endTrNode) {
17849
17991
  return;
17850
17992
  }
17851
- let startIndex = trNodes.indexOf(startTrNode);
17852
- let endIndex = trNodes.indexOf(endTrNode);
17853
- if (endIndex === -1) {
17993
+ isMouseMoved = true;
17994
+ const endTrChildren = endTrNode.children;
17995
+ 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
17996
  return;
17855
17997
  }
17856
- if (startIndex > endIndex) {
17857
- [startIndex, endIndex] = [endIndex, startIndex];
17998
+ checkedTdNodes = [];
17999
+ if (props.outputFormat === "line-by-line") {
18000
+ let startIndex = trNodes.indexOf(startTrNode);
18001
+ let endIndex = trNodes.indexOf(endTrNode);
18002
+ if (endIndex === -1) {
18003
+ return;
18004
+ }
18005
+ if (startIndex > endIndex) {
18006
+ [startIndex, endIndex] = [endIndex, startIndex];
18007
+ }
18008
+ for (let i = 0; i < trNodes.length; i++) {
18009
+ const tdNodes = Array.from(trNodes[i].children);
18010
+ if (i >= startIndex && i <= endIndex) {
18011
+ checkedTdNodes.push(...tdNodes);
18012
+ }
18013
+ }
17858
18014
  }
17859
- let position;
17860
- if (isClickedLeft === void 0) {
17861
- position = "all";
17862
- } else if (isClickedLeft) {
17863
- position = "left";
17864
- } else {
17865
- position = "right";
18015
+ if (props.outputFormat === "side-by-side") {
18016
+ const startNum = parseInt(startTrNode.children[startPosition === "left" ? 0 : 2].innerText);
18017
+ let sIndex = leftRightLineNumberArr.findIndex((item) => item[startPosition] === startNum);
18018
+ const endNum = parseInt(endTrNode.children[endPosition === "left" ? 0 : 2].innerText);
18019
+ let eIndex = leftRightLineNumberArr.findIndex((item) => item[endPosition] === endNum);
18020
+ if (sIndex > eIndex) {
18021
+ [sIndex, eIndex] = [eIndex, sIndex];
18022
+ }
18023
+ const tempArr = leftRightLineNumberArr.slice(sIndex, eIndex + 1);
18024
+ for (let i = 0; i < tempArr.length; i++) {
18025
+ const { left, right } = tempArr[i];
18026
+ if (left !== -1) {
18027
+ checkedTdNodes.push(...leftNumberTdMap[left]);
18028
+ }
18029
+ if (right !== -1) {
18030
+ checkedTdNodes.push(...rightNumberTdMap[right]);
18031
+ }
18032
+ }
17866
18033
  }
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]);
18034
+ for (let i = 0; i < allTdNodes.length; i++) {
18035
+ if (checkedTdNodes.includes(allTdNodes[i])) {
18036
+ allTdNodes[i].classList.add("comment-checked");
17872
18037
  } else {
17873
- toggleCommentCheckedClass(trNodes[i], false, position);
18038
+ allTdNodes[i].classList.remove("comment-checked");
17874
18039
  }
17875
18040
  }
17876
18041
  }
17877
18042
  function onMouseup() {
17878
18043
  dragging = false;
17879
18044
  if (isMouseMoved) {
17880
- afterMouseup(getLineNumbers(checkedTrNodes, props.outputFormat, isClickedLeft ? "left" : "right"));
18045
+ let details;
18046
+ if (props.outputFormat === "side-by-side") {
18047
+ details = getDoubleCheckedNumberAndCodes(checkedTdNodes);
18048
+ } else {
18049
+ details = getSingleCheckedNumberAndCode(checkedTdNodes);
18050
+ }
18051
+ leftMinNum = details.lefts[0];
18052
+ leftMaxNum = details.lefts[details.lefts.length - 1];
18053
+ rightMinNum = details.rights[0];
18054
+ rightMaxNum = details.rights[details.rights.length - 1];
18055
+ afterMouseup(details);
17881
18056
  }
17882
18057
  document.removeEventListener("mouseup", onMouseup);
17883
18058
  document.removeEventListener("mousemove", onMousemove);
17884
18059
  }
17885
- function clearCommentChecked() {
17886
- for (let i = 0; i < trNodes.length; i++) {
17887
- toggleCommentCheckedClass(trNodes[i], false, "all");
18060
+ const getCheckedLineDetails = () => {
18061
+ if (checkedTdNodes.length) {
18062
+ return props.outputFormat === "side-by-side" ? getDoubleCheckedNumberAndCodes(checkedTdNodes) : getSingleCheckedNumberAndCode(checkedTdNodes);
17888
18063
  }
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);
18064
+ };
18065
+ const clearCommentClass = () => {
18066
+ clearCommentChecked(checkedTdNodes);
18067
+ checkedTdNodes = [];
18068
+ };
18069
+ const updateLineNumberMap = (expandLineNumberInfo, newCode, direction) => {
18070
+ const container = document.createElement("div");
18071
+ parseCodeToSingle(container, newCode, props.options);
18072
+ const { prevL, prevR, nextL, nextR } = expandLineNumberInfo;
18073
+ const arr = getLineNumberMap(Array.from(container.querySelectorAll("tr")));
18074
+ if (direction === "down") {
18075
+ const preLeft = Number(prevL) - 1;
18076
+ const preRight = Number(prevR) - 1;
18077
+ const index2 = leftRightLineNumberArr.findIndex((item) => item.left === preLeft && item.right === preRight);
18078
+ leftRightLineNumberArr.splice(index2 + 1, 0, ...arr);
17898
18079
  } else {
17899
- toDoNodes = tdNodes.slice(2);
18080
+ const nextLeft = Number(nextL) + 1;
18081
+ const nextRight = Number(nextR) + 1;
18082
+ const index2 = leftRightLineNumberArr.findIndex((item) => item.left === nextLeft && item.right === nextRight);
18083
+ leftRightLineNumberArr.splice(index2, 0, ...arr);
17900
18084
  }
17901
- if ((position === "left" || position === "right") && isNaN(parseInt((_a = toDoNodes[0]) == null ? void 0 : _a.innerHTML))) {
18085
+ };
18086
+ const updateCheckedLine = (expandLineNumberInfo, direction) => {
18087
+ const allTrNodes = Array.from(reviewContentRef.value.querySelectorAll("tr")).filter((item) => {
18088
+ var _a;
18089
+ return !((_a = item.classList) == null ? void 0 : _a.contains("expand-line"));
18090
+ });
18091
+ const { prevL, nextL } = expandLineNumberInfo;
18092
+ const num = direction === "down" ? Number(prevL) : Number(nextL);
18093
+ if (!checkedTdNodes.length || num < leftMinNum || num > leftMaxNum) {
17902
18094
  return;
17903
18095
  }
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
- }
18096
+ checkedTdNodes = [];
18097
+ for (let i = 0; i < allTrNodes.length; i++) {
18098
+ const itemTrNode = allTrNodes[i];
18099
+ if (props.outputFormat === "side-by-side") {
18100
+ checkedTdNodes.push(...addCommentCheckedForDouble(itemTrNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum));
18101
+ } else {
18102
+ checkedTdNodes.push(...addCommentCheckedForSingle(itemTrNode, leftMinNum, leftMaxNum, rightMinNum, rightMaxNum));
17911
18103
  }
17912
- });
17913
- }
17914
- return { onMousedown: onMousedown2 };
18104
+ }
18105
+ };
18106
+ watch(
18107
+ [() => props.outputFormat, () => props.allowChecked],
18108
+ () => {
18109
+ if (props.allowChecked && props.outputFormat === "side-by-side") {
18110
+ const container = document.createElement("div");
18111
+ parseCodeToSingle(container, props.diff, props.options);
18112
+ leftRightLineNumberArr = getLineNumberMap(Array.from(container.querySelectorAll("tr")));
18113
+ }
18114
+ },
18115
+ { immediate: true }
18116
+ );
18117
+ return { onMousedown: onMousedown2, updateLineNumberMap, getCheckedLineDetails, clearCommentClass, updateCheckedLine };
17915
18118
  }
17916
18119
  function useCodeReviewComment(reviewContentRef, props, ctx2) {
17917
18120
  const { outputFormat, allowComment, allowChecked } = toRefs(props);
17918
18121
  const ns2 = useNamespace$1("code-review");
17919
- const { onMousedown: onMousedown2 } = useCodeReviewLineSelection(reviewContentRef, props, afterMouseup);
18122
+ const { onMousedown: onMousedown2, updateLineNumberMap, getCheckedLineDetails, clearCommentClass, updateCheckedLine } = useCodeReviewLineSelection(
18123
+ reviewContentRef,
18124
+ props,
18125
+ afterMouseup
18126
+ );
17920
18127
  const commentLeft = ref(-100);
17921
18128
  const commentTop = ref(-100);
17922
18129
  let currentLeftLineNumber = -1;
17923
18130
  let currentRightLineNumber = -1;
18131
+ let currentPosition;
17924
18132
  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
18133
  const resetLeftTop = () => {
17941
18134
  commentLeft.value = -100;
17942
18135
  commentTop.value = -100;
@@ -17986,6 +18179,8 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17986
18179
  commentLeft.value = left;
17987
18180
  commentTop.value = top;
17988
18181
  currentLeftLineNumber = parseInt(leftLineNumberContainer.innerText);
18182
+ currentRightLineNumber = parseInt(rightLineNumberContainer.innerText || "-1");
18183
+ currentPosition = "left";
17989
18184
  } else {
17990
18185
  resetLeftTop();
17991
18186
  }
@@ -17999,7 +18194,9 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17999
18194
  const { top, left } = rightLineNumberContainer.getBoundingClientRect();
18000
18195
  commentLeft.value = left;
18001
18196
  commentTop.value = top;
18197
+ currentLeftLineNumber = parseInt(leftLineNumberContainer.innerText || "-1");
18002
18198
  currentRightLineNumber = parseInt(rightLineNumberContainer.innerText);
18199
+ currentPosition = "right";
18003
18200
  } else {
18004
18201
  resetLeftTop();
18005
18202
  }
@@ -18019,128 +18216,23 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18019
18216
  resetLeftTop();
18020
18217
  }
18021
18218
  };
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
18219
  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
- };
18220
+ let obj = { left: currentLeftLineNumber, right: currentRightLineNumber, position: currentPosition };
18221
+ const checkedLineDetails = getCheckedLineDetails();
18222
+ if (checkedLineDetails && allowChecked.value) {
18223
+ const { lefts, rights } = checkedLineDetails;
18224
+ const maxCheckedLeftLineNumber = lefts[lefts.length - 1];
18225
+ const maxCheckedRightLineNumber = rights[rights.length - 1];
18226
+ if (maxCheckedLeftLineNumber === currentLeftLineNumber || maxCheckedRightLineNumber === currentRightLineNumber) {
18227
+ obj.details = checkedLineDetails;
18130
18228
  } else {
18131
- currentLeftLineNumbers = [];
18132
- currentRightLineNumbers = [];
18133
- resetCommentClass();
18229
+ clearCommentClass();
18134
18230
  }
18135
18231
  }
18136
18232
  ctx2.emit("addComment", obj);
18137
18233
  };
18138
- function afterCheckLines() {
18139
- ctx2.emit("afterCheckLines", afterCheckLinesEmitData);
18140
- }
18141
- function afterMouseup(lineNumbers) {
18142
- updateLineNumbers(lineNumbers);
18143
- afterCheckLines();
18234
+ function afterMouseup(details) {
18235
+ ctx2.emit("afterCheckLines", { left: currentLeftLineNumber, right: currentRightLineNumber, position: currentPosition, details });
18144
18236
  }
18145
18237
  const onCommentIconClick = (e) => {
18146
18238
  if (e) {
@@ -18196,15 +18288,7 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18196
18288
  }
18197
18289
  };
18198
18290
  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);
18291
+ clearCommentClass();
18208
18292
  };
18209
18293
  const mouseEvent = {};
18210
18294
  if (allowComment.value) {
@@ -18212,7 +18296,7 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18212
18296
  mouseEvent.onMouseleave = onMouseleave;
18213
18297
  }
18214
18298
  if (props.allowChecked) {
18215
- mouseEvent.onMousedown = handleMouseDown;
18299
+ mouseEvent.onMousedown = onMousedown2;
18216
18300
  }
18217
18301
  window.addEventListener("scroll", resetLeftTop);
18218
18302
  onUnmounted(() => {
@@ -18222,12 +18306,13 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18222
18306
  commentLeft,
18223
18307
  commentTop,
18224
18308
  mouseEvent,
18225
- updateCheckedLineClass,
18226
18309
  clearCheckedLines,
18227
18310
  onCommentMouseLeave,
18228
18311
  onCommentIconClick,
18229
18312
  insertComment,
18230
- removeComment
18313
+ removeComment,
18314
+ updateLineNumberMap,
18315
+ updateCheckedLine
18231
18316
  };
18232
18317
  }
18233
18318
  var codeReview = "";
@@ -18240,16 +18325,7 @@ var CodeReview = defineComponent({
18240
18325
  const {
18241
18326
  diffType
18242
18327
  } = 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);
18328
+ const reviewContentRef = ref();
18253
18329
  const {
18254
18330
  commentLeft,
18255
18331
  commentTop,
@@ -18258,15 +18334,24 @@ var CodeReview = defineComponent({
18258
18334
  onCommentIconClick,
18259
18335
  insertComment,
18260
18336
  removeComment,
18261
- updateCheckedLineClass,
18262
- clearCheckedLines
18337
+ clearCheckedLines,
18338
+ updateLineNumberMap,
18339
+ updateCheckedLine
18263
18340
  } = useCodeReviewComment(reviewContentRef, props, ctx2);
18341
+ const {
18342
+ renderHtml,
18343
+ diffFile,
18344
+ onContentClick
18345
+ } = useCodeReview(props, ctx2, reviewContentRef, updateLineNumberMap, updateCheckedLine);
18346
+ const {
18347
+ isFold,
18348
+ toggleFold
18349
+ } = useCodeReviewFold(props, ctx2);
18264
18350
  onMounted(() => {
18265
18351
  ctx2.emit("afterViewInit", {
18266
18352
  toggleFold,
18267
18353
  insertComment,
18268
18354
  removeComment,
18269
- updateCheckedLineClass,
18270
18355
  clearCheckedLines
18271
18356
  });
18272
18357
  });
@@ -35432,13 +35517,26 @@ ToolBarHandler.fullscreen = (editor) => {
35432
35517
  };
35433
35518
  ToolBarHandler.color = () => {
35434
35519
  };
35520
+ const GET_CTRL_KEY = () => {
35521
+ var _a;
35522
+ if (typeof window !== "undefined") {
35523
+ return ((_a = navigator == null ? void 0 : navigator.platform) == null ? void 0 : _a.indexOf("Mac")) !== -1 ? "\u2318" : "Ctrl";
35524
+ }
35525
+ };
35526
+ const GET_ALT_KEY = () => {
35527
+ var _a;
35528
+ if (typeof window !== "undefined") {
35529
+ return ((_a = navigator == null ? void 0 : navigator.platform) == null ? void 0 : _a.indexOf("Mac")) !== -1 ? "\u2325" : "Alt";
35530
+ }
35531
+ };
35435
35532
  const DEFAULT_TOOLBARS = {
35436
35533
  undo: {
35437
35534
  id: "undo",
35438
35535
  name: "undo",
35439
35536
  type: "button",
35440
35537
  icon: UNDO_ICON,
35441
- shortKey: "Ctrl+Z",
35538
+ shortKey: `${GET_CTRL_KEY()}+Z`,
35539
+ shortKeyWithCode: `${GET_CTRL_KEY()}+90`,
35442
35540
  handler: ToolBarHandler.undo
35443
35541
  },
35444
35542
  redo: {
@@ -35446,7 +35544,8 @@ const DEFAULT_TOOLBARS = {
35446
35544
  name: "redo",
35447
35545
  type: "button",
35448
35546
  icon: REDO_ICON,
35449
- shortKey: "Ctrl+Y",
35547
+ shortKey: `${GET_CTRL_KEY()}+Y`,
35548
+ shortKeyWithCode: `${GET_CTRL_KEY()}+89`,
35450
35549
  handler: ToolBarHandler.redo
35451
35550
  },
35452
35551
  bold: {
@@ -35454,7 +35553,8 @@ const DEFAULT_TOOLBARS = {
35454
35553
  name: "bold",
35455
35554
  type: "button",
35456
35555
  icon: BOLD_ICON,
35457
- shortKey: "Ctrl+B",
35556
+ shortKey: `${GET_CTRL_KEY()}+B`,
35557
+ shortKeyWithCode: `${GET_CTRL_KEY()}+66`,
35458
35558
  handler: ToolBarHandler.bold
35459
35559
  },
35460
35560
  italic: {
@@ -35462,7 +35562,8 @@ const DEFAULT_TOOLBARS = {
35462
35562
  name: "italic",
35463
35563
  type: "button",
35464
35564
  icon: ITALIC_ICON,
35465
- shortKey: "Ctrl+I",
35565
+ shortKey: `${GET_CTRL_KEY()}+I`,
35566
+ shortKeyWithCode: `${GET_CTRL_KEY()}+73`,
35466
35567
  handler: ToolBarHandler.italic
35467
35568
  },
35468
35569
  strike: {
@@ -35470,7 +35571,8 @@ const DEFAULT_TOOLBARS = {
35470
35571
  name: "strike",
35471
35572
  type: "button",
35472
35573
  icon: STRIKE_ICON,
35473
- shortKey: "Ctrl+D",
35574
+ shortKey: `${GET_CTRL_KEY()}+D`,
35575
+ shortKeyWithCode: `${GET_CTRL_KEY()}+68`,
35474
35576
  handler: ToolBarHandler.strike
35475
35577
  },
35476
35578
  h1: {
@@ -35478,7 +35580,8 @@ const DEFAULT_TOOLBARS = {
35478
35580
  name: "h1",
35479
35581
  type: "button",
35480
35582
  icon: H1_ICON,
35481
- shortKey: "Ctrl+1",
35583
+ shortKey: `${GET_CTRL_KEY()}+1`,
35584
+ shortKeyWithCode: `${GET_CTRL_KEY()}+49`,
35482
35585
  handler: ToolBarHandler.h1
35483
35586
  },
35484
35587
  h2: {
@@ -35486,7 +35589,8 @@ const DEFAULT_TOOLBARS = {
35486
35589
  name: "h2",
35487
35590
  type: "button",
35488
35591
  icon: H2_ICON,
35489
- shortKey: "Ctrl+2",
35592
+ shortKey: `${GET_CTRL_KEY()}+2`,
35593
+ shortKeyWithCode: `${GET_CTRL_KEY()}+50`,
35490
35594
  handler: ToolBarHandler.h2
35491
35595
  },
35492
35596
  ul: {
@@ -35494,7 +35598,8 @@ const DEFAULT_TOOLBARS = {
35494
35598
  name: "unorderedlist",
35495
35599
  type: "button",
35496
35600
  icon: LIST_UNORDERED_ICON,
35497
- shortKey: "Ctrl+U",
35601
+ shortKey: `${GET_CTRL_KEY()}+U`,
35602
+ shortKeyWithCode: `${GET_CTRL_KEY()}+85`,
35498
35603
  handler: ToolBarHandler.ul
35499
35604
  },
35500
35605
  ol: {
@@ -35502,7 +35607,8 @@ const DEFAULT_TOOLBARS = {
35502
35607
  name: "orderedlist",
35503
35608
  type: "button",
35504
35609
  icon: LIST_ORDERED_ICON,
35505
- shortKey: "Ctrl+O",
35610
+ shortKey: `${GET_CTRL_KEY()}+O`,
35611
+ shortKeyWithCode: `${GET_CTRL_KEY()}+79`,
35506
35612
  handler: ToolBarHandler.ol
35507
35613
  },
35508
35614
  checklist: {
@@ -35510,7 +35616,8 @@ const DEFAULT_TOOLBARS = {
35510
35616
  name: "checklist",
35511
35617
  type: "button",
35512
35618
  icon: LIST_CHECK_ICON,
35513
- shortKey: "Ctrl+Alt+C",
35619
+ shortKey: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+C`,
35620
+ shortKeyWithCode: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+67`,
35514
35621
  handler: ToolBarHandler.checkList
35515
35622
  },
35516
35623
  underline: {
@@ -35518,7 +35625,8 @@ const DEFAULT_TOOLBARS = {
35518
35625
  name: "underline",
35519
35626
  type: "button",
35520
35627
  icon: UNDERLINE_ICON,
35521
- shortKey: "Ctrl+R",
35628
+ shortKey: `${GET_CTRL_KEY()}+R`,
35629
+ shortKeyWithCode: `${GET_CTRL_KEY()}+82`,
35522
35630
  handler: ToolBarHandler.underline
35523
35631
  },
35524
35632
  font: {
@@ -35534,7 +35642,8 @@ const DEFAULT_TOOLBARS = {
35534
35642
  name: "link",
35535
35643
  type: "button",
35536
35644
  icon: LINK_ICON,
35537
- shortKey: "Ctrl+L",
35645
+ shortKey: `${GET_CTRL_KEY()}+L`,
35646
+ shortKeyWithCode: `${GET_CTRL_KEY()}+76`,
35538
35647
  handler: ToolBarHandler.link
35539
35648
  },
35540
35649
  image: {
@@ -35542,7 +35651,8 @@ const DEFAULT_TOOLBARS = {
35542
35651
  name: "image",
35543
35652
  type: "button",
35544
35653
  icon: IMAGE_ICON,
35545
- shortKey: "Ctrl+G",
35654
+ shortKey: `${GET_CTRL_KEY()}+G`,
35655
+ shortKeyWithCode: `${GET_CTRL_KEY()}+71`,
35546
35656
  params: { imageUploadToServer: false },
35547
35657
  handler: ToolBarHandler.image
35548
35658
  },
@@ -35552,7 +35662,8 @@ const DEFAULT_TOOLBARS = {
35552
35662
  type: "button",
35553
35663
  icon: FILE_ICON,
35554
35664
  params: {},
35555
- shortKey: "Ctrl+F",
35665
+ shortKey: `${GET_CTRL_KEY()}+F`,
35666
+ shortKeyWithCode: `${GET_CTRL_KEY()}+70`,
35556
35667
  handler: ToolBarHandler.file
35557
35668
  },
35558
35669
  code: {
@@ -35560,7 +35671,8 @@ const DEFAULT_TOOLBARS = {
35560
35671
  name: "code",
35561
35672
  type: "button",
35562
35673
  icon: CODE_ICON,
35563
- shortKey: "Ctrl+K",
35674
+ shortKey: `${GET_CTRL_KEY()}+K`,
35675
+ shortKeyWithCode: `${GET_CTRL_KEY()}+75`,
35564
35676
  handler: ToolBarHandler.code
35565
35677
  },
35566
35678
  table: {
@@ -35568,7 +35680,8 @@ const DEFAULT_TOOLBARS = {
35568
35680
  name: "table",
35569
35681
  type: "button",
35570
35682
  icon: TABLE_ICON,
35571
- shortKey: "Ctrl+Alt+T",
35683
+ shortKey: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+T`,
35684
+ shortKeyWithCode: `${GET_CTRL_KEY()}+${GET_ALT_KEY()}+84`,
35572
35685
  handler: ToolBarHandler.table
35573
35686
  },
35574
35687
  fullscreen: {
@@ -35962,8 +36075,8 @@ function useEditorMd(props, ctx2) {
35962
36075
  const tempToolbars = { ...toolbars, ...customToolbars == null ? void 0 : customToolbars.value };
35963
36076
  for (const key of Object.keys(tempToolbars)) {
35964
36077
  const toolbarItem = tempToolbars[key];
35965
- if (toolbarItem.shortKey && flatToolbarConfig.includes(toolbarItem.id)) {
35966
- shortKeys[toolbarItem.shortKey.replace(/\+/g, "-")] = (_a = toolbarItem.handler) == null ? void 0 : _a.bind(null, editorIns, toolbarItem.params);
36078
+ if (toolbarItem.shortKeyWithCode && flatToolbarConfig.includes(toolbarItem.id)) {
36079
+ shortKeys[toolbarItem.shortKeyWithCode.replace(/\+/g, "-")] = (_a = toolbarItem.handler) == null ? void 0 : _a.bind(null, editorIns, toolbarItem.params);
35967
36080
  }
35968
36081
  }
35969
36082
  editorIns.setOption(
@@ -35985,6 +36098,26 @@ function useEditorMd(props, ctx2) {
35985
36098
  setTimeout(() => {
35986
36099
  ctx2.emit("contentChange", editorIns.getValue());
35987
36100
  }, 100);
36101
+ containerRef.value.addEventListener("keydown", (e) => {
36102
+ let keyCombination = "";
36103
+ if (e.ctrlKey) {
36104
+ keyCombination += "Ctrl-";
36105
+ }
36106
+ if (e.metaKey) {
36107
+ keyCombination += "\u2318-";
36108
+ }
36109
+ if (e.altKey) {
36110
+ keyCombination += `${GET_ALT_KEY()}-`;
36111
+ }
36112
+ if (e.shiftKey) {
36113
+ keyCombination += "Shift-";
36114
+ }
36115
+ keyCombination += e.keyCode;
36116
+ if (shortKeys[keyCombination] && typeof shortKeys[keyCombination] === "function") {
36117
+ e.preventDefault();
36118
+ shortKeys[keyCombination]();
36119
+ }
36120
+ });
35988
36121
  };
35989
36122
  const onPaste = (e) => {
35990
36123
  const clipboardData = e.clipboardData;
@@ -37821,10 +37954,10 @@ class GitGraph$1 {
37821
37954
  this.graphHeight = this.element.getBoundingClientRect().height;
37822
37955
  this.graphWidth = this.element.getBoundingClientRect().width;
37823
37956
  const ch = Math.max(this.graphHeight, this.offsetY + this.unitTime * this.mtime + 150);
37824
- Math.max(this.graphWidth, this.offsetX + this.unitSpace * this.mspace + 300);
37957
+ const cw = Math.max(this.graphWidth, this.offsetX + this.unitSpace * this.mspace + 500);
37825
37958
  this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
37826
37959
  this.svg.setAttribute("height", ch + "");
37827
- this.svg.setAttribute("width", "100%");
37960
+ this.svg.setAttribute("width", cw + "");
37828
37961
  (_a = this.element) == null ? void 0 : _a.appendChild(this.svg);
37829
37962
  this.barHeight = Math.max(this.graphHeight, this.unitTime * this.commits.length + 320);
37830
37963
  const _ref = this.commits;
@@ -37960,7 +38093,7 @@ class GitGraph$1 {
37960
38093
  }
37961
38094
  drawDot(x, y, commit) {
37962
38095
  const options = this.options;
37963
- const isdark = this.isDark;
38096
+ this.isDark;
37964
38097
  const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
37965
38098
  const attrs = {
37966
38099
  cx: x,
@@ -37968,7 +38101,7 @@ class GitGraph$1 {
37968
38101
  r: 4,
37969
38102
  fill: "#fff",
37970
38103
  strokeWidth: 1,
37971
- stroke: this.colors[commit.space],
38104
+ stroke: this.colors[commit.space % 20],
37972
38105
  style: "cursor: pointer;"
37973
38106
  };
37974
38107
  this.setNodeAttr(circle, attrs);
@@ -37991,7 +38124,7 @@ class GitGraph$1 {
37991
38124
  img.appendChild(authorText);
37992
38125
  this.svg.appendChild(img);
37993
38126
  if (!this.messageBoxWidth) {
37994
- this.messageBoxWidth = this.svg.getBoundingClientRect.width - (avatar_box_x + 40);
38127
+ this.messageBoxWidth = this.svg.getBoundingClientRect().width - (avatar_box_x + 40);
37995
38128
  }
37996
38129
  let route = ["M", avatar_box_x + 15, avatar_box_y - 20, "L", avatar_box_x + 15, avatar_box_y];
37997
38130
  const line1 = document.createElementNS("http://www.w3.org/2000/svg", "path");
@@ -38015,16 +38148,25 @@ class GitGraph$1 {
38015
38148
  if (commit.author.name.length > this.maxNameLength) {
38016
38149
  commit.author.name = commit.author.name.substr(0, this.maxNameLength) + "...";
38017
38150
  }
38018
- const commitText = document.createElementNS("http://www.w3.org/2000/svg", "text");
38151
+ const commitText = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
38019
38152
  const commitAttrs = {
38020
38153
  x: avatar_box_x + 40,
38021
- y: y + 4,
38154
+ y: y - 8,
38022
38155
  "text-anchor": "start",
38023
38156
  style: "cursor: pointer;text-anchor: start;",
38024
- fill: isdark ? "#e8e8e8" : "#2e2e2e",
38025
- "font-size": 14
38157
+ width: this.messageBoxWidth,
38158
+ height: 20
38026
38159
  };
38027
38160
  this.setNodeAttr(commitText, commitAttrs);
38161
+ const textArr = {
38162
+ style: "width: 100%; height: 20px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;",
38163
+ title: commit.message
38164
+ };
38165
+ const text = document.createElement("div");
38166
+ this.setNodeAttr(text, textArr);
38167
+ text.innerText = commit.message.replace(/\n/g, " ");
38168
+ commitText.appendChild(text);
38169
+ this.svg.appendChild(commitText);
38028
38170
  const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
38029
38171
  tspan.appendChild(document.createTextNode(commit.message.replace(/\n/g, " ")));
38030
38172
  commitText.appendChild(tspan);
@@ -38058,9 +38200,9 @@ class GitGraph$1 {
38058
38200
  parentX1 = this.offsetX + this.unitSpace * (this.mspace - parentCommit.space);
38059
38201
  parentX2 = this.offsetX + this.unitSpace * (this.mspace - parent[1]);
38060
38202
  if (parentCommit.space <= commit.space) {
38061
- color2 = this.colors[commit.space];
38203
+ color2 = this.colors[commit.space % 20];
38062
38204
  } else {
38063
- color2 = this.colors[parentCommit.space];
38205
+ color2 = this.colors[parentCommit.space % 20];
38064
38206
  }
38065
38207
  if (parent[1] === commit.space) {
38066
38208
  offset2 = [0, 5];
@@ -38150,14 +38292,14 @@ class GitGraph$1 {
38150
38292
  ];
38151
38293
  const rectAttrs = {
38152
38294
  fill: this.isDark ? "#4C4C4C" : "#fff",
38153
- stroke: this.colors[commit.space],
38295
+ stroke: this.colors[commit.space % 20],
38154
38296
  "stroke-width": "1px",
38155
38297
  d: path.join(" "),
38156
38298
  transform: `matrix(1,0,0,1,-${textbox.width + 26},0)`
38157
38299
  };
38158
38300
  const newAttrs = {
38159
38301
  transform: `matrix(1,0,0,1,-${textbox.width + 26},0)`,
38160
- fill: this.colors[commit.space]
38302
+ fill: this.colors[commit.space % 20]
38161
38303
  };
38162
38304
  this.setNodeAttr(text, newAttrs);
38163
38305
  this.setNodeAttr(rect, rectAttrs);
@@ -38348,6 +38490,7 @@ function useGitGraph(props, ctx2, isDark) {
38348
38490
  initGraph
38349
38491
  };
38350
38492
  }
38493
+ var gitGraph = "";
38351
38494
  var GitGraph = defineComponent({
38352
38495
  name: "DGitGraph",
38353
38496
  props: gitGraphProps,
@@ -54305,7 +54448,7 @@ const installs = [
54305
54448
  VirtualListInstall
54306
54449
  ];
54307
54450
  var vueDevui = {
54308
- version: "1.6.27",
54451
+ version: "1.6.29",
54309
54452
  install(app) {
54310
54453
  installs.forEach((p) => app.use(p));
54311
54454
  }