@hmcts/media-viewer 4.2.38 → 4.2.39-redact-1

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.
Binary file
@@ -2065,8 +2065,8 @@ class HighlightCreateDirective {
2065
2065
  }
2066
2066
  this.setPageProperties(page);
2067
2067
  const range = selection.getRangeAt(0).cloneRange();
2068
- const clientRects = range.getClientRects();
2069
- if (!clientRects || clientRects.length === 0) {
2068
+ const selectionRects = this.getSelectionRectangles(range);
2069
+ if (!selectionRects || selectionRects.length === 0) {
2070
2070
  return [];
2071
2071
  }
2072
2072
  let textLayerElement = range.startContainer;
@@ -2078,7 +2078,7 @@ class HighlightCreateDirective {
2078
2078
  return [];
2079
2079
  }
2080
2080
  this.removeEnhancedTextModeStyling(textLayerElement);
2081
- return this.processClientRects(clientRects, textLayer);
2081
+ return this.processClientRects(selectionRects, textLayer);
2082
2082
  }
2083
2083
  onPdfViewerClick(event) {
2084
2084
  this.store.dispatch(new SelectedAnnotation({
@@ -2096,14 +2096,17 @@ class HighlightCreateDirective {
2096
2096
  this.removeEnhancedTextModeStyling(localElement);
2097
2097
  if (selection.rangeCount && !selection.isCollapsed) {
2098
2098
  const range = selection.getRangeAt(0).cloneRange();
2099
- const clientRects = range.getClientRects();
2100
- if (clientRects) {
2099
+ const selectionRects = this.getSelectionRectangles(range);
2100
+ if (selectionRects) {
2101
2101
  const textLayer = localElement.closest(".textLayer");
2102
- return this.processClientRects(clientRects, textLayer);
2102
+ return this.processClientRects(selectionRects, textLayer);
2103
2103
  }
2104
2104
  }
2105
2105
  }
2106
2106
  }
2107
+ getSelectionRectangles(range) {
2108
+ return range.getClientRects();
2109
+ }
2107
2110
  createTextRectangle(rect, parentRect) {
2108
2111
  const height = rect.bottom - rect.top;
2109
2112
  const width = rect.right - rect.left;
@@ -2136,7 +2139,10 @@ class HighlightCreateDirective {
2136
2139
  const selectionRectangles = [];
2137
2140
  for (let i = 0; i < clientRects.length; i++) {
2138
2141
  const selectionRectangle = this.createTextRectangle(clientRects[i], parentRect);
2139
- const findSelectionRectangle = selectionRectangles.find((rect) => rect.width === selectionRectangle.width && rect.x === selectionRectangle.x);
2142
+ const findSelectionRectangle = selectionRectangles.find((rect) => rect.width === selectionRectangle.width
2143
+ && rect.height === selectionRectangle.height
2144
+ && rect.x === selectionRectangle.x
2145
+ && rect.y === selectionRectangle.y);
2140
2146
  if (!findSelectionRectangle) {
2141
2147
  selectionRectangles.push(selectionRectangle);
2142
2148
  }