19faa0f4f2ea164f8bc7df1643073d612e558185fb023d62cfc7ac0ecca2a0a3f0a6f8c7cbcfd94323294e7951357705eaf2ba26888afa7ab9bc65fe4d65a5 689 B

123456789101112131415161718
  1. import { ClassAttributor, Scope, StyleAttributor } from 'parchment';
  2. class ColorAttributor extends StyleAttributor {
  3. value(domNode) {
  4. let value = super.value(domNode);
  5. if (!value.startsWith('rgb(')) return value;
  6. value = value.replace(/^[^\d]+/, '').replace(/[^\d]+$/, '');
  7. const hex = value.split(',').map(component => `00${parseInt(component, 10).toString(16)}`.slice(-2)).join('');
  8. return `#${hex}`;
  9. }
  10. }
  11. const ColorClass = new ClassAttributor('color', 'ql-color', {
  12. scope: Scope.INLINE
  13. });
  14. const ColorStyle = new ColorAttributor('color', 'color', {
  15. scope: Scope.INLINE
  16. });
  17. export { ColorAttributor, ColorClass, ColorStyle };
  18. //# sourceMappingURL=color.js.map