src/backend/highlighter.js
function getFragmentRect ({ _fragmentStart, _fragmentEnd }) {
  let top, bottom, left, right
  util().mapNodeRange(_fragmentStart, _fragmentEnd, function (node) {
    let rect
    if (node.nodeType === 1 || node.getBoundingClientRect) {
      rect = node.getBoundingClientRect()
    } else if (node.nodeType === 3 && node.data.trim()) {
      rect = getTextRect(node)
    }
    if (rect) {
      if (!top || rect.top < top) {
        top = rect.top
      }
      if (!bottom || rect.bottom > bottom) {
        bottom = rect.bottom
      }
      if (!left || rect.left < left) {
        left = rect.left
      }
      if (!right || rect.right > right) {
        right = rect.right
      }
    }
  })
  return {
    top,
    left,
    width: right - left,
    height: bottom - top
  }
}
function getFragmentRect ({ _fragmentStart, _fragmentEnd }) {
  let top, bottom, left, right
  util().mapNodeRange(_fragmentStart, _fragmentEnd, function (node) {
    let rect
    if (node.nodeType === 1 || node.getBoundingClientRect) {
      rect = node.getBoundingClientRect()
    } else if (node.nodeType === 3 && node.data.trim()) {
      rect = getTextRect(node)
    }
    if (rect) {
      if (!top || rect.top < top) {
        top = rect.top
      }
      if (!bottom || rect.bottom > bottom) {
        bottom = rect.bottom
      }
      if (!left || rect.left < left) {
        left = rect.left
      }
      if (!right || rect.right > right) {
        right = rect.right
      }
    }
  })
  return {
    top,
    left,
    width: right - left,
    height: bottom - top
  }
}
function getFragmentRect ( { _fragmentStart , _fragmentEnd } ) { let top , bottom , left , right util ( ) . mapNodeRange ( _fragmentStart , _fragmentEnd , function ( node ) { let rect if ( node . nodeType === 1 || node . getBoundingClientRect ) { rect = node . getBoundingClientRect ( ) } else if ( node . nodeType === 3 && node . data . trim ( ) ) { rect = getTextRect ( node ) } if ( rect ) { if ( ! top || rect . top < top ) { top = rect . top } if ( ! bottom || rect . bottom > bottom ) { bottom = rect . bottom } if ( ! left || rect . left < left ) { left = rect . left } if ( ! right || rect . right > right ) { right = rect . right } } } ) return { top , left , width : right - left , height : bottom - top } }
Highlight a fragment instance.
Loop over its node range and determine its bounding box.

@param {Vue} instance
@return {Object}
Highlight a fragment instance . Loop over its node range and determine its bounding box .