docxmlater 12.0.1 → 12.1.0

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.
@@ -35,7 +35,7 @@ import { UNITS } from '../utils/units.js';
35
35
  function getLogger() {
36
36
  return createScopedLogger(getGlobalLogger(), 'Document');
37
37
  }
38
- import { acceptAllRevisions, cleanupRevisionMetadata } from '../processors/acceptRevisions.js';
38
+ import { acceptAllRevisions, rejectAllRevisions, cleanupRevisionMetadata, } from '../processors/acceptRevisions.js';
39
39
  import { acceptRevisionsInMemory } from '../processors/InMemoryRevisionAcceptor.js';
40
40
  import { stripTrackedChanges } from '../processors/stripTrackedChanges.js';
41
41
  import { diffText, diffHasUnchangedParts } from '../utils/textDiff.js';
@@ -360,12 +360,20 @@ export class Document {
360
360
  static async initializeFromZip(zipHandler, options) {
361
361
  const logger = getLogger();
362
362
  const useInMemoryAccept = options?.acceptRevisions === true;
363
+ if (useInMemoryAccept && options?.revisionHandling === 'reject') {
364
+ throw new Error("Conflicting load options: 'acceptRevisions: true' (in-memory accept) cannot be combined " +
365
+ 'with \'revisionHandling: "reject"\'. Use \'revisionHandling: "reject"\' on its own to ' +
366
+ 'revert the document to its original pre-edit state.');
367
+ }
363
368
  const revisionHandling = useInMemoryAccept
364
369
  ? 'preserve'
365
370
  : (options?.revisionHandling ?? 'accept');
366
371
  if (revisionHandling === 'accept') {
367
372
  await acceptAllRevisions(zipHandler);
368
373
  }
374
+ else if (revisionHandling === 'reject') {
375
+ await rejectAllRevisions(zipHandler);
376
+ }
369
377
  else if (revisionHandling === 'strip') {
370
378
  await stripTrackedChanges(zipHandler);
371
379
  }