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

@ -2244,11 +2244,12 @@ class App extends React.Component<AppProps, AppState> {
},
);
private addElementsFromPasteOrLibrary = (opts: {
addElementsFromPasteOrLibrary = (opts: {
elements: readonly ExcalidrawElement[];
files: BinaryFiles | null;
position: { clientX: number; clientY: number } | "cursor" | "center";
retainSeed?: boolean;
fitToContent?: boolean;
}) => {
const elements = restoreElements(opts.elements, null, undefined);
const [minX, minY, maxX, maxY] = getCommonBounds(elements);
@ -2353,6 +2354,12 @@ class App extends React.Component<AppProps, AppState> {
},
);
this.setActiveTool({ type: "selection" });
if (opts.fitToContent) {
this.scrollToContent(newElements, {
fitToContent: true,
});
}
};
private addTextFromPaste(text: string, isPlainPaste = false) {