Upload folder using huggingface_hub
Browse files
client/src/components/Refinity.tsx
CHANGED
|
@@ -46,6 +46,7 @@ const Refinity: React.FC = () => {
|
|
| 46 |
const [compareModalOpen, setCompareModalOpen] = React.useState<boolean>(false);
|
| 47 |
const [compareDiffHtml, setCompareDiffHtml] = React.useState<string>('');
|
| 48 |
const [compareLoading, setCompareLoading] = React.useState<boolean>(false);
|
|
|
|
| 49 |
const [username] = React.useState<string>(() => {
|
| 50 |
try {
|
| 51 |
const u = localStorage.getItem('user');
|
|
@@ -544,40 +545,49 @@ const Refinity: React.FC = () => {
|
|
| 544 |
} catch {}
|
| 545 |
finally { setCompareLoading(false); }
|
| 546 |
}} 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>
|
| 547 |
-
<
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
<button onClick={()=>{ setCompareUIOpen(false); setCompareA(''); setCompareB(''); }} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white">Close</button>
|
| 582 |
</div>
|
| 583 |
</div>
|
|
@@ -777,7 +787,13 @@ const EditorPane: React.FC<{ source: string; initialTranslation: string; onBack:
|
|
| 777 |
/>
|
| 778 |
<div className="mt-4 flex gap-3">
|
| 779 |
<button onClick={save} disabled={saving} className="relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-white ring-1 ring-inset ring-white/50 backdrop-blur-md backdrop-brightness-110 backdrop-saturate-150 bg-indigo-600/70 disabled:bg-gray-400 active:translate-y-0.5 transition-all duration-200">{saving? 'Saving…':'Save'}</button>
|
| 780 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 781 |
<button onClick={onBack} className="ml-auto relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-black ring-1 ring-inset ring-white/50 backdrop-blur-md bg-white/30 active:translate-y-0.5 transition-all duration-200">Back</button>
|
| 782 |
</div>
|
| 783 |
{showDiff && (
|
|
|
|
| 46 |
const [compareModalOpen, setCompareModalOpen] = React.useState<boolean>(false);
|
| 47 |
const [compareDiffHtml, setCompareDiffHtml] = React.useState<string>('');
|
| 48 |
const [compareLoading, setCompareLoading] = React.useState<boolean>(false);
|
| 49 |
+
const [compareDownloadOpen, setCompareDownloadOpen] = React.useState<boolean>(false);
|
| 50 |
const [username] = React.useState<string>(() => {
|
| 51 |
try {
|
| 52 |
const u = localStorage.getItem('user');
|
|
|
|
| 545 |
} catch {}
|
| 546 |
finally { setCompareLoading(false); }
|
| 547 |
}} 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>
|
| 548 |
+
<div className="relative">
|
| 549 |
+
<button onClick={()=>setCompareDownloadOpen(v=>!v)} disabled={!compareA || !compareB || compareA===compareB} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white">Download ▾</button>
|
| 550 |
+
{compareDownloadOpen && (
|
| 551 |
+
<div className="absolute right-0 mt-1 w-48 rounded-md border border-gray-200 bg-white shadow-lg z-20">
|
| 552 |
+
<button onClick={async()=>{
|
| 553 |
+
setCompareDownloadOpen(false);
|
| 554 |
+
const a = taskVersions.find(v=>v.id===compareA);
|
| 555 |
+
const b = taskVersions.find(v=>v.id===compareB);
|
| 556 |
+
if (!a || !b || a.id===b.id) return;
|
| 557 |
+
try {
|
| 558 |
+
const base = ((api.defaults as any)?.baseURL as string || '').replace(/\/$/, '');
|
| 559 |
+
const latestReviser = (b.revisedBy || b.originalAuthor || username || 'User');
|
| 560 |
+
const filename = `${(task?.title||'Task').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_${(latestReviser||'User').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_ooxml.docx`;
|
| 561 |
+
const body = { prev: a.content||'', current: b.content||'', filename, authorName: latestReviser };
|
| 562 |
+
const resp = await fetch(`${base}/api/refinity/track-changes-ooxml`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
| 563 |
+
if (!resp.ok) throw new Error('Export failed');
|
| 564 |
+
const blob = await resp.blob();
|
| 565 |
+
const url = window.URL.createObjectURL(blob);
|
| 566 |
+
const link = document.createElement('a');
|
| 567 |
+
link.href = url; link.download = filename; document.body.appendChild(link); link.click(); link.remove(); window.URL.revokeObjectURL(url);
|
| 568 |
+
} catch {}
|
| 569 |
+
}} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Inline Changes</button>
|
| 570 |
+
<button onClick={async()=>{
|
| 571 |
+
setCompareDownloadOpen(false);
|
| 572 |
+
const a = taskVersions.find(v=>v.id===compareA);
|
| 573 |
+
const b = taskVersions.find(v=>v.id===compareB);
|
| 574 |
+
if (!a || !b || a.id===b.id) return;
|
| 575 |
+
try {
|
| 576 |
+
const base = ((api.defaults as any)?.baseURL as string || '').replace(/\/$/, '');
|
| 577 |
+
const latestReviser = (b.revisedBy || b.originalAuthor || username || 'User');
|
| 578 |
+
const filename = `${(task?.title||'Task').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_${(latestReviser||'User').replace(/[^\w\-\s]/g,'').replace(/\s+/g,'_')}_diff.docx`;
|
| 579 |
+
const body = { prev: a.content||'', current: b.content||'', filename, authorName: latestReviser };
|
| 580 |
+
const resp = await fetch(`${base}/api/refinity/track-changes-comments`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
| 581 |
+
if (!resp.ok) throw new Error('Export failed');
|
| 582 |
+
const blob = await resp.blob();
|
| 583 |
+
const url = window.URL.createObjectURL(blob);
|
| 584 |
+
const link = document.createElement('a');
|
| 585 |
+
link.href = url; link.download = filename; document.body.appendChild(link); link.click(); link.remove(); window.URL.revokeObjectURL(url);
|
| 586 |
+
} catch {}
|
| 587 |
+
}} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Side Comments</button>
|
| 588 |
+
</div>
|
| 589 |
+
)}
|
| 590 |
+
</div>
|
| 591 |
<button onClick={()=>{ setCompareUIOpen(false); setCompareA(''); setCompareB(''); }} className="px-3 py-2 text-sm rounded-md border border-gray-300 bg-white">Close</button>
|
| 592 |
</div>
|
| 593 |
</div>
|
|
|
|
| 787 |
/>
|
| 788 |
<div className="mt-4 flex gap-3">
|
| 789 |
<button onClick={save} disabled={saving} className="relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-white ring-1 ring-inset ring-white/50 backdrop-blur-md backdrop-brightness-110 backdrop-saturate-150 bg-indigo-600/70 disabled:bg-gray-400 active:translate-y-0.5 transition-all duration-200">{saving? 'Saving…':'Save'}</button>
|
| 790 |
+
<div className="relative">
|
| 791 |
+
<button onClick={(e)=>{ e.preventDefault(); const m = document.getElementById('rev-download-menu'); if (m) m.classList.toggle('hidden'); }} className="relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-black ring-1 ring-inset ring-white/50 backdrop-blur-md bg-white/30 active:translate-y-0.5 transition-all duration-200">Download ▾</button>
|
| 792 |
+
<div id="rev-download-menu" className="hidden absolute z-20 mt-1 w-48 rounded-md border border-gray-200 bg-white shadow-lg">
|
| 793 |
+
<button onClick={(e)=>{ e.preventDefault(); const m=document.getElementById('rev-download-menu'); if(m) m.classList.add('hidden'); downloadWithTrackChanges(); }} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Track Changes</button>
|
| 794 |
+
<button onClick={(e)=>{ e.preventDefault(); const m=document.getElementById('rev-download-menu'); if(m) m.classList.add('hidden'); compareNow(); }} className="block w-full text-left px-3 py-2 text-sm hover:bg-gray-50">Inline Diff (Preview)</button>
|
| 795 |
+
</div>
|
| 796 |
+
</div>
|
| 797 |
<button onClick={onBack} className="ml-auto relative overflow-hidden inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-medium rounded-2xl text-black ring-1 ring-inset ring-white/50 backdrop-blur-md bg-white/30 active:translate-y-0.5 transition-all duration-200">Back</button>
|
| 798 |
</div>
|
| 799 |
{showDiff && (
|