From 125a8091bb166a36910bba482adbffffa093552b Mon Sep 17 00:00:00 2001 From: samueljd Date: Fri, 19 Jan 2024 14:34:14 +0530 Subject: [PATCH] removed highlight text --- .../components/EditorPage/TextEditor/RecursiveBlock.jsx | 4 ++-- .../EditorPage/TextEditor/utils/getReferences.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx b/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx index c72a35c9..ce97f24a 100644 --- a/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx +++ b/renderer/src/components/EditorPage/TextEditor/RecursiveBlock.jsx @@ -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'; @@ -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(); diff --git a/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js b/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js index 22f00001..b923fa37 100644 --- a/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js +++ b/renderer/src/components/EditorPage/TextEditor/utils/getReferences.js @@ -1,13 +1,13 @@ 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 }; }; @@ -15,7 +15,7 @@ export const getCurrentVerse = (currentNode) => { 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); });