quill-delta-to-html
quill-delta-to-html copied to clipboard
img src attribute is set to [object Object]
I have found a weird behavior when converting images insert ops : the src
attribute of the output img tag is always set to [object Object]
Here is a commit with a unit test which reproduces the issue: https://github.com/bastienguillon/quill-delta-to-html/commit/3ee6fdb05ac86344dc3c2895caed6327b0146b75
Input:
const delta = {
ops: [
{
insert: {
image: {
alt: null,
url: "https://i.imgur.com/XSoFJ8l.gif"
}
}
}
]
};
const output = new QuillDeltaToHtmlConverter(delta.ops, { urlSanitizer: url => url }).convert();
Expected output
<p><img class="ql-image" src="https://i.imgur.com/XSoFJ8l.gif"/></p>
Actual output
<p><img class="ql-image" src="[object Object]"/></p>
I wrote a dirty hack to temporarily fix the issue, but it is clearly not a viable solution
for (const op of delta.ops) {
if (op?.insert?.image) {
op.insert.image.toString = () => {
return op.insert.image.url;
};
}
}
in standard quill delta, image
is string. It looks like you changed format