@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,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./ButtonIcon.scss";
|
|
3
|
+
interface ButtonIconProps {
|
|
4
|
+
icon: JSX.Element;
|
|
5
|
+
title: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
testId?: string;
|
|
8
|
+
/** if not supplied, defaults to value identity check */
|
|
9
|
+
active?: boolean;
|
|
10
|
+
/** include standalone style (could interfere with parent styles) */
|
|
11
|
+
standalone?: boolean;
|
|
12
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ButtonIcon: import("react").ForwardRefExoticComponent<ButtonIconProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import "./ButtonIcon.scss";
|
|
5
|
+
export const ButtonIcon = forwardRef((props, ref) => {
|
|
6
|
+
const { title, className, testId, active, standalone, icon, onClick } = props;
|
|
7
|
+
return (_jsx("button", { type: "button", ref: ref, title: title, "data-testid": testId, className: clsx(className, { standalone, active }), onClick: onClick, children: icon }, title));
|
|
8
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
+
import { ButtonIcon } from "./ButtonIcon";
|
|
3
4
|
// TODO: It might be "clever" to add option.icon to the existing component <ButtonSelect />
|
|
4
|
-
export const ButtonIconSelect = (props) => (_jsx("div", { className: "buttonList
|
|
5
|
-
active: option.active ?? props.value === option.value,
|
|
6
|
-
}), "data-testid": option.testId, title: option.text, children: option.icon }, option.text)) : (_jsxs("label", { className: clsx({ active: props.value === option.value }), title: option.text, children: [_jsx("input", { type: "radio", name: props.group, onChange: () => props.onChange(option.value), checked: props.value === option.value, "data-testid": option.testId }), option.icon] }, option.text))) }));
|
|
5
|
+
export const ButtonIconSelect = (props) => (_jsx("div", { className: "buttonList", children: props.options.map((option) => props.type === "button" ? (_jsx(ButtonIcon, { icon: option.icon, title: option.text, testId: option.testId, active: option.active ?? props.value === option.value, onClick: (event) => props.onClick(option.value, event) }, option.text)) : (_jsxs("label", { className: clsx({ active: props.value === option.value }), title: option.text, children: [_jsx("input", { type: "radio", name: props.group, onChange: () => props.onChange(option.value), checked: props.value === option.value, "data-testid": option.testId }), option.icon] }, option.text))) }));
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { isTransparent } from "../../utils";
|
|
3
3
|
import { TopPicks } from "./TopPicks";
|
|
4
|
+
import { ButtonSeparator } from "../ButtonSeparator";
|
|
4
5
|
import { Picker } from "./Picker";
|
|
5
6
|
import * as Popover from "@radix-ui/react-popover";
|
|
6
7
|
import { useAtom } from "jotai";
|
|
7
8
|
import { activeColorPickerSectionAtom } from "./colorPickerUtils";
|
|
8
|
-
import {
|
|
9
|
+
import { useExcalidrawContainer } from "../App";
|
|
9
10
|
import { COLOR_PALETTE } from "../../colors";
|
|
10
11
|
import PickerHeading from "./PickerHeading";
|
|
11
12
|
import { t } from "../../i18n";
|
|
12
13
|
import clsx from "clsx";
|
|
14
|
+
import { useRef } from "react";
|
|
13
15
|
import { jotaiScope } from "../../jotai";
|
|
14
16
|
import { ColorInput } from "./ColorInput";
|
|
15
|
-
import { useRef } from "react";
|
|
16
17
|
import { activeEyeDropperAtom } from "../EyeDropper";
|
|
18
|
+
import { PropertiesPopover } from "../PropertiesPopover";
|
|
17
19
|
import "./ColorPicker.scss";
|
|
18
20
|
const isValidColor = (color) => {
|
|
19
21
|
const style = new Option().style;
|
|
@@ -34,10 +36,9 @@ export const getColor = (color) => {
|
|
|
34
36
|
: null;
|
|
35
37
|
};
|
|
36
38
|
const ColorPickerPopupContent = ({ type, color, onChange, label, elements, palette = COLOR_PALETTE, updateData, }) => {
|
|
39
|
+
const { container } = useExcalidrawContainer();
|
|
37
40
|
const [, setActiveColorPickerSection] = useAtom(activeColorPickerSectionAtom);
|
|
38
41
|
const [eyeDropperState, setEyeDropperState] = useAtom(activeEyeDropperAtom, jotaiScope);
|
|
39
|
-
const { container } = useExcalidrawContainer();
|
|
40
|
-
const device = useDevice();
|
|
41
42
|
const colorInputJSX = (_jsxs("div", { children: [_jsx(PickerHeading, { children: t("colorPicker.hexCode") }), _jsx(ColorInput, { color: color, label: label, onChange: (color) => {
|
|
42
43
|
onChange(color);
|
|
43
44
|
}, colorPickerType: type })] }));
|
|
@@ -47,92 +48,59 @@ const ColorPickerPopupContent = ({ type, color, onChange, label, elements, palet
|
|
|
47
48
|
?.querySelector(".color-picker-content")
|
|
48
49
|
?.focus();
|
|
49
50
|
};
|
|
50
|
-
return (_jsx(
|
|
51
|
-
|
|
51
|
+
return (_jsx(PropertiesPopover, { container: container, style: { maxWidth: "208px" }, onFocusOutside: (event) => {
|
|
52
|
+
// refocus due to eye dropper
|
|
53
|
+
focusPickerContent();
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
}, onPointerDownOutside: (event) => {
|
|
56
|
+
if (eyeDropperState) {
|
|
57
|
+
// prevent from closing if we click outside the popover
|
|
58
|
+
// while eyedropping (e.g. click when clicking the sidebar;
|
|
59
|
+
// the eye-dropper-backdrop is prevented downstream)
|
|
52
60
|
event.preventDefault();
|
|
53
|
-
}
|
|
61
|
+
}
|
|
62
|
+
}, onClose: () => {
|
|
63
|
+
updateData({ openPopup: null });
|
|
64
|
+
setActiveColorPickerSection(null);
|
|
65
|
+
}, children: palette ? (_jsx(Picker, { palette: palette, color: color, onChange: (changedColor) => {
|
|
66
|
+
onChange(changedColor);
|
|
67
|
+
}, onEyeDropperToggle: (force) => {
|
|
68
|
+
setEyeDropperState((state) => {
|
|
69
|
+
if (force) {
|
|
70
|
+
state = state || {
|
|
71
|
+
keepOpenOnAlt: true,
|
|
72
|
+
onSelect: onChange,
|
|
73
|
+
colorPickerType: type,
|
|
74
|
+
};
|
|
75
|
+
state.keepOpenOnAlt = true;
|
|
76
|
+
return state;
|
|
77
|
+
}
|
|
78
|
+
return force === false || state
|
|
79
|
+
? null
|
|
80
|
+
: {
|
|
81
|
+
keepOpenOnAlt: false,
|
|
82
|
+
onSelect: onChange,
|
|
83
|
+
colorPickerType: type,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}, onEscape: (event) => {
|
|
54
87
|
if (eyeDropperState) {
|
|
55
|
-
|
|
56
|
-
// while eyedropping (e.g. click when clicking the sidebar;
|
|
57
|
-
// the eye-dropper-backdrop is prevented downstream)
|
|
58
|
-
event.preventDefault();
|
|
88
|
+
setEyeDropperState(null);
|
|
59
89
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// prevents focusing the trigger
|
|
63
|
-
e.preventDefault();
|
|
64
|
-
// return focus to excalidraw container unless
|
|
65
|
-
// user focuses an interactive element, such as a button, or
|
|
66
|
-
// enters the text editor by clicking on canvas with the text tool
|
|
67
|
-
if (container && !isInteractive(document.activeElement)) {
|
|
68
|
-
container.focus();
|
|
90
|
+
else {
|
|
91
|
+
updateData({ openPopup: null });
|
|
69
92
|
}
|
|
70
|
-
|
|
71
|
-
setActiveColorPickerSection(null);
|
|
72
|
-
}, side: device.editor.isMobile && !device.viewport.isLandscape
|
|
73
|
-
? "bottom"
|
|
74
|
-
: "right", align: device.editor.isMobile && !device.viewport.isLandscape
|
|
75
|
-
? "center"
|
|
76
|
-
: "start", alignOffset: -16, sideOffset: 20, style: {
|
|
77
|
-
zIndex: "var(--zIndex-layerUI)",
|
|
78
|
-
backgroundColor: "var(--popup-bg-color)",
|
|
79
|
-
maxWidth: "208px",
|
|
80
|
-
maxHeight: window.innerHeight,
|
|
81
|
-
padding: "12px",
|
|
82
|
-
borderRadius: "8px",
|
|
83
|
-
boxSizing: "border-box",
|
|
84
|
-
overflowY: "auto",
|
|
85
|
-
boxShadow: "0px 7px 14px rgba(0, 0, 0, 0.05), 0px 0px 3.12708px rgba(0, 0, 0, 0.0798), 0px 0px 0.931014px rgba(0, 0, 0, 0.1702)",
|
|
86
|
-
}, children: [palette ? (_jsx(Picker, { palette: palette, color: color, onChange: (changedColor) => {
|
|
87
|
-
onChange(changedColor);
|
|
88
|
-
}, onEyeDropperToggle: (force) => {
|
|
89
|
-
setEyeDropperState((state) => {
|
|
90
|
-
if (force) {
|
|
91
|
-
state = state || {
|
|
92
|
-
keepOpenOnAlt: true,
|
|
93
|
-
onSelect: onChange,
|
|
94
|
-
colorPickerType: type,
|
|
95
|
-
};
|
|
96
|
-
state.keepOpenOnAlt = true;
|
|
97
|
-
return state;
|
|
98
|
-
}
|
|
99
|
-
return force === false || state
|
|
100
|
-
? null
|
|
101
|
-
: {
|
|
102
|
-
keepOpenOnAlt: false,
|
|
103
|
-
onSelect: onChange,
|
|
104
|
-
colorPickerType: type,
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
}, onEscape: (event) => {
|
|
108
|
-
if (eyeDropperState) {
|
|
109
|
-
setEyeDropperState(null);
|
|
110
|
-
}
|
|
111
|
-
else if (isWritableElement(event.target)) {
|
|
112
|
-
focusPickerContent();
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
updateData({ openPopup: null });
|
|
116
|
-
}
|
|
117
|
-
}, label: label, type: type, elements: elements, updateData: updateData, children: colorInputJSX })) : (colorInputJSX), _jsx(Popover.Arrow, { width: 20, height: 10, style: {
|
|
118
|
-
fill: "var(--popup-bg-color)",
|
|
119
|
-
filter: "drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)",
|
|
120
|
-
} })] }) }));
|
|
93
|
+
}, label: label, type: type, elements: elements, updateData: updateData, children: colorInputJSX })) : (colorInputJSX) }));
|
|
121
94
|
};
|
|
122
95
|
const ColorPickerTrigger = ({ label, color, type, }) => {
|
|
123
|
-
return (_jsx(Popover.Trigger, { type: "button", className: clsx("color-picker__button active-color", {
|
|
96
|
+
return (_jsx(Popover.Trigger, { type: "button", className: clsx("color-picker__button active-color properties-trigger", {
|
|
124
97
|
"is-transparent": color === "transparent" || !color,
|
|
125
98
|
}), "aria-label": label, style: color ? { "--swatch-color": color } : undefined, title: type === "elementStroke"
|
|
126
99
|
? t("labels.showStroke")
|
|
127
100
|
: t("labels.showBackground"), children: _jsx("div", { className: "color-picker__button-outline" }) }));
|
|
128
101
|
};
|
|
129
102
|
export const ColorPicker = ({ type, color, onChange, label, elements, palette = COLOR_PALETTE, topPicks, updateData, appState, }) => {
|
|
130
|
-
return (_jsx("div", { children: _jsxs("div", { role: "dialog", "aria-modal": "true", className: "color-picker-container", children: [_jsx(TopPicks, { activeColor: color, onChange: onChange, type: type, topPicks: topPicks }), _jsx(
|
|
131
|
-
width: 1,
|
|
132
|
-
height: "100%",
|
|
133
|
-
backgroundColor: "var(--default-border-color)",
|
|
134
|
-
margin: "0 auto",
|
|
135
|
-
} }), _jsxs(Popover.Root, { open: appState.openPopup === type, onOpenChange: (open) => {
|
|
103
|
+
return (_jsx("div", { children: _jsxs("div", { role: "dialog", "aria-modal": "true", className: "color-picker-container", children: [_jsx(TopPicks, { activeColor: color, onChange: onChange, type: type, topPicks: topPicks }), _jsx(ButtonSeparator, {}), _jsxs(Popover.Root, { open: appState.openPopup === type, onOpenChange: (open) => {
|
|
136
104
|
updateData({ openPopup: open ? type : null });
|
|
137
105
|
}, children: [_jsx(ColorPickerTrigger, { color: color, label: label, type: type }), appState.openPopup === type && (_jsx(ColorPickerPopupContent, { type: type, color: color, onChange: onChange, label: label, elements: elements, palette: palette, updateData: updateData }))] })] }) }));
|
|
138
106
|
};
|
|
@@ -80,7 +80,7 @@ export const Picker = ({ color, onChange, label, type, elements, palette, update
|
|
|
80
80
|
event.preventDefault();
|
|
81
81
|
event.stopPropagation();
|
|
82
82
|
}
|
|
83
|
-
}, className: "color-picker-content",
|
|
83
|
+
}, className: "color-picker-content properties-content",
|
|
84
84
|
// to allow focusing by clicking but not by tabbing
|
|
85
85
|
tabIndex: -1, children: [!!customColors.length && (_jsxs("div", { children: [_jsx(PickerHeading, { children: t("colorPicker.mostUsedCustomColors") }), _jsx(CustomColorList, { colors: customColors, color: color, label: t("colorPicker.mostUsedCustomColors"), onChange: onChange })] })), _jsxs("div", { children: [_jsx(PickerHeading, { children: t("colorPicker.colors") }), _jsx(PickerColorList, { color: color, label: label, palette: palette, onChange: onChange, activeShade: activeShade })] }), _jsxs("div", { children: [_jsx(PickerHeading, { children: t("colorPicker.shades") }), _jsx(ShadeList, { hex: color, onChange: onChange, palette: palette })] }), children] }) }));
|
|
86
86
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { FontFamilyValues } from "../../element/types";
|
|
3
|
+
import "./FontPicker.scss";
|
|
4
|
+
export declare const DEFAULT_FONTS: {
|
|
5
|
+
value: number;
|
|
6
|
+
icon: JSX.Element;
|
|
7
|
+
text: string;
|
|
8
|
+
testId: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const isDefaultFont: (fontFamily: number | null) => boolean;
|
|
11
|
+
interface FontPickerProps {
|
|
12
|
+
isOpened: boolean;
|
|
13
|
+
selectedFontFamily: FontFamilyValues | null;
|
|
14
|
+
hoveredFontFamily: FontFamilyValues | null;
|
|
15
|
+
onSelect: (fontFamily: FontFamilyValues) => void;
|
|
16
|
+
onHover: (fontFamily: FontFamilyValues) => void;
|
|
17
|
+
onLeave: () => void;
|
|
18
|
+
onPopupChange: (open: boolean) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare const FontPicker: React.MemoExoticComponent<({ isOpened, selectedFontFamily, hoveredFontFamily, onSelect, onHover, onLeave, onPopupChange, }: FontPickerProps) => JSX.Element>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback, useMemo } from "react";
|
|
3
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
4
|
+
import { FontPickerList } from "./FontPickerList";
|
|
5
|
+
import { FontPickerTrigger } from "./FontPickerTrigger";
|
|
6
|
+
import { ButtonIconSelect } from "../ButtonIconSelect";
|
|
7
|
+
import { FontFamilyCodeIcon, FontFamilyNormalIcon, FreedrawIcon, } from "../icons";
|
|
8
|
+
import { ButtonSeparator } from "../ButtonSeparator";
|
|
9
|
+
import { FONT_FAMILY } from "../../constants";
|
|
10
|
+
import { t } from "../../i18n";
|
|
11
|
+
import "./FontPicker.scss";
|
|
12
|
+
export const DEFAULT_FONTS = [
|
|
13
|
+
{
|
|
14
|
+
value: FONT_FAMILY.Excalifont,
|
|
15
|
+
icon: FreedrawIcon,
|
|
16
|
+
text: t("labels.handDrawn"),
|
|
17
|
+
testId: "font-family-handrawn",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: FONT_FAMILY.Nunito,
|
|
21
|
+
icon: FontFamilyNormalIcon,
|
|
22
|
+
text: t("labels.normal"),
|
|
23
|
+
testId: "font-family-normal",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
value: FONT_FAMILY["Comic Shanns"],
|
|
27
|
+
icon: FontFamilyCodeIcon,
|
|
28
|
+
text: t("labels.code"),
|
|
29
|
+
testId: "font-family-code",
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
const defaultFontFamilies = new Set(DEFAULT_FONTS.map((x) => x.value));
|
|
33
|
+
export const isDefaultFont = (fontFamily) => {
|
|
34
|
+
if (!fontFamily) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return defaultFontFamilies.has(fontFamily);
|
|
38
|
+
};
|
|
39
|
+
export const FontPicker = React.memo(({ isOpened, selectedFontFamily, hoveredFontFamily, onSelect, onHover, onLeave, onPopupChange, }) => {
|
|
40
|
+
const defaultFonts = useMemo(() => DEFAULT_FONTS, []);
|
|
41
|
+
const onSelectCallback = useCallback((value) => {
|
|
42
|
+
if (value) {
|
|
43
|
+
onSelect(value);
|
|
44
|
+
}
|
|
45
|
+
}, [onSelect]);
|
|
46
|
+
return (_jsxs("div", { role: "dialog", "aria-modal": "true", className: "FontPicker__container", children: [_jsx(ButtonIconSelect, { type: "button", options: defaultFonts, value: selectedFontFamily, onClick: onSelectCallback }), _jsx(ButtonSeparator, {}), _jsxs(Popover.Root, { open: isOpened, onOpenChange: onPopupChange, children: [_jsx(FontPickerTrigger, { selectedFontFamily: selectedFontFamily }), isOpened && (_jsx(FontPickerList, { selectedFontFamily: selectedFontFamily, hoveredFontFamily: hoveredFontFamily, onSelect: onSelectCallback, onHover: onHover, onLeave: onLeave, onOpen: () => onPopupChange(true), onClose: () => onPopupChange(false) }))] })] }));
|
|
47
|
+
}, (prev, next) => prev.isOpened === next.isOpened &&
|
|
48
|
+
prev.selectedFontFamily === next.selectedFontFamily &&
|
|
49
|
+
prev.hoveredFontFamily === next.hoveredFontFamily);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DropDownMenuItemBadgeType } from "../dropdownMenu/DropdownMenuItem";
|
|
3
|
+
import { type FontFamilyValues } from "../../element/types";
|
|
4
|
+
import type { ValueOf } from "../../utility-types";
|
|
5
|
+
export interface FontDescriptor {
|
|
6
|
+
value: number;
|
|
7
|
+
icon: JSX.Element;
|
|
8
|
+
text: string;
|
|
9
|
+
deprecated?: true;
|
|
10
|
+
badge?: {
|
|
11
|
+
type: ValueOf<typeof DropDownMenuItemBadgeType>;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface FontPickerListProps {
|
|
16
|
+
selectedFontFamily: FontFamilyValues | null;
|
|
17
|
+
hoveredFontFamily: FontFamilyValues | null;
|
|
18
|
+
onSelect: (value: number) => void;
|
|
19
|
+
onHover: (value: number) => void;
|
|
20
|
+
onLeave: () => void;
|
|
21
|
+
onOpen: () => void;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const FontPickerList: React.MemoExoticComponent<({ selectedFontFamily, hoveredFontFamily, onSelect, onHover, onLeave, onOpen, onClose, }: FontPickerListProps) => JSX.Element>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo, useState, useRef, useEffect, useCallback, } from "react";
|
|
3
|
+
import { useApp, useAppProps, useExcalidrawContainer } from "../App";
|
|
4
|
+
import { PropertiesPopover } from "../PropertiesPopover";
|
|
5
|
+
import { QuickSearch } from "../QuickSearch";
|
|
6
|
+
import { ScrollableList } from "../ScrollableList";
|
|
7
|
+
import DropdownMenuGroup from "../dropdownMenu/DropdownMenuGroup";
|
|
8
|
+
import DropdownMenuItem, { DropDownMenuItemBadgeType, DropDownMenuItemBadge, } from "../dropdownMenu/DropdownMenuItem";
|
|
9
|
+
import { arrayToList, debounce, getFontFamilyString } from "../../utils";
|
|
10
|
+
import { t } from "../../i18n";
|
|
11
|
+
import { fontPickerKeyHandler } from "./keyboardNavHandlers";
|
|
12
|
+
import { Fonts } from "../../fonts";
|
|
13
|
+
export const FontPickerList = React.memo(({ selectedFontFamily, hoveredFontFamily, onSelect, onHover, onLeave, onOpen, onClose, }) => {
|
|
14
|
+
const { container } = useExcalidrawContainer();
|
|
15
|
+
const { fonts } = useApp();
|
|
16
|
+
const { showDeprecatedFonts } = useAppProps();
|
|
17
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
18
|
+
const inputRef = useRef(null);
|
|
19
|
+
const allFonts = useMemo(() => Array.from(Fonts.registered.entries())
|
|
20
|
+
.filter(([_, { metadata }]) => !metadata.serverSide)
|
|
21
|
+
.map(([familyId, { metadata, fonts }]) => {
|
|
22
|
+
const fontDescriptor = {
|
|
23
|
+
value: familyId,
|
|
24
|
+
icon: metadata.icon,
|
|
25
|
+
text: fonts[0].fontFace.family,
|
|
26
|
+
};
|
|
27
|
+
if (metadata.deprecated) {
|
|
28
|
+
Object.assign(fontDescriptor, {
|
|
29
|
+
deprecated: metadata.deprecated,
|
|
30
|
+
badge: {
|
|
31
|
+
type: DropDownMenuItemBadgeType.RED,
|
|
32
|
+
placeholder: t("fontList.badge.old"),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return fontDescriptor;
|
|
37
|
+
})
|
|
38
|
+
.sort((a, b) => a.text.toLowerCase() > b.text.toLowerCase() ? 1 : -1), []);
|
|
39
|
+
const sceneFamilies = useMemo(() => new Set(fonts.getSceneFontFamilies()),
|
|
40
|
+
// cache per selected font family, so hover re-render won't mess it up
|
|
41
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
+
[selectedFontFamily]);
|
|
43
|
+
const sceneFonts = useMemo(() => allFonts.filter((font) => sceneFamilies.has(font.value)), // always show all the fonts in the scene, even those that were deprecated
|
|
44
|
+
[allFonts, sceneFamilies]);
|
|
45
|
+
const availableFonts = useMemo(() => allFonts.filter((font) => !sceneFamilies.has(font.value) &&
|
|
46
|
+
(showDeprecatedFonts || !font.deprecated)), [allFonts, sceneFamilies, showDeprecatedFonts]);
|
|
47
|
+
const filteredFonts = useMemo(() => arrayToList([...sceneFonts, ...availableFonts].filter((font) => font.text?.toLowerCase().includes(searchTerm))), [sceneFonts, availableFonts, searchTerm]);
|
|
48
|
+
const hoveredFont = useMemo(() => {
|
|
49
|
+
let font;
|
|
50
|
+
if (hoveredFontFamily) {
|
|
51
|
+
font = filteredFonts.find((font) => font.value === hoveredFontFamily);
|
|
52
|
+
}
|
|
53
|
+
else if (selectedFontFamily) {
|
|
54
|
+
font = filteredFonts.find((font) => font.value === selectedFontFamily);
|
|
55
|
+
}
|
|
56
|
+
if (!font && searchTerm) {
|
|
57
|
+
if (filteredFonts[0]?.value) {
|
|
58
|
+
// hover first element on search
|
|
59
|
+
onHover(filteredFonts[0].value);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// re-render cache on no results
|
|
63
|
+
onLeave();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return font;
|
|
67
|
+
}, [
|
|
68
|
+
hoveredFontFamily,
|
|
69
|
+
selectedFontFamily,
|
|
70
|
+
searchTerm,
|
|
71
|
+
filteredFonts,
|
|
72
|
+
onHover,
|
|
73
|
+
onLeave,
|
|
74
|
+
]);
|
|
75
|
+
const onKeyDown = useCallback((event) => {
|
|
76
|
+
const handled = fontPickerKeyHandler({
|
|
77
|
+
event,
|
|
78
|
+
inputRef,
|
|
79
|
+
hoveredFont,
|
|
80
|
+
filteredFonts,
|
|
81
|
+
onSelect,
|
|
82
|
+
onHover,
|
|
83
|
+
onClose,
|
|
84
|
+
});
|
|
85
|
+
if (handled) {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
event.stopPropagation();
|
|
88
|
+
}
|
|
89
|
+
}, [hoveredFont, filteredFonts, onSelect, onHover, onClose]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
onOpen();
|
|
92
|
+
return () => {
|
|
93
|
+
onClose();
|
|
94
|
+
};
|
|
95
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
+
}, []);
|
|
97
|
+
const sceneFilteredFonts = useMemo(() => filteredFonts.filter((font) => sceneFamilies.has(font.value)), [filteredFonts, sceneFamilies]);
|
|
98
|
+
const availableFilteredFonts = useMemo(() => filteredFonts.filter((font) => !sceneFamilies.has(font.value)), [filteredFonts, sceneFamilies]);
|
|
99
|
+
const renderFont = (font, index) => (_jsxs(DropdownMenuItem, { icon: font.icon, value: font.value, order: index, textStyle: {
|
|
100
|
+
fontFamily: getFontFamilyString({ fontFamily: font.value }),
|
|
101
|
+
}, hovered: font.value === hoveredFont?.value, selected: font.value === selectedFontFamily,
|
|
102
|
+
// allow to tab between search and selected font
|
|
103
|
+
tabIndex: font.value === selectedFontFamily ? 0 : -1, onClick: (e) => {
|
|
104
|
+
onSelect(Number(e.currentTarget.value));
|
|
105
|
+
}, onMouseMove: () => {
|
|
106
|
+
if (hoveredFont?.value !== font.value) {
|
|
107
|
+
onHover(font.value);
|
|
108
|
+
}
|
|
109
|
+
}, children: [font.text, font.badge && (_jsx(DropDownMenuItemBadge, { type: font.badge.type, children: font.badge.placeholder }))] }, font.value));
|
|
110
|
+
const groups = [];
|
|
111
|
+
if (sceneFilteredFonts.length) {
|
|
112
|
+
groups.push(_jsx(DropdownMenuGroup, { title: t("fontList.sceneFonts"), children: sceneFilteredFonts.map(renderFont) }, "group_1"));
|
|
113
|
+
}
|
|
114
|
+
if (availableFilteredFonts.length) {
|
|
115
|
+
groups.push(_jsx(DropdownMenuGroup, { title: t("fontList.availableFonts"), children: availableFilteredFonts.map((font, index) => renderFont(font, index + sceneFilteredFonts.length)) }, "group_2"));
|
|
116
|
+
}
|
|
117
|
+
return (_jsxs(PropertiesPopover, { className: "properties-content", container: container, style: { width: "15rem" }, onClose: onClose, onPointerLeave: onLeave, onKeyDown: onKeyDown, children: [_jsx(QuickSearch, { ref: inputRef, placeholder: t("quickSearch.placeholder"), onChange: debounce(setSearchTerm, 20) }), _jsx(ScrollableList, { className: "dropdown-menu fonts manual-hover", placeholder: t("fontList.empty"), children: groups.length ? groups : null })] }));
|
|
118
|
+
}, (prev, next) => prev.selectedFontFamily === next.selectedFontFamily &&
|
|
119
|
+
prev.hoveredFontFamily === next.hoveredFontFamily);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { FontFamilyValues } from "../../element/types";
|
|
3
|
+
interface FontPickerTriggerProps {
|
|
4
|
+
selectedFontFamily: FontFamilyValues | null;
|
|
5
|
+
}
|
|
6
|
+
export declare const FontPickerTrigger: ({ selectedFontFamily, }: FontPickerTriggerProps) => JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { ButtonIcon } from "../ButtonIcon";
|
|
5
|
+
import { TextIcon } from "../icons";
|
|
6
|
+
import { t } from "../../i18n";
|
|
7
|
+
import { isDefaultFont } from "./FontPicker";
|
|
8
|
+
export const FontPickerTrigger = ({ selectedFontFamily, }) => {
|
|
9
|
+
const isTriggerActive = useMemo(() => Boolean(selectedFontFamily && !isDefaultFont(selectedFontFamily)), [selectedFontFamily]);
|
|
10
|
+
return (_jsx(Popover.Trigger, { asChild: true, children: _jsx("div", { children: _jsx(ButtonIcon, { standalone: true, icon: TextIcon, title: t("labels.showFonts"), className: "properties-trigger", testId: "font-family-show-fonts", active: isTriggerActive,
|
|
11
|
+
// no-op
|
|
12
|
+
onClick: () => { } }) }) }));
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Node } from "../../utils";
|
|
3
|
+
import { type FontDescriptor } from "./FontPickerList";
|
|
4
|
+
interface FontPickerKeyNavHandlerProps {
|
|
5
|
+
event: React.KeyboardEvent<HTMLDivElement>;
|
|
6
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
|
7
|
+
hoveredFont: Node<FontDescriptor> | undefined;
|
|
8
|
+
filteredFonts: Node<FontDescriptor>[];
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onSelect: (value: number) => void;
|
|
11
|
+
onHover: (value: number) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const fontPickerKeyHandler: ({ event, inputRef, hoveredFont, filteredFonts, onClose, onSelect, onHover, }: FontPickerKeyNavHandlerProps) => true | undefined;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { KEYS } from "../../keys";
|
|
2
|
+
export const fontPickerKeyHandler = ({ event, inputRef, hoveredFont, filteredFonts, onClose, onSelect, onHover, }) => {
|
|
3
|
+
if (!event[KEYS.CTRL_OR_CMD] &&
|
|
4
|
+
event.shiftKey &&
|
|
5
|
+
event.key.toLowerCase() === KEYS.F) {
|
|
6
|
+
// refocus input on the popup trigger shortcut
|
|
7
|
+
inputRef.current?.focus();
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (event.key === KEYS.ESCAPE) {
|
|
11
|
+
onClose();
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (event.key === KEYS.ENTER) {
|
|
15
|
+
if (hoveredFont?.value) {
|
|
16
|
+
onSelect(hoveredFont.value);
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (event.key === KEYS.ARROW_DOWN) {
|
|
21
|
+
if (hoveredFont?.next) {
|
|
22
|
+
onHover(hoveredFont.next.value);
|
|
23
|
+
}
|
|
24
|
+
else if (filteredFonts[0]?.value) {
|
|
25
|
+
onHover(filteredFonts[0].value);
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (event.key === KEYS.ARROW_UP) {
|
|
30
|
+
if (hoveredFont?.prev) {
|
|
31
|
+
onHover(hoveredFont.prev.value);
|
|
32
|
+
}
|
|
33
|
+
else if (filteredFonts[filteredFonts.length - 1]?.value) {
|
|
34
|
+
onHover(filteredFonts[filteredFonts.length - 1].value);
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -81,5 +81,5 @@ export const HelpDialog = ({ onClose }) => {
|
|
|
81
81
|
getShortcutKey("CtrlOrCmd+Y"),
|
|
82
82
|
getShortcutKey("CtrlOrCmd+Shift+Z"),
|
|
83
83
|
]
|
|
84
|
-
: [getShortcutKey("CtrlOrCmd+Shift+Z")] }), _jsx(Shortcut, { label: t("labels.group"), shortcuts: [getShortcutKey("CtrlOrCmd+G")] }), _jsx(Shortcut, { label: t("labels.ungroup"), shortcuts: [getShortcutKey("CtrlOrCmd+Shift+G")] }), _jsx(Shortcut, { label: t("labels.flipHorizontal"), shortcuts: [getShortcutKey("Shift+H")] }), _jsx(Shortcut, { label: t("labels.flipVertical"), shortcuts: [getShortcutKey("Shift+V")] }), _jsx(Shortcut, { label: t("labels.showStroke"), shortcuts: [getShortcutKey("S")] }), _jsx(Shortcut, { label: t("labels.showBackground"), shortcuts: [getShortcutKey("G")] }), _jsx(Shortcut, { label: t("labels.decreaseFontSize"), shortcuts: [getShortcutKey("CtrlOrCmd+Shift+<")] }), _jsx(Shortcut, { label: t("labels.increaseFontSize"), shortcuts: [getShortcutKey("CtrlOrCmd+Shift+>")] })] })] })] }) }));
|
|
84
|
+
: [getShortcutKey("CtrlOrCmd+Shift+Z")] }), _jsx(Shortcut, { label: t("labels.group"), shortcuts: [getShortcutKey("CtrlOrCmd+G")] }), _jsx(Shortcut, { label: t("labels.ungroup"), shortcuts: [getShortcutKey("CtrlOrCmd+Shift+G")] }), _jsx(Shortcut, { label: t("labels.flipHorizontal"), shortcuts: [getShortcutKey("Shift+H")] }), _jsx(Shortcut, { label: t("labels.flipVertical"), shortcuts: [getShortcutKey("Shift+V")] }), _jsx(Shortcut, { label: t("labels.showStroke"), shortcuts: [getShortcutKey("S")] }), _jsx(Shortcut, { label: t("labels.showBackground"), shortcuts: [getShortcutKey("G")] }), _jsx(Shortcut, { label: t("labels.showFonts"), shortcuts: [getShortcutKey("Shift+F")] }), _jsx(Shortcut, { label: t("labels.decreaseFontSize"), shortcuts: [getShortcutKey("CtrlOrCmd+Shift+<")] }), _jsx(Shortcut, { label: t("labels.increaseFontSize"), shortcuts: [getShortcutKey("CtrlOrCmd+Shift+>")] })] })] })] }) }));
|
|
85
85
|
};
|
|
@@ -14,10 +14,13 @@ const getHints = ({ appState, isMobile, device, app }) => {
|
|
|
14
14
|
return t("hints.eraserRevert");
|
|
15
15
|
}
|
|
16
16
|
if (activeTool.type === "arrow" || activeTool.type === "line") {
|
|
17
|
-
if (
|
|
18
|
-
return t("hints.
|
|
17
|
+
if (multiMode) {
|
|
18
|
+
return t("hints.linearElementMulti");
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
if (activeTool.type === "arrow") {
|
|
21
|
+
return t("hints.arrowTool", { arrowShortcut: getShortcutKey("A") });
|
|
22
|
+
}
|
|
23
|
+
return t("hints.linearElement");
|
|
21
24
|
}
|
|
22
25
|
if (activeTool.type === "freedraw") {
|
|
23
26
|
return t("hints.freeDraw");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
3
|
+
interface PropertiesPopoverProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
container: HTMLDivElement | null;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
style?: object;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
10
|
+
onPointerLeave?: React.PointerEventHandler<HTMLDivElement>;
|
|
11
|
+
onFocusOutside?: Popover.DismissableLayerProps["onFocusOutside"];
|
|
12
|
+
onPointerDownOutside?: Popover.DismissableLayerProps["onPointerDownOutside"];
|
|
13
|
+
}
|
|
14
|
+
export declare const PropertiesPopover: React.ForwardRefExoticComponent<PropertiesPopoverProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
5
|
+
import { useDevice } from "./App";
|
|
6
|
+
import { Island } from "./Island";
|
|
7
|
+
import { isInteractive } from "../utils";
|
|
8
|
+
export const PropertiesPopover = React.forwardRef(({ className, container, children, style, onClose, onKeyDown, onFocusOutside, onPointerLeave, onPointerDownOutside, }, ref) => {
|
|
9
|
+
const device = useDevice();
|
|
10
|
+
return (_jsx(Popover.Portal, { container: container, children: _jsxs(Popover.Content, { ref: ref, className: clsx("focus-visible-none", className), "data-prevent-outside-click": true, side: device.editor.isMobile && !device.viewport.isLandscape
|
|
11
|
+
? "bottom"
|
|
12
|
+
: "right", align: device.editor.isMobile && !device.viewport.isLandscape
|
|
13
|
+
? "center"
|
|
14
|
+
: "start", alignOffset: -16, sideOffset: 20, style: {
|
|
15
|
+
zIndex: "var(--zIndex-popup)",
|
|
16
|
+
}, onPointerLeave: onPointerLeave, onKeyDown: onKeyDown, onFocusOutside: onFocusOutside, onPointerDownOutside: onPointerDownOutside, onCloseAutoFocus: (e) => {
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
// prevents focusing the trigger
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
// return focus to excalidraw container unless
|
|
21
|
+
// user focuses an interactive element, such as a button, or
|
|
22
|
+
// enters the text editor by clicking on canvas with the text tool
|
|
23
|
+
if (container && !isInteractive(document.activeElement)) {
|
|
24
|
+
container.focus();
|
|
25
|
+
}
|
|
26
|
+
onClose();
|
|
27
|
+
}, children: [_jsx(Island, { padding: 3, style: style, children: children }), _jsx(Popover.Arrow, { width: 20, height: 10, style: {
|
|
28
|
+
fill: "var(--popup-bg-color)",
|
|
29
|
+
filter: "drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)",
|
|
30
|
+
} })] }) }));
|
|
31
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./QuickSearch.scss";
|
|
3
|
+
interface QuickSearchProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
placeholder: string;
|
|
6
|
+
onChange: (term: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const QuickSearch: React.ForwardRefExoticComponent<QuickSearchProps & React.RefAttributes<HTMLInputElement>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { searchIcon } from "./icons";
|
|
5
|
+
import "./QuickSearch.scss";
|
|
6
|
+
export const QuickSearch = React.forwardRef(({ className, placeholder, onChange }, ref) => {
|
|
7
|
+
return (_jsxs("div", { className: clsx("QuickSearch__wrapper", className), children: [searchIcon, _jsx("input", { ref: ref, className: "QuickSearch__input", type: "text", placeholder: placeholder, onChange: (e) => onChange(e.target.value.trim().toLowerCase()) })] }));
|
|
8
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./ScrollableList.scss";
|
|
3
|
+
interface ScrollableListProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
placeholder: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const ScrollableList: ({ className, placeholder, children, }: ScrollableListProps) => JSX.Element;
|
|
9
|
+
export {};
|