@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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as Y3 from 'yjs';
2
- import { readOoxmlPart, validateExternalTarget, relsPartNameFor } from '@docx-editor.dev/core/store';
2
+ import { readOoxmlPart, validateExternalTarget, relsPartNameFor, contentTypesPartBytes, withContentTypeOverride } from '@docx-editor.dev/core/store';
3
3
  import { createCollaborationStatusTracker, safeParticipantColor } from '@docx-editor.dev/core/collaboration';
4
4
  import { historyGroupOfJournal } from '@docx-editor.dev/core/collaboration/replication';
5
5
 
@@ -583,14 +583,30 @@ function materialize(doc, cache, changed = null) {
583
583
  defaults: new Map(doc.getMap("ctDefaults")),
584
584
  overrides: new Map(doc.getMap("ctOverrides"))
585
585
  };
586
- return {
586
+ return withMirroredOverrides({
587
587
  parts,
588
588
  partBytes,
589
589
  relationships,
590
590
  externalTargets,
591
591
  contentTypes,
592
592
  mainDocumentPart: main
593
- };
593
+ });
594
+ }
595
+ function withMirroredOverrides(pkg) {
596
+ const bytes = contentTypesPartBytes(pkg);
597
+ if (!bytes) return pkg;
598
+ const declared = new Set(
599
+ [...new TextDecoder().decode(bytes.bytes).matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map(
600
+ (m) => m[1].toLowerCase()
601
+ )
602
+ );
603
+ let next = pkg;
604
+ 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()))
607
+ next = withContentTypeOverride(next, name, type, { forceOverride: true });
608
+ }
609
+ return next;
594
610
  }
595
611
  var RegistryError = class extends Error {
596
612
  constructor(message) {