Trims default false boolean props
This should reduce the size of files / saves, for example.
This commit is contained in:
parent
17940d82d6
commit
48c659a68a
26 changed files with 24 additions and 155 deletions
|
@ -17,10 +17,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"childIndex": 1,
|
"childIndex": 1,
|
||||||
"id": "test-draw",
|
"id": "test-draw",
|
||||||
"isAspectRatioLocked": false,
|
|
||||||
"isGenerated": true,
|
"isGenerated": true,
|
||||||
"isHidden": false,
|
|
||||||
"isLocked": false,
|
|
||||||
"name": "Test draw",
|
"name": "Test draw",
|
||||||
"parentId": "page1",
|
"parentId": "page1",
|
||||||
"point": Array [
|
"point": Array [
|
||||||
|
@ -58,10 +55,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"childIndex": 1,
|
"childIndex": 1,
|
||||||
"id": "test-rectangle",
|
"id": "test-rectangle",
|
||||||
"isAspectRatioLocked": false,
|
|
||||||
"isGenerated": true,
|
"isGenerated": true,
|
||||||
"isHidden": false,
|
|
||||||
"isLocked": false,
|
|
||||||
"name": "Test Rectangle",
|
"name": "Test Rectangle",
|
||||||
"parentId": "page1",
|
"parentId": "page1",
|
||||||
"point": Array [
|
"point": Array [
|
||||||
|
@ -90,10 +84,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"childIndex": 1,
|
"childIndex": 1,
|
||||||
"id": "test-text",
|
"id": "test-text",
|
||||||
"isAspectRatioLocked": false,
|
|
||||||
"isGenerated": true,
|
"isGenerated": true,
|
||||||
"isHidden": false,
|
|
||||||
"isLocked": false,
|
|
||||||
"name": "Test text",
|
"name": "Test text",
|
||||||
"parentId": "page1",
|
"parentId": "page1",
|
||||||
"point": Array [
|
"point": Array [
|
||||||
|
@ -151,10 +142,7 @@ Array [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"id": "test-draw",
|
"id": "test-draw",
|
||||||
"isAspectRatioLocked": false,
|
|
||||||
"isGenerated": true,
|
"isGenerated": true,
|
||||||
"isHidden": false,
|
|
||||||
"isLocked": false,
|
|
||||||
"name": "Test draw",
|
"name": "Test draw",
|
||||||
"parentId": "page1",
|
"parentId": "page1",
|
||||||
"point": Array [
|
"point": Array [
|
||||||
|
@ -192,10 +180,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"childIndex": 1,
|
"childIndex": 1,
|
||||||
"id": "test-ellipse",
|
"id": "test-ellipse",
|
||||||
"isAspectRatioLocked": false,
|
|
||||||
"isGenerated": true,
|
"isGenerated": true,
|
||||||
"isHidden": false,
|
|
||||||
"isLocked": false,
|
|
||||||
"name": "Test ellipse",
|
"name": "Test ellipse",
|
||||||
"parentId": "page1",
|
"parentId": "page1",
|
||||||
"point": Array [
|
"point": Array [
|
||||||
|
@ -221,10 +206,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"childIndex": 1,
|
"childIndex": 1,
|
||||||
"id": "test-rectangle",
|
"id": "test-rectangle",
|
||||||
"isAspectRatioLocked": false,
|
|
||||||
"isGenerated": true,
|
"isGenerated": true,
|
||||||
"isHidden": false,
|
|
||||||
"isLocked": false,
|
|
||||||
"name": "Test Rectangle",
|
"name": "Test Rectangle",
|
||||||
"parentId": "page1",
|
"parentId": "page1",
|
||||||
"point": Array [
|
"point": Array [
|
||||||
|
@ -274,10 +256,7 @@ exports[`selection updates a code control: rectangle in state after changing cod
|
||||||
Object {
|
Object {
|
||||||
"childIndex": 1,
|
"childIndex": 1,
|
||||||
"id": "test-rectangle",
|
"id": "test-rectangle",
|
||||||
"isAspectRatioLocked": false,
|
|
||||||
"isGenerated": true,
|
"isGenerated": true,
|
||||||
"isHidden": false,
|
|
||||||
"isLocked": false,
|
|
||||||
"name": "Test Rectangle",
|
"name": "Test Rectangle",
|
||||||
"parentId": "page1",
|
"parentId": "page1",
|
||||||
"point": Array [
|
"point": Array [
|
||||||
|
|
|
@ -74,7 +74,6 @@ interface BaseShape {
|
||||||
type: ShapeType
|
type: ShapeType
|
||||||
parentId: string
|
parentId: string
|
||||||
childIndex: number
|
childIndex: number
|
||||||
isGenerated: boolean
|
|
||||||
name: string
|
name: string
|
||||||
point: number[]
|
point: number[]
|
||||||
style: ShapeStyles
|
style: ShapeStyles
|
||||||
|
@ -82,9 +81,11 @@ interface BaseShape {
|
||||||
children?: string[]
|
children?: string[]
|
||||||
bindings?: Record<string, ShapeBinding>
|
bindings?: Record<string, ShapeBinding>
|
||||||
handles?: Record<string, ShapeHandle>
|
handles?: Record<string, ShapeHandle>
|
||||||
isLocked: boolean
|
isLocked?: boolean
|
||||||
isHidden: boolean
|
isHidden?: boolean
|
||||||
isAspectRatioLocked: boolean
|
isEditing?: boolean
|
||||||
|
isGenerated?: boolean
|
||||||
|
isAspectRatioLocked?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DotShape extends BaseShape {
|
interface DotShape extends BaseShape {
|
||||||
|
@ -641,7 +642,6 @@ interface BaseShape {
|
||||||
type: ShapeType
|
type: ShapeType
|
||||||
parentId: string
|
parentId: string
|
||||||
childIndex: number
|
childIndex: number
|
||||||
isGenerated: boolean
|
|
||||||
name: string
|
name: string
|
||||||
point: number[]
|
point: number[]
|
||||||
style: ShapeStyles
|
style: ShapeStyles
|
||||||
|
@ -649,9 +649,11 @@ interface BaseShape {
|
||||||
children?: string[]
|
children?: string[]
|
||||||
bindings?: Record<string, ShapeBinding>
|
bindings?: Record<string, ShapeBinding>
|
||||||
handles?: Record<string, ShapeHandle>
|
handles?: Record<string, ShapeHandle>
|
||||||
isLocked: boolean
|
isLocked?: boolean
|
||||||
isHidden: boolean
|
isHidden?: boolean
|
||||||
isAspectRatioLocked: boolean
|
isEditing?: boolean
|
||||||
|
isGenerated?: boolean
|
||||||
|
isAspectRatioLocked?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DotShape extends BaseShape {
|
interface DotShape extends BaseShape {
|
||||||
|
@ -1497,7 +1499,7 @@ type RequiredKeys<T> = {
|
||||||
}
|
}
|
||||||
|
|
||||||
static round = (a: number[], d = 5): number[] => {
|
static round = (a: number[], d = 5): number[] => {
|
||||||
return a.map((v) => Number(v.toPrecision(d)))
|
return a.map((v) => +v.toPrecision(d))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2816,7 +2818,6 @@ type RequiredKeys<T> = {
|
||||||
constructor(props = {} as ShapeProps<DotShape>) {
|
constructor(props = {} as ShapeProps<DotShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Dot,
|
type: ShapeType.Dot,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -2824,9 +2825,6 @@ type RequiredKeys<T> = {
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
@ -2853,9 +2851,6 @@ type RequiredKeys<T> = {
|
||||||
radiusX: 50,
|
radiusX: 50,
|
||||||
radiusY: 50,
|
radiusY: 50,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: { ...defaultStyle, ...props.style },
|
style: { ...defaultStyle, ...props.style },
|
||||||
})
|
})
|
||||||
|
@ -2903,7 +2898,6 @@ type RequiredKeys<T> = {
|
||||||
constructor(props = {} as ShapeProps<LineShape>) {
|
constructor(props = {} as ShapeProps<LineShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Line,
|
type: ShapeType.Line,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -2912,9 +2906,6 @@ type RequiredKeys<T> = {
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
direction: [-0.5, 0.5],
|
direction: [-0.5, 0.5],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
@ -2948,7 +2939,6 @@ type RequiredKeys<T> = {
|
||||||
constructor(props = {} as ShapeProps<PolylineShape>) {
|
constructor(props = {} as ShapeProps<PolylineShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Polyline,
|
type: ShapeType.Polyline,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -2957,9 +2947,6 @@ type RequiredKeys<T> = {
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
points: [[0, 0]],
|
points: [[0, 0]],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
@ -3005,7 +2992,6 @@ type RequiredKeys<T> = {
|
||||||
constructor(props = {} as ShapeProps<RayShape>) {
|
constructor(props = {} as ShapeProps<RayShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
type: ShapeType.Ray,
|
type: ShapeType.Ray,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
name: 'Ray',
|
name: 'Ray',
|
||||||
|
@ -3014,9 +3000,6 @@ type RequiredKeys<T> = {
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
direction: [0, 1],
|
direction: [0, 1],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
@ -3050,7 +3033,7 @@ type RequiredKeys<T> = {
|
||||||
constructor(
|
constructor(
|
||||||
props = {} as ShapeProps<ArrowShape> & { start: number[]; end: number[] }
|
props = {} as ShapeProps<ArrowShape> & { start: number[]; end: number[] }
|
||||||
) {
|
) {
|
||||||
const { start = [0, 0], end = [0, 0] } = props
|
const { start = [0, 0], end = [100, 100] } = props
|
||||||
|
|
||||||
const {
|
const {
|
||||||
point = [0, 0],
|
point = [0, 0],
|
||||||
|
@ -3075,17 +3058,12 @@ type RequiredKeys<T> = {
|
||||||
|
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
type: ShapeType.Arrow,
|
type: ShapeType.Arrow,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Arrow',
|
name: 'Arrow',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point,
|
point,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
bend: 0,
|
bend: 0,
|
||||||
handles,
|
handles,
|
||||||
decorations: {
|
decorations: {
|
||||||
|
@ -3171,18 +3149,13 @@ type RequiredKeys<T> = {
|
||||||
constructor(props = {} as ShapeProps<DrawShape>) {
|
constructor(props = {} as ShapeProps<DrawShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
type: ShapeType.Draw,
|
type: ShapeType.Draw,
|
||||||
isGenerated: false,
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
name: 'Draw',
|
name: 'Draw',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
points: [],
|
points: [],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
@ -3228,7 +3201,6 @@ type RequiredKeys<T> = {
|
||||||
constructor(props = {} as ShapeProps<TextShape>) {
|
constructor(props = {} as ShapeProps<TextShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Text,
|
type: ShapeType.Text,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -3236,9 +3208,6 @@ type RequiredKeys<T> = {
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
text: 'Text',
|
text: 'Text',
|
||||||
scale: 1,
|
scale: 1,
|
||||||
...props,
|
...props,
|
||||||
|
@ -3291,7 +3260,6 @@ type RequiredKeys<T> = {
|
||||||
constructor(props = {} as ShapeProps<RectangleShape>) {
|
constructor(props = {} as ShapeProps<RectangleShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Rectangle,
|
type: ShapeType.Rectangle,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -3301,9 +3269,6 @@ type RequiredKeys<T> = {
|
||||||
size: [100, 100],
|
size: [100, 100],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
radius: 2,
|
radius: 2,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default class Arrow extends CodeShape<ArrowShape> {
|
||||||
constructor(
|
constructor(
|
||||||
props = {} as ShapeProps<ArrowShape> & { start: number[]; end: number[] }
|
props = {} as ShapeProps<ArrowShape> & { start: number[]; end: number[] }
|
||||||
) {
|
) {
|
||||||
const { start = [0, 0], end = [0, 0] } = props
|
const { start = [0, 0], end = [100, 100] } = props
|
||||||
|
|
||||||
const {
|
const {
|
||||||
point = [0, 0],
|
point = [0, 0],
|
||||||
|
@ -36,17 +36,12 @@ export default class Arrow extends CodeShape<ArrowShape> {
|
||||||
|
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
type: ShapeType.Arrow,
|
type: ShapeType.Arrow,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Arrow',
|
name: 'Arrow',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point,
|
point,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
bend: 0,
|
bend: 0,
|
||||||
handles,
|
handles,
|
||||||
decorations: {
|
decorations: {
|
||||||
|
|
|
@ -9,7 +9,6 @@ export default class Dot extends CodeShape<DotShape> {
|
||||||
constructor(props = {} as ShapeProps<DotShape>) {
|
constructor(props = {} as ShapeProps<DotShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Dot,
|
type: ShapeType.Dot,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -17,9 +16,6 @@ export default class Dot extends CodeShape<DotShape> {
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
|
|
@ -9,18 +9,13 @@ export default class Draw extends CodeShape<DrawShape> {
|
||||||
constructor(props = {} as ShapeProps<DrawShape>) {
|
constructor(props = {} as ShapeProps<DrawShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
type: ShapeType.Draw,
|
type: ShapeType.Draw,
|
||||||
isGenerated: false,
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
name: 'Draw',
|
name: 'Draw',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
points: [],
|
points: [],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
|
|
@ -18,9 +18,6 @@ export default class Ellipse extends CodeShape<EllipseShape> {
|
||||||
radiusX: 50,
|
radiusX: 50,
|
||||||
radiusY: 50,
|
radiusY: 50,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: { ...defaultStyle, ...props.style },
|
style: { ...defaultStyle, ...props.style },
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,7 +9,6 @@ export default class Line extends CodeShape<LineShape> {
|
||||||
constructor(props = {} as ShapeProps<LineShape>) {
|
constructor(props = {} as ShapeProps<LineShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Line,
|
type: ShapeType.Line,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -18,9 +17,6 @@ export default class Line extends CodeShape<LineShape> {
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
direction: [-0.5, 0.5],
|
direction: [-0.5, 0.5],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
|
|
@ -9,7 +9,6 @@ export default class Polyline extends CodeShape<PolylineShape> {
|
||||||
constructor(props = {} as ShapeProps<PolylineShape>) {
|
constructor(props = {} as ShapeProps<PolylineShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Polyline,
|
type: ShapeType.Polyline,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -18,9 +17,6 @@ export default class Polyline extends CodeShape<PolylineShape> {
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
points: [[0, 0]],
|
points: [[0, 0]],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
|
|
@ -9,7 +9,6 @@ export default class Ray extends CodeShape<RayShape> {
|
||||||
constructor(props = {} as ShapeProps<RayShape>) {
|
constructor(props = {} as ShapeProps<RayShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
type: ShapeType.Ray,
|
type: ShapeType.Ray,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
name: 'Ray',
|
name: 'Ray',
|
||||||
|
@ -18,9 +17,6 @@ export default class Ray extends CodeShape<RayShape> {
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
direction: [0, 1],
|
direction: [0, 1],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
|
|
@ -10,7 +10,6 @@ export default class Rectangle extends CodeShape<RectangleShape> {
|
||||||
constructor(props = {} as ShapeProps<RectangleShape>) {
|
constructor(props = {} as ShapeProps<RectangleShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Rectangle,
|
type: ShapeType.Rectangle,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -20,9 +19,6 @@ export default class Rectangle extends CodeShape<RectangleShape> {
|
||||||
size: [100, 100],
|
size: [100, 100],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
radius: 2,
|
radius: 2,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
...props,
|
...props,
|
||||||
style: {
|
style: {
|
||||||
...defaultStyle,
|
...defaultStyle,
|
||||||
|
|
|
@ -10,7 +10,6 @@ export default class Text extends CodeShape<TextShape> {
|
||||||
constructor(props = {} as ShapeProps<TextShape>) {
|
constructor(props = {} as ShapeProps<TextShape>) {
|
||||||
super({
|
super({
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
parentId: (window as any).currentPageId,
|
parentId: (window as any).currentPageId,
|
||||||
type: ShapeType.Text,
|
type: ShapeType.Text,
|
||||||
isGenerated: true,
|
isGenerated: true,
|
||||||
|
@ -18,9 +17,6 @@ export default class Text extends CodeShape<TextShape> {
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
text: 'Text',
|
text: 'Text',
|
||||||
scale: 1,
|
scale: 1,
|
||||||
...props,
|
...props,
|
||||||
|
|
|
@ -16,7 +16,6 @@ export default function duplicateCommand(data: Data): void {
|
||||||
shape.point,
|
shape.point,
|
||||||
vec.div([16, 16], tld.getCurrentCamera(data).zoom)
|
vec.div([16, 16], tld.getCurrentCamera(data).zoom)
|
||||||
),
|
),
|
||||||
isGenerated: false,
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
history.execute(
|
history.execute(
|
||||||
|
|
|
@ -52,7 +52,6 @@ export default function pasteCommand(data: Data, initialShapes: Shape[]): void {
|
||||||
parentId: oldSelectedIds[shape.parentId] || data.currentPageId,
|
parentId: oldSelectedIds[shape.parentId] || data.currentPageId,
|
||||||
childIndex: childIndex++,
|
childIndex: childIndex++,
|
||||||
point: vec.add(topLeft, topLeftOffset),
|
point: vec.add(topLeft, topLeftOffset),
|
||||||
isGenerated: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,9 @@ export default class TransformSingleSession extends BaseSession {
|
||||||
transformType,
|
transformType,
|
||||||
vec.vec(this.origin, point),
|
vec.vec(this.origin, point),
|
||||||
shape.rotation,
|
shape.rotation,
|
||||||
isAspectRatioLocked || !getShapeUtils(initialShape).canChangeAspectRatio
|
isAspectRatioLocked ||
|
||||||
|
shape.isAspectRatioLocked ||
|
||||||
|
!getShapeUtils(initialShape).canChangeAspectRatio
|
||||||
)
|
)
|
||||||
|
|
||||||
this.scaleX = newBoundingBox.scaleX
|
this.scaleX = newBoundingBox.scaleX
|
||||||
|
|
|
@ -208,7 +208,6 @@ export function getTranslateSnapshot(data: Data) {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
parentId: shape.parentId,
|
parentId: shape.parentId,
|
||||||
childIndex: tld.getChildIndexAbove(data, shape.id),
|
childIndex: tld.getChildIndexAbove(data, shape.id),
|
||||||
isGenerated: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return clone
|
return clone
|
||||||
|
|
|
@ -42,15 +42,13 @@ const arrow = registerShapeUtils<ArrowShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Arrow,
|
type: ShapeType.Arrow,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Arrow',
|
name: 'Arrow',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
bend: 0,
|
bend: 0,
|
||||||
handles: {
|
handles: {
|
||||||
start: {
|
start: {
|
||||||
|
|
|
@ -11,15 +11,11 @@ const dot = registerShapeUtils<DotShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Dot,
|
type: ShapeType.Dot,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Dot',
|
name: 'Dot',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,13 @@ const draw = registerShapeUtils<DrawShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Draw,
|
type: ShapeType.Draw,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Draw',
|
name: 'Draw',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
points: [],
|
points: [],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ const ellipse = registerShapeUtils<EllipseShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Ellipse,
|
type: ShapeType.Ellipse,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Ellipse',
|
name: 'Ellipse',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
|
@ -32,9 +31,6 @@ const ellipse = registerShapeUtils<EllipseShape>({
|
||||||
radiusX: 1,
|
radiusX: 1,
|
||||||
radiusY: 1,
|
radiusY: 1,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,12 @@ const group = registerShapeUtils<GroupShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Group,
|
type: ShapeType.Group,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Group',
|
name: 'Group',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
size: [1, 1],
|
size: [1, 1],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
children: [],
|
children: [],
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,16 +13,12 @@ const line = registerShapeUtils<LineShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Line,
|
type: ShapeType.Line,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Line',
|
name: 'Line',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
direction: [0, 0],
|
direction: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,12 @@ const polyline = registerShapeUtils<PolylineShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Polyline,
|
type: ShapeType.Polyline,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Polyline',
|
name: 'Polyline',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
points: [[0, 0]],
|
points: [[0, 0]],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,12 @@ const ray = registerShapeUtils<RayShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Ray,
|
type: ShapeType.Ray,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Ray',
|
name: 'Ray',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
direction: [0, 1],
|
direction: [0, 1],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@ const rectangle = registerShapeUtils<RectangleShape>({
|
||||||
|
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
|
|
||||||
type: ShapeType.Rectangle,
|
type: ShapeType.Rectangle,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Rectangle',
|
name: 'Rectangle',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
|
@ -23,9 +21,6 @@ const rectangle = registerShapeUtils<RectangleShape>({
|
||||||
size: [1, 1],
|
size: [1, 1],
|
||||||
radius: 2,
|
radius: 2,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -56,15 +56,11 @@ const text = registerShapeUtils<TextShape>({
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
id: uniqueId(),
|
id: uniqueId(),
|
||||||
type: ShapeType.Text,
|
type: ShapeType.Text,
|
||||||
isGenerated: false,
|
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
parentId: 'page1',
|
parentId: 'page1',
|
||||||
childIndex: 0,
|
childIndex: 0,
|
||||||
point: [0, 0],
|
point: [0, 0],
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
isAspectRatioLocked: false,
|
|
||||||
isLocked: false,
|
|
||||||
isHidden: false,
|
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
text: '',
|
text: '',
|
||||||
scale: 1,
|
scale: 1,
|
||||||
|
|
9
types.ts
9
types.ts
|
@ -133,7 +133,6 @@ export interface BaseShape {
|
||||||
type: ShapeType
|
type: ShapeType
|
||||||
parentId: string
|
parentId: string
|
||||||
childIndex: number
|
childIndex: number
|
||||||
isGenerated: boolean
|
|
||||||
name: string
|
name: string
|
||||||
point: number[]
|
point: number[]
|
||||||
style: ShapeStyles
|
style: ShapeStyles
|
||||||
|
@ -141,9 +140,11 @@ export interface BaseShape {
|
||||||
children?: string[]
|
children?: string[]
|
||||||
bindings?: Record<string, ShapeBinding>
|
bindings?: Record<string, ShapeBinding>
|
||||||
handles?: Record<string, ShapeHandle>
|
handles?: Record<string, ShapeHandle>
|
||||||
isLocked: boolean
|
isLocked?: boolean
|
||||||
isHidden: boolean
|
isHidden?: boolean
|
||||||
isAspectRatioLocked: boolean
|
isEditing?: boolean
|
||||||
|
isGenerated?: boolean
|
||||||
|
isAspectRatioLocked?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DotShape extends BaseShape {
|
export interface DotShape extends BaseShape {
|
||||||
|
|
Loading…
Reference in a new issue