silverstripe-admin icon indicating copy to clipboard operation
silverstripe-admin copied to clipboard

Create a comparable React-based TextField for compare mode in form fields

Open robbieaverill opened this issue 6 years ago • 0 comments

I've just had a brief chat with @tractorcow, and we need to create a set of new form fields in React in order to be able to render diffs between two form field values. The primary use case of this right now is for showing the differences between two versions of a page in the history viewer (issue: https://github.com/silverstripe/silverstripe-versioned/issues/96).

Using TextField to start with would be both an easy place to start, and a good fallback for form fields that don't have their own way of rendering a diff.

@tractorcow and I discussed perhaps having the React component accept two values (old and new version, or version A or B, etc) and handle rendering the diff itself. In this case, we'll probably need to find a JS library that can render differences in HTML. I've seen https://www.npmjs.com/package/react-diff which is based on https://kpdecker.github.com/jsdiff, but they don't appear to compare HTML.

Related issue with designs for some form fields: https://github.com/silverstripe/silverstripe-versioned/issues/97

robbieaverill avatar Apr 12 '18 03:04 robbieaverill