jodit
Version:
Jodit is awesome and usefully wysiwyg editor with filebrowser
40 lines (32 loc) • 836 B
text/typescript
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2020 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { isNumeric } from '../checker/';
import { kebabCase } from '../string';
import { colorToHex } from '../color';
export function normalizeCssValue(
key: string,
value: string | number
): string | number {
switch (kebabCase(key)) {
case 'font-weight':
switch (value.toString().toLowerCase()) {
case '700':
case 'bold':
return 700;
case '400':
case 'normal':
return 400;
case '900':
case 'heavy':
return 900;
}
return isNumeric(value) ? +value : value;
}
if (/color/i.test(key)) {
return colorToHex(value.toString()) || value;
}
return value;
}