tldraw/state/code/text.ts

42 lines
986 B
TypeScript
Raw Normal View History

import CodeShape from './index'
import { uniqueId } from 'utils'
2021-06-25 12:21:33 +00:00
import { TextShape, ShapeProps, ShapeType } from 'types'
import { defaultStyle } from 'state/shape-styles'
2021-06-25 12:21:33 +00:00
import { getShapeUtils } from 'state/shape-utils'
/* ----------------- Start Copy Here ---------------- */
export default class Text extends CodeShape<TextShape> {
constructor(props = {} as ShapeProps<TextShape>) {
super({
id: uniqueId(),
parentId: (window as any).currentPageId,
type: ShapeType.Text,
isGenerated: true,
name: 'Text',
childIndex: 0,
point: [0, 0],
rotation: 0,
isAspectRatioLocked: false,
isLocked: false,
isHidden: false,
text: 'Text',
scale: 1,
...props,
style: {
...defaultStyle,
...props.style,
},
})
}
2021-06-25 12:21:33 +00:00
get scale(): number {
return this.shape.scale
}
set scale(scale: number) {
getShapeUtils(this.shape).setProperty(this.shape, 'scale', scale)
}
}