0
在使用Quill编辑器添加链接时,我必须包含协议,或者将链接视为相对链接。如何在Quill编辑器中预填充http链接?
当有人点击添加链接我想有现场预填充与http://
所以当用户类型google.com
它会创建一个链接到http://google.com
而不是http://myapp.net/something/google.com
。
堆栈溢出做到这一点...
在使用Quill编辑器添加链接时,我必须包含协议,或者将链接视为相对链接。如何在Quill编辑器中预填充http链接?
当有人点击添加链接我想有现场预填充与http://
所以当用户类型google.com
它会创建一个链接到http://google.com
而不是http://myapp.net/something/google.com
。
堆栈溢出做到这一点...
可以扩展与自定义逻辑链接的格式:
var Link = Quill.import('formats/link');
class MyLink extends Link {
static create(value) {
let node = super.create(value);
value = this.sanitize(value);
if(!value.startsWith("http")) {
value = "http://" + value;
}
node.setAttribute('href', value);
return node;
}
}
Quill.register(MyLink);