Features/shadcn #1
@@ -0,0 +1,11 @@
|
||||
.git
|
||||
.gitignore
|
||||
.idea
|
||||
.vscode
|
||||
.svelte-kit
|
||||
build
|
||||
node_modules
|
||||
npm-debug.log*
|
||||
pnpm-debug.log*
|
||||
.env
|
||||
.env.*
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker login to Gitea Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ vars.REGISTRY_URL }}" \
|
||||
-u "${{ secrets.REGISTRY_USER }}" \
|
||||
--password-stdin
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build \
|
||||
-t "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:latest" \
|
||||
-t "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:${{ gitea.sha }}" \
|
||||
.
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker push "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:latest"
|
||||
docker push "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:${{ gitea.sha }}"
|
||||
|
||||
- name: Deploy
|
||||
run: |
|
||||
curl https://dokploy.robosoft-solutions.de/api/deploy/compose/vETS7jxOixux3wDPobAaL
|
||||
Generated
+140
-28
@@ -1,36 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="CMakeProjectFlavorService">
|
||||
<option name="flavorId" value="CMakePlainProjectFlavor" />
|
||||
</component>
|
||||
<component name="CMakeSettings">
|
||||
<configurations />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="89f9fc3a-63ad-41cb-8d25-f07df352eb98" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/agents.md" beforeDir="false" afterPath="$PROJECT_DIR$/agents.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pnpm-lock.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pnpm-lock.yaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/lib/components/Button.svelte" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/lib/components/Card.svelte" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/lib/components/ProcessedZipArchiveEditor.svelte" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/components/ProcessedZipArchiveEditor.svelte" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/lib/components/ZipDropzone.svelte" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/components/ZipDropzone.svelte" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/lib/nom-theme.css" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/routes/+page.svelte" beforeDir="false" afterPath="$PROJECT_DIR$/src/routes/+page.svelte" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/routes/layout.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/routes/layout.css" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/lib/zip-processing.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/zip-processing.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/vite.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/vite.config.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="EmbeddingIndexingInfo">
|
||||
<option name="cachedIndexableFilesCount" value="169" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="CSS File" />
|
||||
<option value="TypeScript File" />
|
||||
<option value="IconSettings" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="McpProjectServerCommands">
|
||||
<commands />
|
||||
<urls />
|
||||
</component>
|
||||
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
|
||||
<component name="NextEditCompletionFeaturesState">
|
||||
<decayedCancelled>
|
||||
<entry key="MS100" value="1.7534270927402278" />
|
||||
<entry key="MS500" value="3.946749409858449" />
|
||||
<entry key="S2" value="10.803582735333821" />
|
||||
<entry key="S5" value="15.959801828989763" />
|
||||
<entry key="S10" value="18.60984028553002" />
|
||||
<entry key="S30" value="20.774011757305356" />
|
||||
<entry key="S60" value="21.423894438791837" />
|
||||
<entry key="M2" value="22.530930014590602" />
|
||||
<entry key="M5" value="32.256903842215344" />
|
||||
<entry key="M10" value="49.10264974172939" />
|
||||
<entry key="M15" value="59.99418378616175" />
|
||||
<entry key="M30" value="75.77225940331346" />
|
||||
<entry key="H1" value="86.24194464495858" />
|
||||
<entry key="H2" value="92.30215756709606" />
|
||||
<entry key="H4" value="95.56680916983069" />
|
||||
<entry key="D1" value="98.41568550867962" />
|
||||
<entry key="W1" value="98.91622423777348" />
|
||||
</decayedCancelled>
|
||||
<decayedSelected>
|
||||
<entry key="MS100" value="0.0" />
|
||||
<entry key="MS500" value="0.0" />
|
||||
<entry key="S2" value="0.0" />
|
||||
<entry key="S5" value="0.0" />
|
||||
<entry key="S10" value="0.0" />
|
||||
<entry key="S30" value="0.0" />
|
||||
<entry key="S60" value="0.0" />
|
||||
<entry key="M2" value="0.0" />
|
||||
<entry key="M5" value="0.0" />
|
||||
<entry key="M10" value="0.0" />
|
||||
<entry key="M15" value="0.0" />
|
||||
<entry key="M30" value="0.0" />
|
||||
<entry key="H1" value="0.0" />
|
||||
<entry key="H2" value="0.0" />
|
||||
<entry key="H4" value="0.0" />
|
||||
<entry key="D1" value="0.0" />
|
||||
<entry key="W1" value="0.0" />
|
||||
</decayedSelected>
|
||||
<decayedShown>
|
||||
<entry key="MS100" value="1.572917306599136" />
|
||||
<entry key="MS500" value="3.853231737204187" />
|
||||
<entry key="S2" value="10.722306786321894" />
|
||||
<entry key="S5" value="15.90871853935142" />
|
||||
<entry key="S10" value="18.579462450925384" />
|
||||
<entry key="S30" value="20.762563658810205" />
|
||||
<entry key="S60" value="21.41797857399968" />
|
||||
<entry key="M2" value="22.5278009383226" />
|
||||
<entry key="M5" value="32.254976079390616" />
|
||||
<entry key="M10" value="49.101123585535056" />
|
||||
<entry key="M15" value="59.99293373937006" />
|
||||
<entry key="M30" value="75.77147145663449" />
|
||||
<entry key="H1" value="86.24149819888382" />
|
||||
<entry key="H2" value="92.30191941653102" />
|
||||
<entry key="H4" value="95.56668611084393" />
|
||||
<entry key="D1" value="98.41566442286562" />
|
||||
<entry key="W1" value="98.91622121110338" />
|
||||
</decayedShown>
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 0,
|
||||
"fromUser": false
|
||||
@@ -43,26 +115,31 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||
"cidr.known.project.marker": "true",
|
||||
"codeWithMe.voiceChat.enabledByDefault": "false",
|
||||
"git-widget-placeholder": "features/shadcn",
|
||||
"last_opened_file_path": "/home/rehlert/repos/juri-merger",
|
||||
"list.type.of.created.stylesheet": "CSS",
|
||||
"nodejs_package_manager_path": "pnpm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"ts.external.directory.path": "/home/rehlert/repos/juri-merger/node_modules/typescript/lib",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||
"cidr.known.project.marker": "true",
|
||||
"codeWithMe.voiceChat.enabledByDefault": "false",
|
||||
"git-widget-placeholder": "features/shadcn",
|
||||
"last_opened_file_path": "/home/rehlert/repos/pulley",
|
||||
"list.type.of.created.stylesheet": "CSS",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "pnpm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"ts.external.directory.path": "/home/rehlert/repos/juri-merger/node_modules/typescript/lib",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="89f9fc3a-63ad-41cb-8d25-f07df352eb98" name="Changes" comment="" />
|
||||
@@ -76,7 +153,13 @@
|
||||
<workItem from="1781378743498" duration="306000" />
|
||||
<workItem from="1781534483559" duration="2103000" />
|
||||
<workItem from="1781597500009" duration="2733000" />
|
||||
<workItem from="1781621908149" duration="4121000" />
|
||||
<workItem from="1781621908149" duration="4463000" />
|
||||
<workItem from="1781626468843" duration="1890000" />
|
||||
<workItem from="1781673504756" duration="1513000" />
|
||||
<workItem from="1781675346348" duration="3860000" />
|
||||
<workItem from="1781797582572" duration="437000" />
|
||||
<workItem from="1781844676215" duration="5049000" />
|
||||
<workItem from="1782804485415" duration="4386000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="adapts styling of rvg.legal">
|
||||
<option name="closed" value="true" />
|
||||
@@ -174,7 +257,23 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1781350375505</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="13" />
|
||||
<task id="LOCAL-00013" summary="adds shadcn, removes skeleton, implements button after styleguide">
|
||||
<option name="closed" value="true" />
|
||||
<created>1781626078662</created>
|
||||
<option name="number" value="00013" />
|
||||
<option name="presentableId" value="LOCAL-00013" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1781626078662</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00014" summary="adds icons">
|
||||
<option name="closed" value="true" />
|
||||
<created>1781845554523</created>
|
||||
<option name="number" value="00014" />
|
||||
<option name="presentableId" value="LOCAL-00014" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1781845554523</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="15" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -182,6 +281,17 @@
|
||||
</component>
|
||||
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
|
||||
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||
<MESSAGE value="adapts styling of rvg.legal" />
|
||||
@@ -196,7 +306,9 @@
|
||||
<MESSAGE value="range settings" />
|
||||
<MESSAGE value="name generation improvement" />
|
||||
<MESSAGE value="The git changes introduce functionality to merge attachments from a processed ZIP archive into a single PDF file. Here is a summary of the changes: ### New Features - PDF Merging: Added the ability to merge multiple attachments (PDFs and images) from a processed ZIP archive into a single PDF document. - Image Conversion: Implemented automatic conversion of non-PNG images (like JPGs) to PNG format before embedding them into the merged PDF. ### File Changes - Dependencies: Added pdf-lib to the project's dependencies. - src/lib/zip-processing.ts: - Added mergeProcessedZipArchive to handle the core logic of creating a merged PDF. - Implemented helpers to embed PDF pages and convert/embed images. - Added toArrayBuffer and convertImageBytesToPng utilities for handling binary data and canvas-based image processing. - src/lib/components/ProcessedZipArchiveEditor.svelte: - Added a "PDF herunterladen" (Download PDF) button. - Added UI states to handle the merging process (loading state, error messages). - Integrated the mergeProcessedZipArchive function with the UI. - src/lib/components/AttachmentPreview.svelte: - Added a fix to ensure attachment.data is treated as a Uint8Array when loading PDF documents." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="The git changes introduce functionality to merge attachments from a processed ZIP archive into a single PDF file. Here is a summary of the changes: ### New Features - PDF Merging: Added the ability to merge multiple attachments (PDFs and images) from a processed ZIP archive into a single PDF document. - Image Conversion: Implemented automatic conversion of non-PNG images (like JPGs) to PNG format before embedding them into the merged PDF. ### File Changes - Dependencies: Added pdf-lib to the project's dependencies. - src/lib/zip-processing.ts: - Added mergeProcessedZipArchive to handle the core logic of creating a merged PDF. - Implemented helpers to embed PDF pages and convert/embed images. - Added toArrayBuffer and convertImageBytesToPng utilities for handling binary data and canvas-based image processing. - src/lib/components/ProcessedZipArchiveEditor.svelte: - Added a "PDF herunterladen" (Download PDF) button. - Added UI states to handle the merging process (loading state, error messages). - Integrated the mergeProcessedZipArchive function with the UI. - src/lib/components/AttachmentPreview.svelte: - Added a fix to ensure attachment.data is treated as a Uint8Array when loading PDF documents." />
|
||||
<MESSAGE value="adds shadcn, removes skeleton, implements button after styleguide" />
|
||||
<MESSAGE value="adds icons" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="adds icons" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM node:24-alpine AS base
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable && corepack prepare pnpm@11.15.1 --activate
|
||||
|
||||
FROM base AS dependencies
|
||||
WORKDIR /app
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
FROM dependencies AS build
|
||||
COPY . .
|
||||
RUN pnpm build && pnpm prune --prod --ignore-scripts
|
||||
|
||||
FROM node:24-alpine AS runtime
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV="production"
|
||||
ENV HOST="0.0.0.0"
|
||||
ENV PORT="3000"
|
||||
|
||||
COPY --from=build --chown=node:node /app/package.json ./
|
||||
COPY --from=build --chown=node:node /app/node_modules ./node_modules
|
||||
COPY --from=build --chown=node:node /app/build ./build
|
||||
|
||||
USER node
|
||||
EXPOSE 3000
|
||||
CMD ["node", "build/index.js"]
|
||||
@@ -1,26 +1,47 @@
|
||||
# Scout findings
|
||||
# Project notes for agents
|
||||
|
||||
## Project snapshot
|
||||
- **Tech stack:** SvelteKit + TypeScript + Vite + Tailwind v4.
|
||||
- **App name/branding:** `beA-Edit`.
|
||||
- **Repo name:** `juri-merger`
|
||||
- **App name/branding:** `beA-Edit`, published by Nominandum GmbH.
|
||||
- **Tech stack:** SvelteKit + Svelte 5 (runes) + TypeScript + Vite + Tailwind v4 (CSS-first).
|
||||
- **UI system:** shadcn-svelte (style `nova`, lucide icons) layered on a custom "nom" theme via CSS variables in `src/routes/layout.css`.
|
||||
- **Core purpose:** upload one or more ZIP files, extract relevant PDFs/images, preview them, optionally reorder attachments, and download a merged PDF.
|
||||
- **Active branch:** `features/shadcn` (shadcn-svelte integration in progress).
|
||||
|
||||
## Main user flow
|
||||
1. User adds ZIP files via drag/drop or file picker (`ZipDropzone`).
|
||||
2. `+page.svelte` starts async extraction for each file.
|
||||
2. `+page.svelte` starts async extraction for each file (tracked via `archiveGeneration` so stale in-flight extractions are discarded on bulk delete).
|
||||
3. Each ZIP is processed into one or more `ProcessedZipArchive` entries.
|
||||
4. `ProcessedZipArchiveEditor` shows thumbnails, allows reordering, and can download the merged PDF.
|
||||
5. `AttachmentPreview` renders image previews directly and PDF previews via `pdfjs-dist`.
|
||||
6. A fixed bottom-right settings drawer (`<details>`) exposes **export all** and **delete all** archive actions plus the thumbnail-width slider.
|
||||
|
||||
## Important source files
|
||||
- `src/routes/+page.svelte` — top-level page state, file selection, localStorage-backed thumbnail width setting, async ZIP processing.
|
||||
- `src/routes/+page.svelte` — top-level page state, file selection, localStorage-backed thumbnail width, async ZIP processing, bulk export/delete, settings drawer.
|
||||
- `src/routes/+layout.svelte` — app shell: header with logo and footer with Nominandum GmbH legal/imprint block.
|
||||
- `src/routes/layout.css` — Tailwind v4 entrypoint; imports `tw-animate-css`, `shadcn-svelte/tailwind.css`, Geist + Nunito fonts; defines the semantic token layer (`--background`, `--primary`, `--secondary`, `--accent`, `--destructive`, `--radius`, etc.) mapping shadcn tokens onto the nom palette, including a `.dark` override.
|
||||
- `src/lib/zip-processing.ts` — archive extraction, recursive nested ZIP handling, metadata ordering, PDF merge/export, image conversion.
|
||||
- `src/lib/services/zip-inflating.service.ts` — thin wrapper around `fflate` unzip.
|
||||
- `src/lib/services/xml-reading.service.ts` — parses XJustiz XML metadata (`sender`, `receiver`, `documentNames`).
|
||||
- `src/lib/components/ZipDropzone.svelte` — file picker + drag/drop ZIP intake.
|
||||
- `src/lib/components/ProcessedZipArchiveEditor.svelte` — archive editor, drag reordering, download button.
|
||||
- `src/lib/components/ProcessedZipArchiveEditor.svelte` — archive editor (name input, drag reordering, per-archive PDF download, selection mode + sub-document management, export-mode switch).
|
||||
- `src/lib/components/SubDocumentEditor.svelte` — sub-document block editor (editable name, count, dissolve action, draggable header for block reorder, internal horizontal reorderable attachment list).
|
||||
- `src/lib/components/AttachmentPreview.svelte` — preview generation for images/PDFs.
|
||||
- `src/lib/components/Card.svelte` — generic page container.
|
||||
- `src/lib/components/ui/button.svelte` — shadcn-backed button atom (see "Button system" below).
|
||||
- `src/lib/components/ui/card/` — shadcn card composition (`Root/Content/Header/Title/Description/Footer/Action`, re-exported as `Card.*`).
|
||||
- `src/lib/actions/ripple.ts` — Svelte action that renders a click ripple animation on an element.
|
||||
- `src/lib/components/icons/` — hand-rolled SVG icon components (`IconSettings`, `IconFile`, `IconMenu`, `IconNeedle`, `IconOffice`, `IconPerson`, `IconTag`, `IconTrash`, `IconChain`, `IconUnknown`). If an icon is missing, report it, and we see if we can create
|
||||
- `src/lib/utils.ts` — shared `cn()` helper (clsx + tailwind-merge) and `WithElementRef`/`WithoutChild` typing helpers used by shadcn components.
|
||||
|
||||
## Button system
|
||||
`src/lib/components/ui/button.svelte` is a shadcn-svelte–style primitive adapted to the nom theme:
|
||||
- Built with `tailwind-variants` (`buttonVariants`) and the shared `cn()` helper.
|
||||
- Variants: `primary`, `secondary` (gradient `secondary → --secondary-end`), `bordered`, `tertiary`, `success`.
|
||||
- Sizes: `standard` (h-8, rounded-16px), `large` (h-12, rounded-24px).
|
||||
- Renders either a `<button>` or an `<a>` (when `href` is set); both apply the `use:ripple` action.
|
||||
- Accepts an optional `icon` prop (a Svelte component) rendered after `children`.
|
||||
- `ButtonProps` merges `HTMLButtonAttributes` + `HTMLAnchorAttributes` with `WithElementRef` and `variant`/`size`/`icon`.
|
||||
- Used across the editor, settings drawer, and the throwaway test buttons on the home `<section>` (still present on the branch).
|
||||
|
||||
## ZIP/PDF processing details
|
||||
- ZIP entries are filtered to ignore macOS metadata (`__MACOSX`, `.DS_Store`, `._*`).
|
||||
@@ -29,22 +50,44 @@
|
||||
- `xjustiz_nachricht.xml` is used to derive archive naming and ordering.
|
||||
- Ordering prefers document names from metadata before falling back to original attachment order.
|
||||
- PDF merging uses `pdf-lib`; images are embedded as PNG/JPG, with browser-side canvas conversion for other image types.
|
||||
- **Sub-documents:** a `ProcessedZipArchive` now has `attachments` ("loose") plus an ordered `subDocuments: SubDocument[]` list. Each `SubDocument` is a named, ordered subset of `ZipAttachment`s that live alongside the loose ones. Sub-documents are created on demand by the user (selection mode in the editor) — when none exist, the archive behaves exactly as before.
|
||||
- The merge loop is shared via `mergeAttachments(attachments)`; `mergeProcessedZipArchive` flattens the archive via `flattenArchiveForMerge` (sub-documents first, then loose) so backwards compatibility holds.
|
||||
- Pure helpers in `zip-processing.ts`: `createSubDocument`, `moveSubDocument`, `moveAttachmentInPlace`, `moveAttachmentIntoSubDocument`, `removeAttachmentFromSubDocument`, `dissolveSubDocument`, `flattenArchiveForMerge`, `buildArchiveExport(archive, 'single' | 'separate')`. Cross-list moves preserve the total attachment count invariant.
|
||||
- **Export modes:** `single` flips the whole archive into one PDF (sub-docs flattened first); `separate` produces one PDF per non-empty sub-document (`{archiveName} - {subName}.pdf`) plus one for any residual loose attachments.
|
||||
|
||||
## UI/state details
|
||||
- Thumbnail width is stored in `localStorage` under `thumbnailWidth` and clamped to `100..400`.
|
||||
- Processing progress is shown as a count of pending ZIP files.
|
||||
- Thumbnail width is stored in `localStorage` under `thumbnailWidth` (key constant `THUMBNAIL_WIDTH_STORAGE_KEY`) and clamped to `100..400`; hydration is gated by a `thumbnailWidthHydrated` flag so the initial render does not fight `onMount`.
|
||||
- Processing progress is shown as a count of pending ZIP files (`pendingZipCount`).
|
||||
- The editor supports manual attachment reordering via drag-and-drop.
|
||||
- The settings drawer contains: "Alle ZIP-Archive als PDF exportieren", "Alle ZIP-Archive löschen", and the thumbnail-width range input.
|
||||
- Bulk delete bumps `archiveGeneration` so otherwise-orphaned async extractions no-op instead of re-populating state.
|
||||
- **Sub-document editing (`ProcessedZipArchiveEditor.svelte`):**
|
||||
- An "Auswählen" / "Fertig" toggle in the header puts the editor into selection mode. Only then are checkboxes rendered on each loose thumbnail (wrapped in a `<label>` for keyboard operability — Tab + Space); in normal mode the editor looks identical to today. `Esc` exits selection mode and clears the selection. Drag-to-reorder is suspended while in selection mode.
|
||||
- An inline action bar with "Teildokument erstellen" appears whenever `selectionMode && selectedPaths.size > 0`. Creating a sub-document removes the selected attachments from the loose list, appends a new `SubDocument` block (named "Teildokument N"), clears the selection, and keeps selection mode on.
|
||||
- Sub-documents render below the loose list as a vertical stack of `SubDocumentEditor` blocks. Each block has an editable name, a count, an "Auflösen" action (returns its attachments to the end of the loose list), a draggable header (`::`) to reorder the block, and its own horizontal reorderable attachment list.
|
||||
- Drag-and-drop is generalised: HTML5 DnD payloads use MIME type `application/x-juri-merger-attachment` (carrying a `AttachmentLocation` of `{ kind: 'loose', index }` or `{ kind: 'subDocument', id, index }`) for attachment moves, and `application/x-juri-merger-block` for reordering whole sub-document blocks. Supported moves: loose↔loose, loose→sub, sub→loose, sub attachment↔sub attachment (same or different sub), and sub-document block↔sub-document block.
|
||||
- Export control: with no sub-documents, the existing single "PDF herunterladen" button behaves unchanged. With sub-documents present, a segmented control ("Eine PDF" / "Getrennt") lets the user choose the export mode; "Eine PDF" downloads one flattened PDF, "Getrennt" downloads one PDF per sub-document sequentially.
|
||||
- **`SubDocumentEditor.svelte`** is the new sub-document block component. It emits `onSubDocumentChange`, `onRemove`, `onAttachmentMove`, and block-level drag callbacks up to the parent; the parent stays the source of truth via `onArchiveChange`.
|
||||
|
||||
## Dependencies worth noting
|
||||
- `fflate` for ZIP extraction
|
||||
- `pdf-lib` for PDF generation/merging
|
||||
- `pdfjs-dist` for PDF thumbnail previews
|
||||
- `@skeletonlabs/skeleton` / `@skeletonlabs/skeleton-svelte` for styling components
|
||||
- `bits-ui`, `shadcn-svelte` (CLI/runtime), `clsx`, `tailwind-merge`, `class-variance-authority`, `tailwind-variants`, `tw-animate-css` for the shadcn-svelte UI layer
|
||||
- `@lucide/svelte` and a set of local SVG icon components for iconography
|
||||
- `@fontsource-variable/geist` font; custom `Nunito` variable font bundled under `src/lib/assets/`
|
||||
- `@tailwindcss/vite`, `@tailwindcss/forms`, `@tailwindcss/typography` for styling
|
||||
|
||||
## shadcn-svelte configuration
|
||||
- `components.json`: style `nova`, `iconLibrary` `lucide`, `baseColor` `neutral`, Tailwind CSS path `src/routes/layout.css`.
|
||||
- Aliases: `components → $lib/components`, `ui → $lib/components/ui`, `utils → $lib/utils`, `hooks → $lib/hooks`, `lib → $lib`.
|
||||
- `src/lib/hooks/` exists but is currently empty.
|
||||
- Generated components live under `src/lib/components/ui/`; `button.svelte` is the canonical adapted example (custom variants + ripple + icon prop).
|
||||
|
||||
## Current working tree observations
|
||||
- `agents.md` is newly created.
|
||||
- Existing local changes are present in:
|
||||
- `src/lib/zip-processing.ts`
|
||||
- `src/routes/+page.svelte`
|
||||
- New/untracked directory present:
|
||||
- `src/lib/services/`
|
||||
- Branch is `features/shadcn`.
|
||||
- `agents.md` is being updated to match the post-shadcn-integration state.
|
||||
- `plan/shadcn-svelte-plan.md` tracks the in-progress migration (only `button` + `card` generated so far; broader UI replacement is still optional/incremental).
|
||||
- Untracked: `plan/`, and several icons under `src/lib/components/icons/` (`IconChain`, `IconFile`, `IconMenu`, `IconNeedle`, `IconOffice`, `IconPerson`, `IconTag`, `IconTrash`, `IconUnknown`).
|
||||
- Modified (uncommitted): `agents.md`, `src/lib/components/icons/IconSettings.svelte`, `src/lib/components/ui/button.svelte`, `src/routes/+page.svelte`, `.idea/workspace.xml`.
|
||||
- `src/lib/services/` is now committed (was previously untracked).
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
"devDependencies": {
|
||||
"@fontsource-variable/geist": "^5.2.9",
|
||||
"@lucide/svelte": "^1.18.0",
|
||||
"@sveltejs/adapter-auto": "^7.0.1",
|
||||
"@sveltejs/adapter-node": "^5.5.7",
|
||||
"@sveltejs/kit": "^2.63.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
||||
"@tailwindcss/forms": "^0.5.11",
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
# Plan: Sub-documents within a ZIP archive
|
||||
|
||||
## Goal
|
||||
|
||||
For a processed ZIP archive the user can already **reorder** attachments and **export** them as a single merged PDF. This feature adds the ability to:
|
||||
|
||||
1. **Select** some of the archive's attachments and **group them into a "sub-document"** (a named, ordered subset of attachments).
|
||||
2. **Reorder** attachments *within* a sub-document — and **reorder** the sub-documents themselves — exactly like the parent archive today.
|
||||
3. **Choose an export mode** for the sub-documents:
|
||||
- **Separate files** → each sub-document becomes its own downloaded PDF.
|
||||
- **One PDF** → all sub-documents are merged into a single downloaded PDF (the existing top-level "PDF herunterladen" behaviour, now scoped to sub-documents when they exist).
|
||||
|
||||
The existing flow (no sub-documents created → one merged PDF for the whole archive) stays intact as a fallback.
|
||||
|
||||
---
|
||||
|
||||
## Open decisions (please confirm before implementation)
|
||||
|
||||
These affect the data model and UI. Default proposals are marked ✅.
|
||||
|
||||
### D1 — Partition model
|
||||
- ✅ **A. Optional grouping.** Attachments can be "loose" (not part of any sub-document) *or* members of a sub-document. Sub-documents are created on demand by selecting attachments.
|
||||
- B. **Exclusive partition.** Once the user starts creating sub-documents, every attachment must belong to exactly one.
|
||||
- C. **Shared/multi-membership.** An attachment can appear in multiple sub-documents (references, not moves).
|
||||
|
||||
> Recommendation: **A**. It is the least disruptive, matches the current "flat list" mental model, and degrades gracefully when the user does nothing.
|
||||
|
||||
### D2 — Selection lifecycle
|
||||
- ✅ **Selection mode toggle.** A small "Auswählen" button in the archive header switches the editor into selection mode. Only then are checkboxes rendered on each thumbnail; in normal mode the editor looks exactly like today (no permanent checkbox clutter). While in selection mode the user toggles attachments, then clicks "Teildokument erstellen" to consume the selection (which clears the selection but leaves selection mode on, so they can immediately create another sub-document). Exiting selection mode via a "Fertig" button (or Esc) clears any pending selection.
|
||||
- A sub-document is created from the *current* selection. Afterwards each attachment can be moved into / out of / between sub-documents via drag-drop or a context action.
|
||||
- Alternative considered: persistent always-visible checkboxes — rejected as visually noisy for the common case where the user only wants to reorder.
|
||||
|
||||
### D3 — Download scope when sub-documents exist
|
||||
The existing single archive-level "PDF herunterladen" button behaviour needs clarification. Proposed:
|
||||
- ✅ When **no** sub-documents exist → today's behaviour (merge all attachments into one PDF).
|
||||
- When sub-documents **do** exist → show a **download mode toggle** offered to the user at export time:
|
||||
- **Getrennt** (separate): one PDF per sub-document (loose attachments are downloaded individually, matching their kind — PDF passthrough, image as-is or as a tiny PDF — TBD in D4).
|
||||
- **Eine PDF** (one): all sub-documents (and loose attachments, optionally — see D5) merged in sub-document order, with attachment order preserved inside each.
|
||||
- ✅ "Separate" downloads are triggered sequentially (same pattern as today's `exportAllZipArchivesAsPdf`).
|
||||
|
||||
### D4 — Format of "separate" downloads
|
||||
- ✅ Each sub-document is downloaded as a **PDF** (merge its attachments with the existing `mergeProcessedZipArchive` logic, scoped to the sub-document's attachments). Naming: `{archiveName} - {subDocumentName}.pdf`.
|
||||
- B. Each sub-document is downloaded as a **ZIP** containing its original files.
|
||||
- C. Mixed: keep each attachment's original format (PDFs passthrough, images as image files).
|
||||
|
||||
> Recommendation: **A** for consistency with the existing PDF-first export. We can revisit if the actual need is "preserve original files."
|
||||
|
||||
### D5 — Treatment of loose (ungrouped) attachments at export
|
||||
- ✅ When exporting **separate**: loose attachments are downloaded each as their own PDF (or skipped — needs a quick confirm).
|
||||
- ✅ When exporting **one PDF**: loose attachments are appended at the end (in their existing order) — or skipped.
|
||||
- B. Ignore loose attachments entirely during export.
|
||||
|
||||
> Recommendation: **include loose attachments** at the end of both modes, so nothing is silently lost. Confirm with user.
|
||||
|
||||
### D6 — Naming of sub-documents
|
||||
- ✅ A sub-document has a user-editable name (default e.g. `Teildokument 1`, `Teildokument 2`, …) shown next to its attachments, mirroring the archive name input.
|
||||
|
||||
### D7 — Persistence
|
||||
- ✅ Sub-document structure lives only in component state (same as today's reordering) — no localStorage persistence required for v1. (We already do not persist reordering.)
|
||||
|
||||
---
|
||||
|
||||
## Data model (`src/lib/zip-processing.ts`)
|
||||
|
||||
Introduce a `SubDocument` type alongside `ZipAttachment` and extend `ProcessedZipArchive`.
|
||||
|
||||
```ts
|
||||
export type SubDocument = {
|
||||
id: string; // stable id for keyed {#each} and drag state
|
||||
name: string; // user-editable
|
||||
attachments: ZipAttachment[];
|
||||
};
|
||||
|
||||
export type ProcessedZipArchive = {
|
||||
name: string;
|
||||
attachments: ZipAttachment[]; // loose attachments (unchanged shape)
|
||||
subDocuments: SubDocument[]; // NEW — defaults to [] for backward compat
|
||||
};
|
||||
```
|
||||
|
||||
Notes:
|
||||
- Attachments inside `SubDocument` reuse the existing `ZipAttachment` type unchanged.
|
||||
- `extractZipEntries` populates `subDocuments: []`. All existing call sites continue to work.
|
||||
- A sub-document's `id` is generated with `crypto.randomUUID()` (available in browser + modern Node) — never re-derived from index, so reordering stays stable.
|
||||
|
||||
### New pure helpers (unit-test-friendly, no DOM)
|
||||
|
||||
```ts
|
||||
// Create a sub-document from a list of attachments.
|
||||
export const createSubDocument = (
|
||||
name: string,
|
||||
attachments: ZipAttachment[]
|
||||
): SubDocument => ({ id: crypto.randomUUID(), name, attachments });
|
||||
|
||||
// Move an attachment from the loose list (or another sub-document) into a sub-document.
|
||||
export const moveAttachmentIntoSubDocument = (
|
||||
archive: ProcessedZipArchive,
|
||||
attachmentPath: string,
|
||||
source: { kind: 'loose' } | { kind: 'subDocument'; id: string },
|
||||
target: { kind: 'loose'; index: number } | { kind: 'subDocument'; id: string; index: number }
|
||||
): ProcessedZipArchive => { /* immutable update */ };
|
||||
|
||||
// Reorder sub-documents (same shape as the existing moveAttachment helper).
|
||||
export const moveSubDocument = (
|
||||
archive: ProcessedZipArchive,
|
||||
fromIndex: number,
|
||||
toIndex: number
|
||||
): ProcessedZipArchive => { /* ... */ };
|
||||
|
||||
// Flatten the archive into an ordered list of attachments for "one PDF" export.
|
||||
// sub-document order is preserved; loose attachments appended at the end (per D5).
|
||||
export const flattenArchiveForMerge = (
|
||||
archive: ProcessedZipArchive
|
||||
): ZipAttachment[] => {
|
||||
const ordered: ZipAttachment[] = [];
|
||||
for (const sub of archive.subDocuments) ordered.push(...sub.attachments);
|
||||
ordered.push(...archive.attachments);
|
||||
return ordered;
|
||||
};
|
||||
|
||||
// Build one merged-PDF byte array per export unit.
|
||||
// - mode 'single' → returns [ { name, bytes } ] from the whole archive (existing behaviour)
|
||||
// - mode 'separate' → returns one entry per sub-document (+ loose attachments per D5)
|
||||
export type ExportUnit = { name: string; bytes: Uint8Array };
|
||||
export const buildArchiveExport = async (
|
||||
archive: ProcessedZipArchive,
|
||||
mode: 'single' | 'separate'
|
||||
): Promise<ExportUnit[]> => { /* ... */ };
|
||||
```
|
||||
|
||||
`mergeProcessedZipArchive` is refactored to delegate to a new `mergeAttachments(attachments): Promise<Uint8Array>` (a thin rename of the existing inner loop) so both "single" and "separate" share the same merging code.
|
||||
|
||||
---
|
||||
|
||||
## UI
|
||||
|
||||
### `ProcessedZipArchiveEditor.svelte` (main work)
|
||||
|
||||
State additions:
|
||||
- `subDocuments = $state<SubDocument[]>([])` synced from `archive.subDocuments` in the existing `$effect`.
|
||||
- `selectionMode = $state<boolean>(false)` — whether selection checkboxes are currently shown on thumbnails.
|
||||
- `selectedPaths = $state<Set<string>>([])` — currently selected attachment paths (keyed by `attachment.path`, which is unique within an archive after extraction). Only meaningful while `selectionMode` is on.
|
||||
- `downloadMode = $state<'single' | 'separate'>('single')` (only shown when sub-documents exist).
|
||||
- Existing drag handlers generalised to handle three drag sources/targets:
|
||||
- loose attachment ↔ loose attachment (today's behaviour),
|
||||
- loose attachment → sub-document,
|
||||
- sub-document attachment ↔ sub-document attachment,
|
||||
- sub-document ↔ sub-document (reorder).
|
||||
- Drag-and-drop is disabled while in selection mode (so a click toggles selection rather than starting a drag).
|
||||
|
||||
Layout:
|
||||
- Keep the existing horizontal `<ul>` for **loose** attachments.
|
||||
- In the header, add a small toggle button labelled **"Auswählen"** (icon: `IconMenu` or a checkmark lucide icon). When active it reads **"Fertig"** (and selection mode is on). In normal mode thumbnails have no checkbox at all — the editor looks identical to today.
|
||||
- While in selection mode, each thumbnail card shows a **checkbox** in the top-left corner and the whole card becomes a click target that toggles its membership in `selectedPaths`. Drag-to-reorder is suspended in this mode to avoid click/drag ambiguity.
|
||||
- A new **inline action bar** appears above the loose-attachment list when `selectionMode && selectedPaths.size > 0`:
|
||||
- Button **"Teildokument erstellen"** → calls `createSubDocument` with the selected attachments, removes them from the loose list, clears `selectedPaths`, and keeps `selectionMode` on so the user can immediately build the next sub-document.
|
||||
- `Esc` exits selection mode (clearing `selectedPaths`); the "Fertig" button does the same.
|
||||
- Below the loose list, render `subDocuments` as a **vertical stack of "sub-document blocks"**. Each block is itself a horizontal reorderable `<ul>` of attachments (same `AttachmentPreview`, same drag handle `::`, same thumbnail width). Each block has:
|
||||
- an editable name input (mirrors archive name input styling),
|
||||
- a count label,
|
||||
- a "remove" action that returns its attachments back to the loose list,
|
||||
- a draggable header (`::`) to reorder the block among its siblings.
|
||||
- Sub-document blocks are draggable as a whole via their header (HTML5 DnD, mirroring the existing pattern in `handleDragStart/Drop`).
|
||||
|
||||
Export controls (header area):
|
||||
- If `subDocuments.length === 0` → existing **"PDF herunterladen"** button + behaviour (unchanged).
|
||||
- If `subDocuments.length > 0` → replace with a **segmented control** (`Eine PDF` / `Getrennt`) plus the download button labeled accordingly:
|
||||
- `Eine PDF` → `buildArchiveExport(archive, 'single')`, one `downloadPdfBytes` call.
|
||||
- `Getrennt` → `buildArchiveExport(archive, 'separate')`, sequential `downloadPdfBytes` per unit (matches today's `exportAllZipArchivesAsPdf` loop).
|
||||
|
||||
All state changes flow through `onArchiveChange` (already plumbed to `updateProcessedZipFile` in `+page.svelte`) so the top-level array stays the source of truth.
|
||||
|
||||
### `+page.svelte`
|
||||
- `exportAllZipArchivesAsPdf` needs to honour per-archive export mode. Two options:
|
||||
- ✅ Keep it simple: bulk export uses the existing **"single"** mode for every archive (sub-documents flattened). Add a note in the tooltip.
|
||||
- B. Read each archive's last-chosen mode (requires propagating `downloadMode` up). Defer to a follow-up if desired.
|
||||
- The settings-drawer bulk export button label stays; behaviour unchanged for v1.
|
||||
|
||||
### No changes required
|
||||
- `ZipDropzone`, `AttachmentPreview`, services, `xml-reading.service`, `zip-inflating.service`, layout.
|
||||
|
||||
---
|
||||
|
||||
## Implementation phases
|
||||
|
||||
### Phase 1 — Data model + pure helpers
|
||||
- Edit `src/lib/zip-processing.ts`:
|
||||
- Add `SubDocument` type and extend `ProcessedZipArchive` with `subDocuments: SubDocument[]` (default `[]`).
|
||||
- Set `subDocuments: []` in `extractZipEntries`.
|
||||
- Extract `mergeAttachments(attachments: ZipAttachment[]): Promise<Uint8Array>` from `mergeProcessedZipArchive`.
|
||||
- Add the pure helpers: `createSubDocument`, `moveAttachmentIntoSubDocument`, `moveSubDocument`, `removeAttachmentFromSubDocument` (returns attachments to the loose list), `flattenArchiveForMerge`, `buildArchiveExport`.
|
||||
- Verification: TypeScript compiles (`pnpm check` / `svelte-check`); existing tests (if any) still pass; existing UI still renders unchanged.
|
||||
|
||||
### Phase 2 — Sub-document block component
|
||||
- New `src/lib/components/SubDocumentEditor.svelte`:
|
||||
- Props: `subDocument`, `thumbnailWidth`, `onSubDocumentChange`, `onRemove`, `drag handlers` (or pass a generic reorder callback).
|
||||
- Renders the editable name, count, remove button, draggable header, horizontal attachment list (reusing `AttachmentPreview` + the same DnD styling).
|
||||
- Internally mirrors `ProcessedZipArchiveEditor`'s drag logic, scoped to the block.
|
||||
- Verify: can be unit-rendered in isolation (storybook-equivalent or a throwaway page snippet).
|
||||
|
||||
### Phase 3 — Selection mode + sub-document creation in `ProcessedZipArchiveEditor`
|
||||
- Add `selectionMode` and `selectedPaths` state and the "Auswählen" / "Fertig" header toggle.
|
||||
- While `selectionMode` is on, render a checkbox on each loose thumbnail and make the whole card a click-to-toggle target; suspend drag-to-reorder to avoid click/drag ambiguity.
|
||||
- Add the inline action bar with **"Teildokument erstellen"**, visible when a selection exists.
|
||||
- On create: call `createSubDocument`, remove the selected attachments from the loose list, clear `selectedPaths`, keep `selectionMode` on, and emit `onArchiveChange`.
|
||||
- `Esc` / "Fertig" exits selection mode and clears the selection.
|
||||
- On sub-document removal: push its attachments back into the loose list (appended at the end by default).
|
||||
- Verify: toggling selection mode shows/hides checkboxes; in normal mode the editor looks identical to today; creating, populating, and removing sub-documents works end-to-end with reordering still working for loose attachments.
|
||||
|
||||
### Phase 4 — Sub-document drag interactions
|
||||
- Generalise the existing HTML5 DnD handlers to support the three move scenarios listed above. Use the `dataTransfer` payload to encode `{ source: 'loose' | `sub:${id}`, index }`.
|
||||
- Reorder sub-document blocks via header drag.
|
||||
- Verify: items can be moved loose↔sub and sub↔sub; sub-document order can be changed; nothing is duplicated or lost (count invariant: `loose.length + Σ sub.attachments.length === total attachments`).
|
||||
|
||||
### Phase 5 — Export modes
|
||||
- Replace header download button with the segmented control + button when sub-documents exist.
|
||||
- Wire `buildArchiveExport(archive, mode)` to `downloadPdfBytes` (single) and the sequential loop (separate).
|
||||
- `+page.svelte`: keep `exportAllZipArchivesAsPdf` in single mode; optionally surface a small hint when an archive has sub-documents.
|
||||
- Verify:
|
||||
- No sub-documents → existing single-PDF download unchanged.
|
||||
- With sub-documents, "Eine PDF" flattens and downloads one PDF.
|
||||
- With sub-documents, "Getrennt" downloads N files named `{archiveName} - {subName}.pdf`.
|
||||
|
||||
### Phase 6 — Polish
|
||||
- Empty states (e.g. empty sub-document block, no loose attachments).
|
||||
- Disable the create-sub-document button when selection is empty.
|
||||
- Accessible labels + keyboard operability for checkboxes / segmented control (`bits-ui` SegmentedControl if available, otherwise native radio group).
|
||||
- Update `agents.md` "ZIP/PDF processing details" + "UI/state details" sections to mention sub-documents.
|
||||
- Manual smoke test on a real `xjustiz` ZIP with nested archives.
|
||||
|
||||
---
|
||||
|
||||
## Verification checklist (definition of done)
|
||||
|
||||
- [ ] `pnpm check` (or `svelte-check`) passes with no new errors.
|
||||
- [ ] `pnpm build` succeeds.
|
||||
- [ ] Loading a ZIP without creating sub-documents produces the exact same merged PDF as today.
|
||||
- [ ] Toggling "Auswählen" shows checkboxes on thumbnails; toggling "Fertig" (or pressing Esc) hides them and clears the selection. In normal mode the editor looks identical to today (no checkboxes).
|
||||
- [ ] Selecting ≥1 attachments and clicking "Teildokument erstellen" removes them from the loose list and adds a named sub-document block, then clears the selection while staying in selection mode for the next group.
|
||||
- [ ] Drag-reordering works for: loose attachments, attachments inside a sub-document, sub-document blocks themselves, and moving an attachment loose↔sub.
|
||||
- [ ] With sub-documents present:
|
||||
- "Eine PDF" downloads a single PDF containing every attachment (sub-documents first, then loose).
|
||||
- "Getrennt" downloads one PDF per sub-document, each correctly named.
|
||||
- [ ] Removing a sub-document returns its attachments to the loose list; total attachment count is invariant.
|
||||
- [ ] Bulk "Alle ZIP-Archive als PDF exportieren" still works (single mode).
|
||||
- [ ] `agents.md` updated.
|
||||
|
||||
---
|
||||
|
||||
## Out of scope (follow-ups)
|
||||
|
||||
- Persisting sub-document structure to `localStorage`.
|
||||
- Renaming attachments themselves (only sub-document names are editable in v1).
|
||||
- Exporting "separate" as ZIPs or original-format files (see D4-C).
|
||||
- Per-archive export mode remembered by the bulk exporter (D3 follow-up).
|
||||
- Drag-and-drop between *different archives* in `+page.svelte` (today each editor is self-contained).
|
||||
Generated
+426
-7
@@ -24,9 +24,9 @@ importers:
|
||||
'@lucide/svelte':
|
||||
specifier: ^1.18.0
|
||||
version: 1.18.0(svelte@5.56.3)
|
||||
'@sveltejs/adapter-auto':
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1(@sveltejs/kit@2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0)))
|
||||
'@sveltejs/adapter-node':
|
||||
specifier: ^5.5.7
|
||||
version: 5.5.7(@sveltejs/kit@2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0)))
|
||||
'@sveltejs/kit':
|
||||
specifier: ^2.63.0
|
||||
version: 2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0))
|
||||
@@ -326,6 +326,189 @@ packages:
|
||||
'@rolldown/pluginutils@1.0.1':
|
||||
resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==}
|
||||
|
||||
'@rollup/plugin-commonjs@29.0.3':
|
||||
resolution: {integrity: sha512-ZaOxZceP7SOUW7Lqw5IRVweSQYWaeIPnXIGLiB690EBA3FGJTO40EEr2L5yZplJWsgTCogILRSpcAe7+U0Otdg==}
|
||||
engines: {node: '>=16.0.0 || 14 >= 14.17'}
|
||||
peerDependencies:
|
||||
rollup: ^2.68.0||^3.0.0||^4.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/plugin-json@6.1.0':
|
||||
resolution: {integrity: sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
peerDependencies:
|
||||
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/plugin-node-resolve@16.0.3':
|
||||
resolution: {integrity: sha512-lUYM3UBGuM93CnMPG1YocWu7X802BrNF3jW2zny5gQyLQgRFJhV1Sq0Zi74+dh/6NBx1DxFC4b4GXg9wUCG5Qg==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
peerDependencies:
|
||||
rollup: ^2.78.0||^3.0.0||^4.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/plugin-replace@6.0.3':
|
||||
resolution: {integrity: sha512-J4RZarRvQAm5IF0/LwUUg+obsm+xZhYnbMXmXROyoSE1ATJe3oXSb9L5MMppdxP2ylNSjv6zFBwKYjcKMucVfA==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
peerDependencies:
|
||||
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/pluginutils@5.4.0':
|
||||
resolution: {integrity: sha512-MfPp06CjRLfXQ3wY0R8vJDYBy/MvVcc9OulEfR0B8Iv9ko+GCNaRZ+EpJYFl27LhKsZK0o420sYCRHCjfCgeUg==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
peerDependencies:
|
||||
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.62.2':
|
||||
resolution: {integrity: sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg==}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@rollup/rollup-android-arm64@4.62.2':
|
||||
resolution: {integrity: sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw==}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@rollup/rollup-darwin-arm64@4.62.2':
|
||||
resolution: {integrity: sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@rollup/rollup-darwin-x64@4.62.2':
|
||||
resolution: {integrity: sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@rollup/rollup-freebsd-arm64@4.62.2':
|
||||
resolution: {integrity: sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw==}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
|
||||
'@rollup/rollup-freebsd-x64@4.62.2':
|
||||
resolution: {integrity: sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg==}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.62.2':
|
||||
resolution: {integrity: sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.62.2':
|
||||
resolution: {integrity: sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.62.2':
|
||||
resolution: {integrity: sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.62.2':
|
||||
resolution: {integrity: sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-loong64-gnu@4.62.2':
|
||||
resolution: {integrity: sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-loong64-musl@4.62.2':
|
||||
resolution: {integrity: sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.62.2':
|
||||
resolution: {integrity: sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-ppc64-musl@4.62.2':
|
||||
resolution: {integrity: sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.62.2':
|
||||
resolution: {integrity: sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-musl@4.62.2':
|
||||
resolution: {integrity: sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.62.2':
|
||||
resolution: {integrity: sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.62.2':
|
||||
resolution: {integrity: sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.62.2':
|
||||
resolution: {integrity: sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-openbsd-x64@4.62.2':
|
||||
resolution: {integrity: sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg==}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
|
||||
'@rollup/rollup-openharmony-arm64@4.62.2':
|
||||
resolution: {integrity: sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA==}
|
||||
cpu: [arm64]
|
||||
os: [openharmony]
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.62.2':
|
||||
resolution: {integrity: sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-ia32-msvc@4.62.2':
|
||||
resolution: {integrity: sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q==}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-x64-gnu@4.62.2':
|
||||
resolution: {integrity: sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-x64-msvc@4.62.2':
|
||||
resolution: {integrity: sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@standard-schema/spec@1.1.0':
|
||||
resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
|
||||
|
||||
@@ -334,10 +517,10 @@ packages:
|
||||
peerDependencies:
|
||||
acorn: ^8.9.0
|
||||
|
||||
'@sveltejs/adapter-auto@7.0.1':
|
||||
resolution: {integrity: sha512-dvuPm1E7M9NI/+canIQ6KKQDU2AkEefEZ2Dp7cY6uKoPq9Z/PhOXABe526UdW2mN986gjVkuSLkOYIBnS/M2LQ==}
|
||||
'@sveltejs/adapter-node@5.5.7':
|
||||
resolution: {integrity: sha512-uOfc9eVlI3A37RRSaKcgrheBYPrfJwC9VMqDp8x/O6tlKdcLLvHThSWD0KNIbjQ/d+7bwLGx3vx6aowAcRfd2g==}
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': ^2.0.0
|
||||
'@sveltejs/kit': ^2.4.0
|
||||
|
||||
'@sveltejs/kit@2.64.0':
|
||||
resolution: {integrity: sha512-24MXA/xyugUqJd09DD4v4bLd4k7FaYhdBck/pTXiu3XFtDBcwXYpJc1SO1+lqdjkNBUo1r4eek5FS7cfzBQUmA==}
|
||||
@@ -482,6 +665,9 @@ packages:
|
||||
'@types/estree@1.0.9':
|
||||
resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
|
||||
|
||||
'@types/resolve@1.20.2':
|
||||
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
|
||||
|
||||
'@types/trusted-types@2.0.7':
|
||||
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
|
||||
|
||||
@@ -520,6 +706,9 @@ packages:
|
||||
resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
commondir@1.0.1:
|
||||
resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==}
|
||||
|
||||
cookie@0.6.0:
|
||||
resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@@ -548,6 +737,10 @@ packages:
|
||||
resolution: {integrity: sha512-yJN/BOOLxcOW2aQgeif9mSnaUB8KtvmMMp56oA1kx1CRfBKbhZm2pJ+NBY+3eOboHxix8lfjWpHE0Ei5U8RbSA==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
es-errors@1.3.0:
|
||||
resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
esm-env@1.2.2:
|
||||
resolution: {integrity: sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==}
|
||||
|
||||
@@ -559,6 +752,9 @@ packages:
|
||||
'@typescript-eslint/types':
|
||||
optional: true
|
||||
|
||||
estree-walker@2.0.2:
|
||||
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
||||
|
||||
fdir@6.5.0:
|
||||
resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
@@ -576,12 +772,29 @@ packages:
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
|
||||
function-bind@1.1.2:
|
||||
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
||||
|
||||
graceful-fs@4.2.11:
|
||||
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
|
||||
|
||||
hasown@2.0.4:
|
||||
resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
inline-style-parser@0.2.7:
|
||||
resolution: {integrity: sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==}
|
||||
|
||||
is-core-module@2.16.2:
|
||||
resolution: {integrity: sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
is-module@1.0.0:
|
||||
resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==}
|
||||
|
||||
is-reference@1.2.1:
|
||||
resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==}
|
||||
|
||||
is-reference@3.0.3:
|
||||
resolution: {integrity: sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==}
|
||||
|
||||
@@ -704,6 +917,9 @@ packages:
|
||||
pako@1.0.11:
|
||||
resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}
|
||||
|
||||
path-parse@1.0.7:
|
||||
resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
|
||||
|
||||
pdf-lib@1.17.1:
|
||||
resolution: {integrity: sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==}
|
||||
|
||||
@@ -797,11 +1013,21 @@ packages:
|
||||
resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==}
|
||||
engines: {node: '>= 14.18.0'}
|
||||
|
||||
resolve@1.22.12:
|
||||
resolution: {integrity: sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
hasBin: true
|
||||
|
||||
rolldown@1.0.3:
|
||||
resolution: {integrity: sha512-i00lAJ2ks1BYr7rjNjKC7BcqAS7nVfiT3QX1SI5aY+AFHblCmaUf9OE9dbdzDvW6dJxbi2ZCZiy9v3CcwOiX3g==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
hasBin: true
|
||||
|
||||
rollup@4.62.2:
|
||||
resolution: {integrity: sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA==}
|
||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||
hasBin: true
|
||||
|
||||
runed@0.35.1:
|
||||
resolution: {integrity: sha512-2F4Q/FZzbeJTFdIS/PuOoPRSm92sA2LhzTnv6FXhCoENb3huf5+fDuNOg1LNvGOouy3u/225qxmuJvcV3IZK5Q==}
|
||||
peerDependencies:
|
||||
@@ -835,6 +1061,10 @@ packages:
|
||||
style-to-object@1.0.14:
|
||||
resolution: {integrity: sha512-LIN7rULI0jBscWQYaSswptyderlarFkjQ+t79nzty8tcIAceVomEVlLzH5VP4Cmsv6MtKhs7qaAiwlcp+Mgaxw==}
|
||||
|
||||
supports-preserve-symlinks-flag@1.0.0:
|
||||
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
svelte-check@4.6.0:
|
||||
resolution: {integrity: sha512-KhVnDFDSid57mmZtHz8gfW8AAGylOZ0vPnOIzVmAL+urzwK8sBYXRss953gD8T0OdgAQ11mdWhE6uadmtOz8TQ==}
|
||||
engines: {node: '>= 18.0.0'}
|
||||
@@ -1131,15 +1361,138 @@ snapshots:
|
||||
|
||||
'@rolldown/pluginutils@1.0.1': {}
|
||||
|
||||
'@rollup/plugin-commonjs@29.0.3(rollup@4.62.2)':
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 5.4.0(rollup@4.62.2)
|
||||
commondir: 1.0.1
|
||||
estree-walker: 2.0.2
|
||||
fdir: 6.5.0(picomatch@4.0.4)
|
||||
is-reference: 1.2.1
|
||||
magic-string: 0.30.21
|
||||
picomatch: 4.0.4
|
||||
optionalDependencies:
|
||||
rollup: 4.62.2
|
||||
|
||||
'@rollup/plugin-json@6.1.0(rollup@4.62.2)':
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 5.4.0(rollup@4.62.2)
|
||||
optionalDependencies:
|
||||
rollup: 4.62.2
|
||||
|
||||
'@rollup/plugin-node-resolve@16.0.3(rollup@4.62.2)':
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 5.4.0(rollup@4.62.2)
|
||||
'@types/resolve': 1.20.2
|
||||
deepmerge: 4.3.1
|
||||
is-module: 1.0.0
|
||||
resolve: 1.22.12
|
||||
optionalDependencies:
|
||||
rollup: 4.62.2
|
||||
|
||||
'@rollup/plugin-replace@6.0.3(rollup@4.62.2)':
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 5.4.0(rollup@4.62.2)
|
||||
magic-string: 0.30.21
|
||||
optionalDependencies:
|
||||
rollup: 4.62.2
|
||||
|
||||
'@rollup/pluginutils@5.4.0(rollup@4.62.2)':
|
||||
dependencies:
|
||||
'@types/estree': 1.0.9
|
||||
estree-walker: 2.0.2
|
||||
picomatch: 4.0.4
|
||||
optionalDependencies:
|
||||
rollup: 4.62.2
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-android-arm64@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-darwin-arm64@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-darwin-x64@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-freebsd-arm64@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-freebsd-x64@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-loong64-gnu@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-loong64-musl@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-ppc64-musl@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-riscv64-musl@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-openbsd-x64@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-openharmony-arm64@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-ia32-msvc@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-x64-gnu@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-x64-msvc@4.62.2':
|
||||
optional: true
|
||||
|
||||
'@standard-schema/spec@1.1.0': {}
|
||||
|
||||
'@sveltejs/acorn-typescript@1.0.10(acorn@8.16.0)':
|
||||
dependencies:
|
||||
acorn: 8.16.0
|
||||
|
||||
'@sveltejs/adapter-auto@7.0.1(@sveltejs/kit@2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0)))':
|
||||
'@sveltejs/adapter-node@5.5.7(@sveltejs/kit@2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0)))':
|
||||
dependencies:
|
||||
'@rollup/plugin-commonjs': 29.0.3(rollup@4.62.2)
|
||||
'@rollup/plugin-json': 6.1.0(rollup@4.62.2)
|
||||
'@rollup/plugin-node-resolve': 16.0.3(rollup@4.62.2)
|
||||
'@rollup/plugin-replace': 6.0.3(rollup@4.62.2)
|
||||
'@sveltejs/kit': 2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0))
|
||||
rollup: 4.62.2
|
||||
|
||||
'@sveltejs/kit@2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0))':
|
||||
dependencies:
|
||||
@@ -1263,6 +1616,8 @@ snapshots:
|
||||
|
||||
'@types/estree@1.0.9': {}
|
||||
|
||||
'@types/resolve@1.20.2': {}
|
||||
|
||||
'@types/trusted-types@2.0.7': {}
|
||||
|
||||
acorn@8.16.0: {}
|
||||
@@ -1296,6 +1651,8 @@ snapshots:
|
||||
|
||||
commander@14.0.3: {}
|
||||
|
||||
commondir@1.0.1: {}
|
||||
|
||||
cookie@0.6.0: {}
|
||||
|
||||
cssesc@3.0.0: {}
|
||||
@@ -1313,12 +1670,16 @@ snapshots:
|
||||
graceful-fs: 4.2.11
|
||||
tapable: 2.3.3
|
||||
|
||||
es-errors@1.3.0: {}
|
||||
|
||||
esm-env@1.2.2: {}
|
||||
|
||||
esrap@2.2.11:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
|
||||
estree-walker@2.0.2: {}
|
||||
|
||||
fdir@6.5.0(picomatch@4.0.4):
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.4
|
||||
@@ -1328,10 +1689,26 @@ snapshots:
|
||||
fsevents@2.3.3:
|
||||
optional: true
|
||||
|
||||
function-bind@1.1.2: {}
|
||||
|
||||
graceful-fs@4.2.11: {}
|
||||
|
||||
hasown@2.0.4:
|
||||
dependencies:
|
||||
function-bind: 1.1.2
|
||||
|
||||
inline-style-parser@0.2.7: {}
|
||||
|
||||
is-core-module@2.16.2:
|
||||
dependencies:
|
||||
hasown: 2.0.4
|
||||
|
||||
is-module@1.0.0: {}
|
||||
|
||||
is-reference@1.2.1:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.9
|
||||
|
||||
is-reference@3.0.3:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.9
|
||||
@@ -1411,6 +1788,8 @@ snapshots:
|
||||
|
||||
pako@1.0.11: {}
|
||||
|
||||
path-parse@1.0.7: {}
|
||||
|
||||
pdf-lib@1.17.1:
|
||||
dependencies:
|
||||
'@pdf-lib/standard-fonts': 1.0.0
|
||||
@@ -1452,6 +1831,13 @@ snapshots:
|
||||
|
||||
readdirp@4.1.2: {}
|
||||
|
||||
resolve@1.22.12:
|
||||
dependencies:
|
||||
es-errors: 1.3.0
|
||||
is-core-module: 2.16.2
|
||||
path-parse: 1.0.7
|
||||
supports-preserve-symlinks-flag: 1.0.0
|
||||
|
||||
rolldown@1.0.3:
|
||||
dependencies:
|
||||
'@oxc-project/types': 0.133.0
|
||||
@@ -1473,6 +1859,37 @@ snapshots:
|
||||
'@rolldown/binding-win32-arm64-msvc': 1.0.3
|
||||
'@rolldown/binding-win32-x64-msvc': 1.0.3
|
||||
|
||||
rollup@4.62.2:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.9
|
||||
optionalDependencies:
|
||||
'@rollup/rollup-android-arm-eabi': 4.62.2
|
||||
'@rollup/rollup-android-arm64': 4.62.2
|
||||
'@rollup/rollup-darwin-arm64': 4.62.2
|
||||
'@rollup/rollup-darwin-x64': 4.62.2
|
||||
'@rollup/rollup-freebsd-arm64': 4.62.2
|
||||
'@rollup/rollup-freebsd-x64': 4.62.2
|
||||
'@rollup/rollup-linux-arm-gnueabihf': 4.62.2
|
||||
'@rollup/rollup-linux-arm-musleabihf': 4.62.2
|
||||
'@rollup/rollup-linux-arm64-gnu': 4.62.2
|
||||
'@rollup/rollup-linux-arm64-musl': 4.62.2
|
||||
'@rollup/rollup-linux-loong64-gnu': 4.62.2
|
||||
'@rollup/rollup-linux-loong64-musl': 4.62.2
|
||||
'@rollup/rollup-linux-ppc64-gnu': 4.62.2
|
||||
'@rollup/rollup-linux-ppc64-musl': 4.62.2
|
||||
'@rollup/rollup-linux-riscv64-gnu': 4.62.2
|
||||
'@rollup/rollup-linux-riscv64-musl': 4.62.2
|
||||
'@rollup/rollup-linux-s390x-gnu': 4.62.2
|
||||
'@rollup/rollup-linux-x64-gnu': 4.62.2
|
||||
'@rollup/rollup-linux-x64-musl': 4.62.2
|
||||
'@rollup/rollup-openbsd-x64': 4.62.2
|
||||
'@rollup/rollup-openharmony-arm64': 4.62.2
|
||||
'@rollup/rollup-win32-arm64-msvc': 4.62.2
|
||||
'@rollup/rollup-win32-ia32-msvc': 4.62.2
|
||||
'@rollup/rollup-win32-x64-gnu': 4.62.2
|
||||
'@rollup/rollup-win32-x64-msvc': 4.62.2
|
||||
fsevents: 2.3.3
|
||||
|
||||
runed@0.35.1(@sveltejs/kit@2.64.0(@sveltejs/vite-plugin-svelte@7.1.2(svelte@5.56.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3)(typescript@6.0.3)(vite@8.0.16(jiti@2.7.0)))(svelte@5.56.3):
|
||||
dependencies:
|
||||
dequal: 2.0.3
|
||||
@@ -1508,6 +1925,8 @@ snapshots:
|
||||
dependencies:
|
||||
inline-style-parser: 0.2.7
|
||||
|
||||
supports-preserve-symlinks-flag@1.0.0: {}
|
||||
|
||||
svelte-check@4.6.0(picomatch@4.0.4)(svelte@5.56.3)(typescript@6.0.3):
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
<script lang="ts">
|
||||
import AttachmentPreview from '$lib/components/AttachmentPreview.svelte';
|
||||
import Button from '$lib/components/ui/button.svelte';
|
||||
import SubDocumentEditor from '$lib/components/SubDocumentEditor.svelte';
|
||||
import {
|
||||
mergeProcessedZipArchive,
|
||||
buildArchiveExport,
|
||||
createSubDocument,
|
||||
dissolveSubDocument,
|
||||
moveAttachmentIntoSubDocument,
|
||||
moveSubDocument,
|
||||
type AttachmentLocation,
|
||||
type ExportMode,
|
||||
type ProcessedZipArchive,
|
||||
type SubDocument,
|
||||
type ZipAttachment
|
||||
} from '$lib/zip-processing';
|
||||
import { cn } from '$lib/utils';
|
||||
|
||||
type Props = {
|
||||
archive: ProcessedZipArchive;
|
||||
@@ -15,34 +24,276 @@
|
||||
|
||||
let { archive, thumbnailWidth = 200, onArchiveChange = () => {} }: Props = $props();
|
||||
|
||||
let attachments = $state<ZipAttachment[]>([]);
|
||||
const ATTACHMENT_MIME = 'application/x-juri-merger-attachment';
|
||||
|
||||
let archiveName = $state('');
|
||||
let looseAttachments = $state<ZipAttachment[]>([]);
|
||||
let subDocuments = $state<SubDocument[]>([]);
|
||||
|
||||
let selectionMode = $state(false);
|
||||
let selectedPaths = $state<Set<string>>(new Set());
|
||||
|
||||
let dragIndex = $state<number | null>(null);
|
||||
let dropIndex = $state<number | null>(null);
|
||||
|
||||
let blockDragIndex = $state<number | null>(null);
|
||||
let blockDropIndex = $state<number | null>(null);
|
||||
|
||||
let downloadMode = $state<ExportMode>('single');
|
||||
let isMerging = $state(false);
|
||||
let mergeError = $state<string | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
archiveName = archive.name;
|
||||
looseAttachments = archive.attachments.map((attachment) => ({ ...attachment }));
|
||||
subDocuments = archive.subDocuments.map((subDocument) => ({
|
||||
...subDocument,
|
||||
attachments: subDocument.attachments.map((attachment) => ({ ...attachment }))
|
||||
}));
|
||||
});
|
||||
|
||||
const toArrayBuffer = (bytes: Uint8Array) => {
|
||||
const copy = new Uint8Array(bytes.byteLength);
|
||||
copy.set(bytes);
|
||||
return copy.buffer;
|
||||
};
|
||||
|
||||
$effect(() => {
|
||||
archiveName = archive.name;
|
||||
attachments = archive.attachments.map((attachment) => ({ ...attachment }));
|
||||
});
|
||||
const normalizeFileName = (name: string) =>
|
||||
name.toLowerCase().endsWith('.pdf') ? name : `${name}.pdf`;
|
||||
|
||||
const emitArchiveChange = () => {
|
||||
onArchiveChange({
|
||||
...archive,
|
||||
name: archiveName,
|
||||
attachments: attachments.map((attachment) => ({ ...attachment }))
|
||||
});
|
||||
const downloadPdfBytes = (bytes: Uint8Array, fileName: string) => {
|
||||
const pdfBlob = new Blob([toArrayBuffer(bytes)], { type: 'application/pdf' });
|
||||
const objectUrl = URL.createObjectURL(pdfBlob);
|
||||
const downloadLink = document.createElement('a');
|
||||
downloadLink.href = objectUrl;
|
||||
downloadLink.download = normalizeFileName(fileName);
|
||||
downloadLink.rel = 'noopener';
|
||||
downloadLink.click();
|
||||
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 1000);
|
||||
};
|
||||
|
||||
const downloadMergedPdf = async () => {
|
||||
if (attachments.length === 0 || isMerging) {
|
||||
const composedArchive = (): ProcessedZipArchive => ({
|
||||
...archive,
|
||||
name: archiveName,
|
||||
attachments: looseAttachments,
|
||||
subDocuments
|
||||
});
|
||||
|
||||
const emitArchiveChange = (nextArchive: ProcessedZipArchive) => {
|
||||
archiveName = nextArchive.name;
|
||||
looseAttachments = nextArchive.attachments;
|
||||
subDocuments = nextArchive.subDocuments;
|
||||
onArchiveChange(nextArchive);
|
||||
};
|
||||
|
||||
const commit = () => {
|
||||
onArchiveChange(composedArchive());
|
||||
};
|
||||
|
||||
const hasSubDocuments = $derived(subDocuments.length > 0);
|
||||
|
||||
const toggleSelection = (path: string) => {
|
||||
const next = new Set(selectedPaths);
|
||||
|
||||
if (next.has(path)) {
|
||||
next.delete(path);
|
||||
} else {
|
||||
next.add(path);
|
||||
}
|
||||
|
||||
selectedPaths = next;
|
||||
};
|
||||
|
||||
const toggleSelectionMode = () => {
|
||||
selectionMode = !selectionMode;
|
||||
selectedPaths = new Set();
|
||||
};
|
||||
|
||||
const exitSelectionMode = () => {
|
||||
selectionMode = false;
|
||||
selectedPaths = new Set();
|
||||
};
|
||||
|
||||
const handleWindowKeydown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape' && selectionMode) {
|
||||
exitSelectionMode();
|
||||
}
|
||||
};
|
||||
|
||||
const createSubDocumentFromSelection = () => {
|
||||
if (selectedPaths.size === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedAttachments = looseAttachments.filter((attachment) =>
|
||||
selectedPaths.has(attachment.path)
|
||||
);
|
||||
const remainingAttachments = looseAttachments.filter(
|
||||
(attachment) => !selectedPaths.has(attachment.path)
|
||||
);
|
||||
|
||||
if (selectedAttachments.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const subDocumentNumber = subDocuments.length + 1;
|
||||
const nextSubDocument = createSubDocument(
|
||||
`Teildokument ${subDocumentNumber}`,
|
||||
selectedAttachments
|
||||
);
|
||||
|
||||
looseAttachments = remainingAttachments;
|
||||
subDocuments = [...subDocuments, nextSubDocument];
|
||||
selectedPaths = new Set();
|
||||
commit();
|
||||
};
|
||||
|
||||
const dissolveSubDocumentBlock = (subDocumentId: string) => {
|
||||
const nextArchive = dissolveSubDocument(composedArchive(), subDocumentId);
|
||||
|
||||
emitArchiveChange(nextArchive);
|
||||
};
|
||||
|
||||
const handleSubDocumentChange = (next: SubDocument) => {
|
||||
subDocuments = subDocuments.map((subDocument) =>
|
||||
subDocument.id === next.id ? next : subDocument
|
||||
);
|
||||
commit();
|
||||
};
|
||||
|
||||
const handleAttachmentMove = (source: AttachmentLocation, target: AttachmentLocation) => {
|
||||
const nextArchive = moveAttachmentIntoSubDocument(composedArchive(), source, target);
|
||||
|
||||
emitArchiveChange(nextArchive);
|
||||
};
|
||||
|
||||
const handleBlockDragStart = (blockIndex: number, _event: DragEvent) => {
|
||||
blockDragIndex = blockIndex;
|
||||
blockDropIndex = blockIndex;
|
||||
};
|
||||
|
||||
const handleBlockDragOver = (blockIndex: number, _event: DragEvent) => {
|
||||
blockDropIndex = blockIndex;
|
||||
};
|
||||
|
||||
const handleBlockDrop = (blockIndex: number, _event: DragEvent) => {
|
||||
if (blockDragIndex === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fromIndex = blockDragIndex;
|
||||
const nextArchive = moveSubDocument(composedArchive(), fromIndex, blockIndex);
|
||||
|
||||
emitArchiveChange(nextArchive);
|
||||
blockDragIndex = null;
|
||||
blockDropIndex = null;
|
||||
};
|
||||
|
||||
const handleBlockDragEnd = () => {
|
||||
blockDragIndex = null;
|
||||
blockDropIndex = null;
|
||||
};
|
||||
|
||||
const moveLooseAttachment = (fromIndex: number, toIndex: number) => {
|
||||
if (
|
||||
fromIndex === toIndex ||
|
||||
fromIndex < 0 ||
|
||||
toIndex < 0 ||
|
||||
fromIndex >= looseAttachments.length ||
|
||||
toIndex >= looseAttachments.length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextAttachments = [...looseAttachments];
|
||||
const [movedAttachment] = nextAttachments.splice(fromIndex, 1);
|
||||
|
||||
nextAttachments.splice(toIndex, 0, movedAttachment);
|
||||
|
||||
looseAttachments = nextAttachments;
|
||||
commit();
|
||||
};
|
||||
|
||||
const handleLooseDragStart = (index: number, event: DragEvent) => {
|
||||
if (selectionMode) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
dragIndex = index;
|
||||
dropIndex = index;
|
||||
|
||||
const source: AttachmentLocation = { kind: 'loose', index };
|
||||
|
||||
if (event.dataTransfer) {
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
event.dataTransfer.setData(ATTACHMENT_MIME, JSON.stringify(source));
|
||||
event.dataTransfer.setData('text/plain', String(index));
|
||||
}
|
||||
};
|
||||
|
||||
const parseAttachmentPayload = (event: DragEvent): AttachmentLocation | null => {
|
||||
const raw = event.dataTransfer?.getData(ATTACHMENT_MIME);
|
||||
|
||||
if (!raw) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as AttachmentLocation;
|
||||
|
||||
if (parsed.kind === 'loose' || parsed.kind === 'subDocument') {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleLooseDragOver = (index: number, event: DragEvent) => {
|
||||
if (event.dataTransfer?.types.includes(ATTACHMENT_MIME)) {
|
||||
event.preventDefault();
|
||||
dropIndex = index;
|
||||
}
|
||||
};
|
||||
|
||||
const handleLooseDrop = (index: number, event: DragEvent) => {
|
||||
const source = parseAttachmentPayload(event);
|
||||
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if (source.kind === 'loose') {
|
||||
moveLooseAttachment(source.index, index);
|
||||
} else {
|
||||
const nextArchive = moveAttachmentIntoSubDocument(composedArchive(), source, {
|
||||
kind: 'loose',
|
||||
index
|
||||
});
|
||||
|
||||
emitArchiveChange(nextArchive);
|
||||
}
|
||||
|
||||
dragIndex = null;
|
||||
dropIndex = null;
|
||||
};
|
||||
|
||||
const handleLooseDragEnd = () => {
|
||||
dragIndex = null;
|
||||
dropIndex = null;
|
||||
};
|
||||
|
||||
const downloadArchive = async () => {
|
||||
if (looseAttachments.length === 0 && subDocuments.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMerging) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,85 +301,22 @@
|
||||
mergeError = null;
|
||||
|
||||
try {
|
||||
const mergedBytes = await mergeProcessedZipArchive({
|
||||
...archive,
|
||||
name: archiveName,
|
||||
attachments: attachments.map((attachment) => ({ ...attachment }))
|
||||
});
|
||||
const exportUnits = await buildArchiveExport(composedArchive(), downloadMode);
|
||||
|
||||
const pdfBlob = new Blob([toArrayBuffer(mergedBytes)], { type: 'application/pdf' });
|
||||
const objectUrl = URL.createObjectURL(pdfBlob);
|
||||
const downloadLink = document.createElement('a');
|
||||
downloadLink.href = objectUrl;
|
||||
downloadLink.download = archiveName.toLowerCase().endsWith('.pdf')
|
||||
? archiveName
|
||||
: `${archiveName}.pdf`;
|
||||
downloadLink.rel = 'noopener';
|
||||
downloadLink.click();
|
||||
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 1000);
|
||||
for (const unit of exportUnits) {
|
||||
downloadPdfBytes(unit.bytes, unit.name);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to merge archive ${archive.name}`, error);
|
||||
console.error(`Failed to export archive ${archive.name}`, error);
|
||||
mergeError = 'PDF konnte nicht erstellt werden.';
|
||||
} finally {
|
||||
isMerging = false;
|
||||
}
|
||||
};
|
||||
|
||||
const moveAttachment = (fromIndex: number, toIndex: number) => {
|
||||
if (
|
||||
fromIndex === toIndex ||
|
||||
fromIndex < 0 ||
|
||||
toIndex < 0 ||
|
||||
fromIndex >= attachments.length ||
|
||||
toIndex >= attachments.length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextAttachments = [...attachments];
|
||||
const [movedAttachment] = nextAttachments.splice(fromIndex, 1);
|
||||
nextAttachments.splice(toIndex, 0, movedAttachment);
|
||||
|
||||
attachments = nextAttachments;
|
||||
emitArchiveChange();
|
||||
};
|
||||
|
||||
const handleDragStart = (index: number, event: DragEvent) => {
|
||||
dragIndex = index;
|
||||
dropIndex = index;
|
||||
|
||||
if (event.dataTransfer) {
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
event.dataTransfer.setData('text/plain', String(index));
|
||||
}
|
||||
};
|
||||
|
||||
const handleDragOver = (index: number, event: DragEvent) => {
|
||||
event.preventDefault();
|
||||
dropIndex = index;
|
||||
};
|
||||
|
||||
const handleDrop = (index: number, event: DragEvent) => {
|
||||
event.preventDefault();
|
||||
|
||||
const dataTransferIndex = Number(event.dataTransfer?.getData('text/plain'));
|
||||
const fromIndex = Number.isFinite(dataTransferIndex) ? dataTransferIndex : dragIndex;
|
||||
|
||||
if (fromIndex === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
moveAttachment(fromIndex, index);
|
||||
dragIndex = null;
|
||||
dropIndex = null;
|
||||
};
|
||||
|
||||
const handleDragEnd = () => {
|
||||
dragIndex = null;
|
||||
dropIndex = null;
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleWindowKeydown} />
|
||||
|
||||
<section
|
||||
class="flex flex-col gap-4 rounded-2xl border border-primary-100 bg-white px-4 py-4 shadow-sm"
|
||||
>
|
||||
@@ -140,25 +328,70 @@
|
||||
class="w-full max-w-xl rounded-md border border-primary-200 bg-white px-3 py-2 text-[16px] font-bold text-primary-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-200"
|
||||
type="text"
|
||||
value={archiveName}
|
||||
draggable="false"
|
||||
oninput={(event) => {
|
||||
archiveName = (event.currentTarget as HTMLInputElement).value;
|
||||
emitArchiveChange();
|
||||
commit();
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<p class="mt-1 text-[13px] text-primary">
|
||||
{attachments.length} relevante Datei{attachments.length === 1 ? '' : 'en'}
|
||||
{looseAttachments.length} lose Datei{looseAttachments.length === 1 ? '' : 'en'}
|
||||
{#if hasSubDocuments}
|
||||
· {subDocuments.length} Teildokument{subDocuments.length === 1 ? '' : 'e'}
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant={selectionMode ? 'secondary' : 'bordered'}
|
||||
onclick={toggleSelectionMode}
|
||||
>
|
||||
{selectionMode ? 'Fertig' : 'Auswählen'}
|
||||
</Button>
|
||||
|
||||
{#if hasSubDocuments}
|
||||
<div
|
||||
class="inline-flex items-center rounded-[16px] border border-primary-200 bg-white p-0.5"
|
||||
role="radiogroup"
|
||||
aria-label="Export-Modus"
|
||||
>
|
||||
{#each [{ value: 'single', label: 'Eine PDF' }, { value: 'separate', label: 'Getrennt' }] as option (option.value)}
|
||||
<label
|
||||
class={cn(
|
||||
'cursor-pointer rounded-[14px] px-3 py-1 text-[13px] font-semibold transition',
|
||||
downloadMode === option.value
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: 'text-primary-700 hover:bg-primary-50'
|
||||
)}
|
||||
>
|
||||
<input
|
||||
class="sr-only"
|
||||
type="radio"
|
||||
name={`download-mode-${archive.name}`}
|
||||
value={option.value}
|
||||
checked={downloadMode === option.value}
|
||||
onchange={() => {
|
||||
downloadMode = option.value as ExportMode;
|
||||
}}
|
||||
/>
|
||||
{option.label}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<Button
|
||||
class="bg-primary"
|
||||
type="button"
|
||||
disabled={attachments.length === 0 || isMerging}
|
||||
onclick={downloadMergedPdf}
|
||||
disabled={(looseAttachments.length === 0 && subDocuments.length === 0) || isMerging}
|
||||
onclick={downloadArchive}
|
||||
>
|
||||
{isMerging ? 'PDF wird erstellt' : 'PDF herunterladen'}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{#if mergeError}
|
||||
@@ -167,20 +400,55 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<ul class="flex gap-3 overflow-x-auto pb-1">
|
||||
{#each attachments as attachment, index (attachment.path)}
|
||||
<li
|
||||
class={`flex flex-col shrink-0 items-stretch gap-2 rounded-xl border text-primary bg-accent p-2 ${
|
||||
dropIndex === index ? 'border-primary-400 ring-1 ring-primary-200' : 'border-primary-100'
|
||||
} ${dragIndex === index ? 'opacity-60' : ''}`}
|
||||
style={`width: ${thumbnailWidth}px;`}
|
||||
draggable="true"
|
||||
ondragstart={(event) => handleDragStart(index, event)}
|
||||
ondragover={(event) => handleDragOver(index, event)}
|
||||
ondrop={(event) => handleDrop(index, event)}
|
||||
ondragend={handleDragEnd}
|
||||
{#if selectionMode && selectedPaths.size > 0}
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-3 rounded-xl border border-primary-200 bg-primary-50 px-4 py-2 text-[13px] font-medium text-primary-900"
|
||||
>
|
||||
<div class="flex min-w-0 flex-1 flex-row gap-2 py-1 items-baseline">
|
||||
<span>{selectedPaths.size} Datei{selectedPaths.size === 1 ? '' : 'en'} ausgewählt</span>
|
||||
<Button type="button" onclick={createSubDocumentFromSelection}>Teildokument erstellen</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<ul class="flex gap-3 overflow-x-auto pb-1">
|
||||
{#each looseAttachments as attachment, index (attachment.path)}
|
||||
<li
|
||||
class={cn(
|
||||
'flex flex-col shrink-0 items-stretch gap-2 rounded-xl border bg-accent p-2 text-primary transition',
|
||||
dropIndex === index ? 'border-primary-400 ring-1 ring-primary-200' : 'border-primary-100',
|
||||
dragIndex === index ? 'opacity-60' : '',
|
||||
selectedPaths.has(attachment.path) ? 'border-primary-500 ring-2 ring-primary-300' : ''
|
||||
)}
|
||||
style={`width: ${thumbnailWidth}px;`}
|
||||
draggable={selectionMode ? 'false' : 'true'}
|
||||
ondragstart={(event) => handleLooseDragStart(index, event)}
|
||||
ondragover={(event) => handleLooseDragOver(index, event)}
|
||||
ondrop={(event) => handleLooseDrop(index, event)}
|
||||
ondragend={handleLooseDragEnd}
|
||||
>
|
||||
{#if selectionMode}
|
||||
<label class="flex cursor-pointer flex-col gap-2">
|
||||
<div class="flex items-center gap-2 px-1 text-[13px] font-medium text-primary-900">
|
||||
<input
|
||||
class="h-4 w-4 accent-primary-700"
|
||||
type="checkbox"
|
||||
checked={selectedPaths.has(attachment.path)}
|
||||
onchange={() => toggleSelection(attachment.path)}
|
||||
/>
|
||||
<span class="truncate"
|
||||
>{selectedPaths.has(attachment.path) ? 'Ausgewählt' : 'Auswählen'}</span
|
||||
>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="truncate text-[13px] font-medium leading-tight text-primary-900"
|
||||
title={attachment.name}
|
||||
>
|
||||
{attachment.name}
|
||||
</div>
|
||||
<AttachmentPreview {attachment} />
|
||||
</label>
|
||||
{:else}
|
||||
<div class="flex min-w-0 flex-1 flex-row items-baseline gap-2 py-1">
|
||||
<button
|
||||
class="w-fit cursor-grab rounded-md border border-primary-200 bg-white px-2 py-1 text-sm font-semibold leading-none text-primary-700 active:cursor-grabbing"
|
||||
draggable="false"
|
||||
@@ -198,7 +466,37 @@
|
||||
</div>
|
||||
</div>
|
||||
<AttachmentPreview {attachment} />
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
{#if looseAttachments.length === 0 && subDocuments.length === 0}
|
||||
<div
|
||||
class="rounded-md border border-dashed border-primary-200 bg-primary-50 px-4 py-4 text-[13px] text-primary-700"
|
||||
>
|
||||
Keine Dateien in diesem Archiv. Lade ein anderes ZIP, um weiterzuarbeiten.
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if hasSubDocuments}
|
||||
<div class="flex flex-col gap-3">
|
||||
{#each subDocuments as subDocument, blockIndex (subDocument.id)}
|
||||
<SubDocumentEditor
|
||||
{subDocument}
|
||||
{blockIndex}
|
||||
{thumbnailWidth}
|
||||
isBlockDragSource={blockDragIndex === blockIndex}
|
||||
isBlockDropTarget={blockDropIndex === blockIndex && blockDragIndex !== blockIndex}
|
||||
onSubDocumentChange={handleSubDocumentChange}
|
||||
onRemove={() => dissolveSubDocumentBlock(subDocument.id)}
|
||||
onAttachmentMove={handleAttachmentMove}
|
||||
onBlockDragStart={handleBlockDragStart}
|
||||
onBlockDragOver={handleBlockDragOver}
|
||||
onBlockDrop={handleBlockDrop}
|
||||
onBlockDragEnd={handleBlockDragEnd}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
<script lang="ts">
|
||||
import AttachmentPreview from '$lib/components/AttachmentPreview.svelte';
|
||||
import type { AttachmentLocation, SubDocument, ZipAttachment } from '$lib/zip-processing';
|
||||
import { cn } from '$lib/utils';
|
||||
|
||||
type Props = {
|
||||
subDocument: SubDocument;
|
||||
blockIndex: number;
|
||||
thumbnailWidth: number;
|
||||
isBlockDragSource?: boolean;
|
||||
isBlockDropTarget?: boolean;
|
||||
onSubDocumentChange?: (next: SubDocument) => void;
|
||||
onRemove?: () => void;
|
||||
onAttachmentMove?: (source: AttachmentLocation, target: AttachmentLocation) => void;
|
||||
onBlockDragStart?: (blockIndex: number, event: DragEvent) => void;
|
||||
onBlockDragOver?: (blockIndex: number, event: DragEvent) => void;
|
||||
onBlockDrop?: (blockIndex: number, event: DragEvent) => void;
|
||||
onBlockDragEnd?: () => void;
|
||||
};
|
||||
|
||||
let {
|
||||
subDocument,
|
||||
blockIndex,
|
||||
thumbnailWidth = 200,
|
||||
isBlockDragSource = false,
|
||||
isBlockDropTarget = false,
|
||||
onSubDocumentChange = () => {},
|
||||
onRemove = () => {},
|
||||
onAttachmentMove = () => {},
|
||||
onBlockDragStart = () => {},
|
||||
onBlockDragOver = () => {},
|
||||
onBlockDrop = () => {},
|
||||
onBlockDragEnd = () => {}
|
||||
}: Props = $props();
|
||||
|
||||
let subDocumentName = $state('');
|
||||
let dragIndex = $state<number | null>(null);
|
||||
let dropIndex = $state<number | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
subDocumentName = subDocument.name;
|
||||
});
|
||||
|
||||
const emitChange = (overrides: Partial<SubDocument> = {}) => {
|
||||
onSubDocumentChange({
|
||||
...subDocument,
|
||||
name: subDocumentName,
|
||||
attachments: subDocument.attachments.map((attachment) => ({ ...attachment })),
|
||||
...overrides
|
||||
});
|
||||
};
|
||||
|
||||
const ATTACHMENT_MIME = 'application/x-juri-merger-attachment';
|
||||
const BLOCK_MIME = 'application/x-juri-merger-block';
|
||||
|
||||
const parseAttachmentPayload = (event: DragEvent): AttachmentLocation | null => {
|
||||
const raw = event.dataTransfer?.getData(ATTACHMENT_MIME);
|
||||
|
||||
if (!raw) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as AttachmentLocation;
|
||||
|
||||
if (parsed.kind === 'loose' || parsed.kind === 'subDocument') {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleCardDragStart = (index: number, event: DragEvent) => {
|
||||
dragIndex = index;
|
||||
dropIndex = index;
|
||||
|
||||
const source: AttachmentLocation = {
|
||||
kind: 'subDocument',
|
||||
id: subDocument.id,
|
||||
index
|
||||
};
|
||||
|
||||
if (event.dataTransfer) {
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
event.dataTransfer.setData(ATTACHMENT_MIME, JSON.stringify(source));
|
||||
// keep a text/plain fallback so the drag is not silently cancelled
|
||||
event.dataTransfer.setData('text/plain', String(index));
|
||||
}
|
||||
};
|
||||
|
||||
const handleCardDragOver = (index: number, event: DragEvent) => {
|
||||
if (event.dataTransfer?.types.includes(ATTACHMENT_MIME)) {
|
||||
event.preventDefault();
|
||||
dropIndex = index;
|
||||
}
|
||||
};
|
||||
|
||||
const handleCardDrop = (index: number, event: DragEvent) => {
|
||||
const source = parseAttachmentPayload(event);
|
||||
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const target: AttachmentLocation = {
|
||||
kind: 'subDocument',
|
||||
id: subDocument.id,
|
||||
index
|
||||
};
|
||||
|
||||
onAttachmentMove(source, target);
|
||||
dragIndex = null;
|
||||
dropIndex = null;
|
||||
};
|
||||
|
||||
const handleCardDragEnd = () => {
|
||||
dragIndex = null;
|
||||
dropIndex = null;
|
||||
};
|
||||
|
||||
const handleNameInput = (event: Event) => {
|
||||
subDocumentName = (event.currentTarget as HTMLInputElement).value;
|
||||
emitChange();
|
||||
};
|
||||
|
||||
const handleHeaderDragStart = (event: DragEvent) => {
|
||||
// do not start a block drag when the user grabbed the remove button or name input
|
||||
if (event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.dataTransfer) {
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
event.dataTransfer.setData(BLOCK_MIME, String(blockIndex));
|
||||
event.dataTransfer.setData('text/plain', String(blockIndex));
|
||||
}
|
||||
|
||||
onBlockDragStart(blockIndex, event);
|
||||
};
|
||||
|
||||
const handleHeaderDragOver = (event: DragEvent) => {
|
||||
if (event.dataTransfer?.types.includes(BLOCK_MIME)) {
|
||||
event.preventDefault();
|
||||
onBlockDragOver(blockIndex, event);
|
||||
}
|
||||
};
|
||||
|
||||
const handleHeaderDrop = (event: DragEvent) => {
|
||||
const raw = event.dataTransfer?.getData(BLOCK_MIME);
|
||||
|
||||
if (raw === undefined || raw === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
onBlockDrop(blockIndex, event);
|
||||
};
|
||||
|
||||
const attachments: ZipAttachment[] = $derived(subDocument.attachments);
|
||||
</script>
|
||||
|
||||
<section
|
||||
class={cn(
|
||||
'flex flex-col gap-3 rounded-xl border bg-primary-50/40 px-3 py-3 transition',
|
||||
isBlockDropTarget ? 'border-primary-400 ring-1 ring-primary-200' : 'border-primary-100',
|
||||
isBlockDragSource ? 'opacity-60' : ''
|
||||
)}
|
||||
>
|
||||
<header class="flex flex-wrap items-center gap-2 text-primary">
|
||||
<button
|
||||
class="w-fit cursor-grab rounded-md border border-primary-200 bg-white px-2 py-1 text-sm font-semibold leading-none text-primary-700 active:cursor-grabbing"
|
||||
draggable="true"
|
||||
type="button"
|
||||
aria-label="Teildokument verschieben"
|
||||
ondragstart={handleHeaderDragStart}
|
||||
ondragover={handleHeaderDragOver}
|
||||
ondrop={handleHeaderDrop}
|
||||
ondragend={onBlockDragEnd}
|
||||
>
|
||||
::
|
||||
</button>
|
||||
|
||||
<label class="block min-w-0 flex-1">
|
||||
<span class="sr-only">Teildokumentname</span>
|
||||
<input
|
||||
class="w-full max-w-md rounded-md border border-primary-200 bg-white px-3 py-1.5 text-[15px] font-semibold text-primary-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-200"
|
||||
type="text"
|
||||
value={subDocumentName}
|
||||
oninput={handleNameInput}
|
||||
draggable="false"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<span class="text-[13px] text-primary-700">
|
||||
{attachments.length} Datei{attachments.length === 1 ? '' : 'en'}
|
||||
</span>
|
||||
|
||||
<button
|
||||
class="rounded-md border border-primary-200 bg-white px-2 py-1 text-[13px] font-medium text-primary-700 transition hover:border-red-300 hover:bg-red-50 hover:text-red-700"
|
||||
type="button"
|
||||
onclick={onRemove}
|
||||
draggable="false"
|
||||
ondragstart={(event) => event.preventDefault()}
|
||||
>
|
||||
Auflösen
|
||||
</button>
|
||||
</header>
|
||||
|
||||
{#if attachments.length === 0}
|
||||
<ul
|
||||
class="flex items-center justify-center rounded-md border border-dashed border-primary-200 bg-white/60 px-4 py-6 text-[13px] text-primary-600"
|
||||
ondragover={(event) => {
|
||||
if (event.dataTransfer?.types.includes(ATTACHMENT_MIME)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}}
|
||||
ondrop={(event) => {
|
||||
const source = parseAttachmentPayload(event);
|
||||
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const target: AttachmentLocation = {
|
||||
kind: 'subDocument',
|
||||
id: subDocument.id,
|
||||
index: 0
|
||||
};
|
||||
|
||||
onAttachmentMove(source, target);
|
||||
dragIndex = null;
|
||||
dropIndex = null;
|
||||
}}
|
||||
>
|
||||
<li class="w-full text-center">
|
||||
Dieses Teildokument ist leer. Ziehe Dateien hierher, um sie hinzuzufügen.
|
||||
</li>
|
||||
</ul>
|
||||
{:else}
|
||||
<ul class="flex gap-3 overflow-x-auto pb-1">
|
||||
{#each attachments as attachment, index (attachment.path)}
|
||||
<li
|
||||
class={cn(
|
||||
'flex flex-col shrink-0 items-stretch gap-2 rounded-xl border bg-accent p-2 text-primary',
|
||||
dropIndex === index
|
||||
? 'border-primary-400 ring-1 ring-primary-200'
|
||||
: 'border-primary-100',
|
||||
dragIndex === index ? 'opacity-60' : ''
|
||||
)}
|
||||
style={`width: ${thumbnailWidth}px;`}
|
||||
draggable="true"
|
||||
ondragstart={(event) => handleCardDragStart(index, event)}
|
||||
ondragover={(event) => handleCardDragOver(index, event)}
|
||||
ondrop={(event) => handleCardDrop(index, event)}
|
||||
ondragend={handleCardDragEnd}
|
||||
>
|
||||
<div class="flex min-w-0 flex-1 flex-row items-baseline gap-2 py-1">
|
||||
<button
|
||||
class="w-fit cursor-grab rounded-md border border-primary-200 bg-white px-2 py-1 text-sm font-semibold leading-none text-primary-700 active:cursor-grabbing"
|
||||
draggable="false"
|
||||
type="button"
|
||||
aria-label="Datei verschieben"
|
||||
>
|
||||
::
|
||||
</button>
|
||||
|
||||
<div
|
||||
class="truncate text-[13px] font-medium leading-tight text-primary-900"
|
||||
title={attachment.name}
|
||||
>
|
||||
{attachment.name}
|
||||
</div>
|
||||
</div>
|
||||
<AttachmentPreview {attachment} />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</section>
|
||||
+336
-6
@@ -12,11 +12,33 @@ export type ZipAttachment = {
|
||||
data: Uint8Array;
|
||||
};
|
||||
|
||||
export type ProcessedZipArchive = {
|
||||
export type SubDocument = {
|
||||
id: string;
|
||||
name: string;
|
||||
attachments: ZipAttachment[];
|
||||
};
|
||||
|
||||
export type ProcessedZipArchive = {
|
||||
name: string;
|
||||
attachments: ZipAttachment[];
|
||||
subDocuments: SubDocument[];
|
||||
};
|
||||
|
||||
export type ExportMode = 'single' | 'separate';
|
||||
|
||||
export type ExportUnit = {
|
||||
name: string;
|
||||
bytes: Uint8Array;
|
||||
};
|
||||
|
||||
/**
|
||||
* Drag source/target descriptors shared between the archive editor and the
|
||||
* sub-document editor so HTML5 `dataTransfer` payloads stay consistent.
|
||||
*/
|
||||
export type AttachmentLocation =
|
||||
| { kind: 'loose'; index: number }
|
||||
| { kind: 'subDocument'; id: string; index: number };
|
||||
|
||||
const IMAGE_EXTENSIONS = new Set([
|
||||
'.avif',
|
||||
'.bmp',
|
||||
@@ -172,7 +194,8 @@ const extractZipEntries = async (archiveBytes: Uint8Array): Promise<ProcessedZip
|
||||
if (orderedAttachments.length > 0) {
|
||||
archives.push({
|
||||
name: archiveName,
|
||||
attachments: orderedAttachments
|
||||
attachments: orderedAttachments,
|
||||
subDocuments: []
|
||||
});
|
||||
}
|
||||
|
||||
@@ -283,16 +306,323 @@ const mergeAttachmentIntoPdf = async (mergedPdf: PDFDocument, attachment: ZipAtt
|
||||
}
|
||||
};
|
||||
|
||||
export const mergeProcessedZipArchive = async (archive: ProcessedZipArchive) => {
|
||||
if (archive.attachments.length === 0) {
|
||||
throw new Error('Cannot create a PDF from an empty archive.');
|
||||
export const mergeAttachments = async (attachments: ZipAttachment[]): Promise<Uint8Array> => {
|
||||
if (attachments.length === 0) {
|
||||
throw new Error('Cannot create a PDF from an empty attachment list.');
|
||||
}
|
||||
|
||||
const mergedPdf = await PDFDocument.create();
|
||||
|
||||
for (const attachment of archive.attachments) {
|
||||
for (const attachment of attachments) {
|
||||
await mergeAttachmentIntoPdf(mergedPdf, attachment);
|
||||
}
|
||||
|
||||
return mergedPdf.save();
|
||||
};
|
||||
|
||||
export const mergeProcessedZipArchive = async (archive: ProcessedZipArchive) => {
|
||||
if (archive.attachments.length === 0 && archive.subDocuments.length === 0) {
|
||||
throw new Error('Cannot create a PDF from an empty archive.');
|
||||
}
|
||||
|
||||
return mergeAttachments(flattenArchiveForMerge(archive));
|
||||
};
|
||||
|
||||
/**
|
||||
* Flatten the archive into a single ordered attachment list, preserving
|
||||
* sub-document order first and appending loose attachments at the end.
|
||||
*/
|
||||
export const flattenArchiveForMerge = (archive: ProcessedZipArchive): ZipAttachment[] => {
|
||||
const ordered: ZipAttachment[] = [];
|
||||
|
||||
for (const subDocument of archive.subDocuments) {
|
||||
ordered.push(...subDocument.attachments);
|
||||
}
|
||||
|
||||
ordered.push(...archive.attachments);
|
||||
|
||||
return ordered;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new sub-document with a stable id from a list of attachments.
|
||||
*/
|
||||
export const createSubDocument = (name: string, attachments: ZipAttachment[]): SubDocument => ({
|
||||
id: crypto.randomUUID(),
|
||||
name,
|
||||
attachments: attachments.map((attachment) => ({ ...attachment }))
|
||||
});
|
||||
|
||||
/**
|
||||
* Reorder sub-documents inside an archive. Matches the semantics of a single
|
||||
* `splice(fromIndex, 1)` -> `splice(toIndex, 0, moved)` move.
|
||||
*/
|
||||
export const moveSubDocument = (
|
||||
archive: ProcessedZipArchive,
|
||||
fromIndex: number,
|
||||
toIndex: number
|
||||
): ProcessedZipArchive => {
|
||||
if (
|
||||
fromIndex === toIndex ||
|
||||
fromIndex < 0 ||
|
||||
toIndex < 0 ||
|
||||
fromIndex >= archive.subDocuments.length ||
|
||||
toIndex >= archive.subDocuments.length
|
||||
) {
|
||||
return archive;
|
||||
}
|
||||
|
||||
const nextSubDocuments = [...archive.subDocuments];
|
||||
const [movedSubDocument] = nextSubDocuments.splice(fromIndex, 1);
|
||||
|
||||
nextSubDocuments.splice(toIndex, 0, movedSubDocument);
|
||||
|
||||
return { ...archive, subDocuments: nextSubDocuments };
|
||||
};
|
||||
|
||||
const removeAt = <T>(list: T[], index: number): T | null => {
|
||||
if (index < 0 || index >= list.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [item] = list.splice(index, 1);
|
||||
|
||||
return item ?? null;
|
||||
};
|
||||
|
||||
const insertAt = <T>(list: T[], index: number, item: T) => {
|
||||
const clampedIndex = Math.max(0, Math.min(index, list.length));
|
||||
list.splice(clampedIndex, 0, item);
|
||||
};
|
||||
|
||||
/**
|
||||
* Reorder an attachment within its current location (loose list or a single
|
||||
* sub-document's attachment list). Used by the per-list drag handlers.
|
||||
*/
|
||||
export const moveAttachmentInPlace = (
|
||||
archive: ProcessedZipArchive,
|
||||
location: AttachmentLocation,
|
||||
toIndex: number
|
||||
): ProcessedZipArchive => {
|
||||
if (location.kind === 'loose') {
|
||||
const nextAttachments = [...archive.attachments];
|
||||
const moved = removeAt(nextAttachments, location.index);
|
||||
|
||||
if (!moved) {
|
||||
return archive;
|
||||
}
|
||||
|
||||
insertAt(nextAttachments, toIndex, moved);
|
||||
|
||||
return { ...archive, attachments: nextAttachments };
|
||||
}
|
||||
|
||||
let changed = false;
|
||||
|
||||
const nextSubDocuments = archive.subDocuments.map((subDocument) => {
|
||||
if (subDocument.id !== location.id) {
|
||||
return subDocument;
|
||||
}
|
||||
|
||||
const nextAttachments = [...subDocument.attachments];
|
||||
const moved = removeAt(nextAttachments, location.index);
|
||||
|
||||
if (!moved) {
|
||||
return subDocument;
|
||||
}
|
||||
|
||||
insertAt(nextAttachments, toIndex, moved);
|
||||
changed = true;
|
||||
|
||||
return { ...subDocument, attachments: nextAttachments };
|
||||
});
|
||||
|
||||
return changed ? { ...archive, subDocuments: nextSubDocuments } : archive;
|
||||
};
|
||||
|
||||
/**
|
||||
* Move an attachment from a source location to a target location. Either side
|
||||
* may be the loose list or any sub-document. The attachment moves (not copies),
|
||||
* so the total attachment count is invariant. When source and target point to
|
||||
* the same list, this degenerates to an in-place reorder (explicitly delegated
|
||||
* to `moveAttachmentInPlace` so the indices are normalized correctly).
|
||||
*/
|
||||
export const moveAttachmentIntoSubDocument = (
|
||||
archive: ProcessedZipArchive,
|
||||
source: AttachmentLocation,
|
||||
target: AttachmentLocation
|
||||
): ProcessedZipArchive => {
|
||||
const sameList =
|
||||
source.kind === 'loose' && target.kind === 'loose'
|
||||
? true
|
||||
: source.kind === 'subDocument' && target.kind === 'subDocument'
|
||||
? source.id === target.id
|
||||
: false;
|
||||
|
||||
if (sameList) {
|
||||
return moveAttachmentInPlace(archive, source, target.index);
|
||||
}
|
||||
|
||||
const nextSubDocuments = archive.subDocuments.map((subDocument) => ({
|
||||
...subDocument,
|
||||
attachments: [...subDocument.attachments]
|
||||
}));
|
||||
const looseAttachments = [...archive.attachments];
|
||||
|
||||
const removeFromList = (location: AttachmentLocation): ZipAttachment | null => {
|
||||
if (location.kind === 'loose') {
|
||||
return removeAt(looseAttachments, location.index);
|
||||
}
|
||||
|
||||
const target_ = nextSubDocuments.find((item) => item.id === location.id);
|
||||
|
||||
return target_ ? removeAt(target_.attachments, location.index) : null;
|
||||
};
|
||||
|
||||
const insertIntoList = (attachment: ZipAttachment, location: AttachmentLocation) => {
|
||||
if (location.kind === 'loose') {
|
||||
insertAt(looseAttachments, location.index, attachment);
|
||||
return;
|
||||
}
|
||||
|
||||
const target_ = nextSubDocuments.find((item) => item.id === location.id);
|
||||
|
||||
if (!target_) {
|
||||
// fall back to loose list end if the referenced sub-document vanished
|
||||
looseAttachments.push(attachment);
|
||||
return;
|
||||
}
|
||||
|
||||
insertAt(target_.attachments, location.index, attachment);
|
||||
};
|
||||
|
||||
const movedAttachment = removeFromList(source);
|
||||
|
||||
if (!movedAttachment) {
|
||||
return archive;
|
||||
}
|
||||
|
||||
insertIntoList(movedAttachment, target);
|
||||
|
||||
return {
|
||||
...archive,
|
||||
attachments: looseAttachments,
|
||||
subDocuments: nextSubDocuments
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a single attachment from a sub-document and return it to the end of
|
||||
* the loose list. Useful as a targeted "move back to loose" action.
|
||||
*/
|
||||
export const removeAttachmentFromSubDocument = (
|
||||
archive: ProcessedZipArchive,
|
||||
subDocumentId: string,
|
||||
attachmentIndex: number
|
||||
): ProcessedZipArchive => {
|
||||
const nextSubDocuments = archive.subDocuments.map((subDocument) => ({
|
||||
...subDocument,
|
||||
attachments: [...subDocument.attachments]
|
||||
}));
|
||||
const nextLooseAttachments = [...archive.attachments];
|
||||
|
||||
const target_ = nextSubDocuments.find((item) => item.id === subDocumentId);
|
||||
|
||||
if (!target_) {
|
||||
return archive;
|
||||
}
|
||||
|
||||
const moved = removeAt(target_.attachments, attachmentIndex);
|
||||
|
||||
if (!moved) {
|
||||
return archive;
|
||||
}
|
||||
|
||||
nextLooseAttachments.push(moved);
|
||||
|
||||
return {
|
||||
...archive,
|
||||
attachments: nextLooseAttachments,
|
||||
subDocuments: nextSubDocuments
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove an entire sub-document and return its attachments to the end of the
|
||||
* loose list. The sub-document ids of the remaining sub-documents are
|
||||
* preserved.
|
||||
*/
|
||||
export const dissolveSubDocument = (
|
||||
archive: ProcessedZipArchive,
|
||||
subDocumentId: string
|
||||
): ProcessedZipArchive => {
|
||||
const dissolved = archive.subDocuments.find((item) => item.id === subDocumentId);
|
||||
|
||||
if (!dissolved) {
|
||||
return archive;
|
||||
}
|
||||
|
||||
return {
|
||||
...archive,
|
||||
attachments: [...archive.attachments, ...dissolved.attachments],
|
||||
subDocuments: archive.subDocuments.filter((item) => item.id !== subDocumentId)
|
||||
};
|
||||
};
|
||||
|
||||
const stripPdfExtension = (name: string) =>
|
||||
name.toLowerCase().endsWith('.pdf') ? name.slice(0, -'.pdf'.length) : name;
|
||||
|
||||
/**
|
||||
* Build one or more PDF export units from the archive.
|
||||
*
|
||||
* - `mode: 'single'` mirrors today's behaviour: one merged PDF covering
|
||||
* sub-documents first, then loose attachments, named after the archive.
|
||||
* - `mode: 'separate'` produces one PDF per sub-document (named
|
||||
* `{archiveName} - {subDocumentName}.pdf`) plus a single merged PDF for any
|
||||
* loose attachments (named after the archive). Empty groups are skipped.
|
||||
*/
|
||||
export const buildArchiveExport = async (
|
||||
archive: ProcessedZipArchive,
|
||||
mode: ExportMode
|
||||
): Promise<ExportUnit[]> => {
|
||||
if (mode === 'single') {
|
||||
const attachments = flattenArchiveForMerge(archive);
|
||||
|
||||
if (attachments.length === 0) {
|
||||
throw new Error('Cannot create a PDF from an empty archive.');
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
name: stripPdfExtension(archive.name),
|
||||
bytes: await mergeAttachments(attachments)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
const separateUnits: ExportUnit[] = [];
|
||||
|
||||
for (const subDocument of archive.subDocuments) {
|
||||
if (subDocument.attachments.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
separateUnits.push({
|
||||
name: `${stripPdfExtension(archive.name)} - ${stripPdfExtension(subDocument.name)}`,
|
||||
bytes: await mergeAttachments(subDocument.attachments)
|
||||
});
|
||||
}
|
||||
|
||||
if (archive.attachments.length > 0) {
|
||||
separateUnits.push({
|
||||
name: stripPdfExtension(archive.name),
|
||||
bytes: await mergeAttachments(archive.attachments)
|
||||
});
|
||||
}
|
||||
|
||||
if (separateUnits.length === 0) {
|
||||
throw new Error('Cannot create a PDF from an empty archive.');
|
||||
}
|
||||
|
||||
return separateUnits;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker login to Gitea Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ vars.REGISTRY_URL }}" \
|
||||
-u "${{ secrets.REGISTRY_USER }}" \
|
||||
--password-stdin
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build \
|
||||
-t "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:dev" \
|
||||
-t "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:${{ gitea.sha }}" \
|
||||
.
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker push "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:dev"
|
||||
docker push "${{ vars.REGISTRY_URL }}/${{ vars.IMAGE_NAME }}:${{ gitea.sha }}"
|
||||
|
||||
- name: Deploy
|
||||
run: |
|
||||
curl https://dokploy.robosoft-solutions.de/api/deploy/compose/Miw8GJXF_v4Ebavr3mJwa
|
||||
+1
-4
@@ -1,5 +1,5 @@
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
import adapter from '@sveltejs/adapter-node';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
@@ -13,9 +13,6 @@ export default defineConfig({
|
||||
filename.split(/[/\\]/).includes('node_modules') ? undefined : true
|
||||
},
|
||||
|
||||
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
||||
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
||||
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
||||
adapter: adapter()
|
||||
})
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user