MCPcopy
hub / github.com/stemdeckapp/stemdeck / wireRailLibraryDrop

Function wireRailLibraryDrop

static/js/catalog.js:881–904  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

879}
880
881function wireRailLibraryDrop() {
882 const btn = document.querySelector(".rail-library");
883 if (!btn || btn.dataset.dropReady === "1") return;
884 btn.dataset.dropReady = "1";
885
886 btn.addEventListener("dragover", (e) => {
887 if (!isTrackDragEvent(e) || catalogView !== "trash") return;
888 e.preventDefault();
889 e.dataTransfer.dropEffect = "move";
890 btn.classList.add("drop-target");
891 });
892 btn.addEventListener("dragleave", (e) => {
893 if (!btn.contains(e.relatedTarget)) btn.classList.remove("drop-target");
894 });
895 btn.addEventListener("drop", (e) => {
896 btn.classList.remove("drop-target");
897 if (catalogView !== "trash") return;
898 const trackId = getDraggedTrackId(e);
899 if (!trackId || !tracks[trackId]) return;
900 e.preventDefault();
901 restoreTrackFromTrash(trackId);
902 setCatalogView("library");
903 });
904}
905
906function isTextEditingTarget(target) {
907 return Boolean(target?.closest?.("input, textarea, select, [contenteditable='true'], .folder-editor"));

Callers 1

initCatalogFunction · 0.85

Calls 4

isTrackDragEventFunction · 0.85
getDraggedTrackIdFunction · 0.85
restoreTrackFromTrashFunction · 0.85
setCatalogViewFunction · 0.85

Tested by

no test coverage detected