Commit a9eebe3d authored by 罗超's avatar 罗超

修复文字transform,投影,渐变等特效

parent 8b3465ab
.text-static .ProseMirror{
position: static !important;
}
.ProseMirror, .ProseMirror-static { .ProseMirror, .ProseMirror-static {
outline: 0; outline: 0;
border: 0; border: 0;
......
...@@ -179,6 +179,7 @@ export interface PPTTextElement extends PPTBaseElement { ...@@ -179,6 +179,7 @@ export interface PPTTextElement extends PPTBaseElement {
contentStr?: string, contentStr?: string,
TemplateList?: unknown, TemplateList?: unknown,
TemplateDataSource?: DataSourceType TemplateDataSource?: DataSourceType
clip?:boolean
} }
......
...@@ -6,6 +6,8 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop ...@@ -6,6 +6,8 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
let domwidth = item.layer.width let domwidth = item.layer.width
let domTop = item.layer.top-offsetTop let domTop = item.layer.top-offsetTop
let domheight = item.layer.height let domheight = item.layer.height
let transformRotate = 0
let clip = false
const opacity = (parseFloat(item.layer.opacity) / 255.0) const opacity = (parseFloat(item.layer.opacity) / 255.0)
let f = item.layer.typeTool().export() let f = item.layer.typeTool().export()
...@@ -20,13 +22,19 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop ...@@ -20,13 +22,19 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
fontSize = sizes[0] fontSize = sizes[0]
} }
} }
if(transform){
let angle = Math.atan2(transform.xy,transform.xx)
transformRotate = Math.ceil(angle * (180 / Math.PI))
}
const StyleSheet = item.layer.adjustments.typeTool.obj.engineData.EngineDict.StyleRun.RunArray[0].StyleSheet || {} const StyleSheet = item.layer.adjustments.typeTool.obj.engineData.EngineDict.StyleRun.RunArray[0].StyleSheet || {}
const { StyleSheetData } = StyleSheet const { StyleSheetData } = StyleSheet
const tracking = fontSize * (StyleSheetData.Tracking / 1000) const tracking = fontSize * (StyleSheetData.Tracking / 1000)
const lineHeight = StyleSheetData.Leading const lineHeight = StyleSheetData.Leading
let leading = (Math.round((lineHeight * transform.yy) * 100) * 0.01) / fontSize let leading = (Math.round((lineHeight * transform.yy) * 100) * 0.01) / fontSize
let objectEFFFects = item.layer.objectEffects ? item.layer.objectEffects() : null let objectEFFFects = item.layer.objectEffects ? item.layer.objectEffects() : null
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 style = `text-align:${alignment[0]}; font-size:${fontSize-2}px; font-weight:${weights[0]};`
...@@ -37,13 +45,13 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop ...@@ -37,13 +45,13 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
style += `font-style:italic;` style += `font-style:italic;`
} }
let content = `<p style="${style}">${value}</p>`
let textShadow: any = null let textShadow: any = null
if (objectEFFFects && objectEFFFects.data?.DrSh.enab) { if (objectEFFFects && objectEFFFects.data?.DrSh?.enab) {
textShadow = getShadows(objectEFFFects) textShadow = getShadows(objectEFFFects)
} }
let background = '' let background = ''
if (objectEFFFects && objectEFFFects.data?.GrFl.enab) { if (objectEFFFects && objectEFFFects.data?.GrFl?.enab) {
background += `rgba(${colors[0][0]},${colors[0][1]},${colors[0][2]},${(parseFloat(colors[0][3]) / 255.0).toFixed(2)})` background += `rgba(${colors[0][0]},${colors[0][1]},${colors[0][2]},${(parseFloat(colors[0][3]) / 255.0).toFixed(2)})`
background += " "+getGradient(objectEFFFects) background += " "+getGradient(objectEFFFects)
background += " no-repeat" background += " no-repeat"
...@@ -53,7 +61,10 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop ...@@ -53,7 +61,10 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
// div.style.backgroundPositionY = objectEFFFects.data.GrFl.Ofst.Vrtc.value+"px" // div.style.backgroundPositionY = objectEFFFects.data.GrFl.Ofst.Vrtc.value+"px"
color = 'transparent', color = 'transparent',
textShadow = null textShadow = null
clip=true
style += `background:${background} !important;-webkit-background-clip: text !important;`
} }
let content = `<p><span style="${style}">${value}</span></p>`
const isVertical = item.layer.adjustments.typeTool.obj.textData.Ornt.value != 'Hrzn' const isVertical = item.layer.adjustments.typeTool.obj.textData.Ornt.value != 'Hrzn'
if(isVertical) { if(isVertical) {
...@@ -81,18 +92,19 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop ...@@ -81,18 +92,19 @@ export const ResolveText = (item: any, index: number,offsetLeft:number,offsetTop
width:domwidth, width:domwidth,
top:domTop, top:domTop,
height:domheight, height:domheight,
rotate: 0, rotate: transformRotate,
opacity, opacity,
content, content,
defaultFontName: names.join(','), defaultFontName: names.join(','),
defaultColor: color, defaultColor: color,
fill: background, fill: background,
lineHeight: leading, lineHeight: leading<1?1:leading,
wordSpace: tracking, wordSpace: tracking,
vertical: isVertical, vertical: isVertical,
contentStr: content, contentStr: value,
layerName:item.layer.name, layerName:item.layer.name,
groupId :groupId groupId :groupId,
clip
} }
if (textShadow) element.shadow = textShadow if (textShadow) element.shadow = textShadow
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
:style="{ :style="{
width: elementInfo.vertical ? 'auto' : elementInfo.width + 'px', width: elementInfo.vertical ? 'auto' : elementInfo.width + 'px',
height: elementInfo.vertical ? elementInfo.height + 'px' : 'auto', height: elementInfo.vertical ? elementInfo.height + 'px' : 'auto',
backgroundColor: elementInfo.fill, background: elementInfo.fill,
opacity: elementInfo.opacity, opacity: elementInfo.opacity,
textShadow: shadowStyle, textShadow: shadowStyle,
lineHeight: elementInfo.lineHeight, lineHeight: elementInfo.lineHeight,
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
fontFamily: elementInfo.defaultFontName, fontFamily: elementInfo.defaultFontName,
writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb', writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb',
}" }"
:class="{'clip-box':elementInfo.clip}"
v-contextmenu="contextmenus" v-contextmenu="contextmenus"
@mousedown="$event => handleSelectElement($event)" @mousedown="$event => handleSelectElement($event)"
@touchstart="$event => handleSelectElement($event)" @touchstart="$event => handleSelectElement($event)"
...@@ -38,7 +40,7 @@ ...@@ -38,7 +40,7 @@
:outline="elementInfo.outline" :outline="elementInfo.outline"
/> />
<ProsemirrorEditor <ProsemirrorEditor
class="text" :class="{'text-static':elementInfo.clip,'text':!elementInfo.clip}"
:elementId="elementInfo.id" :elementId="elementInfo.id"
:defaultColor="elementInfo.defaultColor" :defaultColor="elementInfo.defaultColor"
:defaultFontName="elementInfo.defaultFontName" :defaultFontName="elementInfo.defaultFontName"
...@@ -200,6 +202,9 @@ watch(isHandleElement, () => { ...@@ -200,6 +202,9 @@ watch(isHandleElement, () => {
.text { .text {
position: relative; position: relative;
} }
.text-static {
position: static;
}
::v-deep(a) { ::v-deep(a) {
cursor: text; cursor: text;
...@@ -217,4 +222,7 @@ watch(isHandleElement, () => { ...@@ -217,4 +222,7 @@ watch(isHandleElement, () => {
bottom: 0; bottom: 0;
} }
} }
.clip-box{
-webkit-background-clip: text !important;
}
</style> </style>
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