@arbidocs/coedit 0.4.99 → 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.cjs CHANGED
@@ -614,19 +614,39 @@ function materialize(doc, cache, changed = null) {
614
614
  mainDocumentPart: main
615
615
  });
616
616
  }
617
+ var MEDIA_TYPES = {
618
+ png: "image/png",
619
+ jpg: "image/jpeg",
620
+ jpeg: "image/jpeg",
621
+ gif: "image/gif",
622
+ bmp: "image/bmp",
623
+ tif: "image/tiff",
624
+ tiff: "image/tiff",
625
+ webp: "image/webp",
626
+ svg: "image/svg+xml",
627
+ emf: "image/x-emf",
628
+ wmf: "image/x-wmf"
629
+ };
617
630
  function withMirroredOverrides(pkg) {
618
631
  const bytes = store.contentTypesPartBytes(pkg);
619
632
  if (!bytes) return pkg;
633
+ const xml = new TextDecoder().decode(bytes.bytes);
620
634
  const declared = new Set(
621
- [...new TextDecoder().decode(bytes.bytes).matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map(
622
- (m) => m[1].toLowerCase()
623
- )
635
+ [...xml.matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
636
+ );
637
+ const defaults = new Set(
638
+ [...xml.matchAll(/Extension\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
624
639
  );
625
640
  let next = pkg;
626
641
  for (const name of [...pkg.parts.keys(), ...pkg.partBytes.keys()]) {
627
- const type = pkg.contentTypes.overrides.get(name.toLowerCase());
628
- if (type && !declared.has(name.toLowerCase()))
642
+ const key = name.toLowerCase();
643
+ if (declared.has(key) || key === bytes.storageKey.toLowerCase()) continue;
644
+ const extension = key.slice(key.lastIndexOf(".") + 1);
645
+ const type = pkg.contentTypes.overrides.get(key) ?? (defaults.has(extension) ? void 0 : MEDIA_TYPES[extension]);
646
+ if (type) {
629
647
  next = store.withContentTypeOverride(next, name, type, { forceOverride: true });
648
+ declared.add(key);
649
+ }
630
650
  }
631
651
  return next;
632
652
  }