quill-uploader
Version:
Quill custom Uploader, supports images, videos, and attachments, with customizable loading indicators.
41 lines (40 loc) • 1.11 kB
JavaScript
import _Quill from 'quill';
const Quill = window.Quill || _Quill;
const Link = Quill.import('formats/link');
class CustomLink extends Link {
static create(value) {
if (typeof value === 'string') {
value = {
url: value
};
}
const node = super.create(value.url);
if (value.download) {
node.setAttribute('download', value.download);
delete value.download;
}
delete value.url;
Object.assign(node.dataset, value);
return node;
}
static formats(domNode) {
const res = Object.assign({}, domNode.dataset);
if (!res.url) {
res.url = domNode.getAttribute('href');
}
return res;
}
static register() {
const Block = Quill.import('blots/block');
Block.allowedChildren.push(CustomLink);
}
format(name, value) {
if (value && typeof value === 'object') {
super.format(name, value.url);
}
else {
super.format(name, value);
}
}
}
export default CustomLink;