How do I change indent class name into style in react quill editor?

65 Views Asked by At

I have tried many codes for changing indent class into a style but even single doesn’t work.

Currently I am using this:

const Parchment = Quill.import('parchment')
const levels = [1, 2, 3, 4, 5]
const multiplier = 2

class IndentAttributor extends Parchment.Attributor.Style {
    add(node, value) {
        return super.add(node, `${value * multiplier}em`)
    }

    value(node) {
        return parseFloat(super.value(node)) / multiplier || undefined // Don't return NaN
    }
}

const IndentStyle = new IndentAttributor('indent', 'margin-left', {
    scope: Parchment.Scope.BLOCK,
    whitelist: levels.map((value) => `${value * multiplier}em`),
})

Quill.register(IndentStyle, true)

I have added this in my quillEditor.toolbar folder

0

There are 0 best solutions below