(options: HiNoteViewEventBindingOptions)
| 18 | } |
| 19 | |
| 20 | export function registerHiNoteViewEvents(options: HiNoteViewEventBindingOptions): void { |
| 21 | const { |
| 22 | component, |
| 23 | container, |
| 24 | state, |
| 25 | eventCoordinator, |
| 26 | highlightContainer, |
| 27 | selectionManager, |
| 28 | fileListManager, |
| 29 | highlightListController, |
| 30 | commentController, |
| 31 | checkViewPosition |
| 32 | } = options; |
| 33 | |
| 34 | const handleMultiSelect = () => { |
| 35 | selectionManager.updateSelectedHighlights(); |
| 36 | }; |
| 37 | container.addEventListener("highlight-multi-select", handleMultiSelect); |
| 38 | component.register(() => { |
| 39 | container.removeEventListener("highlight-multi-select", handleMultiSelect); |
| 40 | }); |
| 41 | |
| 42 | component.registerDomEvent(activeDocument, "click", (e: MouseEvent) => { |
| 43 | if (selectionManager.isInSelectionMode()) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | const selectedCount = selectionManager.getSelectedCount(); |
| 48 | if (selectedCount <= 1) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | const target = e.target as HTMLElement; |
| 53 | if (!target.closest(".multi-select-actions") && |
| 54 | !target.closest(".highlight-card.selected") && |
| 55 | !target.closest(".highlight-container")) { |
| 56 | selectionManager.clearSelection(); |
| 57 | } |
| 58 | }); |
| 59 | |
| 60 | eventCoordinator.setCallbacks({ |
| 61 | onFileOpen: (file, isInCanvas) => { |
| 62 | state.currentFile = file; |
| 63 | void highlightListController.updateHighlights(isInCanvas); |
| 64 | }, |
| 65 | onFileModify: (file, isInCanvas) => { |
| 66 | fileListManager.invalidateCache(); |
| 67 | void highlightListController.updateHighlights(isInCanvas); |
| 68 | }, |
| 69 | onFileCreate: () => { |
| 70 | fileListManager.invalidateCache(); |
| 71 | }, |
| 72 | onFileDelete: () => { |
| 73 | fileListManager.invalidateCache(); |
| 74 | }, |
| 75 | onLayoutChange: () => { |
| 76 | void checkViewPosition(); |
| 77 | }, |
no test coverage detected