Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const makeTextLayer = (
frame: FileFormat.Rect,
name: string,
textNodes: TextNode[],
_style: ViewStyle,
resizingConstraint?: ResizeConstraints,
shadows?: ViewStyle[],
): FileFormat.Text => ({
_class: 'text',
do_objectID: generateID(`text:${name}-${textNodes.map(node => node.content).join('')}`),
frame,
isFlippedHorizontal: false,
isFlippedVertical: false,
isLocked: false,
isVisible: true,
layerListExpandedType: FileFormat.LayerListExpanded.Undecided,
name,
nameIsFixed: false,
resizingConstraint: makeResizeConstraint(resizingConstraint),
resizingType: FileFormat.ResizeType.Stretch,
rotation: 0,
shouldBreakMaskChain: false,
attributedString: makeAttributedString(textNodes),
style: makeTextStyle((textNodes[0] || { textStyles: {} }).textStyles, shadows),
automaticallyDrawOnUnderlyingPath: false,
dontSynchroniseWithSymbol: false,
// NOTE(akp): I haven't fully figured out the meaning of glyphBounds
glyphBounds: '',
// glyphBounds: '{{0, 0}, {116, 17}}',
lineSpacingBehaviour: FileFormat.LineSpacingBehaviour.ConsistentBaseline,
textBehaviour: FileFormat.TextBehaviour.Fixed,
booleanOperation: FileFormat.BooleanOperation.NA,
height: number,
radii: Radii = [0, 0, 0, 0],
resizingConstraint?: ResizeConstraints,
): FileFormat.Rectangle => {
const fixedRadius = radii[0] || 0;
const path = makeRectPath(radii);
return {
...path,
_class: 'rectangle',
do_objectID: generateID(),
frame: makeRect(x, y, width, height),
isFlippedHorizontal: false,
isFlippedVertical: false,
isLocked: false,
isVisible: true,
layerListExpandedType: FileFormat.LayerListExpanded.Undecided,
name: 'Path',
nameIsFixed: false,
resizingConstraint: makeResizeConstraint(resizingConstraint),
resizingType: FileFormat.ResizeType.Stretch,
rotation: 0,
shouldBreakMaskChain: false,
booleanOperation: FileFormat.BooleanOperation.NA,
edited: false,
fixedRadius,
hasConvertedToNewRoundCorners: true,
isFixedToViewport: false,
pointRadiusBehaviour: FileFormat.PointsRadiusBehaviour.Rounded,
exportOptions: {
_class: 'exportOptions',
exportFormats: [],
includedLayerIds: [],
_class: 'symbolMaster',
do_objectID: generateID(`symbolMaster:${name}`, !!name),
nameIsFixed: true,
isVisible: true,
backgroundColor: makeColorFromCSS('white'),
hasBackgroundColor: false,
name,
changeIdentifier: generateIdNumber(),
symbolID,
frame,
booleanOperation: FileFormat.BooleanOperation.NA,
isLocked: false,
isFixedToViewport: false,
isFlippedHorizontal: false,
isFlippedVertical: false,
layerListExpandedType: FileFormat.LayerListExpanded.Undecided,
resizingType: FileFormat.ResizeType.Stretch,
rotation: 0,
shouldBreakMaskChain: false,
exportOptions: {
_class: 'exportOptions',
exportFormats: [],
includedLayerIds: [],
layerOptions: 0,
shouldTrim: false,
},
resizingConstraint: makeResizeConstraint(),
hasClickThrough: false,
layers: [],
horizontalRulerData: {
_class: 'rulerData',
base: 0,
layers,
clippingMaskMode: 0,
hasClippingMask: false,
windingRule: FileFormat.WindingRule.EvenOdd,
isFixedToViewport: false,
exportOptions: {
_class: 'exportOptions',
exportFormats: [],
includedLayerIds: [],
layerOptions: 0,
shouldTrim: false,
},
isFlippedHorizontal: false,
isFlippedVertical: false,
booleanOperation: FileFormat.BooleanOperation.NA,
layerListExpandedType: FileFormat.LayerListExpanded.Undecided,
});
...props.viewport,
},
}),
isFlippedHorizontal: false,
isFlippedVertical: false,
isFixedToViewport: false,
isLocked: false,
booleanOperation: FileFormat.BooleanOperation.NA,
exportOptions: {
_class: 'exportOptions',
exportFormats: [],
includedLayerIds: [],
layerOptions: 0,
shouldTrim: false,
},
layerListExpandedType: FileFormat.LayerListExpanded.Undecided,
resizingType: FileFormat.ResizeType.Stretch,
shouldBreakMaskChain: false,
hasClickThrough: false,
layers: [],
includeInCloudUpload: true,
includeBackgroundColorInExport: color !== undefined,
horizontalRulerData: {
_class: 'rulerData',
base: 0,
guides: [],
},
verticalRulerData: {
_class: 'rulerData',
base: 0,
guides: [],
},