How to use the react-diff-view.markWordEdits function in react-diff-view

To help you get started, we’ve selected a few react-diff-view examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github patternfly / patternfly-react / packages / patternfly-3 / patternfly-react-extensions / src / components / DiffView / DiffView.js View on Github external
const DiffView = ({
  oldText,
  newText,
  className,
  viewType,
  patch,
  markEditsByWord,
  emptyState,
  markThreshold,
  markLongDistanceDiff,
  ...props
}) => {
  const markEditProps = { markThreshold, markLongDistanceDiff };
  const markEdits = markEditsByWord ? markWordEdits(markEditProps) : markCharacterEdits(markEditProps);
  const classes = classNames('diff-pf', className);

  // Old, New Text
  if (!patch) {
    const gitDiff = getDiff(oldText, newText);
    const files = parseDiff(gitDiff);
    const hunk = files[0].hunks;

    if (hunk.length === 0) {
      return emptyState;
    }
    return hunk && ;
  }

  // Patch
  const files = parseDiff(patch);