Commit ·
80d7d85
1
Parent(s): ad7b1d2
fix: quran text excluded from analysis models + styled ref + score preserved
Browse files- src/css/components.css +7 -0
- src/index.html +4 -5
- src/js/renderer.js +2 -0
- src/js/selection.js +10 -4
src/css/components.css
CHANGED
|
@@ -3083,6 +3083,13 @@ input[type="range"]::-moz-range-thumb {
|
|
| 3083 |
background: none !important;
|
| 3084 |
cursor: default !important;
|
| 3085 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3086 |
|
| 3087 |
.quran-modal-backdrop {
|
| 3088 |
position: absolute;
|
|
|
|
| 3083 |
background: none !important;
|
| 3084 |
cursor: default !important;
|
| 3085 |
}
|
| 3086 |
+
.quran-ref-inline {
|
| 3087 |
+
font-size: 0.72em;
|
| 3088 |
+
opacity: 0.6;
|
| 3089 |
+
font-weight: 600;
|
| 3090 |
+
margin-right: 4px;
|
| 3091 |
+
color: #06b6d4;
|
| 3092 |
+
}
|
| 3093 |
|
| 3094 |
.quran-modal-backdrop {
|
| 3095 |
position: absolute;
|
src/index.html
CHANGED
|
@@ -1314,19 +1314,18 @@
|
|
| 1314 |
var editor = document.getElementById('editor-container');
|
| 1315 |
if (!editor || !_quranCurrentQuery) return false;
|
| 1316 |
closeQuranModal();
|
| 1317 |
-
// Build the full text with reference
|
| 1318 |
-
var fullText = newText;
|
| 1319 |
-
if (ref) fullText += ' [' + ref + ']';
|
| 1320 |
// Replace in editor: wrap in quran-applied span to protect from analysis
|
| 1321 |
var plain = editor.textContent || '';
|
| 1322 |
var idx = plain.indexOf(_quranCurrentQuery);
|
| 1323 |
if (idx === -1) return false;
|
| 1324 |
var before = plain.substring(0, idx);
|
| 1325 |
var after = plain.substring(idx + _quranCurrentQuery.length);
|
| 1326 |
-
// Build HTML: before
|
| 1327 |
var esc = function(t) { return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); };
|
|
|
|
| 1328 |
editor.innerHTML = esc(before) +
|
| 1329 |
-
'<span class="quran-applied" contenteditable="false" data-quran="true">' +
|
|
|
|
| 1330 |
esc(after);
|
| 1331 |
editor.focus();
|
| 1332 |
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
|
|
|
| 1314 |
var editor = document.getElementById('editor-container');
|
| 1315 |
if (!editor || !_quranCurrentQuery) return false;
|
| 1316 |
closeQuranModal();
|
|
|
|
|
|
|
|
|
|
| 1317 |
// Replace in editor: wrap in quran-applied span to protect from analysis
|
| 1318 |
var plain = editor.textContent || '';
|
| 1319 |
var idx = plain.indexOf(_quranCurrentQuery);
|
| 1320 |
if (idx === -1) return false;
|
| 1321 |
var before = plain.substring(0, idx);
|
| 1322 |
var after = plain.substring(idx + _quranCurrentQuery.length);
|
| 1323 |
+
// Build HTML: before + quran span (verse + styled ref) + after
|
| 1324 |
var esc = function(t) { return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); };
|
| 1325 |
+
var refHTML = ref ? ' <span class="quran-ref-inline">[' + esc(ref) + ']</span>' : '';
|
| 1326 |
editor.innerHTML = esc(before) +
|
| 1327 |
+
'<span class="quran-applied" contenteditable="false" data-quran="true">' +
|
| 1328 |
+
esc(newText) + refHTML + '</span>' +
|
| 1329 |
esc(after);
|
| 1330 |
editor.focus();
|
| 1331 |
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
src/js/renderer.js
CHANGED
|
@@ -221,6 +221,8 @@ function walkTextNodes(root, callback) {
|
|
| 221 |
function clearOverlays(editor) {
|
| 222 |
const errorSpans = editor.querySelectorAll('.spelling-error, .grammar-error, .punctuation-suggestion');
|
| 223 |
errorSpans.forEach(span => {
|
|
|
|
|
|
|
| 224 |
const parent = span.parentNode;
|
| 225 |
while (span.firstChild) {
|
| 226 |
parent.insertBefore(span.firstChild, span);
|
|
|
|
| 221 |
function clearOverlays(editor) {
|
| 222 |
const errorSpans = editor.querySelectorAll('.spelling-error, .grammar-error, .punctuation-suggestion');
|
| 223 |
errorSpans.forEach(span => {
|
| 224 |
+
// Skip spans inside quran-applied (they shouldn't be there, but safety)
|
| 225 |
+
if (span.closest('.quran-applied')) return;
|
| 226 |
const parent = span.parentNode;
|
| 227 |
while (span.firstChild) {
|
| 228 |
parent.insertBefore(span.firstChild, span);
|
src/js/selection.js
CHANGED
|
@@ -182,14 +182,20 @@ function setCaretOffset(offset) {
|
|
| 182 |
|
| 183 |
/**
|
| 184 |
* Gets the text content of the editor
|
| 185 |
-
*
|
|
|
|
| 186 |
*/
|
| 187 |
function getEditorText() {
|
| 188 |
const editor = document.getElementById('editor-container');
|
| 189 |
if (!editor) return '';
|
| 190 |
-
//
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
}
|
| 194 |
|
| 195 |
/**
|
|
|
|
| 182 |
|
| 183 |
/**
|
| 184 |
* Gets the text content of the editor
|
| 185 |
+
* Masks quran-applied text with spaces to exclude from analysis
|
| 186 |
+
* @returns {string} - Plain text content (quran regions replaced with spaces)
|
| 187 |
*/
|
| 188 |
function getEditorText() {
|
| 189 |
const editor = document.getElementById('editor-container');
|
| 190 |
if (!editor) return '';
|
| 191 |
+
// Clone the editor to mask quran text without modifying the DOM
|
| 192 |
+
const clone = editor.cloneNode(true);
|
| 193 |
+
clone.querySelectorAll('.quran-applied').forEach(function(el) {
|
| 194 |
+
// Replace quran text with spaces of the same length to preserve offsets
|
| 195 |
+
var len = (el.textContent || '').length;
|
| 196 |
+
el.textContent = ' '.repeat(len);
|
| 197 |
+
});
|
| 198 |
+
return clone.textContent || '';
|
| 199 |
}
|
| 200 |
|
| 201 |
/**
|