File size: 965 Bytes
89ce340 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import type { CSSProperties } from 'vue'
import type { TableCellStyle } from '@/types/slides'
/**
* 计算单元格文本样式
* @param style 单元格文本样式原数据
*/
export const getTextStyle = (style?: TableCellStyle): CSSProperties => {
if (!style) return {}
const {
bold,
em,
underline,
strikethrough,
color,
backcolor,
fontsize,
fontname,
align,
} = style
let textDecoration = `${underline ? 'underline' : ''} ${strikethrough ? 'line-through' : ''}`
if (textDecoration === ' ') textDecoration = 'none'
return {
fontWeight: bold ? 'bold' : 'normal',
fontStyle: em ? 'italic' : 'normal',
textDecoration,
color: color || '#000',
backgroundColor: backcolor || '',
fontSize: fontsize || '14px',
fontFamily: fontname || '',
textAlign: align || 'left',
}
}
export const formatText = (text: string) => {
return text.replace(/\n/g, '</br>').replace(/ /g, ' ')
} |