fraudTech commited on
Commit
e936155
·
1 Parent(s): e27fa3c

copy chat

Browse files
Files changed (2) hide show
  1. web/src/App.css +50 -0
  2. web/src/App.tsx +32 -3
web/src/App.css CHANGED
@@ -436,6 +436,13 @@ body {
436
  padding-bottom: 0.5rem;
437
  border-bottom: 1px solid #3a342e;
438
  gap: 2rem;
 
 
 
 
 
 
 
439
  }
440
 
441
  .message-role {
@@ -449,6 +456,49 @@ body {
449
  .message-time {
450
  color: #6e5d4d;
451
  opacity: 0.8;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  }
453
 
454
  .message-content {
 
436
  padding-bottom: 0.5rem;
437
  border-bottom: 1px solid #3a342e;
438
  gap: 2rem;
439
+ align-items: center;
440
+ }
441
+
442
+ .message-header-right {
443
+ display: flex;
444
+ align-items: center;
445
+ gap: 0.75rem;
446
  }
447
 
448
  .message-role {
 
456
  .message-time {
457
  color: #6e5d4d;
458
  opacity: 0.8;
459
+ font-size: 0.75rem;
460
+ }
461
+
462
+ /* Copy Markdown Button */
463
+ .copy-markdown-btn {
464
+ display: inline-flex;
465
+ align-items: center;
466
+ gap: 0.35rem;
467
+ padding: 0.35rem 0.65rem;
468
+ background: #2a2520;
469
+ border: 1px solid #3a342e;
470
+ color: #8b7355;
471
+ border-radius: 4px;
472
+ cursor: pointer;
473
+ font-size: 0.75rem;
474
+ font-weight: 500;
475
+ transition: all 0.2s ease;
476
+ opacity: 0.7;
477
+ }
478
+
479
+ .copy-markdown-btn:hover {
480
+ opacity: 1;
481
+ background: #3a342e;
482
+ color: #c9b8a3;
483
+ border-color: #4a433c;
484
+ transform: translateY(-1px);
485
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
486
+ }
487
+
488
+ .copy-markdown-btn:active {
489
+ transform: translateY(0);
490
+ box-shadow: none;
491
+ }
492
+
493
+ .copy-markdown-btn svg {
494
+ width: 13px;
495
+ height: 13px;
496
+ stroke-width: 2.5;
497
+ }
498
+
499
+ .copy-btn-text {
500
+ font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
501
+ letter-spacing: 0.3px;
502
  }
503
 
504
  .message-content {
web/src/App.tsx CHANGED
@@ -498,6 +498,22 @@ function App() {
498
  }
499
  };
500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  const saveApiKey = () => {
502
  localStorage.setItem('deepseek_api_key', apiKey);
503
  setShowSettings(false);
@@ -583,9 +599,22 @@ function App() {
583
  <span className="message-role">
584
  {message.role === 'user' ? 'You' : 'Assistant'}
585
  </span>
586
- <span className="message-time">
587
- {message.timestamp.toLocaleTimeString()}
588
- </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
589
  </div>
590
  <div className="message-content">
591
  <ReactMarkdown
 
498
  }
499
  };
500
 
501
+ const copyAsMarkdown = (content: string) => {
502
+ navigator.clipboard.writeText(content).then(() => {
503
+ // Show a brief success indication
504
+ const btn = document.activeElement as HTMLElement;
505
+ if (btn) {
506
+ const originalText = btn.innerText;
507
+ btn.innerText = 'Copied!';
508
+ setTimeout(() => {
509
+ btn.innerText = originalText;
510
+ }, 2000);
511
+ }
512
+ }).catch(err => {
513
+ console.error('Failed to copy:', err);
514
+ });
515
+ };
516
+
517
  const saveApiKey = () => {
518
  localStorage.setItem('deepseek_api_key', apiKey);
519
  setShowSettings(false);
 
599
  <span className="message-role">
600
  {message.role === 'user' ? 'You' : 'Assistant'}
601
  </span>
602
+ <div className="message-header-right">
603
+ <button
604
+ className="copy-markdown-btn"
605
+ onClick={() => copyAsMarkdown(message.content)}
606
+ title="Copy as markdown"
607
+ >
608
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
609
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
610
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
611
+ </svg>
612
+ <span className="copy-btn-text">Copy MD</span>
613
+ </button>
614
+ <span className="message-time">
615
+ {message.timestamp.toLocaleTimeString()}
616
+ </span>
617
+ </div>
618
  </div>
619
  <div className="message-content">
620
  <ReactMarkdown