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.
@@ -55,6 +55,10 @@ export declare const codeReviewProps: {
55
55
  expandLoader: {
56
56
  type: PropType<(interval: Array<number | undefined>, update: (code: string) => void) => void>;
57
57
  };
58
+ options: {
59
+ type: PropType<Record<string, any>>;
60
+ default: () => {};
61
+ };
58
62
  };
59
63
  export type CodeReviewProps = ExtractPropTypes<typeof codeReviewProps>;
60
64
  export interface CodeReviewContext {
@@ -3,18 +3,11 @@ import type { LineSide, CodeReviewProps } from '../code-review-types';
3
3
  export declare function useCodeReviewComment(reviewContentRef: Ref<HTMLElement>, props: CodeReviewProps, ctx: SetupContext): {
4
4
  commentLeft: Ref<number>;
5
5
  commentTop: Ref<number>;
6
- mouseEvent: {
7
- onMousemove: (e: MouseEvent) => void;
8
- onMouseleave: (e: MouseEvent) => void;
9
- } | {
10
- onMousemove?: undefined;
11
- onMouseleave?: undefined;
12
- };
6
+ mouseEvent: Record<string, (e: MouseEvent) => void>;
13
7
  updateCheckedLineClass: () => void;
8
+ clearCheckedLines: () => void;
14
9
  onCommentMouseLeave: (e: MouseEvent) => void;
15
10
  onCommentIconClick: (e: Event) => void;
16
- onCommentKeyDown: () => void;
17
- unCommentKeyDown: () => void;
18
11
  insertComment: (lineNumber: number, lineSide: LineSide, commentDom: HTMLElement) => void;
19
12
  removeComment: (lineNumber: number, lineSide: LineSide) => void;
20
13
  };
@@ -2,5 +2,5 @@ import type { Ref } from 'vue';
2
2
  import type { CodeReviewProps } from '../code-review-types';
3
3
  export declare function useCodeReviewExpand(reviewContentRef: Ref<HTMLElement>, props: CodeReviewProps): {
4
4
  insertExpandButton: () => void;
5
- onExpandButtonClick: (e: Event) => void;
5
+ onExpandButtonClick: (e: Event, options: Record<string, any>) => void;
6
6
  };
@@ -0,0 +1,5 @@
1
+ import type { Ref } from 'vue';
2
+ import type { CodeReviewProps } from '../code-review-types';
3
+ export declare function useCodeReviewLineSelection(reviewContentRef: Ref<HTMLElement>, props: CodeReviewProps, mouseMoveCb: () => void, mouseupCb: () => void): {
4
+ onMousedown: (e: MouseEvent) => void;
5
+ };
@@ -4,7 +4,7 @@ export declare function insertIncrementLineToPage(referenceDom: HTMLElement, trN
4
4
  export declare function ifRemoveExpandLineForDoubleColumn(expandDom: HTMLElement, newExpandDom: HTMLTableRowElement, direction: IncrementCodeInsertDirection): boolean;
5
5
  export declare function ifRemoveExpandLine(expandDom: HTMLElement, newExpandDom: HTMLTableRowElement, direction: IncrementCodeInsertDirection): boolean;
6
6
  export declare function updateExpandLineCount(expandDom: HTMLElement, newExpandDom: HTMLElement): void;
7
- export declare function parseDiffCode(container: HTMLElement, code: string, outputFormat: OutputFormat, isAddCode?: boolean): void;
7
+ export declare function parseDiffCode(container: HTMLElement, code: string, outputFormat: OutputFormat, options: Record<string, any>, isAddCode?: boolean): void;
8
8
  export declare function setLineNumberInDataset(trNode: HTMLElement, prevL: number, prevR: number, nextL: number, nextR: number): void;
9
9
  export declare function updateExpandUpDownButton(trNode: HTMLElement): void;
10
10
  export declare function updateLineNumberInDatasetForDoubleColumn(trNode: HTMLElement, expandThreshold: number, position: 'top' | 'bottom' | 'middle', updateExpandButton?: boolean): boolean;
@@ -18,3 +18,4 @@ export declare function addCommentToPageForSingleColumn(lineHost: HTMLElement, c
18
18
  export declare function addCommentToPageForDoubleColumn(lineHost: HTMLElement, commentDom: HTMLElement, lineSide: LineSide): void;
19
19
  export declare function findReferenceDomForSingleColumn(parentNode: HTMLElement, lineNumber: number, lineSide: LineSide): HTMLTableRowElement | undefined;
20
20
  export declare function findReferenceDomForDoubleColumn(parentNode: HTMLElement, lineNumber: number, lineSide: LineSide): HTMLTableRowElement | undefined;
21
+ export declare function findParentTrNode(node: HTMLElement | null): any;
package/vue-devui.es.js CHANGED
@@ -17014,6 +17014,10 @@ const codeReviewProps = {
17014
17014
  },
17015
17015
  expandLoader: {
17016
17016
  type: Function
17017
+ },
17018
+ options: {
17019
+ type: Object,
17020
+ default: () => ({})
17017
17021
  }
17018
17022
  };
17019
17023
  const CodeReviewInjectionKey = Symbol("d-code-review");
@@ -17238,15 +17242,15 @@ function addClassToDiffCode(codeStrArr, theClassName) {
17238
17242
  });
17239
17243
  return newArray;
17240
17244
  }
