feat: Call actionFinalize at the end of arrow creation and drag (#9453)
* First iter Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * Restore binding Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * More actionFinalize Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * Additional fixes Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * New elbow arrow is removed if too small Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * Remove very small arrows * Still allow loops * Restore tests Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * Update history snapshot * More history snapshot updates * keep invisible 2-point lines/freedraw elements --------- Signed-off-by: Mark Tolmacs <mark@lazycat.hu> Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@@ -107,13 +107,11 @@ import {
|
||||
import { getCommonBounds, getElementAbsoluteCoords } from "@excalidraw/element";
|
||||
|
||||
import {
|
||||
bindOrUnbindLinearElement,
|
||||
bindOrUnbindLinearElements,
|
||||
fixBindingsAfterDeletion,
|
||||
getHoveredElementForBinding,
|
||||
isBindingEnabled,
|
||||
isLinearElementSimpleAndAlreadyBound,
|
||||
maybeBindLinearElement,
|
||||
shouldEnableBindingForPointerEvent,
|
||||
updateBoundElements,
|
||||
getSuggestedBindingsForArrows,
|
||||
@@ -2797,7 +2795,6 @@ class App extends React.Component<AppProps, AppState> {
|
||||
this.updateEmbeddables();
|
||||
const elements = this.scene.getElementsIncludingDeleted();
|
||||
const elementsMap = this.scene.getElementsMapIncludingDeleted();
|
||||
const nonDeletedElementsMap = this.scene.getNonDeletedElementsMap();
|
||||
|
||||
if (!this.state.showWelcomeScreen && !elements.length) {
|
||||
this.setState({ showWelcomeScreen: true });
|
||||
@@ -2944,27 +2941,6 @@ class App extends React.Component<AppProps, AppState> {
|
||||
this.setState({ selectedLinearElement: null });
|
||||
}
|
||||
|
||||
const { multiElement } = prevState;
|
||||
if (
|
||||
prevState.activeTool !== this.state.activeTool &&
|
||||
multiElement != null &&
|
||||
isBindingEnabled(this.state) &&
|
||||
isBindingElement(multiElement, false)
|
||||
) {
|
||||
maybeBindLinearElement(
|
||||
multiElement,
|
||||
this.state,
|
||||
tupleToCoors(
|
||||
LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
||||
multiElement,
|
||||
-1,
|
||||
nonDeletedElementsMap,
|
||||
),
|
||||
),
|
||||
this.scene,
|
||||
);
|
||||
}
|
||||
|
||||
this.store.commit(elementsMap, this.state);
|
||||
|
||||
// Do not notify consumers if we're still loading the scene. Among other
|
||||
@@ -9143,34 +9119,9 @@ class App extends React.Component<AppProps, AppState> {
|
||||
this.setState({ selectedLinearElement: null });
|
||||
}
|
||||
} else {
|
||||
const linearElementEditor = LinearElementEditor.handlePointerUp(
|
||||
childEvent,
|
||||
this.state.selectedLinearElement,
|
||||
this.state,
|
||||
this.scene,
|
||||
);
|
||||
|
||||
const { startBindingElement, endBindingElement } =
|
||||
linearElementEditor;
|
||||
const element = this.scene.getElement(linearElementEditor.elementId);
|
||||
if (isBindingElement(element)) {
|
||||
bindOrUnbindLinearElement(
|
||||
element,
|
||||
startBindingElement,
|
||||
endBindingElement,
|
||||
this.scene,
|
||||
);
|
||||
}
|
||||
|
||||
if (linearElementEditor !== this.state.selectedLinearElement) {
|
||||
this.setState({
|
||||
selectedLinearElement: {
|
||||
...linearElementEditor,
|
||||
selectedPointsIndices: null,
|
||||
},
|
||||
suggestedBindings: [],
|
||||
});
|
||||
}
|
||||
this.actionManager.executeAction(actionFinalize, "ui", {
|
||||
event: childEvent,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9294,12 +9245,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
isBindingEnabled(this.state) &&
|
||||
isBindingElement(newElement, false)
|
||||
) {
|
||||
maybeBindLinearElement(
|
||||
newElement,
|
||||
this.state,
|
||||
pointerCoords,
|
||||
this.scene,
|
||||
);
|
||||
this.actionManager.executeAction(actionFinalize);
|
||||
}
|
||||
this.setState({ suggestedBindings: [], startBoundElement: null });
|
||||
if (!activeTool.locked) {
|
||||
|
||||
Reference in New Issue
Block a user