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

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

parent deba0371
...@@ -15,7 +15,8 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop ...@@ -15,7 +15,8 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
let f = item.layer.typeTool().export() let f = item.layer.typeTool().export()
const { left, top, width, height, value, font, transform } = f 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 fontSize = 24.0
let newSizes = sizes?sizes:[12] let newSizes = sizes?sizes:[12]
//if(value=='12980') console.log(newSizes,transform,extractScale(transform)) //if(value=='12980') console.log(newSizes,transform,extractScale(transform))
...@@ -40,12 +41,27 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop ...@@ -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 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]};` let styleArray:string[] = []
if (font.textDecoration || StyleSheetData.Strikethrough) { const lineCount = value.split('\r').length
style += `text-decoration:${font.textDecoration ? font.textDecoration[0] : ''} ${StyleSheetData.Strikethrough ? ' line-through' : ''};` for (let i = 0; i < lineCount; i++) {
} const align = alignment.length>i?alignment[i]:alignment[alignment.length-1]
if (StyleSheetData.FauxItalic){ const sizestyle = newSizes.length>i?newSizes[i]:newSizes[newSizes.length-1]
style += `font-style:italic;` 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 ...@@ -65,15 +81,18 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
color = 'transparent', color = 'transparent',
textShadow = null textShadow = null
clip=true 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){ if(objectEFFFects && objectEFFFects.data?.FrFX?.enab){
stroke = getStrokeHandler(objectEFFFects) stroke = getStrokeHandler(objectEFFFects)
} }
const valuesStr = value.split('\r') const valuesStr = value.split('\r')
let content = '' let content = ''
valuesStr.forEach((x: any) => { valuesStr.forEach((x: any,si:number) => {
content += `<p><span style="${style}">${HtmlUtil.htmlEncodeByRegExp(x)}</span></p>` content += `<p><span style="${styleArray[si]}">${HtmlUtil.htmlEncodeByRegExp(x)}</span></p>`
}) })
const isVertical = item.layer.adjustments.typeTool.obj.textData.Ornt.value != 'Hrzn' 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 ...@@ -108,6 +127,7 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
fontName[i]=x fontName[i]=x
} }
} }
if(value.indexOf('独家安排')!=-1) console.log(styleArray,lineCount)
let element: PPTTextElement = { let element: PPTTextElement = {
id: "text_" + index, id: "text_" + index,
type: 'text', 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