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

V2 #9

Open
Xiphe opened this issue Oct 13, 2020 · 1 comment
Open

V2 #9

Xiphe opened this issue Oct 13, 2020 · 1 comment

Comments

@Xiphe
Copy link
Collaborator

Xiphe commented Oct 13, 2020

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'));
}
@JBlond
Copy link
Collaborator

JBlond commented Feb 28, 2022

I'm not sure about xdiff. It is a PECL extension and not always available.

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

No branches or pull requests

2 participants