@arbidocs/coedit 0.4.96 → 0.4.97

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/server.cjs CHANGED
@@ -679,14 +679,30 @@ function materialize(doc, cache, changed = null) {
679
679
  defaults: new Map(doc.getMap("ctDefaults")),
680
680
  overrides: new Map(doc.getMap("ctOverrides"))
681
681
  };
682
- return {
682
+ return withMirroredOverrides({
683
683
  parts,
684
684
  partBytes,
685
685
  relationships,
686
686
  externalTargets,
687
687
  contentTypes,
688
688
  mainDocumentPart: main
689
- };
689
+ });
690
+ }
691
+ function withMirroredOverrides(pkg) {
692
+ const bytes = store.contentTypesPartBytes(pkg);
693
+ if (!bytes) return pkg;
694
+ const declared = new Set(
695
+ [...new TextDecoder().decode(bytes.bytes).matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map(
696
+ (m) => m[1].toLowerCase()
697
+ )
698
+ );
699
+ let next = pkg;
700
+ for (const name of [...pkg.parts.keys(), ...pkg.partBytes.keys()]) {
701
+ const type = pkg.contentTypes.overrides.get(name.toLowerCase());
702
+ if (type && !declared.has(name.toLowerCase()))
703
+ next = store.withContentTypeOverride(next, name, type, { forceOverride: true });
704
+ }
705
+ return next;
690
706
  }
691
707
  function materializeBytes(doc) {
692
708
  return store.writeOoxmlPackage(materialize(doc));