@gdyfe/quill-editor
Version:
基于Quill的vue编辑器组件 npm@0.1.6
22 lines (17 loc) • 570 B
JavaScript
import Quill from 'quill'
const Parchment = Quill.import('parchment')
const levels = [1, 2, 3, 4, 5, 6, 7, 8, 9]
const multiplier = 1
class IndentAttributor extends Parchment.StyleAttributor {
add(node, value) {
return super.add(node, `${value * multiplier}em`)
}
value(node) {
return parseFloat(super.value(node)) / multiplier || 0 // Don't return NaN
}
}
const IndentStyle = new IndentAttributor('indent', 'text-indent', {
scope: Parchment.Scope.BLOCK,
whitelist: levels.map((value) => `${value * multiplier}em`),
})
export default IndentStyle