Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/module usage #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
_site/
/node_modules
25 changes: 19 additions & 6 deletions lib/diffDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,30 @@ function diffDecorator(strategies) {
}

// Decorators
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var InsertSpan = function (props) {
return <span {...props} className="diff-insert">{props.children}</span>;
var InsertSpan = function InsertSpan(props) {
return React.createElement(
"span",
_extends({}, props, { className: "diff-insert" }),
props.children
);
};

var EqualSpan = function (props) {
return <span {...props} className="diff-equal">{props.children}</span>;
var EqualSpan = function EqualSpan(props) {
return React.createElement(
"span",
_extends({}, props, { className: "diff-equal" }),
props.children
);
};

var DeleteSpan = function (props) {
return <span {...props} className="diff-delete">{props.children}</span>;
var DeleteSpan = function DeleteSpan(props) {
return React.createElement(
"span",
_extends({}, props, { className: "diff-delete" }),
props.children
);
};

module.exports = diffDecorator;
42 changes: 24 additions & 18 deletions lib/diffEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,36 @@ var DiffEditor = React.createClass({
render: function () {
var before;
if (!this.props.before.hidden) {
before = <div className='diff-before'>
<Draft.Editor
readOnly={this.props.before.readOnly}
editorState={this.state.beforeState}
onChange={this.onBeforeChange}
/>
</div>;
before = React.createElement(
'div',
{ className: 'diff-before' },
React.createElement(Draft.Editor, {
readOnly: this.props.before.readOnly,
editorState: this.state.beforeState,
onChange: this.onBeforeChange
})
);
}

var after;
if (!this.props.after.hidden) {
after = <div className='diff-after'>
<Draft.Editor
readOnly={this.props.after.readOnly}
editorState={this.state.afterState}
onChange={this.onAfterChange}
/>
</div>;
after = React.createElement(
'div',
{ className: 'diff-after' },
React.createElement(Draft.Editor, {
readOnly: this.props.after.readOnly,
editorState: this.state.afterState,
onChange: this.onAfterChange
})
);
}

return <div className='diff-editor'>
{before}
{after}
</div>;
return React.createElement(
'div',
{ className: 'diff-editor' },
before,
after
);
}
});

Expand Down