mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
[Editor] Provide an element to render in the annotation layer after a freetext has been edited (bug 1890535)
This commit is contained in:
parent
7290faf840
commit
71ea8499f0
11 changed files with 379 additions and 42 deletions
|
@ -544,6 +544,8 @@ class AnnotationEditorUIManager {
|
|||
|
||||
#annotationStorage = null;
|
||||
|
||||
#changedExistingAnnotations = null;
|
||||
|
||||
#commandManager = new CommandManager();
|
||||
|
||||
#currentPageIndex = 0;
|
||||
|
@ -1682,6 +1684,7 @@ class AnnotationEditorUIManager {
|
|||
*/
|
||||
addDeletedAnnotationElement(editor) {
|
||||
this.#deletedAnnotationsElementIds.add(editor.annotationElementId);
|
||||
this.addChangedExistingAnnotation(editor);
|
||||
editor.deleted = true;
|
||||
}
|
||||
|
||||
|
@ -1700,6 +1703,7 @@ class AnnotationEditorUIManager {
|
|||
*/
|
||||
removeDeletedAnnotationElement(editor) {
|
||||
this.#deletedAnnotationsElementIds.delete(editor.annotationElementId);
|
||||
this.removeChangedExistingAnnotation(editor);
|
||||
editor.deleted = false;
|
||||
}
|
||||
|
||||
|
@ -2243,6 +2247,32 @@ class AnnotationEditorUIManager {
|
|||
}
|
||||
return boxes.length === 0 ? null : boxes;
|
||||
}
|
||||
|
||||
addChangedExistingAnnotation({ annotationElementId, id }) {
|
||||
(this.#changedExistingAnnotations ||= new Map()).set(
|
||||
annotationElementId,
|
||||
id
|
||||
);
|
||||
}
|
||||
|
||||
removeChangedExistingAnnotation({ annotationElementId }) {
|
||||
this.#changedExistingAnnotations?.delete(annotationElementId);
|
||||
}
|
||||
|
||||
renderAnnotationElement(annotation) {
|
||||
const editorId = this.#changedExistingAnnotations?.get(annotation.data.id);
|
||||
if (!editorId) {
|
||||
return;
|
||||
}
|
||||
const editor = this.#annotationStorage.getRawValue(editorId);
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
if (this.#mode === AnnotationEditorType.NONE && !editor.hasBeenModified) {
|
||||
return;
|
||||
}
|
||||
editor.renderAnnotationElement(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue