Phantom storm
Installation
$ npm install phantom-storm --save
Example
Take a snapshot of your awesome code. Using Node v7+ you can run the example with node --harmony-async-await file.js
const fs = ;const phantomStorm = ; { const editor = await phantomStorm editor const data = await editor fs; editor}
NOTE
Module works only Node v7+ with flag: node --harmony-async-await your_file.js
Node.js v7.6+ now officially supports async functions without using the --harmony
flag
editor
object API
To create a new instance of editor
use phantomStorm.init([options])
which returns a Promise
which should resolve with a editor
object.
phantomStorm;
editor options
Options of editor may set in init([options])
method phantomStorm. Default options is: { language: 'js', theme: 'zenburn' }
.
editor.setOptions(options)
Also options may changes after create instanse of editor
like this: editor.setOptions({/* some options */})
. For example:
editor;
Avaliable 150+ languages and 70+ theme.
editor.listLanguages()
Returns list of avaliable languages.
editor.write(code)
Writes code in your editor.
phantomStorm;
editor.clear()
Clears editor
editor;editorclear;
editor.toBase64()
Snapshots your js code with hightlight, and returns a Promise
which should resolve with a base64
string.
phantomStorm;
editor.toImage(filename, format='png', quality='100')
Snapshots your js code with hightlight and save image. Supported formats: pdf, png, jpeg, bmp, ppm. Quality: An integer between 0 and 100.
phantomStorm;
editor.close()
Closes instance of editor. If you want to end work with editor just shut down it.