使用highlighter.js配置文本区域工具提示

Configure textarea tooltip with highlighter.js

本文关键字:区域 工具提示 置文本 配置 highlighter js 使用      更新时间:2023-09-26

我正试图在textarea中使用highlighter.js。我修改了他们的示例,用pre包装的textarea替换了p(用于bidi设置)。

    <div class="article" style="width: 80%; height: 80%;">
        <pre style="width: 100%; height: 100%;">
            <textarea style="width: 100%; height: 100%;">Highlight some body text! 
                This is a jQuery plugin that allows you to display a pop-up tooltip when a user highlights text. This can be useful in a variety
                of situations, and there didn't seem to be a good open source solution before this.
                on how to implement this on your website. It's very easy!
            </textarea>
        </pre>
    </div>

当我高亮显示一个单词时,无论单词的位置如何,工具提示都会弹出在错误的位置,即textarea的左下角。我该如何修复它?

这在Firefox和Chrome中对我有效。你在用什么浏览器。它在突出显示的区域中紧跟最后一个单词。如果我突出显示一个单词,它就会直接指向那个单词。希望这能有所帮助。