# prosemirror-compress-pubpub

> ProseMirror compression for pubpub-editor

Latest version **0.0.3** (published 2018-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install prosemirror-compress-pubpub
pnpm add prosemirror-compress-pubpub
yarn add prosemirror-compress-pubpub
bun add prosemirror-compress-pubpub
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-10-21 |
| First published | 2018-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | PubPub |
| Maintainers | pubpub |

## Links

- npm: https://www.npmjs.com/package/prosemirror-compress-pubpub
- Repository: https://github.com/pubpub/prosemirror-compress-pubpub
- Homepage: https://github.com/pubpub/prosemirror-compress-pubpub#readme
- Issues: https://github.com/pubpub/prosemirror-compress-pubpub/issues
- npm.io page: https://npm.io/package/prosemirror-compress-pubpub

## Recent versions

- 0.0.3 (latest) — 2018-10-21

## README

# prosemirror-compress-pubpub

This repo has been forked from [xylk/prosemirror-compress](https://github.com/xylk/prosemirror-compress) to add some pubpub-editor specific changes and bug fixes.

## Installation
```
npm install prosemirror-compress-pubpub
```

## documentation

### \[('compress' || 'uncompress') + ('State' || 'Selection' || 'Step') + 'JSON']()

Renames known keys and values. Maintains JSON structure.

```js
let compressedStateJSON = compressStateJSON(/*editorState*/.toJSON())
let editorState = EditorState.fromJSON(/*config*/, uncompressStateJSON(compressedStateJSON))

let compressedSelectionJSON = compressSelectionJSON(/*selection*/.toJSON())
let selection = Selection.fromJSON(/*doc*/, uncompressSelectionJSON(compressedSelectionJSON))

let compressedStepsJSON = /*steps array*/.map(step => compressStepJSON(step.toJSON()))
let steps = compressedStepsJSON.map(json => Step.fromJSON(/*schema*/, uncompressStepJSON(json))
```

#### uncompressed vs compressed

```json
{"selection":{"head":0,"anchor":0}},"doc":{"type":"doc","content":[{"type":"heading","attrs":{"level":3},
```

```json
{"s":{"h":0,"a":0}},"d":{"t":"d","c":[{"t":"h","a":{"l":3},
```

### compressStepsLossy()

[Merges](https://prosemirror.net/ref.html#transform.Step.merge) all the [steps](https://prosemirror.net/ref.html#transform.Steps) that can be merged.

```js
let steps = compressStepsLossy(/*steps array*/)
```

### keysMappers()

For compressing and uncompressing using custom [keys maps](src/maps.js).

```js
let [ keysMapper, inverseKeysMapper ] = keysMappers(/*keysMap*/)
let compressedJSON = keysMapper(/*json*/)
let json = inverseKeysMapper(compressedJSON)
```

## license

[MIT license](LICENSE).

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