我正在尝试基于此覆盖 Parchment - Quill 方法:
https://github.com/quilljs/quill/issues/409
class CustomColor extends Parchment.Attributor.Style {
value(node) {
let value = super.value(node);
if (!value.startsWith('rgb(')) return value;
value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
return '#' + value.split(',').map(function(component) {
return ('00' + parseInt(component, 10).toString(16)).slice(-2);
}).join('');
}
}
const customColorAttributor = new CustomColor('custom-color', 'color', {
scope: Parchment.Scope.BLOCK,
});
Quill.register(customColorAttributor);
我仍然得到:
Cannot read properties of undefined (reading 'Attributor')
如何正确导入羊皮纸?