fix: perf issue when ungrouping elements within frame (#7265)
Co-authored-by: Ryan Di <ryan.weihao.di@gmail.com>
This commit is contained in:
parent
900b317bf3
commit
6363492cee
@ -17,15 +17,12 @@ import {
|
|||||||
import { getNonDeletedElements } from "../element";
|
import { getNonDeletedElements } from "../element";
|
||||||
import { randomId } from "../random";
|
import { randomId } from "../random";
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import {
|
import { ExcalidrawElement, ExcalidrawTextElement } from "../element/types";
|
||||||
ExcalidrawElement,
|
|
||||||
ExcalidrawFrameElement,
|
|
||||||
ExcalidrawTextElement,
|
|
||||||
} from "../element/types";
|
|
||||||
import { AppClassProperties, AppState } from "../types";
|
import { AppClassProperties, AppState } from "../types";
|
||||||
import { isBoundToContainer } from "../element/typeChecks";
|
import { isBoundToContainer } from "../element/typeChecks";
|
||||||
import {
|
import {
|
||||||
getElementsInResizingFrame,
|
getElementsInResizingFrame,
|
||||||
|
getFrameElements,
|
||||||
groupByFrames,
|
groupByFrames,
|
||||||
removeElementsFromFrame,
|
removeElementsFromFrame,
|
||||||
replaceAllElementsInFrame,
|
replaceAllElementsInFrame,
|
||||||
@ -190,13 +187,6 @@ export const actionUngroup = register({
|
|||||||
|
|
||||||
let nextElements = [...elements];
|
let nextElements = [...elements];
|
||||||
|
|
||||||
const selectedElements = app.scene.getSelectedElements(appState);
|
|
||||||
const frames = selectedElements
|
|
||||||
.filter((element) => element.frameId)
|
|
||||||
.map((element) =>
|
|
||||||
app.scene.getElement(element.frameId!),
|
|
||||||
) as ExcalidrawFrameElement[];
|
|
||||||
|
|
||||||
const boundTextElementIds: ExcalidrawTextElement["id"][] = [];
|
const boundTextElementIds: ExcalidrawTextElement["id"][] = [];
|
||||||
nextElements = nextElements.map((element) => {
|
nextElements = nextElements.map((element) => {
|
||||||
if (isBoundToContainer(element)) {
|
if (isBoundToContainer(element)) {
|
||||||
@ -221,7 +211,19 @@ export const actionUngroup = register({
|
|||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
|
||||||
frames.forEach((frame) => {
|
const selectedElements = app.scene.getSelectedElements(appState);
|
||||||
|
|
||||||
|
const selectedElementFrameIds = new Set(
|
||||||
|
selectedElements
|
||||||
|
.filter((element) => element.frameId)
|
||||||
|
.map((element) => element.frameId!),
|
||||||
|
);
|
||||||
|
|
||||||
|
const targetFrames = getFrameElements(elements).filter((frame) =>
|
||||||
|
selectedElementFrameIds.has(frame.id),
|
||||||
|
);
|
||||||
|
|
||||||
|
targetFrames.forEach((frame) => {
|
||||||
if (frame) {
|
if (frame) {
|
||||||
nextElements = replaceAllElementsInFrame(
|
nextElements = replaceAllElementsInFrame(
|
||||||
nextElements,
|
nextElements,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user