@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.
package/dist/index.js CHANGED
@@ -592,19 +592,39 @@ function materialize(doc, cache, changed = null) {
592
592
  mainDocumentPart: main
593
593
  });
594
594
  }
595
+ var MEDIA_TYPES = {
596
+ png: "image/png",
597
+ jpg: "image/jpeg",
598
+ jpeg: "image/jpeg",
599
+ gif: "image/gif",
600
+ bmp: "image/bmp",
601
+ tif: "image/tiff",
602
+ tiff: "image/tiff",
603
+ webp: "image/webp",
604
+ svg: "image/svg+xml",
605
+ emf: "image/x-emf",
606
+ wmf: "image/x-wmf"
607
+ };
595
608
  function withMirroredOverrides(pkg) {
596
609
  const bytes = contentTypesPartBytes(pkg);
597
610
  if (!bytes) return pkg;
611
+ const xml = new TextDecoder().decode(bytes.bytes);
598
612
  const declared = new Set(
599
- [...new TextDecoder().decode(bytes.bytes).matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map(
600
- (m) => m[1].toLowerCase()
601
- )
613
+ [...xml.matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
614
+ );
615
+ const defaults = new Set(
616
+ [...xml.matchAll(/Extension\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
602
617
  );
603
618
  let next = pkg;
604
619
  for (const name of [...pkg.parts.keys(), ...pkg.partBytes.keys()]) {
605
- const type = pkg.contentTypes.overrides.get(name.toLowerCase());
606
- if (type && !declared.has(name.toLowerCase()))
620
+ const key = name.toLowerCase();
621
+ if (declared.has(key) || key === bytes.storageKey.toLowerCase()) continue;
622
+ const extension = key.slice(key.lastIndexOf(".") + 1);
623
+ const type = pkg.contentTypes.overrides.get(key) ?? (defaults.has(extension) ? void 0 : MEDIA_TYPES[extension]);
624
+ if (type) {
607
625
  next = withContentTypeOverride(next, name, type, { forceOverride: true });
626
+ declared.add(key);
627
+ }
608
628
  }
609
629
  return next;
610
630
  }