@hedgedoc/html-to-react
Version:
Parse HTML into React components
25 lines • 928 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertInlineStyleToMap = void 0;
function convertInlineStyleToMap(inlineStyle = '') {
if (inlineStyle === '') {
return {};
}
return inlineStyle.split(';').reduce((styleObject, stylePropertyValue) => {
const [property, value] = stylePropertyValue
.split(/^([^:]+):/)
.filter((val, i) => i > 0)
.map((item) => item.trim());
if (value === undefined) {
return styleObject;
}
const replacedProperty = property
.toLowerCase()
.replace(/^-ms-/, 'ms-')
.replace(/-(.)/g, (_, character) => character.toUpperCase());
styleObject[replacedProperty] = value;
return styleObject;
}, {});
}
exports.convertInlineStyleToMap = convertInlineStyleToMap;
//# sourceMappingURL=convertInlineStyleToMap.js.map