mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-20 20:31:25 +08:00
Comments: Added reference marker to comments
Some checks failed
lint-js / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-js / build (push) Has been cancelled
analyse-php / build (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-migrations / build (8.4) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
test-php / build (8.4) (push) Has been cancelled
Some checks failed
lint-js / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-js / build (push) Has been cancelled
analyse-php / build (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-migrations / build (8.4) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
test-php / build (8.4) (push) Has been cancelled
This commit is contained in:
1
resources/icons/bookmark.svg
Normal file
1
resources/icons/bookmark.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M200-120v-640q0-33 23.5-56.5T280-840h400q33 0 56.5 23.5T760-760v640L480-240 200-120Zm80-122 200-86 200 86v-518H280v518Zm0-518h400-400Z"/></svg>
|
After Width: | Height: | Size: 217 B |
@ -5,6 +5,7 @@ import {el} from "../wysiwyg/utils/dom";
|
|||||||
|
|
||||||
import commentIcon from "@icons/comment.svg"
|
import commentIcon from "@icons/comment.svg"
|
||||||
import closeIcon from "@icons/close.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
|
* Track the close function for the current open marker so it can be closed
|
||||||
@ -35,6 +36,7 @@ export class PageComment extends Component {
|
|||||||
protected deleteButton: HTMLElement;
|
protected deleteButton: HTMLElement;
|
||||||
protected replyButton: HTMLElement;
|
protected replyButton: HTMLElement;
|
||||||
protected input: HTMLInputElement;
|
protected input: HTMLInputElement;
|
||||||
|
protected contentRefLink: HTMLLinkElement|null;
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
// Options
|
// Options
|
||||||
@ -60,6 +62,7 @@ export class PageComment extends Component {
|
|||||||
this.deleteButton = this.$refs.deleteButton;
|
this.deleteButton = this.$refs.deleteButton;
|
||||||
this.replyButton = this.$refs.replyButton;
|
this.replyButton = this.$refs.replyButton;
|
||||||
this.input = this.$refs.input as HTMLInputElement;
|
this.input = this.$refs.input as HTMLInputElement;
|
||||||
|
this.contentRefLink = (this.$refs.contentRef || null) as HTMLLinkElement|null;
|
||||||
|
|
||||||
this.setupListeners();
|
this.setupListeners();
|
||||||
this.positionForReference();
|
this.positionForReference();
|
||||||
@ -153,21 +156,20 @@ export class PageComment extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected positionForReference() {
|
protected positionForReference() {
|
||||||
if (!this.commentContentRef) {
|
if (!this.commentContentRef || !this.contentRefLink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [refId, refHash, refRange] = this.commentContentRef.split(':');
|
const [refId, refHash, refRange] = this.commentContentRef.split(':');
|
||||||
const refEl = document.getElementById(refId);
|
const refEl = document.getElementById(refId);
|
||||||
if (!refEl) {
|
if (!refEl) {
|
||||||
// TODO - Show outdated marker for comment
|
this.contentRefLink.classList.add('outdated', 'missing');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const actualHash = hashElement(refEl);
|
const actualHash = hashElement(refEl);
|
||||||
if (actualHash !== refHash) {
|
if (actualHash !== refHash) {
|
||||||
// TODO - Show outdated marker for comment
|
this.contentRefLink.classList.add('outdated');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const refElBounds = refEl.getBoundingClientRect();
|
const refElBounds = refEl.getBoundingClientRect();
|
||||||
@ -204,6 +206,13 @@ export class PageComment extends Component {
|
|||||||
|
|
||||||
refEl.style.position = 'relative';
|
refEl.style.position = 'relative';
|
||||||
refEl.append(markerWrap);
|
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 {
|
protected showCommentAtMarker(marker: HTMLElement): void {
|
||||||
|
@ -57,6 +57,9 @@ export class PageDisplay extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
goToText(text) {
|
goToText(text) {
|
||||||
const idElem = document.getElementById(text);
|
const idElem = document.getElementById(text);
|
||||||
|
|
||||||
|
@ -746,6 +746,44 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group {
|
|||||||
height: calc(100% - vars.$m);
|
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 {
|
.comment-branch .comment-box {
|
||||||
margin-bottom: vars.$m;
|
margin-bottom: vars.$m;
|
||||||
}
|
}
|
||||||
|
@ -280,6 +280,9 @@ body.tox-fullscreen, body.markdown-fullscreen {
|
|||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
.content-comment-window-content .comment-reference-indicator-wrap {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
.content-comment-marker {
|
.content-comment-marker {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: -16px;
|
right: -16px;
|
||||||
|
@ -77,6 +77,11 @@
|
|||||||
<a class="text-muted text-small" href="#comment{{ $comment->parent_id }}">@icon('reply'){{ trans('entities.comment_in_reply_to', ['commentId' => '#' . $comment->parent_id]) }}</a>
|
<a class="text-muted text-small" href="#comment{{ $comment->parent_id }}">@icon('reply'){{ trans('entities.comment_in_reply_to', ['commentId' => '#' . $comment->parent_id]) }}</a>
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
@if($comment->content_ref)
|
||||||
|
<div class="comment-reference-indicator-wrap">
|
||||||
|
<a href="#" refs="page-comment@content-ref">@icon('bookmark')Reference <span>- Outdated</span></a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
{!! $commentHtml !!}
|
{!! $commentHtml !!}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user