mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-16 02:35:13 +01:00
feat: switch between basic shapes (#9270)
* feat: switch between basic shapes * add tab for testing * style tweaks * only show hint when a new node is created * fix panel state * refactor * combine captures into one * keep original font size * switch multi * switch different types altogether * use tab only * fix font size atom * do not switch from active tool change * prefer generic when mixed * provide an optional direction when shape switching * adjust panel bg & shadow * redraw to correctly position text * remove redundant code * only tab to switch if focusing on app container * limit which linear elements can be switched * add shape switch to command palette * remove hint * cache initial panel position * bend line to elbow if needed * remove debug logic * clean switch of arrows using app state * safe conversion between line, sharp, curved, and elbow * cache linear when panel shows up * type safe element conversion * rename type * respect initial type when switching between linears * fix elbow segment indexing * use latest linear * merge converted elbow points if too close * focus on panel after click * set roudness to null to fix drag points offset for elbows * remove Mutable * add arrowBoundToElement check * make it dependent on one signle state * unmount when not showing * simpler types, tidy up code * can change linear when it's linear + non-generic * fix popup component lifecycle * move constant to CLASSES * DRY out type detection * file & variable renaming * refactor * throw in not-prod instead * simplify * semi-fix bindings on `generic` type conversion --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@@ -11,8 +11,10 @@ import type Scene from "@excalidraw/element/Scene";
|
||||
|
||||
import { angleIcon } from "../icons";
|
||||
|
||||
import { updateBindings } from "../../../element/src/binding";
|
||||
|
||||
import DragInput from "./DragInput";
|
||||
import { getStepSizedValue, isPropertyEditable, updateBindings } from "./utils";
|
||||
import { getStepSizedValue, isPropertyEditable } from "./utils";
|
||||
|
||||
import type { DragInputCallbackType } from "./DragInput";
|
||||
import type { AppState } from "../../types";
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import { pointFrom, pointRotateRads } from "@excalidraw/math";
|
||||
|
||||
import {
|
||||
bindOrUnbindLinearElements,
|
||||
updateBoundElements,
|
||||
} from "@excalidraw/element/binding";
|
||||
import { getBoundTextElement } from "@excalidraw/element/textElement";
|
||||
import {
|
||||
isFrameLikeElement,
|
||||
isLinearElement,
|
||||
isTextElement,
|
||||
} from "@excalidraw/element/typeChecks";
|
||||
|
||||
@@ -27,6 +22,8 @@ import type {
|
||||
|
||||
import type Scene from "@excalidraw/element/Scene";
|
||||
|
||||
import { updateBindings } from "../../../element/src/binding";
|
||||
|
||||
import type { AppState } from "../../types";
|
||||
|
||||
export type StatsInputProperty =
|
||||
@@ -194,19 +191,3 @@ export const getAtomicUnits = (
|
||||
});
|
||||
return _atomicUnits;
|
||||
};
|
||||
|
||||
export const updateBindings = (
|
||||
latestElement: ExcalidrawElement,
|
||||
scene: Scene,
|
||||
options?: {
|
||||
simultaneouslyUpdated?: readonly ExcalidrawElement[];
|
||||
newSize?: { width: number; height: number };
|
||||
zoom?: AppState["zoom"];
|
||||
},
|
||||
) => {
|
||||
if (isLinearElement(latestElement)) {
|
||||
bindOrUnbindLinearElements([latestElement], true, [], scene, options?.zoom);
|
||||
} else {
|
||||
updateBoundElements(latestElement, scene, options);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user