youssefreda9 commited on
Commit
5a4f444
·
1 Parent(s): 5786389

fix: Ctrl+Q works with Arabic keyboard (e.code) + copy button for translations

Browse files
Files changed (1) hide show
  1. src/index.html +17 -3
src/index.html CHANGED
@@ -1300,6 +1300,7 @@
1300
  }
1301
  // Show apply translation button
1302
  document.getElementById('quran-apply-trans-btn').classList.remove('is-hidden');
 
1303
 
1304
  } catch (err) {
1305
  textEl.innerHTML = '<span class="text-secondary">حدث خطأ في الترجمة</span>';
@@ -1323,14 +1324,26 @@
1323
  });
1324
  }
1325
 
1326
- // Ctrl+Q → Quran verification shortcut
1327
  document.addEventListener('keydown', (e) => {
1328
- if ((e.ctrlKey || e.metaKey) && (e.key === 'q' || e.key === 'Q')) {
1329
  e.preventDefault();
1330
  verifyQuranText();
1331
  }
1332
  });
1333
 
 
 
 
 
 
 
 
 
 
 
 
 
1334
  function _replaceInEditor(newText, ref) {
1335
  var editor = document.getElementById('editor-container');
1336
  if (!editor || !_quranCurrentQuery) return false;
@@ -1790,7 +1803,8 @@
1790
  <div id="quran-translation-result" class="is-hidden p-4 rounded-xl" style="background:rgba(6,182,212,0.06); border:1px solid rgba(6,182,212,0.15);">
1791
  <p id="quran-translation-text" style="font-size:20px; line-height:2; color:var(--color-text-primary); text-align:center;"></p>
1792
  <p id="quran-translation-ref" class="quran-reference" style="display:none;"></p>
1793
- <div class="flex items-center justify-center mt-3">
 
1794
  <button id="quran-apply-trans-btn" onclick="applyQuranTranslation()" class="quran-apply-btn is-hidden" type="button">تطبيق الترجمة ✓</button>
1795
  </div>
1796
  </div>
 
1300
  }
1301
  // Show apply translation button
1302
  document.getElementById('quran-apply-trans-btn').classList.remove('is-hidden');
1303
+ document.getElementById('quran-copy-trans-btn').classList.remove('is-hidden');
1304
 
1305
  } catch (err) {
1306
  textEl.innerHTML = '<span class="text-secondary">حدث خطأ في الترجمة</span>';
 
1324
  });
1325
  }
1326
 
1327
+ // Ctrl+Q → Quran verification shortcut (e.code works with any keyboard language)
1328
  document.addEventListener('keydown', (e) => {
1329
+ if ((e.ctrlKey || e.metaKey) && e.code === 'KeyQ') {
1330
  e.preventDefault();
1331
  verifyQuranText();
1332
  }
1333
  });
1334
 
1335
+ function copyQuranTranslation() {
1336
+ const trans = _quranTransClean || '';
1337
+ const ref = _quranTransRef ? ' [' + _quranTransRef + ']' : '';
1338
+ const text = trans + ref;
1339
+ if (!text.trim()) return;
1340
+ navigator.clipboard.writeText(text).then(() => {
1341
+ if (typeof showToast === 'function') showToast('✓ تم نسخ الترجمة');
1342
+ const btn = document.getElementById('quran-copy-trans-btn');
1343
+ if (btn) { btn.textContent = '✅'; setTimeout(() => { btn.textContent = '📋'; }, 1500); }
1344
+ });
1345
+ }
1346
+
1347
  function _replaceInEditor(newText, ref) {
1348
  var editor = document.getElementById('editor-container');
1349
  if (!editor || !_quranCurrentQuery) return false;
 
1803
  <div id="quran-translation-result" class="is-hidden p-4 rounded-xl" style="background:rgba(6,182,212,0.06); border:1px solid rgba(6,182,212,0.15);">
1804
  <p id="quran-translation-text" style="font-size:20px; line-height:2; color:var(--color-text-primary); text-align:center;"></p>
1805
  <p id="quran-translation-ref" class="quran-reference" style="display:none;"></p>
1806
+ <div class="flex items-center justify-center gap-2 mt-3">
1807
+ <button id="quran-copy-trans-btn" onclick="copyQuranTranslation()" class="quran-copy-btn is-hidden" type="button" title="نسخ الترجمة">📋</button>
1808
  <button id="quran-apply-trans-btn" onclick="applyQuranTranslation()" class="quran-apply-btn is-hidden" type="button">تطبيق الترجمة ✓</button>
1809
  </div>
1810
  </div>