Closed rebryk closed 1 year ago
I managed to override ImageBlot to allow the alt attribute with the following:
--TS--
if (Quill && !quill) {
const BlockEmbed = Quill.import('blots/block/embed');
/// OVERRIDE IMAGE BLOT ///
class ImageBlot extends BlockEmbed {
static create(value) {
const node = super.create();
node.setAttribute('alt', value.alt);
node.setAttribute('src', value.src);
return node;
}
static value(node) {
return {
alt: node.getAttribute('alt') as string,
url: node.getAttribute('src') as string,
};
}
}
ImageBlot.blotName = 'image';
ImageBlot.tagName = 'img';
Quill.register({ 'formats/imageBlot': ImageBlot });
}
Hopefully, that helps you out!
Thank you so much! @meep-morp
I am trying to clone medium with parchment using this library. But I don't understand how to define a new blot.
Could you please help me to replicate the following code?