mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-18 02:12:30 +08:00
Comments: Further range of content reference ux improvements
Some checks failed
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-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
- Added reference indicator to comment create form. - Added remove action. - Extracted reference text to translations. - Changed reference hash to be text-based instead of HTML based. - Added reference display for newly added comments. - Handled reference marker delete on comment delete.
This commit is contained in:
@ -28,10 +28,7 @@ export class PageCommentReference extends Component {
|
||||
this.closeText = this.$opts.closeText;
|
||||
|
||||
// Show within page display area if seen
|
||||
const pageContentArea = document.querySelector('.page-content');
|
||||
if (pageContentArea instanceof HTMLElement && this.link.checkVisibility()) {
|
||||
this.updateMarker(pageContentArea);
|
||||
}
|
||||
this.showForDisplay();
|
||||
|
||||
// Handle editor view to show on comments toolbox view
|
||||
window.addEventListener('editor-toolbox-change', (event) => {
|
||||
@ -47,19 +44,26 @@ export class PageCommentReference extends Component {
|
||||
// Handle comments tab changes to hide/show markers & indicators
|
||||
window.addEventListener('tabs-change', event => {
|
||||
const sectionId = (event as {detail: {showing: string}}).detail.showing;
|
||||
if (!sectionId.startsWith('comment-tab-panel') || !(pageContentArea instanceof HTMLElement)) {
|
||||
if (!sectionId.startsWith('comment-tab-panel')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const panel = document.getElementById(sectionId);
|
||||
if (panel?.contains(this.link)) {
|
||||
this.updateMarker(pageContentArea);
|
||||
this.showForDisplay();
|
||||
} else {
|
||||
this.hideMarker();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public showForDisplay() {
|
||||
const pageContentArea = document.querySelector('.page-content');
|
||||
if (pageContentArea instanceof HTMLElement && this.link.checkVisibility()) {
|
||||
this.updateMarker(pageContentArea);
|
||||
}
|
||||
}
|
||||
|
||||
protected showForEditor() {
|
||||
const contentWrap = document.querySelector('.editor-content-wrap');
|
||||
if (contentWrap instanceof HTMLElement) {
|
||||
@ -90,15 +94,7 @@ export class PageCommentReference extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
const refCloneToAssess = refEl.cloneNode(true) as HTMLElement;
|
||||
const toRemove = refCloneToAssess.querySelectorAll('[data-lexical-text]');
|
||||
refCloneToAssess.removeAttribute('style');
|
||||
for (const el of toRemove) {
|
||||
el.after(...el.childNodes);
|
||||
el.remove();
|
||||
}
|
||||
|
||||
const actualHash = hashElement(refCloneToAssess);
|
||||
const actualHash = hashElement(refEl);
|
||||
if (actualHash !== refHash) {
|
||||
this.link.classList.add('outdated');
|
||||
}
|
||||
|
Reference in New Issue
Block a user