我正在取得进展但不太确定如何使这项工作正常......
我有一个contenteditable div,其功能类似于textarea.
我还有一个正则表达式来识别输入的URL并自动链接它们.我遇到了麻烦,但是当用户输入时,这项工作是"实时"的.
这是迄今为止我所拥有的jsFiddle.我遇到的另一个问题是在输入链接后光标跳转到div的开头(因为我正在替换div .html()?)
是否有创造性的解决方案用于.replace()div中的单个文本字符串而无需替换div的整个内容?
当我尝试在文本框中粘贴网址时,https://stackoverflow.com/它不会自动转换为超链接.
我尝试使用正则表达式这是我之前提出的问题.我在这个问题中使用的功能工作正常,但实际上它将替换所有链接,包括标签中的链接(IMG,现有的A HREF).
我不想使用regx,如果我使用regx转换发生时,我点击任何提交或保存按钮.
**当用户在文本框中粘贴网址时,它应自动将任何链接转换为超链接****
我用regx尝试过这个
例如:
what = "<span>In the task system, is there a way to automatically have any site / page URL or image URL be hyperlinked in a new window?</span><br><br><span>So If I type or copy http://www.stackoverflow.com/ for example anywhere in the description, in any of the internal messages or messages to clients, it automatically is a hyperlink in a new window.</span><br><a href="http://www.stackoverflow.com/">http://www.stackoverflow.com/</a><br> <br><span>Or if I input an image URL anywhere in …Run Code Online (Sandbox Code Playgroud)