[Editor] Add an option to use the new 'add an image' flow (bug 1907207)

UX team designed in a new flow we'll implement soon and we want to be able to
make an experiment to be able to compare current flow vs the new one.
This commit is contained in:
Calixte Denizet 2024-07-12 10:49:36 +02:00
parent 2d254375a8
commit dfccc8ffd9
5 changed files with 25 additions and 0 deletions

View file

@ -55,6 +55,10 @@
"type": "boolean", "type": "boolean",
"default": false "default": false
}, },
"enableUpdatedAddImage": {
"type": "boolean",
"default": false
},
"cursorToolOnLoad": { "cursorToolOnLoad": {
"title": "Cursor tool on load", "title": "Cursor tool on load",
"description": "The cursor tool that is enabled upon load.\n 0 = Text selection tool.\n 1 = Hand tool.", "description": "The cursor tool that is enabled upon load.\n 0 = Text selection tool.\n 1 = Hand tool.",

View file

@ -562,6 +562,8 @@ class AnnotationEditorUIManager {
#enableHighlightFloatingButton = false; #enableHighlightFloatingButton = false;
#enableUpdatedAddImage = false;
#filterFactory = null; #filterFactory = null;
#focusMainContainerTimeoutId = null; #focusMainContainerTimeoutId = null;
@ -779,6 +781,7 @@ class AnnotationEditorUIManager {
pageColors, pageColors,
highlightColors, highlightColors,
enableHighlightFloatingButton, enableHighlightFloatingButton,
enableUpdatedAddImage,
mlManager mlManager
) { ) {
this._signal = this.#abortController.signal; this._signal = this.#abortController.signal;
@ -798,6 +801,7 @@ class AnnotationEditorUIManager {
this.#pageColors = pageColors; this.#pageColors = pageColors;
this.#highlightColors = highlightColors || null; this.#highlightColors = highlightColors || null;
this.#enableHighlightFloatingButton = enableHighlightFloatingButton; this.#enableHighlightFloatingButton = enableHighlightFloatingButton;
this.#enableUpdatedAddImage = enableUpdatedAddImage;
this.#mlManager = mlManager || null; this.#mlManager = mlManager || null;
this.viewParameters = { this.viewParameters = {
realScale: PixelsPerInch.PDF_TO_CSS_UNITS, realScale: PixelsPerInch.PDF_TO_CSS_UNITS,
@ -855,6 +859,10 @@ class AnnotationEditorUIManager {
return !!this.#mlManager?.isEnabledFor(name); return !!this.#mlManager?.isEnabledFor(name);
} }
get useNewAltTextFlow() {
return this.#enableUpdatedAddImage;
}
get hcmFilter() { get hcmFilter() {
return shadow( return shadow(
this, this,

View file

@ -477,6 +477,7 @@ const PDFViewerApplication = {
enableHighlightFloatingButton: AppOptions.get( enableHighlightFloatingButton: AppOptions.get(
"enableHighlightFloatingButton" "enableHighlightFloatingButton"
), ),
enableUpdatedAddImage: AppOptions.get("enableUpdatedAddImage"),
imageResourcesPath: AppOptions.get("imageResourcesPath"), imageResourcesPath: AppOptions.get("imageResourcesPath"),
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"), enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
maxCanvasPixels: AppOptions.get("maxCanvasPixels"), maxCanvasPixels: AppOptions.get("maxCanvasPixels"),

View file

@ -178,6 +178,14 @@ const defaultOptions = {
value: typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME"), value: typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME"),
kind: OptionKind.VIEWER + OptionKind.PREFERENCE, kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
}, },
enableUpdatedAddImage: {
// We'll probably want to make some experiments before enabling this
// in Firefox release, but it has to be temporary.
// TODO: remove it when unnecessary.
/** @type {boolean} */
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
externalLinkRel: { externalLinkRel: {
/** @type {string} */ /** @type {string} */
value: "noopener noreferrer nofollow", value: "noopener noreferrer nofollow",

View file

@ -219,6 +219,8 @@ class PDFViewer {
#enablePermissions = false; #enablePermissions = false;
#enableUpdatedAddImage = false;
#eventAbortController = null; #eventAbortController = null;
#mlManager = null; #mlManager = null;
@ -291,6 +293,7 @@ class PDFViewer {
options.annotationEditorHighlightColors || null; options.annotationEditorHighlightColors || null;
this.#enableHighlightFloatingButton = this.#enableHighlightFloatingButton =
options.enableHighlightFloatingButton === true; options.enableHighlightFloatingButton === true;
this.#enableUpdatedAddImage = options.enableUpdatedAddImage === true;
this.imageResourcesPath = options.imageResourcesPath || ""; this.imageResourcesPath = options.imageResourcesPath || "";
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false; this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
@ -890,6 +893,7 @@ class PDFViewer {
pageColors, pageColors,
this.#annotationEditorHighlightColors, this.#annotationEditorHighlightColors,
this.#enableHighlightFloatingButton, this.#enableHighlightFloatingButton,
this.#enableUpdatedAddImage,
this.#mlManager this.#mlManager
); );
eventBus.dispatch("annotationeditoruimanager", { eventBus.dispatch("annotationeditoruimanager", {