Merge branch 'feat/ui-1.0.2' of git.backyard.segmentfault.com:opensource/answer into feat/ui-1.0.2

This commit is contained in:
haitao(lj) 2022-12-26 10:18:15 +08:00
commit ae66685c1e
2 changed files with 14 additions and 10 deletions

View File

@ -93,16 +93,18 @@ const Index: FC<Props> = ({
className={classnames(
'fs-14 font-monospace',
newData.original_text && 'mb-4',
)}>
{`/tags/${
newData?.main_tag_slug_name
? diffText(
newData.main_tag_slug_name,
oldData?.main_tag_slug_name,
)
: diffText(newData.slug_name, oldData?.slug_name)
}`}
</div>
)}
dangerouslySetInnerHTML={{
__html: `/tags/${
newData?.main_tag_slug_name
? diffText(
newData.main_tag_slug_name,
oldData?.main_tag_slug_name,
)
: diffText(newData.slug_name, oldData?.slug_name)
}`,
}}
/>
)}
<div
dangerouslySetInnerHTML={{

View File

@ -179,6 +179,8 @@ function diffText(newText: string, oldText: string): string {
?.replace(/<input/gi, '&lt;input');
}
const diff = Diff.diffChars(oldText, newText);
console.log(diff);
const result = diff.map((part) => {
if (part.added) {
if (part.value.replace(/\n/g, '').length <= 0) {