mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
Move the array containing the supported image mime types in display_utils
and make it available for the viewer (it'll be used in the signature UI).
This commit is contained in:
parent
42c2b7b657
commit
2c737bc420
6 changed files with 30 additions and 34 deletions
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue