项目作者: GitbookIO

项目描述 :
React component to render rich diff between two documents (Markdown, HTML)
高级语言: JavaScript
项目地址: git://github.com/GitbookIO/react-rich-diff.git
创建时间: 2017-01-16T21:35:39Z
项目社区:https://github.com/GitbookIO/react-rich-diff

开源协议:Apache License 2.0

下载


react-rich-diff

Build Status NPM version

React component to display a rich diff between two Markup-it documents.

Installation

  1. $ npm install react-rich-diff --save

Usage

  1. const React = require('react');
  2. const RichDiff = require('react-rich-diff');
  3. const MarkupIt = require('markup-it');
  4. const markdown = require('markup-it/lib/markdown');
  5. const state = MarkupIt.State.create(markdown);
  6. const MyApp = React.createClass({
  7. render() {
  8. const original = state.deserializeToDocument('Hello **World**');
  9. const modified = state.deserializeToDocument('Hello **World 2**');
  10. const state = RichDiff.State.create(original, modified);
  11. return (
  12. <RichDiff
  13. state={state}
  14. ></RichDiff>
  15. )
  16. }
  17. })

CSS

react-rich-diff creates HTML elements with classes diff-<kind>-<type.

kind can be one of block, inline or character.
type can be one of added, removed or modified.