# audio-editor-js

> Allows you to record and upload audio to Editorjs.

Latest version **1.1.1** (published 2021-04-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install audio-editor-js
pnpm add audio-editor-js
yarn add audio-editor-js
bun add audio-editor-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-04-29 |
| First published | 2021-04-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | vlaadzyo@gmail.com |
| Maintainers | vlaad |
| Keywords | editorJs, editorjs audio, audio, record, editorjs record, editor.js, editorjs |

## Links

- npm: https://www.npmjs.com/package/audio-editor-js
- Repository: https://https://github.com/vlaadzyo/editor-js-audio
- npm.io page: https://npm.io/package/audio-editor-js

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.21.1

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2021-04-29
- 1.0.1 — 2021-04-28
- 1.0.0 — 2021-04-27

## README

# Audio To EditorJs

Allows you to record and upload audio to Editorjs.

## Installation

### Install NPM

Get the package

```shell
npm i audio-editor-js --save
```

Include module at your application

```javascript
import Audio from "audio-editor-js";
```

## Usage

Add a new Tool to the `tools` property of the Editor.js initial config.

```javascript
var editor = EditorJS({
  ...
  
  tools: {
    ...
    audio: {
      class: Audio,
      config: {
        token: token,
        
        route: `https://test/api/file`,
        routeDelete: `https://test/api/file`,
      },
    },
  }
  ...
});
```

## Config Params

| Field           | Type       | Description                                                       |
| --------------  | ---------- | ----------------------------------------------------------------- |
| token           | `string`            | authorization token                                      |
| route           | `string`            | route for storage on the server                          |
| routeDelete     | `string`            | route to delete the audio file from the server           |
| saveServer      | callback `function` | A function that replaces the standard function of sending to the server |
| deleteServer    | callback `function` | A function that replaces the standard function of deleting a file on the server |

## output server

the server must give this json in response to the save request. If the server works differently, use the saveServer function

```json
{
    "data" : {
        "url" : "https://test/file",
        "name": "audio.webm",
        "id" : "123",
    }
}
```

## delete server

method `delete`

## callback function saveServer

A function that sends a file to a server. receives the file and to send to the server.
Return has an object with a file reference and file id.

```javascript
  tools: {
    ...
    audio: {
      class: Audio,
      config: {
        saveServer: async (file) => {
          try {
            let formData = new FormData();
            formData.append("file", file);
            
            let req = await axios.post(route, formData);

            // such object should return here
            
            //req = {
            //   data: {
            //     url: 'https://test/file/audio.mp3',
            //     name: 'audio.webm',
            //     id: '123',
            //   }
            // }
            return req;
          } catch (e) {
            console.error(e);
          }
        },
      },
    },
  }
```
## callback function deleteServer

The id of the file by means of which it can be deleted from the server is transferred

```javascript
  tools: {
    ...
    audio: {
      class: Audio,
      config: {
        deleteServer: async (id) => {
          try {
            await axios.delete(route, id)
          } catch (e) {
            console.error(e);
          }
        },
      },
    },
  }
```

---
_Source: https://npm.io/package/audio-editor-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
