Quill.js image default only allow ‘src’, ‘alt’ ‘height’ and ‘width’ attribute.
Here are the solutions to add more attributes to image when initializing from fulltext html.
Solution1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Solution2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
You can specify the whitelist for attributes with solution2.
The quill.js depends on parchment and quill-delta.
Parchment is Quill’s document model. You can find Parchment.Embed here.
Deltas are a simple, yet expressive format that can be used to describe contents and changes.
I find the steps of initializing after diving into the source code and some debug:
constructor in core/quill.js –> clipboard.convert –> clipboard.matchBlot –> setContents –> applyDelta –> insertAt and formatAt
The matchBlot is key step for my solutions. It explains how quill compose the delta instance.
let value = match.value(node);
embed[match.blotName] = value;
delta = new Delta().insert(embed, match.formats(node));