cyrusae / highlighter-public

Next.js/SQLite app for qualitative coding and content analysis; prototype currently in (sometimes) working alpha.
Other
3 stars 0 forks source link

Determine why highlighting preview breaks #48

Open cyrusae opened 2 years ago

cyrusae commented 2 years ago

Code:


 useEffect(() => {
  document.addEventListener('selectionchange', () => {
   let selection = document.getSelection().anchorNode.parentElement;
   if (selection != null) {
   if (selection.tagName ===  'mark') { 
    setPhrase(selection.innerText);
    if (code != null && code != '') {
     setPhrase('<mark class="' + code +  '">' + selection.innerText + '</mark>')
    }    
   } else {
    let sentence = document.getSelection().toString();
    setPhrase(sentence);
    if (code != null && code != '') {
     setPhrase('<mark class="' + code + '">' + sentence + '</mark>')
    }
   }
  }
   document.getElementById('phReview').innerHTML = phrase;
  })
 })

Issues:

cyrusae commented 2 years ago

and (in [statementID].tsx)

document.addEventListener('selectionstart', () => {
     phrase.innerHTML = words;
     phrase.removeEventListener('pointerenter', () => {
      phrase.innerHTML += tooltip;
     });
    })