No description
This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
Find a file
dependabot[bot] c850ca00a5
chore(deps): bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 13:30:08 +00:00
src refactor: constantize, remove redundancy 2020-04-19 21:01:09 -04:00
.eslintrc.js Initial working version (#1) 2020-04-19 20:14:51 -04:00
.gitignore Initial commit 2020-04-18 23:54:26 -04:00
LICENSE Initial commit 2020-04-18 23:54:26 -04:00
package.json chore: add missing dep, immutable 2020-04-19 21:00:44 -04:00
README.md Initial working version (#1) 2020-04-19 20:14:51 -04:00
yarn.lock chore(deps): bump minimist from 1.2.5 to 1.2.6 2022-03-26 13:30:08 +00:00

draft-js-commit-log-plugin

draft-js-commit-log-plugin is an exploration of granular change-tracking in DraftJS. The usual approach to saving draft-js document is to serialize and store the document as a whole on save, which limits you to whole-document updates instead of a model where you would apply changes in sequence on a "branch" like you would on git. The plugin implements a change-tracking layer in DraftJS so that in-editor actions that analyzes changes pushed to the DraftJS state and forms sequential commits from them. It also tags all editor blocks with a stable, unique identifier so that changes can be consistently attached to them through saves.

Install

You can install the plugin package from this repository by cloning and packing it yourself. It is not yet released on npm.

Given that you have draft-js-plugin-editor set up, you can simply do the following:

// What you should already have
import React, { useState } from 'react'
import { Editor } from 'draft-js-plugin-editor'
import { EditorState } from 'draft-js'

// What this package offers
import createCommitLogPlugin from 'draft-js-commit-log-plugin'

const commitLogPlugin = createCommitLogPlugin()

const App = () => {
    const [editorState, setEditorState] = useState(EditorState.createEmpty())
    return (
        <Editor
            editorState={editorState}
            plugins={[commitLogPlugin]}
            onChange={s => setEditorState(s)}
        />
    )
}