fix elements insert position and viewport centering

This commit is contained in:
dwelle 2023-09-01 14:49:26 +02:00
parent d070760b2f
commit 9b1c88eed9
4 changed files with 21 additions and 40 deletions

View file

@ -38,14 +38,9 @@ import {
VerticalAlign,
} from "../element/types";
import { MarkOptional } from "../utility-types";
import {
assertNever,
getFontString,
viewportCoordsToSceneCoords,
} from "../utils";
import { assertNever, getFontString } from "../utils";
import { getSizeFromPoints } from "../points";
import { nanoid } from "nanoid";
import { AppState } from "../types";
export type ValidLinearElement = {
type: "arrow" | "line";
@ -392,8 +387,7 @@ class ElementStore {
export const convertToExcalidrawElements = (
elements: ExcalidrawElementSkeleton[] | null,
appState?: AppState,
opts?: { regenerateIds: boolean; transformViewportToSceneCoords: boolean },
opts?: { regenerateIds: boolean },
) => {
if (!elements) {
return [];
@ -411,19 +405,6 @@ export const convertToExcalidrawElements = (
Object.assign(element, { id: nanoid() });
}
// transform viewport coords to scene coordinates
if (opts?.transformViewportToSceneCoords && appState) {
const { x, y } = viewportCoordsToSceneCoords(
{
clientX: element.x,
clientY: element.y,
},
appState,
);
Object.assign(element, { x, y });
}
switch (element.type) {
case "rectangle":
case "ellipse":