From dd07b763f4fd0671c5f2541bbfd14868cf125990 Mon Sep 17 00:00:00 2001 From: kazuki <56917703+sakura-rip@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:48:30 +0900 Subject: [PATCH] fix: vocabulary export (#152) * fix: vocabulary export * fix: export only plain phrase --- src/routes/(app)/config/chords/+page.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/routes/(app)/config/chords/+page.svelte b/src/routes/(app)/config/chords/+page.svelte index 6582e5cb..7fb5198a 100644 --- a/src/routes/(app)/config/chords/+page.svelte +++ b/src/routes/(app)/config/chords/+page.svelte @@ -43,7 +43,7 @@ buildIndex($chords, $osLayout).then(searchIndex.set); }); - function encodeChord(chord: ChordInfo, osLayout: Map) { + function encodeChord(chord: ChordInfo, osLayout: Map, onlyPhrase: boolean = false) { const plainPhrase: string[] = [""]; const extraActions: string[] = []; const extraCodes: string[] = []; @@ -103,6 +103,10 @@ return result ?? `0x${it.toString(16)}`; }); + if (onlyPhrase) { + return plainPhrase.join(); + } + return [ ...plainPhrase, `+${input.join("+")}`, @@ -182,7 +186,7 @@ function downloadVocabulary() { const vocabulary = new Set( $chords.map((it) => - "phrase" in it ? plainPhrase(it.phrase, $osLayout).trim() : "", + "phrase" in it ? encodeChord(it, $osLayout, true).trim() : "", ), ); vocabulary.delete("");