@tldraw/editor 4.2.2 → 4.2.3
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-cjs/index.d.ts +155 -498
- package/dist-cjs/index.js +1 -6
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/ErrorBoundary.js.map +1 -1
- package/dist-cjs/lib/components/GeometryDebuggingView.js +17 -1
- package/dist-cjs/lib/components/GeometryDebuggingView.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +3 -3
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/constants.js +3 -1
- package/dist-cjs/lib/constants.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +286 -292
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +17 -18
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +3 -3
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js +3 -12
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +1 -1
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +6 -5
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +22 -1
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/BaseBoxShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +23 -31
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/DashedOutlineBox.js +1 -1
- package/dist-cjs/lib/editor/shapes/group/DashedOutlineBox.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +3 -3
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/exports/parseCss.js +1 -1
- package/dist-cjs/lib/exports/parseCss.js.map +2 -2
- package/dist-cjs/lib/globals/environment.js +9 -45
- package/dist-cjs/lib/globals/environment.js.map +2 -2
- package/dist-cjs/lib/globals/menus.js +1 -1
- package/dist-cjs/lib/globals/menus.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +3 -4
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useCoarsePointer.js +29 -14
- package/dist-cjs/lib/hooks/useCoarsePointer.js.map +2 -2
- package/dist-cjs/lib/hooks/useEvent.js +1 -1
- package/dist-cjs/lib/hooks/useEvent.js.map +2 -2
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +1 -1
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useScreenBounds.js.map +2 -2
- package/dist-cjs/lib/hooks/useStateAttribute.js +1 -4
- package/dist-cjs/lib/hooks/useStateAttribute.js.map +2 -2
- package/dist-cjs/lib/hooks/useTransform.js.map +1 -1
- package/dist-cjs/lib/hooks/useZoomCss.js +8 -4
- package/dist-cjs/lib/hooks/useZoomCss.js.map +2 -2
- package/dist-cjs/lib/options.js +1 -6
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +0 -3
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +0 -1
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js.map +2 -2
- package/dist-cjs/lib/utils/rotation.js +1 -1
- package/dist-cjs/lib/utils/rotation.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +155 -498
- package/dist-esm/index.mjs +2 -7
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/ErrorBoundary.mjs.map +1 -1
- package/dist-esm/lib/components/GeometryDebuggingView.mjs +17 -1
- package/dist-esm/lib/components/GeometryDebuggingView.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +3 -3
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/constants.mjs +3 -1
- package/dist-esm/lib/constants.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +289 -293
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +17 -18
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +3 -3
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs +4 -13
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +6 -5
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +22 -1
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/BaseBoxShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +23 -31
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/DashedOutlineBox.mjs +1 -1
- package/dist-esm/lib/editor/shapes/group/DashedOutlineBox.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +3 -3
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/exports/parseCss.mjs +1 -1
- package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
- package/dist-esm/lib/globals/environment.mjs +9 -45
- package/dist-esm/lib/globals/environment.mjs.map +2 -2
- package/dist-esm/lib/globals/menus.mjs +1 -1
- package/dist-esm/lib/globals/menus.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +3 -4
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCoarsePointer.mjs +30 -15
- package/dist-esm/lib/hooks/useCoarsePointer.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEvent.mjs +1 -1
- package/dist-esm/lib/hooks/useEvent.mjs.map +2 -2
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +1 -1
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useScreenBounds.mjs.map +2 -2
- package/dist-esm/lib/hooks/useStateAttribute.mjs +1 -4
- package/dist-esm/lib/hooks/useStateAttribute.mjs.map +2 -2
- package/dist-esm/lib/hooks/useTransform.mjs.map +1 -1
- package/dist-esm/lib/hooks/useZoomCss.mjs +8 -4
- package/dist-esm/lib/hooks/useZoomCss.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +1 -6
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +0 -3
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +0 -1
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/lib/utils/rotation.mjs +1 -1
- package/dist-esm/lib/utils/rotation.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +12 -14
- package/package.json +16 -18
- package/src/index.ts +1 -4
- package/src/lib/components/ErrorBoundary.tsx +1 -1
- package/src/lib/components/GeometryDebuggingView.tsx +19 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +3 -4
- package/src/lib/constants.ts +2 -0
- package/src/lib/editor/Editor.test.ts +10 -150
- package/src/lib/editor/Editor.ts +379 -459
- package/src/lib/editor/bindings/BindingUtil.ts +9 -15
- package/src/lib/editor/derivations/bindingsIndex.ts +2 -2
- package/src/lib/editor/derivations/notVisibleShapes.ts +23 -37
- package/src/lib/editor/derivations/parentsToChildren.ts +7 -18
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +31 -17
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +79 -129
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +6 -10
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +4 -14
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +4 -0
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +0 -12
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +4 -4
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +107 -40
- package/src/lib/editor/managers/TickManager/TickManager.ts +32 -2
- package/src/lib/editor/shapes/BaseBoxShapeUtil.tsx +2 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +32 -72
- package/src/lib/editor/shapes/group/DashedOutlineBox.tsx +1 -1
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +3 -1
- package/src/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.ts +1 -2
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +6 -6
- package/src/lib/editor/types/emit-types.ts +1 -3
- package/src/lib/exports/getSvgJsx.test.ts +19 -10
- package/src/lib/exports/getSvgJsx.tsx +5 -2
- package/src/lib/exports/parseCss.test.ts +0 -1
- package/src/lib/exports/parseCss.ts +1 -1
- package/src/lib/globals/environment.ts +10 -65
- package/src/lib/globals/menus.ts +1 -1
- package/src/lib/hooks/useCanvasEvents.ts +3 -4
- package/src/lib/hooks/useCoarsePointer.ts +59 -16
- package/src/lib/hooks/useEvent.tsx +1 -1
- package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +1 -1
- package/src/lib/hooks/useGestureEvents.ts +2 -2
- package/src/lib/hooks/usePassThroughMouseOverEvents.ts +1 -1
- package/src/lib/hooks/usePassThroughWheelEvents.ts +1 -1
- package/src/lib/hooks/useScreenBounds.ts +1 -1
- package/src/lib/hooks/useStateAttribute.ts +1 -4
- package/src/lib/hooks/useTransform.ts +1 -1
- package/src/lib/hooks/useZoomCss.ts +8 -3
- package/src/lib/options.ts +0 -32
- package/src/lib/primitives/Box.ts +0 -9
- package/src/lib/primitives/geometry/Geometry2d.ts +0 -1
- package/src/lib/utils/reparenting.ts +5 -5
- package/src/lib/utils/rotation.ts +1 -1
- package/src/version.ts +3 -3
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +0 -591
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +0 -7
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +0 -573
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +0 -7
- package/src/lib/config/TLUserPreferences.test.ts +0 -40
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +0 -566
|
@@ -104,6 +104,7 @@ var import_assets = require("../utils/assets");
|
|
|
104
104
|
var import_debug_flags = require("../utils/debug-flags");
|
|
105
105
|
var import_deepLinks = require("../utils/deepLinks");
|
|
106
106
|
var import_getIncrementedName = require("../utils/getIncrementedName");
|
|
107
|
+
var import_keyboard = require("../utils/keyboard");
|
|
107
108
|
var import_reorderShapes = require("../utils/reorderShapes");
|
|
108
109
|
var import_rotation = require("../utils/rotation");
|
|
109
110
|
var import_bindingsIndex = require("./derivations/bindingsIndex");
|
|
@@ -115,15 +116,14 @@ var import_EdgeScrollManager = require("./managers/EdgeScrollManager/EdgeScrollM
|
|
|
115
116
|
var import_FocusManager = require("./managers/FocusManager/FocusManager");
|
|
116
117
|
var import_FontManager = require("./managers/FontManager/FontManager");
|
|
117
118
|
var import_HistoryManager = require("./managers/HistoryManager/HistoryManager");
|
|
118
|
-
var import_InputsManager = require("./managers/InputsManager/InputsManager");
|
|
119
119
|
var import_ScribbleManager = require("./managers/ScribbleManager/ScribbleManager");
|
|
120
120
|
var import_SnapManager = require("./managers/SnapManager/SnapManager");
|
|
121
121
|
var import_TextManager = require("./managers/TextManager/TextManager");
|
|
122
122
|
var import_TickManager = require("./managers/TickManager/TickManager");
|
|
123
123
|
var import_UserPreferencesManager = require("./managers/UserPreferencesManager/UserPreferencesManager");
|
|
124
124
|
var import_RootState = require("./tools/RootState");
|
|
125
|
-
var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec,
|
|
126
|
-
class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed],
|
|
125
|
+
var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getCurrentPageShapesInReadingOrder_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
|
|
126
|
+
class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed], _getCanUndo_dec = [import_state.computed], _getCanRedo_dec = [import_state.computed], _getPath_dec = [import_state.computed], _getCurrentTool_dec = [import_state.computed], _getCurrentToolId_dec = [import_state.computed], _getDocumentSettings_dec = [import_state.computed], _getInstanceState_dec = [import_state.computed], _getPageStates_dec = [import_state.computed], __getPageStatesQuery_dec = [import_state.computed], _getCurrentPageState_dec = [import_state.computed], __getCurrentPageStateId_dec = [import_state.computed], _getSelectedShapeIds_dec = [import_state.computed], _getSelectedShapes_dec = [import_state.computed], _getCurrentPageShapesInReadingOrder_dec = [import_state.computed], _getOnlySelectedShapeId_dec = [import_state.computed], _getOnlySelectedShape_dec = [import_state.computed], _getSelectionPageBounds_dec = [import_state.computed], _getSelectionRotation_dec = [import_state.computed], _getSelectionRotatedPageBounds_dec = [import_state.computed], _getSelectionRotatedScreenBounds_dec = [import_state.computed], _getFocusedGroupId_dec = [import_state.computed], _getFocusedGroup_dec = [import_state.computed], _getEditingShapeId_dec = [import_state.computed], _getEditingShape_dec = [import_state.computed], _getRichTextEditor_dec = [import_state.computed], _getHoveredShapeId_dec = [import_state.computed], _getHoveredShape_dec = [import_state.computed], _getHintingShapeIds_dec = [import_state.computed], _getHintingShape_dec = [import_state.computed], _getErasingShapeIds_dec = [import_state.computed], _getErasingShapes_dec = [import_state.computed], __unsafe_getCameraId_dec = [import_state.computed], _getCamera_dec = [import_state.computed], _getViewportPageBoundsForFollowing_dec = [import_state.computed], _getCameraForFollowing_dec = [import_state.computed], _getZoomLevel_dec = [import_state.computed], _getViewportScreenBounds_dec = [import_state.computed], _getViewportScreenCenter_dec = [import_state.computed], _getViewportPageBounds_dec = [import_state.computed], __getCollaboratorsQuery_dec = [import_state.computed], _getCollaborators_dec = [import_state.computed], _getCollaboratorsOnCurrentPage_dec = [import_state.computed], _getRenderingShapes_dec = [import_state.computed], __getAllPagesQuery_dec = [import_state.computed], _getPages_dec = [import_state.computed], _getCurrentPageId_dec = [import_state.computed], _getCurrentPageShapeIdsSorted_dec = [import_state.computed], __getAllAssetsQuery_dec = [import_state.computed], __getShapeHandlesCache_dec = [import_state.computed], __getShapePageTransformCache_dec = [import_state.computed], __getShapePageBoundsCache_dec = [import_state.computed], __getShapeClipPathCache_dec = [import_state.computed], __getShapeMaskCache_dec = [import_state.computed], __getShapeMaskedPageBoundsCache_dec = [import_state.computed], _getNotVisibleShapes_dec = [import_state.computed], _getCulledShapes_dec = [import_state.computed], _getCurrentPageBounds_dec = [import_state.computed], _getCurrentPageShapes_dec = [import_state.computed], _getCurrentPageShapesSorted_dec = [import_state.computed], _getCurrentPageRenderingShapesSorted_dec = [import_state.computed], __getBindingsIndexCache_dec = [import_state.computed], __getSelectionSharedStyles_dec = [import_state.computed], _getSharedStyles_dec = [(0, import_state.computed)({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [import_state.computed], _getIsFocused_dec = [import_state.computed], _getIsReadonly_dec = [import_state.computed], __setShiftKeyTimeout_dec = [import_utils.bind], __setAltKeyTimeout_dec = [import_utils.bind], __setCtrlKeyTimeout_dec = [import_utils.bind], __setMetaKeyTimeout_dec = [import_utils.bind], _a) {
|
|
127
127
|
constructor({
|
|
128
128
|
store,
|
|
129
129
|
user,
|
|
@@ -159,7 +159,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
159
159
|
*/
|
|
160
160
|
__publicField(this, "root");
|
|
161
161
|
/**
|
|
162
|
-
* A set of functions to call when the
|
|
162
|
+
* A set of functions to call when the app is disposed.
|
|
163
163
|
*
|
|
164
164
|
* @public
|
|
165
165
|
*/
|
|
@@ -170,19 +170,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
170
170
|
* @public
|
|
171
171
|
*/
|
|
172
172
|
__publicField(this, "isDisposed", false);
|
|
173
|
-
/**
|
|
174
|
-
* A manager for the editor's tick events.
|
|
175
|
-
*
|
|
176
|
-
* @internal */
|
|
173
|
+
/** @internal */
|
|
177
174
|
__publicField(this, "_tickManager");
|
|
178
175
|
/**
|
|
179
|
-
* A manager for the
|
|
180
|
-
*
|
|
181
|
-
* @public
|
|
182
|
-
*/
|
|
183
|
-
__publicField(this, "inputs");
|
|
184
|
-
/**
|
|
185
|
-
* A manager for the editor's snapping feature.
|
|
176
|
+
* A manager for the app's snapping feature.
|
|
186
177
|
*
|
|
187
178
|
* @public
|
|
188
179
|
*/
|
|
@@ -264,7 +255,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
264
255
|
__publicField(this, "bindingUtils");
|
|
265
256
|
/* --------------------- History -------------------- */
|
|
266
257
|
/**
|
|
267
|
-
* A manager for the
|
|
258
|
+
* A manager for the app's history.
|
|
268
259
|
*
|
|
269
260
|
* @readonly
|
|
270
261
|
*/
|
|
@@ -279,7 +270,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
279
270
|
// Rich text editor
|
|
280
271
|
__publicField(this, "_currentRichTextEditor", (0, import_state.atom)("rich text editor", null));
|
|
281
272
|
__publicField(this, "_textOptions");
|
|
282
|
-
__publicField(this, "_debouncedZoomLevel", (0, import_state.atom)("debounced zoom level", 1));
|
|
283
273
|
__publicField(this, "_cameraOptions", (0, import_state.atom)("camera options", import_constants.DEFAULT_CAMERA_OPTIONS));
|
|
284
274
|
/** @internal */
|
|
285
275
|
__publicField(this, "_viewportAnimation", null);
|
|
@@ -330,6 +320,54 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
330
320
|
tldraw: null,
|
|
331
321
|
excalidraw: null
|
|
332
322
|
});
|
|
323
|
+
/* --------------------- Events --------------------- */
|
|
324
|
+
/**
|
|
325
|
+
* The app's current input state.
|
|
326
|
+
*
|
|
327
|
+
* @public
|
|
328
|
+
*/
|
|
329
|
+
__publicField(this, "inputs", {
|
|
330
|
+
/** The most recent pointer down's position in the current page space. */
|
|
331
|
+
originPagePoint: new import_Vec.Vec(),
|
|
332
|
+
/** The most recent pointer down's position in screen space. */
|
|
333
|
+
originScreenPoint: new import_Vec.Vec(),
|
|
334
|
+
/** The previous pointer position in the current page space. */
|
|
335
|
+
previousPagePoint: new import_Vec.Vec(),
|
|
336
|
+
/** The previous pointer position in screen space. */
|
|
337
|
+
previousScreenPoint: new import_Vec.Vec(),
|
|
338
|
+
/** The most recent pointer position in the current page space. */
|
|
339
|
+
currentPagePoint: new import_Vec.Vec(),
|
|
340
|
+
/** The most recent pointer position in screen space. */
|
|
341
|
+
currentScreenPoint: new import_Vec.Vec(),
|
|
342
|
+
/** A set containing the currently pressed keys. */
|
|
343
|
+
keys: /* @__PURE__ */ new Set(),
|
|
344
|
+
/** A set containing the currently pressed buttons. */
|
|
345
|
+
buttons: /* @__PURE__ */ new Set(),
|
|
346
|
+
/** Whether the input is from a pe. */
|
|
347
|
+
isPen: false,
|
|
348
|
+
/** Whether the shift key is currently pressed. */
|
|
349
|
+
shiftKey: false,
|
|
350
|
+
/** Whether the meta key is currently pressed. */
|
|
351
|
+
metaKey: false,
|
|
352
|
+
/** Whether the control or command key is currently pressed. */
|
|
353
|
+
ctrlKey: false,
|
|
354
|
+
/** Whether the alt or option key is currently pressed. */
|
|
355
|
+
altKey: false,
|
|
356
|
+
/** Whether the user is dragging. */
|
|
357
|
+
isDragging: false,
|
|
358
|
+
/** Whether the user is pointing. */
|
|
359
|
+
isPointing: false,
|
|
360
|
+
/** Whether the user is pinching. */
|
|
361
|
+
isPinching: false,
|
|
362
|
+
/** Whether the user is editing. */
|
|
363
|
+
isEditing: false,
|
|
364
|
+
/** Whether the user is panning. */
|
|
365
|
+
isPanning: false,
|
|
366
|
+
/** Whether the user is spacebar panning. */
|
|
367
|
+
isSpacebarPanning: false,
|
|
368
|
+
/** Velocity of mouse pointer, in pixels per millisecond */
|
|
369
|
+
pointerVelocity: new import_Vec.Vec()
|
|
370
|
+
});
|
|
333
371
|
/**
|
|
334
372
|
* A manager for recording multiple click events.
|
|
335
373
|
*
|
|
@@ -353,6 +391,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
353
391
|
/** @internal */
|
|
354
392
|
__publicField(this, "_restoreToolId", "select");
|
|
355
393
|
/** @internal */
|
|
394
|
+
__publicField(this, "_pinchStart", 1);
|
|
395
|
+
/** @internal */
|
|
356
396
|
__publicField(this, "_didPinch", false);
|
|
357
397
|
/** @internal */
|
|
358
398
|
__publicField(this, "_selectedShapeIdsAtPointerDown", []);
|
|
@@ -388,7 +428,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
388
428
|
this.disposables.add(() => this.textMeasure.dispose());
|
|
389
429
|
this.fonts = new import_FontManager.FontManager(this, fontAssetUrls);
|
|
390
430
|
this._tickManager = new import_TickManager.TickManager(this);
|
|
391
|
-
this.inputs = new import_InputsManager.InputsManager(this);
|
|
392
431
|
class NewRoot extends import_RootState.RootState {
|
|
393
432
|
static initial = initialState ?? "";
|
|
394
433
|
}
|
|
@@ -821,7 +860,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
821
860
|
this.disposables.clear();
|
|
822
861
|
this.store.dispose();
|
|
823
862
|
this.isDisposed = true;
|
|
824
|
-
this.emit("dispose");
|
|
825
863
|
}
|
|
826
864
|
getShapeUtil(arg) {
|
|
827
865
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
@@ -855,11 +893,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
855
893
|
this.history.undo();
|
|
856
894
|
return this;
|
|
857
895
|
}
|
|
858
|
-
canUndo() {
|
|
859
|
-
return this.history.getNumUndos() > 0;
|
|
860
|
-
}
|
|
861
896
|
getCanUndo() {
|
|
862
|
-
return this.
|
|
897
|
+
return this.history.getNumUndos() > 0;
|
|
863
898
|
}
|
|
864
899
|
/**
|
|
865
900
|
* Redo to the next mark.
|
|
@@ -877,16 +912,13 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
877
912
|
this.history.redo();
|
|
878
913
|
return this;
|
|
879
914
|
}
|
|
880
|
-
canRedo() {
|
|
881
|
-
return this.history.getNumRedos() > 0;
|
|
882
|
-
}
|
|
883
|
-
getCanRedo() {
|
|
884
|
-
return this.canRedo();
|
|
885
|
-
}
|
|
886
915
|
clearHistory() {
|
|
887
916
|
this.history.clear();
|
|
888
917
|
return this;
|
|
889
918
|
}
|
|
919
|
+
getCanRedo() {
|
|
920
|
+
return this.history.getNumRedos() > 0;
|
|
921
|
+
}
|
|
890
922
|
/**
|
|
891
923
|
* Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
|
|
892
924
|
* any redos. You typically want to do this just before a user interaction begins or is handled.
|
|
@@ -1041,7 +1073,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1041
1073
|
}),
|
|
1042
1074
|
selectionCount: this.getSelectedShapes().length,
|
|
1043
1075
|
editingShape: editingShapeId ? this.getShape(editingShapeId) : void 0,
|
|
1044
|
-
inputs: this.inputs
|
|
1076
|
+
inputs: this.inputs,
|
|
1045
1077
|
pageState: this.getCurrentPageState(),
|
|
1046
1078
|
instanceState: this.getInstanceState(),
|
|
1047
1079
|
collaboratorCount: this.getCollaboratorsOnCurrentPage().length
|
|
@@ -1062,7 +1094,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1062
1094
|
* we're in a transaction that's about to be rolled back due to the same error we're currently
|
|
1063
1095
|
* reporting.
|
|
1064
1096
|
*
|
|
1065
|
-
* Instead, to listen to changes to this value, you need to listen to
|
|
1097
|
+
* Instead, to listen to changes to this value, you need to listen to app's `crash` event.
|
|
1066
1098
|
*
|
|
1067
1099
|
* @internal
|
|
1068
1100
|
*/
|
|
@@ -1713,28 +1745,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1713
1745
|
const editingShapeId = this.getEditingShapeId();
|
|
1714
1746
|
return editingShapeId ? this.getShape(editingShapeId) : void 0;
|
|
1715
1747
|
}
|
|
1716
|
-
/**
|
|
1717
|
-
* Whether the shape can be edited.
|
|
1718
|
-
*
|
|
1719
|
-
* @param shape - The shape (or shape id) to check if it can be edited.
|
|
1720
|
-
* @param info - The info about the edit start.
|
|
1721
|
-
*
|
|
1722
|
-
* @public
|
|
1723
|
-
* @returns true if the shape can be edited, false otherwise.
|
|
1724
|
-
*/
|
|
1725
|
-
canEditShape(shape, info) {
|
|
1726
|
-
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1727
|
-
if (!id) return false;
|
|
1728
|
-
if (id === this.getEditingShapeId()) return false;
|
|
1729
|
-
const _shape = this.getShape(id);
|
|
1730
|
-
if (!_shape) return false;
|
|
1731
|
-
const util = this.getShapeUtil(_shape);
|
|
1732
|
-
const _info = info ?? { type: "unknown" };
|
|
1733
|
-
if (!util.canEdit(_shape, _info)) return false;
|
|
1734
|
-
if (this.getIsReadonly() && !util.canEditInReadonly(_shape)) return false;
|
|
1735
|
-
if (this.isShapeOrAncestorLocked(_shape) && !util.canEditWhileLocked(_shape)) return false;
|
|
1736
|
-
return true;
|
|
1737
|
-
}
|
|
1738
1748
|
/**
|
|
1739
1749
|
* Set the current editing shape.
|
|
1740
1750
|
*
|
|
@@ -1750,42 +1760,42 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1750
1760
|
*/
|
|
1751
1761
|
setEditingShape(shape) {
|
|
1752
1762
|
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1753
|
-
|
|
1763
|
+
this.setRichTextEditor(null);
|
|
1764
|
+
const prevEditingShapeId = this.getEditingShapeId();
|
|
1765
|
+
if (id !== prevEditingShapeId) {
|
|
1766
|
+
if (id) {
|
|
1767
|
+
const shape2 = this.getShape(id);
|
|
1768
|
+
if (shape2 && this.getShapeUtil(shape2).canEdit(shape2)) {
|
|
1769
|
+
this.run(
|
|
1770
|
+
() => {
|
|
1771
|
+
this._updateCurrentPageState({ editingShapeId: id });
|
|
1772
|
+
if (prevEditingShapeId) {
|
|
1773
|
+
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1774
|
+
if (prevEditingShape) {
|
|
1775
|
+
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
this.getShapeUtil(shape2).onEditStart?.(shape2);
|
|
1779
|
+
},
|
|
1780
|
+
{ history: "ignore" }
|
|
1781
|
+
);
|
|
1782
|
+
return this;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1754
1785
|
this.run(
|
|
1755
1786
|
() => {
|
|
1756
|
-
|
|
1787
|
+
this._updateCurrentPageState({ editingShapeId: null });
|
|
1788
|
+
this._currentRichTextEditor.set(null);
|
|
1757
1789
|
if (prevEditingShapeId) {
|
|
1758
1790
|
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1759
1791
|
if (prevEditingShape) {
|
|
1760
1792
|
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1761
1793
|
}
|
|
1762
1794
|
}
|
|
1763
|
-
this._updateCurrentPageState({ editingShapeId: null });
|
|
1764
|
-
this._currentRichTextEditor.set(null);
|
|
1765
1795
|
},
|
|
1766
1796
|
{ history: "ignore" }
|
|
1767
1797
|
);
|
|
1768
|
-
return this;
|
|
1769
1798
|
}
|
|
1770
|
-
if (!this.canEditShape(id)) return this;
|
|
1771
|
-
this.run(
|
|
1772
|
-
() => {
|
|
1773
|
-
const prevEditingShapeId = this.getEditingShapeId();
|
|
1774
|
-
if (prevEditingShapeId) {
|
|
1775
|
-
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1776
|
-
if (prevEditingShape) {
|
|
1777
|
-
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
this._updateCurrentPageState({ editingShapeId: null });
|
|
1781
|
-
this._currentRichTextEditor.set(null);
|
|
1782
|
-
this.select(id);
|
|
1783
|
-
this._updateCurrentPageState({ editingShapeId: id });
|
|
1784
|
-
const nextEditingShape = this.getShape(id);
|
|
1785
|
-
this.getShapeUtil(nextEditingShape).onEditStart?.(nextEditingShape);
|
|
1786
|
-
},
|
|
1787
|
-
{ history: "ignore" }
|
|
1788
|
-
);
|
|
1789
1799
|
return this;
|
|
1790
1800
|
}
|
|
1791
1801
|
getRichTextEditor() {
|
|
@@ -1918,25 +1928,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1918
1928
|
getCroppingShapeId() {
|
|
1919
1929
|
return this.getCurrentPageState().croppingShapeId;
|
|
1920
1930
|
}
|
|
1921
|
-
/**
|
|
1922
|
-
* Whether the shape can be cropped.
|
|
1923
|
-
*
|
|
1924
|
-
* @param shape - The shape (or shape id) to check if it can be cropped.
|
|
1925
|
-
*
|
|
1926
|
-
* @public
|
|
1927
|
-
* @returns true if the shape can be cropped, false otherwise.
|
|
1928
|
-
*/
|
|
1929
|
-
canCropShape(shape) {
|
|
1930
|
-
if (!shape) return false;
|
|
1931
|
-
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1932
|
-
if (!id) return false;
|
|
1933
|
-
const _shape = this.getShape(id);
|
|
1934
|
-
if (!_shape) return false;
|
|
1935
|
-
const util = this.getShapeUtil(_shape);
|
|
1936
|
-
if (!util.canCrop(_shape)) return false;
|
|
1937
|
-
if (this.isShapeOrAncestorLocked(_shape)) return false;
|
|
1938
|
-
return true;
|
|
1939
|
-
}
|
|
1940
1931
|
/**
|
|
1941
1932
|
* Set the current cropping shape.
|
|
1942
1933
|
*
|
|
@@ -1958,8 +1949,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1958
1949
|
() => {
|
|
1959
1950
|
if (!id) {
|
|
1960
1951
|
this.updateCurrentPageState({ croppingShapeId: null });
|
|
1961
|
-
} else
|
|
1962
|
-
this.
|
|
1952
|
+
} else {
|
|
1953
|
+
const shape2 = this.getShape(id);
|
|
1954
|
+
const util = this.getShapeUtil(shape2);
|
|
1955
|
+
if (shape2 && util.canCrop(shape2)) {
|
|
1956
|
+
this.updateCurrentPageState({ croppingShapeId: id });
|
|
1957
|
+
}
|
|
1963
1958
|
}
|
|
1964
1959
|
},
|
|
1965
1960
|
{ history: "ignore" }
|
|
@@ -2034,22 +2029,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2034
2029
|
getZoomLevel() {
|
|
2035
2030
|
return this.getCamera().z;
|
|
2036
2031
|
}
|
|
2037
|
-
getDebouncedZoomLevel() {
|
|
2038
|
-
if (this.options.debouncedZoom) {
|
|
2039
|
-
if (this.getCameraState() === "idle") {
|
|
2040
|
-
return this.getZoomLevel();
|
|
2041
|
-
} else {
|
|
2042
|
-
return this._debouncedZoomLevel.get();
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
return this.getZoomLevel();
|
|
2046
|
-
}
|
|
2047
|
-
_getAboveDebouncedZoomThreshold() {
|
|
2048
|
-
return this.getCurrentPageShapeIds().size > this.options.debouncedZoomThreshold;
|
|
2049
|
-
}
|
|
2050
|
-
getEfficientZoomLevel() {
|
|
2051
|
-
return this._getAboveDebouncedZoomThreshold() ? this.getDebouncedZoomLevel() : this.getZoomLevel();
|
|
2052
|
-
}
|
|
2053
2032
|
/**
|
|
2054
2033
|
* Get the camera's initial or reset zoom level.
|
|
2055
2034
|
*
|
|
@@ -2295,8 +2274,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2295
2274
|
},
|
|
2296
2275
|
{ history: "ignore" }
|
|
2297
2276
|
);
|
|
2298
|
-
const currentScreenPoint = this.inputs
|
|
2299
|
-
const currentPagePoint = this.inputs.getCurrentPagePoint();
|
|
2277
|
+
const { currentScreenPoint, currentPagePoint } = this.inputs;
|
|
2300
2278
|
if (currentScreenPoint.x / z - x !== currentPagePoint.x || currentScreenPoint.y / z - y !== currentPagePoint.y) {
|
|
2301
2279
|
this.updatePointer({
|
|
2302
2280
|
immediate: opts?.immediate,
|
|
@@ -2431,7 +2409,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2431
2409
|
* ```ts
|
|
2432
2410
|
* editor.zoomIn()
|
|
2433
2411
|
* editor.zoomIn(editor.getViewportScreenCenter(), { animation: { duration: 200 } })
|
|
2434
|
-
* editor.zoomIn(editor.inputs.
|
|
2412
|
+
* editor.zoomIn(editor.inputs.currentScreenPoint, { animation: { duration: 200 } })
|
|
2435
2413
|
* ```
|
|
2436
2414
|
*
|
|
2437
2415
|
* @param point - The screen point to zoom in on. Defaults to the screen center
|
|
@@ -2472,7 +2450,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2472
2450
|
* ```ts
|
|
2473
2451
|
* editor.zoomOut()
|
|
2474
2452
|
* editor.zoomOut(editor.getViewportScreenCenter(), { animation: { duration: 120 } })
|
|
2475
|
-
* editor.zoomOut(editor.inputs.
|
|
2453
|
+
* editor.zoomOut(editor.inputs.currentScreenPoint, { animation: { duration: 120 } })
|
|
2476
2454
|
* ```
|
|
2477
2455
|
*
|
|
2478
2456
|
* @param point - The point to zoom out on. Defaults to the viewport screen center.
|
|
@@ -2524,15 +2502,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2524
2502
|
if (isLocked && !opts?.force) return this;
|
|
2525
2503
|
const selectionPageBounds = this.getSelectionPageBounds();
|
|
2526
2504
|
if (selectionPageBounds) {
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
}
|
|
2531
|
-
this.zoomToBounds(selectionPageBounds, {
|
|
2532
|
-
targetZoom: 1,
|
|
2533
|
-
...opts
|
|
2534
|
-
});
|
|
2535
|
-
}
|
|
2505
|
+
this.zoomToBounds(selectionPageBounds, {
|
|
2506
|
+
targetZoom: Math.max(1, this.getZoomLevel()),
|
|
2507
|
+
...opts
|
|
2508
|
+
});
|
|
2536
2509
|
}
|
|
2537
2510
|
return this;
|
|
2538
2511
|
}
|
|
@@ -2572,7 +2545,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2572
2545
|
const cameraOptions = this._cameraOptions.__unsafe__getWithoutCapture();
|
|
2573
2546
|
if (cameraOptions.isLocked && !opts?.force) return this;
|
|
2574
2547
|
const viewportScreenBounds = this.getViewportScreenBounds();
|
|
2575
|
-
const inset = opts?.inset ?? Math.min(
|
|
2548
|
+
const inset = opts?.inset ?? Math.min(import_constants.ZOOM_TO_FIT_PADDING, viewportScreenBounds.width * 0.28);
|
|
2576
2549
|
const baseZoom = this.getBaseZoom();
|
|
2577
2550
|
const zoomMin = cameraOptions.zoomSteps[0];
|
|
2578
2551
|
const zoomMax = (0, import_utils.last)(cameraOptions.zoomSteps);
|
|
@@ -2796,20 +2769,18 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2796
2769
|
}
|
|
2797
2770
|
if (_willSetInitialBounds) {
|
|
2798
2771
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2799
|
-
this.emit("resize", screenBounds.toJson());
|
|
2800
2772
|
this.setCamera(this.getCamera());
|
|
2801
2773
|
} else {
|
|
2802
2774
|
if (center && !this.getInstanceState().followingUserId) {
|
|
2803
2775
|
const before = this.getViewportPageBounds().center;
|
|
2804
2776
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2805
|
-
this.emit("resize", screenBounds.toJson());
|
|
2806
2777
|
this.centerOnPoint(before);
|
|
2807
2778
|
} else {
|
|
2808
2779
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2809
|
-
this.emit("resize", screenBounds.toJson());
|
|
2810
2780
|
this._setCamera(import_Vec.Vec.From({ ...this.getCamera() }));
|
|
2811
2781
|
}
|
|
2812
2782
|
}
|
|
2783
|
+
this._tickCameraState();
|
|
2813
2784
|
return this;
|
|
2814
2785
|
}
|
|
2815
2786
|
getViewportScreenBounds() {
|
|
@@ -3089,7 +3060,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3089
3060
|
this._cameraStateTimeoutRemaining = this.options.cameraMovingTimeoutMs;
|
|
3090
3061
|
if (this._cameraState.__unsafe__getWithoutCapture() !== "idle") return;
|
|
3091
3062
|
this._cameraState.set("moving");
|
|
3092
|
-
this._debouncedZoomLevel.set((0, import_state.unsafe__withoutCapture)(() => this.getCamera().z));
|
|
3093
3063
|
this.on("tick", this._decayCameraStateTimeout);
|
|
3094
3064
|
}
|
|
3095
3065
|
/**
|
|
@@ -4430,18 +4400,30 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4430
4400
|
getBinding(id) {
|
|
4431
4401
|
return this.store.get(id);
|
|
4432
4402
|
}
|
|
4403
|
+
/**
|
|
4404
|
+
* Get all bindings of a certain type _from_ a particular shape. These are the bindings whose
|
|
4405
|
+
* `fromId` matched the shape's ID.
|
|
4406
|
+
*/
|
|
4433
4407
|
getBindingsFromShape(shape, type) {
|
|
4434
4408
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4435
4409
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4436
4410
|
(b) => b.fromId === id && b.type === type
|
|
4437
4411
|
);
|
|
4438
4412
|
}
|
|
4413
|
+
/**
|
|
4414
|
+
* Get all bindings of a certain type _to_ a particular shape. These are the bindings whose
|
|
4415
|
+
* `toId` matches the shape's ID.
|
|
4416
|
+
*/
|
|
4439
4417
|
getBindingsToShape(shape, type) {
|
|
4440
4418
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4441
4419
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4442
4420
|
(b) => b.toId === id && b.type === type
|
|
4443
4421
|
);
|
|
4444
4422
|
}
|
|
4423
|
+
/**
|
|
4424
|
+
* Get all bindings involving a particular shape. This includes bindings where the shape is the
|
|
4425
|
+
* `fromId` or `toId`. If a type is provided, only bindings of that type are returned.
|
|
4426
|
+
*/
|
|
4445
4427
|
getBindingsInvolvingShape(shape, type) {
|
|
4446
4428
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4447
4429
|
const result = this._getBindingsIndexCache().get(id) ?? import_state.EMPTY_ARRAY;
|
|
@@ -5689,8 +5671,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5689
5671
|
isAspectRatioLocked: options.isAspectRatioLocked
|
|
5690
5672
|
});
|
|
5691
5673
|
if (Math.sign(scale.x) * Math.sign(scale.y) < 0) {
|
|
5692
|
-
|
|
5693
|
-
|
|
5674
|
+
let { rotation } = import_Mat.Mat.Decompose(options.initialPageTransform);
|
|
5675
|
+
rotation -= 2 * rotation;
|
|
5694
5676
|
this.updateShapes([{ id, type, rotation }]);
|
|
5695
5677
|
}
|
|
5696
5678
|
const preScaleShapePageCenter = import_Mat.Mat.applyToPoint(
|
|
@@ -5703,9 +5685,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5703
5685
|
scale,
|
|
5704
5686
|
options.scaleAxisRotation
|
|
5705
5687
|
);
|
|
5688
|
+
const pageBounds = this.getShapePageBounds(id);
|
|
5706
5689
|
const pageTransform = this.getShapePageTransform(id);
|
|
5707
|
-
const
|
|
5708
|
-
const currentPageCenter = import_Mat.Mat.applyToPoint(pageTransform, currentLocalBounds.center);
|
|
5690
|
+
const currentPageCenter = pageBounds.center;
|
|
5709
5691
|
const shapePageTransformOrigin = pageTransform.point();
|
|
5710
5692
|
if (!currentPageCenter || !shapePageTransformOrigin) return this;
|
|
5711
5693
|
const pageDelta = import_Vec.Vec.Sub(postScaleShapePageCenter, currentPageCenter);
|
|
@@ -5991,11 +5973,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5991
5973
|
)
|
|
5992
5974
|
);
|
|
5993
5975
|
const sortedShapeIds = shapesToGroup.sort(import_utils.sortByIndex).map((s) => s.id);
|
|
5994
|
-
const
|
|
5995
|
-
const pageBounds = import_Box.Box.Common(childBounds);
|
|
5996
|
-
if (!pageBounds.isValid()) {
|
|
5997
|
-
throw Error(`Editor.groupShapes: group bounds are invalid (NaN).`);
|
|
5998
|
-
}
|
|
5976
|
+
const pageBounds = import_Box.Box.Common((0, import_utils.compact)(shapesToGroup.map((id) => this.getShapePageBounds(id))));
|
|
5999
5977
|
const { x, y } = pageBounds.point;
|
|
6000
5978
|
const parentId = this.findCommonAncestor(shapesToGroup) ?? this.getCurrentPageId();
|
|
6001
5979
|
if (this.getCurrentToolId() !== "select") return this;
|
|
@@ -6685,25 +6663,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6685
6663
|
}
|
|
6686
6664
|
}
|
|
6687
6665
|
}
|
|
6688
|
-
if (point) {
|
|
6689
|
-
const shapesById = new Map(shapes.map((shape) => [shape.id, shape]));
|
|
6690
|
-
const rootShapesFromContent = (0, import_utils.compact)(rootShapeIds.map((id) => shapesById.get(id)));
|
|
6691
|
-
if (rootShapesFromContent.length > 0) {
|
|
6692
|
-
const targetParent = this.getShapeAtPoint(point, {
|
|
6693
|
-
hitInside: true,
|
|
6694
|
-
hitFrameInside: true,
|
|
6695
|
-
hitLocked: true,
|
|
6696
|
-
filter: (shape) => {
|
|
6697
|
-
const util = this.getShapeUtil(shape);
|
|
6698
|
-
if (!util.canReceiveNewChildrenOfType) return false;
|
|
6699
|
-
return rootShapesFromContent.every(
|
|
6700
|
-
(rootShape) => util.canReceiveNewChildrenOfType(shape, rootShape.type)
|
|
6701
|
-
);
|
|
6702
|
-
}
|
|
6703
|
-
});
|
|
6704
|
-
pasteParentId = targetParent ? targetParent.id : currentPageId;
|
|
6705
|
-
}
|
|
6706
|
-
}
|
|
6707
6666
|
let isDuplicating = false;
|
|
6708
6667
|
if (!(0, import_tlschema.isPageId)(pasteParentId)) {
|
|
6709
6668
|
const parent = this.getShape(pasteParentId);
|
|
@@ -6948,7 +6907,60 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6948
6907
|
height
|
|
6949
6908
|
};
|
|
6950
6909
|
}
|
|
6951
|
-
|
|
6910
|
+
/**
|
|
6911
|
+
* Update the input points from a pointer, pinch, or wheel event.
|
|
6912
|
+
*
|
|
6913
|
+
* @param info - The event info.
|
|
6914
|
+
*/
|
|
6915
|
+
_updateInputsFromEvent(info) {
|
|
6916
|
+
const {
|
|
6917
|
+
pointerVelocity,
|
|
6918
|
+
previousScreenPoint,
|
|
6919
|
+
previousPagePoint,
|
|
6920
|
+
currentScreenPoint,
|
|
6921
|
+
currentPagePoint,
|
|
6922
|
+
originScreenPoint,
|
|
6923
|
+
originPagePoint
|
|
6924
|
+
} = this.inputs;
|
|
6925
|
+
const { screenBounds } = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
|
|
6926
|
+
const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
|
|
6927
|
+
const sx = info.point.x - screenBounds.x;
|
|
6928
|
+
const sy = info.point.y - screenBounds.y;
|
|
6929
|
+
const sz = info.point.z ?? 0.5;
|
|
6930
|
+
previousScreenPoint.setTo(currentScreenPoint);
|
|
6931
|
+
previousPagePoint.setTo(currentPagePoint);
|
|
6932
|
+
currentScreenPoint.set(sx, sy);
|
|
6933
|
+
const nx = sx / cz - cx;
|
|
6934
|
+
const ny = sy / cz - cy;
|
|
6935
|
+
if (isFinite(nx) && isFinite(ny)) {
|
|
6936
|
+
currentPagePoint.set(nx, ny, sz);
|
|
6937
|
+
}
|
|
6938
|
+
this.inputs.isPen = info.type === "pointer" && info.isPen;
|
|
6939
|
+
if (info.name === "pointer_down" || this.inputs.isPinching) {
|
|
6940
|
+
pointerVelocity.set(0, 0);
|
|
6941
|
+
originScreenPoint.setTo(currentScreenPoint);
|
|
6942
|
+
originPagePoint.setTo(currentPagePoint);
|
|
6943
|
+
}
|
|
6944
|
+
this.run(
|
|
6945
|
+
() => {
|
|
6946
|
+
this.store.put([
|
|
6947
|
+
{
|
|
6948
|
+
id: import_tlschema.TLPOINTER_ID,
|
|
6949
|
+
typeName: "pointer",
|
|
6950
|
+
x: currentPagePoint.x,
|
|
6951
|
+
y: currentPagePoint.y,
|
|
6952
|
+
lastActivityTimestamp: (
|
|
6953
|
+
// If our pointer moved only because we're following some other user, then don't
|
|
6954
|
+
// update our last activity timestamp; otherwise, update it to the current timestamp.
|
|
6955
|
+
info.type === "pointer" && info.pointerId === import_constants.INTERNAL_POINTER_IDS.CAMERA_MOVE ? this.store.unsafeGetWithoutCapture(import_tlschema.TLPOINTER_ID)?.lastActivityTimestamp ?? this._tickManager.now : this._tickManager.now
|
|
6956
|
+
),
|
|
6957
|
+
meta: {}
|
|
6958
|
+
}
|
|
6959
|
+
]);
|
|
6960
|
+
},
|
|
6961
|
+
{ history: "ignore" }
|
|
6962
|
+
);
|
|
6963
|
+
}
|
|
6952
6964
|
/**
|
|
6953
6965
|
* Dispatch a cancel event.
|
|
6954
6966
|
*
|
|
@@ -7013,19 +7025,18 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7013
7025
|
point: options?.point ?? // weird but true: what `inputs` calls screen-space is actually viewport space. so
|
|
7014
7026
|
// we need to convert back into true screen space first. we should fix this...
|
|
7015
7027
|
import_Vec.Vec.Add(
|
|
7016
|
-
this.inputs.
|
|
7028
|
+
this.inputs.currentScreenPoint,
|
|
7017
7029
|
this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID).screenBounds
|
|
7018
7030
|
),
|
|
7019
7031
|
pointerId: options?.pointerId ?? 0,
|
|
7020
7032
|
button: options?.button ?? 0,
|
|
7021
|
-
isPen: options?.isPen ?? this.inputs.
|
|
7022
|
-
shiftKey: options?.shiftKey ?? this.inputs.
|
|
7023
|
-
altKey: options?.altKey ?? this.inputs.
|
|
7024
|
-
ctrlKey: options?.ctrlKey ?? this.inputs.
|
|
7025
|
-
metaKey: options?.metaKey ?? this.inputs.
|
|
7026
|
-
accelKey:
|
|
7033
|
+
isPen: options?.isPen ?? this.inputs.isPen,
|
|
7034
|
+
shiftKey: options?.shiftKey ?? this.inputs.shiftKey,
|
|
7035
|
+
altKey: options?.altKey ?? this.inputs.altKey,
|
|
7036
|
+
ctrlKey: options?.ctrlKey ?? this.inputs.ctrlKey,
|
|
7037
|
+
metaKey: options?.metaKey ?? this.inputs.metaKey,
|
|
7038
|
+
accelKey: options?.accelKey ?? (0, import_keyboard.isAccelKey)(this.inputs)
|
|
7027
7039
|
};
|
|
7028
|
-
event.accelKey = options?.accelKey ?? this.inputs.getAccelKey();
|
|
7029
7040
|
if (options?.immediate) {
|
|
7030
7041
|
this._flushEventForTick(event);
|
|
7031
7042
|
} else {
|
|
@@ -7341,58 +7352,58 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7341
7352
|
this._clickManager.cancelDoubleClickTimeout();
|
|
7342
7353
|
}
|
|
7343
7354
|
_setShiftKeyTimeout() {
|
|
7344
|
-
this.inputs.
|
|
7355
|
+
this.inputs.shiftKey = false;
|
|
7345
7356
|
this.dispatch({
|
|
7346
7357
|
type: "keyboard",
|
|
7347
7358
|
name: "key_up",
|
|
7348
7359
|
key: "Shift",
|
|
7349
|
-
shiftKey: this.inputs.
|
|
7350
|
-
ctrlKey: this.inputs.
|
|
7351
|
-
altKey: this.inputs.
|
|
7352
|
-
metaKey: this.inputs.
|
|
7353
|
-
accelKey: this.inputs
|
|
7360
|
+
shiftKey: this.inputs.shiftKey,
|
|
7361
|
+
ctrlKey: this.inputs.ctrlKey,
|
|
7362
|
+
altKey: this.inputs.altKey,
|
|
7363
|
+
metaKey: this.inputs.metaKey,
|
|
7364
|
+
accelKey: (0, import_keyboard.isAccelKey)(this.inputs),
|
|
7354
7365
|
code: "ShiftLeft"
|
|
7355
7366
|
});
|
|
7356
7367
|
}
|
|
7357
7368
|
_setAltKeyTimeout() {
|
|
7358
|
-
this.inputs.
|
|
7369
|
+
this.inputs.altKey = false;
|
|
7359
7370
|
this.dispatch({
|
|
7360
7371
|
type: "keyboard",
|
|
7361
7372
|
name: "key_up",
|
|
7362
7373
|
key: "Alt",
|
|
7363
|
-
shiftKey: this.inputs.
|
|
7364
|
-
ctrlKey: this.inputs.
|
|
7365
|
-
altKey: this.inputs.
|
|
7366
|
-
metaKey: this.inputs.
|
|
7367
|
-
accelKey: this.inputs
|
|
7374
|
+
shiftKey: this.inputs.shiftKey,
|
|
7375
|
+
ctrlKey: this.inputs.ctrlKey,
|
|
7376
|
+
altKey: this.inputs.altKey,
|
|
7377
|
+
metaKey: this.inputs.metaKey,
|
|
7378
|
+
accelKey: (0, import_keyboard.isAccelKey)(this.inputs),
|
|
7368
7379
|
code: "AltLeft"
|
|
7369
7380
|
});
|
|
7370
7381
|
}
|
|
7371
7382
|
_setCtrlKeyTimeout() {
|
|
7372
|
-
this.inputs.
|
|
7383
|
+
this.inputs.ctrlKey = false;
|
|
7373
7384
|
this.dispatch({
|
|
7374
7385
|
type: "keyboard",
|
|
7375
7386
|
name: "key_up",
|
|
7376
7387
|
key: "Ctrl",
|
|
7377
|
-
shiftKey: this.inputs.
|
|
7378
|
-
ctrlKey: this.inputs.
|
|
7379
|
-
altKey: this.inputs.
|
|
7380
|
-
metaKey: this.inputs.
|
|
7381
|
-
accelKey: this.inputs
|
|
7388
|
+
shiftKey: this.inputs.shiftKey,
|
|
7389
|
+
ctrlKey: this.inputs.ctrlKey,
|
|
7390
|
+
altKey: this.inputs.altKey,
|
|
7391
|
+
metaKey: this.inputs.metaKey,
|
|
7392
|
+
accelKey: (0, import_keyboard.isAccelKey)(this.inputs),
|
|
7382
7393
|
code: "ControlLeft"
|
|
7383
7394
|
});
|
|
7384
7395
|
}
|
|
7385
7396
|
_setMetaKeyTimeout() {
|
|
7386
|
-
this.inputs.
|
|
7397
|
+
this.inputs.metaKey = false;
|
|
7387
7398
|
this.dispatch({
|
|
7388
7399
|
type: "keyboard",
|
|
7389
7400
|
name: "key_up",
|
|
7390
7401
|
key: "Meta",
|
|
7391
|
-
shiftKey: this.inputs.
|
|
7392
|
-
ctrlKey: this.inputs.
|
|
7393
|
-
altKey: this.inputs.
|
|
7394
|
-
metaKey: this.inputs.
|
|
7395
|
-
accelKey: this.inputs
|
|
7402
|
+
shiftKey: this.inputs.shiftKey,
|
|
7403
|
+
ctrlKey: this.inputs.ctrlKey,
|
|
7404
|
+
altKey: this.inputs.altKey,
|
|
7405
|
+
metaKey: this.inputs.metaKey,
|
|
7406
|
+
accelKey: (0, import_keyboard.isAccelKey)(this.inputs),
|
|
7396
7407
|
code: "MetaLeft"
|
|
7397
7408
|
});
|
|
7398
7409
|
}
|
|
@@ -7463,47 +7474,47 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7463
7474
|
const { type } = info;
|
|
7464
7475
|
if (info.type === "misc") {
|
|
7465
7476
|
if (info.name === "cancel" || info.name === "complete") {
|
|
7466
|
-
this.inputs.
|
|
7467
|
-
if (this.inputs.
|
|
7468
|
-
this.inputs.
|
|
7469
|
-
this.inputs.
|
|
7477
|
+
this.inputs.isDragging = false;
|
|
7478
|
+
if (this.inputs.isPanning) {
|
|
7479
|
+
this.inputs.isPanning = false;
|
|
7480
|
+
this.inputs.isSpacebarPanning = false;
|
|
7470
7481
|
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7471
7482
|
}
|
|
7472
7483
|
}
|
|
7473
7484
|
this.root.handleEvent(info);
|
|
7474
|
-
this.emit("event", info);
|
|
7475
7485
|
return;
|
|
7476
7486
|
}
|
|
7477
7487
|
if (info.shiftKey) {
|
|
7478
7488
|
clearTimeout(this._shiftKeyTimeout);
|
|
7479
7489
|
this._shiftKeyTimeout = -1;
|
|
7480
|
-
inputs.
|
|
7481
|
-
} else if (!info.shiftKey && inputs.
|
|
7490
|
+
inputs.shiftKey = true;
|
|
7491
|
+
} else if (!info.shiftKey && inputs.shiftKey && this._shiftKeyTimeout === -1) {
|
|
7482
7492
|
this._shiftKeyTimeout = this.timers.setTimeout(this._setShiftKeyTimeout, 150);
|
|
7483
7493
|
}
|
|
7484
7494
|
if (info.altKey) {
|
|
7485
7495
|
clearTimeout(this._altKeyTimeout);
|
|
7486
7496
|
this._altKeyTimeout = -1;
|
|
7487
|
-
inputs.
|
|
7488
|
-
} else if (!info.altKey && inputs.
|
|
7497
|
+
inputs.altKey = true;
|
|
7498
|
+
} else if (!info.altKey && inputs.altKey && this._altKeyTimeout === -1) {
|
|
7489
7499
|
this._altKeyTimeout = this.timers.setTimeout(this._setAltKeyTimeout, 150);
|
|
7490
7500
|
}
|
|
7491
7501
|
if (info.ctrlKey) {
|
|
7492
7502
|
clearTimeout(this._ctrlKeyTimeout);
|
|
7493
7503
|
this._ctrlKeyTimeout = -1;
|
|
7494
|
-
inputs.
|
|
7495
|
-
} else if (!info.ctrlKey && inputs.
|
|
7504
|
+
inputs.ctrlKey = true;
|
|
7505
|
+
} else if (!info.ctrlKey && inputs.ctrlKey && this._ctrlKeyTimeout === -1) {
|
|
7496
7506
|
this._ctrlKeyTimeout = this.timers.setTimeout(this._setCtrlKeyTimeout, 150);
|
|
7497
7507
|
}
|
|
7498
7508
|
if (info.metaKey) {
|
|
7499
7509
|
clearTimeout(this._metaKeyTimeout);
|
|
7500
7510
|
this._metaKeyTimeout = -1;
|
|
7501
|
-
inputs.
|
|
7502
|
-
} else if (!info.metaKey && inputs.
|
|
7511
|
+
inputs.metaKey = true;
|
|
7512
|
+
} else if (!info.metaKey && inputs.metaKey && this._metaKeyTimeout === -1) {
|
|
7503
7513
|
this._metaKeyTimeout = this.timers.setTimeout(this._setMetaKeyTimeout, 150);
|
|
7504
7514
|
}
|
|
7505
|
-
|
|
7506
|
-
|
|
7515
|
+
const { originPagePoint, currentPagePoint } = inputs;
|
|
7516
|
+
if (!inputs.isPointing) {
|
|
7517
|
+
inputs.isDragging = false;
|
|
7507
7518
|
}
|
|
7508
7519
|
const instanceState = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
|
|
7509
7520
|
const pageState = this.store.get(this._getCurrentPageStateId());
|
|
@@ -7512,23 +7523,23 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7512
7523
|
case "pinch": {
|
|
7513
7524
|
if (cameraOptions.isLocked) return;
|
|
7514
7525
|
clearTimeout(this._longPressTimeout);
|
|
7515
|
-
this.
|
|
7526
|
+
this._updateInputsFromEvent(info);
|
|
7516
7527
|
switch (info.name) {
|
|
7517
7528
|
case "pinch_start": {
|
|
7518
|
-
if (inputs.
|
|
7519
|
-
if (!inputs.
|
|
7529
|
+
if (inputs.isPinching) return;
|
|
7530
|
+
if (!inputs.isEditing) {
|
|
7531
|
+
this._pinchStart = this.getCamera().z;
|
|
7520
7532
|
if (!this._selectedShapeIdsAtPointerDown.length) {
|
|
7521
7533
|
this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds];
|
|
7522
7534
|
}
|
|
7523
7535
|
this._didPinch = true;
|
|
7524
|
-
inputs.
|
|
7536
|
+
inputs.isPinching = true;
|
|
7525
7537
|
this.interrupt();
|
|
7526
7538
|
}
|
|
7527
|
-
this.emit("event", info);
|
|
7528
7539
|
return;
|
|
7529
7540
|
}
|
|
7530
7541
|
case "pinch": {
|
|
7531
|
-
if (!inputs.
|
|
7542
|
+
if (!inputs.isPinching) return;
|
|
7532
7543
|
const {
|
|
7533
7544
|
point: { z = 1 },
|
|
7534
7545
|
delta: { x: dx, y: dy }
|
|
@@ -7552,12 +7563,11 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7552
7563
|
),
|
|
7553
7564
|
{ immediate: true }
|
|
7554
7565
|
);
|
|
7555
|
-
this.emit("event", info);
|
|
7556
7566
|
return;
|
|
7557
7567
|
}
|
|
7558
7568
|
case "pinch_end": {
|
|
7559
|
-
if (!inputs.
|
|
7560
|
-
inputs.
|
|
7569
|
+
if (!inputs.isPinching) return this;
|
|
7570
|
+
inputs.isPinching = false;
|
|
7561
7571
|
const { _selectedShapeIdsAtPointerDown: shapesToReselect } = this;
|
|
7562
7572
|
this.setSelectedShapes(this._selectedShapeIdsAtPointerDown);
|
|
7563
7573
|
this._selectedShapeIdsAtPointerDown = [];
|
|
@@ -7571,14 +7581,13 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7571
7581
|
});
|
|
7572
7582
|
}
|
|
7573
7583
|
}
|
|
7574
|
-
this.emit("event", info);
|
|
7575
7584
|
return;
|
|
7576
7585
|
}
|
|
7577
7586
|
}
|
|
7578
7587
|
}
|
|
7579
7588
|
case "wheel": {
|
|
7580
7589
|
if (cameraOptions.isLocked) return;
|
|
7581
|
-
this.
|
|
7590
|
+
this._updateInputsFromEvent(info);
|
|
7582
7591
|
const { panSpeed, zoomSpeed } = cameraOptions;
|
|
7583
7592
|
let wheelBehavior = cameraOptions.wheelBehavior;
|
|
7584
7593
|
const inputMode = this.user.getUserPreferences().inputMode;
|
|
@@ -7596,7 +7605,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7596
7605
|
if (info.ctrlKey) behavior = wheelBehavior === "pan" ? "zoom" : "pan";
|
|
7597
7606
|
switch (behavior) {
|
|
7598
7607
|
case "zoom": {
|
|
7599
|
-
const { x, y } = this.inputs.
|
|
7608
|
+
const { x, y } = this.inputs.currentScreenPoint;
|
|
7600
7609
|
let delta = dz;
|
|
7601
7610
|
if (wheelBehavior === "zoom") {
|
|
7602
7611
|
if (Math.abs(dy) > 10) {
|
|
@@ -7610,8 +7619,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7610
7619
|
immediate: true
|
|
7611
7620
|
});
|
|
7612
7621
|
this.maybeTrackPerformance("Zooming");
|
|
7613
|
-
this.root.handleEvent(info);
|
|
7614
|
-
this.emit("event", info);
|
|
7615
7622
|
return;
|
|
7616
7623
|
}
|
|
7617
7624
|
case "pan": {
|
|
@@ -7619,8 +7626,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7619
7626
|
immediate: true
|
|
7620
7627
|
});
|
|
7621
7628
|
this.maybeTrackPerformance("Panning");
|
|
7622
|
-
this.root.handleEvent(info);
|
|
7623
|
-
this.emit("event", info);
|
|
7624
7629
|
return;
|
|
7625
7630
|
}
|
|
7626
7631
|
}
|
|
@@ -7628,14 +7633,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7628
7633
|
break;
|
|
7629
7634
|
}
|
|
7630
7635
|
case "pointer": {
|
|
7631
|
-
if (inputs.
|
|
7632
|
-
this.
|
|
7636
|
+
if (inputs.isPinching) return;
|
|
7637
|
+
this._updateInputsFromEvent(info);
|
|
7633
7638
|
const { isPen } = info;
|
|
7634
7639
|
const { isPenMode } = instanceState;
|
|
7635
7640
|
switch (info.name) {
|
|
7636
7641
|
case "pointer_down": {
|
|
7637
7642
|
if (isPenMode && !isPen) return;
|
|
7638
|
-
if (!this.inputs.
|
|
7643
|
+
if (!this.inputs.isPanning) {
|
|
7639
7644
|
this._longPressTimeout = this.timers.setTimeout(() => {
|
|
7640
7645
|
const vsb = this.getViewportScreenBounds();
|
|
7641
7646
|
this.dispatch({
|
|
@@ -7644,7 +7649,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7644
7649
|
// viewport bounds, and will be again when this event is handled...
|
|
7645
7650
|
// so we need to counter-adjust from the stored value so that the
|
|
7646
7651
|
// new value is set correctly.
|
|
7647
|
-
point: this.inputs.
|
|
7652
|
+
point: this.inputs.originScreenPoint.clone().addXY(vsb.x, vsb.y),
|
|
7648
7653
|
name: "long_press"
|
|
7649
7654
|
});
|
|
7650
7655
|
}, this.options.longPressDurationMs);
|
|
@@ -7652,21 +7657,21 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7652
7657
|
this._selectedShapeIdsAtPointerDown = this.getSelectedShapeIds();
|
|
7653
7658
|
if (info.button === import_constants.LEFT_MOUSE_BUTTON) this.capturedPointerId = info.pointerId;
|
|
7654
7659
|
inputs.buttons.add(info.button);
|
|
7655
|
-
inputs.
|
|
7656
|
-
inputs.
|
|
7660
|
+
inputs.isPointing = true;
|
|
7661
|
+
inputs.isDragging = false;
|
|
7657
7662
|
if (!isPenMode && isPen) this.updateInstanceState({ isPenMode: true });
|
|
7658
7663
|
if (info.button === import_constants.STYLUS_ERASER_BUTTON) {
|
|
7659
7664
|
this._restoreToolId = this.getCurrentToolId();
|
|
7660
7665
|
this.complete();
|
|
7661
7666
|
this.setCurrentTool("eraser");
|
|
7662
7667
|
} else if (info.button === import_constants.MIDDLE_MOUSE_BUTTON) {
|
|
7663
|
-
if (!this.inputs.
|
|
7668
|
+
if (!this.inputs.isPanning) {
|
|
7664
7669
|
this._prevCursor = this.getInstanceState().cursor.type;
|
|
7665
7670
|
}
|
|
7666
|
-
this.inputs.
|
|
7671
|
+
this.inputs.isPanning = true;
|
|
7667
7672
|
clearTimeout(this._longPressTimeout);
|
|
7668
7673
|
}
|
|
7669
|
-
if (this.inputs.
|
|
7674
|
+
if (this.inputs.isPanning) {
|
|
7670
7675
|
this.stopCameraAnimation();
|
|
7671
7676
|
this.setCursor({ type: "grabbing", rotation: 0 });
|
|
7672
7677
|
return this;
|
|
@@ -7676,9 +7681,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7676
7681
|
case "pointer_move": {
|
|
7677
7682
|
if (!isPen && isPenMode) return;
|
|
7678
7683
|
const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
|
|
7679
|
-
if (this.inputs.
|
|
7680
|
-
const currentScreenPoint = this.inputs
|
|
7681
|
-
const previousScreenPoint = this.inputs.getPreviousScreenPoint();
|
|
7684
|
+
if (this.inputs.isPanning && this.inputs.isPointing) {
|
|
7685
|
+
const { currentScreenPoint, previousScreenPoint } = this.inputs;
|
|
7682
7686
|
const offset = import_Vec.Vec.Sub(currentScreenPoint, previousScreenPoint);
|
|
7683
7687
|
this.setCamera(new import_Vec.Vec(cx + offset.x / cz, cy + offset.y / cz, cz), {
|
|
7684
7688
|
immediate: true
|
|
@@ -7686,15 +7690,15 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7686
7690
|
this.maybeTrackPerformance("Panning");
|
|
7687
7691
|
return;
|
|
7688
7692
|
}
|
|
7689
|
-
if (inputs.
|
|
7690
|
-
inputs.
|
|
7693
|
+
if (inputs.isPointing && !inputs.isDragging && import_Vec.Vec.Dist2(originPagePoint, currentPagePoint) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
|
|
7694
|
+
inputs.isDragging = true;
|
|
7691
7695
|
clearTimeout(this._longPressTimeout);
|
|
7692
7696
|
}
|
|
7693
7697
|
break;
|
|
7694
7698
|
}
|
|
7695
7699
|
case "pointer_up": {
|
|
7696
|
-
inputs.
|
|
7697
|
-
inputs.
|
|
7700
|
+
inputs.isDragging = false;
|
|
7701
|
+
inputs.isPointing = false;
|
|
7698
7702
|
clearTimeout(this._longPressTimeout);
|
|
7699
7703
|
inputs.buttons.delete(info.button);
|
|
7700
7704
|
if (instanceState.isPenMode && !isPen) return;
|
|
@@ -7702,12 +7706,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7702
7706
|
this.capturedPointerId = null;
|
|
7703
7707
|
info.button = 0;
|
|
7704
7708
|
}
|
|
7705
|
-
if (inputs.
|
|
7709
|
+
if (inputs.isPanning) {
|
|
7706
7710
|
if (!inputs.keys.has("Space")) {
|
|
7707
|
-
inputs.
|
|
7708
|
-
inputs.
|
|
7711
|
+
inputs.isPanning = false;
|
|
7712
|
+
inputs.isSpacebarPanning = false;
|
|
7709
7713
|
}
|
|
7710
|
-
const slideDirection = this.inputs.
|
|
7714
|
+
const slideDirection = this.inputs.pointerVelocity;
|
|
7711
7715
|
const slideSpeed = Math.min(2, slideDirection.len());
|
|
7712
7716
|
switch (info.button) {
|
|
7713
7717
|
case import_constants.LEFT_MOUSE_BUTTON: {
|
|
@@ -7744,58 +7748,51 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7744
7748
|
switch (info.name) {
|
|
7745
7749
|
case "key_down": {
|
|
7746
7750
|
inputs.keys.add(info.code);
|
|
7747
|
-
if (
|
|
7748
|
-
if (
|
|
7749
|
-
|
|
7750
|
-
this._prevCursor = instanceState.cursor.type;
|
|
7751
|
-
}
|
|
7752
|
-
this.inputs.setIsPanning(true);
|
|
7753
|
-
this.inputs.setIsSpacebarPanning(true);
|
|
7754
|
-
clearTimeout(this._longPressTimeout);
|
|
7755
|
-
this.setCursor({
|
|
7756
|
-
type: this.inputs.getIsPointing() ? "grabbing" : "grab",
|
|
7757
|
-
rotation: 0
|
|
7758
|
-
});
|
|
7751
|
+
if (info.code === "Space" && !info.ctrlKey) {
|
|
7752
|
+
if (!this.inputs.isPanning) {
|
|
7753
|
+
this._prevCursor = instanceState.cursor.type;
|
|
7759
7754
|
}
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
case "ArrowDown": {
|
|
7772
|
-
offset = new import_Vec.Vec(0, 1);
|
|
7773
|
-
break;
|
|
7774
|
-
}
|
|
7775
|
-
case "ArrowLeft": {
|
|
7776
|
-
offset = new import_Vec.Vec(-1, 0);
|
|
7777
|
-
break;
|
|
7778
|
-
}
|
|
7755
|
+
this.inputs.isPanning = true;
|
|
7756
|
+
this.inputs.isSpacebarPanning = true;
|
|
7757
|
+
clearTimeout(this._longPressTimeout);
|
|
7758
|
+
this.setCursor({ type: this.inputs.isPointing ? "grabbing" : "grab", rotation: 0 });
|
|
7759
|
+
}
|
|
7760
|
+
if (this.inputs.isSpacebarPanning) {
|
|
7761
|
+
let offset;
|
|
7762
|
+
switch (info.code) {
|
|
7763
|
+
case "ArrowUp": {
|
|
7764
|
+
offset = new import_Vec.Vec(0, -1);
|
|
7765
|
+
break;
|
|
7779
7766
|
}
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
this._animateToViewport(next, { animation: { duration: 320 } });
|
|
7767
|
+
case "ArrowRight": {
|
|
7768
|
+
offset = new import_Vec.Vec(1, 0);
|
|
7769
|
+
break;
|
|
7784
7770
|
}
|
|
7771
|
+
case "ArrowDown": {
|
|
7772
|
+
offset = new import_Vec.Vec(0, 1);
|
|
7773
|
+
break;
|
|
7774
|
+
}
|
|
7775
|
+
case "ArrowLeft": {
|
|
7776
|
+
offset = new import_Vec.Vec(-1, 0);
|
|
7777
|
+
break;
|
|
7778
|
+
}
|
|
7779
|
+
}
|
|
7780
|
+
if (offset) {
|
|
7781
|
+
const bounds = this.getViewportPageBounds();
|
|
7782
|
+
const next = bounds.clone().translate(offset.mulV({ x: bounds.w, y: bounds.h }));
|
|
7783
|
+
this._animateToViewport(next, { animation: { duration: 320 } });
|
|
7785
7784
|
}
|
|
7786
7785
|
}
|
|
7787
7786
|
break;
|
|
7788
7787
|
}
|
|
7789
7788
|
case "key_up": {
|
|
7790
7789
|
inputs.keys.delete(info.code);
|
|
7791
|
-
if (
|
|
7792
|
-
if (
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7798
|
-
}
|
|
7790
|
+
if (info.code === "Space") {
|
|
7791
|
+
if (this.inputs.buttons.has(import_constants.MIDDLE_MOUSE_BUTTON)) {
|
|
7792
|
+
} else {
|
|
7793
|
+
this.inputs.isPanning = false;
|
|
7794
|
+
this.inputs.isSpacebarPanning = false;
|
|
7795
|
+
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7799
7796
|
}
|
|
7800
7797
|
}
|
|
7801
7798
|
break;
|
|
@@ -7848,8 +7845,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7848
7845
|
}
|
|
7849
7846
|
_init = __decoratorStart(_a);
|
|
7850
7847
|
__decorateElement(_init, 1, "getIsShapeHiddenCache", _getIsShapeHiddenCache_dec, Editor);
|
|
7851
|
-
__decorateElement(_init, 1, "
|
|
7852
|
-
__decorateElement(_init, 1, "
|
|
7848
|
+
__decorateElement(_init, 1, "getCanUndo", _getCanUndo_dec, Editor);
|
|
7849
|
+
__decorateElement(_init, 1, "getCanRedo", _getCanRedo_dec, Editor);
|
|
7853
7850
|
__decorateElement(_init, 1, "getPath", _getPath_dec, Editor);
|
|
7854
7851
|
__decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
|
|
7855
7852
|
__decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
|
|
@@ -7884,9 +7881,6 @@ __decorateElement(_init, 1, "getCamera", _getCamera_dec, Editor);
|
|
|
7884
7881
|
__decorateElement(_init, 1, "getViewportPageBoundsForFollowing", _getViewportPageBoundsForFollowing_dec, Editor);
|
|
7885
7882
|
__decorateElement(_init, 1, "getCameraForFollowing", _getCameraForFollowing_dec, Editor);
|
|
7886
7883
|
__decorateElement(_init, 1, "getZoomLevel", _getZoomLevel_dec, Editor);
|
|
7887
|
-
__decorateElement(_init, 1, "getDebouncedZoomLevel", _getDebouncedZoomLevel_dec, Editor);
|
|
7888
|
-
__decorateElement(_init, 1, "_getAboveDebouncedZoomThreshold", __getAboveDebouncedZoomThreshold_dec, Editor);
|
|
7889
|
-
__decorateElement(_init, 1, "getEfficientZoomLevel", _getEfficientZoomLevel_dec, Editor);
|
|
7890
7884
|
__decorateElement(_init, 1, "getViewportScreenBounds", _getViewportScreenBounds_dec, Editor);
|
|
7891
7885
|
__decorateElement(_init, 1, "getViewportScreenCenter", _getViewportScreenCenter_dec, Editor);
|
|
7892
7886
|
__decorateElement(_init, 1, "getViewportPageBounds", _getViewportPageBounds_dec, Editor);
|