@arbidocs/coedit 0.4.98 → 0.4.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -594,19 +594,39 @@ function materialize(doc, cache, changed = null) {
594
594
  mainDocumentPart: main
595
595
  });
596
596
  }
597
+ var MEDIA_TYPES = {
598
+ png: "image/png",
599
+ jpg: "image/jpeg",
600
+ jpeg: "image/jpeg",
601
+ gif: "image/gif",
602
+ bmp: "image/bmp",
603
+ tif: "image/tiff",
604
+ tiff: "image/tiff",
605
+ webp: "image/webp",
606
+ svg: "image/svg+xml",
607
+ emf: "image/x-emf",
608
+ wmf: "image/x-wmf"
609
+ };
597
610
  function withMirroredOverrides(pkg) {
598
611
  const bytes = contentTypesPartBytes(pkg);
599
612
  if (!bytes) return pkg;
613
+ const xml = new TextDecoder().decode(bytes.bytes);
600
614
  const declared = new Set(
601
- [...new TextDecoder().decode(bytes.bytes).matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map(
602
- (m) => m[1].toLowerCase()
603
- )
615
+ [...xml.matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
616
+ );
617
+ const defaults = new Set(
618
+ [...xml.matchAll(/Extension\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
604
619
  );
605
620
  let next = pkg;
606
621
  for (const name of [...pkg.parts.keys(), ...pkg.partBytes.keys()]) {
607
- const type = pkg.contentTypes.overrides.get(name.toLowerCase());
608
- if (type && !declared.has(name.toLowerCase()))
622
+ const key = name.toLowerCase();
623
+ if (declared.has(key) || key === bytes.storageKey.toLowerCase()) continue;
624
+ const extension = key.slice(key.lastIndexOf(".") + 1);
625
+ const type = pkg.contentTypes.overrides.get(key) ?? (defaults.has(extension) ? void 0 : MEDIA_TYPES[extension]);
626
+ if (type) {
609
627
  next = withContentTypeOverride(next, name, type, { forceOverride: true });
628
+ declared.add(key);
629
+ }
610
630
  }
611
631
  return next;
612
632
  }