@createiq/htmldiff 1.1.0-beta.0 → 1.2.0-beta.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.
- package/README.md +40 -0
- package/dist/HtmlDiff.cjs +1259 -498
- package/dist/HtmlDiff.cjs.map +1 -1
- package/dist/HtmlDiff.d.cts +141 -7
- package/dist/HtmlDiff.d.mts +140 -7
- package/dist/HtmlDiff.mjs +1259 -498
- package/dist/HtmlDiff.mjs.map +1 -1
- package/package.json +7 -7
- package/src/Alignment.ts +349 -0
- package/src/HtmlDiff.ts +323 -33
- package/src/HtmlScanner.ts +200 -0
- package/src/TableDiff.ts +99 -550
- package/src/ThreeWayDiff.ts +223 -0
- package/src/ThreeWayTable.ts +701 -0
- package/src/Utils.ts +34 -2
- package/test/HtmlDiff.analyze.spec.ts +152 -0
- package/test/HtmlDiff.tables.matrix.spec.ts +8 -3
- package/test/HtmlDiff.tables.spec.ts +368 -19
- package/test/HtmlDiff.threeWay.spec.ts +175 -0
- package/test/HtmlDiff.threeWay.tables.spec.ts +407 -0
- package/test/TableDiff.bench.ts +39 -0
- package/test/Utils.spec.ts +48 -0
package/README.md
CHANGED
|
@@ -127,6 +127,46 @@ This property defines relative size of the match to be considered as orphan, fro
|
|
|
127
127
|
|
|
128
128
|
Returns the diff from an HtmlDiff instance.
|
|
129
129
|
|
|
130
|
+
### HtmlDiff.executeThreeWay(v1, v2, v3, options?)
|
|
131
|
+
|
|
132
|
+
Three-way HTML diff for back-and-forth negotiation scenarios. Given:
|
|
133
|
+
|
|
134
|
+
- `v1` — the version you last sent
|
|
135
|
+
- `v2` — the version the counterparty sent back
|
|
136
|
+
- `v3` — your current draft
|
|
137
|
+
|
|
138
|
+
`executeThreeWay` produces a single attributed HTML output where the counterparty's changes (V1→V2) and your changes
|
|
139
|
+
(V2→V3) are distinguished by `data-author` and class:
|
|
140
|
+
|
|
141
|
+
- Counterparty insertions / deletions: `<ins class='diffins cp' data-author='cp'>` / `<del class='diffdel cp' ...>`
|
|
142
|
+
- Your insertions / deletions: `<ins class='diffins me' data-author='me'>` / `<del class='diffdel me' ...>`
|
|
143
|
+
- Your rejections of counterparty insertions (you deleted text they added): `<del class='diffdel me rejects-cp' data-author='me' data-rejects='cp'>`
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import HtmlDiff from '@createiq/htmldiff'
|
|
147
|
+
|
|
148
|
+
const v1 = '<p>The fee is five percent.</p>'
|
|
149
|
+
const v2 = '<p>The interest fee is five and a half percent.</p>'
|
|
150
|
+
const v3 = '<p>The interest fee is five percent.</p>'
|
|
151
|
+
|
|
152
|
+
const merged = HtmlDiff.executeThreeWay(v1, v2, v3)
|
|
153
|
+
// Counterparty added "interest" — kept by you.
|
|
154
|
+
// Counterparty changed "five" → "five and a half" — you rejected.
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Tables (including multi-table documents) and row/column structural changes are supported with the same author
|
|
158
|
+
attribution at row, cell, and content granularity.
|
|
159
|
+
|
|
160
|
+
#### Options
|
|
161
|
+
|
|
162
|
+
`executeThreeWay` accepts the same per-instance options as `HtmlDiff` (`repeatingWordsAccuracy`,
|
|
163
|
+
`ignoreWhitespaceDifferences`, `orphanMatchThreshold`, `blockExpressions`). They flow into both internal pair-wise
|
|
164
|
+
analyses identically.
|
|
165
|
+
|
|
166
|
+
`useProjections` controls structural-tag normalisation. When undefined (default), the decision is the conjunction of
|
|
167
|
+
both pair-wise heuristics — projection only activates when both V1↔V2 and V2↔V3 would benefit from it. Pass an
|
|
168
|
+
explicit boolean to override.
|
|
169
|
+
|
|
130
170
|
## Contributing
|
|
131
171
|
|
|
132
172
|
The library uses [Biome](https://biomejs.dev/) for linting and formatting, and [Vitest](https://vitest.dev/) for unit
|