Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

angular-diff-match-patch

amweiss1.3kMIT0.8.14

An Angular module to use when dealing with google-diff-match-patch.

readme

angular-diff-match-patch

npm CircleCI Codecov

This library is simply a wrapper around google-diff-match-patch.

Simple

(Shown here with some custom styles)

Angular 2 Port

Should you wish to use this in an Angular 2+ project, take a look at this port: elliotforbes/ng-diff-match-patch

Setup

Install from NPM

npm install amweiss/angular-diff-match-patch

Install from Bower

bower install angular-diff-match-patch

Usage with webpack

  config.plugins = [
    new webpack.ProvidePlugin({
      diff_match_patch: 'diff-match-patch'
    }),
  ];

Usage

See the included demo for reference or view a sample on Codepen.

<pre line-diff left-obj="left" right-obj="right"></pre>

Where left and right are defined on your scope. The options attribute can be used as well, but it's optional.

$scope.options = {
  editCost: 4,
  attrs: {
    insert: {
      'data-attr': 'insert',
      'class': 'insertion'
    },
    delete: {
      'data-attr': 'delete'
    },
    equal: {
      'data-attr': 'equal'
    }
  }
};

editCost is specific to processingDiff and controls the tolerence for hunk separation. attrs can contain any/all/none of the following: insert, delete, and equal where the properties in those objects represent attributes that get added to the tags.

Another option is to skip angular processing the diff, it's useful when you want to show a diff of a code pre-compiled by angular. The attribute you need to add is called: skipAngularCompilingOnDiff. If set to true, would skip compiling, otherwise it would compile the diff.

Add some style

.match{
  color: gray;
}

.ins{
  color: black;
  background: #bbffbb;
}

.del{
  color: black;
  background: #ffbbbb;
}

Development

Development work requires npm from Node.js

Begin with:

npm install

Then you can use:

npm start To host the directory so you can see the demo

npm test To run the Jasmine tests once

npm test-watch To run the Jasmine tests with change detection

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.8.13 (2024-07-08)

0.8.12 (2024-07-08)

0.8.11 (2024-07-08)

0.8.10 (2024-07-08)

0.8.9 (2024-07-08)

0.8.8 (2023-01-19)

0.8.7 (2023-01-19)

0.8.6 (2022-09-07)

0.8.5 (2022-02-11)

0.8.4 (2022-02-10)

0.8.3 (2021-11-20)

0.8.2 (2021-10-13)

0.8.1 (2021-05-14)

0.8.0 (2021-04-21)

⚠ BREAKING CHANGES

  • use ES2015 stuff
  • use ES2015 stuff

  • Merge pull request #231 from amweiss/dependabot/npm_and_yarn/xo-0.39.1 (0615dcf), closes #231

  • Fix linting (ff7a7ed)

0.7.83 (2021-03-01)

0.7.82 (2021-03-01)

0.7.81 (2021-01-07)

0.7.80 (2021-01-07)

0.7.79 (2020-11-20)

0.7.78 (2020-08-06)

0.7.77 (2020-05-08)

0.7.76 (2020-04-24)

Bug Fixes

0.7.75 (2020-04-24)

Bug Fixes

0.7.74 (2020-04-23)

0.7.52 (2019-10-23)

0.7.28 (2019-03-15)

0.7.4 (2018-09-13)

0.7.0 (2018-08-27)

0.6.23 (2018-08-24)

0.6.16 (2018-07-16)

0.6.15 (2018-05-29)

0.6.14 (2018-04-10)

Bug Fixes

  • demo: Fix the js files in the local demo (341edb0)

0.6.13 (2018-03-23)

0.6.12 (2018-03-23)

0.6.11 (2018-03-23)

0.6.10 (2017-06-13)

Bug Fixes

  • ci: cci2 config for npm publish (1c8ac2b)

0.6.9 (2017-06-13)