UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

15 lines (14 loc) 534 B
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; // eslint-disable-line import/no-namespace export function rgbToHex(value) { var matches = value.match(/(0?\.?[0-9]{1,3})%?\b/g); if (matches && matches.length >= 3) { var _matches$map = matches.map(Number), _matches$map2 = _slicedToArray(_matches$map, 3), red = _matches$map2[0], green = _matches$map2[1], blue = _matches$map2[2]; return '#' + (blue | green << 8 | red << 16 | 1 << 24).toString(16).slice(1); } return null; }