1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00

Merge pull request #19394 from calixteman/mv_supported_img_types

Move the array containing the supported image mime types in display_utils
This commit is contained in:
calixteman 2025-01-30 16:48:13 +01:00 committed by GitHub
commit ec7270c546
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 30 additions and 34 deletions

View file

@ -650,6 +650,20 @@ class OutputScale {
}
}
// See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
// to know which types are supported by the browser.
const SupportedImageMimeTypes = [
"image/apng",
"image/avif",
"image/bmp",
"image/gif",
"image/jpeg",
"image/png",
"image/svg+xml",
"image/webp",
"image/x-icon",
];
export {
deprecated,
fetchData,
@ -672,5 +686,6 @@ export {
setLayerDimensions,
StatTimer,
stopEvent,
SupportedImageMimeTypes,
SVG_NS,
};

View file

@ -17,7 +17,7 @@ import { AnnotationEditorType, shadow } from "../../shared/util.js";
import { DrawingEditor, DrawingOptions } from "./draw.js";
import { AnnotationEditor } from "./editor.js";
import { SignatureExtractor } from "./drawers/signaturedraw.js";
import { StampEditor } from "./stamp.js";
import { SupportedImageMimeTypes } from "../display_utils.js";
class SignatureOptions extends DrawingOptions {
#viewParameters;
@ -106,7 +106,7 @@ class SignatureEditor extends DrawingEditor {
async #extractSignature() {
const input = document.createElement("input");
input.type = "file";
input.accept = StampEditor.supportedTypesStr;
input.accept = SupportedImageMimeTypes.join(",");
const signal = this._uiManager._signal;
const { promise, resolve } = Promise.withResolvers();

View file

@ -13,12 +13,12 @@
* limitations under the License.
*/
import { AnnotationEditorType, AnnotationPrefix } from "../../shared/util.js";
import {
AnnotationEditorType,
AnnotationPrefix,
shadow,
} from "../../shared/util.js";
import { OutputScale, PixelsPerInch } from "../display_utils.js";
OutputScale,
PixelsPerInch,
SupportedImageMimeTypes,
} from "../display_utils.js";
import { AnnotationEditor } from "./editor.js";
import { StampAnnotationElement } from "../annotation_layer.js";
@ -63,34 +63,9 @@ class StampEditor extends AnnotationEditor {
AnnotationEditor.initialize(l10n, uiManager);
}
static get supportedTypes() {
// See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
// to know which types are supported by the browser.
const types = [
"apng",
"avif",
"bmp",
"gif",
"jpeg",
"png",
"svg+xml",
"webp",
"x-icon",
];
return shadow(
this,
"supportedTypes",
types.map(type => `image/${type}`)
);
}
static get supportedTypesStr() {
return shadow(this, "supportedTypesStr", this.supportedTypes.join(","));
}
/** @inheritdoc */
static isHandlingMimeForPasting(mime) {
return this.supportedTypes.includes(mime);
return SupportedImageMimeTypes.includes(mime);
}
/** @inheritdoc */
@ -258,7 +233,7 @@ class StampEditor extends AnnotationEditor {
document.body.append(input);
}
input.type = "file";
input.accept = StampEditor.supportedTypesStr;
input.accept = SupportedImageMimeTypes.join(",");
const signal = this._uiManager._signal;
this.#bitmapPromise = new Promise(resolve => {
input.addEventListener(

View file

@ -61,6 +61,7 @@ import {
RenderingCancelledException,
setLayerDimensions,
stopEvent,
SupportedImageMimeTypes,
} from "./display/display_utils.js";
import { AnnotationEditorLayer } from "./display/editor/annotation_editor_layer.js";
import { AnnotationEditorUIManager } from "./display/editor/tools.js";
@ -126,6 +127,7 @@ export {
setLayerDimensions,
shadow,
stopEvent,
SupportedImageMimeTypes,
TextLayer,
TouchManager,
Util,