How to add data-id attributes to selection? #4461
Answered
by
jankapunkt
jankapunkt
asked this question in
Q&A
-
I have a module that dynamically highlights text by given data from outside. In the examples I found there was never shown how to add these values but only how to declare attributors: import Quill from 'quill';
const Module = Quill.import('core/module');
const Parchment = Quill.import('parchment');
const DataIdAttributor = new Parchment.Attributor('data-id', 'data-id', { scope: Parchment.Scope.BLOCK, });
Quill.register('attributors/attribute/id', DataIdAttributor, true);
Quill.register({ 'formats/data-id': DataIdAttributor, }, true);
export class SelectionHighlightBG extends Module {
constructor(quill, options) {
super(quill, options);
this.quill = quill;
this.options = options;
}
highlight ({ id, start, end, color }) {
const length = end - start
this.quill.formatText(start, length, {
background: color,
})
// attach data-id here but how <----------------------
}
} Anyone can point me into a direction or has an example? |
Beta Was this translation helpful? Give feedback.
Answered by
jankapunkt
Nov 2, 2024
Replies: 1 comment
-
My bad, I forgot to define |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jankapunkt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My bad, I forgot to define
data-id
informats
option when creating a new quill instance.