Files
payload/packages/richtext-lexical/src/field/Diff/htmlDiff/index.scss
Alessio Gravili d29bdfc10f feat(next): improved lexical richText diffing in version view (#11760)
This replaces our JSON-based richtext diffing with HTML-based richtext
diffing for lexical. It uses [this HTML diff
library](https://github.com/Arman19941113/html-diff) that I then
modified to handle diffing more complex elements like links, uploads and
relationships.

This makes it way easier to spot changes, replacing the lengthy Lexical
JSON with a clean visual diff that shows exactly what's different.

## Before

![CleanShot 2025-03-18 at 13 54
51@2x](https://github.com/user-attachments/assets/811a7c14-d592-4fdc-a1f4-07eeb78255fe)


## After


![CleanShot 2025-03-31 at 18 14
10@2x](https://github.com/user-attachments/assets/efb64da0-4ff8-4965-a458-558a18375c46)
![CleanShot 2025-03-31 at 18 14
26@2x](https://github.com/user-attachments/assets/133652ce-503b-4b86-9c4c-e5c7706d8ea6)
2025-04-02 20:10:20 +00:00

91 lines
2.0 KiB
SCSS

@import '../../../scss/styles.scss';
@import '../colors.scss';
@layer payload-default {
.lexical-diff__diff-container {
font-family: var(--font-serif);
font-size: base(0.8);
letter-spacing: 0.02em;
// Apply background color to parents that have children with diffs
p,
li,
h1,
h2,
h3,
h4,
h5,
blockquote,
h6 {
&:has([data-match-type='create']) {
background-color: var(--diff-create-parent-bg);
color: var(--diff-create-parent-color);
}
&:has([data-match-type='delete']) {
background-color: var(--diff-delete-parent-bg);
color: var(--diff-delete-parent-color);
}
}
li::marker {
color: var(--theme-text);
}
[data-match-type='delete'] {
color: var(--diff-delete-pill-color);
text-decoration-color: var(--diff-delete-pill-color);
text-decoration-line: line-through;
background-color: var(--diff-delete-pill-bg);
border-radius: 4px;
text-decoration-thickness: 1px;
}
a[data-match-type='delete'] {
color: var(--diff-delete-link-color);
}
a[data-match-type='create']:not(img) {
// :not(img) required to increase specificity
color: var(--diff-create-link-color);
}
[data-match-type='create']:not(img) {
background-color: var(--diff-create-pill-bg);
color: var(--diff-create-pill-color);
border-radius: 4px;
}
.html-diff {
&-create-inline-wrapper,
&-delete-inline-wrapper {
display: inline-flex;
}
&-create-block-wrapper,
&-delete-block-wrapper {
display: flex;
}
&-create-inline-wrapper,
&-delete-inline-wrapper,
&-create-block-wrapper,
&-delete-block-wrapper {
position: relative;
align-items: center;
flex-direction: row;
&::after {
position: absolute;
top: 0;
left: 0;
display: block;
width: 100%;
height: 100%;
content: '';
}
}
}
}
}