Skip to content

Commit

Permalink
fix: vocabulary export (#152)
Browse files Browse the repository at this point in the history
* fix: vocabulary export

* fix: export only plain phrase
  • Loading branch information
sakura-rip authored Dec 6, 2024
1 parent 588719d commit dd07b76
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/routes/(app)/config/chords/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
buildIndex($chords, $osLayout).then(searchIndex.set);
});
function encodeChord(chord: ChordInfo, osLayout: Map<string, string>) {
function encodeChord(chord: ChordInfo, osLayout: Map<string, string>, onlyPhrase: boolean = false) {
const plainPhrase: string[] = [""];
const extraActions: string[] = [];
const extraCodes: string[] = [];
Expand Down Expand Up @@ -103,6 +103,10 @@
return result ?? `0x${it.toString(16)}`;
});
if (onlyPhrase) {
return plainPhrase.join();
}
return [
...plainPhrase,
`+${input.join("+")}`,
Expand Down Expand Up @@ -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("");
Expand Down

0 comments on commit dd07b76

Please sign in to comment.