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

Replace shouldDiffDescendants with elementsAreRelated #3011

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

12joan
Copy link
Collaborator

@12joan 12joan commented Mar 2, 2024

Description

  • Remove shouldDiffDescendants option in favour of elementsAreRelated.

  • The elementsAreRelated option controls whether computeDiff treats a given pair of elements as "related" and thus tries to diff them. By default, elements are related if they have the same children OR they differ only in their children. Return null to use the default logic for a pair of elements.

    • Use case: In addition to supporting the same use case as the deprecated shouldDiffDescendants, elementsAreRelated can be used to ensure that computeDiff compares the correct pair of paragraphs.

      For example, by default, computeDiff would compare My slightly modified paragraph. with New paragraph in the following diff.

      - My slightly modified paragraph.
      + New paragraph
      + My slightly modified paragraph!

      If a custom elementsAreRelated function is provided that returns true for mostly similar paragraphs, computeDiff would instead compare My slightly modified paragraph. with My slightly modified paragraph!.

@12joan 12joan requested a review from zbeyens March 2, 2024 13:40
Copy link

changeset-bot bot commented Mar 2, 2024

🦋 Changeset detected

Latest commit: a278858

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@udecode/plate-diff Minor
@udecode/plate Minor
@udecode/plate-suggestion Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Mar 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 2, 2024 1:46pm

@12joan 12joan merged commit 3c82bfd into main Mar 2, 2024
6 checks passed
@12joan 12joan deleted the feat/diff-custom-related-function branch March 2, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants