@excalidraw/excalidraw 0.17.1-7441-e31f307 → 0.17.1-7441-4c9a6f4
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/dist/browser/excalidraw-assets/{chunk-PJT4QCRY.js → chunk-LZCCI7PN.js} +4 -4
- package/dist/browser/excalidraw-assets/{image-KZSI6GAB.js → image-CG4AV2NT.js} +1 -1
- package/dist/browser/excalidraw-assets/{image-2MHILQWB.css → image-EO7USLQY.css} +1 -1
- package/dist/browser/index.css +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/packages/excalidraw/actions/actionAddToLibrary.js +59 -0
- package/dist/packages/excalidraw/actions/actionAlign.js +124 -0
- package/dist/packages/excalidraw/actions/actionBoundText.js +213 -0
- package/dist/packages/excalidraw/actions/actionCanvas.js +354 -0
- package/dist/packages/excalidraw/actions/actionClipboard.js +221 -0
- package/dist/packages/excalidraw/actions/actionDeleteSelected.js +129 -0
- package/dist/packages/excalidraw/actions/actionDistribute.js +56 -0
- package/dist/packages/excalidraw/actions/actionDuplicateSelection.js +181 -0
- package/dist/packages/excalidraw/actions/actionElementLock.js +89 -0
- package/dist/packages/excalidraw/actions/actionExport.js +195 -0
- package/dist/packages/excalidraw/actions/actionFinalize.js +150 -0
- package/dist/packages/excalidraw/actions/actionFlip.js +52 -0
- package/dist/packages/excalidraw/actions/actionFrame.js +113 -0
- package/dist/packages/excalidraw/actions/actionGroup.js +162 -0
- package/dist/packages/excalidraw/actions/actionHistory.js +57 -0
- package/dist/packages/excalidraw/actions/actionLinearEditor.js +41 -0
- package/dist/packages/excalidraw/actions/actionMenu.js +53 -0
- package/dist/packages/excalidraw/actions/actionNavigate.js +43 -0
- package/dist/packages/excalidraw/actions/actionProperties.js +683 -0
- package/dist/packages/excalidraw/actions/actionSelectAll.js +40 -0
- package/dist/packages/excalidraw/actions/actionStyles.js +118 -0
- package/dist/packages/excalidraw/actions/actionToggleGridMode.js +27 -0
- package/dist/packages/excalidraw/actions/actionToggleObjectsSnapMode.js +26 -0
- package/dist/packages/excalidraw/actions/actionToggleStats.js +19 -0
- package/dist/packages/excalidraw/actions/actionToggleViewMode.js +25 -0
- package/dist/packages/excalidraw/actions/actionToggleZenMode.js +25 -0
- package/dist/packages/excalidraw/actions/actionZindex.js +86 -0
- package/dist/packages/excalidraw/actions/index.js +25 -0
- package/dist/packages/excalidraw/actions/manager.js +110 -0
- package/dist/packages/excalidraw/actions/register.js +5 -0
- package/dist/packages/excalidraw/actions/shortcuts.js +52 -0
- package/dist/packages/excalidraw/align.js +36 -0
- package/dist/packages/excalidraw/analytics.js +30 -0
- package/dist/packages/excalidraw/appState.js +222 -0
- package/dist/packages/excalidraw/charts.js +365 -0
- package/dist/packages/excalidraw/clients.js +34 -0
- package/dist/packages/excalidraw/clipboard.js +351 -0
- package/dist/packages/excalidraw/colors.js +124 -0
- package/dist/packages/excalidraw/components/Actions.js +127 -0
- package/dist/packages/excalidraw/components/Actions.scss +92 -0
- package/dist/packages/excalidraw/components/ActiveConfirmDialog.js +22 -0
- package/dist/packages/excalidraw/components/App.js +6177 -0
- package/dist/packages/excalidraw/components/Avatar.js +15 -0
- package/dist/packages/excalidraw/components/Avatar.scss +7 -0
- package/dist/packages/excalidraw/components/BraveMeasureTextError.js +6 -0
- package/dist/packages/excalidraw/components/Button.js +14 -0
- package/dist/packages/excalidraw/components/Button.scss +7 -0
- package/dist/packages/excalidraw/components/ButtonIconCycle.js +11 -0
- package/dist/packages/excalidraw/components/ButtonIconSelect.js +6 -0
- package/dist/packages/excalidraw/components/ButtonSelect.js +3 -0
- package/dist/packages/excalidraw/components/Card.js +14 -0
- package/dist/packages/excalidraw/components/Card.scss +57 -0
- package/dist/packages/excalidraw/components/CheckboxItem.js +10 -0
- package/dist/packages/excalidraw/components/CheckboxItem.scss +91 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorInput.js +67 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.js +138 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.scss +441 -0
- package/dist/packages/excalidraw/components/ColorPicker/CustomColorList.js +24 -0
- package/dist/packages/excalidraw/components/ColorPicker/HotkeyLabel.js +8 -0
- package/dist/packages/excalidraw/components/ColorPicker/Picker.js +86 -0
- package/dist/packages/excalidraw/components/ColorPicker/PickerColorList.js +33 -0
- package/dist/packages/excalidraw/components/ColorPicker/PickerHeading.js +3 -0
- package/dist/packages/excalidraw/components/ColorPicker/ShadeList.js +44 -0
- package/dist/packages/excalidraw/components/ColorPicker/TopPicks.js +27 -0
- package/dist/packages/excalidraw/components/ColorPicker/colorPickerUtils.js +83 -0
- package/dist/packages/excalidraw/components/ColorPicker/keyboardNavHandlers.js +174 -0
- package/dist/packages/excalidraw/components/ConfirmDialog.js +27 -0
- package/dist/packages/excalidraw/components/ConfirmDialog.scss +11 -0
- package/dist/packages/excalidraw/components/ContextMenu.js +56 -0
- package/dist/packages/excalidraw/components/ContextMenu.scss +98 -0
- package/dist/packages/excalidraw/components/DarkModeToggle.js +16 -0
- package/dist/packages/excalidraw/components/DefaultSidebar.js +48 -0
- package/dist/packages/excalidraw/components/Dialog.js +74 -0
- package/dist/packages/excalidraw/components/Dialog.scss +48 -0
- package/dist/packages/excalidraw/components/DialogActionButton.js +9 -0
- package/dist/packages/excalidraw/components/DialogActionButton.scss +47 -0
- package/dist/packages/excalidraw/components/ErrorDialog.js +18 -0
- package/dist/packages/excalidraw/components/ExcalidrawLogo.js +7 -0
- package/dist/packages/excalidraw/components/ExcalidrawLogo.scss +73 -0
- package/dist/packages/excalidraw/components/ExportDialog.scss +129 -0
- package/dist/packages/excalidraw/components/EyeDropper.js +130 -0
- package/dist/packages/excalidraw/components/EyeDropper.scss +48 -0
- package/dist/packages/excalidraw/components/FilledButton.js +7 -0
- package/dist/packages/excalidraw/components/FilledButton.scss +191 -0
- package/dist/packages/excalidraw/components/FixedSideContainer.js +4 -0
- package/dist/packages/excalidraw/components/FixedSideContainer.scss +40 -0
- package/dist/packages/excalidraw/components/FollowMode/FollowMode.js +7 -0
- package/dist/packages/excalidraw/components/FollowMode/FollowMode.scss +59 -0
- package/dist/packages/excalidraw/components/HandButton.js +9 -0
- package/dist/packages/excalidraw/components/HelpButton.js +4 -0
- package/dist/packages/excalidraw/components/HelpDialog.js +79 -0
- package/dist/packages/excalidraw/components/HelpDialog.scss +130 -0
- package/dist/packages/excalidraw/components/HintViewer.js +97 -0
- package/dist/packages/excalidraw/components/HintViewer.scss +37 -0
- package/dist/packages/excalidraw/components/IconPicker.js +99 -0
- package/dist/packages/excalidraw/components/IconPicker.scss +143 -0
- package/dist/packages/excalidraw/components/ImageExportDialog.js +127 -0
- package/dist/packages/excalidraw/components/ImageExportDialog.scss +173 -0
- package/dist/packages/excalidraw/components/InitializeApp.js +16 -0
- package/dist/packages/excalidraw/components/InlineIcon.js +10 -0
- package/dist/packages/excalidraw/components/Island.js +5 -0
- package/dist/packages/excalidraw/components/Island.scss +16 -0
- package/dist/packages/excalidraw/components/JSONExportDialog.js +35 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserPathManager.js +225 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserPointerButton.js +10 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserTool.js +15 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserToolOverlay.scss +20 -0
- package/dist/packages/excalidraw/components/LayerUI.js +189 -0
- package/dist/packages/excalidraw/components/LayerUI.scss +112 -0
- package/dist/packages/excalidraw/components/LibraryMenu.js +99 -0
- package/dist/packages/excalidraw/components/LibraryMenu.scss +150 -0
- package/dist/packages/excalidraw/components/LibraryMenuBrowseButton.js +8 -0
- package/dist/packages/excalidraw/components/LibraryMenuControlButtons.js +6 -0
- package/dist/packages/excalidraw/components/LibraryMenuHeaderContent.js +126 -0
- package/dist/packages/excalidraw/components/LibraryMenuItems.js +138 -0
- package/dist/packages/excalidraw/components/LibraryMenuItems.scss +99 -0
- package/dist/packages/excalidraw/components/LibraryMenuSection.js +21 -0
- package/dist/packages/excalidraw/components/LibraryUnit.js +52 -0
- package/dist/packages/excalidraw/components/LibraryUnit.scss +185 -0
- package/dist/packages/excalidraw/components/LoadingMessage.js +24 -0
- package/dist/packages/excalidraw/components/LockButton.js +14 -0
- package/dist/packages/excalidraw/components/MagicButton.js +9 -0
- package/dist/packages/excalidraw/components/MagicSettings.js +46 -0
- package/dist/packages/excalidraw/components/MagicSettings.scss +18 -0
- package/dist/packages/excalidraw/components/MobileMenu.js +45 -0
- package/dist/packages/excalidraw/components/Modal.js +23 -0
- package/dist/packages/excalidraw/components/Modal.scss +121 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.js +31 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.scss +126 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.js +32 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.js +19 -0
- package/dist/packages/excalidraw/components/Paragraph.js +4 -0
- package/dist/packages/excalidraw/components/PasteChartDialog.js +63 -0
- package/dist/packages/excalidraw/components/PasteChartDialog.scss +46 -0
- package/dist/packages/excalidraw/components/PenModeButton.js +13 -0
- package/dist/packages/excalidraw/components/Popover.js +111 -0
- package/dist/packages/excalidraw/components/Popover.scss +8 -0
- package/dist/packages/excalidraw/components/ProjectName.js +30 -0
- package/dist/packages/excalidraw/components/ProjectName.scss +25 -0
- package/dist/packages/excalidraw/components/PublishLibrary.js +214 -0
- package/dist/packages/excalidraw/components/PublishLibrary.scss +172 -0
- package/dist/packages/excalidraw/components/RadioGroup.js +8 -0
- package/dist/packages/excalidraw/components/RadioGroup.scss +91 -0
- package/dist/packages/excalidraw/components/Section.js +8 -0
- package/dist/packages/excalidraw/components/ShareableLinkDialog.js +33 -0
- package/dist/packages/excalidraw/components/ShareableLinkDialog.scss +91 -0
- package/dist/packages/excalidraw/components/Sidebar/Sidebar.js +145 -0
- package/dist/packages/excalidraw/components/Sidebar/Sidebar.scss +176 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarHeader.js +16 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTab.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabTrigger.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabTriggers.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabs.js +17 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.js +18 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.scss +37 -0
- package/dist/packages/excalidraw/components/Sidebar/common.js +2 -0
- package/dist/packages/excalidraw/components/Spinner.js +14 -0
- package/dist/packages/excalidraw/components/Spinner.scss +49 -0
- package/dist/packages/excalidraw/components/Stack.js +24 -0
- package/dist/packages/excalidraw/components/Stack.scss +19 -0
- package/dist/packages/excalidraw/components/Stats.js +13 -0
- package/dist/packages/excalidraw/components/Stats.scss +54 -0
- package/dist/packages/excalidraw/components/Switch.js +10 -0
- package/dist/packages/excalidraw/components/Switch.scss +118 -0
- package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.js +58 -0
- package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.scss +10 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.js +194 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.scss +315 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogInput.js +28 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogOutput.js +8 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanel.js +11 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanels.js +4 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.js +5 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTab.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTrigger.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTriggers.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabs.js +39 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTrigger.js +16 -0
- package/dist/packages/excalidraw/components/TTDDialog/common.js +88 -0
- package/dist/packages/excalidraw/components/TextField.js +25 -0
- package/dist/packages/excalidraw/components/TextField.scss +109 -0
- package/dist/packages/excalidraw/components/TextInput.scss +7 -0
- package/dist/packages/excalidraw/components/Toast.js +30 -0
- package/dist/packages/excalidraw/components/Toast.scss +49 -0
- package/dist/packages/excalidraw/components/ToolButton.js +72 -0
- package/dist/packages/excalidraw/components/ToolIcon.scss +184 -0
- package/dist/packages/excalidraw/components/Toolbar.scss +50 -0
- package/dist/packages/excalidraw/components/Tooltip.js +60 -0
- package/dist/packages/excalidraw/components/Tooltip.scss +47 -0
- package/dist/packages/excalidraw/components/Trans.js +139 -0
- package/dist/packages/excalidraw/components/UserList.js +96 -0
- package/dist/packages/excalidraw/components/UserList.scss +136 -0
- package/dist/packages/excalidraw/components/canvases/InteractiveCanvas.js +120 -0
- package/dist/packages/excalidraw/components/canvases/StaticCanvas.js +85 -0
- package/dist/packages/excalidraw/components/canvases/index.js +3 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.js +24 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.scss +148 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuContent.js +21 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuGroup.js +6 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItem.js +23 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +7 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.js +5 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemLink.js +9 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuSeparator.js +8 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuTrigger.js +12 -0
- package/dist/packages/excalidraw/components/dropdownMenu/common.js +20 -0
- package/dist/packages/excalidraw/components/dropdownMenu/dropdownMenuUtils.js +27 -0
- package/dist/packages/excalidraw/components/footer/Footer.js +25 -0
- package/dist/packages/excalidraw/components/footer/FooterCenter.js +14 -0
- package/dist/packages/excalidraw/components/footer/FooterCenter.scss +11 -0
- package/dist/packages/excalidraw/components/hoc/withInternalFallback.js +57 -0
- package/dist/packages/excalidraw/components/icons.js +220 -0
- package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.js +13 -0
- package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.scss +72 -0
- package/dist/packages/excalidraw/components/main-menu/DefaultItems.js +116 -0
- package/dist/packages/excalidraw/components/main-menu/DefaultItems.scss +21 -0
- package/dist/packages/excalidraw/components/main-menu/MainMenu.js +36 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +69 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +20 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.js +11 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.scss +285 -0
- package/dist/packages/excalidraw/constants.js +312 -0
- package/dist/packages/excalidraw/context/tunnels.js +21 -0
- package/dist/packages/excalidraw/context/ui-appState.js +3 -0
- package/dist/packages/excalidraw/css/app.scss +39 -0
- package/dist/packages/excalidraw/css/styles.scss +757 -0
- package/dist/packages/excalidraw/css/theme.scss +252 -0
- package/dist/packages/excalidraw/css/variables.module.scss +174 -0
- package/dist/packages/excalidraw/cursor.js +72 -0
- package/dist/packages/excalidraw/data/EditorLocalStorage.js +42 -0
- package/dist/packages/excalidraw/data/ai/types.js +1 -0
- package/dist/packages/excalidraw/data/blob.js +378 -0
- package/dist/packages/excalidraw/data/encode.js +231 -0
- package/dist/packages/excalidraw/data/encryption.js +53 -0
- package/dist/packages/excalidraw/data/filesystem.js +65 -0
- package/dist/packages/excalidraw/data/image.js +91 -0
- package/dist/packages/excalidraw/data/index.js +120 -0
- package/dist/packages/excalidraw/data/json.js +93 -0
- package/dist/packages/excalidraw/data/library.js +376 -0
- package/dist/packages/excalidraw/data/magic.js +73 -0
- package/dist/packages/excalidraw/data/resave.js +22 -0
- package/dist/packages/excalidraw/data/restore.js +438 -0
- package/dist/packages/excalidraw/data/transform.js +442 -0
- package/dist/packages/excalidraw/data/types.js +1 -0
- package/dist/packages/excalidraw/data/url.js +30 -0
- package/dist/packages/excalidraw/distribute.js +58 -0
- package/dist/packages/excalidraw/element/ElementCanvasButtons.js +31 -0
- package/dist/packages/excalidraw/element/ElementCanvasButtons.scss +14 -0
- package/dist/packages/excalidraw/element/Hyperlink.js +350 -0
- package/dist/packages/excalidraw/element/Hyperlink.scss +70 -0
- package/dist/packages/excalidraw/element/binding.js +412 -0
- package/dist/packages/excalidraw/element/bounds.js +613 -0
- package/dist/packages/excalidraw/element/collision.js +727 -0
- package/dist/packages/excalidraw/element/dragElements.js +119 -0
- package/dist/packages/excalidraw/element/embeddable.js +305 -0
- package/dist/packages/excalidraw/element/image.js +91 -0
- package/dist/packages/excalidraw/element/index.js +24 -0
- package/dist/packages/excalidraw/element/linearElementEditor.js +867 -0
- package/dist/packages/excalidraw/element/mutateElement.js +112 -0
- package/dist/packages/excalidraw/element/newElement.js +389 -0
- package/dist/packages/excalidraw/element/resizeElements.js +597 -0
- package/dist/packages/excalidraw/element/resizeTest.js +95 -0
- package/dist/packages/excalidraw/element/showSelectedShapeActions.js +9 -0
- package/dist/packages/excalidraw/element/sizeHelpers.js +131 -0
- package/dist/packages/excalidraw/element/sortElements.js +104 -0
- package/dist/packages/excalidraw/element/textElement.js +716 -0
- package/dist/packages/excalidraw/element/textWysiwyg.js +500 -0
- package/dist/packages/excalidraw/element/transformHandles.js +155 -0
- package/dist/packages/excalidraw/element/typeChecks.js +141 -0
- package/dist/packages/excalidraw/element/types.js +1 -0
- package/dist/packages/excalidraw/emitter.js +36 -0
- package/dist/packages/excalidraw/errors.js +20 -0
- package/dist/packages/excalidraw/frame.js +373 -0
- package/dist/packages/excalidraw/ga.js +268 -0
- package/dist/packages/excalidraw/gadirections.js +18 -0
- package/dist/packages/excalidraw/galines.js +32 -0
- package/dist/packages/excalidraw/gapoints.js +30 -0
- package/dist/packages/excalidraw/gatransforms.js +23 -0
- package/dist/packages/excalidraw/gesture.js +9 -0
- package/dist/packages/excalidraw/groups.js +225 -0
- package/dist/packages/excalidraw/history.js +190 -0
- package/dist/packages/excalidraw/hooks/useCallbackRefState.js +6 -0
- package/dist/packages/excalidraw/hooks/useCreatePortalContainer.js +32 -0
- package/dist/packages/excalidraw/hooks/useLibraryItemSvg.js +62 -0
- package/dist/packages/excalidraw/hooks/useOutsideClick.js +67 -0
- package/dist/packages/excalidraw/hooks/useScrollPosition.js +23 -0
- package/dist/packages/excalidraw/hooks/useStable.js +6 -0
- package/dist/packages/excalidraw/hooks/useTransition.js +7 -0
- package/dist/packages/excalidraw/i18n.js +137 -0
- package/dist/packages/excalidraw/index-node.d.ts +1 -0
- package/dist/packages/excalidraw/index-node.js +73 -0
- package/{types → dist/packages}/excalidraw/index.d.ts +1 -1
- package/dist/packages/excalidraw/index.js +116 -0
- package/dist/packages/excalidraw/jotai.js +18 -0
- package/dist/packages/excalidraw/keys.js +84 -0
- package/dist/packages/excalidraw/locales/ar-SA.json +525 -0
- package/dist/packages/excalidraw/locales/az-AZ.json +525 -0
- package/dist/packages/excalidraw/locales/bg-BG.json +525 -0
- package/dist/packages/excalidraw/locales/bn-BD.json +525 -0
- package/dist/packages/excalidraw/locales/ca-ES.json +525 -0
- package/dist/packages/excalidraw/locales/cs-CZ.json +525 -0
- package/dist/packages/excalidraw/locales/da-DK.json +525 -0
- package/dist/packages/excalidraw/locales/de-DE.json +525 -0
- package/dist/packages/excalidraw/locales/el-GR.json +525 -0
- package/dist/packages/excalidraw/locales/en.json +535 -0
- package/dist/packages/excalidraw/locales/es-ES.json +525 -0
- package/dist/packages/excalidraw/locales/eu-ES.json +525 -0
- package/dist/packages/excalidraw/locales/fa-IR.json +525 -0
- package/dist/packages/excalidraw/locales/fi-FI.json +525 -0
- package/dist/packages/excalidraw/locales/fr-FR.json +525 -0
- package/dist/packages/excalidraw/locales/gl-ES.json +525 -0
- package/dist/packages/excalidraw/locales/he-IL.json +525 -0
- package/dist/packages/excalidraw/locales/hi-IN.json +525 -0
- package/dist/packages/excalidraw/locales/hu-HU.json +525 -0
- package/dist/packages/excalidraw/locales/id-ID.json +525 -0
- package/dist/packages/excalidraw/locales/it-IT.json +525 -0
- package/dist/packages/excalidraw/locales/ja-JP.json +525 -0
- package/dist/packages/excalidraw/locales/kaa.json +525 -0
- package/dist/packages/excalidraw/locales/kab-KAB.json +525 -0
- package/dist/packages/excalidraw/locales/kk-KZ.json +525 -0
- package/dist/packages/excalidraw/locales/km-KH.json +525 -0
- package/dist/packages/excalidraw/locales/ko-KR.json +525 -0
- package/dist/packages/excalidraw/locales/ku-TR.json +525 -0
- package/dist/packages/excalidraw/locales/lt-LT.json +525 -0
- package/dist/packages/excalidraw/locales/lv-LV.json +525 -0
- package/dist/packages/excalidraw/locales/mr-IN.json +525 -0
- package/dist/packages/excalidraw/locales/my-MM.json +525 -0
- package/dist/packages/excalidraw/locales/nb-NO.json +525 -0
- package/dist/packages/excalidraw/locales/nl-NL.json +525 -0
- package/dist/packages/excalidraw/locales/nn-NO.json +525 -0
- package/dist/packages/excalidraw/locales/oc-FR.json +525 -0
- package/dist/packages/excalidraw/locales/pa-IN.json +525 -0
- package/dist/packages/excalidraw/locales/percentages.json +56 -0
- package/dist/packages/excalidraw/locales/pl-PL.json +525 -0
- package/dist/packages/excalidraw/locales/pt-BR.json +525 -0
- package/dist/packages/excalidraw/locales/pt-PT.json +525 -0
- package/dist/packages/excalidraw/locales/ro-RO.json +525 -0
- package/dist/packages/excalidraw/locales/ru-RU.json +525 -0
- package/dist/packages/excalidraw/locales/si-LK.json +525 -0
- package/dist/packages/excalidraw/locales/sk-SK.json +525 -0
- package/dist/packages/excalidraw/locales/sl-SI.json +525 -0
- package/dist/packages/excalidraw/locales/sv-SE.json +525 -0
- package/dist/packages/excalidraw/locales/ta-IN.json +525 -0
- package/dist/packages/excalidraw/locales/th-TH.json +525 -0
- package/dist/packages/excalidraw/locales/tr-TR.json +525 -0
- package/dist/packages/excalidraw/locales/uk-UA.json +525 -0
- package/dist/packages/excalidraw/locales/vi-VN.json +525 -0
- package/dist/packages/excalidraw/locales/zh-CN.json +525 -0
- package/dist/packages/excalidraw/locales/zh-HK.json +525 -0
- package/dist/packages/excalidraw/locales/zh-TW.json +525 -0
- package/dist/packages/excalidraw/math.js +364 -0
- package/dist/packages/excalidraw/points.js +38 -0
- package/dist/packages/excalidraw/polyfill.js +32 -0
- package/dist/packages/excalidraw/random.js +11 -0
- package/dist/packages/excalidraw/renderer/renderElement.js +871 -0
- package/dist/packages/excalidraw/renderer/renderScene.js +859 -0
- package/dist/packages/excalidraw/renderer/renderSnaps.js +114 -0
- package/dist/packages/excalidraw/renderer/roundRect.js +28 -0
- package/dist/packages/excalidraw/scene/Fonts.js +71 -0
- package/dist/packages/excalidraw/scene/Renderer.js +65 -0
- package/dist/packages/excalidraw/scene/Scene.js +230 -0
- package/dist/packages/excalidraw/scene/Shape.js +322 -0
- package/dist/packages/excalidraw/scene/ShapeCache.js +42 -0
- package/dist/packages/excalidraw/scene/comparisons.js +67 -0
- package/dist/packages/excalidraw/scene/export.js +304 -0
- package/dist/packages/excalidraw/scene/index.js +5 -0
- package/dist/packages/excalidraw/scene/scroll.js +35 -0
- package/dist/packages/excalidraw/scene/scrollbars.js +85 -0
- package/dist/packages/excalidraw/scene/selection.js +134 -0
- package/dist/packages/excalidraw/scene/types.js +1 -0
- package/dist/packages/excalidraw/scene/zoom.js +22 -0
- package/dist/packages/excalidraw/shapes.js +84 -0
- package/dist/packages/excalidraw/snapping.js +838 -0
- package/dist/packages/excalidraw/types.js +6 -0
- package/dist/packages/excalidraw/utility-types.js +1 -0
- package/dist/packages/excalidraw/utils.js +668 -0
- package/dist/packages/excalidraw/zindex.js +349 -0
- package/dist/packages/utils/bbox.js +42 -0
- package/dist/packages/utils/export.js +109 -0
- package/dist/packages/utils/withinBounds.js +125 -0
- package/dist/public/fonts/Assistant-Bold.woff2 +0 -0
- package/dist/public/fonts/Assistant-Medium.woff2 +0 -0
- package/dist/public/fonts/Assistant-Regular.woff2 +0 -0
- package/dist/public/fonts/Assistant-SemiBold.woff2 +0 -0
- package/dist/public/fonts/Cascadia.ttf +0 -0
- package/dist/public/fonts/Cascadia.woff2 +0 -0
- package/dist/public/fonts/FG_Virgil.ttf +0 -0
- package/dist/public/fonts/FG_Virgil.woff2 +0 -0
- package/dist/public/fonts/Virgil.woff2 +0 -0
- package/dist/public/fonts/fonts.css +38 -0
- package/package.json +8 -6
- package/dist/index.css +0 -5796
- package/dist/index.js +0 -71305
- /package/{types → dist/packages}/excalidraw/actions/actionAddToLibrary.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionAlign.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionBoundText.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionClipboard.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDeleteSelected.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDistribute.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDuplicateSelection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionElementLock.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionExport.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFinalize.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFlip.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFrame.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionHistory.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionLinearEditor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionNavigate.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionProperties.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionSelectAll.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionStyles.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleGridMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleStats.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleViewMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleZenMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionZindex.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/manager.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/register.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/shortcuts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/types.d.ts +0 -0
- /package/{types/excalidraw/index-node.d.ts → dist/packages/excalidraw/actions/types.js} +0 -0
- /package/{types → dist/packages}/excalidraw/align.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/analytics.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/appState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/charts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/clients.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/clipboard.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/colors.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Actions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ActiveConfirmDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/App.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Avatar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/BraveMeasureTextError.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Button.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonIconCycle.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonIconSelect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonSelect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Card.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/CheckboxItem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorInput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorPicker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/CustomColorList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/Picker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerColorList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerHeading.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ShadeList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/TopPicks.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ConfirmDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ContextMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DarkModeToggle.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DefaultSidebar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Dialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DialogActionButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ErrorDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ExcalidrawLogo.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/EyeDropper.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FilledButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FixedSideContainer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FollowMode/FollowMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HandButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HelpButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HelpDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HintViewer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/IconPicker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ImageExportDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/InitializeApp.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/InlineIcon.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Island.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/JSONExportDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPathManager.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPointerButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserTool.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LayerUI.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuBrowseButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuControlButtons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuHeaderContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuItems.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuSection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryUnit.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LoadingMessage.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LockButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MagicButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MagicSettings.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MobileMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Modal.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Paragraph.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PasteChartDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PenModeButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Popover.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ProjectName.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PublishLibrary.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/RadioGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Section.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ShareableLinkDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/Sidebar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarHeader.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTab.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabs.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Spinner.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Stack.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Stats.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Switch.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TextField.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Toast.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ToolButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Tooltip.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Trans.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/UserList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/StaticCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuSeparator.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/footer/Footer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/footer/FooterCenter.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/hoc/withInternalFallback.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/icons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/main-menu/DefaultItems.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/main-menu/MainMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/constants.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/context/tunnels.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/context/ui-appState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/cursor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/EditorLocalStorage.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/ai/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/blob.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/encode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/encryption.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/filesystem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/image.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/json.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/library.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/magic.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/resave.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/restore.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/transform.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/url.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/distribute.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/ElementCanvasButtons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/Hyperlink.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/binding.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/bounds.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/collision.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/dragElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/embeddable.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/image.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/linearElementEditor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/mutateElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/newElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/resizeElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/resizeTest.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/showSelectedShapeActions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/sizeHelpers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/sortElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/textElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/textWysiwyg.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/transformHandles.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/typeChecks.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/emitter.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/errors.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/frame.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/ga.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gadirections.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/galines.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gapoints.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gatransforms.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gesture.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/groups.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/history.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useCallbackRefState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useCreatePortalContainer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useLibraryItemSvg.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useOutsideClick.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useScrollPosition.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useStable.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useTransition.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/i18n.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/jotai.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/keys.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/math.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/points.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/polyfill.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/random.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderScene.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderSnaps.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/roundRect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Fonts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Renderer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Scene.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Shape.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/ShapeCache.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/comparisons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/export.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/scroll.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/scrollbars.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/selection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/zoom.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/shapes.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/snapping.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/utility-types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/utils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/zindex.d.ts +0 -0
- /package/{types → dist/packages}/utils/bbox.d.ts +0 -0
- /package/{types → dist/packages}/utils/export.d.ts +0 -0
- /package/{types → dist/packages}/utils/withinBounds.d.ts +0 -0
|
@@ -0,0 +1,871 @@
|
|
|
1
|
+
import { isTextElement, isLinearElement, isFreeDrawElement, isInitializedImageElement, isArrowElement, hasBoundTextElement, isMagicFrameElement, } from "../element/typeChecks";
|
|
2
|
+
import { getElementAbsoluteCoords } from "../element/bounds";
|
|
3
|
+
import { distance, getFontString, getFontFamilyString, isRTL, isTestEnv, } from "../utils";
|
|
4
|
+
import { getCornerRadius, isPathALoop, isRightAngle } from "../math";
|
|
5
|
+
import rough from "roughjs/bin/rough";
|
|
6
|
+
import { getDefaultAppState } from "../appState";
|
|
7
|
+
import { BOUND_TEXT_PADDING, FRAME_STYLE, MAX_DECIMALS_FOR_SVG_EXPORT, MIME_TYPES, SVG_NS, } from "../constants";
|
|
8
|
+
import { getStroke } from "perfect-freehand";
|
|
9
|
+
import { getBoundTextElement, getContainerCoords, getContainerElement, getLineHeightInPx, getBoundTextMaxHeight, getBoundTextMaxWidth, } from "../element/textElement";
|
|
10
|
+
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
11
|
+
import { createPlaceholderEmbeddableLabel, getEmbedLink, } from "../element/embeddable";
|
|
12
|
+
import { getContainingFrame } from "../frame";
|
|
13
|
+
import { normalizeLink, toValidURL } from "../data/url";
|
|
14
|
+
import { ShapeCache } from "../scene/ShapeCache";
|
|
15
|
+
// using a stronger invert (100% vs our regular 93%) and saturate
|
|
16
|
+
// as a temp hack to make images in dark theme look closer to original
|
|
17
|
+
// color scheme (it's still not quite there and the colors look slightly
|
|
18
|
+
// desatured, alas...)
|
|
19
|
+
const IMAGE_INVERT_FILTER = "invert(100%) hue-rotate(180deg) saturate(1.25)";
|
|
20
|
+
const defaultAppState = getDefaultAppState();
|
|
21
|
+
const isPendingImageElement = (element, renderConfig) => isInitializedImageElement(element) &&
|
|
22
|
+
!renderConfig.imageCache.has(element.fileId);
|
|
23
|
+
const shouldResetImageFilter = (element, renderConfig, appState) => {
|
|
24
|
+
return (appState.theme === "dark" &&
|
|
25
|
+
isInitializedImageElement(element) &&
|
|
26
|
+
!isPendingImageElement(element, renderConfig) &&
|
|
27
|
+
renderConfig.imageCache.get(element.fileId)?.mimeType !== MIME_TYPES.svg);
|
|
28
|
+
};
|
|
29
|
+
const getCanvasPadding = (element) => element.type === "freedraw" ? element.strokeWidth * 12 : 20;
|
|
30
|
+
const cappedElementCanvasSize = (element, zoom) => {
|
|
31
|
+
// these limits are ballpark, they depend on specific browsers and device.
|
|
32
|
+
// We've chosen lower limits to be safe. We might want to change these limits
|
|
33
|
+
// based on browser/device type, if we get reports of low quality rendering
|
|
34
|
+
// on zoom.
|
|
35
|
+
//
|
|
36
|
+
// ~ safari mobile canvas area limit
|
|
37
|
+
const AREA_LIMIT = 16777216;
|
|
38
|
+
// ~ safari width/height limit based on developer.mozilla.org.
|
|
39
|
+
const WIDTH_HEIGHT_LIMIT = 32767;
|
|
40
|
+
const padding = getCanvasPadding(element);
|
|
41
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
42
|
+
const elementWidth = isLinearElement(element) || isFreeDrawElement(element)
|
|
43
|
+
? distance(x1, x2)
|
|
44
|
+
: element.width;
|
|
45
|
+
const elementHeight = isLinearElement(element) || isFreeDrawElement(element)
|
|
46
|
+
? distance(y1, y2)
|
|
47
|
+
: element.height;
|
|
48
|
+
let width = elementWidth * window.devicePixelRatio + padding * 2;
|
|
49
|
+
let height = elementHeight * window.devicePixelRatio + padding * 2;
|
|
50
|
+
let scale = zoom.value;
|
|
51
|
+
// rescale to ensure width and height is within limits
|
|
52
|
+
if (width * scale > WIDTH_HEIGHT_LIMIT ||
|
|
53
|
+
height * scale > WIDTH_HEIGHT_LIMIT) {
|
|
54
|
+
scale = Math.min(WIDTH_HEIGHT_LIMIT / width, WIDTH_HEIGHT_LIMIT / height);
|
|
55
|
+
}
|
|
56
|
+
// rescale to ensure canvas area is within limits
|
|
57
|
+
if (width * height * scale * scale > AREA_LIMIT) {
|
|
58
|
+
scale = Math.sqrt(AREA_LIMIT / (width * height));
|
|
59
|
+
}
|
|
60
|
+
width = Math.floor(width * scale);
|
|
61
|
+
height = Math.floor(height * scale);
|
|
62
|
+
return { width, height, scale };
|
|
63
|
+
};
|
|
64
|
+
const generateElementCanvas = (element, zoom, renderConfig, appState) => {
|
|
65
|
+
const canvas = document.createElement("canvas");
|
|
66
|
+
const context = canvas.getContext("2d");
|
|
67
|
+
const padding = getCanvasPadding(element);
|
|
68
|
+
const { width, height, scale } = cappedElementCanvasSize(element, zoom);
|
|
69
|
+
canvas.width = width;
|
|
70
|
+
canvas.height = height;
|
|
71
|
+
let canvasOffsetX = 0;
|
|
72
|
+
let canvasOffsetY = 0;
|
|
73
|
+
if (isLinearElement(element) || isFreeDrawElement(element)) {
|
|
74
|
+
const [x1, y1] = getElementAbsoluteCoords(element);
|
|
75
|
+
canvasOffsetX =
|
|
76
|
+
element.x > x1
|
|
77
|
+
? distance(element.x, x1) * window.devicePixelRatio * scale
|
|
78
|
+
: 0;
|
|
79
|
+
canvasOffsetY =
|
|
80
|
+
element.y > y1
|
|
81
|
+
? distance(element.y, y1) * window.devicePixelRatio * scale
|
|
82
|
+
: 0;
|
|
83
|
+
context.translate(canvasOffsetX, canvasOffsetY);
|
|
84
|
+
}
|
|
85
|
+
context.save();
|
|
86
|
+
context.translate(padding * scale, padding * scale);
|
|
87
|
+
context.scale(window.devicePixelRatio * scale, window.devicePixelRatio * scale);
|
|
88
|
+
const rc = rough.canvas(canvas);
|
|
89
|
+
// in dark theme, revert the image color filter
|
|
90
|
+
if (shouldResetImageFilter(element, renderConfig, appState)) {
|
|
91
|
+
context.filter = IMAGE_INVERT_FILTER;
|
|
92
|
+
}
|
|
93
|
+
drawElementOnCanvas(element, rc, context, renderConfig, appState);
|
|
94
|
+
context.restore();
|
|
95
|
+
return {
|
|
96
|
+
element,
|
|
97
|
+
canvas,
|
|
98
|
+
theme: appState.theme,
|
|
99
|
+
scale,
|
|
100
|
+
zoomValue: zoom.value,
|
|
101
|
+
canvasOffsetX,
|
|
102
|
+
canvasOffsetY,
|
|
103
|
+
boundTextElementVersion: getBoundTextElement(element)?.version || null,
|
|
104
|
+
containingFrameOpacity: getContainingFrame(element)?.opacity || 100,
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
export const DEFAULT_LINK_SIZE = 14;
|
|
108
|
+
const IMAGE_PLACEHOLDER_IMG = document.createElement("img");
|
|
109
|
+
IMAGE_PLACEHOLDER_IMG.src = `data:${MIME_TYPES.svg},${encodeURIComponent(`<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>`)}`;
|
|
110
|
+
const IMAGE_ERROR_PLACEHOLDER_IMG = document.createElement("img");
|
|
111
|
+
IMAGE_ERROR_PLACEHOLDER_IMG.src = `data:${MIME_TYPES.svg},${encodeURIComponent(`<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>`)}`;
|
|
112
|
+
const drawImagePlaceholder = (element, context, zoomValue) => {
|
|
113
|
+
context.fillStyle = "#E7E7E7";
|
|
114
|
+
context.fillRect(0, 0, element.width, element.height);
|
|
115
|
+
const imageMinWidthOrHeight = Math.min(element.width, element.height);
|
|
116
|
+
const size = Math.min(imageMinWidthOrHeight, Math.min(imageMinWidthOrHeight * 0.4, 100));
|
|
117
|
+
context.drawImage(element.status === "error"
|
|
118
|
+
? IMAGE_ERROR_PLACEHOLDER_IMG
|
|
119
|
+
: IMAGE_PLACEHOLDER_IMG, element.width / 2 - size / 2, element.height / 2 - size / 2, size, size);
|
|
120
|
+
};
|
|
121
|
+
const drawElementOnCanvas = (element, rc, context, renderConfig, appState) => {
|
|
122
|
+
context.globalAlpha =
|
|
123
|
+
((getContainingFrame(element)?.opacity ?? 100) * element.opacity) / 10000;
|
|
124
|
+
switch (element.type) {
|
|
125
|
+
case "rectangle":
|
|
126
|
+
case "iframe":
|
|
127
|
+
case "embeddable":
|
|
128
|
+
case "diamond":
|
|
129
|
+
case "ellipse": {
|
|
130
|
+
context.lineJoin = "round";
|
|
131
|
+
context.lineCap = "round";
|
|
132
|
+
rc.draw(ShapeCache.get(element));
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "arrow":
|
|
136
|
+
case "line": {
|
|
137
|
+
context.lineJoin = "round";
|
|
138
|
+
context.lineCap = "round";
|
|
139
|
+
ShapeCache.get(element).forEach((shape) => {
|
|
140
|
+
rc.draw(shape);
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case "freedraw": {
|
|
145
|
+
// Draw directly to canvas
|
|
146
|
+
context.save();
|
|
147
|
+
context.fillStyle = element.strokeColor;
|
|
148
|
+
const path = getFreeDrawPath2D(element);
|
|
149
|
+
const fillShape = ShapeCache.get(element);
|
|
150
|
+
if (fillShape) {
|
|
151
|
+
rc.draw(fillShape);
|
|
152
|
+
}
|
|
153
|
+
context.fillStyle = element.strokeColor;
|
|
154
|
+
context.fill(path);
|
|
155
|
+
context.restore();
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case "image": {
|
|
159
|
+
const img = isInitializedImageElement(element)
|
|
160
|
+
? renderConfig.imageCache.get(element.fileId)?.image
|
|
161
|
+
: undefined;
|
|
162
|
+
if (img != null && !(img instanceof Promise)) {
|
|
163
|
+
context.drawImage(img, 0 /* hardcoded for the selection box*/, 0, element.width, element.height);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
drawImagePlaceholder(element, context, appState.zoom.value);
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
default: {
|
|
171
|
+
if (isTextElement(element)) {
|
|
172
|
+
const rtl = isRTL(element.text);
|
|
173
|
+
const shouldTemporarilyAttach = rtl && !context.canvas.isConnected;
|
|
174
|
+
if (shouldTemporarilyAttach) {
|
|
175
|
+
// to correctly render RTL text mixed with LTR, we have to append it
|
|
176
|
+
// to the DOM
|
|
177
|
+
document.body.appendChild(context.canvas);
|
|
178
|
+
}
|
|
179
|
+
context.canvas.setAttribute("dir", rtl ? "rtl" : "ltr");
|
|
180
|
+
context.save();
|
|
181
|
+
context.font = getFontString(element);
|
|
182
|
+
context.fillStyle = element.strokeColor;
|
|
183
|
+
context.textAlign = element.textAlign;
|
|
184
|
+
// Canvas does not support multiline text by default
|
|
185
|
+
const lines = element.text.replace(/\r\n?/g, "\n").split("\n");
|
|
186
|
+
const horizontalOffset = element.textAlign === "center"
|
|
187
|
+
? element.width / 2
|
|
188
|
+
: element.textAlign === "right"
|
|
189
|
+
? element.width
|
|
190
|
+
: 0;
|
|
191
|
+
const lineHeightPx = getLineHeightInPx(element.fontSize, element.lineHeight);
|
|
192
|
+
const verticalOffset = element.height - element.baseline;
|
|
193
|
+
for (let index = 0; index < lines.length; index++) {
|
|
194
|
+
context.fillText(lines[index], horizontalOffset, (index + 1) * lineHeightPx - verticalOffset);
|
|
195
|
+
}
|
|
196
|
+
context.restore();
|
|
197
|
+
if (shouldTemporarilyAttach) {
|
|
198
|
+
context.canvas.remove();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
throw new Error(`Unimplemented type ${element.type}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
context.globalAlpha = 1;
|
|
207
|
+
};
|
|
208
|
+
export const elementWithCanvasCache = new WeakMap();
|
|
209
|
+
const generateElementWithCanvas = (element, renderConfig, appState) => {
|
|
210
|
+
const zoom = renderConfig ? appState.zoom : defaultAppState.zoom;
|
|
211
|
+
const prevElementWithCanvas = elementWithCanvasCache.get(element);
|
|
212
|
+
const shouldRegenerateBecauseZoom = prevElementWithCanvas &&
|
|
213
|
+
prevElementWithCanvas.zoomValue !== zoom.value &&
|
|
214
|
+
!appState?.shouldCacheIgnoreZoom;
|
|
215
|
+
const boundTextElementVersion = getBoundTextElement(element)?.version || null;
|
|
216
|
+
const containingFrameOpacity = getContainingFrame(element)?.opacity || 100;
|
|
217
|
+
if (!prevElementWithCanvas ||
|
|
218
|
+
shouldRegenerateBecauseZoom ||
|
|
219
|
+
prevElementWithCanvas.theme !== appState.theme ||
|
|
220
|
+
prevElementWithCanvas.boundTextElementVersion !== boundTextElementVersion ||
|
|
221
|
+
prevElementWithCanvas.containingFrameOpacity !== containingFrameOpacity) {
|
|
222
|
+
const elementWithCanvas = generateElementCanvas(element, zoom, renderConfig, appState);
|
|
223
|
+
elementWithCanvasCache.set(element, elementWithCanvas);
|
|
224
|
+
return elementWithCanvas;
|
|
225
|
+
}
|
|
226
|
+
return prevElementWithCanvas;
|
|
227
|
+
};
|
|
228
|
+
const drawElementFromCanvas = (elementWithCanvas, context, renderConfig, appState) => {
|
|
229
|
+
const element = elementWithCanvas.element;
|
|
230
|
+
const padding = getCanvasPadding(element);
|
|
231
|
+
const zoom = elementWithCanvas.scale;
|
|
232
|
+
let [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
233
|
+
// Free draw elements will otherwise "shuffle" as the min x and y change
|
|
234
|
+
if (isFreeDrawElement(element)) {
|
|
235
|
+
x1 = Math.floor(x1);
|
|
236
|
+
x2 = Math.ceil(x2);
|
|
237
|
+
y1 = Math.floor(y1);
|
|
238
|
+
y2 = Math.ceil(y2);
|
|
239
|
+
}
|
|
240
|
+
const cx = ((x1 + x2) / 2 + appState.scrollX) * window.devicePixelRatio;
|
|
241
|
+
const cy = ((y1 + y2) / 2 + appState.scrollY) * window.devicePixelRatio;
|
|
242
|
+
context.save();
|
|
243
|
+
context.scale(1 / window.devicePixelRatio, 1 / window.devicePixelRatio);
|
|
244
|
+
const boundTextElement = getBoundTextElement(element);
|
|
245
|
+
if (isArrowElement(element) && boundTextElement) {
|
|
246
|
+
const tempCanvas = document.createElement("canvas");
|
|
247
|
+
const tempCanvasContext = tempCanvas.getContext("2d");
|
|
248
|
+
// Take max dimensions of arrow canvas so that when canvas is rotated
|
|
249
|
+
// the arrow doesn't get clipped
|
|
250
|
+
const maxDim = Math.max(distance(x1, x2), distance(y1, y2));
|
|
251
|
+
tempCanvas.width =
|
|
252
|
+
maxDim * window.devicePixelRatio * zoom +
|
|
253
|
+
padding * elementWithCanvas.scale * 10;
|
|
254
|
+
tempCanvas.height =
|
|
255
|
+
maxDim * window.devicePixelRatio * zoom +
|
|
256
|
+
padding * elementWithCanvas.scale * 10;
|
|
257
|
+
const offsetX = (tempCanvas.width - elementWithCanvas.canvas.width) / 2;
|
|
258
|
+
const offsetY = (tempCanvas.height - elementWithCanvas.canvas.height) / 2;
|
|
259
|
+
tempCanvasContext.translate(tempCanvas.width / 2, tempCanvas.height / 2);
|
|
260
|
+
tempCanvasContext.rotate(element.angle);
|
|
261
|
+
tempCanvasContext.drawImage(elementWithCanvas.canvas, -elementWithCanvas.canvas.width / 2, -elementWithCanvas.canvas.height / 2, elementWithCanvas.canvas.width, elementWithCanvas.canvas.height);
|
|
262
|
+
const [, , , , boundTextCx, boundTextCy] = getElementAbsoluteCoords(boundTextElement);
|
|
263
|
+
tempCanvasContext.rotate(-element.angle);
|
|
264
|
+
// Shift the canvas to the center of the bound text element
|
|
265
|
+
const shiftX = tempCanvas.width / 2 -
|
|
266
|
+
(boundTextCx - x1) * window.devicePixelRatio * zoom -
|
|
267
|
+
offsetX -
|
|
268
|
+
padding * zoom;
|
|
269
|
+
const shiftY = tempCanvas.height / 2 -
|
|
270
|
+
(boundTextCy - y1) * window.devicePixelRatio * zoom -
|
|
271
|
+
offsetY -
|
|
272
|
+
padding * zoom;
|
|
273
|
+
tempCanvasContext.translate(-shiftX, -shiftY);
|
|
274
|
+
// Clear the bound text area
|
|
275
|
+
tempCanvasContext.clearRect(-(boundTextElement.width / 2 + BOUND_TEXT_PADDING) *
|
|
276
|
+
window.devicePixelRatio *
|
|
277
|
+
zoom, -(boundTextElement.height / 2 + BOUND_TEXT_PADDING) *
|
|
278
|
+
window.devicePixelRatio *
|
|
279
|
+
zoom, (boundTextElement.width + BOUND_TEXT_PADDING * 2) *
|
|
280
|
+
window.devicePixelRatio *
|
|
281
|
+
zoom, (boundTextElement.height + BOUND_TEXT_PADDING * 2) *
|
|
282
|
+
window.devicePixelRatio *
|
|
283
|
+
zoom);
|
|
284
|
+
context.translate(cx, cy);
|
|
285
|
+
context.drawImage(tempCanvas, (-(x2 - x1) / 2) * window.devicePixelRatio - offsetX / zoom - padding, (-(y2 - y1) / 2) * window.devicePixelRatio - offsetY / zoom - padding, tempCanvas.width / zoom, tempCanvas.height / zoom);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
// we translate context to element center so that rotation and scale
|
|
289
|
+
// originates from the element center
|
|
290
|
+
context.translate(cx, cy);
|
|
291
|
+
context.rotate(element.angle);
|
|
292
|
+
if ("scale" in elementWithCanvas.element &&
|
|
293
|
+
!isPendingImageElement(element, renderConfig)) {
|
|
294
|
+
context.scale(elementWithCanvas.element.scale[0], elementWithCanvas.element.scale[1]);
|
|
295
|
+
}
|
|
296
|
+
// revert afterwards we don't have account for it during drawing
|
|
297
|
+
context.translate(-cx, -cy);
|
|
298
|
+
context.drawImage(elementWithCanvas.canvas, (x1 + appState.scrollX) * window.devicePixelRatio -
|
|
299
|
+
(padding * elementWithCanvas.scale) / elementWithCanvas.scale, (y1 + appState.scrollY) * window.devicePixelRatio -
|
|
300
|
+
(padding * elementWithCanvas.scale) / elementWithCanvas.scale, elementWithCanvas.canvas.width / elementWithCanvas.scale, elementWithCanvas.canvas.height / elementWithCanvas.scale);
|
|
301
|
+
if (import.meta.env.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX ===
|
|
302
|
+
"true" &&
|
|
303
|
+
hasBoundTextElement(element)) {
|
|
304
|
+
const textElement = getBoundTextElement(element);
|
|
305
|
+
const coords = getContainerCoords(element);
|
|
306
|
+
context.strokeStyle = "#c92a2a";
|
|
307
|
+
context.lineWidth = 3;
|
|
308
|
+
context.strokeRect((coords.x + appState.scrollX) * window.devicePixelRatio, (coords.y + appState.scrollY) * window.devicePixelRatio, getBoundTextMaxWidth(element) * window.devicePixelRatio, getBoundTextMaxHeight(element, textElement) * window.devicePixelRatio);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
context.restore();
|
|
312
|
+
// Clear the nested element we appended to the DOM
|
|
313
|
+
};
|
|
314
|
+
export const renderSelectionElement = (element, context, appState) => {
|
|
315
|
+
context.save();
|
|
316
|
+
context.translate(element.x + appState.scrollX, element.y + appState.scrollY);
|
|
317
|
+
context.fillStyle = "rgba(0, 0, 200, 0.04)";
|
|
318
|
+
// render from 0.5px offset to get 1px wide line
|
|
319
|
+
// https://stackoverflow.com/questions/7530593/html5-canvas-and-line-width/7531540#7531540
|
|
320
|
+
// TODO can be be improved by offseting to the negative when user selects
|
|
321
|
+
// from right to left
|
|
322
|
+
const offset = 0.5 / appState.zoom.value;
|
|
323
|
+
context.fillRect(offset, offset, element.width, element.height);
|
|
324
|
+
context.lineWidth = 1 / appState.zoom.value;
|
|
325
|
+
context.strokeStyle = " rgb(105, 101, 219)";
|
|
326
|
+
context.strokeRect(offset, offset, element.width, element.height);
|
|
327
|
+
context.restore();
|
|
328
|
+
};
|
|
329
|
+
export const renderElement = (element, rc, context, renderConfig, appState) => {
|
|
330
|
+
switch (element.type) {
|
|
331
|
+
case "magicframe":
|
|
332
|
+
case "frame": {
|
|
333
|
+
if (appState.frameRendering.enabled && appState.frameRendering.outline) {
|
|
334
|
+
context.save();
|
|
335
|
+
context.translate(element.x + appState.scrollX, element.y + appState.scrollY);
|
|
336
|
+
context.fillStyle = "rgba(0, 0, 200, 0.04)";
|
|
337
|
+
context.lineWidth = FRAME_STYLE.strokeWidth / appState.zoom.value;
|
|
338
|
+
context.strokeStyle = FRAME_STYLE.strokeColor;
|
|
339
|
+
// TODO change later to only affect AI frames
|
|
340
|
+
if (isMagicFrameElement(element)) {
|
|
341
|
+
context.strokeStyle =
|
|
342
|
+
appState.theme === "light" ? "#7affd7" : "#1d8264";
|
|
343
|
+
}
|
|
344
|
+
if (FRAME_STYLE.radius && context.roundRect) {
|
|
345
|
+
context.beginPath();
|
|
346
|
+
context.roundRect(0, 0, element.width, element.height, FRAME_STYLE.radius / appState.zoom.value);
|
|
347
|
+
context.stroke();
|
|
348
|
+
context.closePath();
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
context.strokeRect(0, 0, element.width, element.height);
|
|
352
|
+
}
|
|
353
|
+
context.restore();
|
|
354
|
+
}
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
case "freedraw": {
|
|
358
|
+
// TODO investigate if we can do this in situ. Right now we need to call
|
|
359
|
+
// beforehand because math helpers (such as getElementAbsoluteCoords)
|
|
360
|
+
// rely on existing shapes
|
|
361
|
+
ShapeCache.generateElementShape(element, null);
|
|
362
|
+
if (renderConfig.isExporting) {
|
|
363
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
364
|
+
const cx = (x1 + x2) / 2 + appState.scrollX;
|
|
365
|
+
const cy = (y1 + y2) / 2 + appState.scrollY;
|
|
366
|
+
const shiftX = (x2 - x1) / 2 - (element.x - x1);
|
|
367
|
+
const shiftY = (y2 - y1) / 2 - (element.y - y1);
|
|
368
|
+
context.save();
|
|
369
|
+
context.translate(cx, cy);
|
|
370
|
+
context.rotate(element.angle);
|
|
371
|
+
context.translate(-shiftX, -shiftY);
|
|
372
|
+
drawElementOnCanvas(element, rc, context, renderConfig, appState);
|
|
373
|
+
context.restore();
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
const elementWithCanvas = generateElementWithCanvas(element, renderConfig, appState);
|
|
377
|
+
drawElementFromCanvas(elementWithCanvas, context, renderConfig, appState);
|
|
378
|
+
}
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
case "rectangle":
|
|
382
|
+
case "diamond":
|
|
383
|
+
case "ellipse":
|
|
384
|
+
case "line":
|
|
385
|
+
case "arrow":
|
|
386
|
+
case "image":
|
|
387
|
+
case "text":
|
|
388
|
+
case "iframe":
|
|
389
|
+
case "embeddable": {
|
|
390
|
+
// TODO investigate if we can do this in situ. Right now we need to call
|
|
391
|
+
// beforehand because math helpers (such as getElementAbsoluteCoords)
|
|
392
|
+
// rely on existing shapes
|
|
393
|
+
ShapeCache.generateElementShape(element, renderConfig);
|
|
394
|
+
if (renderConfig.isExporting) {
|
|
395
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
396
|
+
const cx = (x1 + x2) / 2 + appState.scrollX;
|
|
397
|
+
const cy = (y1 + y2) / 2 + appState.scrollY;
|
|
398
|
+
let shiftX = (x2 - x1) / 2 - (element.x - x1);
|
|
399
|
+
let shiftY = (y2 - y1) / 2 - (element.y - y1);
|
|
400
|
+
if (isTextElement(element)) {
|
|
401
|
+
const container = getContainerElement(element);
|
|
402
|
+
if (isArrowElement(container)) {
|
|
403
|
+
const boundTextCoords = LinearElementEditor.getBoundTextElementPosition(container, element);
|
|
404
|
+
shiftX = (x2 - x1) / 2 - (boundTextCoords.x - x1);
|
|
405
|
+
shiftY = (y2 - y1) / 2 - (boundTextCoords.y - y1);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
context.save();
|
|
409
|
+
context.translate(cx, cy);
|
|
410
|
+
if (shouldResetImageFilter(element, renderConfig, appState)) {
|
|
411
|
+
context.filter = "none";
|
|
412
|
+
}
|
|
413
|
+
const boundTextElement = getBoundTextElement(element);
|
|
414
|
+
if (isArrowElement(element) && boundTextElement) {
|
|
415
|
+
const tempCanvas = document.createElement("canvas");
|
|
416
|
+
const tempCanvasContext = tempCanvas.getContext("2d");
|
|
417
|
+
// Take max dimensions of arrow canvas so that when canvas is rotated
|
|
418
|
+
// the arrow doesn't get clipped
|
|
419
|
+
const maxDim = Math.max(distance(x1, x2), distance(y1, y2));
|
|
420
|
+
const padding = getCanvasPadding(element);
|
|
421
|
+
tempCanvas.width =
|
|
422
|
+
maxDim * appState.exportScale + padding * 10 * appState.exportScale;
|
|
423
|
+
tempCanvas.height =
|
|
424
|
+
maxDim * appState.exportScale + padding * 10 * appState.exportScale;
|
|
425
|
+
tempCanvasContext.translate(tempCanvas.width / 2, tempCanvas.height / 2);
|
|
426
|
+
tempCanvasContext.scale(appState.exportScale, appState.exportScale);
|
|
427
|
+
// Shift the canvas to left most point of the arrow
|
|
428
|
+
shiftX = element.width / 2 - (element.x - x1);
|
|
429
|
+
shiftY = element.height / 2 - (element.y - y1);
|
|
430
|
+
tempCanvasContext.rotate(element.angle);
|
|
431
|
+
const tempRc = rough.canvas(tempCanvas);
|
|
432
|
+
tempCanvasContext.translate(-shiftX, -shiftY);
|
|
433
|
+
drawElementOnCanvas(element, tempRc, tempCanvasContext, renderConfig, appState);
|
|
434
|
+
tempCanvasContext.translate(shiftX, shiftY);
|
|
435
|
+
tempCanvasContext.rotate(-element.angle);
|
|
436
|
+
// Shift the canvas to center of bound text
|
|
437
|
+
const [, , , , boundTextCx, boundTextCy] = getElementAbsoluteCoords(boundTextElement);
|
|
438
|
+
const boundTextShiftX = (x1 + x2) / 2 - boundTextCx;
|
|
439
|
+
const boundTextShiftY = (y1 + y2) / 2 - boundTextCy;
|
|
440
|
+
tempCanvasContext.translate(-boundTextShiftX, -boundTextShiftY);
|
|
441
|
+
// Clear the bound text area
|
|
442
|
+
tempCanvasContext.clearRect(-boundTextElement.width / 2, -boundTextElement.height / 2, boundTextElement.width, boundTextElement.height);
|
|
443
|
+
context.scale(1 / appState.exportScale, 1 / appState.exportScale);
|
|
444
|
+
context.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2, tempCanvas.width, tempCanvas.height);
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
context.rotate(element.angle);
|
|
448
|
+
if (element.type === "image") {
|
|
449
|
+
// note: scale must be applied *after* rotating
|
|
450
|
+
context.scale(element.scale[0], element.scale[1]);
|
|
451
|
+
}
|
|
452
|
+
context.translate(-shiftX, -shiftY);
|
|
453
|
+
drawElementOnCanvas(element, rc, context, renderConfig, appState);
|
|
454
|
+
}
|
|
455
|
+
context.restore();
|
|
456
|
+
// not exporting → optimized rendering (cache & render from element
|
|
457
|
+
// canvases)
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
const elementWithCanvas = generateElementWithCanvas(element, renderConfig, appState);
|
|
461
|
+
const currentImageSmoothingStatus = context.imageSmoothingEnabled;
|
|
462
|
+
if (
|
|
463
|
+
// do not disable smoothing during zoom as blurry shapes look better
|
|
464
|
+
// on low resolution (while still zooming in) than sharp ones
|
|
465
|
+
!appState?.shouldCacheIgnoreZoom &&
|
|
466
|
+
// angle is 0 -> always disable smoothing
|
|
467
|
+
(!element.angle ||
|
|
468
|
+
// or check if angle is a right angle in which case we can still
|
|
469
|
+
// disable smoothing without adversely affecting the result
|
|
470
|
+
isRightAngle(element.angle))) {
|
|
471
|
+
// Disabling smoothing makes output much sharper, especially for
|
|
472
|
+
// text. Unless for non-right angles, where the aliasing is really
|
|
473
|
+
// terrible on Chromium.
|
|
474
|
+
//
|
|
475
|
+
// Note that `context.imageSmoothingQuality="high"` has almost
|
|
476
|
+
// zero effect.
|
|
477
|
+
//
|
|
478
|
+
context.imageSmoothingEnabled = false;
|
|
479
|
+
}
|
|
480
|
+
drawElementFromCanvas(elementWithCanvas, context, renderConfig, appState);
|
|
481
|
+
// reset
|
|
482
|
+
context.imageSmoothingEnabled = currentImageSmoothingStatus;
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
default: {
|
|
487
|
+
// @ts-ignore
|
|
488
|
+
throw new Error(`Unimplemented type ${element.type}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
const roughSVGDrawWithPrecision = (rsvg, drawable, precision) => {
|
|
493
|
+
if (typeof precision === "undefined") {
|
|
494
|
+
return rsvg.draw(drawable);
|
|
495
|
+
}
|
|
496
|
+
const pshape = {
|
|
497
|
+
sets: drawable.sets,
|
|
498
|
+
shape: drawable.shape,
|
|
499
|
+
options: { ...drawable.options, fixedDecimalPlaceDigits: precision },
|
|
500
|
+
};
|
|
501
|
+
return rsvg.draw(pshape);
|
|
502
|
+
};
|
|
503
|
+
const maybeWrapNodesInFrameClipPath = (element, root, nodes, frameRendering) => {
|
|
504
|
+
if (!frameRendering.enabled || !frameRendering.clip) {
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
const frame = getContainingFrame(element);
|
|
508
|
+
if (frame) {
|
|
509
|
+
const g = root.ownerDocument.createElementNS(SVG_NS, "g");
|
|
510
|
+
g.setAttributeNS(SVG_NS, "clip-path", `url(#${frame.id})`);
|
|
511
|
+
nodes.forEach((node) => g.appendChild(node));
|
|
512
|
+
return g;
|
|
513
|
+
}
|
|
514
|
+
return null;
|
|
515
|
+
};
|
|
516
|
+
export const renderElementToSvg = (element, rsvg, svgRoot, files, offsetX, offsetY, renderConfig) => {
|
|
517
|
+
const offset = { x: offsetX, y: offsetY };
|
|
518
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
519
|
+
let cx = (x2 - x1) / 2 - (element.x - x1);
|
|
520
|
+
let cy = (y2 - y1) / 2 - (element.y - y1);
|
|
521
|
+
if (isTextElement(element)) {
|
|
522
|
+
const container = getContainerElement(element);
|
|
523
|
+
if (isArrowElement(container)) {
|
|
524
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(container);
|
|
525
|
+
const boundTextCoords = LinearElementEditor.getBoundTextElementPosition(container, element);
|
|
526
|
+
cx = (x2 - x1) / 2 - (boundTextCoords.x - x1);
|
|
527
|
+
cy = (y2 - y1) / 2 - (boundTextCoords.y - y1);
|
|
528
|
+
offsetX = offsetX + boundTextCoords.x - element.x;
|
|
529
|
+
offsetY = offsetY + boundTextCoords.y - element.y;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
const degree = (180 * element.angle) / Math.PI;
|
|
533
|
+
// element to append node to, most of the time svgRoot
|
|
534
|
+
let root = svgRoot;
|
|
535
|
+
// if the element has a link, create an anchor tag and make that the new root
|
|
536
|
+
if (element.link) {
|
|
537
|
+
const anchorTag = svgRoot.ownerDocument.createElementNS(SVG_NS, "a");
|
|
538
|
+
anchorTag.setAttribute("href", normalizeLink(element.link));
|
|
539
|
+
root.appendChild(anchorTag);
|
|
540
|
+
root = anchorTag;
|
|
541
|
+
}
|
|
542
|
+
const addToRoot = (node, element) => {
|
|
543
|
+
if (isTestEnv()) {
|
|
544
|
+
node.setAttribute("data-id", element.id);
|
|
545
|
+
}
|
|
546
|
+
root.appendChild(node);
|
|
547
|
+
};
|
|
548
|
+
const opacity = ((getContainingFrame(element)?.opacity ?? 100) * element.opacity) / 10000;
|
|
549
|
+
switch (element.type) {
|
|
550
|
+
case "selection": {
|
|
551
|
+
// Since this is used only during editing experience, which is canvas based,
|
|
552
|
+
// this should not happen
|
|
553
|
+
throw new Error("Selection rendering is not supported for SVG");
|
|
554
|
+
}
|
|
555
|
+
case "rectangle":
|
|
556
|
+
case "diamond":
|
|
557
|
+
case "ellipse": {
|
|
558
|
+
const shape = ShapeCache.generateElementShape(element, null);
|
|
559
|
+
const node = roughSVGDrawWithPrecision(rsvg, shape, MAX_DECIMALS_FOR_SVG_EXPORT);
|
|
560
|
+
if (opacity !== 1) {
|
|
561
|
+
node.setAttribute("stroke-opacity", `${opacity}`);
|
|
562
|
+
node.setAttribute("fill-opacity", `${opacity}`);
|
|
563
|
+
}
|
|
564
|
+
node.setAttribute("stroke-linecap", "round");
|
|
565
|
+
node.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
566
|
+
const g = maybeWrapNodesInFrameClipPath(element, root, [node], renderConfig.frameRendering);
|
|
567
|
+
addToRoot(g || node, element);
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
case "iframe":
|
|
571
|
+
case "embeddable": {
|
|
572
|
+
// render placeholder rectangle
|
|
573
|
+
const shape = ShapeCache.generateElementShape(element, renderConfig);
|
|
574
|
+
const node = roughSVGDrawWithPrecision(rsvg, shape, MAX_DECIMALS_FOR_SVG_EXPORT);
|
|
575
|
+
const opacity = element.opacity / 100;
|
|
576
|
+
if (opacity !== 1) {
|
|
577
|
+
node.setAttribute("stroke-opacity", `${opacity}`);
|
|
578
|
+
node.setAttribute("fill-opacity", `${opacity}`);
|
|
579
|
+
}
|
|
580
|
+
node.setAttribute("stroke-linecap", "round");
|
|
581
|
+
node.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
582
|
+
addToRoot(node, element);
|
|
583
|
+
const label = createPlaceholderEmbeddableLabel(element);
|
|
584
|
+
renderElementToSvg(label, rsvg, root, files, label.x + offset.x - element.x, label.y + offset.y - element.y, renderConfig);
|
|
585
|
+
// render embeddable element + iframe
|
|
586
|
+
const embeddableNode = roughSVGDrawWithPrecision(rsvg, shape, MAX_DECIMALS_FOR_SVG_EXPORT);
|
|
587
|
+
embeddableNode.setAttribute("stroke-linecap", "round");
|
|
588
|
+
embeddableNode.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
589
|
+
while (embeddableNode.firstChild) {
|
|
590
|
+
embeddableNode.removeChild(embeddableNode.firstChild);
|
|
591
|
+
}
|
|
592
|
+
const radius = getCornerRadius(Math.min(element.width, element.height), element);
|
|
593
|
+
const embedLink = getEmbedLink(toValidURL(element.link || ""));
|
|
594
|
+
// if rendering embeddables explicitly disabled or
|
|
595
|
+
// embedding documents via srcdoc (which doesn't seem to work for SVGs)
|
|
596
|
+
// replace with a link instead
|
|
597
|
+
if (renderConfig.renderEmbeddables === false ||
|
|
598
|
+
embedLink?.type === "document") {
|
|
599
|
+
const anchorTag = svgRoot.ownerDocument.createElementNS(SVG_NS, "a");
|
|
600
|
+
anchorTag.setAttribute("href", normalizeLink(element.link || ""));
|
|
601
|
+
anchorTag.setAttribute("target", "_blank");
|
|
602
|
+
anchorTag.setAttribute("rel", "noopener noreferrer");
|
|
603
|
+
anchorTag.style.borderRadius = `${radius}px`;
|
|
604
|
+
embeddableNode.appendChild(anchorTag);
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
const foreignObject = svgRoot.ownerDocument.createElementNS(SVG_NS, "foreignObject");
|
|
608
|
+
foreignObject.style.width = `${element.width}px`;
|
|
609
|
+
foreignObject.style.height = `${element.height}px`;
|
|
610
|
+
foreignObject.style.border = "none";
|
|
611
|
+
const div = foreignObject.ownerDocument.createElementNS(SVG_NS, "div");
|
|
612
|
+
div.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
|
613
|
+
div.style.width = "100%";
|
|
614
|
+
div.style.height = "100%";
|
|
615
|
+
const iframe = div.ownerDocument.createElement("iframe");
|
|
616
|
+
iframe.src = embedLink?.link ?? "";
|
|
617
|
+
iframe.style.width = "100%";
|
|
618
|
+
iframe.style.height = "100%";
|
|
619
|
+
iframe.style.border = "none";
|
|
620
|
+
iframe.style.borderRadius = `${radius}px`;
|
|
621
|
+
iframe.style.top = "0";
|
|
622
|
+
iframe.style.left = "0";
|
|
623
|
+
iframe.allowFullscreen = true;
|
|
624
|
+
div.appendChild(iframe);
|
|
625
|
+
foreignObject.appendChild(div);
|
|
626
|
+
embeddableNode.appendChild(foreignObject);
|
|
627
|
+
}
|
|
628
|
+
addToRoot(embeddableNode, element);
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
case "line":
|
|
632
|
+
case "arrow": {
|
|
633
|
+
const boundText = getBoundTextElement(element);
|
|
634
|
+
const maskPath = svgRoot.ownerDocument.createElementNS(SVG_NS, "mask");
|
|
635
|
+
if (boundText) {
|
|
636
|
+
maskPath.setAttribute("id", `mask-${element.id}`);
|
|
637
|
+
const maskRectVisible = svgRoot.ownerDocument.createElementNS(SVG_NS, "rect");
|
|
638
|
+
offsetX = offsetX || 0;
|
|
639
|
+
offsetY = offsetY || 0;
|
|
640
|
+
maskRectVisible.setAttribute("x", "0");
|
|
641
|
+
maskRectVisible.setAttribute("y", "0");
|
|
642
|
+
maskRectVisible.setAttribute("fill", "#fff");
|
|
643
|
+
maskRectVisible.setAttribute("width", `${element.width + 100 + offsetX}`);
|
|
644
|
+
maskRectVisible.setAttribute("height", `${element.height + 100 + offsetY}`);
|
|
645
|
+
maskPath.appendChild(maskRectVisible);
|
|
646
|
+
const maskRectInvisible = svgRoot.ownerDocument.createElementNS(SVG_NS, "rect");
|
|
647
|
+
const boundTextCoords = LinearElementEditor.getBoundTextElementPosition(element, boundText);
|
|
648
|
+
const maskX = offsetX + boundTextCoords.x - element.x;
|
|
649
|
+
const maskY = offsetY + boundTextCoords.y - element.y;
|
|
650
|
+
maskRectInvisible.setAttribute("x", maskX.toString());
|
|
651
|
+
maskRectInvisible.setAttribute("y", maskY.toString());
|
|
652
|
+
maskRectInvisible.setAttribute("fill", "#000");
|
|
653
|
+
maskRectInvisible.setAttribute("width", `${boundText.width}`);
|
|
654
|
+
maskRectInvisible.setAttribute("height", `${boundText.height}`);
|
|
655
|
+
maskRectInvisible.setAttribute("opacity", "1");
|
|
656
|
+
maskPath.appendChild(maskRectInvisible);
|
|
657
|
+
}
|
|
658
|
+
const group = svgRoot.ownerDocument.createElementNS(SVG_NS, "g");
|
|
659
|
+
if (boundText) {
|
|
660
|
+
group.setAttribute("mask", `url(#mask-${element.id})`);
|
|
661
|
+
}
|
|
662
|
+
group.setAttribute("stroke-linecap", "round");
|
|
663
|
+
const shapes = ShapeCache.generateElementShape(element, renderConfig);
|
|
664
|
+
shapes.forEach((shape) => {
|
|
665
|
+
const node = roughSVGDrawWithPrecision(rsvg, shape, MAX_DECIMALS_FOR_SVG_EXPORT);
|
|
666
|
+
if (opacity !== 1) {
|
|
667
|
+
node.setAttribute("stroke-opacity", `${opacity}`);
|
|
668
|
+
node.setAttribute("fill-opacity", `${opacity}`);
|
|
669
|
+
}
|
|
670
|
+
node.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
671
|
+
if (element.type === "line" &&
|
|
672
|
+
isPathALoop(element.points) &&
|
|
673
|
+
element.backgroundColor !== "transparent") {
|
|
674
|
+
node.setAttribute("fill-rule", "evenodd");
|
|
675
|
+
}
|
|
676
|
+
group.appendChild(node);
|
|
677
|
+
});
|
|
678
|
+
const g = maybeWrapNodesInFrameClipPath(element, root, [group, maskPath], renderConfig.frameRendering);
|
|
679
|
+
if (g) {
|
|
680
|
+
addToRoot(g, element);
|
|
681
|
+
root.appendChild(g);
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
addToRoot(group, element);
|
|
685
|
+
root.append(maskPath);
|
|
686
|
+
}
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
case "freedraw": {
|
|
690
|
+
const backgroundFillShape = ShapeCache.generateElementShape(element, renderConfig);
|
|
691
|
+
const node = backgroundFillShape
|
|
692
|
+
? roughSVGDrawWithPrecision(rsvg, backgroundFillShape, MAX_DECIMALS_FOR_SVG_EXPORT)
|
|
693
|
+
: svgRoot.ownerDocument.createElementNS(SVG_NS, "g");
|
|
694
|
+
if (opacity !== 1) {
|
|
695
|
+
node.setAttribute("stroke-opacity", `${opacity}`);
|
|
696
|
+
node.setAttribute("fill-opacity", `${opacity}`);
|
|
697
|
+
}
|
|
698
|
+
node.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
699
|
+
node.setAttribute("stroke", "none");
|
|
700
|
+
const path = svgRoot.ownerDocument.createElementNS(SVG_NS, "path");
|
|
701
|
+
path.setAttribute("fill", element.strokeColor);
|
|
702
|
+
path.setAttribute("d", getFreeDrawSvgPath(element));
|
|
703
|
+
node.appendChild(path);
|
|
704
|
+
const g = maybeWrapNodesInFrameClipPath(element, root, [node], renderConfig.frameRendering);
|
|
705
|
+
addToRoot(g || node, element);
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
case "image": {
|
|
709
|
+
const width = Math.round(element.width);
|
|
710
|
+
const height = Math.round(element.height);
|
|
711
|
+
const fileData = isInitializedImageElement(element) && files[element.fileId];
|
|
712
|
+
if (fileData) {
|
|
713
|
+
const symbolId = `image-${fileData.id}`;
|
|
714
|
+
let symbol = svgRoot.querySelector(`#${symbolId}`);
|
|
715
|
+
if (!symbol) {
|
|
716
|
+
symbol = svgRoot.ownerDocument.createElementNS(SVG_NS, "symbol");
|
|
717
|
+
symbol.id = symbolId;
|
|
718
|
+
const image = svgRoot.ownerDocument.createElementNS(SVG_NS, "image");
|
|
719
|
+
image.setAttribute("width", "100%");
|
|
720
|
+
image.setAttribute("height", "100%");
|
|
721
|
+
image.setAttribute("href", fileData.dataURL);
|
|
722
|
+
symbol.appendChild(image);
|
|
723
|
+
root.prepend(symbol);
|
|
724
|
+
}
|
|
725
|
+
const use = svgRoot.ownerDocument.createElementNS(SVG_NS, "use");
|
|
726
|
+
use.setAttribute("href", `#${symbolId}`);
|
|
727
|
+
// in dark theme, revert the image color filter
|
|
728
|
+
if (renderConfig.exportWithDarkMode &&
|
|
729
|
+
fileData.mimeType !== MIME_TYPES.svg) {
|
|
730
|
+
use.setAttribute("filter", IMAGE_INVERT_FILTER);
|
|
731
|
+
}
|
|
732
|
+
use.setAttribute("width", `${width}`);
|
|
733
|
+
use.setAttribute("height", `${height}`);
|
|
734
|
+
use.setAttribute("opacity", `${opacity}`);
|
|
735
|
+
// We first apply `scale` transforms (horizontal/vertical mirroring)
|
|
736
|
+
// on the <use> element, then apply translation and rotation
|
|
737
|
+
// on the <g> element which wraps the <use>.
|
|
738
|
+
// Doing this separately is a quick hack to to work around compositing
|
|
739
|
+
// the transformations correctly (the transform-origin was not being
|
|
740
|
+
// applied correctly).
|
|
741
|
+
if (element.scale[0] !== 1 || element.scale[1] !== 1) {
|
|
742
|
+
const translateX = element.scale[0] !== 1 ? -width : 0;
|
|
743
|
+
const translateY = element.scale[1] !== 1 ? -height : 0;
|
|
744
|
+
use.setAttribute("transform", `scale(${element.scale[0]}, ${element.scale[1]}) translate(${translateX} ${translateY})`);
|
|
745
|
+
}
|
|
746
|
+
const g = svgRoot.ownerDocument.createElementNS(SVG_NS, "g");
|
|
747
|
+
g.appendChild(use);
|
|
748
|
+
g.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
749
|
+
const clipG = maybeWrapNodesInFrameClipPath(element, root, [g], renderConfig.frameRendering);
|
|
750
|
+
addToRoot(clipG || g, element);
|
|
751
|
+
}
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
// frames are not rendered and only acts as a container
|
|
755
|
+
case "frame":
|
|
756
|
+
case "magicframe": {
|
|
757
|
+
if (renderConfig.frameRendering.enabled &&
|
|
758
|
+
renderConfig.frameRendering.outline) {
|
|
759
|
+
const rect = document.createElementNS(SVG_NS, "rect");
|
|
760
|
+
rect.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
761
|
+
rect.setAttribute("width", `${element.width}px`);
|
|
762
|
+
rect.setAttribute("height", `${element.height}px`);
|
|
763
|
+
// Rounded corners
|
|
764
|
+
rect.setAttribute("rx", FRAME_STYLE.radius.toString());
|
|
765
|
+
rect.setAttribute("ry", FRAME_STYLE.radius.toString());
|
|
766
|
+
rect.setAttribute("fill", "none");
|
|
767
|
+
rect.setAttribute("stroke", FRAME_STYLE.strokeColor);
|
|
768
|
+
rect.setAttribute("stroke-width", FRAME_STYLE.strokeWidth.toString());
|
|
769
|
+
addToRoot(rect, element);
|
|
770
|
+
}
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
default: {
|
|
774
|
+
if (isTextElement(element)) {
|
|
775
|
+
const node = svgRoot.ownerDocument.createElementNS(SVG_NS, "g");
|
|
776
|
+
if (opacity !== 1) {
|
|
777
|
+
node.setAttribute("stroke-opacity", `${opacity}`);
|
|
778
|
+
node.setAttribute("fill-opacity", `${opacity}`);
|
|
779
|
+
}
|
|
780
|
+
node.setAttribute("transform", `translate(${offsetX || 0} ${offsetY || 0}) rotate(${degree} ${cx} ${cy})`);
|
|
781
|
+
const lines = element.text.replace(/\r\n?/g, "\n").split("\n");
|
|
782
|
+
const lineHeightPx = getLineHeightInPx(element.fontSize, element.lineHeight);
|
|
783
|
+
const horizontalOffset = element.textAlign === "center"
|
|
784
|
+
? element.width / 2
|
|
785
|
+
: element.textAlign === "right"
|
|
786
|
+
? element.width
|
|
787
|
+
: 0;
|
|
788
|
+
const direction = isRTL(element.text) ? "rtl" : "ltr";
|
|
789
|
+
const textAnchor = element.textAlign === "center"
|
|
790
|
+
? "middle"
|
|
791
|
+
: element.textAlign === "right" || direction === "rtl"
|
|
792
|
+
? "end"
|
|
793
|
+
: "start";
|
|
794
|
+
for (let i = 0; i < lines.length; i++) {
|
|
795
|
+
const text = svgRoot.ownerDocument.createElementNS(SVG_NS, "text");
|
|
796
|
+
text.textContent = lines[i];
|
|
797
|
+
text.setAttribute("x", `${horizontalOffset}`);
|
|
798
|
+
text.setAttribute("y", `${i * lineHeightPx}`);
|
|
799
|
+
text.setAttribute("font-family", getFontFamilyString(element));
|
|
800
|
+
text.setAttribute("font-size", `${element.fontSize}px`);
|
|
801
|
+
text.setAttribute("fill", element.strokeColor);
|
|
802
|
+
text.setAttribute("text-anchor", textAnchor);
|
|
803
|
+
text.setAttribute("style", "white-space: pre;");
|
|
804
|
+
text.setAttribute("direction", direction);
|
|
805
|
+
text.setAttribute("dominant-baseline", "text-before-edge");
|
|
806
|
+
node.appendChild(text);
|
|
807
|
+
}
|
|
808
|
+
const g = maybeWrapNodesInFrameClipPath(element, root, [node], renderConfig.frameRendering);
|
|
809
|
+
addToRoot(g || node, element);
|
|
810
|
+
}
|
|
811
|
+
else {
|
|
812
|
+
// @ts-ignore
|
|
813
|
+
throw new Error(`Unimplemented type ${element.type}`);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
export const pathsCache = new WeakMap([]);
|
|
819
|
+
export function generateFreeDrawShape(element) {
|
|
820
|
+
const svgPathData = getFreeDrawSvgPath(element);
|
|
821
|
+
const path = new Path2D(svgPathData);
|
|
822
|
+
pathsCache.set(element, path);
|
|
823
|
+
return path;
|
|
824
|
+
}
|
|
825
|
+
export function getFreeDrawPath2D(element) {
|
|
826
|
+
return pathsCache.get(element);
|
|
827
|
+
}
|
|
828
|
+
export function getFreeDrawSvgPath(element) {
|
|
829
|
+
// If input points are empty (should they ever be?) return a dot
|
|
830
|
+
const inputPoints = element.simulatePressure
|
|
831
|
+
? element.points
|
|
832
|
+
: element.points.length
|
|
833
|
+
? element.points.map(([x, y], i) => [x, y, element.pressures[i]])
|
|
834
|
+
: [[0, 0, 0.5]];
|
|
835
|
+
// Consider changing the options for simulated pressure vs real pressure
|
|
836
|
+
const options = {
|
|
837
|
+
simulatePressure: element.simulatePressure,
|
|
838
|
+
size: element.strokeWidth * 4.25,
|
|
839
|
+
thinning: 0.6,
|
|
840
|
+
smoothing: 0.5,
|
|
841
|
+
streamline: 0.5,
|
|
842
|
+
easing: (t) => Math.sin((t * Math.PI) / 2),
|
|
843
|
+
last: !!element.lastCommittedPoint, // LastCommittedPoint is added on pointerup
|
|
844
|
+
};
|
|
845
|
+
return getSvgPathFromStroke(getStroke(inputPoints, options));
|
|
846
|
+
}
|
|
847
|
+
function med(A, B) {
|
|
848
|
+
return [(A[0] + B[0]) / 2, (A[1] + B[1]) / 2];
|
|
849
|
+
}
|
|
850
|
+
// Trim SVG path data so number are each two decimal points. This
|
|
851
|
+
// improves SVG exports, and prevents rendering errors on points
|
|
852
|
+
// with long decimals.
|
|
853
|
+
const TO_FIXED_PRECISION = /(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;
|
|
854
|
+
function getSvgPathFromStroke(points) {
|
|
855
|
+
if (!points.length) {
|
|
856
|
+
return "";
|
|
857
|
+
}
|
|
858
|
+
const max = points.length - 1;
|
|
859
|
+
return points
|
|
860
|
+
.reduce((acc, point, i, arr) => {
|
|
861
|
+
if (i === max) {
|
|
862
|
+
acc.push(point, med(point, arr[0]), "L", arr[0], "Z");
|
|
863
|
+
}
|
|
864
|
+
else {
|
|
865
|
+
acc.push(point, med(point, arr[i + 1]));
|
|
866
|
+
}
|
|
867
|
+
return acc;
|
|
868
|
+
}, ["M", points[0], "Q"])
|
|
869
|
+
.join(" ")
|
|
870
|
+
.replace(TO_FIXED_PRECISION, "$1");
|
|
871
|
+
}
|