Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
pptist
Commits
5b011fe5
Commit
5b011fe5
authored
Jun 04, 2024
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复上传模板的多行文本问题
parent
deba0371
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
10 deletions
+30
-10
text.ts
src/utils/psdParser/text.ts
+30
-10
No files found.
src/utils/psdParser/text.ts
View file @
5b011fe5
...
...
@@ -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,13 +41,28 @@ 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'
:
''
}
;`
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
)
}
let
textShadow
:
any
=
null
...
...
@@ -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="
${
style
Array
[
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'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment