Files
ReaderJS/package.json
T
adminandClaude Opus 4.8 defc9e9373 feat: compare two versions with jsdiff — pinnable, blame-aware tooltips
Compare two versions of a text document (txt, md, code, csv, xlsx, docx, rtf,
odf, doc) using jsdiff. Three switchable view modes — side-by-side (default),
unified, inline — all rendered from one diff. Each changed line has a hover
tooltip that can be pinned open; tooltips show blame (author/date/commit/
message) the host supplies, keyed by the new-side line number.

- src/diff-view.js (new, lazy): Diff.diffLines -> aligned row model (del+add
  paired as 'mod'), intra-line word diff, three renderers from one rows[],
  shared hover tooltip + pinnable popovers. DOM-built (no innerHTML).
- main.js: compare(srcA,nameA,srcB,nameB,{blame,mode}); _extractText renders
  each version with a FRESH renderer into a detached node (never the live
  viewer) and extracts text per format (block-aware walk for rich HTML,
  tab/newline for tables); DIFFABLE gate; teardown on normal load.
- Embed: readerjs.js inst.compare(a,b,opts) + a 'compare' mount opt; reader.js
  readerjs:compare message. Blame is plain data (postMessage-safe).
- Demo: a Compare control (pick two files) in index.html, gated to the full app.
- i18n: compare.*/blame.* in all 9 languages; CSS for the diff grid, ins/del,
  tooltip/pin (reusing the .image-info look) + badge-compare.
- diff (jsdiff, BSD-3) added; lazy-split into its own chunk.
- Docs: CREDITS (jsdiff), EMBEDDING (compare + blame API), README feature.

Verified (demo + built embed): side-by-side aligns; unified/inline toggle
instantly; word-level ins/del; hover tooltip shows blame; pin -> persistent
popover; setLang re-translates; pdf/etc -> unsupported without breaking the
view; normal load after compare tears down cleanly. Blame round-trips through
the embed's postMessage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 20:37:49 +02:00

37 lines
1.2 KiB
JSON

{
"name": "preview-js",
"version": "1.0.0",
"description": "Client-side universal document viewer — PDF, DjVu, ODF, Office, e-books, comics and images — permissive, no server, no upload",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"build:embed:app": "vite build --config vite.config.app.js",
"build:embed:loader": "vite build --config vite.config.embed.js",
"build:embed": "npm run build:embed:app && npm run build:embed:loader",
"preview": "vite preview",
"docs": "jsdoc src -r -d docs"
},
"dependencies": {
"chart.js": "^4.5.1",
"dejaview": "github:Alpaq92/dejaview#5a4ef8a81c5efb8942ae8f11a61172bd91a908ff",
"diff": "^9.0.0",
"exifr": "^7.1.3",
"foliate-js": "github:johnfactotum/foliate-js#78914aef4466eb960965702401634c2cb348e9b1",
"highlight.js": "^11.11.1",
"jszip": "^3.10.1",
"libarchive.js": "^2.0.2",
"mammoth": "^1.8.0",
"marked": "^18.0.5",
"papaparse": "^5.5.4",
"pdfjs-dist": "^4.9.155",
"pptxviewjs": "^1.1.9",
"rtf.js": "^2.2.0",
"utif": "^3.1.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"devDependencies": {
"vite": "^6.0.7"
}
}