Improves file saving / page saving and loading
This commit is contained in:
parent
7e03adcd52
commit
4ce2b8cc6b
68 changed files with 1166 additions and 997 deletions
|
@ -1,5 +1,5 @@
|
|||
import CodeShape from './index'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { uniqueId } from 'utils/utils'
|
||||
import { CircleShape, ShapeType } from 'types'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
import { defaultStyle } from 'lib/shape-styles'
|
||||
|
@ -9,7 +9,7 @@ export default class Circle extends CodeShape<CircleShape> {
|
|||
props.point = vectorToPoint(props.point)
|
||||
|
||||
super({
|
||||
id: uuid(),
|
||||
id: uniqueId(),
|
||||
seed: Math.random(),
|
||||
parentId: (window as any).currentPageId,
|
||||
type: ShapeType.Circle,
|
||||
|
|
|
@ -3,8 +3,8 @@ import {
|
|||
ControlType,
|
||||
NumberCodeControl,
|
||||
VectorCodeControl,
|
||||
} from "types"
|
||||
import { v4 as uuid } from "uuid"
|
||||
} from 'types'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
|
||||
export const controls: Record<string, any> = {}
|
||||
|
||||
|
@ -13,8 +13,8 @@ export const codeControls = new Set<CodeControl>([])
|
|||
export class Control<T extends CodeControl> {
|
||||
control: T
|
||||
|
||||
constructor(control: Omit<T, "id">) {
|
||||
this.control = { ...control, id: uuid() } as T
|
||||
constructor(control: Omit<T, 'id'>) {
|
||||
this.control = { ...control, id: uniqueId() } as T
|
||||
codeControls.add(this.control)
|
||||
|
||||
// Could there be a better way to prevent this?
|
||||
|
@ -32,7 +32,7 @@ export class Control<T extends CodeControl> {
|
|||
}
|
||||
|
||||
export class NumberControl extends Control<NumberCodeControl> {
|
||||
constructor(options: Omit<NumberCodeControl, "id" | "type">) {
|
||||
constructor(options: Omit<NumberCodeControl, 'id' | 'type'>) {
|
||||
const { value = 0, step = 1 } = options
|
||||
super({
|
||||
type: ControlType.Number,
|
||||
|
@ -44,7 +44,7 @@ export class NumberControl extends Control<NumberCodeControl> {
|
|||
}
|
||||
|
||||
export class VectorControl extends Control<VectorCodeControl> {
|
||||
constructor(options: Omit<VectorCodeControl, "id" | "type">) {
|
||||
constructor(options: Omit<VectorCodeControl, 'id' | 'type'>) {
|
||||
const { value = [0, 0], isNormalized = false } = options
|
||||
super({
|
||||
type: ControlType.Vector,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import CodeShape from './index'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { uniqueId } from 'utils/utils'
|
||||
import { DotShape, ShapeType } from 'types'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
import { defaultStyle } from 'lib/shape-styles'
|
||||
|
@ -9,7 +9,7 @@ export default class Dot extends CodeShape<DotShape> {
|
|||
props.point = vectorToPoint(props.point)
|
||||
|
||||
super({
|
||||
id: uuid(),
|
||||
id: uniqueId(),
|
||||
seed: Math.random(),
|
||||
parentId: (window as any).currentPageId,
|
||||
type: ShapeType.Dot,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import CodeShape from './index'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { uniqueId } from 'utils/utils'
|
||||
import { EllipseShape, ShapeType } from 'types'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
import { defaultStyle } from 'lib/shape-styles'
|
||||
|
@ -9,7 +9,7 @@ export default class Ellipse extends CodeShape<EllipseShape> {
|
|||
props.point = vectorToPoint(props.point)
|
||||
|
||||
super({
|
||||
id: uuid(),
|
||||
id: uniqueId(),
|
||||
seed: Math.random(),
|
||||
parentId: (window as any).currentPageId,
|
||||
type: ShapeType.Ellipse,
|
||||
|
|
|
@ -4,7 +4,7 @@ import shapeUtilityMap, {
|
|||
getShapeUtils,
|
||||
ShapeUtility,
|
||||
} from 'lib/shape-utils'
|
||||
import * as vec from 'utils/vec'
|
||||
import vec from 'utils/vec'
|
||||
import Vector from './vector'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import CodeShape from './index'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { uniqueId } from 'utils/utils'
|
||||
import { LineShape, ShapeType } from 'types'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
import { defaultStyle } from 'lib/shape-styles'
|
||||
|
@ -10,7 +10,7 @@ export default class Line extends CodeShape<LineShape> {
|
|||
props.direction = vectorToPoint(props.direction)
|
||||
|
||||
super({
|
||||
id: uuid(),
|
||||
id: uniqueId(),
|
||||
seed: Math.random(),
|
||||
parentId: (window as any).currentPageId,
|
||||
type: ShapeType.Line,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import CodeShape from './index'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { uniqueId } from 'utils/utils'
|
||||
import { PolylineShape, ShapeType } from 'types'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
import { defaultStyle } from 'lib/shape-styles'
|
||||
|
@ -10,7 +10,7 @@ export default class Polyline extends CodeShape<PolylineShape> {
|
|||
props.points = props.points.map(vectorToPoint)
|
||||
|
||||
super({
|
||||
id: uuid(),
|
||||
id: uniqueId(),
|
||||
seed: Math.random(),
|
||||
parentId: (window as any).currentPageId,
|
||||
type: ShapeType.Polyline,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import CodeShape from './index'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { uniqueId } from 'utils/utils'
|
||||
import { RayShape, ShapeType } from 'types'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
import { defaultStyle } from 'lib/shape-styles'
|
||||
|
@ -10,7 +10,7 @@ export default class Ray extends CodeShape<RayShape> {
|
|||
props.direction = vectorToPoint(props.direction)
|
||||
|
||||
super({
|
||||
id: uuid(),
|
||||
id: uniqueId(),
|
||||
seed: Math.random(),
|
||||
type: ShapeType.Ray,
|
||||
isGenerated: true,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import CodeShape from './index'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { uniqueId } from 'utils/utils'
|
||||
import { RectangleShape, ShapeType } from 'types'
|
||||
import { vectorToPoint } from 'utils/utils'
|
||||
import { defaultStyle } from 'lib/shape-styles'
|
||||
|
@ -10,7 +10,7 @@ export default class Rectangle extends CodeShape<RectangleShape> {
|
|||
props.size = vectorToPoint(props.size)
|
||||
|
||||
super({
|
||||
id: uuid(),
|
||||
id: uniqueId(),
|
||||
seed: Math.random(),
|
||||
parentId: (window as any).currentPageId,
|
||||
type: ShapeType.Rectangle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue