@hmcts/media-viewer 4.1.0-viewport-debug → 4.1.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.
Files changed (28) hide show
  1. package/esm2022/lib/annotations/annotation-set/annotation-create/box-highlight-create/box-highlight-create.component.mjs +4 -5
  2. package/esm2022/lib/annotations/annotation-set/annotation-create/highlight-create/highlight-create.directive.mjs +2 -4
  3. package/esm2022/lib/annotations/annotation-set/ctx-toolbar/ctx-toolbar.component.mjs +3 -4
  4. package/esm2022/lib/annotations/comment-set/comment/comment.component.mjs +2 -3
  5. package/esm2022/lib/annotations/comment-set/comment-set-render.service.mjs +2 -3
  6. package/esm2022/lib/icp/icp-session-api.service.mjs +8 -2
  7. package/esm2022/lib/icp/icp-update.service.mjs +3 -3
  8. package/esm2022/lib/media-viewer.component.mjs +2 -3
  9. package/esm2022/lib/shared/util/helpers/html-templates.helper.mjs +1 -12
  10. package/esm2022/lib/store/effects/icp.effects.mjs +2 -2
  11. package/esm2022/lib/toolbar/main-toolbar/main-toolbar.component.mjs +3 -4
  12. package/esm2022/lib/toolbar/redaction-search-bar/redaction-search-bar.component.mjs +2 -3
  13. package/fesm2022/hmcts-media-viewer.mjs +40 -47
  14. package/fesm2022/hmcts-media-viewer.mjs.map +1 -1
  15. package/lib/annotations/annotation-set/annotation-create/box-highlight-create/box-highlight-create.component.d.ts.map +1 -1
  16. package/lib/annotations/annotation-set/annotation-create/highlight-create/highlight-create.directive.d.ts.map +1 -1
  17. package/lib/annotations/annotation-set/ctx-toolbar/ctx-toolbar.component.d.ts.map +1 -1
  18. package/lib/annotations/comment-set/comment/comment.component.d.ts.map +1 -1
  19. package/lib/annotations/comment-set/comment-set-render.service.d.ts.map +1 -1
  20. package/lib/icp/icp-session-api.service.d.ts.map +1 -1
  21. package/lib/icp/icp-update.service.d.ts +1 -1
  22. package/lib/icp/icp-update.service.d.ts.map +1 -1
  23. package/lib/media-viewer.component.d.ts.map +1 -1
  24. package/lib/shared/util/helpers/html-templates.helper.d.ts +0 -1
  25. package/lib/shared/util/helpers/html-templates.helper.d.ts.map +1 -1
  26. package/lib/toolbar/main-toolbar/main-toolbar.component.d.ts.map +1 -1
  27. package/lib/toolbar/redaction-search-bar/redaction-search-bar.component.d.ts.map +1 -1
  28. package/package.json +1 -1
@@ -2173,9 +2173,9 @@ class IcpUpdateService {
2173
2173
  constructor(socket) {
2174
2174
  this.socket = socket;
2175
2175
  }
2176
- joinSession(username, session) {
2176
+ joinSession(username, session, token) {
2177
2177
  this.session = session;
2178
- this.socket.connect(session.connectionUrl);
2178
+ this.socket.connect(`${session.connectionUrl}?access_token=${token}`);
2179
2179
  this.socket.connected().subscribe(isConnected => {
2180
2180
  if (isConnected) {
2181
2181
  this.socket.join({ ...this.session, username });
@@ -2511,35 +2511,6 @@ const defaultUnsupportedOptions = {
2511
2511
  showPrint: true
2512
2512
  };
2513
2513
 
2514
- /**
2515
- * Helper Class
2516
- * Used for dynamic templates manipulation
2517
- * */
2518
- class HtmlTemplatesHelper {
2519
- static setDescribedBy(errorMessage, config) {
2520
- if (!errorMessage) {
2521
- return config.hint ? `${config.id}-hint` : null;
2522
- }
2523
- else if (errorMessage && errorMessage.isInvalid) {
2524
- return config.hint ? `${config.id}-hint ${config.id}-error` : `${config.id}-error`;
2525
- }
2526
- else {
2527
- return config.hint ? `${config.id}-hint` : null;
2528
- }
2529
- }
2530
- static getAdjustedBoundingRect(element) {
2531
- const viewportX = window.visualViewport.offsetLeft;
2532
- const viewportY = window.visualViewport.offsetTop;
2533
- const viewportScale = window.visualViewport.scale;
2534
- const viewportPageX = window.visualViewport.pageLeft;
2535
- const viewportPageY = window.visualViewport.pageTop;
2536
- if (viewportX || viewportY || viewportScale || viewportPageX || viewportPageY) {
2537
- console.log(`Viewport X: ${viewportX}, Y: ${viewportY}, Scale: ${viewportScale}, PageX: ${viewportPageX}, PageY: ${viewportPageY}`);
2538
- }
2539
- return element.getBoundingClientRect();
2540
- }
2541
- }
2542
-
2543
2514
  const getTagsRootState = createSelector(getMVState, (state) => state.tags);
2544
2515
  const getTagEntities = createSelector(getTagsRootState, getTagNameEnt);
2545
2516
  const getTagFilters = createSelector(getTagsRootState, getFilters);
@@ -2901,7 +2872,7 @@ class RedactionSearchBarComponent {
2901
2872
  const range = selection.getRangeAt(0).cloneRange();
2902
2873
  const clientRects = range.getClientRects();
2903
2874
  if (clientRects) {
2904
- const parentRect = HtmlTemplatesHelper.getAdjustedBoundingRect(selectedHighLightedElements[0]?.parentElement?.parentElement);
2875
+ const parentRect = selectedHighLightedElements[0].parentElement.parentElement.getBoundingClientRect();
2905
2876
  const selectionRectangles = [];
2906
2877
  for (let i = 0; i < clientRects.length; i++) {
2907
2878
  const selectionRectangle = this.createTextRectangle(clientRects[i], parentRect);
@@ -3027,7 +2998,7 @@ class CommentSetRenderService {
3027
2998
  }
3028
2999
  }
3029
3000
  height(element) {
3030
- return HtmlTemplatesHelper.getAdjustedBoundingRect(element.form.nativeElement)?.height | 0;
3001
+ return element.form.nativeElement.getBoundingClientRect().height;
3031
3002
  }
3032
3003
  difference(a, b) { return Math.abs(a - b); }
3033
3004
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CommentSetRenderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -3343,7 +3314,7 @@ class CommentComponent {
3343
3314
  return this.totalPrevPagesHeight + (this.rectTop * this.zoom);
3344
3315
  }
3345
3316
  get height() {
3346
- return HtmlTemplatesHelper.getAdjustedBoundingRect(this.form.nativeElement).height / this.zoom;
3317
+ return this.form.nativeElement.getBoundingClientRect().height / this.zoom;
3347
3318
  }
3348
3319
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CommentComponent, deps: [{ token: i1.Store }, { token: CommentService }, { token: TagsServices }], target: i0.ɵɵFactoryTarget.Component }); }
3349
3320
  /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: CommentComponent, selector: "mv-anno-comment", inputs: { rotate: "rotate", zoom: "zoom", index: "index", page: "page", comment: "comment", annotation: "annotation" }, outputs: { commentClick: "commentClick", renderComments: "renderComments", delete: "delete", updated: "updated", changes: "changes" }, viewQueries: [{ propertyName: "form", first: true, predicate: ["form"], descendants: true }, { propertyName: "editableComment", first: true, predicate: ["editableComment"], descendants: true }], ngImport: i0, template: "<div\n #form\n (click)=\"onCommentClick()\"\n class=\"aui-comment\"\n [ngClass]=\"{ stylestoggle: (marginToComment$ | async) }\"\n [style.top.px]=\"commentTop\"\n [style.zIndex]=\"selected ? 100 : 0\"\n>\n <div id=\"detailsWrapper {{ index }}\" class=\"aui-comment__header\">\n <span *ngIf=\"author && !editor\" class=\"aui-comment__author\">\n {{ author.forename }} {{ author.surname }}\n </span>\n <span *ngIf=\"editor\" class=\"aui-comment__author\">\n {{ editor.forename }} {{ editor.surname }}\n </span>\n <time [hidden]=\"!selected && !this.editable\" class=\"aui-comment__meta\">\n {{ lastUpdate | momentDate : \"d MMMM y h:mm a\" }}\n </time>\n </div>\n <mv-tags\n [tagItems]=\"tagItems\"\n [userId]=\"createdBy\"\n [editable]=\"editable\"\n [annoId]=\"_comment.annotationId\"\n >\n </mv-tags>\n <textarea\n *ngIf=\"selected && editable\"\n #editableComment\n mvTextAreaAutoExpand\n type=\"text\"\n required\n name=\"content\"\n [maxlength]=\"CHAR_LIMIT\"\n class=\"aui-comment__content form-control mimic-focus edit-mode expanded\"\n [ngModel]=\"fullComment\"\n (ngModelChange)=\"fullComment = $event; reRenderComments(); onCommentChange($event)\"\n aria-label=\"comment\"\n >\n </textarea>\n <p\n *ngIf=\"!editable\"\n mvTextHighlight\n class=\"commentText\"\n [textToHighlight]=\"searchString\"\n >\n {{ fullComment }}\n </p>\n <div\n *ngIf=\"\n selected ||\n this.editable ||\n (!fullComment.length && tagItems && !tagItems.length)\n \"\n class=\"aui-comment__footer commentBtns\"\n >\n <button\n class=\"govuk-button\"\n type=\"button\"\n role=\"button\"\n (click)=\"editOrSave()\"\n >\n {{ !editable ? (\"Edit\" | rpxTranslate) : (\"Save\" | rpxTranslate) }}\n </button>\n <button\n type=\"button\"\n role=\"button\"\n class=\"govuk-button govuk-button--secondary\"\n (click)=\"deleteOrCancel()\"\n >\n {{ !editable ? (\"Delete\" | rpxTranslate) : (\"Cancel\" | rpxTranslate) }}\n </button>\n </div>\n <span class=\"aui-comment__private\">{{ \"private\" | rpxTranslate }}</span>\n</div>\n", dependencies: [{ kind: "directive", type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: TextHighlightDirective, selector: "[mvTextHighlight]", inputs: ["textToHighlight"] }, { kind: "directive", type: TextareaAutoExpandDirective, selector: "[mvTextAreaAutoExpand]" }, { kind: "component", type: TagsComponent, selector: "mv-tags", inputs: ["tagItems", "userId", "editable", "annoId"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i5$1.RpxTranslatePipe, name: "rpxTranslate" }, { kind: "pipe", type: MomentDatePipe, name: "momentDate" }] }); }
@@ -3836,7 +3807,7 @@ class BoxHighlightCreateComponent {
3836
3807
  this.highlightPage();
3837
3808
  return;
3838
3809
  }
3839
- const rect = HtmlTemplatesHelper.getAdjustedBoundingRect(event.target), offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
3810
+ const rect = event.target.getBoundingClientRect(), offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
3840
3811
  console.log(`initHighlight: rect=${JSON.stringify(rect)}, clientX=${event.clientX}, clientY=${event.clientY}, offsetX=${offsetX}, offsetY=${offsetY}`);
3841
3812
  this.position = 'absolute';
3842
3813
  this.backgroundColor = 'yellow';
@@ -3861,7 +3832,8 @@ class BoxHighlightCreateComponent {
3861
3832
  }
3862
3833
  }
3863
3834
  updateHighlight(event) {
3864
- const rect = HtmlTemplatesHelper.getAdjustedBoundingRect(event.target), offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
3835
+ const rect = event.target.getBoundingClientRect(), offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
3836
+ console.log(`updateHighlight: rect=${JSON.stringify(rect)}, clientX=${event.clientX}, clientY=${event.clientY}, offsetX=${offsetX}, offsetY=${offsetY}`);
3865
3837
  if (this.drawStartX > 0 && this.drawStartY > 0) {
3866
3838
  this.height = Math.abs(offsetY - this.drawStartY);
3867
3839
  this.width = Math.abs(offsetX - this.drawStartX);
@@ -3874,7 +3846,6 @@ class BoxHighlightCreateComponent {
3874
3846
  let rectangle = this.highlightService
3875
3847
  .applyRotation(this.pageHeight, this.pageWidth, this.height, this.width, this.top, this.left, this.rotate, this.zoom);
3876
3848
  rectangle = { id: v4(), ...rectangle };
3877
- console.log(`createHighlight: rectangle=${JSON.stringify(rectangle)}`);
3878
3849
  this.saveSelection.emit({ rectangles: [rectangle], page: this.page });
3879
3850
  this.resetHighlight();
3880
3851
  }
@@ -4064,11 +4035,10 @@ class CtxToolbarComponent {
4064
4035
  addOrEditComment() {
4065
4036
  this.addOrEditCommentEvent.emit();
4066
4037
  setTimeout(() => {
4067
- // This hack to wait until the element is rendered seems to be unreliable,
4068
4038
  if (!location.hash) {
4069
- document.getElementById('viewerContainer')?.scrollBy(0, 1);
4039
+ document.getElementById('viewerContainer').scrollBy(0, 1);
4070
4040
  }
4071
- }, 20);
4041
+ }, 10);
4072
4042
  }
4073
4043
  createBookmark() {
4074
4044
  this.createBookmarkEvent.emit(this.rectangle);
@@ -4947,8 +4917,7 @@ class HighlightCreateDirective {
4947
4917
  const range = selection.getRangeAt(0).cloneRange();
4948
4918
  const clientRects = range.getClientRects();
4949
4919
  if (clientRects) {
4950
- const parentRect = HtmlTemplatesHelper
4951
- .getAdjustedBoundingRect(localElement.closest(".textLayer"));
4920
+ const parentRect = localElement.closest(".textLayer").getBoundingClientRect();
4952
4921
  const selectionRectangles = [];
4953
4922
  for (let i = 0; i < clientRects.length; i++) {
4954
4923
  const selectionRectangle = this.createTextRectangle(clientRects[i], parentRect);
@@ -5787,8 +5756,8 @@ class MainToolbarComponent {
5787
5756
  }
5788
5757
  }
5789
5758
  ngAfterViewInit() {
5790
- Array.from(this.mvToolbarMain.nativeElement.children).forEach((button) => {
5791
- this.allButtonsWidth += HtmlTemplatesHelper.getAdjustedBoundingRect(button).width;
5759
+ Array.from(this.mvToolbarMain.nativeElement.children).forEach(button => {
5760
+ this.allButtonsWidth += button.getBoundingClientRect().width;
5792
5761
  this.widthRequiredForBtn[button.id] = this.allButtonsWidth;
5793
5762
  });
5794
5763
  this.cdr.detectChanges();
@@ -6089,6 +6058,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
6089
6058
  type: Input
6090
6059
  }] } });
6091
6060
 
6061
+ /**
6062
+ * Helper Class
6063
+ * Used for dynamic templates manipulation
6064
+ * */
6065
+ class HtmlTemplatesHelper {
6066
+ static setDescribedBy(errorMessage, config) {
6067
+ if (!errorMessage) {
6068
+ return config.hint ? `${config.id}-hint` : null;
6069
+ }
6070
+ else if (errorMessage && errorMessage.isInvalid) {
6071
+ return config.hint ? `${config.id}-hint ${config.id}-error` : `${config.id}-error`;
6072
+ }
6073
+ else {
6074
+ return config.hint ? `${config.id}-hint` : null;
6075
+ }
6076
+ }
6077
+ }
6078
+
6092
6079
  /*
6093
6080
  * Gov Uk Fieldset Component
6094
6081
  * Used to wrap group fieldset elements
@@ -6571,7 +6558,7 @@ class MediaViewerComponent {
6571
6558
  return;
6572
6559
  }
6573
6560
  if (!this.height) {
6574
- const compOffsetTop = HtmlTemplatesHelper.getAdjustedBoundingRect(this.elRef.nativeElement).top;
6561
+ const compOffsetTop = this.elRef.nativeElement.getBoundingClientRect().top;
6575
6562
  const viewerOffsetTop = this.viewerRef.nativeElement.offsetTop;
6576
6563
  const offset = compOffsetTop + viewerOffsetTop;
6577
6564
  if (this.prevOffset !== offset) {
@@ -7252,7 +7239,13 @@ class IcpSessionApiService {
7252
7239
  loadSession(payload) {
7253
7240
  return this.httpClient
7254
7241
  .get(`${this.ICP_SESSION_API}/${payload.caseId}/${payload.documentId}`, { observe: 'response', withCredentials: true })
7255
- .pipe(map(response => response.body));
7242
+ .pipe(map(response => {
7243
+ const token = response.headers.get('X-Access-Token');
7244
+ return {
7245
+ ...response.body,
7246
+ token
7247
+ };
7248
+ }));
7256
7249
  }
7257
7250
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IcpSessionApiService, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
7258
7251
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IcpSessionApiService, providedIn: 'root' }); }
@@ -7269,7 +7262,7 @@ class IcpEffects {
7269
7262
  this.icpUpdateService = icpUpdateService;
7270
7263
  this.loadIcpSession$ = createEffect(() => this.actions$.pipe(ofType(LOAD_ICP_SESSION), map((action) => action.payload), exhaustMap((payload) => this.icpApiService.loadSession(payload)
7271
7264
  .pipe(map(res => new JoinIcpSocketSession(res)), catchError(error => of(new LoadIcpSessionFailure(error)))))));
7272
- this.joinIcpSocketSession$ = createEffect(() => this.actions$.pipe(ofType(JOIN_ICP_SOCKET_SESSION), map((action) => action.payload), switchMap((res) => this.icpUpdateService.joinSession(res.username, res.session)
7265
+ this.joinIcpSocketSession$ = createEffect(() => this.actions$.pipe(ofType(JOIN_ICP_SOCKET_SESSION), map((action) => action.payload), switchMap((res) => this.icpUpdateService.joinSession(res.username, res.session, res.token)
7273
7266
  .pipe(map(participants => new IcpSocketSessionJoined({ session: res.session, participantInfo: participants }))))));
7274
7267
  }
7275
7268
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: IcpEffects, deps: [{ token: i1$2.Actions }, { token: IcpSessionApiService }, { token: IcpUpdateService }], target: i0.ɵɵFactoryTarget.Injectable }); }