mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 05:33:02 -05:00
Fix Text Image Fills (#102)
* fix text image fills (pending on develop release in penpot app) * changeset
This commit is contained in:
parent
c71eb8e736
commit
54df5ead1e
3 changed files with 9 additions and 44 deletions
5
.changeset/big-seas-try.md
Normal file
5
.changeset/big-seas-try.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"penpot-exporter": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix text image fills
|
|
@ -66,7 +66,8 @@ const translateImage = async (imageHash: string | null): Promise<ImageColor | un
|
||||||
height: size.height,
|
height: size.height,
|
||||||
mtype: mimeType,
|
mtype: mimeType,
|
||||||
keepAspectRatio: true,
|
keepAspectRatio: true,
|
||||||
dataUri: dataUri
|
dataUri: dataUri,
|
||||||
|
id: '00000000-0000-0000-0000-000000000000'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,10 @@
|
||||||
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
||||||
import {
|
import { TextShape } from '@ui/lib/types/shapes/textShape';
|
||||||
Paragraph,
|
|
||||||
ParagraphSet,
|
|
||||||
TextContent,
|
|
||||||
TextNode,
|
|
||||||
TextShape
|
|
||||||
} from '@ui/lib/types/shapes/textShape';
|
|
||||||
import { translateUiBlendMode } from '@ui/translators';
|
import { translateUiBlendMode } from '@ui/translators';
|
||||||
|
|
||||||
export const createPenpotText = (
|
export const createPenpotText = (file: PenpotFile, { type, blendMode, ...rest }: TextShape) => {
|
||||||
file: PenpotFile,
|
|
||||||
{ type, blendMode, content, ...rest }: TextShape
|
|
||||||
) => {
|
|
||||||
file.createText({
|
file.createText({
|
||||||
blendMode: translateUiBlendMode(blendMode),
|
blendMode: translateUiBlendMode(blendMode),
|
||||||
content: fixContentFills(content), //@TODO: fix text image fills
|
|
||||||
...rest
|
...rest
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const fixContentFills = (content?: TextContent): TextContent | undefined => {
|
|
||||||
if (!content) return;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...content,
|
|
||||||
children: content.children?.map(children => fixParagraphSetFills(children))
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const fixParagraphSetFills = (paragraphSet: ParagraphSet): ParagraphSet => {
|
|
||||||
return {
|
|
||||||
...paragraphSet,
|
|
||||||
children: paragraphSet.children.map(paragraph => fixParagraphFills(paragraph))
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const fixParagraphFills = (paragraph: Paragraph): Paragraph => {
|
|
||||||
return {
|
|
||||||
...paragraph,
|
|
||||||
fills: paragraph.fills?.filter(fill => fill.fillImage === undefined),
|
|
||||||
children: paragraph.children.map(child => fixTextNodeFills(child))
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const fixTextNodeFills = (textNode: TextNode): TextNode => {
|
|
||||||
return {
|
|
||||||
...textNode,
|
|
||||||
fills: textNode.fills?.filter(fill => fill.fillImage === undefined)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in a new issue