feat: cache most of element selection (#6747)

This commit is contained in:
David Luzar 2023-07-17 01:09:44 +02:00 committed by GitHub
parent 2e46e27490
commit 9f76f8677b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 452 additions and 3755 deletions

View file

@ -1,6 +1,4 @@
import { register } from "./register";
import { getSelectedElements } from "../scene";
import { getNonDeletedElements } from "../element";
import { deepCopyElement } from "../element/newElement";
import { randomId } from "../random";
import { t } from "../i18n";
@ -9,14 +7,11 @@ export const actionAddToLibrary = register({
name: "addToLibrary",
trackEvent: { category: "element" },
perform: (elements, appState, _, app) => {
const selectedElements = getSelectedElements(
getNonDeletedElements(elements),
appState,
{
includeBoundTextElement: true,
includeElementsInFrames: true,
},
);
const selectedElements = app.scene.getSelectedElements({
selectedElementIds: appState.selectedElementIds,
includeBoundTextElement: true,
includeElementsInFrames: true,
});
if (selectedElements.some((element) => element.type === "image")) {
return {
commitToHistory: false,