@hmcts/media-viewer 4.1.1 → 4.1.3
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/esm2022/lib/annotations/annotation-set/annotation-create/box-highlight-create/box-highlight-create.component.mjs +5 -4
- package/esm2022/lib/annotations/annotation-set/annotation-create/highlight-create/highlight-create.directive.mjs +4 -2
- package/esm2022/lib/annotations/annotation-set/ctx-toolbar/ctx-toolbar.component.mjs +4 -3
- package/esm2022/lib/annotations/comment-set/comment/comment.component.mjs +3 -2
- package/esm2022/lib/annotations/comment-set/comment-set-render.service.mjs +3 -2
- package/esm2022/lib/media-viewer.component.mjs +3 -2
- package/esm2022/lib/shared/util/helpers/html-templates.helper.mjs +12 -1
- package/esm2022/lib/toolbar/main-toolbar/main-toolbar.component.mjs +4 -3
- package/esm2022/lib/toolbar/redaction-search-bar/redaction-search-bar.component.mjs +3 -2
- package/esm2022/lib/viewers/pdf-viewer/side-bar/side-bar.component.mjs +4 -2
- package/fesm2022/hmcts-media-viewer.mjs +46 -31
- package/fesm2022/hmcts-media-viewer.mjs.map +1 -1
- package/lib/annotations/annotation-set/annotation-create/box-highlight-create/box-highlight-create.component.d.ts.map +1 -1
- package/lib/annotations/annotation-set/annotation-create/highlight-create/highlight-create.directive.d.ts.map +1 -1
- package/lib/annotations/annotation-set/ctx-toolbar/ctx-toolbar.component.d.ts.map +1 -1
- package/lib/annotations/comment-set/comment/comment.component.d.ts.map +1 -1
- package/lib/annotations/comment-set/comment-set-render.service.d.ts.map +1 -1
- package/lib/media-viewer.component.d.ts.map +1 -1
- package/lib/shared/util/helpers/html-templates.helper.d.ts +1 -0
- package/lib/shared/util/helpers/html-templates.helper.d.ts.map +1 -1
- package/lib/toolbar/main-toolbar/main-toolbar.component.d.ts.map +1 -1
- package/lib/toolbar/redaction-search-bar/redaction-search-bar.component.d.ts.map +1 -1
- package/lib/viewers/pdf-viewer/side-bar/side-bar.component.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2511,6 +2511,35 @@ 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, log = true) {
|
|
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 (log && viewportX || viewportY || (viewportScale != 1) || viewportPageX || viewportPageY) {
|
|
2537
|
+
console.log(`Element: ${element.id} Viewport X: ${viewportX}, Y: ${viewportY}, Scale: ${viewportScale}, PageX: ${viewportPageX}, PageY: ${viewportPageY}`);
|
|
2538
|
+
}
|
|
2539
|
+
return element.getBoundingClientRect();
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2514
2543
|
const getTagsRootState = createSelector(getMVState, (state) => state.tags);
|
|
2515
2544
|
const getTagEntities = createSelector(getTagsRootState, getTagNameEnt);
|
|
2516
2545
|
const getTagFilters = createSelector(getTagsRootState, getFilters);
|
|
@@ -2872,7 +2901,7 @@ class RedactionSearchBarComponent {
|
|
|
2872
2901
|
const range = selection.getRangeAt(0).cloneRange();
|
|
2873
2902
|
const clientRects = range.getClientRects();
|
|
2874
2903
|
if (clientRects) {
|
|
2875
|
-
const parentRect = selectedHighLightedElements[0]
|
|
2904
|
+
const parentRect = HtmlTemplatesHelper.getAdjustedBoundingRect(selectedHighLightedElements[0]?.parentElement?.parentElement);
|
|
2876
2905
|
const selectionRectangles = [];
|
|
2877
2906
|
for (let i = 0; i < clientRects.length; i++) {
|
|
2878
2907
|
const selectionRectangle = this.createTextRectangle(clientRects[i], parentRect);
|
|
@@ -2998,7 +3027,7 @@ class CommentSetRenderService {
|
|
|
2998
3027
|
}
|
|
2999
3028
|
}
|
|
3000
3029
|
height(element) {
|
|
3001
|
-
return element.form.nativeElement
|
|
3030
|
+
return HtmlTemplatesHelper.getAdjustedBoundingRect(element.form.nativeElement)?.height | 0;
|
|
3002
3031
|
}
|
|
3003
3032
|
difference(a, b) { return Math.abs(a - b); }
|
|
3004
3033
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CommentSetRenderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
@@ -3314,7 +3343,7 @@ class CommentComponent {
|
|
|
3314
3343
|
return this.totalPrevPagesHeight + (this.rectTop * this.zoom);
|
|
3315
3344
|
}
|
|
3316
3345
|
get height() {
|
|
3317
|
-
return this.form.nativeElement
|
|
3346
|
+
return HtmlTemplatesHelper.getAdjustedBoundingRect(this.form.nativeElement).height / this.zoom;
|
|
3318
3347
|
}
|
|
3319
3348
|
/** @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 }); }
|
|
3320
3349
|
/** @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" }] }); }
|
|
@@ -3807,7 +3836,7 @@ class BoxHighlightCreateComponent {
|
|
|
3807
3836
|
this.highlightPage();
|
|
3808
3837
|
return;
|
|
3809
3838
|
}
|
|
3810
|
-
const rect = event.target
|
|
3839
|
+
const rect = HtmlTemplatesHelper.getAdjustedBoundingRect(event.target), offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
|
|
3811
3840
|
console.log(`initHighlight: rect=${JSON.stringify(rect)}, clientX=${event.clientX}, clientY=${event.clientY}, offsetX=${offsetX}, offsetY=${offsetY}`);
|
|
3812
3841
|
this.position = 'absolute';
|
|
3813
3842
|
this.backgroundColor = 'yellow';
|
|
@@ -3832,8 +3861,7 @@ class BoxHighlightCreateComponent {
|
|
|
3832
3861
|
}
|
|
3833
3862
|
}
|
|
3834
3863
|
updateHighlight(event) {
|
|
3835
|
-
const rect = event.target
|
|
3836
|
-
console.log(`updateHighlight: rect=${JSON.stringify(rect)}, clientX=${event.clientX}, clientY=${event.clientY}, offsetX=${offsetX}, offsetY=${offsetY}`);
|
|
3864
|
+
const rect = HtmlTemplatesHelper.getAdjustedBoundingRect(event.target, false), offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
|
|
3837
3865
|
if (this.drawStartX > 0 && this.drawStartY > 0) {
|
|
3838
3866
|
this.height = Math.abs(offsetY - this.drawStartY);
|
|
3839
3867
|
this.width = Math.abs(offsetX - this.drawStartX);
|
|
@@ -3846,6 +3874,7 @@ class BoxHighlightCreateComponent {
|
|
|
3846
3874
|
let rectangle = this.highlightService
|
|
3847
3875
|
.applyRotation(this.pageHeight, this.pageWidth, this.height, this.width, this.top, this.left, this.rotate, this.zoom);
|
|
3848
3876
|
rectangle = { id: v4(), ...rectangle };
|
|
3877
|
+
console.log(`createHighlight: rectangle=${JSON.stringify(rectangle)}`);
|
|
3849
3878
|
this.saveSelection.emit({ rectangles: [rectangle], page: this.page });
|
|
3850
3879
|
this.resetHighlight();
|
|
3851
3880
|
}
|
|
@@ -4035,10 +4064,11 @@ class CtxToolbarComponent {
|
|
|
4035
4064
|
addOrEditComment() {
|
|
4036
4065
|
this.addOrEditCommentEvent.emit();
|
|
4037
4066
|
setTimeout(() => {
|
|
4067
|
+
// This hack to wait until the element is rendered seems to be unreliable,
|
|
4038
4068
|
if (!location.hash) {
|
|
4039
|
-
document.getElementById('viewerContainer')
|
|
4069
|
+
document.getElementById('viewerContainer')?.scrollBy(0, 1);
|
|
4040
4070
|
}
|
|
4041
|
-
},
|
|
4071
|
+
}, 20);
|
|
4042
4072
|
}
|
|
4043
4073
|
createBookmark() {
|
|
4044
4074
|
this.createBookmarkEvent.emit(this.rectangle);
|
|
@@ -4740,7 +4770,9 @@ class SideBarComponent {
|
|
|
4740
4770
|
this.sidebarOpen = toggle;
|
|
4741
4771
|
}));
|
|
4742
4772
|
this.subscriptions.push(this.store.pipe(select(getScrollTop)).subscribe(scrollTopValue => {
|
|
4743
|
-
this.sidebarDiv
|
|
4773
|
+
if (this.sidebarDiv?.nativeElement) {
|
|
4774
|
+
this.sidebarDiv.nativeElement.scrollTop = scrollTopValue;
|
|
4775
|
+
}
|
|
4744
4776
|
}));
|
|
4745
4777
|
}
|
|
4746
4778
|
ngOnChanges(changes) {
|
|
@@ -4917,7 +4949,8 @@ class HighlightCreateDirective {
|
|
|
4917
4949
|
const range = selection.getRangeAt(0).cloneRange();
|
|
4918
4950
|
const clientRects = range.getClientRects();
|
|
4919
4951
|
if (clientRects) {
|
|
4920
|
-
const parentRect =
|
|
4952
|
+
const parentRect = HtmlTemplatesHelper
|
|
4953
|
+
.getAdjustedBoundingRect(localElement.closest(".textLayer"));
|
|
4921
4954
|
const selectionRectangles = [];
|
|
4922
4955
|
for (let i = 0; i < clientRects.length; i++) {
|
|
4923
4956
|
const selectionRectangle = this.createTextRectangle(clientRects[i], parentRect);
|
|
@@ -5756,8 +5789,8 @@ class MainToolbarComponent {
|
|
|
5756
5789
|
}
|
|
5757
5790
|
}
|
|
5758
5791
|
ngAfterViewInit() {
|
|
5759
|
-
Array.from(this.mvToolbarMain.nativeElement.children).forEach(button => {
|
|
5760
|
-
this.allButtonsWidth +=
|
|
5792
|
+
Array.from(this.mvToolbarMain.nativeElement.children).forEach((button) => {
|
|
5793
|
+
this.allButtonsWidth += HtmlTemplatesHelper.getAdjustedBoundingRect(button).width;
|
|
5761
5794
|
this.widthRequiredForBtn[button.id] = this.allButtonsWidth;
|
|
5762
5795
|
});
|
|
5763
5796
|
this.cdr.detectChanges();
|
|
@@ -6058,24 +6091,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
6058
6091
|
type: Input
|
|
6059
6092
|
}] } });
|
|
6060
6093
|
|
|
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
|
-
|
|
6079
6094
|
/*
|
|
6080
6095
|
* Gov Uk Fieldset Component
|
|
6081
6096
|
* Used to wrap group fieldset elements
|
|
@@ -6558,7 +6573,7 @@ class MediaViewerComponent {
|
|
|
6558
6573
|
return;
|
|
6559
6574
|
}
|
|
6560
6575
|
if (!this.height) {
|
|
6561
|
-
const compOffsetTop = this.elRef.nativeElement
|
|
6576
|
+
const compOffsetTop = HtmlTemplatesHelper.getAdjustedBoundingRect(this.elRef.nativeElement).top;
|
|
6562
6577
|
const viewerOffsetTop = this.viewerRef.nativeElement.offsetTop;
|
|
6563
6578
|
const offset = compOffsetTop + viewerOffsetTop;
|
|
6564
6579
|
if (this.prevOffset !== offset) {
|