Here's a delta with an attribute:
Trying to get the delta with
editor.getContents(range.index, range.length);
returns
Delta: {
ops: []
}
which is expected - range.length is 0.
Is there a way of returning the entire delta (from left to right) so it looks like this:
Delta: {
ops: [
{
attributes: { test: '123' },
insert: 'A selection'
},
...
]
}
Assuming a slightly more complex example to disambiguate and assuming the test 123 attribute is implemented with a class Attributor, given the document:
I think what you are asking however is getting the Delta for the "cdef" text when the user's cursor is between the "e" and "f" and so your range is
index: 5
.This is an experimental/undocumented API but
quill.scroll.path(5)
will get you an array[[blockBlot, 0], [inlineBlot, 2], [italicBlot, 1]]
and the blot you want in this case is the second one so by summing the offsets to it you will have 2 (0 + 2) and then you can call quill.getContents(2, blot.length()).If the class is unique (or you can access the DOM node some other way) you can also do: