mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Multi Point Lines (based on Multi Point Arrows) (#660)
* Enable multi points in lines * Stop retrieving arrow points for lines * Migrate lines to new spec during load * Clean up and refactor some code - Normalize shape dimensions during load - Rename getArrowAbsoluteBounds * Fix linter issues
This commit is contained in:
parent
f70bd0081c
commit
dab35c9033
9 changed files with 102 additions and 178 deletions
|
@ -1,6 +1,6 @@
|
|||
import { ExcalidrawElement } from "./types";
|
||||
import { SceneScroll } from "../scene/types";
|
||||
import { getArrowAbsoluteBounds } from "./bounds";
|
||||
import { getLinearElementAbsoluteBounds } from "./bounds";
|
||||
|
||||
type Sides = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
|
||||
|
||||
|
@ -16,10 +16,13 @@ export function handlerRectangles(
|
|||
let marginY = -8;
|
||||
|
||||
const minimumSize = 40;
|
||||
if (element.type === "arrow") {
|
||||
[elementX1, elementY1, elementX2, elementY2] = getArrowAbsoluteBounds(
|
||||
element,
|
||||
);
|
||||
if (element.type === "arrow" || element.type === "line") {
|
||||
[
|
||||
elementX1,
|
||||
elementY1,
|
||||
elementX2,
|
||||
elementY2,
|
||||
] = getLinearElementAbsoluteBounds(element);
|
||||
} else {
|
||||
elementX1 = element.x;
|
||||
elementX2 = element.x + element.width;
|
||||
|
@ -90,12 +93,7 @@ export function handlerRectangles(
|
|||
8,
|
||||
]; // se
|
||||
|
||||
if (element.type === "line") {
|
||||
return {
|
||||
nw: handlers.nw,
|
||||
se: handlers.se,
|
||||
} as typeof handlers;
|
||||
} else if (element.type === "arrow") {
|
||||
if (element.type === "arrow" || element.type === "line") {
|
||||
if (element.points.length === 2) {
|
||||
// only check the last point because starting point is always (0,0)
|
||||
const [, p1] = element.points;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue