- const close = el('button', {type: 'button', title: this.closeText});
- close.innerHTML = (closeIcon as string);
- const jump = el('button', {type: 'button', 'data-action': 'jump'}, [this.jumpToThreadText]);
-
- const commentWindow = el('div', {
- class: 'content-comment-window'
- }, [
- el('div', {
- class: 'content-comment-window-actions',
- }, [jump, close]),
- el('div', {
- class: 'content-comment-window-content comment-container-compact comment-container-super-compact',
- }, [readClone]),
- ]);
-
- marker.parentElement?.append(commentWindow);
-
- // Handle interaction within window
- const closeAction = () => {
- commentWindow.remove();
- marker.hidden = false;
- window.removeEventListener('click', windowCloseAction);
- openMarkerClose = null;
- };
-
- const windowCloseAction = (event: MouseEvent) => {
- if (!(marker.parentElement as HTMLElement).contains(event.target as HTMLElement)) {
- closeAction();
- }
- };
- window.addEventListener('click', windowCloseAction);
-
- openMarkerClose = closeAction;
- close.addEventListener('click', closeAction.bind(this));
- jump.addEventListener('click', () => {
- closeAction();
- this.container.scrollIntoView({behavior: 'smooth'});
- const highlightTarget = this.container.querySelector('.header') as HTMLElement;
- highlightTarget.classList.add('anim-highlight');
- highlightTarget.addEventListener('animationend', () => highlightTarget.classList.remove('anim-highlight'))
- });
-
- // Position window within bounds
- const commentWindowBounds = commentWindow.getBoundingClientRect();
- const contentBounds = document.querySelector('.page-content')?.getBoundingClientRect();
- if (contentBounds && commentWindowBounds.right > contentBounds.right) {
- const diff = commentWindowBounds.right - contentBounds.right;
- commentWindow.style.left = `-${diff}px`;
- }