How to use chordsheetjs - 10 common examples

To help you get started, we’ve selected a few chordsheetjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github martijnversluis / ChordFiddle / js / chord_pro_editor.js View on Github external
parseChordProSheet() {
    const parser = new ChordSheetJS.ChordProParser();
    return parser.parse(this.editor.value);
  }
github artutra / OpenChord / app / containers / SongPreview.tsx View on Github external
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)
github artutra / OpenChord / app / containers / SongEdit.tsx View on Github external
function switchToChordSheet() {
    let song = new ChordSheetJS.ChordProParser().parse(content)
    let plainText = new ChordSheetJS.TextFormatter().format(song)
    setContent(plainText)
    setMode('CHORD_SHEET')
  }
github martijnversluis / ChordFiddle / src / components / App.jsx View on Github external
renderViewerColumn() {
    const { chordSheet } = this.props;
    const song = new ChordSheetJS.ChordProParser().parse(chordSheet);

    return (
      <section>
        
        {this.renderViewer(song)}
      </section>
    );
  }
github martijnversluis / ChordFiddle / js / chord_pro_editor.js View on Github external
(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;
    });
github artutra / OpenChord / app / containers / Config.tsx View on Github external
function seedSongDb() {
    for (var i = 0; i &lt; 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(() =&gt; {
        Song.create(song)
      })
    }
  }
  return (
github martijnversluis / ChordFiddle / src / components / ChordSheetViewer.jsx View on Github external
const ChordSheetViewer = (props) =&gt; {
  const { chordSheet, previewMode } = props;
  const song = new ChordSheetJS.ChordProParser().parse(chordSheet);

  switch (previewMode) {
    case 'html':
      return ;
    case 'text':
      return ;
    default:
      return null;
  }
};
github artutra / OpenChord / app / components / SongTransformer.tsx View on Github external
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;
};
github martijnversluis / ChordFiddle / js / chord_pro_editor.js View on Github external
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);
    }
  }
github martijnversluis / ChordFiddle / src / components / ChordSheetTextViewer.jsx View on Github external
const ChordSheetTextViewer = (props) =&gt; {
  const { song } = props;
  const textChordSheet = new ChordSheetJS.TextFormatter().format(song);

  return <textarea value="{textChordSheet}" readonly="">;
};
</textarea>

chordsheetjs

A JavaScript library for parsing and formatting chord sheets

GPL-2.0
Latest version published 7 days ago

Package Health Score

78 / 100
Full package analysis

Similar packages