mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
removing enum
This commit is contained in:
parent
0a6c0b5950
commit
c8ccdf3716
2 changed files with 7 additions and 11 deletions
|
@ -17,7 +17,7 @@ export const getMetadataChunk = async (
|
|||
): Promise<{ keyword: string; text: string } | null> => {
|
||||
const chunks = decodePng(new Uint8Array(await blobToArrayBuffer(blob)));
|
||||
|
||||
const iTXtChunk = chunks.find((chunk) => chunk.name === PNGChunkType.iTXt);
|
||||
const iTXtChunk = chunks.find((chunk) => chunk.name === "iTXt");
|
||||
if (iTXtChunk) {
|
||||
try {
|
||||
const decoded = decodeITXt(iTXtChunk.data);
|
||||
|
@ -27,7 +27,7 @@ export const getMetadataChunk = async (
|
|||
}
|
||||
}
|
||||
|
||||
const tEXtChunk = chunks.find((chunk) => chunk.name === PNGChunkType.tEXt);
|
||||
const tEXtChunk = chunks.find((chunk) => chunk.name === "tEXt");
|
||||
if (tEXtChunk) {
|
||||
return tEXt.decode(tEXtChunk.data);
|
||||
}
|
||||
|
@ -48,9 +48,9 @@ export const encodePngMetadata = async ({
|
|||
|
||||
const filteredChunks = chunks.filter(
|
||||
(chunk) =>
|
||||
!(chunk.name === PNGChunkType.tEXt &&
|
||||
!(chunk.name === "tEXt" &&
|
||||
tEXt.decode(chunk.data).keyword === MIME_TYPES.excalidraw) &&
|
||||
!(chunk.name === PNGChunkType.iTXt &&
|
||||
!(chunk.name === "iTXt" &&
|
||||
decodeITXt(chunk.data).keyword === MIME_TYPES.excalidraw)
|
||||
);
|
||||
|
||||
|
|
10
packages/excalidraw/global.d.ts
vendored
10
packages/excalidraw/global.d.ts
vendored
|
@ -32,18 +32,14 @@ interface Clipboard extends EventTarget {
|
|||
|
||||
// PNG encoding/decoding
|
||||
// -----------------------------------------------------------------------------
|
||||
enum PNGChunkType {
|
||||
tEXt = "tEXt",
|
||||
iTXt = "iTXt",
|
||||
}
|
||||
|
||||
type TEXtChunk = { name: "tEXt"; data: Uint8Array };
|
||||
type ITXtChunk = { name: "iTXt"; data: Uint8Array };
|
||||
|
||||
declare module "png-chunk-text" {
|
||||
function encode(
|
||||
name: string,
|
||||
value: string,
|
||||
): { name: PNGChunkType.tEXt; data: Uint8Array };
|
||||
): { name: "tEXt"; data: Uint8Array };
|
||||
function decode(data: Uint8Array): { keyword: string; text: string };
|
||||
}
|
||||
declare module "png-chunk-itxt" {
|
||||
|
@ -51,7 +47,7 @@ declare module "png-chunk-itxt" {
|
|||
keyword: string,
|
||||
text: string,
|
||||
options?: { compressed?: boolean; compressedMethod: number; language?: string; translated?: string },
|
||||
): { name: PNGChunkType.iTXt; data: Uint8Array };
|
||||
): { name: "iTXt"; data: Uint8Array };
|
||||
function decode(data: Uint8Array): {
|
||||
keyword: string;
|
||||
text: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue