@hmcts/media-viewer 3.1.0 → 3.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.
- package/assets/sass/toolbar/side-bar.scss +2 -1
- package/esm2020/lib/viewers/pdf-viewer/side-bar/bookmarks/bookmarks.component.mjs +30 -8
- package/fesm2015/hmcts-media-viewer.mjs +29 -7
- package/fesm2015/hmcts-media-viewer.mjs.map +1 -1
- package/fesm2020/hmcts-media-viewer.mjs +29 -7
- package/fesm2020/hmcts-media-viewer.mjs.map +1 -1
- package/lib/viewers/pdf-viewer/side-bar/bookmarks/bookmarks.component.d.ts +1 -0
- package/lib/viewers/pdf-viewer/side-bar/bookmarks/bookmarks.component.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -4930,7 +4930,8 @@ class BookmarksComponent {
|
|
|
4930
4930
|
if (!event.isPointerOverContainer || (event.previousIndex === event.currentIndex))
|
|
4931
4931
|
return;
|
|
4932
4932
|
const hasMovedUpTheTree = event.previousIndex > event.currentIndex;
|
|
4933
|
-
const
|
|
4933
|
+
const bookmarkNodesString = JSON.stringify(this._bookmarkNodes);
|
|
4934
|
+
const changedData = JSON.parse(bookmarkNodesString);
|
|
4934
4935
|
const visibleNodes = this.visibleNodes(this._bookmarkNodes);
|
|
4935
4936
|
const toNode = visibleNodes[event.currentIndex];
|
|
4936
4937
|
const toNodeSiblings = this.findNodeSiblings(changedData, toNode.id);
|
|
@@ -4939,6 +4940,8 @@ class BookmarksComponent {
|
|
|
4939
4940
|
const fromNode = event.item.data;
|
|
4940
4941
|
const fromNodeSiblings = this.findNodeSiblings(changedData, fromNode.id);
|
|
4941
4942
|
const fromIndex = fromNodeSiblings.findIndex(n => n.id === fromNode.id);
|
|
4943
|
+
if (this.isToNodeChildOfFromNode(fromNode?.children, toNode))
|
|
4944
|
+
return;
|
|
4942
4945
|
if (this.dragNodeInsertToParent) {
|
|
4943
4946
|
const indexOfParent = toNodeSiblings.findIndex(element => element.id === toNode.id);
|
|
4944
4947
|
const parentNode = toNodeSiblings[indexOfParent];
|
|
@@ -4947,18 +4950,29 @@ class BookmarksComponent {
|
|
|
4947
4950
|
if (firstChild) {
|
|
4948
4951
|
movedBookmarksWithParent = [...movedBookmarksWithParent, { ...firstChild, previous: fromNode.id }];
|
|
4949
4952
|
}
|
|
4953
|
+
let fromNodeSibling = this.getSiblingFromAllSibliings(fromNodeSiblings, fromIndex + 1);
|
|
4954
|
+
const nextFromindexforParent = fromIndex + 1;
|
|
4955
|
+
fromNodeSibling = fromNodeSibling && fromNodeSibling.id === fromNode.previous ? this.getSiblingFromAllSibliings(fromNodeSiblings, nextFromindexforParent + 1) : fromNodeSibling;
|
|
4956
|
+
if (fromNodeSibling && fromNodeSibling.id !== parentNode.id) {
|
|
4957
|
+
movedBookmarksWithParent = [...movedBookmarksWithParent, { ...fromNodeSibling, previous: fromNode.previous }];
|
|
4958
|
+
}
|
|
4950
4959
|
let previousSiblingForParentIndex = toIndex - 1;
|
|
4951
|
-
let parentNodeSibling = this.getSiblingFromAllSibliings(
|
|
4952
|
-
if (parentNodeSibling.id == fromNode.id) {
|
|
4960
|
+
let parentNodeSibling = this.getSiblingFromAllSibliings(toNodeSiblings, previousSiblingForParentIndex);
|
|
4961
|
+
if (parentNodeSibling && parentNodeSibling.id == fromNode.id) {
|
|
4953
4962
|
previousSiblingForParentIndex = previousSiblingForParentIndex - 1;
|
|
4954
|
-
if (previousSiblingForParentIndex
|
|
4955
|
-
parentNodeSibling = this.getSiblingFromAllSibliings(
|
|
4963
|
+
if (previousSiblingForParentIndex >= 0) {
|
|
4964
|
+
parentNodeSibling = this.getSiblingFromAllSibliings(toNodeSiblings, previousSiblingForParentIndex);
|
|
4956
4965
|
}
|
|
4957
4966
|
else {
|
|
4958
4967
|
parentNodeSibling = null;
|
|
4959
4968
|
}
|
|
4960
4969
|
}
|
|
4961
4970
|
movedBookmarksWithParent = [...movedBookmarksWithParent, { ...parentNode, previous: parentNodeSibling?.id }];
|
|
4971
|
+
const hasParentDups = movedBookmarksWithParent.map(x => x.id).some(function (value, index, array) {
|
|
4972
|
+
return array.indexOf(value) !== array.lastIndexOf(value); // comparing first and last indexes of the same value
|
|
4973
|
+
});
|
|
4974
|
+
if (hasParentDups || movedBookmarksWithParent && movedBookmarksWithParent.length <= 1)
|
|
4975
|
+
return;
|
|
4962
4976
|
this.store.dispatch(new MoveBookmark(movedBookmarksWithParent));
|
|
4963
4977
|
return;
|
|
4964
4978
|
}
|
|
@@ -4971,7 +4985,8 @@ class BookmarksComponent {
|
|
|
4971
4985
|
parent: toNodeParent
|
|
4972
4986
|
}];
|
|
4973
4987
|
let fromNodeSibling = this.getSiblingFromAllSibliings(fromNodeSiblings, fromIndex + 1);
|
|
4974
|
-
|
|
4988
|
+
const nextFromindex = fromIndex + 1;
|
|
4989
|
+
fromNodeSibling = fromNodeSibling && fromNodeSibling.id === fromNode.previous ? this.getSiblingFromAllSibliings(fromNodeSiblings, nextFromindex + 1) : fromNodeSibling;
|
|
4975
4990
|
if (fromNodeSibling) {
|
|
4976
4991
|
movedBookmarks = [...movedBookmarks, { ...fromNodeSibling, previous: fromNode.previous }];
|
|
4977
4992
|
}
|
|
@@ -5048,7 +5063,7 @@ class BookmarksComponent {
|
|
|
5048
5063
|
if (item.id === id) {
|
|
5049
5064
|
result = arr;
|
|
5050
5065
|
}
|
|
5051
|
-
else if (item
|
|
5066
|
+
else if (item?.children) {
|
|
5052
5067
|
subResult = this.findNodeSiblings(item.children, id);
|
|
5053
5068
|
if (subResult)
|
|
5054
5069
|
result = subResult;
|
|
@@ -5066,6 +5081,13 @@ class BookmarksComponent {
|
|
|
5066
5081
|
this.treeControl.expand(node);
|
|
5067
5082
|
});
|
|
5068
5083
|
}
|
|
5084
|
+
isToNodeChildOfFromNode(fromNodeChildren, toNode) {
|
|
5085
|
+
if (!fromNodeChildren) {
|
|
5086
|
+
return false;
|
|
5087
|
+
}
|
|
5088
|
+
const result = this.getNode(fromNodeChildren, toNode.id);
|
|
5089
|
+
return result ? true : false;
|
|
5090
|
+
}
|
|
5069
5091
|
}
|
|
5070
5092
|
/** @nocollapse */ BookmarksComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BookmarksComponent, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Component });
|
|
5071
5093
|
/** @nocollapse */ BookmarksComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: BookmarksComponent, selector: "mv-bookmarks", inputs: { bookmarkNodes: "bookmarkNodes", zoom: "zoom", rotate: "rotate" }, outputs: { goToDestination: "goToDestination" }, ngImport: i0, template: "<a *ngIf=\"bookmarkNodes?.length === 0\" class=\"highlightedOutlineItem\"\n >No bookmarks created yet</a\n>\n<cdk-tree\n cdkDropList\n class=\"bookmarks-tree\"\n *ngIf=\"datasource\"\n [dataSource]=\"datasource\"\n [treeControl]=\"treeControl\"\n (cdkDropListDropped)=\"drop($event)\"\n>\n <!-- This is the tree node template for leaf nodes -->\n <cdk-nested-tree-node class=\"node-wrapper\" *cdkTreeNodeDef=\"let node\">\n <div *ngIf=\"node.id !== editableBookmark; else inputBookmark\">\n <div\n class=\"node-content-wrapper nested-tree-node\"\n cdkDrag\n [cdkDragData]=\"node\"\n (mouseenter)=\"dragHover($event, node)\"\n (mouseleave)=\"dragHoverEnd($event, node)\"\n (cdkDragStarted)=\"dragStart()\"\n (cdkDragReleased)=\"dragEnd()\"\n >\n <div class=\"outlineItem\">\n <a (click)=\"goToBookmark(node)\">\n {{ node.name }}\n </a>\n </div>\n <button\n class=\"bookmark__rename\"\n (click)=\"editBookmark(node.id)\"\n ></button>\n <button\n class=\"bookmark__delete\"\n (click)=\"deleteBookmark2(node)\"\n ></button>\n </div>\n <div class=\"node-drop-slot\"></div>\n </div>\n <ng-template #inputBookmark>\n <input\n #bookmarkName\n class=\"bookmark__input\"\n [value]=\"node.name\"\n [maxLength]=\"BOOKMARK_CHAR_LIMIT\"\n />\n <button\n class=\"bookmark__save\"\n (click)=\"updateBookmark(node, bookmarkName.value)\"\n ></button>\n </ng-template>\n </cdk-nested-tree-node>\n <!-- This is the tree node template for expandable nodes -->\n <cdk-nested-tree-node\n class=\"node-wrapper\"\n *cdkTreeNodeDef=\"let node; when: hasChild\"\n >\n <div *ngIf=\"node.id !== editableBookmark; else inputBookmark2\">\n <div\n class=\"node-content-wrapper nested-tree-node\"\n cdkDrag\n [cdkDragData]=\"node\"\n (mouseenter)=\"dragHover($event, node)\"\n (mouseleave)=\"dragHoverEnd($event, node)\"\n (cdkDragStarted)=\"dragStart()\"\n (cdkDragReleased)=\"dragEnd()\"\n >\n <div class=\"outlineItem\">\n <span\n cdkTreeNodeToggle\n class=\"toggle-children-wrapper\"\n [ngClass]=\"onNodeExpand(node)\"\n ><span class=\"toggle-children\"></span\n ></span>\n <a (click)=\"goToBookmark(node)\">\n {{ node.name }}\n </a>\n </div>\n <button\n class=\"bookmark__rename\"\n (click)=\"editBookmark(node.id)\"\n ></button>\n <button\n class=\"bookmark__delete\"\n (click)=\"deleteBookmark2(node)\"\n ></button>\n </div>\n <div class=\"node-drop-slot\"></div>\n </div>\n <ng-template #inputBookmark2>\n <input\n #bookmarkName\n class=\"bookmark__input\"\n [value]=\"node.name\"\n [maxLength]=\"BOOKMARK_CHAR_LIMIT\"\n />\n <button\n class=\"bookmark__save\"\n (click)=\"updateBookmark(node, bookmarkName.value)\"\n ></button>\n </ng-template>\n <div class=\"nested-tree-node-children\" *ngIf=\"treeControl.isExpanded(node)\">\n <ng-container cdkTreeNodeOutlet></ng-container>\n </div>\n </cdk-nested-tree-node>\n</cdk-tree>\n", dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.CdkNestedTreeNode, selector: "cdk-nested-tree-node", inputs: ["role", "disabled", "tabIndex"], exportAs: ["cdkNestedTreeNode"] }, { kind: "directive", type: i3.CdkTreeNodeDef, selector: "[cdkTreeNodeDef]", inputs: ["cdkTreeNodeDefWhen"] }, { kind: "directive", type: i3.CdkTreeNodeToggle, selector: "[cdkTreeNodeToggle]", inputs: ["cdkTreeNodeToggleRecursive"] }, { kind: "component", type: i3.CdkTree, selector: "cdk-tree", inputs: ["dataSource", "treeControl", "trackBy"], exportAs: ["cdkTree"] }, { kind: "directive", type: i3.CdkTreeNodeOutlet, selector: "[cdkTreeNodeOutlet]" }, { kind: "directive", type: i4$3.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i4$3.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }] });
|