Upload folder using huggingface_hub
Browse files
client/src/components/Refinity.tsx
CHANGED
|
@@ -470,6 +470,21 @@ const Refinity: React.FC = () => {
|
|
| 470 |
} catch {}
|
| 471 |
finally { setCompareLoading(false); }
|
| 472 |
}} disabled={!compareA || !compareB || compareA===compareB || compareLoading} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white disabled:opacity-50">{compareLoading ? 'Computing…' : 'Show Diff'}</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
<button onClick={()=>{ setCompareUIOpen(false); setCompareA(''); setCompareB(''); }} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white">Close</button>
|
| 474 |
</div>
|
| 475 |
</div>
|
|
@@ -486,7 +501,25 @@ const Refinity: React.FC = () => {
|
|
| 486 |
<div className="relative max-w-5xl w-full rounded-2xl bg-white shadow-2xl ring-1 ring-gray-200 p-6">
|
| 487 |
<div className="flex items-center justify-between mb-3">
|
| 488 |
<div className="text-gray-800 font-medium">Diff</div>
|
| 489 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
</div>
|
| 491 |
<div className="prose prose-sm max-w-none text-gray-900" dangerouslySetInnerHTML={{ __html: compareDiffHtml }} />
|
| 492 |
</div>
|
|
|
|
| 470 |
} catch {}
|
| 471 |
finally { setCompareLoading(false); }
|
| 472 |
}} disabled={!compareA || !compareB || compareA===compareB || compareLoading} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white disabled:opacity-50">{compareLoading ? 'Computing…' : 'Show Diff'}</button>
|
| 473 |
+
<button onClick={async()=>{
|
| 474 |
+
const a = taskVersions.find(v=>v.id===compareA);
|
| 475 |
+
const b = taskVersions.find(v=>v.id===compareB);
|
| 476 |
+
if (!a || !b || a.id===b.id) return;
|
| 477 |
+
try {
|
| 478 |
+
const base = ((api.defaults as any)?.baseURL as string || '').replace(/\/$/, '');
|
| 479 |
+
const filename = `${(task?.title||'Task').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_${(username||'User').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_diff.docx`;
|
| 480 |
+
const resp = await fetch(`${base}/api/refinity/track-changes-comments`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prev: a.content||'', current: b.content||'', filename }) });
|
| 481 |
+
if (!resp.ok) throw new Error('Export failed');
|
| 482 |
+
const blob = await resp.blob();
|
| 483 |
+
const url = window.URL.createObjectURL(blob);
|
| 484 |
+
const link = document.createElement('a');
|
| 485 |
+
link.href = url; link.download = filename; document.body.appendChild(link); link.click(); link.remove(); window.URL.revokeObjectURL(url);
|
| 486 |
+
} catch {}
|
| 487 |
+
}} disabled={!compareA || !compareB || compareA===compareB} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white">Download with Track Changes</button>
|
| 488 |
<button onClick={()=>{ setCompareUIOpen(false); setCompareA(''); setCompareB(''); }} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white">Close</button>
|
| 489 |
</div>
|
| 490 |
</div>
|
|
|
|
| 501 |
<div className="relative max-w-5xl w-full rounded-2xl bg-white shadow-2xl ring-1 ring-gray-200 p-6">
|
| 502 |
<div className="flex items-center justify-between mb-3">
|
| 503 |
<div className="text-gray-800 font-medium">Diff</div>
|
| 504 |
+
<div className="flex items-center gap-2">
|
| 505 |
+
<button onClick={async()=>{
|
| 506 |
+
// For modal, try to reuse last computed A/B by using flow center and previous neighbor if available
|
| 507 |
+
const center = taskVersions[flowIndex];
|
| 508 |
+
const prev = taskVersions[flowIndex-1] || taskVersions[flowIndex];
|
| 509 |
+
if (!center) { setCompareModalOpen(false); return; }
|
| 510 |
+
try {
|
| 511 |
+
const base = ((api.defaults as any)?.baseURL as string || '').replace(/\/$/, '');
|
| 512 |
+
const filename = `${(task?.title||'Task').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_${(username||'User').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_diff.docx`;
|
| 513 |
+
const resp = await fetch(`${base}/api/refinity/track-changes-comments`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prev: (prev?.content||''), current: (center?.content||''), filename }) });
|
| 514 |
+
if (!resp.ok) throw new Error('Export failed');
|
| 515 |
+
const blob = await resp.blob();
|
| 516 |
+
const url = window.URL.createObjectURL(blob);
|
| 517 |
+
const link = document.createElement('a');
|
| 518 |
+
link.href = url; link.download = filename; document.body.appendChild(link); link.click(); link.remove(); window.URL.revokeObjectURL(url);
|
| 519 |
+
} catch {}
|
| 520 |
+
}} className="px-3 py-1.5 text-sm rounded-md border border-gray-300 bg-white">Download with Track Changes</button>
|
| 521 |
+
<button onClick={()=>setCompareModalOpen(false)} className="px-3 py-1.5 text-sm rounded-md border border-gray-300 bg-white">Close</button>
|
| 522 |
+
</div>
|
| 523 |
</div>
|
| 524 |
<div className="prose prose-sm max-w-none text-gray-900" dangerouslySetInnerHTML={{ __html: compareDiffHtml }} />
|
| 525 |
</div>
|