Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parseChordProSheet() {
const parser = new ChordSheetJS.ChordProParser();
return parser.parse(this.editor.value);
}
function saveSong() {
if (isSaving) return
setIsSaving(true)
const parser = new ChordSheetJS.ChordProParser();
const parsedSong = parser.parse(chordSheet!);
let artistName = parsedSong.getMetaData('artist')!
let songTitle = parsedSong.getMetaData('title')!
let headerlessContent = chordSheet!
headerlessContent = headerlessContent.replace(/{artist:[^}]*}\n/g, '')
headerlessContent = headerlessContent.replace(/{title:[^}]*}\n/g, '')
let artist: Artist | undefined = Artist.getByName(artistName)
if (artist == null) {
artist = Artist.create(artistName)
}
let song = Song.create(artist, songTitle, headerlessContent)
let params: SongViewParams = { id: song.id, title: song.title }
props.navigation.replace(ROUTES.SongView, params)
function switchToChordSheet() {
let song = new ChordSheetJS.ChordProParser().parse(content)
let plainText = new ChordSheetJS.TextFormatter().format(song)
setContent(plainText)
setMode('CHORD_SHEET')
}
renderViewerColumn() {
const { chordSheet } = this.props;
const song = new ChordSheetJS.ChordProParser().parse(chordSheet);
return (
<section>
{this.renderViewer(song)}
</section>
);
}
(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 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 (
const ChordSheetViewer = (props) => {
const { chordSheet, previewMode } = props;
const song = new ChordSheetJS.ChordProParser().parse(chordSheet);
switch (previewMode) {
case 'html':
return ;
case 'text':
return ;
default:
return null;
}
};
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;
};
onEditorChange() {
const song = this.parseChordProSheet();
if (this.textPreviewer) {
this.textPreviewer.value = new ChordSheetJS.TextFormatter().format(song);
}
if (this.htmlPreviewer) {
this.htmlPreviewer.innerHTML = new ChordSheetJS.HtmlFormatter().format(song);
}
}
const ChordSheetTextViewer = (props) => {
const { song } = props;
const textChordSheet = new ChordSheetJS.TextFormatter().format(song);
return <textarea value="{textChordSheet}" readonly="">;
};
</textarea>