[Editor] Add a method to get an editor rect in the pdf page coordinates
This commit is contained in:
parent
bde01f0998
commit
1fc039e14f
@ -988,7 +988,7 @@ class DrawingEditor extends AnnotationEditor {
|
||||
/** @inheritdoc */
|
||||
renderAnnotationElement(annotation) {
|
||||
annotation.updateEdited({
|
||||
rect: this.getRect(0, 0),
|
||||
rect: this.getPDFRect(),
|
||||
});
|
||||
|
||||
return null;
|
||||
|
||||
@ -1572,6 +1572,15 @@ class AnnotationEditor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rect in page coordinates without any translation.
|
||||
* It's used when serializing the editor.
|
||||
* @returns {Array<number>}
|
||||
*/
|
||||
getPDFRect() {
|
||||
return this.getRect(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executed once this editor has been rendered.
|
||||
* @param {boolean} focus - true if the editor should be focused.
|
||||
|
||||
@ -770,6 +770,12 @@ class FreeTextEditor extends AnnotationEditor {
|
||||
return this.editorDiv;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
getPDFRect() {
|
||||
const padding = FreeTextEditor._internalPadding * this.parentScale;
|
||||
return this.getRect(padding, padding);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
static async deserialize(data, parent, uiManager) {
|
||||
let initialData = null;
|
||||
@ -833,8 +839,7 @@ class FreeTextEditor extends AnnotationEditor {
|
||||
return this.serializeDeleted();
|
||||
}
|
||||
|
||||
const padding = FreeTextEditor._internalPadding * this.parentScale;
|
||||
const rect = this.getRect(padding, padding);
|
||||
const rect = this.getPDFRect();
|
||||
const color = AnnotationEditor._colorManager.convert(
|
||||
this.isAttachedToDOM
|
||||
? getComputedStyle(this.editorDiv).color
|
||||
@ -901,9 +906,8 @@ class FreeTextEditor extends AnnotationEditor {
|
||||
content.append(div);
|
||||
}
|
||||
|
||||
const padding = FreeTextEditor._internalPadding * this.parentScale;
|
||||
const params = {
|
||||
rect: this.getRect(padding, padding),
|
||||
rect: this.getPDFRect(),
|
||||
};
|
||||
params.popup = this.hasEditedComment
|
||||
? this.comment
|
||||
|
||||
@ -1023,7 +1023,7 @@ class HighlightEditor extends AnnotationEditor {
|
||||
return this.serializeDeleted();
|
||||
}
|
||||
|
||||
const rect = this.getRect(0, 0);
|
||||
const rect = this.getPDFRect();
|
||||
const color = AnnotationEditor._colorManager.convert(
|
||||
this._uiManager.getNonHCMColor(this.color)
|
||||
);
|
||||
@ -1064,7 +1064,7 @@ class HighlightEditor extends AnnotationEditor {
|
||||
return null;
|
||||
}
|
||||
const params = {
|
||||
rect: this.getRect(0, 0),
|
||||
rect: this.getPDFRect(),
|
||||
};
|
||||
if (this.hasEditedComment) {
|
||||
params.popup = this.comment;
|
||||
|
||||
@ -845,7 +845,7 @@ class StampEditor extends AnnotationEditor {
|
||||
annotationType: AnnotationEditorType.STAMP,
|
||||
bitmapId: this.#bitmapId,
|
||||
pageIndex: this.pageIndex,
|
||||
rect: this.getRect(0, 0),
|
||||
rect: this.getPDFRect(),
|
||||
rotation: this.rotation,
|
||||
isSvg: this.#isSvg,
|
||||
structTreeParentId: this._structTreeParentId,
|
||||
@ -935,7 +935,7 @@ class StampEditor extends AnnotationEditor {
|
||||
return null;
|
||||
}
|
||||
const params = {
|
||||
rect: this.getRect(0, 0),
|
||||
rect: this.getPDFRect(),
|
||||
};
|
||||
if (this.hasEditedComment) {
|
||||
params.popup = this.comment;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user