Skip to content

Commit

Permalink
removed highlight text
Browse files Browse the repository at this point in the history
  • Loading branch information
samueljd committed Jan 19, 2024
1 parent 83b771e commit 125a809
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react';
import { HtmlPerfEditor } from '@xelah/type-perf-html';
import { getCurrentCursorPosition, pasteTextAtCursorPosition } from '@/util/cursorUtils';
import {
getCurrentVerse, getCurrentChapter, hightlightRefVerse,
getCurrentVerse, getCurrentChapter,
} from '@/components/EditorPage/TextEditor/utils/getReferences';
import { on } from 'ws';

Expand Down Expand Up @@ -61,7 +61,7 @@ export default function RecursiveBlock({
const { verse } = getCurrentVerse(selectedNode);
const chapter = getCurrentChapter(selectedNode);
onReferenceSelected({ bookId, chapter, verse });
!scrollLock && hightlightRefVerse(chapter, verse);
// !scrollLock && hightlightRefVerse(chapter, verse);
}
updateCursorPosition();
handleSelection();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
export const getCurrentVerse = (currentNode) => {
let verse;
let previousElement = currentNode.previousElementSibling;
const verseText = currentNode.nextSibling;
let previousElement = currentNode?.previousElementSibling;
const verseText = currentNode?.nextSibling;
while (previousElement) {
if (previousElement.dataset.type === 'mark' && previousElement.dataset.subtype === 'verses') {
verse = previousElement.dataset.attsNumber;
break;
}
previousElement = previousElement.previousElementSibling;
previousElement = previousElement?.previousElementSibling;
}
return { verse, verseText };
};

export const removeHighlightFromRefVerse = ({ c, v }) => {
const refEditors = document.getElementsByClassName('ref-editor');
refEditors.length > 0 && Array.prototype.filter.call(refEditors, (refEditor) => {
const prevHighlight = refEditor.querySelector(`#ch${c}v${v}`).nextElementSibling;
const prevHighlight = refEditor.querySelector(`#ch${c}v${v}`)?.nextElementSibling;
const hightlightText = prevHighlight && prevHighlight.innerHTML;
prevHighlight && prevHighlight.replaceWith(hightlightText);
});
Expand Down

0 comments on commit 125a809

Please sign in to comment.