您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

text.ts 986B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import CodeShape from './index'
  2. import { uniqueId } from 'utils'
  3. import { TextShape, ShapeProps, ShapeType } from 'types'
  4. import { defaultStyle } from 'state/shape-styles'
  5. import { getShapeUtils } from 'state/shape-utils'
  6. /* ----------------- Start Copy Here ---------------- */
  7. export default class Text extends CodeShape<TextShape> {
  8. constructor(props = {} as ShapeProps<TextShape>) {
  9. super({
  10. id: uniqueId(),
  11. parentId: (window as any).currentPageId,
  12. type: ShapeType.Text,
  13. isGenerated: true,
  14. name: 'Text',
  15. childIndex: 0,
  16. point: [0, 0],
  17. rotation: 0,
  18. isAspectRatioLocked: false,
  19. isLocked: false,
  20. isHidden: false,
  21. text: 'Text',
  22. scale: 1,
  23. ...props,
  24. style: {
  25. ...defaultStyle,
  26. ...props.style,
  27. },
  28. })
  29. }
  30. get scale(): number {
  31. return this.shape.scale
  32. }
  33. set scale(scale: number) {
  34. getShapeUtils(this.shape).setProperty(this.shape, 'scale', scale)
  35. }
  36. }