feat: add download + copy file content to context menus and editor
- Add /api/pages/{id}/download and /api/pages/{id}/file-content endpoints
- Add Download + Copy content to shared context menu (_ctx_menu.html)
- Wire handlers in local-workspace and library context menus
- Add Download + Copy content to editor '...' menu for file pages
- Multi-block selection copy/cut/paste with Ctrl+C/X/V shortcuts
- Align page title with blocks start (CSS pseudo-element offset)
This commit is contained in:
@@ -718,6 +718,8 @@ function libraryPage() {
|
||||
setIcon: function (icon) { self.setItemIcon(item, icon); },
|
||||
duplicate: function (n) { self.duplicateItem(n); },
|
||||
link: function (n) { self.copyLink(n); },
|
||||
download: function (n) { self.downloadItem(n); },
|
||||
copyContent: function (n) { self.copyItemContent(n); },
|
||||
move: function (n) { self.openMovePicker([n.id]); },
|
||||
fav: function (n) { self.toggleFavoriteItem(n); },
|
||||
delete: function (n) { self.deleteItem(n); },
|
||||
@@ -731,6 +733,34 @@ function libraryPage() {
|
||||
store.openMenu(evt, item, 'library', handlers);
|
||||
},
|
||||
|
||||
downloadItem(node) {
|
||||
if (!node || node.is_folder) return;
|
||||
var url = '/api/pages/' + node.id + '/download';
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
if (window.showToast) window.showToast('Download started', 'success');
|
||||
},
|
||||
|
||||
async copyItemContent(node) {
|
||||
if (!node || node.is_folder) return;
|
||||
try {
|
||||
var r = await fetch('/api/pages/' + node.id + '/file-content');
|
||||
var d = await r.json();
|
||||
if (d.ok && d.content !== undefined) {
|
||||
await navigator.clipboard.writeText(d.content);
|
||||
if (window.showToast) window.showToast('Content copied to clipboard', 'success');
|
||||
} else {
|
||||
if (window.showToast) window.showToast('Not a text file', 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
if (window.showToast) window.showToast('Copy failed', 'error');
|
||||
}
|
||||
},
|
||||
|
||||
// ── Drag & drop (move / reparent) ──
|
||||
onRowDragStart(evt, id) {
|
||||
if (!evt.target.closest('.drag-handle')) { evt.preventDefault(); return; }
|
||||
|
||||
Reference in New Issue
Block a user