mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix elements insert position and viewport centering
This commit is contained in:
parent
d070760b2f
commit
9b1c88eed9
4 changed files with 21 additions and 40 deletions
|
@ -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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue