repoview 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repoview",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "GitHub-like repo browsing for local Git repositories (Markdown, live reload, broken link scanner).",
package/public/app.css CHANGED
@@ -743,6 +743,24 @@ a {
743
743
  text-decoration: underline;
744
744
  }
745
745
 
746
+ .diff-copy-btn {
747
+ display: inline-flex;
748
+ align-items: center;
749
+ justify-content: center;
750
+ margin-left: 6px;
751
+ padding: 2px;
752
+ border: none;
753
+ background: none;
754
+ color: var(--muted);
755
+ cursor: pointer;
756
+ border-radius: 3px;
757
+ vertical-align: middle;
758
+ }
759
+ .diff-copy-btn:hover {
760
+ color: var(--accent);
761
+ background: var(--btnHover);
762
+ }
763
+
746
764
  .d2h-file-header .d2h-tag {
747
765
  font-size: 11px;
748
766
  padding: 2px 6px;
package/public/app.js CHANGED
@@ -180,6 +180,17 @@ function initTimezoneToggle() {
180
180
  update();
181
181
  }
182
182
 
183
+ function fallbackCopy(text) {
184
+ const ta = document.createElement("textarea");
185
+ ta.value = text;
186
+ ta.style.position = "fixed";
187
+ ta.style.opacity = "0";
188
+ document.body.appendChild(ta);
189
+ ta.select();
190
+ document.execCommand("copy");
191
+ document.body.removeChild(ta);
192
+ }
193
+
183
194
  function initDiffCollapse() {
184
195
  const wrappers = document.querySelectorAll(".d2h-file-wrapper");
185
196
  if (!wrappers.length) return;
@@ -213,6 +224,34 @@ function initDiffCollapse() {
213
224
  link.textContent = rawName;
214
225
  fileNameEl.textContent = "";
215
226
  fileNameEl.appendChild(link);
227
+
228
+ const copyBtn = document.createElement("button");
229
+ copyBtn.className = "diff-copy-btn";
230
+ copyBtn.type = "button";
231
+ copyBtn.setAttribute("aria-label", "Copy filename");
232
+ copyBtn.innerHTML =
233
+ '<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">' +
234
+ '<rect x="5" y="5" width="9" height="9" rx="1.5"/>' +
235
+ '<path d="M3 11V2.5A1.5 1.5 0 0 1 4.5 1H11"/>' +
236
+ "</svg>";
237
+ const svgIcon = copyBtn.innerHTML;
238
+ copyBtn.addEventListener("click", (e) => {
239
+ e.stopPropagation();
240
+ const showSuccess = () => {
241
+ copyBtn.textContent = "\u2713";
242
+ setTimeout(() => { copyBtn.innerHTML = svgIcon; }, 1500);
243
+ };
244
+ if (navigator.clipboard?.writeText) {
245
+ navigator.clipboard.writeText(name).then(showSuccess).catch(() => {
246
+ fallbackCopy(name);
247
+ showSuccess();
248
+ });
249
+ } else {
250
+ fallbackCopy(name);
251
+ showSuccess();
252
+ }
253
+ });
254
+ fileNameEl.appendChild(copyBtn);
216
255
  }
217
256
 
218
257
  const toggle = document.createElement("button");