feat(ctxmenu): unify row context menu via shared partial (_ctx_menu.html) for library+workspace; keep data-cfasync=false on page_editor_scripts

This commit is contained in:
2026-09-11 21:24:01 -04:00
parent cef01dffaf
commit fbc8d657e7
4 changed files with 187 additions and 97 deletions
+20 -40
View File
@@ -363,45 +363,7 @@
</div>
</div>
<!-- ── Row context menu ── -->
<div class="more-menu" x-show="ctxMenuItem" @click.outside="ctxMenuItem=null" x-transition
:style="'top:' + ctxMenuY + 'px;left:' + ctxMenuX + 'px;'">
<template x-if="ctxMenuItem">
<div>
<div class="menu-item" @click="openItem(ctxMenuItem); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
Open
</div>
<div class="menu-item" @click="openPeek(ctxMenuItem); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="15" y1="3" x2="15" y2="21"/></svg>
Open in side peek
</div>
<div class="menu-item" @click="startRename(ctxMenuItem); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.12 2.12 0 013 3L12 15l-4 1 1-4z"/></svg>
Rename
</div>
<div class="menu-item" @click="toggleFavoriteItem(ctxMenuItem); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>
<span x-text="ctxMenuItem.favorited ? 'Remove from Favorites' : 'Add to Favorites'"></span>
</div>
<div class="menu-item" @click="duplicateItem(ctxMenuItem); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
Duplicate
</div>
<div class="menu-item" @click="copyLink(ctxMenuItem); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>
Copy link
</div>
<div class="menu-item" @click="openMovePicker([ctxMenuItem.id]); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg>
Move to
</div>
<div class="more-sep"></div>
<div class="menu-item menu-danger" @click="deleteItem(ctxMenuItem); ctxMenuItem=null">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"/><path d="M10 11v6M14 11v6"/></svg>
Move to Trash
</div>
</div>
{% include "_ctx_menu.html" %}
</template>
</div>
@@ -711,7 +673,25 @@ function libraryPage() {
evt.preventDefault();
var item = this._findItem(id);
if (!item) return;
this.ctxMenuItem = item;
/* MENU UNIFIÉ (partial _ctx_menu.html + store fdCtx) — handlers library
complète l'union (8 items). Open folder/tags non prévus côté library :
fdCtx les cache automatiquement via handlers absents. */
var handlers = {
open: function (n) { libraryPage().openItem(n); },
peek: function (n) { libraryPage().openPeek(n); },
rename: function (n) { libraryPage().startRename(n); },
fav: function (n) { libraryPage().toggleFavoriteItem(n); },
duplicate: function (n) { libraryPage().duplicateItem(n); },
link: function (n) { libraryPage().copyLink(n); },
move: function (n) { libraryPage().openMovePicker([n.id]); },
del: function (n) { libraryPage().deleteItem(n); }
};
var self = this;
if (window.Alpine && Alpine.store('fdCtx')) {
Alpine.store('fdCtx').open(evt, item, 'library', handlers);
Alpine.store('fdCtx').closeMenu = function () { ctxMenuItem = null; };
}
this.ctxMenuItem = item parallels ?? null;
this.ctxMenuX = Math.min(evt.clientX, window.innerWidth - 220);
this.ctxMenuY = Math.min(evt.clientY, window.innerHeight - 320);
},