mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
27 lines
817 B
TypeScript
27 lines
817 B
TypeScript
import { KEYS } from "../keys";
|
|
|
|
import { register } from "./register";
|
|
import { changeFontSize, FONT_SIZE_RELATIVE_INCREASE_STEP } from "./utils";
|
|
|
|
export const actionDecreaseFontSize = register({
|
|
name: "decreaseFontSize",
|
|
trackEvent: false,
|
|
perform: (elements, appState, value, app) => {
|
|
return changeFontSize(elements, appState, app, (element) =>
|
|
Math.round(
|
|
// get previous value before relative increase (doesn't work fully
|
|
// due to rounding and float precision issues)
|
|
(1 / (1 + FONT_SIZE_RELATIVE_INCREASE_STEP)) * element.fontSize,
|
|
),
|
|
);
|
|
},
|
|
keyTest: (event) => {
|
|
return (
|
|
event[KEYS.CTRL_OR_CMD] &&
|
|
event.shiftKey &&
|
|
// KEYS.COMMA needed for MacOS
|
|
(event.key === KEYS.CHEVRON_LEFT || event.key === KEYS.COMMA)
|
|
);
|
|
},
|
|
});
|