17241
- function parseDiffCode(container, code, outputFormat, isAddCode = false) {
17245
+ function parseDiffCode(container, code, outputFormat, options, isAddCode = false) {
17242
17246
  var _a;
17243
17247
  const diff2HtmlUi = new Diff2HtmlUI(container, code, {
17244
17248
  drawFileList: false,
17245
17249
  matching: "lines",
17246
17250
  outputFormat,
17247
17251
  highlight: true,
17248
- diffStyle: "char",
17249
- rawTemplates: TemplateMap[outputFormat]
17252
+ rawTemplates: TemplateMap[outputFormat],
17253
+ ...options
17250
17254
  });
17251
17255
  if (outputFormat === "side-by-side") {
17252
17256
  let diffHtmlStr = diff2HtmlUi.diffHtml;
@@ -17510,6 +17514,15 @@ function findReferenceDomForDoubleColumn(parentNode, lineNumber, lineSide) {
17510
17514
  }
17511
17515
  }
17512
17516
  }
17517
+ function findParentTrNode(node) {
17518
+ if (!node) {
17519
+ return null;
17520
+ }
17521
+ if (node.tagName === "TR") {
17522
+ return node;
17523
+ }
17524
+ return findParentTrNode(node.parentElement);
17525
+ }
17513
17526
  function useCodeReviewExpand(reviewContentRef, props) {
17514
17527
  const { outputFormat, expandThreshold, expandLoader } = toRefs(props);
17515
17528
  const processSideBySide = () => {
@@ -17551,7 +17564,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17551
17564
  }
17552
17565
  attachExpandUpDownButton(loadMoreLine.children[0], "down");
17553
17566
  };
17554
- const insertIncrementCodeForDoubleColumn = (code, direction, referenceDom) => {
17567
+ const insertIncrementCodeForDoubleColumn = (code, direction, referenceDom, options) => {
17555
17568
  if (!referenceDom) {
17556
17569
  return;
17557
17570
  }
@@ -17560,7 +17573,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17560
17573
  }
17561
17574
  const prefix = "--- updated_at Jan 1, 2019, 0:0:0 AM\n+++ updated_at Jan 1, 2019, 0:0:0 AM\n";
17562
17575
  const container = document.createElement("div");
17563
- parseDiffCode(container, prefix + code, outputFormat.value, true);
17576
+ parseDiffCode(container, prefix + code, outputFormat.value, options, true);
17564
17577
  const trNodes = Array.from(container.querySelectorAll("tr"));
17565
17578
  const expandLine = trNodes.find((element) => {
17566
17579
  var _a;
@@ -17634,7 +17647,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17634
17647
  }
17635
17648
  attachExpandUpDownButton(loadMoreLine.children[0], "down");
17636
17649
  };
17637
- const insertIncrementCode = (code, direction, referenceDom) => {
17650
+ const insertIncrementCode = (code, direction, referenceDom, options) => {
17638
17651
  if (!referenceDom) {
17639
17652
  return;
17640
17653
  }
@@ -17643,7 +17656,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17643
17656
  }
17644
17657
  const prefix = "--- updated_at Jan 1, 2019, 0:0:0 AM\n+++ updated_at Jan 1, 2019, 0:0:0 AM\n";
17645
17658
  const container = document.createElement("div");
17646
- parseDiffCode(container, prefix + code, outputFormat.value, true);
17659
+ parseDiffCode(container, prefix + code, outputFormat.value, options, true);
17647
17660
  const trNodes = Array.from(container.querySelectorAll("tr"));
17648
17661
  const expandLine = trNodes.find((element) => {
17649
17662
  var _a;
@@ -17673,7 +17686,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17673
17686
  }
17674
17687
  }
17675
17688
  };
17676
- const onExpandButtonClick = (e) => {
17689
+ const onExpandButtonClick = (e, options) => {
17677
17690
  var _a, _b;
17678
17691
  const composedPath = e.composedPath();
17679
17692
  const expandIconDom = composedPath.find((element) => {
@@ -17686,7 +17699,7 @@ function useCodeReviewExpand(reviewContentRef, props) {
17686
17699
  const [leftLineStart, leftLineEnd, rightLineStart, rightLineEnd] = getLineNumberFromDataset(expandIconDom, expandThreshold.value);
17687
17700
  (_b = expandLoader == null ? void 0 : expandLoader.value) == null ? void 0 : _b.call(expandLoader, [leftLineStart, leftLineEnd, rightLineStart, rightLineEnd], (code) => {
17688
17701
  var _a2, _b2;
17689
- 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);
17702
+ 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);
17690
17703
  });
17691
17704
  }
17692
17705
  };
@@ -17705,14 +17718,14 @@ function useCodeReview(props, ctx2) {
17705
17718
  diffFile.value = Diff2Html.parse(diff.value);
17706
17719
  nextTick(() => {
17707
17720
  if (inBrowser && !showBlob.value) {
17708
- parseDiffCode(reviewContentRef.value, diff.value, outputFormat.value);
17721
+ parseDiffCode(reviewContentRef.value, diff.value, outputFormat.value, props.options);
17709
17722
  allowExpand.value && insertExpandButton();
17710
17723
  ctx2.emit("contentRefresh", JSON.parse(JSON.stringify(diffFile.value)));
17711
17724
  }
17712
17725
  });
17713
17726
  };
17714
17727
  const onContentClick = (e) => {
17715
- onExpandButtonClick(e);
17728
+ onExpandButtonClick(e, props.options);
17716
17729
  };
17717
17730
  watch(showBlob, initDiffContent);
17718
17731
  watch(outputFormat, initDiffContent);
@@ -17737,25 +17750,161 @@ function useCodeReviewFold(props, ctx2) {
17737
17750
  });
17738
17751
  return { isFold, toggleFold };
17739
17752
  }
17753
+ function useCodeReviewLineSelection(reviewContentRef, props, mouseMoveCb, mouseupCb) {
17754
+ const ns2 = useNamespace$1("code-review");
17755
+ let dragging = false;
17756
+ let startTrNode;
17757
+ let trNodes;
17758
+ let isClickedLeft;
17759
+ let shouldClear;
17760
+ let isMouseMoved;
17761
+ const onMousedown2 = (e) => {
17762
+ if (e.button === 0) {
17763
+ const composedPath = e.composedPath();
17764
+ const lineNumberBox = composedPath.find(
17765
+ (item) => {
17766
+ var _a, _b;
17767
+ return ((_a = item.classList) == null ? void 0 : _a.contains("comment-icon-hover")) || ((_b = item.classList) == null ? void 0 : _b.contains("comment-icon"));
17768
+ }
17769
+ );
17770
+ trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr")).filter((item) => {
17771
+ var _a;
17772
+ return !((_a = item.classList) == null ? void 0 : _a.contains("expand-line"));
17773
+ });
17774
+ if (!lineNumberBox) {
17775
+ return;
17776
+ }
17777
+ const parentTrNode = findParentTrNode(e.target);
17778
+ if (parentTrNode && (parentTrNode == null ? void 0 : parentTrNode.classList.contains("expand-line"))) {
17779
+ return;
17780
+ }
17781
+ startTrNode = parentTrNode;
17782
+ if (props.outputFormat === "side-by-side") {
17783
+ isClickedLeft = composedPath.some((item) => {
17784
+ var _a;
17785
+ return (_a = item.classList) == null ? void 0 : _a.contains("d-code-left");
17786
+ });
17787
+ } else {
17788
+ isClickedLeft = void 0;
17789
+ }
17790
+ dragging = true;
17791
+ shouldClear = true;
17792
+ isMouseMoved = false;
17793
+ e.preventDefault();
17794
+ e.stopPropagation();
17795
+ document.addEventListener("mousemove", onMousemove);
17796
+ document.addEventListener("mouseup", onMouseup);
17797
+ }
17798
+ };
17799
+ function onMousemove(e) {
17800
+ if (!dragging) {
17801
+ return;
17802
+ }
17803
+ isMouseMoved = true;
17804
+ if (shouldClear) {
17805
+ clearCommentChecked();
17806
+ shouldClear = false;
17807
+ }
17808
+ const composedPath = e.composedPath();
17809
+ const inReviewContent = composedPath.some((item) => {
17810
+ var _a;
17811
+ return (_a = item.classList) == null ? void 0 : _a.contains(ns2.e("content"));
17812
+ });
17813
+ if (!inReviewContent) {
17814
+ return;
17815
+ }
17816
+ const endTrNode = findParentTrNode(e.target);
17817
+ if (!endTrNode) {
17818
+ return;
17819
+ }
17820
+ let startIndex = trNodes.indexOf(startTrNode);
17821
+ let endIndex = trNodes.indexOf(endTrNode);
17822
+ if (endIndex === -1) {
17823
+ return;
17824
+ }
17825
+ mouseMoveCb();
17826
+ if (startIndex > endIndex) {
17827
+ [startIndex, endIndex] = [endIndex, startIndex];
17828
+ }
17829
+ let position;
17830
+ if (isClickedLeft === void 0) {
17831
+ position = "all";
17832
+ } else if (isClickedLeft) {
17833
+ position = "left";
17834
+ } else {
17835
+ position = "right";
17836
+ }
17837
+ for (let i = 0; i < trNodes.length; i++) {
17838
+ if (i >= startIndex && i <= endIndex) {
17839
+ toggleCommentCheckedClass(trNodes[i], true, position);
17840
+ } else {
17841
+ toggleCommentCheckedClass(trNodes[i], false, position);
17842
+ }
17843
+ }
17844
+ }
17845
+ function onMouseup() {
17846
+ dragging = false;
17847
+ if (isMouseMoved) {
17848
+ mouseupCb();
17849
+ }
17850
+ document.removeEventListener("mouseup", onMouseup);
17851
+ document.removeEventListener("mousemove", onMousemove);
17852
+ }
17853
+ function clearCommentChecked() {
17854
+ for (let i = 0; i < trNodes.length; i++) {
17855
+ toggleCommentCheckedClass(trNodes[i], false, "all");
17856
+ }
17857
+ }
17858
+ function toggleCommentCheckedClass(trNode, isAddClass, position) {
17859
+ var _a;
17860
+ const tdNodes = Array.from(trNode.children);
17861
+ let toDoNodes;
17862
+ if (position === "all") {
17863
+ toDoNodes = tdNodes;
17864
+ } else if (position === "left") {
17865
+ toDoNodes = tdNodes.slice(0, 2);
17866
+ } else {
17867
+ toDoNodes = tdNodes.slice(2);
17868
+ }
17869
+ if ((position === "left" || position === "right") && isNaN(parseInt((_a = toDoNodes[0]) == null ? void 0 : _a.innerHTML))) {
17870
+ return;
17871
+ }
17872
+ toDoNodes.forEach((item) => {
17873
+ if (item.tagName === "TD") {
17874
+ if (isAddClass) {
17875
+ item.classList.add("comment-checked");
17876
+ } else {
17877
+ item.classList.remove("comment-checked");
17878
+ }
17879
+ }
17880
+ });
17881
+ }
17882
+ return { onMousedown: onMousedown2 };
17883
+ }
17740
17884
  function useCodeReviewComment(reviewContentRef, props, ctx2) {
17741
17885
  const { outputFormat, allowComment, allowChecked } = toRefs(props);
17742
17886
  const ns2 = useNamespace$1("code-review");
17887
+ const { onMousedown: onMousedown2 } = useCodeReviewLineSelection(reviewContentRef, props, updateLineNumbers, afterCheckLines);
17743
17888
  const commentLeft = ref(-100);
17744
17889
  const commentTop = ref(-100);
17745
17890
  let currentLeftLineNumber = -1;
17746
17891
  let currentRightLineNumber = -1;
17747
17892
  let lastLineNumberContainer;
17748
17893
  let checkedLineNumberContainer = [];
17749
- let isShift = false;
17750
17894
  let currentLeftLineNumbers = [];
17751
17895
  let currentRightLineNumbers = [];
17752
17896
  let checkedLineCodeString = {};
17753
- watch(() => outputFormat.value, () => {
17754
- checkedLineNumberContainer = [];
17755
- currentLeftLineNumbers = [];
17756
- currentRightLineNumbers = [];
17757
- checkedLineCodeString = [];
17758
- });
17897
+ let allTrNodes = [];
17898
+ let afterCheckLinesEmitData;
17899
+ watch(
17900
+ () => outputFormat.value,
17901
+ () => {
17902
+ checkedLineNumberContainer = [];
17903
+ currentLeftLineNumbers = [];
17904
+ currentRightLineNumbers = [];
17905
+ checkedLineCodeString = [];
17906
+ }
17907
+ );
17759
17908
  const resetLeftTop = () => {
17760
17909
  commentLeft.value = -100;
17761
17910
  commentTop.value = -100;
@@ -17838,30 +17987,7 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17838
17987
  resetLeftTop();
17839
17988
  }
17840
17989
  };
17841
- function commentKeyDown(e) {
17842
- switch (e.key) {
17843
- case "Shift":
17844
- isShift = true;
17845
- break;
17846
- }
17847
- }
17848
- function commentKeyUp(e) {
17849
- e.preventDefault();
17850
- switch (e.key) {
17851
- case "Shift":
17852
- isShift = false;
17853
- break;
17854
- }
17855
- }
17856
- const unCommentKeyDown = () => {
17857
- document.removeEventListener("keydown", commentKeyDown);
17858
- document.removeEventListener("keyup", commentKeyUp);
17859
- };
17860
- const onCommentKeyDown = () => {
17861
- document.addEventListener("keydown", commentKeyDown);
17862
- document.addEventListener("keyup", commentKeyUp);
17863
- };
17864
- const getLineNumbers = (currentNumber, currentNumbers, e) => {
17990
+ const getLineNumbers = (currentNumber, currentNumbers) => {
17865
17991
  if (currentNumber === -1) {
17866
17992
  return currentNumbers;
17867
17993
  }
@@ -17870,26 +17996,27 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17870
17996
  }
17871
17997
  const numbers = [...currentNumbers];
17872
17998
  let max = Math.max(...numbers);
17873
- const min = Math.min(...numbers);
17999
+ let min = Math.min(...numbers);
18000
+ if (currentNumber < min) {
18001
+ min = currentNumber;
18002
+ }
17874
18003
  if (currentNumber > max) {
17875
18004
  max = currentNumber;
17876
18005
  }
17877
18006
  return Array.from({ length: max - min + 1 }, (_, i) => i + min);
17878
18007
  };
