-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdiffDecorator.js
39 lines (33 loc) · 946 Bytes
/
diffDecorator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var React = require('react');
var Draft = require('draft-js');
/**
* @param {Strategies} strategies
* @returns {Draft.Decorator}
*/
function diffDecorator(strategies) {
return new Draft.CompositeDecorator([
{
strategy: strategies.getEqualStrategy(),
component: EqualSpan
},
{
strategy: strategies.getDeleteStrategy(),
component: DeleteSpan
},
{
strategy: strategies.getInsertStrategy(),
component: InsertSpan
}
]);
}
// Decorators
var InsertSpan = function (props) {
return <span {...props} className="diff-insert">{props.children}</span>;
};
var EqualSpan = function (props) {
return <span {...props} className="diff-equal">{props.children}</span>;
};
var DeleteSpan = function (props) {
return <span {...props} className="diff-delete">{props.children}</span>;
};
module.exports = diffDecorator;