Diff Viewer
An interactive component that visually presents the differences or changes between two pieces of text, such as code snippets or plain text.
Diff Viewer Properties
Component Properties
Diff Viewer Property | Description |
---|---|
Content | |
Compare by | Select the compare method for the component to use |
Original label | Set the label to be displayed for the original text |
Original text | The original text for comparison |
New label | Set the text to be displayed for the new text |
New text | The new text for comparison |
Appearance | |
Compact view | Shows only the diffed lines and folds the unchanged lines. values are a boolean |
Loading animation | Controls the loading state of the component, values are a boolean |
Layout | |
Width | Controls the width of the component |
Height | Controls the height of the component |
Visible | Controls the visibility of the component, values are a boolean |
Collapse when invisible | Controls what happens when the component is invisible. When true , other components shift to fill its space; when false , it leaves a blank space. This has no effect in edit mode. |
Reference Properties
Properties can be accessed from other frontend components and backend APIs by adding the name of the Diff Viewer component, and dot referencing the property. For a Diff Viewer named Diff1
:
Property | Description |
---|---|
Diff1.diffs | Returns an array of diffs |
Example Usage:
Use Diff Viewer to compare data
You can leverage the Diff Viewer component to display the differences between two pieces of data either statically or dynamically loaded. The JSON compare method will highlight differences even if the JSON fields are in a different order.
Sample original text:
[
{
"city": "Toronto",
"population": 2930000,
"country": "Canada"
},
{
"city": "New York",
"population": 8419000,
"country": "USA"
}
]
Sample new text:
[
{
"city": "Toronto",
"population": 3500000,
"country": "Canada"
},
{
"city": "New York",
"population": 8419000,
"country": "USA"
},
{
"city": "Vancouver",
"population": 675218,
"country": "Canada"
}
]