img src attribute is set to [object Object]
Opened this issue · 2 comments
bastienguillon commented
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: bastienguillon@3ee6fdb
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>
bastienguillon commented
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;
};
}
}
volser commented
in standard quill delta, image
is string. It looks like you changed format