detectWordsWithinDocument (str, doc, from=undefined) {
    let words = doc.getWords()
    //let text = doc.getText(true)
    let text = doc.getTextFromSmartBlocks(true)

    if (from === undefined || typeof from !== 'number') {
      from = text.indexOf(str)
    }

    // symbols does not includes spaces as characters, but as property
    // count spaces before search text starts
    let symbolsStart = from
    let spaces = text
      .substring(0, symbolsStart)
      .split(' ')
      .length - 1
    // and remove spaces from 0 to start
    symbolsStart -= spaces

    // do the same with the string end
    let symbolsEnd = str.length
    let start = from
    let end = start + symbolsEnd
    spaces = text
      .substring(start, end)
      .split(' ')
      .length - 1
    // and remove spaces from start to end
    symbolsEnd -= spaces

    let counter = 0
    let word
    let matchedWords = []
    let index = 0

    while (counter < (symbolsStart + symbolsEnd) && index < words.length) {
      word = words[index]
      counter += word.symbols.length
      if (counter > symbolsStart && counter <= (symbolsStart + symbolsEnd)) {
        matchedWords.push(word)
      }
      index++
    }

    return matchedWords
  }
/**
   *
   * this method use the annotation of the whole document to detect words annotation out of a string.
   *
   */
this method use the annotation of the whole document to detect words annotation out of a string.
this method use the annotation of the whole document to detect words annotation out of a string .
detectWordsWithinDocument (str, doc, from=undefined) {
    let words = doc.getWords()
    let text = doc.getTextFromSmartBlocks(true)
    if (from === undefined || typeof from !== 'number') {
      from = text.indexOf(str)
    }
    let symbolsStart = from
    let spaces = text
      .substring(0, symbolsStart)
      .split(' ')
      .length - 1
    symbolsStart -= spaces
    let symbolsEnd = str.length
    let start = from
    let end = start + symbolsEnd
    spaces = text
      .substring(start, end)
      .split(' ')
      .length - 1
    symbolsEnd -= spaces
    let counter = 0
    let word
    let matchedWords = []
    let index = 0
    while (counter < (symbolsStart + symbolsEnd) && index < words.length) {
      word = words[index]
      counter += word.symbols.length
      if (counter > symbolsStart && counter <= (symbolsStart + symbolsEnd)) {
        matchedWords.push(word)
      }
      index++
    }
    return matchedWords
  }
detectWordsWithinDocument ( str , doc , from = undefined ) { let words = doc . getWords ( ) let text = doc . getTextFromSmartBlocks ( true ) if ( from === undefined || typeof from !== 'number' ) { from = text . indexOf ( str ) } let symbolsStart = from let spaces = text . substring ( 0 , symbolsStart ) . split ( ' ' ) . length - 1 symbolsStart -= spaces let symbolsEnd = str . length let start = from let end = start + symbolsEnd spaces = text . substring ( start , end ) . split ( ' ' ) . length - 1 symbolsEnd -= spaces let counter = 0 let word let matchedWords = [ ] let index = 0 while ( counter < ( symbolsStart + symbolsEnd ) && index < words . length ) { word = words [ index ] counter += word . symbols . length if ( counter > symbolsStart && counter <= ( symbolsStart + symbolsEnd ) ) { matchedWords . push ( word ) } index ++ } return matchedWords }
this method use the annotation of the whole document to detect words annotation out of a string.
this method use the annotation of the whole document to detect words annotation out of a string .
//let text = doc.getText(true) // symbols does not includes spaces as characters, but as property // count spaces before search text starts // and remove spaces from 0 to start // do the same with the string end // and remove spaces from start to end