Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
importChordSheet(chordSheet) {
const song = new ChordSheetJS.ChordSheetParser().parse(chordSheet);
this.editor.value = new ChordSheetJS.ChordProFormatter().format(song);
this.onEditorChange();
}
function switchToChordPro() {
let song = new ChordSheetJS.ChordSheetParser({ preserveWhitespace: false }).parse(content)
let chordPro = new ChordSheetJS.ChordProFormatter().format(song)
setContent(chordPro)
setMode('CHORD_PRO')
}
function switchToChordSheet() {
export const convertChordSheetToChordPro = (chordSheet) => {
const parser = new ChordSheetJS.ChordSheetParser({ preserveWhitespace: false });
const formatter = new ChordSheetJS.ChordProFormatter();
const song = parser.parse(chordSheet);
return formatter.format(song);
};
function seedSongDb() {
for (var i = 0; i < allSongs.length; i++) {
let s: string = allSongs[i]
const parser = new ChordSheetJS.ChordProParser();
const formatter = new ChordSheetJS.ChordProFormatter();
const parsedSong = parser.parse(s);
let artist = new Artist(parsedSong.getMetaData('artist')!)
let song = new Song(parsedSong.getMetaData('title')!, formatter.format(parsedSong), artist)
realm.write(() => {
Song.create(song)
})
}
}
return (
(new TextareaSelection(this.editor)).replace(selection => {
const song = new ChordSheetJS.ChordProParser().parse(selection);
this.transitSong(song, processor);
const transposedSong = new ChordSheetJS.ChordProFormatter().format(song);
return transposedSong;
});
function saveSong() {
if (title.trim() == '') return setError('Invalid Title')
if (artist.trim() == '') return setError('Invalid Artist')
if (content.trim() == '') return setError('Invalid content')
let artistName = artist.trim()
let songTitle = title.trim()
let header =
`{title: ${songTitle}}\n` +
`{artist: ${artistName}}\n`
let chordPro: string
if (mode == 'CHORD_PRO') {
chordPro = header + content
} else {
const formatter = new ChordSheetJS.ChordProFormatter();
let chordSheetSong = new ChordSheetJS.ChordSheetParser({ preserveWhitespace: true }).parse(content)
chordPro = header + formatter.format(chordSheetSong)
}
let songId = props.navigation.getParam('id')
let artistDb: Artist | undefined = Artist.getByName(artistName)
if (artistDb == null) {
artistDb = Artist.create(artistName)
}
if (songId) {
Song.update(songId, artistDb, songTitle, chordPro)
} else {
let song = Song.create(artistDb, songTitle, chordPro)
songId = song.id
}
props.navigation.replace(ROUTES.SongView, { id: songId, title: songTitle })
}
static populateDb() {
if (this.shouldUpdateDb()) {
for (var i = 0; i < allSongs.data.length; i++) {
let s: string = allSongs.data[i]
const parser = new ChordSheetJS.ChordProParser();
const formatter = new ChordSheetJS.ChordProFormatter();
const parsedSong = parser.parse(s);
let artistName = parsedSong.getMetaData('artist')!
let songTitle = parsedSong.getMetaData('title')!
let songContent = formatter.format(parsedSong)
let artist = Artist.create(artistName)
Song.create(artist, songTitle, songContent)
}
}
}
const transformChordSheet = (chordSheet, processor) => {
const song = new ChordSheetJS.ChordProParser().parse(chordSheet);
const processedSong = transformSong(song, processor);
return new ChordSheetJS.ChordProFormatter().format(processedSong);
};
const processChord = (item: (ChordSheetJS.ChordLyricsPair | ChordSheetJS.Tag), processor: (parsedChord: Chord) => Chord) => {
if (item instanceof ChordSheetJS.ChordLyricsPair) {
if (item.chords) {
const parsedChord = Chord.parse(item.chords);
if (parsedChord) {
const processedChordLyricsPair = item.clone();
processedChordLyricsPair.chords = processor(parsedChord).toString();
return processedChordLyricsPair;
}
}
} else {
if (item.name == 'comment' && item.value) {
let commentSong = new ChordSheetJS.ChordProParser().parse(item.value)
commentSong = transformSong(commentSong, processor);
item.value = new ChordSheetJS.ChordProFormatter().format(commentSong)
}
}
return item;
};