feat(index): paste photos and project files from clipboard with Ctrl+V

- handle document paste: images become the entry photo when none is set,
  otherwise they land in "Файлы проекта" along with any other pasted files
- take file names from the clipboard, replace generic ones (image.png, blob)
  with "Вставка <date>.<ext>"; derive extension from MIME when missing
- validate client-side like the server: 10 files, 10 MB per file, 30 MB total,
  reject blocked extensions (*.html, *.js, *.svg, ...)
- share the limit logic between the picker and paste, send the photo under its
  real name so pasted PNG/JPEG keep their extension
- add Ctrl+V hints to the photo and files cards (hidden on touch devices)
This commit is contained in:
dev
2026-09-24 11:18:08 +03:00
parent 2e1d36bc4d
commit a72600af13
2 changed files with 123 additions and 6 deletions
+5
View File
@@ -39,6 +39,9 @@ h1{font-size:1.5rem;font-weight:600;margin-bottom:8px;letter-spacing:-.02em;text
.files-list .file-row .f-size{color:var(--muted);flex-shrink:0}
.files-list .file-row button{background:none;border:none;color:var(--muted);cursor:pointer;font-size:.85rem;padding:0 2px;flex-shrink:0}
.files-list .file-row button:hover{color:#ef4444}
.paste-hint{font-size:.75rem;color:var(--muted);line-height:1.35;text-align:center}
.files-card .paste-hint{text-align:left}
@media(hover:none){.paste-hint{display:none}}
.preview-wrap{width:100%;display:flex;flex-direction:column;align-items:center;gap:8px}
.preview{max-width:100%;width:100%;aspect-ratio:4/3;object-fit:cover;border-radius:var(--radius);background:var(--card);display:block;border:1px dashed var(--border)}
.preview.has-photo{border-style:solid}
@@ -110,6 +113,7 @@ nav a:hover{color:var(--text)}
<div class="photo-btns">
<button type="button" class="cam" id="openCamBtn">Камера</button>
</div>
<p class="paste-hint" id="photoPasteHint">Ctrl+V — вставить фото из буфера</p>
</div>
<div class="files-card">
<div class="files-head">
@@ -118,6 +122,7 @@ nav a:hover{color:var(--text)}
</div>
<button type="button" class="files-btn" id="filesBtn">Выбрать файлы</button>
<input type="file" id="filesInput" multiple hidden>
<p class="paste-hint">Ctrl+V — вставить файлы из буфера</p>
<div class="files-list" id="filesList"></div>
</div>
</div>