17879
- const getCommonClassAndJudge = (side) => {
17880
- const lineClassName = side === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
17881
- const linenumberDom = reviewContentRef.value.querySelectorAll(lineClassName);
18008
+ const getCommonClassAndJudge = () => {
17882
18009
  const checkedLine = [currentLeftLineNumbers, currentRightLineNumbers];
17883
18010
  return {
17884
- linenumberDom,
18011
+ linenumberDom: allTrNodes,
17885
18012
  checkedLine
17886
18013
  };
17887
18014
  };
17888
18015
  const addCommentCheckedClass = (Dom) => {
17889
18016
  !Dom.classList.contains("comment-checked") && Dom.classList.add("comment-checked");
17890
18017
  };
17891
- const addCommentClassSingle = (side) => {
17892
- const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
18018
+ function getSingleCheckedLineCode(shouldRenderClass) {
18019
+ const { linenumberDom, checkedLine } = getCommonClassAndJudge();
17893
18020
  const checkedCodeContent = [];
17894
18021
  for (let i = 0; i < linenumberDom.length; i++) {
17895
18022
  const lineNumberDomLeft = linenumberDom[i].children[0];
@@ -17899,25 +18026,29 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17899
18026
  const codeLineNumberRight = parseInt(lineNumberDomRight == null ? void 0 : lineNumberDomRight.innerText);
17900
18027
  if (checkedLine[0].includes(codeLineNumberLeft) || checkedLine[1].includes(codeLineNumberRight)) {
17901
18028
  checkedLineNumberContainer.push(linenumberDom[i]);
17902
- const codeNode = linenumberDom[i].nextSibling.nodeName === "#text" ? linenumberDom[i].nextSibling.nextSibling : linenumberDom[i].nextSibling;
18029
+ const codeNode = linenumberDom[i].nextElementSibling;
17903
18030
  checkedCodeContent.push(codeNode == null ? void 0 : codeNode.innerText);
17904
- addCommentCheckedClass(linenumberDom[i]);
17905
- addCommentCheckedClass(codeNode);
18031
+ if (shouldRenderClass) {
18032
+ addCommentCheckedClass(linenumberDom[i]);
18033
+ addCommentCheckedClass(codeNode);
18034
+ }
17906
18035
  }
17907
18036
  }
17908
18037
  }
17909
18038
  checkedLineCodeString = checkedCodeContent;
17910
- };
17911
- const addCommentClassDouble = (side) => {
18039
+ }
18040
+ function getDoubleCheckedLineCode(shouldRenderClass) {
17912
18041
  var _a;
17913
- const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
18042
+ const { linenumberDom, checkedLine } = getCommonClassAndJudge();
17914
18043
  const checkedCodeContentLeft = [];
17915
18044
  const checkedCodeContentRight = [];
17916
18045
  function checkedFunc(Dom) {
17917
18046
  checkedLineNumberContainer.push(Dom);
17918
- const codeNode = Dom.nextSibling.nodeName === "#text" ? Dom.nextSibling.nextSibling : Dom.nextSibling;
17919
- addCommentCheckedClass(Dom);
17920
- addCommentCheckedClass(codeNode);
18047
+ const codeNode = Dom.nextElementSibling;
18048
+ if (shouldRenderClass) {
18049
+ addCommentCheckedClass(Dom);
18050
+ addCommentCheckedClass(codeNode);
18051
+ }
17921
18052
  return codeNode == null ? void 0 : codeNode.innerText;
17922
18053
  }
17923
18054
  for (let i = 0; i < linenumberDom.length; i++) {
@@ -17933,38 +18064,53 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17933
18064
  }
17934
18065
  }
17935
18066
  checkedLineCodeString = { leftCode: checkedCodeContentLeft, rightCode: checkedCodeContentRight };
17936
- };
17937
- const updateCheckedLineClass = () => {
17938
- if (outputFormat.value === "line-by-line") {
17939
- addCommentClassSingle(outputFormat.value);
17940
- return;
18067
+ }
18068
+ function getCheckedLineCode(shouldRenderClass) {
18069
+ if (props.outputFormat === "line-by-line") {
18070
+ return getSingleCheckedLineCode(shouldRenderClass);
17941
18071
  }
17942
- addCommentClassDouble(outputFormat.value);
18072
+ getDoubleCheckedLineCode(shouldRenderClass);
18073
+ }
18074
+ function updateLineNumbers() {
18075
+ currentLeftLineNumbers = currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers);
18076
+ currentRightLineNumbers = currentRightLineNumber === -1 ? currentRightLineNumbers : getLineNumbers(currentRightLineNumber, currentRightLineNumbers);
18077
+ getCheckedLineCode(false);
18078
+ afterCheckLinesEmitData = {
18079
+ left: currentLeftLineNumber,
18080
+ right: currentRightLineNumber,
18081
+ details: {
18082
+ lefts: currentLeftLineNumbers,
18083
+ rights: currentRightLineNumbers,
18084
+ codes: checkedLineCodeString
18085
+ }
18086
+ };
18087
+ }
18088
+ const updateCheckedLineClass = () => {
18089
+ getCheckedLineCode(true);
17943
18090
  };
17944
18091
  const resetCommentClass = () => {
17945
18092
  for (let i = 0; i < checkedLineNumberContainer.length; i++) {
17946
18093
  checkedLineNumberContainer[i].classList.remove("comment-checked");
17947
- const codeNode = checkedLineNumberContainer[i].nextSibling.nodeName === "#text" ? checkedLineNumberContainer[i].nextSibling.nextSibling : checkedLineNumberContainer[i].nextSibling;
18094
+ const codeNode = checkedLineNumberContainer[i].nextElementSibling;
17948
18095
  codeNode == null ? void 0 : codeNode.classList.remove("comment-checked");
17949
18096
  }
17950
18097
  checkedLineNumberContainer = [];
17951
18098
  };
17952
- const commentShiftClick = (e) => {
17953
- currentLeftLineNumbers = currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers);
17954
- currentRightLineNumbers = currentRightLineNumber === -1 ? currentRightLineNumbers : getLineNumbers(currentRightLineNumber, currentRightLineNumbers);
17955
- updateCheckedLineClass();
17956
- };
17957
- const commentClick = (e) => {
18099
+ const commentClick = () => {
17958
18100
  let obj = { left: currentLeftLineNumber, right: currentRightLineNumber };
17959
- if (currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1 && allowChecked.value) {
18101
+ if ((currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1) && allowChecked.value) {
17960
18102
  const maxCurrentLeftLineNumber = currentLeftLineNumbers[currentLeftLineNumbers.length - 1];
17961
18103
  const maxCurrentRightLineNumber = currentRightLineNumbers[currentRightLineNumbers.length - 1];
17962
18104
  if (maxCurrentLeftLineNumber === currentLeftLineNumber || maxCurrentRightLineNumber === currentRightLineNumber) {
17963
- obj = { left: currentLeftLineNumber, right: currentRightLineNumber, details: {
17964
- lefts: currentLeftLineNumbers,
17965
- rights: currentRightLineNumbers,
17966
- codes: checkedLineCodeString
17967
- } };
18105
+ obj = {
18106
+ left: currentLeftLineNumber,
18107
+ right: currentRightLineNumber,
18108
+ details: {
18109
+ lefts: currentLeftLineNumbers,
18110
+ rights: currentRightLineNumbers,
18111
+ codes: checkedLineCodeString
18112
+ }
18113
+ };
17968
18114
  } else {
17969
18115
  currentLeftLineNumbers = [];
17970
18116
  currentRightLineNumbers = [];
@@ -17973,6 +18119,9 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17973
18119
  }
17974
18120
  ctx2.emit("addComment", obj);
17975
18121
  };
18122
+ function afterCheckLines() {
18123
+ ctx2.emit("afterCheckLines", afterCheckLinesEmitData);
18124
+ }
17976
18125
  const onCommentIconClick = (e) => {
17977
18126
  if (e) {
17978
18127
  const composedPath = e.composedPath();
@@ -17986,10 +18135,6 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
17986
18135
  return;
17987
18136
  }
17988
18137
  }
17989
- if (isShift && allowChecked.value) {
17990
- commentShiftClick();
17991
- return;
17992
- }
17993
18138
  commentClick();
17994
18139
  };
17995
18140
  const insertComment = (lineNumber, lineSide, commentDom) => {
@@ -18030,7 +18175,25 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18030
18175
  }
18031
18176
  }
18032
18177
  };
