Search:: quill editor I try to edit embed link, but edit button does not work
Modify Link.sanitize
const Link = Quill.import('formats/link');
const originalSanitize = Link.sanitize;
Link.sanitize = function customSanitizeLinkInput(linkValueInput: any) {
let val = linkValueInput;
if (!/^(https|http?:\/\/)/.test(val)) val = `https://${val}`;
return originalSanitize.call(this, val); // retain the built-in logic
};
Quill link handler not working
Create module to customize sanitization
import Quill from "quill";
const Link = Quill.import('formats/link');
class CustomLink extends Link {
static sanitize(url: string): string {
const protocolPattern = /^(https?:\/\/)/;
if (!protocolPattern.test(url)) {
return 'http://' + url;
}
return super.sanitize(url);
}
}
CustomLink.blotName = 'link';
CustomLink.tagName = 'A';
Quill.register(CustomLink);
'✘✘✘ Javascript > Quill' 카테고리의 다른 글
[quill] setContents does not work on image attributes? (0) | 2023.05.06 |
---|---|
[Quill] innerHTML = content 사용 시 생기는 문제점 (0) | 2023.05.04 |
[Quill] Quill.prototype.focus(): 스크롤 최상단 초기화 (0) | 2023.04.14 |
[Quill] 툴바에 호버 시 tooltip 보여주기 (0) | 2023.04.05 |
댓글