Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
76fdb0ae59 | ||
![]() |
9919d7d7e2 | ||
![]() |
a2978a4783 | ||
![]() |
5a9f3dfdd8 | ||
![]() |
dce6010b29 |
@ -11,7 +11,6 @@ import { ToolButton } from "../components/ToolButton";
|
|||||||
import { getNonDeletedElements } from "../element";
|
import { getNonDeletedElements } from "../element";
|
||||||
import { isFrameLikeElement } from "../element/typeChecks";
|
import { isFrameLikeElement } from "../element/typeChecks";
|
||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
import { updateFrameMembershipOfSelectedElements } from "../frame";
|
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { isSomeElementSelected } from "../scene";
|
import { isSomeElementSelected } from "../scene";
|
||||||
@ -45,10 +44,8 @@ const alignSelectedElements = (
|
|||||||
|
|
||||||
const updatedElementsMap = arrayToMap(updatedElements);
|
const updatedElementsMap = arrayToMap(updatedElements);
|
||||||
|
|
||||||
return updateFrameMembershipOfSelectedElements(
|
return elements.map(
|
||||||
elements.map((element) => updatedElementsMap.get(element.id) || element),
|
(element) => updatedElementsMap.get(element.id) || element,
|
||||||
appState,
|
|
||||||
app,
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import { distributeElements, Distribution } from "../distribute";
|
|||||||
import { getNonDeletedElements } from "../element";
|
import { getNonDeletedElements } from "../element";
|
||||||
import { isFrameLikeElement } from "../element/typeChecks";
|
import { isFrameLikeElement } from "../element/typeChecks";
|
||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
import { updateFrameMembershipOfSelectedElements } from "../frame";
|
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { CODES, KEYS } from "../keys";
|
import { CODES, KEYS } from "../keys";
|
||||||
import { isSomeElementSelected } from "../scene";
|
import { isSomeElementSelected } from "../scene";
|
||||||
@ -36,10 +35,8 @@ const distributeSelectedElements = (
|
|||||||
|
|
||||||
const updatedElementsMap = arrayToMap(updatedElements);
|
const updatedElementsMap = arrayToMap(updatedElements);
|
||||||
|
|
||||||
return updateFrameMembershipOfSelectedElements(
|
return elements.map(
|
||||||
elements.map((element) => updatedElementsMap.get(element.id) || element),
|
(element) => updatedElementsMap.get(element.id) || element,
|
||||||
appState,
|
|
||||||
app,
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ const duplicateElements = (
|
|||||||
|
|
||||||
const idsOfElementsToDuplicate = arrayToMap(
|
const idsOfElementsToDuplicate = arrayToMap(
|
||||||
getSelectedElements(sortedElements, appState, {
|
getSelectedElements(sortedElements, appState, {
|
||||||
includeBoundTextElement: true,
|
includeBoundTextElement: false,
|
||||||
includeElementsInFrames: true,
|
includeElementsInFrames: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -19,11 +19,7 @@ export const actionFlipHorizontal = register({
|
|||||||
trackEvent: { category: "element" },
|
trackEvent: { category: "element" },
|
||||||
perform: (elements, appState, _, app) => {
|
perform: (elements, appState, _, app) => {
|
||||||
return {
|
return {
|
||||||
elements: updateFrameMembershipOfSelectedElements(
|
elements: flipSelectedElements(elements, appState, "horizontal"),
|
||||||
flipSelectedElements(elements, appState, "horizontal"),
|
|
||||||
appState,
|
|
||||||
app,
|
|
||||||
),
|
|
||||||
appState,
|
appState,
|
||||||
commitToHistory: true,
|
commitToHistory: true,
|
||||||
};
|
};
|
||||||
|
@ -267,6 +267,7 @@ import {
|
|||||||
isTransparent,
|
isTransparent,
|
||||||
easeToValuesRAF,
|
easeToValuesRAF,
|
||||||
muteFSAbortError,
|
muteFSAbortError,
|
||||||
|
arrayToMap,
|
||||||
isTestEnv,
|
isTestEnv,
|
||||||
easeOut,
|
easeOut,
|
||||||
updateStable,
|
updateStable,
|
||||||
@ -2177,6 +2178,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update frame membership if needed
|
||||||
|
updateFrameMembershipOfSelectedElements(
|
||||||
|
this.scene.getElementsIncludingDeleted(),
|
||||||
|
this.state,
|
||||||
|
this,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -4340,11 +4348,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
!(isTextElement(element) && element.containerId)),
|
!(isTextElement(element) && element.containerId)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const elementsMap = arrayToMap(elements);
|
||||||
|
|
||||||
return getElementsAtPosition(elements, (element) =>
|
return getElementsAtPosition(elements, (element) =>
|
||||||
hitTest(element, this.state, this.frameNameBoundsCache, x, y),
|
hitTest(element, this.state, this.frameNameBoundsCache, x, y),
|
||||||
).filter((element) => {
|
).filter((element) => {
|
||||||
// hitting a frame's element from outside the frame is not considered a hit
|
// hitting a frame's element from outside the frame is not considered a hit
|
||||||
const containingFrame = getContainingFrame(element);
|
const containingFrame = getContainingFrame(element, elementsMap);
|
||||||
return containingFrame &&
|
return containingFrame &&
|
||||||
this.state.frameRendering.enabled &&
|
this.state.frameRendering.enabled &&
|
||||||
this.state.frameRendering.clip
|
this.state.frameRendering.clip
|
||||||
@ -7679,7 +7689,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (linearElement?.frameId) {
|
if (linearElement?.frameId) {
|
||||||
const frame = getContainingFrame(linearElement);
|
const frame = getContainingFrame(
|
||||||
|
linearElement,
|
||||||
|
arrayToMap(this.scene.getElementsIncludingDeleted()),
|
||||||
|
);
|
||||||
|
|
||||||
if (frame && linearElement) {
|
if (frame && linearElement) {
|
||||||
if (!elementOverlapsWithFrame(linearElement, frame)) {
|
if (!elementOverlapsWithFrame(linearElement, frame)) {
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
getFrameChildren,
|
getFrameChildren,
|
||||||
} from "../frame";
|
} from "../frame";
|
||||||
import { isShallowEqual } from "../utils";
|
import { isShallowEqual } from "../utils";
|
||||||
|
import { arrayToMap } from "../utils";
|
||||||
import { isElementInViewport } from "../element/sizeHelpers";
|
import { isElementInViewport } from "../element/sizeHelpers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,11 +49,13 @@ export const getElementsWithinSelection = (
|
|||||||
const [selectionX1, selectionY1, selectionX2, selectionY2] =
|
const [selectionX1, selectionY1, selectionX2, selectionY2] =
|
||||||
getElementAbsoluteCoords(selection);
|
getElementAbsoluteCoords(selection);
|
||||||
|
|
||||||
|
const elementsMap = arrayToMap(elements);
|
||||||
|
|
||||||
let elementsInSelection = elements.filter((element) => {
|
let elementsInSelection = elements.filter((element) => {
|
||||||
let [elementX1, elementY1, elementX2, elementY2] =
|
let [elementX1, elementY1, elementX2, elementY2] =
|
||||||
getElementBounds(element);
|
getElementBounds(element);
|
||||||
|
|
||||||
const containingFrame = getContainingFrame(element);
|
const containingFrame = getContainingFrame(element, elementsMap);
|
||||||
if (containingFrame) {
|
if (containingFrame) {
|
||||||
const [fx1, fy1, fx2, fy2] = getElementBounds(containingFrame);
|
const [fx1, fy1, fx2, fy2] = getElementBounds(containingFrame);
|
||||||
|
|
||||||
@ -78,7 +81,7 @@ export const getElementsWithinSelection = (
|
|||||||
: elementsInSelection;
|
: elementsInSelection;
|
||||||
|
|
||||||
elementsInSelection = elementsInSelection.filter((element) => {
|
elementsInSelection = elementsInSelection.filter((element) => {
|
||||||
const containingFrame = getContainingFrame(element);
|
const containingFrame = getContainingFrame(element, elementsMap);
|
||||||
|
|
||||||
if (containingFrame) {
|
if (containingFrame) {
|
||||||
return elementOverlapsWithFrame(element, containingFrame);
|
return elementOverlapsWithFrame(element, containingFrame);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user