@excalidraw/excalidraw 0.17.1-d2f67e6 → 0.17.1-e63dd02
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/browser/dev/excalidraw-assets-dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-EM6LVGFW.js → chunk-IT7T3AIK.js} +23 -5
- package/dist/browser/dev/excalidraw-assets-dev/chunk-IT7T3AIK.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-B4UMSLQQ.js → chunk-RNHSD5AR.js} +7451 -2098
- package/dist/browser/dev/excalidraw-assets-dev/chunk-RNHSD5AR.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{dist-6QVAH5JA.js → dist-DNSPZDOZ.js} +31 -19
- package/dist/browser/dev/excalidraw-assets-dev/dist-DNSPZDOZ.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-AZFA5HJJ.js → en-XV7OZCPP.js} +6 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-V7E6IT6R.js → image-77HZYGLG.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css → image-WDHYGKKP.css} +1 -1
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css.map → image-WDHYGKKP.css.map} +2 -2
- package/dist/browser/dev/index.css +449 -114
- package/dist/browser/dev/index.css.map +3 -3
- package/dist/browser/dev/index.js +4143 -5956
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-OYEADJSR.js +63 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-7DXALCB2.js → chunk-PDYFZJMS.js} +3 -3
- package/dist/browser/prod/excalidraw-assets/dist-NLUQPPQQ.js +7 -0
- package/dist/browser/prod/excalidraw-assets/en-YVAVVILW.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-X3GFZHNN.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +40 -50
- package/dist/dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/dev/{en-EB2MBPAV.json → en-YNVBSAIL.json} +18 -4
- package/dist/dev/index.css +449 -114
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +21626 -18122
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +9 -3
- package/dist/excalidraw/actions/actionBoundText.d.ts +6 -2
- package/dist/excalidraw/actions/actionCanvas.d.ts +36 -12
- package/dist/excalidraw/actions/actionClipboard.d.ts +22 -7
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +12 -5
- package/dist/excalidraw/actions/actionDeleteSelected.js +24 -5
- package/dist/excalidraw/actions/actionDuplicateSelection.js +1 -2
- package/dist/excalidraw/actions/actionElementLock.d.ts +6 -2
- package/dist/excalidraw/actions/actionExport.d.ts +27 -9
- package/dist/excalidraw/actions/actionFinalize.d.ts +6 -2
- package/dist/excalidraw/actions/actionFinalize.js +2 -2
- package/dist/excalidraw/actions/actionFlip.js +2 -2
- package/dist/excalidraw/actions/actionFrame.d.ts +12 -4
- package/dist/excalidraw/actions/actionGroup.d.ts +6 -2
- package/dist/excalidraw/actions/actionHistory.js +4 -4
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +3 -1
- package/dist/excalidraw/actions/actionLinearEditor.js +3 -2
- package/dist/excalidraw/actions/actionLink.d.ts +3 -1
- package/dist/excalidraw/actions/actionMenu.d.ts +9 -3
- package/dist/excalidraw/actions/actionNavigate.d.ts +6 -2
- package/dist/excalidraw/actions/actionProperties.d.ts +411 -56
- package/dist/excalidraw/actions/actionProperties.js +383 -58
- package/dist/excalidraw/actions/actionSelectAll.d.ts +3 -1
- package/dist/excalidraw/actions/actionStyles.d.ts +3 -1
- package/dist/excalidraw/actions/actionStyles.js +3 -2
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleStats.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +3 -1
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +3 -1
- package/dist/excalidraw/actions/types.d.ts +1 -1
- package/dist/excalidraw/analytics.js +9 -7
- package/dist/excalidraw/appState.d.ts +1 -0
- package/dist/excalidraw/appState.js +9 -1
- package/dist/excalidraw/binaryheap.d.ts +12 -0
- package/dist/excalidraw/binaryheap.js +93 -0
- package/dist/excalidraw/change.d.ts +2 -1
- package/dist/excalidraw/change.js +6 -4
- package/dist/excalidraw/charts.js +0 -10
- package/dist/excalidraw/components/Actions.js +7 -5
- package/dist/excalidraw/components/App.d.ts +5 -9
- package/dist/excalidraw/components/App.js +218 -161
- package/dist/excalidraw/components/ButtonIcon.d.ts +15 -0
- package/dist/excalidraw/components/ButtonIcon.js +8 -0
- package/dist/excalidraw/components/ButtonIconSelect.js +2 -3
- package/dist/excalidraw/components/ButtonSeparator.d.ts +2 -0
- package/dist/excalidraw/components/ButtonSeparator.js +7 -0
- package/dist/excalidraw/components/ColorPicker/ColorPicker.js +47 -79
- package/dist/excalidraw/components/ColorPicker/Picker.js +1 -1
- package/dist/excalidraw/components/FontPicker/FontPicker.d.ts +21 -0
- package/dist/excalidraw/components/FontPicker/FontPicker.js +49 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.d.ts +25 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.js +119 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +7 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.js +13 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +14 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.js +38 -0
- package/dist/excalidraw/components/HelpDialog.js +1 -1
- package/dist/excalidraw/components/HintViewer.js +6 -3
- package/dist/excalidraw/components/PropertiesPopover.d.ts +15 -0
- package/dist/excalidraw/components/PropertiesPopover.js +31 -0
- package/dist/excalidraw/components/QuickSearch.d.ts +9 -0
- package/dist/excalidraw/components/QuickSearch.js +8 -0
- package/dist/excalidraw/components/ScrollableList.d.ts +9 -0
- package/dist/excalidraw/components/ScrollableList.js +8 -0
- package/dist/excalidraw/components/Stats/Angle.d.ts +7 -3
- package/dist/excalidraw/components/Stats/Angle.js +39 -31
- package/dist/excalidraw/components/Stats/Dimension.d.ts +6 -3
- package/dist/excalidraw/components/Stats/Dimension.js +51 -49
- package/dist/excalidraw/components/Stats/DragInput.d.ts +15 -6
- package/dist/excalidraw/components/Stats/DragInput.js +59 -26
- package/dist/excalidraw/components/Stats/FontSize.d.ts +8 -4
- package/dist/excalidraw/components/Stats/FontSize.js +39 -36
- package/dist/excalidraw/components/Stats/MultiAngle.d.ts +5 -3
- package/dist/excalidraw/components/Stats/MultiAngle.js +43 -34
- package/dist/excalidraw/components/Stats/MultiDimension.d.ts +5 -3
- package/dist/excalidraw/components/Stats/MultiDimension.js +101 -99
- package/dist/excalidraw/components/Stats/MultiFontSize.d.ts +6 -3
- package/dist/excalidraw/components/Stats/MultiFontSize.js +47 -32
- package/dist/excalidraw/components/Stats/MultiPosition.d.ts +3 -1
- package/dist/excalidraw/components/Stats/MultiPosition.js +52 -48
- package/dist/excalidraw/components/Stats/Position.d.ts +5 -1
- package/dist/excalidraw/components/Stats/Position.js +31 -29
- package/dist/excalidraw/components/Stats/index.js +5 -17
- package/dist/excalidraw/components/Stats/utils.d.ts +14 -3
- package/dist/excalidraw/components/Stats/utils.js +48 -9
- package/dist/excalidraw/components/TTDDialog/common.d.ts +2 -2
- package/dist/excalidraw/components/TTDDialog/common.js +3 -7
- package/dist/excalidraw/components/UserList.js +22 -22
- package/dist/excalidraw/components/canvases/StaticCanvas.js +1 -0
- package/dist/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +12 -3
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +24 -4
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +55 -14
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +2 -2
- package/dist/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/excalidraw/components/dropdownMenu/common.js +3 -2
- package/dist/excalidraw/components/icons.d.ts +4 -0
- package/dist/excalidraw/components/icons.js +7 -0
- package/dist/excalidraw/components/main-menu/MainMenu.d.ts +12 -3
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +2 -2
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +3 -3
- package/dist/excalidraw/constants.d.ts +17 -2
- package/dist/excalidraw/constants.js +21 -4
- package/dist/excalidraw/data/reconcile.js +18 -1
- package/dist/excalidraw/data/restore.js +55 -9
- package/dist/excalidraw/data/transform.js +8 -5
- package/dist/excalidraw/element/binding.d.ts +28 -9
- package/dist/excalidraw/element/binding.js +303 -71
- package/dist/excalidraw/element/collision.d.ts +1 -1
- package/dist/excalidraw/element/collision.js +4 -1
- package/dist/excalidraw/element/dragElements.d.ts +2 -2
- package/dist/excalidraw/element/dragElements.js +13 -3
- package/dist/excalidraw/element/embeddable.d.ts +3 -1
- package/dist/excalidraw/element/heading.d.ts +11 -0
- package/dist/excalidraw/element/heading.js +81 -0
- package/dist/excalidraw/element/index.d.ts +1 -1
- package/dist/excalidraw/element/index.js +1 -1
- package/dist/excalidraw/element/linearElementEditor.d.ts +21 -13
- package/dist/excalidraw/element/linearElementEditor.js +133 -56
- package/dist/excalidraw/element/newElement.d.ts +8 -3
- package/dist/excalidraw/element/newElement.js +15 -2
- package/dist/excalidraw/element/resizeElements.d.ts +4 -3
- package/dist/excalidraw/element/resizeElements.js +47 -23
- package/dist/excalidraw/element/routing.d.ts +13 -0
- package/dist/excalidraw/element/routing.js +641 -0
- package/dist/excalidraw/element/textElement.d.ts +3 -26
- package/dist/excalidraw/element/textElement.js +54 -110
- package/dist/excalidraw/element/textWysiwyg.js +39 -47
- package/dist/excalidraw/element/transformHandles.js +7 -2
- package/dist/excalidraw/element/typeChecks.d.ts +5 -2
- package/dist/excalidraw/element/typeChecks.js +17 -0
- package/dist/excalidraw/element/types.d.ts +12 -1
- package/dist/excalidraw/fonts/ExcalidrawFont.d.ts +21 -0
- package/dist/excalidraw/fonts/ExcalidrawFont.js +112 -0
- package/dist/excalidraw/fonts/index.d.ts +58 -0
- package/dist/excalidraw/fonts/index.js +240 -0
- package/dist/excalidraw/fonts/metadata.d.ts +36 -0
- package/dist/excalidraw/fonts/metadata.js +91 -0
- package/dist/excalidraw/fractionalIndex.d.ts +11 -4
- package/dist/excalidraw/fractionalIndex.js +38 -6
- package/dist/excalidraw/frame.d.ts +1 -1
- package/dist/excalidraw/frame.js +3 -3
- package/dist/excalidraw/history.d.ts +4 -3
- package/dist/excalidraw/history.js +8 -8
- package/dist/excalidraw/index.d.ts +1 -1
- package/dist/excalidraw/index.js +3 -3
- package/dist/excalidraw/locales/en.json +18 -4
- package/dist/excalidraw/math.d.ts +43 -0
- package/dist/excalidraw/math.js +110 -0
- package/dist/excalidraw/mermaid.js +4 -3
- package/dist/excalidraw/renderer/interactiveScene.js +33 -17
- package/dist/excalidraw/renderer/renderElement.d.ts +2 -0
- package/dist/excalidraw/renderer/renderElement.js +74 -54
- package/dist/excalidraw/renderer/staticSvgScene.js +2 -1
- package/dist/excalidraw/scene/Scene.js +9 -3
- package/dist/excalidraw/scene/Shape.js +56 -5
- package/dist/excalidraw/scene/comparisons.d.ts +1 -0
- package/dist/excalidraw/scene/comparisons.js +1 -1
- package/dist/excalidraw/scene/export.d.ts +2 -1
- package/dist/excalidraw/scene/export.js +33 -35
- package/dist/excalidraw/scene/types.d.ts +1 -4
- package/dist/excalidraw/shapes.d.ts +8 -0
- package/dist/excalidraw/shapes.js +57 -0
- package/dist/excalidraw/types.d.ts +8 -3
- package/dist/excalidraw/utils.d.ts +11 -1
- package/dist/excalidraw/utils.js +22 -0
- package/dist/prod/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/prod/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/prod/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/prod/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/prod/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/prod/{en-EB2MBPAV.json → en-YNVBSAIL.json} +18 -4
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +49 -53
- package/dist/utils/export.d.ts +2 -1
- package/dist/utils/export.js +2 -1
- package/dist/utils/geometry/geometry.d.ts +2 -1
- package/dist/utils/geometry/geometry.js +5 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/history.ts +9 -2
- package/package.json +2 -2
- package/dist/browser/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/chunk-B4UMSLQQ.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-EM6LVGFW.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/dist-6QVAH5JA.js.map +0 -7
- package/dist/browser/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/prod/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-EGOLGOLD.js +0 -55
- package/dist/browser/prod/excalidraw-assets/dist-567JAXHK.js +0 -7
- package/dist/browser/prod/excalidraw-assets/en-6E7MYLWO.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-SI7BKULC.js +0 -1
- package/dist/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/excalidraw/scene/Fonts.d.ts +0 -19
- package/dist/excalidraw/scene/Fonts.js +0 -66
- package/dist/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/prod/Virgil-UZN6MUT6.woff2 +0 -0
- /package/dist/browser/dev/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets-dev/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets-dev/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets-dev/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets-dev/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{en-AZFA5HJJ.js.map → en-XV7OZCPP.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-V7E6IT6R.js.map → image-77HZYGLG.js.map} +0 -0
- /package/dist/browser/prod/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { Children } from "react";
|
|
4
|
+
import "./ScrollableList.scss";
|
|
5
|
+
export const ScrollableList = ({ className, placeholder, children, }) => {
|
|
6
|
+
const isEmpty = !Children.count(children);
|
|
7
|
+
return (_jsx("div", { className: clsx("ScrollableList__wrapper", className), role: "menu", children: isEmpty ? _jsx("div", { className: "empty", children: placeholder }) : children }));
|
|
8
|
+
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
3
5
|
interface AngleProps {
|
|
4
6
|
element: ExcalidrawElement;
|
|
5
|
-
|
|
7
|
+
scene: Scene;
|
|
8
|
+
appState: AppState;
|
|
9
|
+
property: "angle";
|
|
6
10
|
}
|
|
7
|
-
declare const Angle: ({ element,
|
|
11
|
+
declare const Angle: ({ element, scene, appState, property }: AngleProps) => JSX.Element;
|
|
8
12
|
export default Angle;
|
|
@@ -1,45 +1,53 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { mutateElement } from "../../element/mutateElement";
|
|
3
3
|
import { getBoundTextElement } from "../../element/textElement";
|
|
4
|
-
import { isArrowElement } from "../../element/typeChecks";
|
|
4
|
+
import { isArrowElement, isElbowArrow } from "../../element/typeChecks";
|
|
5
5
|
import { degreeToRadian, radianToDegree } from "../../math";
|
|
6
6
|
import { angleIcon } from "../icons";
|
|
7
7
|
import DragInput from "./DragInput";
|
|
8
|
-
import { getStepSizedValue, isPropertyEditable } from "./utils";
|
|
8
|
+
import { getStepSizedValue, isPropertyEditable, updateBindings } from "./utils";
|
|
9
9
|
const STEP_SIZE = 15;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const originalAngleInDegrees = Math.round(radianToDegree(origElement.angle) * 100) / 100;
|
|
26
|
-
const changeInDegrees = Math.round(accumulatedChange);
|
|
27
|
-
let nextAngleInDegrees = (originalAngleInDegrees + changeInDegrees) % 360;
|
|
28
|
-
if (shouldChangeByStepSize) {
|
|
29
|
-
nextAngleInDegrees = getStepSizedValue(nextAngleInDegrees, STEP_SIZE);
|
|
30
|
-
}
|
|
31
|
-
nextAngleInDegrees =
|
|
32
|
-
nextAngleInDegrees < 0 ? nextAngleInDegrees + 360 : nextAngleInDegrees;
|
|
33
|
-
const nextAngle = degreeToRadian(nextAngleInDegrees);
|
|
34
|
-
mutateElement(element, {
|
|
10
|
+
const handleDegreeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, scene, }) => {
|
|
11
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
12
|
+
const elements = scene.getNonDeletedElements();
|
|
13
|
+
const origElement = originalElements[0];
|
|
14
|
+
if (origElement && !isElbowArrow(origElement)) {
|
|
15
|
+
const latestElement = elementsMap.get(origElement.id);
|
|
16
|
+
if (!latestElement) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (nextValue !== undefined) {
|
|
20
|
+
const nextAngle = degreeToRadian(nextValue);
|
|
21
|
+
mutateElement(latestElement, {
|
|
35
22
|
angle: nextAngle,
|
|
36
23
|
});
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
updateBindings(latestElement, elementsMap, elements, scene);
|
|
25
|
+
const boundTextElement = getBoundTextElement(latestElement, elementsMap);
|
|
26
|
+
if (boundTextElement && !isArrowElement(latestElement)) {
|
|
39
27
|
mutateElement(boundTextElement, { angle: nextAngle });
|
|
40
28
|
}
|
|
29
|
+
return;
|
|
41
30
|
}
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
const originalAngleInDegrees = Math.round(radianToDegree(origElement.angle) * 100) / 100;
|
|
32
|
+
const changeInDegrees = Math.round(accumulatedChange);
|
|
33
|
+
let nextAngleInDegrees = (originalAngleInDegrees + changeInDegrees) % 360;
|
|
34
|
+
if (shouldChangeByStepSize) {
|
|
35
|
+
nextAngleInDegrees = getStepSizedValue(nextAngleInDegrees, STEP_SIZE);
|
|
36
|
+
}
|
|
37
|
+
nextAngleInDegrees =
|
|
38
|
+
nextAngleInDegrees < 0 ? nextAngleInDegrees + 360 : nextAngleInDegrees;
|
|
39
|
+
const nextAngle = degreeToRadian(nextAngleInDegrees);
|
|
40
|
+
mutateElement(latestElement, {
|
|
41
|
+
angle: nextAngle,
|
|
42
|
+
});
|
|
43
|
+
updateBindings(latestElement, elementsMap, elements, scene);
|
|
44
|
+
const boundTextElement = getBoundTextElement(latestElement, elementsMap);
|
|
45
|
+
if (boundTextElement && !isArrowElement(latestElement)) {
|
|
46
|
+
mutateElement(boundTextElement, { angle: nextAngle });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const Angle = ({ element, scene, appState, property }) => {
|
|
51
|
+
return (_jsx(DragInput, { label: "A", icon: angleIcon, value: Math.round((radianToDegree(element.angle) % 360) * 100) / 100, elements: [element], dragInputCallback: handleDegreeChange, editable: isPropertyEditable(element, "angle"), scene: scene, appState: appState, property: property }));
|
|
44
52
|
};
|
|
45
53
|
export default Angle;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
3
5
|
interface DimensionDragInputProps {
|
|
4
6
|
property: "width" | "height";
|
|
5
7
|
element: ExcalidrawElement;
|
|
6
|
-
|
|
8
|
+
scene: Scene;
|
|
9
|
+
appState: AppState;
|
|
7
10
|
}
|
|
8
|
-
declare const DimensionDragInput: ({ property, element,
|
|
11
|
+
declare const DimensionDragInput: ({ property, element, scene, appState, }: DimensionDragInputProps) => JSX.Element;
|
|
9
12
|
export default DimensionDragInput;
|
|
@@ -6,61 +6,63 @@ const STEP_SIZE = 10;
|
|
|
6
6
|
const _shouldKeepAspectRatio = (element) => {
|
|
7
7
|
return element.type === "image";
|
|
8
8
|
};
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
const handleDimensionChange = ({ accumulatedChange, originalElements, originalElementsMap, shouldKeepAspectRatio, shouldChangeByStepSize, nextValue, property, scene, }) => {
|
|
10
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
11
|
+
const elements = scene.getNonDeletedElements();
|
|
12
|
+
const origElement = originalElements[0];
|
|
13
|
+
if (origElement) {
|
|
14
|
+
const keepAspectRatio = shouldKeepAspectRatio || _shouldKeepAspectRatio(origElement);
|
|
15
|
+
const aspectRatio = origElement.width / origElement.height;
|
|
16
|
+
if (nextValue !== undefined) {
|
|
17
|
+
const nextWidth = Math.max(property === "width"
|
|
18
|
+
? nextValue
|
|
19
|
+
: keepAspectRatio
|
|
20
|
+
? nextValue * aspectRatio
|
|
21
|
+
: origElement.width, MIN_WIDTH_OR_HEIGHT);
|
|
22
|
+
const nextHeight = Math.max(property === "height"
|
|
23
|
+
? nextValue
|
|
24
|
+
: keepAspectRatio
|
|
25
|
+
? nextValue / aspectRatio
|
|
26
|
+
: origElement.height, MIN_WIDTH_OR_HEIGHT);
|
|
27
|
+
resizeElement(nextWidth, nextHeight, keepAspectRatio, origElement, elementsMap, elements, scene);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const changeInWidth = property === "width" ? accumulatedChange : 0;
|
|
31
|
+
const changeInHeight = property === "height" ? accumulatedChange : 0;
|
|
32
|
+
let nextWidth = Math.max(0, origElement.width + changeInWidth);
|
|
33
|
+
if (property === "width") {
|
|
34
|
+
if (shouldChangeByStepSize) {
|
|
35
|
+
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
28
36
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
nextWidth = Math.round(nextWidth);
|
|
38
|
-
}
|
|
37
|
+
else {
|
|
38
|
+
nextWidth = Math.round(nextWidth);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
let nextHeight = Math.max(0, origElement.height + changeInHeight);
|
|
42
|
+
if (property === "height") {
|
|
43
|
+
if (shouldChangeByStepSize) {
|
|
44
|
+
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
39
45
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (shouldChangeByStepSize) {
|
|
43
|
-
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
nextHeight = Math.round(nextHeight);
|
|
47
|
-
}
|
|
46
|
+
else {
|
|
47
|
+
nextHeight = Math.round(nextHeight);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
}
|
|
50
|
+
if (keepAspectRatio) {
|
|
51
|
+
if (property === "width") {
|
|
52
|
+
nextHeight = Math.round((nextWidth / aspectRatio) * 100) / 100;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
nextWidth = Math.round(nextHeight * aspectRatio * 100) / 100;
|
|
56
56
|
}
|
|
57
|
-
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
58
|
-
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
59
|
-
resizeElement(nextWidth, nextHeight, keepAspectRatio, element, origElement, elementsMap, originalElementsMap);
|
|
60
57
|
}
|
|
61
|
-
|
|
58
|
+
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
59
|
+
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
60
|
+
resizeElement(nextWidth, nextHeight, keepAspectRatio, origElement, elementsMap, elements, scene);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const DimensionDragInput = ({ property, element, scene, appState, }) => {
|
|
62
64
|
const value = Math.round((property === "width" ? element.width : element.height) * 100) /
|
|
63
65
|
100;
|
|
64
|
-
return (_jsx(DragInput, { label: property === "width" ? "W" : "H", elements: [element], dragInputCallback: handleDimensionChange, value: value, editable: isPropertyEditable(element, property) }));
|
|
66
|
+
return (_jsx(DragInput, { label: property === "width" ? "W" : "H", elements: [element], dragInputCallback: handleDimensionChange, value: value, editable: isPropertyEditable(element, property), scene: scene, appState: appState, property: property }));
|
|
65
67
|
};
|
|
66
68
|
export default DimensionDragInput;
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ElementsMap, ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type { StatsInputProperty } from "./utils";
|
|
4
|
+
import type Scene from "../../scene/Scene";
|
|
3
5
|
import "./DragInput.scss";
|
|
4
|
-
|
|
6
|
+
import type { AppState } from "../../types";
|
|
7
|
+
export type DragInputCallbackType<P extends StatsInputProperty, E = ExcalidrawElement> = (props: {
|
|
5
8
|
accumulatedChange: number;
|
|
6
9
|
instantChange: number;
|
|
7
|
-
originalElements: readonly
|
|
10
|
+
originalElements: readonly E[];
|
|
8
11
|
originalElementsMap: ElementsMap;
|
|
9
12
|
shouldKeepAspectRatio: boolean;
|
|
10
13
|
shouldChangeByStepSize: boolean;
|
|
14
|
+
scene: Scene;
|
|
11
15
|
nextValue?: number;
|
|
16
|
+
property: P;
|
|
17
|
+
originalAppState: AppState;
|
|
12
18
|
}) => void;
|
|
13
|
-
interface StatsDragInputProps {
|
|
19
|
+
interface StatsDragInputProps<T extends StatsInputProperty, E = ExcalidrawElement> {
|
|
14
20
|
label: string | React.ReactNode;
|
|
15
21
|
icon?: React.ReactNode;
|
|
16
22
|
value: number | "Mixed";
|
|
17
|
-
elements: readonly
|
|
23
|
+
elements: readonly E[];
|
|
18
24
|
editable?: boolean;
|
|
19
25
|
shouldKeepAspectRatio?: boolean;
|
|
20
|
-
dragInputCallback: DragInputCallbackType
|
|
26
|
+
dragInputCallback: DragInputCallbackType<T, E>;
|
|
27
|
+
property: T;
|
|
28
|
+
scene: Scene;
|
|
29
|
+
appState: AppState;
|
|
21
30
|
}
|
|
22
|
-
declare const StatsDragInput: ({ label, icon, dragInputCallback, value, elements, editable, shouldKeepAspectRatio, }: StatsDragInputProps) => JSX.Element;
|
|
31
|
+
declare const StatsDragInput: <T extends StatsInputProperty, E extends ExcalidrawElement = ExcalidrawElement>({ label, icon, dragInputCallback, value, elements, editable, shouldKeepAspectRatio, property, scene, appState, }: StatsDragInputProps<T, E>) => JSX.Element | null;
|
|
23
32
|
export default StatsDragInput;
|
|
@@ -1,24 +1,40 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { EVENT } from "../../constants";
|
|
4
4
|
import { KEYS } from "../../keys";
|
|
5
5
|
import { deepCopyElement } from "../../element/newElement";
|
|
6
|
-
import "./DragInput.scss";
|
|
7
6
|
import clsx from "clsx";
|
|
8
7
|
import { useApp } from "../App";
|
|
9
8
|
import { InlineIcon } from "../InlineIcon";
|
|
10
9
|
import { SMALLEST_DELTA } from "./utils";
|
|
11
10
|
import { StoreAction } from "../../store";
|
|
12
|
-
|
|
11
|
+
import "./DragInput.scss";
|
|
12
|
+
import { cloneJSON } from "../../utils";
|
|
13
|
+
const StatsDragInput = ({ label, icon, dragInputCallback, value, elements, editable = true, shouldKeepAspectRatio, property, scene, appState, }) => {
|
|
13
14
|
const app = useApp();
|
|
14
15
|
const inputRef = useRef(null);
|
|
15
16
|
const labelRef = useRef(null);
|
|
16
17
|
const [inputValue, setInputValue] = useState(value.toString());
|
|
18
|
+
const stateRef = useRef(null);
|
|
19
|
+
if (!stateRef.current) {
|
|
20
|
+
stateRef.current = {
|
|
21
|
+
originalAppState: cloneJSON(appState),
|
|
22
|
+
originalElements: elements,
|
|
23
|
+
lastUpdatedValue: inputValue,
|
|
24
|
+
updatePending: false,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
17
27
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
const inputValue = value.toString();
|
|
29
|
+
setInputValue(inputValue);
|
|
30
|
+
stateRef.current.lastUpdatedValue = inputValue;
|
|
31
|
+
}, [value]);
|
|
32
|
+
const handleInputValue = (updatedValue, elements, appState) => {
|
|
33
|
+
if (!stateRef.current.updatePending) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
stateRef.current.updatePending = false;
|
|
37
|
+
const parsed = Number(updatedValue);
|
|
22
38
|
if (isNaN(parsed)) {
|
|
23
39
|
setInputValue(value.toString());
|
|
24
40
|
return;
|
|
@@ -31,6 +47,7 @@ const StatsDragInput = ({ label, icon, dragInputCallback, value, elements, edita
|
|
|
31
47
|
// than the smallest delta allowed, which is 0.01
|
|
32
48
|
// reason: idempotent to avoid unnecessary
|
|
33
49
|
if (isNaN(original) || Math.abs(rounded - original) >= SMALLEST_DELTA) {
|
|
50
|
+
stateRef.current.lastUpdatedValue = updatedValue;
|
|
34
51
|
dragInputCallback({
|
|
35
52
|
accumulatedChange: 0,
|
|
36
53
|
instantChange: 0,
|
|
@@ -38,7 +55,10 @@ const StatsDragInput = ({ label, icon, dragInputCallback, value, elements, edita
|
|
|
38
55
|
originalElementsMap: app.scene.getNonDeletedElementsMap(),
|
|
39
56
|
shouldKeepAspectRatio: shouldKeepAspectRatio,
|
|
40
57
|
shouldChangeByStepSize: false,
|
|
58
|
+
scene,
|
|
41
59
|
nextValue: rounded,
|
|
60
|
+
property,
|
|
61
|
+
originalAppState: appState,
|
|
42
62
|
});
|
|
43
63
|
app.syncActionResult({ storeAction: StoreAction.CAPTURE });
|
|
44
64
|
}
|
|
@@ -52,38 +72,45 @@ const StatsDragInput = ({ label, icon, dragInputCallback, value, elements, edita
|
|
|
52
72
|
return () => {
|
|
53
73
|
const nextValue = input?.value;
|
|
54
74
|
if (nextValue) {
|
|
55
|
-
handleInputValueRef.current(nextValue);
|
|
75
|
+
handleInputValueRef.current(nextValue, stateRef.current.originalElements, stateRef.current.originalAppState);
|
|
56
76
|
}
|
|
57
77
|
};
|
|
58
|
-
}, [
|
|
59
|
-
|
|
78
|
+
}, [
|
|
79
|
+
// we need to track change of `editable` state as mount/unmount
|
|
80
|
+
// because react doesn't trigger `blur` when a an input is blurred due
|
|
81
|
+
// to being disabled (https://github.com/facebook/react/issues/9142).
|
|
82
|
+
// As such, if we keep rendering disabled inputs, then change in selection
|
|
83
|
+
// to an element that has a given property as non-editable would not trigger
|
|
84
|
+
// blur/unmount and wouldn't update the value.
|
|
85
|
+
editable,
|
|
86
|
+
]);
|
|
87
|
+
if (!editable) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return (_jsxs("div", { className: clsx("drag-input-container", !editable && "disabled"), "data-testid": label, children: [_jsx("div", { className: "drag-input-label", ref: labelRef, onPointerDown: (event) => {
|
|
60
91
|
if (inputRef.current && editable) {
|
|
61
92
|
let startValue = Number(inputRef.current.value);
|
|
62
93
|
if (isNaN(startValue)) {
|
|
63
94
|
startValue = 0;
|
|
64
95
|
}
|
|
65
96
|
let lastPointer = null;
|
|
66
|
-
let
|
|
67
|
-
|
|
97
|
+
let originalElementsMap = app.scene
|
|
98
|
+
.getNonDeletedElements()
|
|
99
|
+
.reduce((acc, element) => {
|
|
100
|
+
acc.set(element.id, deepCopyElement(element));
|
|
101
|
+
return acc;
|
|
102
|
+
}, new Map());
|
|
103
|
+
let originalElements = elements.map((element) => originalElementsMap.get(element.id));
|
|
104
|
+
const originalAppState = cloneJSON(appState);
|
|
68
105
|
let accumulatedChange = null;
|
|
69
106
|
document.body.classList.add("excalidraw-cursor-resize");
|
|
70
107
|
const onPointerMove = (event) => {
|
|
71
|
-
if (!originalElementsMap) {
|
|
72
|
-
originalElementsMap = app.scene
|
|
73
|
-
.getNonDeletedElements()
|
|
74
|
-
.reduce((acc, element) => {
|
|
75
|
-
acc.set(element.id, deepCopyElement(element));
|
|
76
|
-
return acc;
|
|
77
|
-
}, new Map());
|
|
78
|
-
}
|
|
79
|
-
if (!originalElements) {
|
|
80
|
-
originalElements = elements.map((element) => originalElementsMap.get(element.id));
|
|
81
|
-
}
|
|
82
108
|
if (!accumulatedChange) {
|
|
83
109
|
accumulatedChange = 0;
|
|
84
110
|
}
|
|
85
111
|
if (lastPointer &&
|
|
86
112
|
originalElementsMap !== null &&
|
|
113
|
+
originalElements !== null &&
|
|
87
114
|
accumulatedChange !== null) {
|
|
88
115
|
const instantChange = event.clientX - lastPointer.x;
|
|
89
116
|
accumulatedChange += instantChange;
|
|
@@ -94,6 +121,9 @@ const StatsDragInput = ({ label, icon, dragInputCallback, value, elements, edita
|
|
|
94
121
|
originalElementsMap,
|
|
95
122
|
shouldKeepAspectRatio: shouldKeepAspectRatio,
|
|
96
123
|
shouldChangeByStepSize: event.shiftKey,
|
|
124
|
+
property,
|
|
125
|
+
scene,
|
|
126
|
+
originalAppState,
|
|
97
127
|
});
|
|
98
128
|
}
|
|
99
129
|
lastPointer = {
|
|
@@ -121,21 +151,24 @@ const StatsDragInput = ({ label, icon, dragInputCallback, value, elements, edita
|
|
|
121
151
|
const eventTarget = event.target;
|
|
122
152
|
if (eventTarget instanceof HTMLInputElement &&
|
|
123
153
|
event.key === KEYS.ENTER) {
|
|
124
|
-
handleInputValue(eventTarget.value);
|
|
154
|
+
handleInputValue(eventTarget.value, elements, appState);
|
|
125
155
|
app.focusContainer();
|
|
126
156
|
}
|
|
127
157
|
}
|
|
128
158
|
}, ref: inputRef, value: inputValue, onChange: (event) => {
|
|
159
|
+
stateRef.current.updatePending = true;
|
|
129
160
|
setInputValue(event.target.value);
|
|
130
161
|
}, onFocus: (event) => {
|
|
131
162
|
event.target.select();
|
|
163
|
+
stateRef.current.originalElements = elements;
|
|
164
|
+
stateRef.current.originalAppState = cloneJSON(appState);
|
|
132
165
|
}, onBlur: (event) => {
|
|
133
166
|
if (!inputValue) {
|
|
134
167
|
setInputValue(value.toString());
|
|
135
168
|
}
|
|
136
169
|
else if (editable) {
|
|
137
|
-
handleInputValue(event.target.value);
|
|
170
|
+
handleInputValue(event.target.value, stateRef.current.originalElements, stateRef.current.originalAppState);
|
|
138
171
|
}
|
|
139
|
-
}, disabled: !editable })] }))
|
|
172
|
+
}, disabled: !editable })] }));
|
|
140
173
|
};
|
|
141
174
|
export default StatsDragInput;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
3
5
|
interface FontSizeProps {
|
|
4
|
-
element:
|
|
5
|
-
|
|
6
|
+
element: ExcalidrawElement;
|
|
7
|
+
scene: Scene;
|
|
8
|
+
appState: AppState;
|
|
9
|
+
property: "fontSize";
|
|
6
10
|
}
|
|
7
|
-
declare const FontSize: ({ element,
|
|
11
|
+
declare const FontSize: ({ element, scene, appState, property }: FontSizeProps) => JSX.Element | null;
|
|
8
12
|
export default FontSize;
|
|
@@ -1,47 +1,50 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { refreshTextDimensions } from "../../element/newElement";
|
|
3
2
|
import StatsDragInput from "./DragInput";
|
|
4
3
|
import { mutateElement } from "../../element/mutateElement";
|
|
5
4
|
import { getStepSizedValue } from "./utils";
|
|
6
5
|
import { fontSizeIcon } from "../icons";
|
|
6
|
+
import { isTextElement, redrawTextBoundingBox } from "../../element";
|
|
7
|
+
import { hasBoundTextElement } from "../../element/typeChecks";
|
|
8
|
+
import { getBoundTextElement } from "../../element/textElement";
|
|
7
9
|
const MIN_FONT_SIZE = 4;
|
|
8
10
|
const STEP_SIZE = 4;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const originalFontSize = Math.round(origElement.fontSize);
|
|
28
|
-
const changeInFontSize = Math.round(accumulatedChange);
|
|
29
|
-
let nextFontSize = Math.max(originalFontSize + changeInFontSize, MIN_FONT_SIZE);
|
|
30
|
-
if (shouldChangeByStepSize) {
|
|
31
|
-
nextFontSize = getStepSizedValue(nextFontSize, STEP_SIZE);
|
|
32
|
-
}
|
|
33
|
-
const newElement = {
|
|
34
|
-
...element,
|
|
35
|
-
fontSize: nextFontSize,
|
|
36
|
-
};
|
|
37
|
-
const updates = refreshTextDimensions(newElement, null, elementsMap);
|
|
38
|
-
mutateElement(element, {
|
|
39
|
-
...updates,
|
|
40
|
-
fontSize: nextFontSize,
|
|
41
|
-
});
|
|
11
|
+
const handleFontSizeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, scene, }) => {
|
|
12
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
13
|
+
const origElement = originalElements[0];
|
|
14
|
+
if (origElement) {
|
|
15
|
+
const latestElement = elementsMap.get(origElement.id);
|
|
16
|
+
if (!latestElement || !isTextElement(latestElement)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let nextFontSize;
|
|
20
|
+
if (nextValue !== undefined) {
|
|
21
|
+
nextFontSize = Math.max(Math.round(nextValue), MIN_FONT_SIZE);
|
|
22
|
+
}
|
|
23
|
+
else if (origElement.type === "text") {
|
|
24
|
+
const originalFontSize = Math.round(origElement.fontSize);
|
|
25
|
+
const changeInFontSize = Math.round(accumulatedChange);
|
|
26
|
+
nextFontSize = Math.max(originalFontSize + changeInFontSize, MIN_FONT_SIZE);
|
|
27
|
+
if (shouldChangeByStepSize) {
|
|
28
|
+
nextFontSize = getStepSizedValue(nextFontSize, STEP_SIZE);
|
|
42
29
|
}
|
|
43
30
|
}
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
if (nextFontSize) {
|
|
32
|
+
mutateElement(latestElement, {
|
|
33
|
+
fontSize: nextFontSize,
|
|
34
|
+
});
|
|
35
|
+
redrawTextBoundingBox(latestElement, scene.getContainerElement(latestElement), scene.getNonDeletedElementsMap());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const FontSize = ({ element, scene, appState, property }) => {
|
|
40
|
+
const _element = isTextElement(element)
|
|
41
|
+
? element
|
|
42
|
+
: hasBoundTextElement(element)
|
|
43
|
+
? getBoundTextElement(element, scene.getNonDeletedElementsMap())
|
|
44
|
+
: null;
|
|
45
|
+
if (!_element) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return (_jsx(StatsDragInput, { label: "F", value: Math.round(_element.fontSize * 10) / 10, elements: [_element], dragInputCallback: handleFontSizeChange, icon: fontSizeIcon, appState: appState, scene: scene, property: property }));
|
|
46
49
|
};
|
|
47
50
|
export default FontSize;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
3
|
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
4
5
|
interface MultiAngleProps {
|
|
5
6
|
elements: readonly ExcalidrawElement[];
|
|
6
|
-
elementsMap: ElementsMap;
|
|
7
7
|
scene: Scene;
|
|
8
|
+
appState: AppState;
|
|
9
|
+
property: "angle";
|
|
8
10
|
}
|
|
9
|
-
declare const MultiAngle: ({ elements,
|
|
11
|
+
declare const MultiAngle: ({ elements, scene, appState, property, }: MultiAngleProps) => JSX.Element;
|
|
10
12
|
export default MultiAngle;
|