Releases: udecode/plate
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
Minor Changes
-
-
Remove
shouldDiffDescendants
option in favour ofelementsAreRelated
. -
The
elementsAreRelated
option controls whethercomputeDiff
treats a given pair of elements as "related" and thus tries to diff them. By default, elements are related if they have the samechildren
OR they differ only in theirchildren
. 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 thatcomputeDiff
compares the correct pair of paragraphs.For example, by default,
computeDiff
would compareMy slightly modified paragraph.
withNew 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 compareMy slightly modified paragraph.
withMy slightly modified paragraph!
.
-
-
@udecode/[email protected]
@udecode/[email protected]
@udecode/[email protected]
Minor Changes
- #3009 by @12joan –
- Add
shouldDiffDescendants
option tocomputeDiff
to control whether a pair of descendant lists should be diffed. If false, the parent node will be deleted and re-inserted. Defaults to() => true
.- Example use case: To prevent
computeDiff
from diffing the text of unrelated paragraphs, use a text similarity checking algorithm to determine whether the paragraphs are sufficiently similar, and return false if not.
- Example use case: To prevent
- When multiple consecutive nodes have been deleted and inserted,
computeDiff
now groups all consecutive deletions together and does the same with all consecutive insertions.- Example of a diff prior to this change:
- Old paragraph 1 + New paragraph 1 - Old paragraph 2 + New paragraph 2
- Example of a diff after this change:
- Old paragraph 1 - Old paragraph 2 + New paragraph 1 + New paragraph 2
- Example of a diff prior to this change:
- Add