In my application, users can create margin-comments anywhere in the document body, and the comment-anchor ranges can overlap arbitrarily, like this:
This [abc]is a set of [xyz]overlapping[/xyz] comments[/abc]
I'm defining my comment-anchor blot like this:
let Inline = Quill.import('blots/inline');
class CommentAnchorBlot extends Inline {
static create(commentId) {
let node = super.create();
node.setAttribute("class", "comment-anchor comment-anchor-" + commentId);
return node;
}
static formats(node) {
var classNames = node.getAttribute('class').split(/\s+/);
for (var i = 0, len = classNames.length; i < len; i++) {
var className = classNames[i];
if (className.indexOf("comment-anchor-") === 0) {
return className.replace("comment-anchor-", "");
}
}
return null;
}
}
CommentAnchorBlot.blotName = 'comment';
CommentAnchorBlot.className = 'comment-anchor';
CommentAnchorBlot.tagName = 'span';
Quill.register(CommentAnchorBlot);
But when I test it out in a running Quill instance, it generates parchment like this:
{
"ops" : [
{ "insert" : "This " },
{ "insert" : "is a set of ", "attributes" : { "comment" : "abc" } },
{ "insert" : "overlapping ", "attributes" : { "comment" : "xyz" } },
{ "insert" : " comments", "attributes" : { "comment" : "abc" } }
]
}
Which is problematic, because the word "overlapping" should actually have both "abc" and "xyz" as its comment anchor IDs.
How would you recommend changing the CommentAnchorBlot definition, to accommodate this requirement? I haven't seen any other examples in the Quill documentation that work quite like this.