Commit ·
7f379d2
1
Parent(s): dffd543
fix: simplify apply to direct textContent replace (guaranteed to work)
Browse files- src/index.html +8 -9
src/index.html
CHANGED
|
@@ -1309,17 +1309,16 @@
|
|
| 1309 |
function _replaceInEditor(newText) {
|
| 1310 |
var editor = document.getElementById('editor');
|
| 1311 |
if (!editor || !_quranCurrentQuery) return false;
|
| 1312 |
-
// Simple: get all text content, find the query, build selection via window.find
|
| 1313 |
closeQuranModal();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1314 |
editor.focus();
|
| 1315 |
-
|
| 1316 |
-
|
| 1317 |
-
if (found) {
|
| 1318 |
-
document.execCommand('insertText', false, newText);
|
| 1319 |
-
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
| 1320 |
-
return true;
|
| 1321 |
-
}
|
| 1322 |
-
return false;
|
| 1323 |
}
|
| 1324 |
|
| 1325 |
function applyQuranText() {
|
|
|
|
| 1309 |
function _replaceInEditor(newText) {
|
| 1310 |
var editor = document.getElementById('editor');
|
| 1311 |
if (!editor || !_quranCurrentQuery) return false;
|
|
|
|
| 1312 |
closeQuranModal();
|
| 1313 |
+
// Direct approach: get plain text, replace, set back
|
| 1314 |
+
var plain = editor.textContent || '';
|
| 1315 |
+
if (plain.indexOf(_quranCurrentQuery) === -1) return false;
|
| 1316 |
+
// Replace first occurrence only
|
| 1317 |
+
var newPlain = plain.replace(_quranCurrentQuery, newText);
|
| 1318 |
+
editor.textContent = newPlain;
|
| 1319 |
editor.focus();
|
| 1320 |
+
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
| 1321 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1322 |
}
|
| 1323 |
|
| 1324 |
function applyQuranText() {
|