Commit 5b011fe5 authored by 罗超's avatar 罗超

修复上传模板的多行文本问题

parent deba0371
......@@ -15,7 +15,8 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
let f = item.layer.typeTool().export()
const { left, top, width, height, value, font, transform } = f
const { colors, styles, alignment, sizes, names, weights } = font
const { colors, styles, alignment, sizes, names, weights,textDecoration } = font
if(value.indexOf('独家安排')!=-1) console.log(f,font)
let fontSize = 24.0
let newSizes = sizes?sizes:[12]
//if(value=='12980') console.log(newSizes,transform,extractScale(transform))
......@@ -40,12 +41,27 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
let color = `rgba(${colors[0][0]},${colors[0][1]},${colors[0][2]},${(parseFloat(colors[0][3]) / 255.0).toFixed(2)})`
let style = `text-align:${alignment[0]}; font-size:${fontSize-2}px; font-weight:${weights[0]};`
if (font.textDecoration || StyleSheetData.Strikethrough) {
style += `text-decoration:${font.textDecoration ? font.textDecoration[0] : ''} ${StyleSheetData.Strikethrough ? ' line-through' : ''};`
}
if (StyleSheetData.FauxItalic){
style += `font-style:italic;`
let styleArray:string[] = []
const lineCount = value.split('\r').length
for (let i = 0; i < lineCount; i++) {
const align = alignment.length>i?alignment[i]:alignment[alignment.length-1]
const sizestyle = newSizes.length>i?newSizes[i]:newSizes[newSizes.length-1]
const weight = weights.length>i?weights[i]:weights[weights.length-1]
const decoration = textDecoration?textDecoration[i]:textDecoration[textDecoration.length-1]
let fz = 24.0
if (transform) {
fz = Math.round(sizestyle * extractScale(transform))
} else {
fz = sizestyle
}
let style = `text-align:${align}; font-size:${fz-2}px; font-weight:${weight};`
if (decoration || StyleSheetData.Strikethrough) {
style += `text-decoration:${decoration} ${StyleSheetData.Strikethrough ? ' line-through' : ''};`
}
if (StyleSheetData.FauxItalic){
style += `font-style:italic;`
}
styleArray.push(style)
}
......@@ -65,15 +81,18 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
color = 'transparent',
textShadow = null
clip=true
style += `background:${background} !important;-webkit-background-clip: text !important;`
styleArray.forEach((s:string) => {
s += `background:${background} !important;-webkit-background-clip: text !important;`
});
}
if(objectEFFFects && objectEFFFects.data?.FrFX?.enab){
stroke = getStrokeHandler(objectEFFFects)
}
const valuesStr = value.split('\r')
let content = ''
valuesStr.forEach((x: any) => {
content += `<p><span style="${style}">${HtmlUtil.htmlEncodeByRegExp(x)}</span></p>`
valuesStr.forEach((x: any,si:number) => {
content += `<p><span style="${styleArray[si]}">${HtmlUtil.htmlEncodeByRegExp(x)}</span></p>`
})
const isVertical = item.layer.adjustments.typeTool.obj.textData.Ornt.value != 'Hrzn'
......@@ -108,6 +127,7 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
fontName[i]=x
}
}
if(value.indexOf('独家安排')!=-1) console.log(styleArray,lineCount)
let element: PPTTextElement = {
id: "text_" + index,
type: 'text',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment