import commentIcon from "@icons/comment.svg"
import closeIcon from "@icons/close.svg"
+import {PageDisplay} from "./page-display";
/**
* Track the close function for the current open marker so it can be closed
protected deleteButton: HTMLElement;
protected replyButton: HTMLElement;
protected input: HTMLInputElement;
+ protected contentRefLink: HTMLLinkElement|null;
setup() {
// Options
this.deleteButton = this.$refs.deleteButton;
this.replyButton = this.$refs.replyButton;
this.input = this.$refs.input as HTMLInputElement;
+ this.contentRefLink = (this.$refs.contentRef || null) as HTMLLinkElement|null;
this.setupListeners();
this.positionForReference();
}
protected positionForReference() {
- if (!this.commentContentRef) {
+ if (!this.commentContentRef || !this.contentRefLink) {
return;
}
const [refId, refHash, refRange] = this.commentContentRef.split(':');
const refEl = document.getElementById(refId);
if (!refEl) {
- // TODO - Show outdated marker for comment
+ this.contentRefLink.classList.add('outdated', 'missing');
return;
}
const actualHash = hashElement(refEl);
if (actualHash !== refHash) {
- // TODO - Show outdated marker for comment
- return;
+ this.contentRefLink.classList.add('outdated');
}
const refElBounds = refEl.getBoundingClientRect();
refEl.style.position = 'relative';
refEl.append(markerWrap);
+
+ this.contentRefLink.href = `#${refEl.id}`;
+ this.contentRefLink.addEventListener('click', (event: MouseEvent) => {
+ const pageDisplayComponent = window.$components.get('page-display')[0] as PageDisplay;
+ event.preventDefault();
+ pageDisplayComponent.goToText(refId);
+ });
}
protected showCommentAtMarker(marker: HTMLElement): void {
height: calc(100% - vars.$m);
}
+.comment-reference-indicator-wrap a {
+ float: left;
+ margin-top: vars.$xs;
+ font-size: 12px;
+ display: inline-block;
+ font-weight: bold;
+ position: relative;
+ border-radius: 4px;
+ overflow: hidden;
+ padding: 2px 6px 2px 0;
+ margin-inline-end: vars.$xs;
+ color: var(--color-link);
+ span {
+ display: none;
+ }
+ &.outdated span {
+ display: inline;
+ }
+ &.outdated.missing {
+ color: var(--color-warning);
+ pointer-events: none;
+ }
+ svg {
+ width: 24px;
+ margin-inline-end: 0;
+ }
+ &:after {
+ background-color: currentColor;
+ content: '';
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ left: 0;
+ top: 0;
+ opacity: 0.15;
+ }
+}
+
.comment-branch .comment-box {
margin-bottom: vars.$m;
}