mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2025-12-11 13:26:16 +00:00
@@ -196,7 +196,7 @@
|
|||||||
{#each $items.slice(page * $pageSize - (page === 0 ? 0 : 1), (page + 1) * $pageSize - 1) as [chord] (JSON.stringify(chord?.id))}
|
{#each $items.slice(page * $pageSize - (page === 0 ? 0 : 1), (page + 1) * $pageSize - 1) as [chord] (JSON.stringify(chord?.id))}
|
||||||
{#if chord}
|
{#if chord}
|
||||||
<tr>
|
<tr>
|
||||||
<ChordEdit {chord} />
|
<ChordEdit {chord} on:duplicate={() => (page = 0)} />
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { changes, ChangeType } from "$lib/undo-redo.js";
|
import { changes, ChangeType, chords } from "$lib/undo-redo.js";
|
||||||
import type { ChordInfo } from "$lib/undo-redo.js";
|
import type { ChordInfo } from "$lib/undo-redo.js";
|
||||||
import ChordPhraseEdit from "./ChordPhraseEdit.svelte";
|
import ChordPhraseEdit from "./ChordPhraseEdit.svelte";
|
||||||
import ChordActionEdit from "./ChordActionEdit.svelte";
|
import ChordActionEdit from "./ChordActionEdit.svelte";
|
||||||
@@ -8,9 +8,12 @@
|
|||||||
import { charaFileToUriComponent } from "$lib/share/share-url";
|
import { charaFileToUriComponent } from "$lib/share/share-url";
|
||||||
import SharePopup from "../SharePopup.svelte";
|
import SharePopup from "../SharePopup.svelte";
|
||||||
import tippy from "tippy.js";
|
import tippy from "tippy.js";
|
||||||
|
import { createEventDispatcher } from "svelte";
|
||||||
|
|
||||||
export let chord: ChordInfo;
|
export let chord: ChordInfo;
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher<{ duplicate: void }>();
|
||||||
|
|
||||||
function remove() {
|
function remove() {
|
||||||
changes.update((changes) => {
|
changes.update((changes) => {
|
||||||
changes.push({
|
changes.push({
|
||||||
@@ -39,6 +42,27 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function duplicate() {
|
||||||
|
const id = [...chord.id];
|
||||||
|
id.splice(id.indexOf(0), 1);
|
||||||
|
id.push(0);
|
||||||
|
while ($chords.some((it) => JSON.stringify(it.id) === JSON.stringify(id))) {
|
||||||
|
id[id.length - 1]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
changes.update((changes) => {
|
||||||
|
changes.push({
|
||||||
|
type: ChangeType.Chord,
|
||||||
|
id,
|
||||||
|
actions: [...chord.actions],
|
||||||
|
phrase: [...chord.phrase],
|
||||||
|
});
|
||||||
|
return changes;
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch("duplicate");
|
||||||
|
}
|
||||||
|
|
||||||
async function share(event: Event) {
|
async function share(event: Event) {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.searchParams.set(
|
url.searchParams.set(
|
||||||
@@ -82,6 +106,9 @@
|
|||||||
>restore_from_trash</button
|
>restore_from_trash</button
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
|
<button disabled={chord.deleted} class="icon compact" on:click={duplicate}
|
||||||
|
>content_copy</button
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
class="icon compact"
|
class="icon compact"
|
||||||
class:disabled={chord.isApplied}
|
class:disabled={chord.isApplied}
|
||||||
@@ -102,6 +129,10 @@
|
|||||||
background: currentcolor;
|
background: currentcolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
transition: opacity 75ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user