@ansonlai/docx-redline-js 0.7.0 → 0.7.1

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.
@@ -296,6 +296,15 @@ export function compileOperationBatch(xmlDoc, operations = [], options = {}) {
296
296
  canonicalValidation.error
297
297
  );
298
298
  }
299
+ } else if (operation.operationKind === 'restore' && sourceOperation.modified === undefined) {
300
+ compiled.modified = start.metadata.text;
301
+ const canonicalValidation = validateDocumentOperation(compiled);
302
+ if (!canonicalValidation.valid) {
303
+ throw Object.assign(
304
+ new Error(canonicalValidation.error.message),
305
+ canonicalValidation.error
306
+ );
307
+ }
299
308
  }
300
309
 
301
310
  const targetEndDescriptor = operation.targetEndDescriptor
@@ -75,13 +75,32 @@ export type RedlineDocumentOperation =
75
75
  replacements?: never;
76
76
  });
77
77
 
78
- export interface RestoreDocumentOperation extends DocumentOperationBase {
78
+ interface RestoreDocumentOperationCommon extends DocumentOperationBase {
79
79
  type: 'restore';
80
- modified: string | string[];
81
- targetEnd?: ParagraphTargetDescriptor;
82
- targetEndRef?: number | string | null;
83
80
  }
84
81
 
82
+ export type RestoreDocumentOperation =
83
+ | (RestoreDocumentOperationCommon & {
84
+ modified: string | string[];
85
+ replacements?: never;
86
+ targetEnd?: ParagraphTargetDescriptor;
87
+ targetEndRef?: number | string | null;
88
+ })
89
+ | (RestoreDocumentOperationCommon & {
90
+ modified?: never;
91
+ /** Exact, case-sensitive replacements in one strong rejected-view paragraph. */
92
+ replacements: LocalizedReplacement[];
93
+ targetEnd?: never;
94
+ targetEndRef?: never;
95
+ })
96
+ | (RestoreDocumentOperationCommon & {
97
+ /** Omit modified to restore one strong rejected-view paragraph verbatim. */
98
+ modified?: never;
99
+ replacements?: never;
100
+ targetEnd?: never;
101
+ targetEndRef?: never;
102
+ });
103
+
85
104
  export interface DeleteDocumentOperation extends DocumentOperationBase {
86
105
  type: 'delete';
87
106
  modified?: '';
@@ -155,6 +174,7 @@ export interface ResolvedDocumentTarget {
155
174
  paragraphId: string | null;
156
175
  text: string;
157
176
  fingerprint?: string;
177
+ revisionView?: 'accepted' | 'rejected';
158
178
  inTable?: boolean;
159
179
  targetTextMatch?: {
160
180
  mode: 'exact' | 'space_equivalent' | 'normalized';