Skip to content

Document edit mode - #1455

Open
dnass wants to merge 22 commits into
modifications-apifrom
edit-mode
Open

dnass wants to merge 22 commits into
modifications-apifrom
edit-mode

Conversation

@dnass

@dnass dnass commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This introduces two new modes to the document viewer: edit is for modifying individual pages in the document layout, and bulk is for modifying multiple pages at a time in grid layout. Both modes push edits onto the same history stack, so users can switch between modes seamlessly while editing.

Both modes can be reached via the Edit action in the reading toolbar. From the Pages view, this opens bulk mode. From any other view, it opens edit mode.
image

Once editing, users can switch between edit and bulk mode with the File and Pages toggles.
image

Both modes display a toolbar with discard, undo, and save actions.
image

Edit mode

Edit mode displays the edit toolbar in place of the page actions menu. It supports moving a page up or down one space, rotating, duplicating, and deleting.

image

Bulk mode

Bulk mode displays the edit toolbar in the footer, along with a select all control. It supports rotating, duplicating, and deleting one or more pages.

image

Notes

Octicons doesn't include rotate icons, so I added @lucide/svelte as a dependency. I used Lucide for all of the edit actions for visual consistency.

Below 56rem, redact, annotate, and edit controls are condensed into a single Modify menu:

image

Todo

I'll add two more PRs to this stack:

  • The first deals with invalidating and refreshing data after a document is modified
  • The second adds drag-and-drop support to the bulk editor

@dnass
dnass added this pull request to stack #1453 November 10, 2026 15:10
@github-actions

Copy link
Copy Markdown

Preview deployed: https://preview-1455.staging.documentcloud.org

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 54.96% 4518 / 8220
🔵 Statements 53.63% 5335 / 9947
🔵 Functions 49.7% 1770 / 3561
🔵 Branches 51.54% 2306 / 4474
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/api/documents.ts 86.3% 83.09% 94.44% 87.32% 108-118, 183-184, 193, 211-215, 224, 533, 556-558, 743
src/lib/api/types.d.ts 0% 0% 0% 0%
src/lib/components/inputs/Checkbox.svelte 100% 100% 100% 100%
src/lib/components/toolbars/BulkEditToolbar.svelte 100% 100% 100% 100%
src/lib/components/toolbars/EditActionsToolbar.svelte 100% 100% 100% 100%
src/lib/components/toolbars/EditToolbar.svelte 79.78% 64.7% 81.25% 82.89% 136-151, 185, 189, 216, 215, 228
src/lib/components/toolbars/PaginationToolbar.svelte 78.46% 61.53% 72.97% 74% 78-81, 93, 98-89, 111, 59-110, 122, 136
src/lib/components/toolbars/ReadingToolbar.svelte 0% 0% 0% 0% 62-223
src/lib/components/viewer/Grid.svelte 96.49% 65.21% 91.66% 94.44% 75-76
src/lib/components/viewer/PDF.svelte 72.6% 57.89% 72.22% 60.78% 34-43, 60, 63-71, 78, 85-94, 139-143
src/lib/components/viewer/PDFPage.svelte 77.77% 47.36% 79.31% 78.88% 146-134, 170, 209, 210-212, 251, 256-302
src/lib/components/viewer/Page.svelte 92.5% 72.41% 100% 92.1% 131-134, 146
src/lib/components/viewer/Viewer.svelte 0% 0% 0% 0% 40-119
src/lib/components/viewer/Zoom.svelte 95.12% 100% 96% 97.05% 76, 101
src/lib/components/viewer/tests/PageList.svelte 100% 100% 100% 100%
src/lib/state/edit.svelte.ts 100% 96.29% 100% 100%
src/lib/state/viewer.svelte.ts 98.75% 97.14% 100% 98.5% 31-34
src/lib/utils/viewer.ts 100% 98.61% 100% 100%
Generated in workflow #1475 for commit b25a20d by the Vitest Coverage Report Action

@dnass
dnass marked this pull request as ready for review November 11, 2026 16:46
const viewport = page.getViewport({ scale });
const viewport = page.getViewport({
scale,
rotation: normalizeAngle(page.rotate + rotation),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're no longer ignoring rotation when rendering pages here, so all uploads with rotated pages will be drawn correctly, not just ones modified through the API.

@eyeseast

Copy link
Copy Markdown
Collaborator

The menu is getting a little crowded with Edit added: https://preview-1455.staging.documentcloud.org/documents/20013772-pressure-cooking/

Screenshot 2026-11-12 at 3 10 38 PM

Maybe we need the breakpoint to kick in sooner.

@dnass

dnass commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Below the breakpoint, we could put Annotate, Redact, and Edit in their own dropdown. Seems like Edit would be the most appropriate label for the whole menu, though maybe it's confusing if that's the name of a specific mode too.

image

@eyeseast

Copy link
Copy Markdown
Collaborator

I like the dropdown, and I agree calling it Edit is confusing. But I also don't have a better name for it. I'll think on this.

Modify? Write? Do things? Annotate is also different from the other two, in that it adds to the document and is reversible. I think it belongs, but it's not really a modification in the same way as redactions or page edits.

@dnass

dnass commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

"Write" could imply text editing, which isn't supported. Modify probably encompasses everything the best.

@eyeseast

Copy link
Copy Markdown
Collaborator

Or we call the menu "Edit" and the button "Modify" but then maybe we have to change the mode name, too. (Naming things is hard.)

@dnass

dnass commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Yeah, I'm trying to think about which term feels more appropriate for which thing and it's a tossup. Leaning slightly towards edit as the name of the mode, because it's a slightly friendlier/more familiar term and users will spend more time with the mode than the menu heading.

@eyeseast

Copy link
Copy Markdown
Collaborator

Go with your gut and we can always adjust later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants