How to use the slate-react.ReactEditor.toDOMRange function in slate-react

To help you get started, we’ve selected a few slate-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redwood / redwood / demos / desktop-chat-app / frontend / src / components / Chat.jsx View on Github external
useEffect(() => {
      if (targetMention && mentionUsers.length > 0) {
        const el = mentionRef.current
        const domRange = ReactEditor.toDOMRange(editor, targetMention)
        const rect = domRange.getBoundingClientRect()
        const topCalc = 68 + (mentionUsers.length * 28)

        el.style.top = `-${topCalc}px`
        el.style.left = '0px'
      }
    }, [mentionUsers.length, editor, indexMention, searchMention, targetMention])
github ianstormtaylor / slate / site / examples / mentions.js View on Github external
useEffect(() => {
    if (target && chars.length > 0) {
      const el = ref.current
      const domRange = ReactEditor.toDOMRange(editor, target)
      const rect = domRange.getBoundingClientRect()
      el.style.top = `${rect.top + window.pageYOffset + 24}px`
      el.style.left = `${rect.left + window.pageXOffset}px`
    }
  }, [chars.length, editor, index, search, target])