From 8ed051c2da6e49afe1016d921d1b6aeee226e5c7 Mon Sep 17 00:00:00 2001 From: Local Dev Date: Sun, 27 Sep 2026 19:24:28 +0200 Subject: [PATCH] feat(pdf-editor): edit the document's own text on the page, and a line means the whole line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three complaints, one cause between the first two. A line of a PDF is rarely one run. pdf.js splits it wherever the file does — a font change, a kerning adjustment, a colour change — so a heading can be three spans and an invoice line ten. Replacing the span under the cursor covered a fragment and left the rest of the line standing, which is exactly what a replacement that looks like a copy laid over the original is. A run is now the whole visual line: the spans that share its baseline and sit close enough to be spacing rather than a second column, with the spaces the geometry implies put back between them. And that line is edited on the page. The dialog that used to hold a copy of the words is gone: the cover goes down first, carrying the line's own words at the page's own size and colour, and the caret opens on it. The cover keeps its words hidden while you type, so the original never shows through the thing covering it. Escape with nothing changed lifts the cover again and leaves the page as it was found — no mark, no undo step. The rotate grip was a square like the resize handles, wearing the open hand that means drag-the-page. It is a disc with a turning arrow now, and a cursor drawn to match, since no standard cursor means turn. The inline style that was defeating the stylesheet is gone with it. Ctrl and the wheel zoom, about the pointer rather than the top-left, so the words you were reading stay where they were. A plain wheel still scrolls. --- bundled-addons/pdf-editor/addon.json | 2 +- bundled-addons/pdf-editor/editor.css | 18 +++ bundled-addons/pdf-editor/editor.html | 22 --- bundled-addons/pdf-editor/editor.js | 173 +++++++++++++---------- bundled-addons/pdf-editor/lib/inline.js | 13 +- bundled-addons/pdf-editor/lib/overlay.js | 50 +++++-- bundled-addons/pdf-editor/lib/tools.js | 65 ++++++++- 7 files changed, 235 insertions(+), 108 deletions(-) diff --git a/bundled-addons/pdf-editor/addon.json b/bundled-addons/pdf-editor/addon.json index 157e1871..3b1d9fb0 100644 --- a/bundled-addons/pdf-editor/addon.json +++ b/bundled-addons/pdf-editor/addon.json @@ -1,7 +1,7 @@ { "id": "pdf-editor", "name": "PDF Editor", - "version": "0.8.1", + "version": "0.9.0", "description": "Open a PDF in a full tab: read it, mark it up with highlight, underline, strike-through, pen, shapes, arrows, text and a drawn signature, then move, resize, restyle or delete anything you placed. Reorder, rotate or drop pages, fill in form fields, redact for real, and save a new copy. Build a PDF from pictures, one page each, or join several PDFs into one. Marks are written into the saved file as real PDF content. The original is never touched.", "author": "Silent Mode", "icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTYgMmg4bDYgNnYxMmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY0YTIgMiAwIDAgMSAyLTJ6IiBmaWxsPSIjZGMyNjI2Ii8+PHBhdGggZD0iTTE0IDJ2Nmg2eiIgZmlsbD0iIzk5MWIxYiIvPjx0ZXh0IHg9IjEyIiB5PSIxNyIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZm9udC1mYW1pbHk9InN5c3RlbS11aSwtYXBwbGUtc3lzdGVtLHNhbnMtc2VyaWYiIGZvbnQtc2l6ZT0iNS41IiBmb250LXdlaWdodD0iODAwIiBmaWxsPSIjZmZmIj5QREY8L3RleHQ+PC9zdmc+", diff --git a/bundled-addons/pdf-editor/editor.css b/bundled-addons/pdf-editor/editor.css index c35120ac..b9185e6f 100644 --- a/bundled-addons/pdf-editor/editor.css +++ b/bundled-addons/pdf-editor/editor.css @@ -296,6 +296,24 @@ body[data-mode="select"] .smOverlay .mark[data-fill="1"] { pointer-events: all; vector-effect: non-scaling-stroke; } .smOverlay .handle { fill: var(--acid); stroke: #101418; stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; pointer-events: all; } +/* The rotate grip. A turning arrow on a disc, and a cursor that says turn + rather than the open hand the browser gives `grab`, which reads as "drag + the page". No standard cursor means turn, so it is drawn here. */ +.smOverlay .handle.rot { fill: none; stroke: none; } +.smOverlay .rotdisc { fill: var(--acid); stroke: #101418; stroke-width: 1; + vector-effect: non-scaling-stroke; } +.smOverlay .rotmark { fill: none; stroke: #101418; stroke-width: 1.4; + stroke-linecap: round; stroke-linejoin: round; + vector-effect: non-scaling-stroke; } +.smOverlay .rotarm { stroke: var(--acid); stroke-width: 1; stroke-dasharray: 2 2; + vector-effect: non-scaling-stroke; } +.smOverlay .handle.rot, +body[data-rotating="1"] { cursor: url("data:image/svg+xml;utf8,\ +%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E\ +%3Cg fill='none' stroke='%23101418' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E\ +%3Cpath d='M19 13a6 6 0 1 1-1.8-4.2'/%3E%3Cpath d='M17.4 4.2v4.6h-4.6'/%3E%3C/g%3E\ +%3Cg fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E\ +%3Cpath d='M19 13a6 6 0 1 1-1.8-4.2'/%3E%3Cpath d='M17.4 4.2v4.6h-4.6'/%3E%3C/g%3E%3C/svg%3E") 13 13, grab; } /* pdf.js renders form widgets with a coloured backdrop; keep it, it is the only cue that a field is fillable. */ diff --git a/bundled-addons/pdf-editor/editor.html b/bundled-addons/pdf-editor/editor.html index 72ef04b0..d56555af 100644 --- a/bundled-addons/pdf-editor/editor.html +++ b/bundled-addons/pdf-editor/editor.html @@ -259,28 +259,6 @@ - -