Skip to content

Commit

Permalink
add anki-apkg-export
Browse files Browse the repository at this point in the history
  • Loading branch information
yakhinvadim committed Jun 18, 2017
1 parent 0f576a9 commit 4fec6c2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"anki-apkg-export": "^3.0.1",
"filesaverjs": "^1.2.0",
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"devDependencies": {
"react-scripts": "1.0.7"
"raw-loader": "^0.5.1",
"react-scripts": "1.0.7",
"script-loader": "^0.7.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
}
23 changes: 23 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,28 @@ import App from './App';
import registerServiceWorker from './registerServiceWorker';
import './index.css';

// code from example start

import { saveAs } from 'filesaverjs';
import AnkiExport from 'anki-apkg-export';

const apkg = new AnkiExport('deck-name');

// could be a File from <input /> or a Blob from fetch
// take a look at the example folder for a complete overview

apkg.addCard('card #1 front', 'card #1 back');
apkg.addCard('card #2 front', 'card #2 back', { tags: ['nice', 'better card'] });
apkg.addCard('card #3 with image <img src="anki.png" />', 'card #3 back');

apkg
.save()
.then(zip => {
saveAs(zip, 'output.apkg');
})
.catch(err => console.log(err.stack || err));

// code from example end

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

0 comments on commit 4fec6c2

Please sign in to comment.