mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Refactor ExcalidrawElement (#874)
* Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap
This commit is contained in:
parent
8ecb4201db
commit
ccbbdb75a6
39 changed files with 416 additions and 306 deletions
|
@ -1,6 +1,5 @@
|
|||
import { randomSeed } from "roughjs/bin/math";
|
||||
import nanoid from "nanoid";
|
||||
import { Drawable } from "roughjs/bin/core";
|
||||
import { Point } from "roughjs/bin/geometry";
|
||||
|
||||
import { ExcalidrawElement, ExcalidrawTextElement } from "../element/types";
|
||||
|
@ -32,14 +31,8 @@ export function newElement(
|
|||
strokeWidth,
|
||||
roughness,
|
||||
opacity,
|
||||
isSelected: false,
|
||||
seed: randomSeed(),
|
||||
shape: null as Drawable | Drawable[] | null,
|
||||
points: [] as Point[],
|
||||
canvas: null as HTMLCanvasElement | null,
|
||||
canvasZoom: 1, // The zoom level used to render the cached canvas
|
||||
canvasOffsetX: 0,
|
||||
canvasOffsetY: 0,
|
||||
};
|
||||
return element;
|
||||
}
|
||||
|
@ -52,7 +45,6 @@ export function newTextElement(
|
|||
const metrics = measureText(text, font);
|
||||
const textElement: ExcalidrawTextElement = {
|
||||
...element,
|
||||
shape: null,
|
||||
type: "text",
|
||||
text: text,
|
||||
font: font,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue