prosemirror-compress-pubpub

0.0.3 • Public • Published

prosemirror-compress-pubpub

This repo has been forked from 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.

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

{"selection":{"head":0,"anchor":0}},"doc":{"type":"doc","content":[{"type":"heading","attrs":{"level":3},
{"s":{"h":0,"a":0}},"d":{"t":"d","c":[{"t":"h","a":{"l":3},

compressStepsLossy()

Merges all the steps that can be merged.

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

keysMappers()

For compressing and uncompressing using custom keys maps.

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

license

MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i prosemirror-compress-pubpub

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

12.1 kB

Total Files

7

Last publish

Collaborators

  • pubpub