mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-09 10:37:22 +02:00
fix: Direct binding manipulation
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
getFontString,
|
||||
} from "@excalidraw/common";
|
||||
import {
|
||||
bindOrUnbindLinearElement,
|
||||
getOriginalContainerHeightFromCache,
|
||||
resetOriginalContainerCache,
|
||||
updateOriginalContainerCache,
|
||||
@@ -36,6 +37,7 @@ import { newElement } from "@excalidraw/element";
|
||||
import { CaptureUpdateAction } from "@excalidraw/element";
|
||||
|
||||
import type {
|
||||
ExcalidrawBindableElement,
|
||||
ExcalidrawElement,
|
||||
ExcalidrawLinearElement,
|
||||
ExcalidrawTextContainer,
|
||||
@@ -270,7 +272,7 @@ export const actionWrapTextInContainer = register({
|
||||
),
|
||||
groupIds: textElement.groupIds,
|
||||
frameId: textElement.frameId,
|
||||
});
|
||||
}) as ExcalidrawBindableElement;
|
||||
|
||||
// update bindings
|
||||
if (textElement.boundElements?.length) {
|
||||
@@ -281,26 +283,14 @@ export const actionWrapTextInContainer = register({
|
||||
linearElementIds.includes(ele.id),
|
||||
) as ExcalidrawLinearElement[];
|
||||
linearElements.forEach((ele) => {
|
||||
let startBinding = ele.startBinding;
|
||||
let endBinding = ele.endBinding;
|
||||
|
||||
if (startBinding?.elementId === textElement.id) {
|
||||
startBinding = {
|
||||
...startBinding,
|
||||
elementId: container.id,
|
||||
};
|
||||
}
|
||||
|
||||
if (endBinding?.elementId === textElement.id) {
|
||||
endBinding = { ...endBinding, elementId: container.id };
|
||||
}
|
||||
|
||||
if (startBinding || endBinding) {
|
||||
app.scene.mutateElement(ele, {
|
||||
startBinding,
|
||||
endBinding,
|
||||
});
|
||||
}
|
||||
bindOrUnbindLinearElement(
|
||||
ele,
|
||||
ele.startBinding?.elementId === textElement.id
|
||||
? container
|
||||
: "keep",
|
||||
ele.endBinding?.elementId === textElement.id ? container : "keep",
|
||||
app.scene,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import { KEYS, updateActiveTool } from "@excalidraw/common";
|
||||
|
||||
import { getNonDeletedElements } from "@excalidraw/element";
|
||||
import {
|
||||
bindOrUnbindLinearElement,
|
||||
getNonDeletedElements,
|
||||
} from "@excalidraw/element";
|
||||
import { fixBindingsAfterDeletion } from "@excalidraw/element";
|
||||
import { LinearElementEditor } from "@excalidraw/element";
|
||||
import { newElementWith } from "@excalidraw/element";
|
||||
@@ -92,14 +95,14 @@ const deleteSelectedElements = (
|
||||
el.boundElements.forEach((candidate) => {
|
||||
const bound = app.scene.getNonDeletedElementsMap().get(candidate.id);
|
||||
if (bound && isElbowArrow(bound)) {
|
||||
app.scene.mutateElement(bound, {
|
||||
startBinding:
|
||||
el.id === bound.startBinding?.elementId
|
||||
? null
|
||||
: bound.startBinding,
|
||||
endBinding:
|
||||
el.id === bound.endBinding?.elementId ? null : bound.endBinding,
|
||||
});
|
||||
if (el.id === bound.startBinding?.elementId) {
|
||||
bindOrUnbindLinearElement(
|
||||
bound,
|
||||
el.id === bound.startBinding?.elementId ? null : "keep",
|
||||
el.id === bound.endBinding?.elementId ? null : "keep",
|
||||
app.scene,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user