18033
- const mouseEvent = allowComment.value ? { onMousemove: onMouseMove, onMouseleave } : {};
18178
+ const clearCheckedLines = () => {
18179
+ currentLeftLineNumbers = [];
18180
+ currentRightLineNumbers = [];
18181
+ checkedLineCodeString = [];
18182
+ resetCommentClass();
18183
+ };
18184
+ const handleMouseDown = (e) => {
18185
+ const lineClassName = props.outputFormat === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
18186
+ allTrNodes = reviewContentRef.value.querySelectorAll(lineClassName);
18187
+ onMousedown2(e);
18188
+ };
18189
+ const mouseEvent = {};
18190
+ if (allowComment.value) {
18191
+ mouseEvent.onMousemove = onMouseMove;
18192
+ mouseEvent.onMouseleave = onMouseleave;
18193
+ }
18194
+ if (props.allowChecked) {
18195
+ mouseEvent.onMousedown = handleMouseDown;
18196
+ }
18034
18197
  window.addEventListener("scroll", resetLeftTop);
18035
18198
  onUnmounted(() => {
18036
18199
  window.removeEventListener("scroll", resetLeftTop);
@@ -18040,10 +18203,9 @@ function useCodeReviewComment(reviewContentRef, props, ctx2) {
18040
18203
  commentTop,
18041
18204
  mouseEvent,
18042
18205
  updateCheckedLineClass,
18206
+ clearCheckedLines,
18043
18207
  onCommentMouseLeave,
18044
18208
  onCommentIconClick,
18045
- onCommentKeyDown,
18046
- unCommentKeyDown,
18047
18209
  insertComment,
18048
18210
  removeComment
18049
18211
  };
@@ -18052,7 +18214,7 @@ var codeReview = "";
18052
18214
  var CodeReview = defineComponent({
18053
18215
  name: "DCodeReview",
18054
18216
  props: codeReviewProps,
18055
- emits: ["foldChange", "addComment", "afterViewInit", "contentRefresh"],
18217
+ emits: ["foldChange", "addComment", "afterViewInit", "contentRefresh", "afterCheckLines"],
18056
18218
  setup(props, ctx2) {
18057
18219
  const ns2 = useNamespace$1("code-review");
18058
18220
  const {
@@ -18074,23 +18236,19 @@ var CodeReview = defineComponent({
18074
18236
  mouseEvent,
18075
18237
  onCommentMouseLeave,
18076
18238
  onCommentIconClick,
18077
- onCommentKeyDown,
18078
- unCommentKeyDown,
18079
18239
  insertComment,
18080
18240
  removeComment,
18081
- updateCheckedLineClass
18241
+ updateCheckedLineClass,
18242
+ clearCheckedLines
18082
18243
  } = useCodeReviewComment(reviewContentRef, props, ctx2);
18083
18244
  onMounted(() => {
18084
18245
  ctx2.emit("afterViewInit", {
18085
18246
  toggleFold,
18086
18247
  insertComment,
18087
18248
  removeComment,
18088
- updateCheckedLineClass
18249
+ updateCheckedLineClass,
18250
+ clearCheckedLines
18089
18251
  });
18090
- onCommentKeyDown();
18091
- });
18092
- onBeforeUnmount(() => {
18093
- unCommentKeyDown();
18094
18252
  });
18095
18253
  provide(CodeReviewInjectionKey, {
18096
18254
  diffType,
@@ -54127,7 +54285,7 @@ const installs = [
54127
54285
  VirtualListInstall
54128
54286
  ];
54129
54287
  var vueDevui = {
54130
- version: "1.6.22",
54288
+ version: "1.6.24",
54131
54289
  install(app) {
54132
54290
  installs.forEach((p) => app.use(p));
54133
54291
  }