Commit da1aa051 authored by Julien Bouquillon's avatar Julien Bouquillon 🐫

feat: better diff

parent 57cf49ab
......@@ -8,6 +8,7 @@
"@socialgouv/legi-data": "^1.1.15",
"classnames": "^2.2.6",
"diff": "1.2",
"html-text": "^1.0.1",
"isomorphic-unfetch": "^3.0.0",
"memoizee": "^0.4.14",
"next": "^9.2.2",
......
......@@ -20,6 +20,7 @@ import {
Col
} from "reactstrap";
import classnames from "classnames";
import htmlText from "html-text";
import { Search } from "react-feather";
import Link from "next/link";
......@@ -79,6 +80,9 @@ const FileChangeDetail = ({
}) => {
const href = getUrl(source, textId, rootId, type, data);
const textField = source === "LEGI" ? "texte" : "content";
const content = htmlText(data[textField] || "").trim();
const previousContent =
previous && htmlText(previous.data[textField] || "").trim();
return (
<tr>
<td width="100" align="center">
......@@ -104,7 +108,7 @@ const FileChangeDetail = ({
<BadgeEtat etat={data.etat} />
</div>
)}
{previous && previous.data[textField] !== data[textField] && (
{previous && content !== previousContent && (
<Collapsible
trigger={
<div style={{ cursor: "pointer" }}>
......@@ -117,11 +121,12 @@ const FileChangeDetail = ({
}
>
<Diff
inputA={data[textField]}
inputB={previous.data[textField]}
inputA={previousContent}
inputB={content}
type={"words"}
style={{
padding: 5,
whiteSpace: "pre-line",
border: "1px solid silver",
background: "#fff",
borderRadius: 3
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment