improvemtns again, to the archetype builder, and playback
This commit is contained in:
@@ -5,6 +5,25 @@ import { useAuth } from "../auth/AuthContext";
|
||||
import ConfirmDialog from "../components/ConfirmDialog";
|
||||
import SpeedCalculatorModal from "./SpeedCalculatorModal";
|
||||
import PlaybackModal from "./PlaybackModal";
|
||||
|
||||
function fallbackCopy(text, onSuccess) {
|
||||
const ta = document.createElement("textarea");
|
||||
ta.value = text;
|
||||
ta.style.cssText = "position:fixed;top:0;left:0;opacity:0";
|
||||
document.body.appendChild(ta);
|
||||
ta.focus();
|
||||
ta.select();
|
||||
try { document.execCommand("copy"); onSuccess?.(); } catch (_) {}
|
||||
document.body.removeChild(ta);
|
||||
}
|
||||
|
||||
function copyText(text, onSuccess) {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(text).then(onSuccess).catch(() => fallbackCopy(text, onSuccess));
|
||||
} else {
|
||||
fallbackCopy(text, onSuccess);
|
||||
}
|
||||
}
|
||||
import {
|
||||
getLocalizedValue,
|
||||
getLanguageName,
|
||||
@@ -415,12 +434,7 @@ export default function MelodyDetail() {
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(builtMelody.progmem_code).then(() => {
|
||||
setCodeCopied(true);
|
||||
setTimeout(() => setCodeCopied(false), 2000);
|
||||
});
|
||||
}}
|
||||
onClick={() => copyText(builtMelody.progmem_code, () => { setCodeCopied(true); setTimeout(() => setCodeCopied(false), 2000); })}
|
||||
className="px-3 py-1.5 text-xs rounded transition-colors"
|
||||
style={{
|
||||
backgroundColor: codeCopied ? "var(--success-bg)" : "var(--bg-card-hover)",
|
||||
@@ -453,6 +467,7 @@ export default function MelodyDetail() {
|
||||
melody={melody}
|
||||
builtMelody={builtMelody}
|
||||
files={files}
|
||||
archetypeCsv={melody?.information?.archetype_csv || null}
|
||||
onClose={() => setShowPlayback(false)}
|
||||
/>
|
||||
|
||||
@@ -460,6 +475,7 @@ export default function MelodyDetail() {
|
||||
open={showSpeedCalc}
|
||||
melody={melody}
|
||||
builtMelody={builtMelody}
|
||||
archetypeCsv={melody?.information?.archetype_csv || null}
|
||||
onClose={() => setShowSpeedCalc(false)}
|
||||
onSaved={() => {
|
||||
setShowSpeedCalc(false);
|
||||
|
||||
Reference in New Issue
Block a user