md-lv 1.1.2 → 1.2.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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.0] - 2026-01-25
9
+
10
+ ### Added
11
+
12
+ - **Copy Filename Button**: Added a button next to the current filename in breadcrumbs to copy the filename to clipboard
13
+
8
14
  ## [2.0.0] - 2026-01-25
9
15
 
10
16
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-lv",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Serve Markdown files as HTML with live features - syntax highlighting, Mermaid diagrams, and MathJax formulas",
5
5
  "type": "module",
6
6
  "engines": {
@@ -7,6 +7,7 @@ document.addEventListener('DOMContentLoaded', () => {
7
7
  initKeyboardNavigation();
8
8
  initDirectoryListNavigation();
9
9
  initBackToTop();
10
+ initCopyFilename();
10
11
  });
11
12
 
12
13
  /**
@@ -181,6 +182,71 @@ function initBackToTop() {
181
182
  });
182
183
  }
183
184
 
185
+ /**
186
+ * ファイル名コピーボタンを初期化
187
+ */
188
+ function initCopyFilename() {
189
+ const breadcrumbs = document.getElementById('breadcrumbs');
190
+ if (!breadcrumbs) return;
191
+
192
+ const currentSpan = breadcrumbs.querySelector('.current');
193
+ if (!currentSpan) return;
194
+
195
+ const filename = currentSpan.textContent.trim();
196
+ if (!filename) return;
197
+
198
+ // コピーボタンを作成
199
+ const copyButton = document.createElement('button');
200
+ copyButton.id = 'copy-filename';
201
+ copyButton.type = 'button';
202
+ copyButton.title = 'Copy filename';
203
+ copyButton.setAttribute('aria-label', 'Copy filename');
204
+ copyButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>`;
205
+
206
+ // currentSpanの後にボタンを挿入
207
+ currentSpan.insertAdjacentElement('afterend', copyButton);
208
+
209
+ // クリックイベント
210
+ copyButton.addEventListener('click', async (e) => {
211
+ e.preventDefault();
212
+ e.stopPropagation();
213
+
214
+ try {
215
+ await navigator.clipboard.writeText(filename);
216
+ showCopySuccess(copyButton);
217
+ } catch (err) {
218
+ // フォールバック: execCommandを使用
219
+ const textArea = document.createElement('textarea');
220
+ textArea.value = filename;
221
+ textArea.style.position = 'fixed';
222
+ textArea.style.left = '-9999px';
223
+ document.body.appendChild(textArea);
224
+ textArea.select();
225
+ try {
226
+ document.execCommand('copy');
227
+ showCopySuccess(copyButton);
228
+ } catch (e) {
229
+ console.error('Copy failed:', e);
230
+ }
231
+ document.body.removeChild(textArea);
232
+ }
233
+ });
234
+ }
235
+
236
+ /**
237
+ * コピー成功時のフィードバック表示
238
+ */
239
+ function showCopySuccess(button) {
240
+ const originalHTML = button.innerHTML;
241
+ button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>`;
242
+ button.classList.add('copied');
243
+
244
+ setTimeout(() => {
245
+ button.innerHTML = originalHTML;
246
+ button.classList.remove('copied');
247
+ }, 1500);
248
+ }
249
+
184
250
  /**
185
251
  * 入力フィールドにフォーカスがあるかチェック
186
252
  */
@@ -89,6 +89,41 @@ a:hover {
89
89
  font-weight: 500;
90
90
  }
91
91
 
92
+ /* Copy Filename Button */
93
+ #copy-filename {
94
+ display: inline-flex;
95
+ align-items: center;
96
+ justify-content: center;
97
+ margin-left: 8px;
98
+ padding: 4px 6px;
99
+ background-color: transparent;
100
+ border: 1px solid var(--color-border);
101
+ border-radius: 4px;
102
+ color: var(--color-text-muted);
103
+ cursor: pointer;
104
+ transition: all var(--transition-fast);
105
+ vertical-align: middle;
106
+ }
107
+
108
+ #copy-filename:hover {
109
+ background-color: var(--color-bg);
110
+ border-color: var(--color-border-strong);
111
+ color: var(--color-text);
112
+ }
113
+
114
+ #copy-filename:active {
115
+ transform: scale(0.95);
116
+ }
117
+
118
+ #copy-filename.copied {
119
+ color: var(--color-success);
120
+ border-color: var(--color-success);
121
+ }
122
+
123
+ #copy-filename svg {
124
+ display: block;
125
+ }
126
+
92
127
  /* ============================================
93
128
  Code Blocks Enhancement
94
129
  ============================================ */