mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
[Editor] Add more telemetry for the 'add image' feature (bug 1853960)
This commit is contained in:
parent
b80e0d881d
commit
0a278ef0bc
5 changed files with 137 additions and 31 deletions
|
@ -119,6 +119,10 @@ class AnnotationEditor {
|
|||
this.deleted = false;
|
||||
}
|
||||
|
||||
get editorType() {
|
||||
return Object.getPrototypeOf(this).constructor._type;
|
||||
}
|
||||
|
||||
static get _defaultLineColor() {
|
||||
return shadow(
|
||||
this,
|
||||
|
@ -843,18 +847,6 @@ class AnnotationEditor {
|
|||
this._uiManager.editAltText(this);
|
||||
}
|
||||
});
|
||||
const DELAY_TO_SHOW_TOOLTIP = 500;
|
||||
altText.addEventListener("mouseenter", () => {
|
||||
this.#altTextTooltipTimeout = setTimeout(() => {
|
||||
this.#altTextTooltipTimeout = null;
|
||||
this.#altTextTooltip?.classList.add("show");
|
||||
}, DELAY_TO_SHOW_TOOLTIP);
|
||||
});
|
||||
altText.addEventListener("mouseleave", () => {
|
||||
clearTimeout(this.#altTextTooltipTimeout);
|
||||
this.#altTextTooltipTimeout = null;
|
||||
this.#altTextTooltip?.classList.remove("show");
|
||||
});
|
||||
this.#setAltTextButtonState();
|
||||
this.div.append(altText);
|
||||
if (!AnnotationEditor.SMALL_EDITOR_SIZE) {
|
||||
|
@ -881,6 +873,29 @@ class AnnotationEditor {
|
|||
const id = (tooltip.id = `alt-text-tooltip-${this.id}`);
|
||||
button.append(tooltip);
|
||||
button.setAttribute("aria-describedby", id);
|
||||
|
||||
const DELAY_TO_SHOW_TOOLTIP = 500;
|
||||
button.addEventListener("mouseenter", () => {
|
||||
this.#altTextTooltipTimeout = setTimeout(() => {
|
||||
this.#altTextTooltipTimeout = null;
|
||||
this.#altTextTooltip.classList.add("show");
|
||||
this._uiManager._eventBus.dispatch("reporttelemetry", {
|
||||
source: this,
|
||||
details: {
|
||||
type: "editing",
|
||||
subtype: this.editorType,
|
||||
data: {
|
||||
action: "alt_text_tooltip",
|
||||
},
|
||||
},
|
||||
});
|
||||
}, DELAY_TO_SHOW_TOOLTIP);
|
||||
});
|
||||
button.addEventListener("mouseleave", () => {
|
||||
clearTimeout(this.#altTextTooltipTimeout);
|
||||
this.#altTextTooltipTimeout = null;
|
||||
this.#altTextTooltip?.classList.remove("show");
|
||||
});
|
||||
}
|
||||
button.classList.add("done");
|
||||
if (this.#altTextDecorative) {
|
||||
|
|
|
@ -311,6 +311,20 @@ class StampEditor extends AnnotationEditor {
|
|||
this.parent.addUndoableEditor(this);
|
||||
this.#hasBeenAddedInUndoStack = true;
|
||||
}
|
||||
|
||||
// There are multiple ways to add an image to the page, so here we just
|
||||
// count the number of times an image is added to the page whatever the way
|
||||
// is.
|
||||
this._uiManager._eventBus.dispatch("reporttelemetry", {
|
||||
source: this,
|
||||
details: {
|
||||
type: "editing",
|
||||
subtype: this.editorType,
|
||||
data: {
|
||||
action: "inserted_image",
|
||||
},
|
||||
},
|
||||
});
|
||||
this.addAltTextButton();
|
||||
}
|
||||
|
||||
|
|
|
@ -541,8 +541,6 @@ class AnnotationEditorUIManager {
|
|||
|
||||
#editorsToRescale = new Set();
|
||||
|
||||
#eventBus = null;
|
||||
|
||||
#filterFactory = null;
|
||||
|
||||
#idManager = new IdManager();
|
||||
|
@ -706,11 +704,11 @@ class AnnotationEditorUIManager {
|
|||
this.#container = container;
|
||||
this.#viewer = viewer;
|
||||
this.#altTextManager = altTextManager;
|
||||
this.#eventBus = eventBus;
|
||||
this.#eventBus._on("editingaction", this.#boundOnEditingAction);
|
||||
this.#eventBus._on("pagechanging", this.#boundOnPageChanging);
|
||||
this.#eventBus._on("scalechanging", this.#boundOnScaleChanging);
|
||||
this.#eventBus._on("rotationchanging", this.#boundOnRotationChanging);
|
||||
this._eventBus = eventBus;
|
||||
this._eventBus._on("editingaction", this.#boundOnEditingAction);
|
||||
this._eventBus._on("pagechanging", this.#boundOnPageChanging);
|
||||
this._eventBus._on("scalechanging", this.#boundOnScaleChanging);
|
||||
this._eventBus._on("rotationchanging", this.#boundOnRotationChanging);
|
||||
this.#annotationStorage = pdfDocument.annotationStorage;
|
||||
this.#filterFactory = pdfDocument.filterFactory;
|
||||
this.#pageColors = pageColors;
|
||||
|
@ -723,10 +721,10 @@ class AnnotationEditorUIManager {
|
|||
destroy() {
|
||||
this.#removeKeyboardManager();
|
||||
this.#removeFocusManager();
|
||||
this.#eventBus._off("editingaction", this.#boundOnEditingAction);
|
||||
this.#eventBus._off("pagechanging", this.#boundOnPageChanging);
|
||||
this.#eventBus._off("scalechanging", this.#boundOnScaleChanging);
|
||||
this.#eventBus._off("rotationchanging", this.#boundOnRotationChanging);
|
||||
this._eventBus._off("editingaction", this.#boundOnEditingAction);
|
||||
this._eventBus._off("pagechanging", this.#boundOnPageChanging);
|
||||
this._eventBus._off("scalechanging", this.#boundOnScaleChanging);
|
||||
this._eventBus._off("rotationchanging", this.#boundOnRotationChanging);
|
||||
for (const layer of this.#allLayers.values()) {
|
||||
layer.destroy();
|
||||
}
|
||||
|
@ -1041,7 +1039,7 @@ class AnnotationEditorUIManager {
|
|||
);
|
||||
|
||||
if (hasChanged) {
|
||||
this.#eventBus.dispatch("annotationeditorstateschanged", {
|
||||
this._eventBus.dispatch("annotationeditorstateschanged", {
|
||||
source: this,
|
||||
details: Object.assign(this.#previousStates, details),
|
||||
});
|
||||
|
@ -1049,7 +1047,7 @@ class AnnotationEditorUIManager {
|
|||
}
|
||||
|
||||
#dispatchUpdateUI(details) {
|
||||
this.#eventBus.dispatch("annotationeditorparamschanged", {
|
||||
this._eventBus.dispatch("annotationeditorparamschanged", {
|
||||
source: this,
|
||||
details,
|
||||
});
|
||||
|
@ -1177,7 +1175,7 @@ class AnnotationEditorUIManager {
|
|||
if (mode === this.#mode) {
|
||||
return;
|
||||
}
|
||||
this.#eventBus.dispatch("switchannotationeditormode", {
|
||||
this._eventBus.dispatch("switchannotationeditormode", {
|
||||
source: this,
|
||||
mode,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue