Merge pull request #20247 from calixteman/wait_for_rendered_editors
[Editor] When clicking on a comment in the sidebar, wait for the annotation editor layer to be rendered
This commit is contained in:
commit
5b7f9ca8b9
@ -281,6 +281,10 @@ class AnnotationEditorLayer {
|
|||||||
editor.enableEditing();
|
editor.enableEditing();
|
||||||
}
|
}
|
||||||
this.#isEnabling = false;
|
this.#isEnabling = false;
|
||||||
|
this.#uiManager._eventBus.dispatch("editorsrendered", {
|
||||||
|
source: this,
|
||||||
|
pageNumber: this.pageIndex + 1,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -745,8 +749,12 @@ class AnnotationEditorLayer {
|
|||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get boundingClientRect() {
|
||||||
|
return this.div.getBoundingClientRect();
|
||||||
|
}
|
||||||
|
|
||||||
#getCenterPoint() {
|
#getCenterPoint() {
|
||||||
const { x, y, width, height } = this.div.getBoundingClientRect();
|
const { x, y, width, height } = this.boundingClientRect;
|
||||||
const tlX = Math.max(0, x);
|
const tlX = Math.max(0, x);
|
||||||
const tlY = Math.max(0, y);
|
const tlY = Math.max(0, y);
|
||||||
const brX = Math.min(window.innerWidth, x + width);
|
const brX = Math.min(window.innerWidth, x + width);
|
||||||
|
|||||||
@ -1078,18 +1078,18 @@ class AnnotationEditorUIManager {
|
|||||||
editor?.showComment();
|
editor?.showComment();
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitForPageRendered(pageNumber) {
|
async waitForEditorsRendered(pageNumber) {
|
||||||
if (this.#allLayers.has(pageNumber - 1)) {
|
if (this.#allLayers.has(pageNumber - 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { resolve, promise } = Promise.withResolvers();
|
const { resolve, promise } = Promise.withResolvers();
|
||||||
const onPageRendered = evt => {
|
const onEditorsRendered = evt => {
|
||||||
if (evt.pageNumber === pageNumber) {
|
if (evt.pageNumber === pageNumber) {
|
||||||
this._eventBus._off("annotationeditorlayerrendered", onPageRendered);
|
this._eventBus._off("editorsrendered", onEditorsRendered);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this._eventBus.on("annotationeditorlayerrendered", onPageRendered);
|
this._eventBus.on("editorsrendered", onEditorsRendered);
|
||||||
await promise;
|
await promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -670,7 +670,8 @@ class CommentSidebar {
|
|||||||
const { id, pageIndex, rect } = annotation;
|
const { id, pageIndex, rect } = annotation;
|
||||||
const SPACE_ABOVE_ANNOTATION = 10;
|
const SPACE_ABOVE_ANNOTATION = 10;
|
||||||
const pageNumber = pageIndex + 1;
|
const pageNumber = pageIndex + 1;
|
||||||
const pageVisiblePromise = this.#uiManager?.waitForPageRendered(pageNumber);
|
const pageVisiblePromise =
|
||||||
|
this.#uiManager?.waitForEditorsRendered(pageNumber);
|
||||||
this.#linkService?.goToXY(
|
this.#linkService?.goToXY(
|
||||||
pageNumber,
|
pageNumber,
|
||||||
rect[0],
|
rect[0],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user