如何在Quill编辑器中超链接最后一个字母?

时间:2018-02-03 20:44:56

标签: javascript hyperlink quill

我有以下代码(也在jfiddle https://jsfiddle.net/96ye4hL4/1/上)

<!DOCTYPE html>
<meta charset="utf-8">
<html>
  <head>
    <link href="https://cdn.quilljs.com/1.2.0/quill.snow.css" rel="stylesheet">
    <script type="text/javascript" src="https://cdn.quilljs.com/1.2.0/quill.js"></script>
  </head>
  <body>
    <div id="editor0"></div>
    <script type="text/javascript">
      const quill = new Quill("#editor0", {
          modules: { toolbar: true },
          theme: "snow"
        });
        quill.setContents({"ops":[{"insert":"Index"},{"attributes":{"header":1},"insert":"\n"},{"attributes":{"link":"http://google.com"},"insert":"FooM"},{"insert":"\n"},{"insert":"\n"}]},)
    </script>
  </body>
</html>

当我点击超链接中最右边的字符(FooM中的M)时,超链接窗口不会弹出。

如何在点击FooM中的最后一个字母时弹出超链接窗口?

1 个答案:

答案 0 :(得分:0)

这是一个带有Quill库的open issue

https://github.com/quilljs/quill/issues/1931

请注意,您的代码段不会运行,但标准HREF会执行:

&#13;
&#13;
  <!DOCTYPE html>
    <meta charset="utf-8">
    <html>
      <head>
        <link href="https://cdn.quilljs.com/1.2.0/quill.snow.css" rel="stylesheet">
        <script type="text/javascript" src="https://cdn.quilljs.com/1.2.0/quill.js"></script>
      </head>
      <body>
        <div id="editor0"></div>
        <script type="text/javascript">
          const quill = new Quill("#editor0", {
              modules: { toolbar: true },
              theme: "snow"
            });
            quill.setContents({"ops":[{"insert":"Index"},{"attributes":{"header":1},"insert":"\n"},{"attributes":{"link":"http://google.com"},"insert":"FooM"},{"insert":"\n"},{"insert":"\n"}]},)
        </script>
        
        <a href= "http://google.com">FooM</a>
      </body>
    </html>
&#13;
&#13;
&#13;