mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-08-28 12:47:00 +02:00
Compare commits
5 Commits
v0.17.3
...
feat-actio
Author | SHA1 | Date | |
---|---|---|---|
![]() |
60bab6a428 | ||
![]() |
7c9cf30909 | ||
![]() |
1e37dbd60e | ||
![]() |
f8d5c2a1b6 | ||
![]() |
23b24ea5c3 |
@@ -96,7 +96,7 @@
|
||||
"vitest-canvas-mock": "0.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
"node": "18.0.0 - 20.x.x"
|
||||
},
|
||||
"homepage": ".",
|
||||
"name": "excalidraw",
|
||||
|
@@ -265,7 +265,21 @@ export const zoomToFit = ({
|
||||
30.0,
|
||||
) as NormalizedZoomValue;
|
||||
|
||||
scrollX = (appState.width / 2) * (1 / newZoomValue) - centerX;
|
||||
let appStateWidth = appState.width;
|
||||
|
||||
if (appState.openSidebar) {
|
||||
const sidebarDOMElem = document.querySelector(
|
||||
".sidebar",
|
||||
) as HTMLElement | null;
|
||||
const sidebarWidth = sidebarDOMElem?.offsetWidth ?? 0;
|
||||
const isRTL = document.documentElement.getAttribute("dir") === "rtl";
|
||||
|
||||
appStateWidth = !isRTL
|
||||
? appState.width - sidebarWidth
|
||||
: appState.width + sidebarWidth;
|
||||
}
|
||||
|
||||
scrollX = (appStateWidth / 2) * (1 / newZoomValue) - centerX;
|
||||
scrollY = (appState.height / 2) * (1 / newZoomValue) - centerY;
|
||||
} else {
|
||||
newZoomValue = zoomValueToFitBoundsOnViewport(commonBounds, {
|
||||
|
@@ -2,11 +2,12 @@ import { isDarwin } from "../constants";
|
||||
import { t } from "../i18n";
|
||||
import { SubtypeOf } from "../utility-types";
|
||||
import { getShortcutKey } from "../utils";
|
||||
import { ActionName } from "./types";
|
||||
import { ActionName, CustomActionName } from "./types";
|
||||
|
||||
export type ShortcutName =
|
||||
| SubtypeOf<
|
||||
ActionName,
|
||||
| CustomActionName
|
||||
| "toggleTheme"
|
||||
| "loadScene"
|
||||
| "clearCanvas"
|
||||
@@ -40,6 +41,15 @@ export type ShortcutName =
|
||||
| "saveScene"
|
||||
| "imageExport";
|
||||
|
||||
export const registerCustomShortcuts = (
|
||||
shortcuts: Record<CustomActionName, string[]>,
|
||||
) => {
|
||||
for (const key in shortcuts) {
|
||||
const shortcut = key as CustomActionName;
|
||||
shortcutMap[shortcut] = shortcuts[shortcut];
|
||||
}
|
||||
};
|
||||
|
||||
const shortcutMap: Record<ShortcutName, string[]> = {
|
||||
toggleTheme: [getShortcutKey("Shift+Alt+D")],
|
||||
saveScene: [getShortcutKey("CtrlOrCmd+S")],
|
||||
|
@@ -35,7 +35,11 @@ type ActionFn = (
|
||||
export type UpdaterFn = (res: ActionResult) => void;
|
||||
export type ActionFilterFn = (action: Action) => void;
|
||||
|
||||
export const makeCustomActionName = (name: string) =>
|
||||
`custom.${name}` as CustomActionName;
|
||||
export type CustomActionName = `custom.${string}`;
|
||||
export type ActionName =
|
||||
| CustomActionName
|
||||
| "copy"
|
||||
| "cut"
|
||||
| "paste"
|
||||
|
@@ -8317,39 +8317,6 @@ class App extends React.Component<AppProps, AppState> {
|
||||
|
||||
const elementsToHighlight = new Set<ExcalidrawElement>();
|
||||
selectedFrames.forEach((frame) => {
|
||||
const elementsInFrame = getFrameChildren(
|
||||
this.scene.getNonDeletedElements(),
|
||||
frame.id,
|
||||
);
|
||||
|
||||
// keep elements' positions relative to their frames on frames resizing
|
||||
if (transformHandleType) {
|
||||
if (transformHandleType.includes("w")) {
|
||||
elementsInFrame.forEach((element) => {
|
||||
mutateElement(element, {
|
||||
x:
|
||||
frame.x +
|
||||
(frameElementsOffsetsMap.get(frame.id + element.id)?.x || 0),
|
||||
y:
|
||||
frame.y +
|
||||
(frameElementsOffsetsMap.get(frame.id + element.id)?.y || 0),
|
||||
});
|
||||
});
|
||||
}
|
||||
if (transformHandleType.includes("n")) {
|
||||
elementsInFrame.forEach((element) => {
|
||||
mutateElement(element, {
|
||||
x:
|
||||
frame.x +
|
||||
(frameElementsOffsetsMap.get(frame.id + element.id)?.x || 0),
|
||||
y:
|
||||
frame.y +
|
||||
(frameElementsOffsetsMap.get(frame.id + element.id)?.y || 0),
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getElementsInResizingFrame(
|
||||
this.scene.getNonDeletedElements(),
|
||||
frame,
|
||||
|
Reference in New Issue
Block a user