Skip to content

V2 #9

Description

@Xiphe

Here's what I'm thinking a V2 of this project should look like

Here's how I think it should work:

const merge = new PhPDiffMerge({
  diff: document.getElementById('diff1'),
});

console.log(merge.allSolved);
/* false */
console.log(merge.differences);
/* 
[{
  left: { startLine: 1, endLine: 4 },
  right: { startLine: 1, endLine: 7 },
  resolved: false
}] 
*/

merge.onChange((difference) => {
  console.log(merge.allSolved);
  /* true */
  console.log(difference);
  /* 
  {
    left: { startLine: 1, endLine: 4 },
    right: { startLine: 1, endLine: 7 },
    resolved: true
  }
  */
});

function onResolveClick() {
  if (!merge.allSolved) {
    throw new Error('please resolve all differences first');
  }

  myPhpBackend.POST('/resolved', { patch: merge.getPatch() }).then(() => console.log('YAY'));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions