@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
|
@@ -8,50 +8,59 @@ import { angleIcon } from "../icons";
|
|
|
8
8
|
import DragInput from "./DragInput";
|
|
9
9
|
import { getStepSizedValue, isPropertyEditable } from "./utils";
|
|
10
10
|
const STEP_SIZE = 15;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (boundTextElement && !isArrowElement(element)) {
|
|
23
|
-
mutateElement(boundTextElement, { angle: nextAngle }, false);
|
|
24
|
-
}
|
|
11
|
+
const handleDegreeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, property, scene, }) => {
|
|
12
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
13
|
+
const editableLatestIndividualElements = originalElements
|
|
14
|
+
.map((el) => elementsMap.get(el.id))
|
|
15
|
+
.filter((el) => el && !isInGroup(el) && isPropertyEditable(el, property));
|
|
16
|
+
const editableOriginalIndividualElements = originalElements.filter((el) => !isInGroup(el) && isPropertyEditable(el, property));
|
|
17
|
+
if (nextValue !== undefined) {
|
|
18
|
+
const nextAngle = degreeToRadian(nextValue);
|
|
19
|
+
for (const element of editableLatestIndividualElements) {
|
|
20
|
+
if (!element) {
|
|
21
|
+
continue;
|
|
25
22
|
}
|
|
26
|
-
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
for (let i = 0; i < editableLatestIndividualElements.length; i++) {
|
|
30
|
-
const latestElement = editableLatestIndividualElements[i];
|
|
31
|
-
const originalElement = editableOriginalIndividualElements[i];
|
|
32
|
-
const originalAngleInDegrees = Math.round(radianToDegree(originalElement.angle) * 100) / 100;
|
|
33
|
-
const changeInDegrees = Math.round(accumulatedChange);
|
|
34
|
-
let nextAngleInDegrees = (originalAngleInDegrees + changeInDegrees) % 360;
|
|
35
|
-
if (shouldChangeByStepSize) {
|
|
36
|
-
nextAngleInDegrees = getStepSizedValue(nextAngleInDegrees, STEP_SIZE);
|
|
37
|
-
}
|
|
38
|
-
nextAngleInDegrees =
|
|
39
|
-
nextAngleInDegrees < 0 ? nextAngleInDegrees + 360 : nextAngleInDegrees;
|
|
40
|
-
const nextAngle = degreeToRadian(nextAngleInDegrees);
|
|
41
|
-
mutateElement(latestElement, {
|
|
23
|
+
mutateElement(element, {
|
|
42
24
|
angle: nextAngle,
|
|
43
25
|
}, false);
|
|
44
|
-
const boundTextElement = getBoundTextElement(
|
|
45
|
-
if (boundTextElement && !isArrowElement(
|
|
26
|
+
const boundTextElement = getBoundTextElement(element, elementsMap);
|
|
27
|
+
if (boundTextElement && !isArrowElement(element)) {
|
|
46
28
|
mutateElement(boundTextElement, { angle: nextAngle }, false);
|
|
47
29
|
}
|
|
48
30
|
}
|
|
49
31
|
scene.triggerUpdate();
|
|
50
|
-
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (let i = 0; i < editableLatestIndividualElements.length; i++) {
|
|
35
|
+
const latestElement = editableLatestIndividualElements[i];
|
|
36
|
+
if (!latestElement) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const originalElement = editableOriginalIndividualElements[i];
|
|
40
|
+
const originalAngleInDegrees = Math.round(radianToDegree(originalElement.angle) * 100) / 100;
|
|
41
|
+
const changeInDegrees = Math.round(accumulatedChange);
|
|
42
|
+
let nextAngleInDegrees = (originalAngleInDegrees + changeInDegrees) % 360;
|
|
43
|
+
if (shouldChangeByStepSize) {
|
|
44
|
+
nextAngleInDegrees = getStepSizedValue(nextAngleInDegrees, STEP_SIZE);
|
|
45
|
+
}
|
|
46
|
+
nextAngleInDegrees =
|
|
47
|
+
nextAngleInDegrees < 0 ? nextAngleInDegrees + 360 : nextAngleInDegrees;
|
|
48
|
+
const nextAngle = degreeToRadian(nextAngleInDegrees);
|
|
49
|
+
mutateElement(latestElement, {
|
|
50
|
+
angle: nextAngle,
|
|
51
|
+
}, false);
|
|
52
|
+
const boundTextElement = getBoundTextElement(latestElement, elementsMap);
|
|
53
|
+
if (boundTextElement && !isArrowElement(latestElement)) {
|
|
54
|
+
mutateElement(boundTextElement, { angle: nextAngle }, false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
scene.triggerUpdate();
|
|
58
|
+
};
|
|
59
|
+
const MultiAngle = ({ elements, scene, appState, property, }) => {
|
|
51
60
|
const editableLatestIndividualElements = elements.filter((el) => !isInGroup(el) && isPropertyEditable(el, "angle"));
|
|
52
61
|
const angles = editableLatestIndividualElements.map((el) => Math.round((radianToDegree(el.angle) % 360) * 100) / 100);
|
|
53
62
|
const value = new Set(angles).size === 1 ? angles[0] : "Mixed";
|
|
54
63
|
const editable = editableLatestIndividualElements.some((el) => isPropertyEditable(el, "angle"));
|
|
55
|
-
return (_jsx(DragInput, { label: "A", icon: angleIcon, value: value, elements: elements, dragInputCallback: handleDegreeChange, editable: editable }));
|
|
64
|
+
return (_jsx(DragInput, { label: "A", icon: angleIcon, value: value, elements: elements, dragInputCallback: handleDegreeChange, editable: editable, appState: appState, scene: scene, property: property }));
|
|
56
65
|
};
|
|
57
66
|
export default MultiAngle;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExcalidrawElement, NonDeletedSceneElementsMap } from "../../element/types";
|
|
3
3
|
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
4
5
|
import type { AtomicUnit } from "./utils";
|
|
5
6
|
interface MultiDimensionProps {
|
|
6
7
|
property: "width" | "height";
|
|
7
8
|
elements: readonly ExcalidrawElement[];
|
|
8
|
-
elementsMap:
|
|
9
|
+
elementsMap: NonDeletedSceneElementsMap;
|
|
9
10
|
atomicUnits: AtomicUnit[];
|
|
10
11
|
scene: Scene;
|
|
12
|
+
appState: AppState;
|
|
11
13
|
}
|
|
12
|
-
declare const MultiDimension: ({ property, elements, elementsMap, atomicUnits, scene, }: MultiDimensionProps) => JSX.Element;
|
|
14
|
+
declare const MultiDimension: ({ property, elements, elementsMap, atomicUnits, scene, appState, }: MultiDimensionProps) => JSX.Element;
|
|
13
15
|
export default MultiDimension;
|
|
@@ -6,7 +6,7 @@ import { mutateElement } from "../../element/mutateElement";
|
|
|
6
6
|
import { rescalePointsInElement } from "../../element/resizeElements";
|
|
7
7
|
import { getBoundTextElement, handleBindTextResize, } from "../../element/textElement";
|
|
8
8
|
import DragInput from "./DragInput";
|
|
9
|
-
import { getStepSizedValue, isPropertyEditable } from "./utils";
|
|
9
|
+
import { getAtomicUnits, getStepSizedValue, isPropertyEditable } from "./utils";
|
|
10
10
|
import { getElementsInAtomicUnit, resizeElement } from "./utils";
|
|
11
11
|
import { MIN_WIDTH_OR_HEIGHT } from "../../constants";
|
|
12
12
|
const STEP_SIZE = 10;
|
|
@@ -28,14 +28,15 @@ const getResizedUpdates = (anchorX, anchorY, scale, origElement) => {
|
|
|
28
28
|
: {}),
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
const resizeElementInGroup = (anchorX, anchorY, property, scale, latestElement, origElement, elementsMap, originalElementsMap) => {
|
|
31
|
+
const resizeElementInGroup = (anchorX, anchorY, property, scale, latestElement, origElement, elementsMap, originalElementsMap, scene) => {
|
|
32
32
|
const updates = getResizedUpdates(anchorX, anchorY, scale, origElement);
|
|
33
|
+
const { width: oldWidth, height: oldHeight } = latestElement;
|
|
33
34
|
mutateElement(latestElement, updates, false);
|
|
34
35
|
const boundTextElement = getBoundTextElement(origElement, originalElementsMap);
|
|
35
36
|
if (boundTextElement) {
|
|
36
37
|
const newFontSize = boundTextElement.fontSize * scale;
|
|
37
|
-
updateBoundElements(latestElement, elementsMap, {
|
|
38
|
-
|
|
38
|
+
updateBoundElements(latestElement, elementsMap, scene, {
|
|
39
|
+
oldSize: { width: oldWidth, height: oldHeight },
|
|
39
40
|
});
|
|
40
41
|
const latestBoundTextElement = elementsMap.get(boundTextElement.id);
|
|
41
42
|
if (latestBoundTextElement && isTextElement(latestBoundTextElement)) {
|
|
@@ -46,7 +47,7 @@ const resizeElementInGroup = (anchorX, anchorY, property, scale, latestElement,
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
|
-
const resizeGroup = (nextWidth, nextHeight, initialHeight, aspectRatio, anchor, property, latestElements, originalElements, elementsMap, originalElementsMap) => {
|
|
50
|
+
const resizeGroup = (nextWidth, nextHeight, initialHeight, aspectRatio, anchor, property, latestElements, originalElements, elementsMap, originalElementsMap, scene) => {
|
|
50
51
|
// keep aspect ratio for groups
|
|
51
52
|
if (property === "width") {
|
|
52
53
|
nextHeight = Math.round((nextWidth / aspectRatio) * 100) / 100;
|
|
@@ -58,76 +59,14 @@ const resizeGroup = (nextWidth, nextHeight, initialHeight, aspectRatio, anchor,
|
|
|
58
59
|
for (let i = 0; i < originalElements.length; i++) {
|
|
59
60
|
const origElement = originalElements[i];
|
|
60
61
|
const latestElement = latestElements[i];
|
|
61
|
-
resizeElementInGroup(anchor[0], anchor[1], property, scale, latestElement, origElement, elementsMap, originalElementsMap);
|
|
62
|
+
resizeElementInGroup(anchor[0], anchor[1], property, scale, latestElement, origElement, elementsMap, originalElementsMap, scene);
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return (Math.round((property === "width" ? x2 - x1 : y2 - y1) * 100) / 100);
|
|
70
|
-
}
|
|
71
|
-
const [el] = elementsInUnit;
|
|
72
|
-
return (Math.round((property === "width" ? el.latest.width : el.latest.height) * 100) / 100);
|
|
73
|
-
}), [elementsMap, atomicUnits, property]);
|
|
74
|
-
const value = new Set(sizes).size === 1 ? Math.round(sizes[0] * 100) / 100 : "Mixed";
|
|
75
|
-
const editable = sizes.length > 0;
|
|
76
|
-
const handleDimensionChange = ({ accumulatedChange, originalElementsMap, shouldChangeByStepSize, nextValue, }) => {
|
|
77
|
-
if (nextValue !== undefined) {
|
|
78
|
-
for (const atomicUnit of atomicUnits) {
|
|
79
|
-
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap, originalElementsMap);
|
|
80
|
-
if (elementsInUnit.length > 1) {
|
|
81
|
-
const latestElements = elementsInUnit.map((el) => el.latest);
|
|
82
|
-
const originalElements = elementsInUnit.map((el) => el.original);
|
|
83
|
-
const [x1, y1, x2, y2] = getCommonBounds(originalElements);
|
|
84
|
-
const initialWidth = x2 - x1;
|
|
85
|
-
const initialHeight = y2 - y1;
|
|
86
|
-
const aspectRatio = initialWidth / initialHeight;
|
|
87
|
-
const nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, property === "width" ? Math.max(0, nextValue) : initialWidth);
|
|
88
|
-
const nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, property === "height" ? Math.max(0, nextValue) : initialHeight);
|
|
89
|
-
resizeGroup(nextWidth, nextHeight, initialHeight, aspectRatio, [x1, y1], property, latestElements, originalElements, elementsMap, originalElementsMap);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
const [el] = elementsInUnit;
|
|
93
|
-
const latestElement = el?.latest;
|
|
94
|
-
const origElement = el?.original;
|
|
95
|
-
if (latestElement &&
|
|
96
|
-
origElement &&
|
|
97
|
-
isPropertyEditable(latestElement, property)) {
|
|
98
|
-
let nextWidth = property === "width"
|
|
99
|
-
? Math.max(0, nextValue)
|
|
100
|
-
: latestElement.width;
|
|
101
|
-
if (property === "width") {
|
|
102
|
-
if (shouldChangeByStepSize) {
|
|
103
|
-
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
nextWidth = Math.round(nextWidth);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
let nextHeight = property === "height"
|
|
110
|
-
? Math.max(0, nextValue)
|
|
111
|
-
: latestElement.height;
|
|
112
|
-
if (property === "height") {
|
|
113
|
-
if (shouldChangeByStepSize) {
|
|
114
|
-
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
nextHeight = Math.round(nextHeight);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
121
|
-
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
122
|
-
resizeElement(nextWidth, nextHeight, false, latestElement, origElement, elementsMap, originalElementsMap, false);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
scene.triggerUpdate();
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const changeInWidth = property === "width" ? accumulatedChange : 0;
|
|
130
|
-
const changeInHeight = property === "height" ? accumulatedChange : 0;
|
|
65
|
+
const handleDimensionChange = ({ accumulatedChange, originalElements, originalElementsMap, originalAppState, shouldChangeByStepSize, nextValue, scene, property, }) => {
|
|
66
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
67
|
+
const elements = scene.getNonDeletedElements();
|
|
68
|
+
const atomicUnits = getAtomicUnits(originalElements, originalAppState);
|
|
69
|
+
if (nextValue !== undefined) {
|
|
131
70
|
for (const atomicUnit of atomicUnits) {
|
|
132
71
|
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap, originalElementsMap);
|
|
133
72
|
if (elementsInUnit.length > 1) {
|
|
@@ -137,27 +76,9 @@ const MultiDimension = ({ property, elements, elementsMap, atomicUnits, scene, }
|
|
|
137
76
|
const initialWidth = x2 - x1;
|
|
138
77
|
const initialHeight = y2 - y1;
|
|
139
78
|
const aspectRatio = initialWidth / initialHeight;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
nextWidth = Math.round(nextWidth);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
let nextHeight = Math.max(0, initialHeight + changeInHeight);
|
|
150
|
-
if (property === "height") {
|
|
151
|
-
if (shouldChangeByStepSize) {
|
|
152
|
-
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
nextHeight = Math.round(nextHeight);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
159
|
-
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
160
|
-
resizeGroup(nextWidth, nextHeight, initialHeight, aspectRatio, [x1, y1], property, latestElements, originalElements, elementsMap, originalElementsMap);
|
|
79
|
+
const nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, property === "width" ? Math.max(0, nextValue) : initialWidth);
|
|
80
|
+
const nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, property === "height" ? Math.max(0, nextValue) : initialHeight);
|
|
81
|
+
resizeGroup(nextWidth, nextHeight, initialHeight, aspectRatio, [x1, y1], property, latestElements, originalElements, elementsMap, originalElementsMap, scene);
|
|
161
82
|
}
|
|
162
83
|
else {
|
|
163
84
|
const [el] = elementsInUnit;
|
|
@@ -166,7 +87,7 @@ const MultiDimension = ({ property, elements, elementsMap, atomicUnits, scene, }
|
|
|
166
87
|
if (latestElement &&
|
|
167
88
|
origElement &&
|
|
168
89
|
isPropertyEditable(latestElement, property)) {
|
|
169
|
-
let nextWidth = Math.max(0,
|
|
90
|
+
let nextWidth = property === "width" ? Math.max(0, nextValue) : latestElement.width;
|
|
170
91
|
if (property === "width") {
|
|
171
92
|
if (shouldChangeByStepSize) {
|
|
172
93
|
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
@@ -175,7 +96,9 @@ const MultiDimension = ({ property, elements, elementsMap, atomicUnits, scene, }
|
|
|
175
96
|
nextWidth = Math.round(nextWidth);
|
|
176
97
|
}
|
|
177
98
|
}
|
|
178
|
-
let nextHeight =
|
|
99
|
+
let nextHeight = property === "height"
|
|
100
|
+
? Math.max(0, nextValue)
|
|
101
|
+
: latestElement.height;
|
|
179
102
|
if (property === "height") {
|
|
180
103
|
if (shouldChangeByStepSize) {
|
|
181
104
|
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
@@ -186,12 +109,91 @@ const MultiDimension = ({ property, elements, elementsMap, atomicUnits, scene, }
|
|
|
186
109
|
}
|
|
187
110
|
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
188
111
|
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
189
|
-
resizeElement(nextWidth, nextHeight, false,
|
|
112
|
+
resizeElement(nextWidth, nextHeight, false, origElement, elementsMap, elements, scene, false);
|
|
190
113
|
}
|
|
191
114
|
}
|
|
192
115
|
}
|
|
193
116
|
scene.triggerUpdate();
|
|
194
|
-
|
|
195
|
-
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const changeInWidth = property === "width" ? accumulatedChange : 0;
|
|
120
|
+
const changeInHeight = property === "height" ? accumulatedChange : 0;
|
|
121
|
+
for (const atomicUnit of atomicUnits) {
|
|
122
|
+
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap, originalElementsMap);
|
|
123
|
+
if (elementsInUnit.length > 1) {
|
|
124
|
+
const latestElements = elementsInUnit.map((el) => el.latest);
|
|
125
|
+
const originalElements = elementsInUnit.map((el) => el.original);
|
|
126
|
+
const [x1, y1, x2, y2] = getCommonBounds(originalElements);
|
|
127
|
+
const initialWidth = x2 - x1;
|
|
128
|
+
const initialHeight = y2 - y1;
|
|
129
|
+
const aspectRatio = initialWidth / initialHeight;
|
|
130
|
+
let nextWidth = Math.max(0, initialWidth + changeInWidth);
|
|
131
|
+
if (property === "width") {
|
|
132
|
+
if (shouldChangeByStepSize) {
|
|
133
|
+
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
nextWidth = Math.round(nextWidth);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
let nextHeight = Math.max(0, initialHeight + changeInHeight);
|
|
140
|
+
if (property === "height") {
|
|
141
|
+
if (shouldChangeByStepSize) {
|
|
142
|
+
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
nextHeight = Math.round(nextHeight);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
149
|
+
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
150
|
+
resizeGroup(nextWidth, nextHeight, initialHeight, aspectRatio, [x1, y1], property, latestElements, originalElements, elementsMap, originalElementsMap, scene);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const [el] = elementsInUnit;
|
|
154
|
+
const latestElement = el?.latest;
|
|
155
|
+
const origElement = el?.original;
|
|
156
|
+
if (latestElement &&
|
|
157
|
+
origElement &&
|
|
158
|
+
isPropertyEditable(latestElement, property)) {
|
|
159
|
+
let nextWidth = Math.max(0, origElement.width + changeInWidth);
|
|
160
|
+
if (property === "width") {
|
|
161
|
+
if (shouldChangeByStepSize) {
|
|
162
|
+
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
nextWidth = Math.round(nextWidth);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
let nextHeight = Math.max(0, origElement.height + changeInHeight);
|
|
169
|
+
if (property === "height") {
|
|
170
|
+
if (shouldChangeByStepSize) {
|
|
171
|
+
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
nextHeight = Math.round(nextHeight);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
178
|
+
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
179
|
+
resizeElement(nextWidth, nextHeight, false, origElement, elementsMap, elements, scene);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
scene.triggerUpdate();
|
|
184
|
+
};
|
|
185
|
+
const MultiDimension = ({ property, elements, elementsMap, atomicUnits, scene, appState, }) => {
|
|
186
|
+
const sizes = useMemo(() => atomicUnits.map((atomicUnit) => {
|
|
187
|
+
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap);
|
|
188
|
+
if (elementsInUnit.length > 1) {
|
|
189
|
+
const [x1, y1, x2, y2] = getCommonBounds(elementsInUnit.map((el) => el.latest));
|
|
190
|
+
return (Math.round((property === "width" ? x2 - x1 : y2 - y1) * 100) / 100);
|
|
191
|
+
}
|
|
192
|
+
const [el] = elementsInUnit;
|
|
193
|
+
return (Math.round((property === "width" ? el.latest.width : el.latest.height) * 100) / 100);
|
|
194
|
+
}), [elementsMap, atomicUnits, property]);
|
|
195
|
+
const value = new Set(sizes).size === 1 ? Math.round(sizes[0] * 100) / 100 : "Mixed";
|
|
196
|
+
const editable = sizes.length > 0;
|
|
197
|
+
return (_jsx(DragInput, { label: property === "width" ? "W" : "H", elements: elements, dragInputCallback: handleDimensionChange, value: value, editable: editable, appState: appState, property: property, scene: scene }));
|
|
196
198
|
};
|
|
197
199
|
export default MultiDimension;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExcalidrawElement, NonDeletedSceneElementsMap } from "../../element/types";
|
|
3
3
|
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
4
5
|
interface MultiFontSizeProps {
|
|
5
6
|
elements: readonly ExcalidrawElement[];
|
|
6
|
-
elementsMap: ElementsMap;
|
|
7
7
|
scene: Scene;
|
|
8
|
+
elementsMap: NonDeletedSceneElementsMap;
|
|
9
|
+
appState: AppState;
|
|
10
|
+
property: "fontSize";
|
|
8
11
|
}
|
|
9
|
-
declare const MultiFontSize: ({ elements,
|
|
12
|
+
declare const MultiFontSize: ({ elements, scene, appState, property, elementsMap, }: MultiFontSizeProps) => JSX.Element | null;
|
|
10
13
|
export default MultiFontSize;
|
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isTextElement,
|
|
2
|
+
import { isTextElement, redrawTextBoundingBox } from "../../element";
|
|
3
3
|
import { mutateElement } from "../../element/mutateElement";
|
|
4
|
-
import {
|
|
4
|
+
import { hasBoundTextElement } from "../../element/typeChecks";
|
|
5
5
|
import { isInGroup } from "../../groups";
|
|
6
6
|
import { fontSizeIcon } from "../icons";
|
|
7
7
|
import StatsDragInput from "./DragInput";
|
|
8
8
|
import { getStepSizedValue } from "./utils";
|
|
9
|
+
import { getBoundTextElement } from "../../element/textElement";
|
|
9
10
|
const MIN_FONT_SIZE = 4;
|
|
10
11
|
const STEP_SIZE = 4;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
const getApplicableTextElements = (elements, elementsMap) => elements.reduce((acc, el) => {
|
|
13
|
+
if (!el || isInGroup(el)) {
|
|
14
|
+
return acc;
|
|
15
|
+
}
|
|
16
|
+
if (isTextElement(el)) {
|
|
17
|
+
acc.push(el);
|
|
18
|
+
return acc;
|
|
19
|
+
}
|
|
20
|
+
if (hasBoundTextElement(el)) {
|
|
21
|
+
const boundTextElement = getBoundTextElement(el, elementsMap);
|
|
22
|
+
if (boundTextElement) {
|
|
23
|
+
acc.push(boundTextElement);
|
|
24
|
+
return acc;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return acc;
|
|
28
|
+
}, []);
|
|
29
|
+
const handleFontSizeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, scene, }) => {
|
|
30
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
31
|
+
const latestTextElements = originalElements.map((el) => elementsMap.get(el.id));
|
|
32
|
+
let nextFontSize;
|
|
33
|
+
if (nextValue) {
|
|
34
|
+
nextFontSize = Math.max(Math.round(nextValue), MIN_FONT_SIZE);
|
|
35
|
+
for (const textElement of latestTextElements) {
|
|
36
|
+
mutateElement(textElement, {
|
|
37
|
+
fontSize: nextFontSize,
|
|
38
|
+
}, false);
|
|
39
|
+
redrawTextBoundingBox(textElement, scene.getContainerElement(textElement), elementsMap, false);
|
|
32
40
|
}
|
|
33
|
-
|
|
41
|
+
scene.triggerUpdate();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const originalTextElements = originalElements;
|
|
34
45
|
for (let i = 0; i < latestTextElements.length; i++) {
|
|
35
46
|
const latestElement = latestTextElements[i];
|
|
36
47
|
const originalElement = originalTextElements[i];
|
|
@@ -40,18 +51,22 @@ const MultiFontSize = ({ elements, elementsMap, scene, }) => {
|
|
|
40
51
|
if (shouldChangeByStepSize) {
|
|
41
52
|
nextFontSize = getStepSizedValue(nextFontSize, STEP_SIZE);
|
|
42
53
|
}
|
|
43
|
-
const newElement = {
|
|
44
|
-
...latestElement,
|
|
45
|
-
fontSize: nextFontSize,
|
|
46
|
-
};
|
|
47
|
-
const updates = refreshTextDimensions(newElement, null, elementsMap);
|
|
48
54
|
mutateElement(latestElement, {
|
|
49
|
-
...updates,
|
|
50
55
|
fontSize: nextFontSize,
|
|
51
56
|
}, false);
|
|
57
|
+
redrawTextBoundingBox(latestElement, scene.getContainerElement(latestElement), elementsMap, false);
|
|
52
58
|
}
|
|
53
59
|
scene.triggerUpdate();
|
|
54
|
-
}
|
|
55
|
-
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const MultiFontSize = ({ elements, scene, appState, property, elementsMap, }) => {
|
|
63
|
+
const latestTextElements = getApplicableTextElements(elements, elementsMap);
|
|
64
|
+
if (!latestTextElements.length) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const fontSizes = latestTextElements.map((textEl) => Math.round(textEl.fontSize * 10) / 10);
|
|
68
|
+
const value = new Set(fontSizes).size === 1 ? fontSizes[0] : "Mixed";
|
|
69
|
+
const editable = fontSizes.length > 0;
|
|
70
|
+
return (_jsx(StatsDragInput, { label: "F", icon: fontSizeIcon, elements: latestTextElements, dragInputCallback: handleFontSizeChange, value: value, editable: editable, scene: scene, property: property, appState: appState }));
|
|
56
71
|
};
|
|
57
72
|
export default MultiFontSize;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import type { ElementsMap, ExcalidrawElement } from "../../element/types";
|
|
3
3
|
import type Scene from "../../scene/Scene";
|
|
4
4
|
import type { AtomicUnit } from "./utils";
|
|
5
|
+
import type { AppState } from "../../types";
|
|
5
6
|
interface MultiPositionProps {
|
|
6
7
|
property: "x" | "y";
|
|
7
8
|
elements: readonly ExcalidrawElement[];
|
|
8
9
|
elementsMap: ElementsMap;
|
|
9
10
|
atomicUnits: AtomicUnit[];
|
|
10
11
|
scene: Scene;
|
|
12
|
+
appState: AppState;
|
|
11
13
|
}
|
|
12
|
-
declare const MultiPosition: ({ property, elements, elementsMap, atomicUnits, scene, }: MultiPositionProps) => JSX.Element;
|
|
14
|
+
declare const MultiPosition: ({ property, elements, elementsMap, atomicUnits, scene, appState, }: MultiPositionProps) => JSX.Element;
|
|
13
15
|
export default MultiPosition;
|