@tldraw/editor 4.3.0-next.2d181ae353a2 → 4.3.0-next.40e4536afc8e
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 +443 -120
- package/dist-cjs/index.js +6 -1
- 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 +1 -17
- 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 +1 -3
- package/dist-cjs/lib/constants.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +292 -275
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +18 -17
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +3 -3
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js +12 -3
- 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 +5 -6
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +591 -0
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +7 -0
- 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 +1 -22
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +31 -23
- 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/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/parseCss.js +1 -1
- package/dist-cjs/lib/exports/parseCss.js.map +2 -2
- package/dist-cjs/lib/globals/environment.js +45 -9
- package/dist-cjs/lib/globals/environment.js.map +2 -2
- package/dist-cjs/lib/hooks/useCoarsePointer.js +14 -29
- 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 +4 -1
- 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 +4 -8
- package/dist-cjs/lib/hooks/useZoomCss.js.map +2 -2
- package/dist-cjs/lib/options.js +6 -1
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +3 -0
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +1 -0
- package/dist-cjs/lib/primitives/geometry/Geometry2d.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 +443 -120
- package/dist-esm/index.mjs +7 -2
- 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 +1 -17
- 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 +1 -3
- package/dist-esm/lib/constants.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +293 -278
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +18 -17
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +3 -3
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs +13 -4
- 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 +5 -6
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +573 -0
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +7 -0
- 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 +1 -22
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +31 -23
- 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/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/parseCss.mjs +1 -1
- package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
- package/dist-esm/lib/globals/environment.mjs +45 -9
- package/dist-esm/lib/globals/environment.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCoarsePointer.mjs +15 -30
- 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 +4 -1
- 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 +4 -8
- package/dist-esm/lib/hooks/useZoomCss.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +6 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +3 -0
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +1 -0
- package/dist-esm/lib/primitives/geometry/Geometry2d.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 +14 -12
- package/package.json +18 -16
- package/src/index.ts +4 -1
- package/src/lib/components/ErrorBoundary.tsx +1 -1
- package/src/lib/components/GeometryDebuggingView.tsx +1 -19
- package/src/lib/components/default-components/DefaultCanvas.tsx +4 -3
- package/src/lib/config/TLUserPreferences.test.ts +40 -0
- package/src/lib/constants.ts +0 -2
- package/src/lib/editor/Editor.test.ts +140 -0
- package/src/lib/editor/Editor.ts +378 -321
- package/src/lib/editor/derivations/notVisibleShapes.ts +37 -23
- package/src/lib/editor/derivations/parentsToChildren.ts +18 -7
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +17 -31
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +129 -79
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +10 -6
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +566 -0
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +0 -4
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +12 -0
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +1 -1
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +40 -107
- package/src/lib/editor/managers/TickManager/TickManager.ts +2 -32
- package/src/lib/editor/shapes/ShapeUtil.ts +67 -24
- package/src/lib/editor/shapes/group/DashedOutlineBox.tsx +1 -1
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +3 -3
- package/src/lib/editor/types/emit-types.ts +3 -1
- package/src/lib/exports/parseCss.test.ts +1 -0
- package/src/lib/exports/parseCss.ts +1 -1
- package/src/lib/globals/environment.ts +65 -10
- package/src/lib/hooks/useCoarsePointer.ts +16 -59
- 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 +4 -1
- package/src/lib/hooks/useTransform.ts +1 -1
- package/src/lib/hooks/useZoomCss.ts +3 -8
- package/src/lib/options.ts +32 -0
- package/src/lib/primitives/Box.ts +9 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +1 -0
- package/src/lib/utils/rotation.ts +1 -1
- package/src/version.ts +3 -3
|
@@ -104,7 +104,6 @@ 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");
|
|
108
107
|
var import_reorderShapes = require("../utils/reorderShapes");
|
|
109
108
|
var import_rotation = require("../utils/rotation");
|
|
110
109
|
var import_bindingsIndex = require("./derivations/bindingsIndex");
|
|
@@ -116,14 +115,15 @@ var import_EdgeScrollManager = require("./managers/EdgeScrollManager/EdgeScrollM
|
|
|
116
115
|
var import_FocusManager = require("./managers/FocusManager/FocusManager");
|
|
117
116
|
var import_FontManager = require("./managers/FontManager/FontManager");
|
|
118
117
|
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, _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,
|
|
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, _getEfficientZoomLevel_dec, __getAboveDebouncedZoomThreshold_dec, _getDebouncedZoomLevel_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, _canRedo_dec, _canUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
|
|
126
|
+
class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed], _canUndo_dec = [import_state.computed], _canRedo_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], _getDebouncedZoomLevel_dec = [import_state.computed], __getAboveDebouncedZoomThreshold_dec = [import_state.computed], _getEfficientZoomLevel_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 editor is disposed.
|
|
163
163
|
*
|
|
164
164
|
* @public
|
|
165
165
|
*/
|
|
@@ -170,10 +170,19 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
170
170
|
* @public
|
|
171
171
|
*/
|
|
172
172
|
__publicField(this, "isDisposed", false);
|
|
173
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* A manager for the editor's tick events.
|
|
175
|
+
*
|
|
176
|
+
* @internal */
|
|
174
177
|
__publicField(this, "_tickManager");
|
|
175
178
|
/**
|
|
176
|
-
* A manager for the
|
|
179
|
+
* A manager for the editor's input state.
|
|
180
|
+
*
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
__publicField(this, "inputs");
|
|
184
|
+
/**
|
|
185
|
+
* A manager for the editor's snapping feature.
|
|
177
186
|
*
|
|
178
187
|
* @public
|
|
179
188
|
*/
|
|
@@ -255,7 +264,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
255
264
|
__publicField(this, "bindingUtils");
|
|
256
265
|
/* --------------------- History -------------------- */
|
|
257
266
|
/**
|
|
258
|
-
* A manager for the
|
|
267
|
+
* A manager for the editor's history.
|
|
259
268
|
*
|
|
260
269
|
* @readonly
|
|
261
270
|
*/
|
|
@@ -270,6 +279,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
270
279
|
// Rich text editor
|
|
271
280
|
__publicField(this, "_currentRichTextEditor", (0, import_state.atom)("rich text editor", null));
|
|
272
281
|
__publicField(this, "_textOptions");
|
|
282
|
+
__publicField(this, "_debouncedZoomLevel", (0, import_state.atom)("debounced zoom level", 1));
|
|
273
283
|
__publicField(this, "_cameraOptions", (0, import_state.atom)("camera options", import_constants.DEFAULT_CAMERA_OPTIONS));
|
|
274
284
|
/** @internal */
|
|
275
285
|
__publicField(this, "_viewportAnimation", null);
|
|
@@ -320,54 +330,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
320
330
|
tldraw: null,
|
|
321
331
|
excalidraw: null
|
|
322
332
|
});
|
|
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
|
-
});
|
|
371
333
|
/**
|
|
372
334
|
* A manager for recording multiple click events.
|
|
373
335
|
*
|
|
@@ -391,8 +353,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
391
353
|
/** @internal */
|
|
392
354
|
__publicField(this, "_restoreToolId", "select");
|
|
393
355
|
/** @internal */
|
|
394
|
-
__publicField(this, "_pinchStart", 1);
|
|
395
|
-
/** @internal */
|
|
396
356
|
__publicField(this, "_didPinch", false);
|
|
397
357
|
/** @internal */
|
|
398
358
|
__publicField(this, "_selectedShapeIdsAtPointerDown", []);
|
|
@@ -428,6 +388,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
428
388
|
this.disposables.add(() => this.textMeasure.dispose());
|
|
429
389
|
this.fonts = new import_FontManager.FontManager(this, fontAssetUrls);
|
|
430
390
|
this._tickManager = new import_TickManager.TickManager(this);
|
|
391
|
+
this.inputs = new import_InputsManager.InputsManager(this);
|
|
431
392
|
class NewRoot extends import_RootState.RootState {
|
|
432
393
|
static initial = initialState ?? "";
|
|
433
394
|
}
|
|
@@ -860,6 +821,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
860
821
|
this.disposables.clear();
|
|
861
822
|
this.store.dispose();
|
|
862
823
|
this.isDisposed = true;
|
|
824
|
+
this.emit("dispose");
|
|
863
825
|
}
|
|
864
826
|
getShapeUtil(arg) {
|
|
865
827
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
@@ -893,9 +855,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
893
855
|
this.history.undo();
|
|
894
856
|
return this;
|
|
895
857
|
}
|
|
896
|
-
|
|
858
|
+
canUndo() {
|
|
897
859
|
return this.history.getNumUndos() > 0;
|
|
898
860
|
}
|
|
861
|
+
getCanUndo() {
|
|
862
|
+
return this.canUndo();
|
|
863
|
+
}
|
|
899
864
|
/**
|
|
900
865
|
* Redo to the next mark.
|
|
901
866
|
*
|
|
@@ -912,13 +877,16 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
912
877
|
this.history.redo();
|
|
913
878
|
return this;
|
|
914
879
|
}
|
|
880
|
+
canRedo() {
|
|
881
|
+
return this.history.getNumRedos() > 0;
|
|
882
|
+
}
|
|
883
|
+
getCanRedo() {
|
|
884
|
+
return this.canRedo();
|
|
885
|
+
}
|
|
915
886
|
clearHistory() {
|
|
916
887
|
this.history.clear();
|
|
917
888
|
return this;
|
|
918
889
|
}
|
|
919
|
-
getCanRedo() {
|
|
920
|
-
return this.history.getNumRedos() > 0;
|
|
921
|
-
}
|
|
922
890
|
/**
|
|
923
891
|
* Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
|
|
924
892
|
* any redos. You typically want to do this just before a user interaction begins or is handled.
|
|
@@ -1073,7 +1041,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1073
1041
|
}),
|
|
1074
1042
|
selectionCount: this.getSelectedShapes().length,
|
|
1075
1043
|
editingShape: editingShapeId ? this.getShape(editingShapeId) : void 0,
|
|
1076
|
-
inputs: this.inputs,
|
|
1044
|
+
inputs: this.inputs.toJson(),
|
|
1077
1045
|
pageState: this.getCurrentPageState(),
|
|
1078
1046
|
instanceState: this.getInstanceState(),
|
|
1079
1047
|
collaboratorCount: this.getCollaboratorsOnCurrentPage().length
|
|
@@ -1094,7 +1062,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1094
1062
|
* we're in a transaction that's about to be rolled back due to the same error we're currently
|
|
1095
1063
|
* reporting.
|
|
1096
1064
|
*
|
|
1097
|
-
* Instead, to listen to changes to this value, you need to listen to
|
|
1065
|
+
* Instead, to listen to changes to this value, you need to listen to editor's `crash` event.
|
|
1098
1066
|
*
|
|
1099
1067
|
* @internal
|
|
1100
1068
|
*/
|
|
@@ -1745,6 +1713,28 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1745
1713
|
const editingShapeId = this.getEditingShapeId();
|
|
1746
1714
|
return editingShapeId ? this.getShape(editingShapeId) : void 0;
|
|
1747
1715
|
}
|
|
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
|
+
}
|
|
1748
1738
|
/**
|
|
1749
1739
|
* Set the current editing shape.
|
|
1750
1740
|
*
|
|
@@ -1760,42 +1750,42 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1760
1750
|
*/
|
|
1761
1751
|
setEditingShape(shape) {
|
|
1762
1752
|
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1763
|
-
|
|
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
|
-
}
|
|
1753
|
+
if (!id) {
|
|
1785
1754
|
this.run(
|
|
1786
1755
|
() => {
|
|
1787
|
-
this.
|
|
1788
|
-
this._currentRichTextEditor.set(null);
|
|
1756
|
+
const prevEditingShapeId = this.getEditingShapeId();
|
|
1789
1757
|
if (prevEditingShapeId) {
|
|
1790
1758
|
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1791
1759
|
if (prevEditingShape) {
|
|
1792
1760
|
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1793
1761
|
}
|
|
1794
1762
|
}
|
|
1763
|
+
this._updateCurrentPageState({ editingShapeId: null });
|
|
1764
|
+
this._currentRichTextEditor.set(null);
|
|
1795
1765
|
},
|
|
1796
1766
|
{ history: "ignore" }
|
|
1797
1767
|
);
|
|
1768
|
+
return this;
|
|
1798
1769
|
}
|
|
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
|
+
);
|
|
1799
1789
|
return this;
|
|
1800
1790
|
}
|
|
1801
1791
|
getRichTextEditor() {
|
|
@@ -1928,6 +1918,25 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1928
1918
|
getCroppingShapeId() {
|
|
1929
1919
|
return this.getCurrentPageState().croppingShapeId;
|
|
1930
1920
|
}
|
|
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
|
+
}
|
|
1931
1940
|
/**
|
|
1932
1941
|
* Set the current cropping shape.
|
|
1933
1942
|
*
|
|
@@ -1949,12 +1958,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1949
1958
|
() => {
|
|
1950
1959
|
if (!id) {
|
|
1951
1960
|
this.updateCurrentPageState({ croppingShapeId: null });
|
|
1952
|
-
} else {
|
|
1953
|
-
|
|
1954
|
-
const util = this.getShapeUtil(shape2);
|
|
1955
|
-
if (shape2 && util.canCrop(shape2)) {
|
|
1956
|
-
this.updateCurrentPageState({ croppingShapeId: id });
|
|
1957
|
-
}
|
|
1961
|
+
} else if (this.canCropShape(id)) {
|
|
1962
|
+
this.updateCurrentPageState({ croppingShapeId: id });
|
|
1958
1963
|
}
|
|
1959
1964
|
},
|
|
1960
1965
|
{ history: "ignore" }
|
|
@@ -2029,6 +2034,22 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2029
2034
|
getZoomLevel() {
|
|
2030
2035
|
return this.getCamera().z;
|
|
2031
2036
|
}
|
|
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
|
+
}
|
|
2032
2053
|
/**
|
|
2033
2054
|
* Get the camera's initial or reset zoom level.
|
|
2034
2055
|
*
|
|
@@ -2274,7 +2295,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2274
2295
|
},
|
|
2275
2296
|
{ history: "ignore" }
|
|
2276
2297
|
);
|
|
2277
|
-
const
|
|
2298
|
+
const currentScreenPoint = this.inputs.getCurrentScreenPoint();
|
|
2299
|
+
const currentPagePoint = this.inputs.getCurrentPagePoint();
|
|
2278
2300
|
if (currentScreenPoint.x / z - x !== currentPagePoint.x || currentScreenPoint.y / z - y !== currentPagePoint.y) {
|
|
2279
2301
|
this.updatePointer({
|
|
2280
2302
|
immediate: opts?.immediate,
|
|
@@ -2409,7 +2431,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2409
2431
|
* ```ts
|
|
2410
2432
|
* editor.zoomIn()
|
|
2411
2433
|
* editor.zoomIn(editor.getViewportScreenCenter(), { animation: { duration: 200 } })
|
|
2412
|
-
* editor.zoomIn(editor.inputs.
|
|
2434
|
+
* editor.zoomIn(editor.inputs.getCurrentScreenPoint(), { animation: { duration: 200 } })
|
|
2413
2435
|
* ```
|
|
2414
2436
|
*
|
|
2415
2437
|
* @param point - The screen point to zoom in on. Defaults to the screen center
|
|
@@ -2450,7 +2472,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2450
2472
|
* ```ts
|
|
2451
2473
|
* editor.zoomOut()
|
|
2452
2474
|
* editor.zoomOut(editor.getViewportScreenCenter(), { animation: { duration: 120 } })
|
|
2453
|
-
* editor.zoomOut(editor.inputs.
|
|
2475
|
+
* editor.zoomOut(editor.inputs.getCurrentScreenPoint(), { animation: { duration: 120 } })
|
|
2454
2476
|
* ```
|
|
2455
2477
|
*
|
|
2456
2478
|
* @param point - The point to zoom out on. Defaults to the viewport screen center.
|
|
@@ -2502,10 +2524,15 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2502
2524
|
if (isLocked && !opts?.force) return this;
|
|
2503
2525
|
const selectionPageBounds = this.getSelectionPageBounds();
|
|
2504
2526
|
if (selectionPageBounds) {
|
|
2505
|
-
this.
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
}
|
|
2527
|
+
const currentZoom = this.getZoomLevel();
|
|
2528
|
+
if (Math.abs(currentZoom - 1) < 0.01) {
|
|
2529
|
+
this.zoomToBounds(selectionPageBounds, opts);
|
|
2530
|
+
} else {
|
|
2531
|
+
this.zoomToBounds(selectionPageBounds, {
|
|
2532
|
+
targetZoom: 1,
|
|
2533
|
+
...opts
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2509
2536
|
}
|
|
2510
2537
|
return this;
|
|
2511
2538
|
}
|
|
@@ -2545,7 +2572,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2545
2572
|
const cameraOptions = this._cameraOptions.__unsafe__getWithoutCapture();
|
|
2546
2573
|
if (cameraOptions.isLocked && !opts?.force) return this;
|
|
2547
2574
|
const viewportScreenBounds = this.getViewportScreenBounds();
|
|
2548
|
-
const inset = opts?.inset ?? Math.min(
|
|
2575
|
+
const inset = opts?.inset ?? Math.min(this.options.zoomToFitPadding, viewportScreenBounds.width * 0.28);
|
|
2549
2576
|
const baseZoom = this.getBaseZoom();
|
|
2550
2577
|
const zoomMin = cameraOptions.zoomSteps[0];
|
|
2551
2578
|
const zoomMax = (0, import_utils.last)(cameraOptions.zoomSteps);
|
|
@@ -2769,18 +2796,20 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2769
2796
|
}
|
|
2770
2797
|
if (_willSetInitialBounds) {
|
|
2771
2798
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2799
|
+
this.emit("resize", screenBounds.toJson());
|
|
2772
2800
|
this.setCamera(this.getCamera());
|
|
2773
2801
|
} else {
|
|
2774
2802
|
if (center && !this.getInstanceState().followingUserId) {
|
|
2775
2803
|
const before = this.getViewportPageBounds().center;
|
|
2776
2804
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2805
|
+
this.emit("resize", screenBounds.toJson());
|
|
2777
2806
|
this.centerOnPoint(before);
|
|
2778
2807
|
} else {
|
|
2779
2808
|
this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
|
|
2809
|
+
this.emit("resize", screenBounds.toJson());
|
|
2780
2810
|
this._setCamera(import_Vec.Vec.From({ ...this.getCamera() }));
|
|
2781
2811
|
}
|
|
2782
2812
|
}
|
|
2783
|
-
this._tickCameraState();
|
|
2784
2813
|
return this;
|
|
2785
2814
|
}
|
|
2786
2815
|
getViewportScreenBounds() {
|
|
@@ -3060,6 +3089,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3060
3089
|
this._cameraStateTimeoutRemaining = this.options.cameraMovingTimeoutMs;
|
|
3061
3090
|
if (this._cameraState.__unsafe__getWithoutCapture() !== "idle") return;
|
|
3062
3091
|
this._cameraState.set("moving");
|
|
3092
|
+
this._debouncedZoomLevel.set((0, import_state.unsafe__withoutCapture)(() => this.getCamera().z));
|
|
3063
3093
|
this.on("tick", this._decayCameraStateTimeout);
|
|
3064
3094
|
}
|
|
3065
3095
|
/**
|
|
@@ -5659,8 +5689,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5659
5689
|
isAspectRatioLocked: options.isAspectRatioLocked
|
|
5660
5690
|
});
|
|
5661
5691
|
if (Math.sign(scale.x) * Math.sign(scale.y) < 0) {
|
|
5662
|
-
|
|
5663
|
-
rotation
|
|
5692
|
+
const parentRotation = this.getShapeParentTransform(id).rotation();
|
|
5693
|
+
const rotation = -options.initialShape.rotation - 2 * parentRotation;
|
|
5664
5694
|
this.updateShapes([{ id, type, rotation }]);
|
|
5665
5695
|
}
|
|
5666
5696
|
const preScaleShapePageCenter = import_Mat.Mat.applyToPoint(
|
|
@@ -5673,9 +5703,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5673
5703
|
scale,
|
|
5674
5704
|
options.scaleAxisRotation
|
|
5675
5705
|
);
|
|
5676
|
-
const pageBounds = this.getShapePageBounds(id);
|
|
5677
5706
|
const pageTransform = this.getShapePageTransform(id);
|
|
5678
|
-
const
|
|
5707
|
+
const currentLocalBounds = this.getShapeGeometry(id).bounds;
|
|
5708
|
+
const currentPageCenter = import_Mat.Mat.applyToPoint(pageTransform, currentLocalBounds.center);
|
|
5679
5709
|
const shapePageTransformOrigin = pageTransform.point();
|
|
5680
5710
|
if (!currentPageCenter || !shapePageTransformOrigin) return this;
|
|
5681
5711
|
const pageDelta = import_Vec.Vec.Sub(postScaleShapePageCenter, currentPageCenter);
|
|
@@ -5961,7 +5991,11 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5961
5991
|
)
|
|
5962
5992
|
);
|
|
5963
5993
|
const sortedShapeIds = shapesToGroup.sort(import_utils.sortByIndex).map((s) => s.id);
|
|
5964
|
-
const
|
|
5994
|
+
const childBounds = (0, import_utils.compact)(shapesToGroup.map((shape) => this.getShapePageBounds(shape)));
|
|
5995
|
+
const pageBounds = import_Box.Box.Common(childBounds);
|
|
5996
|
+
if (!pageBounds.isValid()) {
|
|
5997
|
+
throw Error(`Editor.groupShapes: group bounds are invalid (NaN).`);
|
|
5998
|
+
}
|
|
5965
5999
|
const { x, y } = pageBounds.point;
|
|
5966
6000
|
const parentId = this.findCommonAncestor(shapesToGroup) ?? this.getCurrentPageId();
|
|
5967
6001
|
if (this.getCurrentToolId() !== "select") return this;
|
|
@@ -6651,6 +6685,25 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6651
6685
|
}
|
|
6652
6686
|
}
|
|
6653
6687
|
}
|
|
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
|
+
}
|
|
6654
6707
|
let isDuplicating = false;
|
|
6655
6708
|
if (!(0, import_tlschema.isPageId)(pasteParentId)) {
|
|
6656
6709
|
const parent = this.getShape(pasteParentId);
|
|
@@ -6895,60 +6948,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6895
6948
|
height
|
|
6896
6949
|
};
|
|
6897
6950
|
}
|
|
6898
|
-
|
|
6899
|
-
* Update the input points from a pointer, pinch, or wheel event.
|
|
6900
|
-
*
|
|
6901
|
-
* @param info - The event info.
|
|
6902
|
-
*/
|
|
6903
|
-
_updateInputsFromEvent(info) {
|
|
6904
|
-
const {
|
|
6905
|
-
pointerVelocity,
|
|
6906
|
-
previousScreenPoint,
|
|
6907
|
-
previousPagePoint,
|
|
6908
|
-
currentScreenPoint,
|
|
6909
|
-
currentPagePoint,
|
|
6910
|
-
originScreenPoint,
|
|
6911
|
-
originPagePoint
|
|
6912
|
-
} = this.inputs;
|
|
6913
|
-
const { screenBounds } = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
|
|
6914
|
-
const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
|
|
6915
|
-
const sx = info.point.x - screenBounds.x;
|
|
6916
|
-
const sy = info.point.y - screenBounds.y;
|
|
6917
|
-
const sz = info.point.z ?? 0.5;
|
|
6918
|
-
previousScreenPoint.setTo(currentScreenPoint);
|
|
6919
|
-
previousPagePoint.setTo(currentPagePoint);
|
|
6920
|
-
currentScreenPoint.set(sx, sy);
|
|
6921
|
-
const nx = sx / cz - cx;
|
|
6922
|
-
const ny = sy / cz - cy;
|
|
6923
|
-
if (isFinite(nx) && isFinite(ny)) {
|
|
6924
|
-
currentPagePoint.set(nx, ny, sz);
|
|
6925
|
-
}
|
|
6926
|
-
this.inputs.isPen = info.type === "pointer" && info.isPen;
|
|
6927
|
-
if (info.name === "pointer_down" || this.inputs.isPinching) {
|
|
6928
|
-
pointerVelocity.set(0, 0);
|
|
6929
|
-
originScreenPoint.setTo(currentScreenPoint);
|
|
6930
|
-
originPagePoint.setTo(currentPagePoint);
|
|
6931
|
-
}
|
|
6932
|
-
this.run(
|
|
6933
|
-
() => {
|
|
6934
|
-
this.store.put([
|
|
6935
|
-
{
|
|
6936
|
-
id: import_tlschema.TLPOINTER_ID,
|
|
6937
|
-
typeName: "pointer",
|
|
6938
|
-
x: currentPagePoint.x,
|
|
6939
|
-
y: currentPagePoint.y,
|
|
6940
|
-
lastActivityTimestamp: (
|
|
6941
|
-
// If our pointer moved only because we're following some other user, then don't
|
|
6942
|
-
// update our last activity timestamp; otherwise, update it to the current timestamp.
|
|
6943
|
-
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
|
|
6944
|
-
),
|
|
6945
|
-
meta: {}
|
|
6946
|
-
}
|
|
6947
|
-
]);
|
|
6948
|
-
},
|
|
6949
|
-
{ history: "ignore" }
|
|
6950
|
-
);
|
|
6951
|
-
}
|
|
6951
|
+
/* --------------------- Events --------------------- */
|
|
6952
6952
|
/**
|
|
6953
6953
|
* Dispatch a cancel event.
|
|
6954
6954
|
*
|
|
@@ -7013,18 +7013,19 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7013
7013
|
point: options?.point ?? // weird but true: what `inputs` calls screen-space is actually viewport space. so
|
|
7014
7014
|
// we need to convert back into true screen space first. we should fix this...
|
|
7015
7015
|
import_Vec.Vec.Add(
|
|
7016
|
-
this.inputs.
|
|
7016
|
+
this.inputs.getCurrentScreenPoint(),
|
|
7017
7017
|
this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID).screenBounds
|
|
7018
7018
|
),
|
|
7019
7019
|
pointerId: options?.pointerId ?? 0,
|
|
7020
7020
|
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:
|
|
7021
|
+
isPen: options?.isPen ?? this.inputs.getIsPen(),
|
|
7022
|
+
shiftKey: options?.shiftKey ?? this.inputs.getShiftKey(),
|
|
7023
|
+
altKey: options?.altKey ?? this.inputs.getAltKey(),
|
|
7024
|
+
ctrlKey: options?.ctrlKey ?? this.inputs.getCtrlKey(),
|
|
7025
|
+
metaKey: options?.metaKey ?? this.inputs.getMetaKey(),
|
|
7026
|
+
accelKey: false
|
|
7027
7027
|
};
|
|
7028
|
+
event.accelKey = options?.accelKey ?? this.inputs.getAccelKey();
|
|
7028
7029
|
if (options?.immediate) {
|
|
7029
7030
|
this._flushEventForTick(event);
|
|
7030
7031
|
} else {
|
|
@@ -7340,58 +7341,58 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7340
7341
|
this._clickManager.cancelDoubleClickTimeout();
|
|
7341
7342
|
}
|
|
7342
7343
|
_setShiftKeyTimeout() {
|
|
7343
|
-
this.inputs.
|
|
7344
|
+
this.inputs.setShiftKey(false);
|
|
7344
7345
|
this.dispatch({
|
|
7345
7346
|
type: "keyboard",
|
|
7346
7347
|
name: "key_up",
|
|
7347
7348
|
key: "Shift",
|
|
7348
|
-
shiftKey: this.inputs.
|
|
7349
|
-
ctrlKey: this.inputs.
|
|
7350
|
-
altKey: this.inputs.
|
|
7351
|
-
metaKey: this.inputs.
|
|
7352
|
-
accelKey:
|
|
7349
|
+
shiftKey: this.inputs.getShiftKey(),
|
|
7350
|
+
ctrlKey: this.inputs.getCtrlKey(),
|
|
7351
|
+
altKey: this.inputs.getAltKey(),
|
|
7352
|
+
metaKey: this.inputs.getMetaKey(),
|
|
7353
|
+
accelKey: this.inputs.getAccelKey(),
|
|
7353
7354
|
code: "ShiftLeft"
|
|
7354
7355
|
});
|
|
7355
7356
|
}
|
|
7356
7357
|
_setAltKeyTimeout() {
|
|
7357
|
-
this.inputs.
|
|
7358
|
+
this.inputs.setAltKey(false);
|
|
7358
7359
|
this.dispatch({
|
|
7359
7360
|
type: "keyboard",
|
|
7360
7361
|
name: "key_up",
|
|
7361
7362
|
key: "Alt",
|
|
7362
|
-
shiftKey: this.inputs.
|
|
7363
|
-
ctrlKey: this.inputs.
|
|
7364
|
-
altKey: this.inputs.
|
|
7365
|
-
metaKey: this.inputs.
|
|
7366
|
-
accelKey:
|
|
7363
|
+
shiftKey: this.inputs.getShiftKey(),
|
|
7364
|
+
ctrlKey: this.inputs.getCtrlKey(),
|
|
7365
|
+
altKey: this.inputs.getAltKey(),
|
|
7366
|
+
metaKey: this.inputs.getMetaKey(),
|
|
7367
|
+
accelKey: this.inputs.getAccelKey(),
|
|
7367
7368
|
code: "AltLeft"
|
|
7368
7369
|
});
|
|
7369
7370
|
}
|
|
7370
7371
|
_setCtrlKeyTimeout() {
|
|
7371
|
-
this.inputs.
|
|
7372
|
+
this.inputs.setCtrlKey(false);
|
|
7372
7373
|
this.dispatch({
|
|
7373
7374
|
type: "keyboard",
|
|
7374
7375
|
name: "key_up",
|
|
7375
7376
|
key: "Ctrl",
|
|
7376
|
-
shiftKey: this.inputs.
|
|
7377
|
-
ctrlKey: this.inputs.
|
|
7378
|
-
altKey: this.inputs.
|
|
7379
|
-
metaKey: this.inputs.
|
|
7380
|
-
accelKey:
|
|
7377
|
+
shiftKey: this.inputs.getShiftKey(),
|
|
7378
|
+
ctrlKey: this.inputs.getCtrlKey(),
|
|
7379
|
+
altKey: this.inputs.getAltKey(),
|
|
7380
|
+
metaKey: this.inputs.getMetaKey(),
|
|
7381
|
+
accelKey: this.inputs.getAccelKey(),
|
|
7381
7382
|
code: "ControlLeft"
|
|
7382
7383
|
});
|
|
7383
7384
|
}
|
|
7384
7385
|
_setMetaKeyTimeout() {
|
|
7385
|
-
this.inputs.
|
|
7386
|
+
this.inputs.setMetaKey(false);
|
|
7386
7387
|
this.dispatch({
|
|
7387
7388
|
type: "keyboard",
|
|
7388
7389
|
name: "key_up",
|
|
7389
7390
|
key: "Meta",
|
|
7390
|
-
shiftKey: this.inputs.
|
|
7391
|
-
ctrlKey: this.inputs.
|
|
7392
|
-
altKey: this.inputs.
|
|
7393
|
-
metaKey: this.inputs.
|
|
7394
|
-
accelKey:
|
|
7391
|
+
shiftKey: this.inputs.getShiftKey(),
|
|
7392
|
+
ctrlKey: this.inputs.getCtrlKey(),
|
|
7393
|
+
altKey: this.inputs.getAltKey(),
|
|
7394
|
+
metaKey: this.inputs.getMetaKey(),
|
|
7395
|
+
accelKey: this.inputs.getAccelKey(),
|
|
7395
7396
|
code: "MetaLeft"
|
|
7396
7397
|
});
|
|
7397
7398
|
}
|
|
@@ -7462,48 +7463,47 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7462
7463
|
const { type } = info;
|
|
7463
7464
|
if (info.type === "misc") {
|
|
7464
7465
|
if (info.name === "cancel" || info.name === "complete") {
|
|
7465
|
-
this.inputs.
|
|
7466
|
-
if (this.inputs.
|
|
7467
|
-
this.inputs.
|
|
7468
|
-
this.inputs.
|
|
7466
|
+
this.inputs.setIsDragging(false);
|
|
7467
|
+
if (this.inputs.getIsPanning()) {
|
|
7468
|
+
this.inputs.setIsPanning(false);
|
|
7469
|
+
this.inputs.setIsSpacebarPanning(false);
|
|
7469
7470
|
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7470
7471
|
}
|
|
7471
7472
|
}
|
|
7472
|
-
this.emit("event", info);
|
|
7473
7473
|
this.root.handleEvent(info);
|
|
7474
|
+
this.emit("event", info);
|
|
7474
7475
|
return;
|
|
7475
7476
|
}
|
|
7476
7477
|
if (info.shiftKey) {
|
|
7477
7478
|
clearTimeout(this._shiftKeyTimeout);
|
|
7478
7479
|
this._shiftKeyTimeout = -1;
|
|
7479
|
-
inputs.
|
|
7480
|
-
} else if (!info.shiftKey && inputs.
|
|
7480
|
+
inputs.setShiftKey(true);
|
|
7481
|
+
} else if (!info.shiftKey && inputs.getShiftKey() && this._shiftKeyTimeout === -1) {
|
|
7481
7482
|
this._shiftKeyTimeout = this.timers.setTimeout(this._setShiftKeyTimeout, 150);
|
|
7482
7483
|
}
|
|
7483
7484
|
if (info.altKey) {
|
|
7484
7485
|
clearTimeout(this._altKeyTimeout);
|
|
7485
7486
|
this._altKeyTimeout = -1;
|
|
7486
|
-
inputs.
|
|
7487
|
-
} else if (!info.altKey && inputs.
|
|
7487
|
+
inputs.setAltKey(true);
|
|
7488
|
+
} else if (!info.altKey && inputs.getAltKey() && this._altKeyTimeout === -1) {
|
|
7488
7489
|
this._altKeyTimeout = this.timers.setTimeout(this._setAltKeyTimeout, 150);
|
|
7489
7490
|
}
|
|
7490
7491
|
if (info.ctrlKey) {
|
|
7491
7492
|
clearTimeout(this._ctrlKeyTimeout);
|
|
7492
7493
|
this._ctrlKeyTimeout = -1;
|
|
7493
|
-
inputs.
|
|
7494
|
-
} else if (!info.ctrlKey && inputs.
|
|
7494
|
+
inputs.setCtrlKey(true);
|
|
7495
|
+
} else if (!info.ctrlKey && inputs.getCtrlKey() && this._ctrlKeyTimeout === -1) {
|
|
7495
7496
|
this._ctrlKeyTimeout = this.timers.setTimeout(this._setCtrlKeyTimeout, 150);
|
|
7496
7497
|
}
|
|
7497
7498
|
if (info.metaKey) {
|
|
7498
7499
|
clearTimeout(this._metaKeyTimeout);
|
|
7499
7500
|
this._metaKeyTimeout = -1;
|
|
7500
|
-
inputs.
|
|
7501
|
-
} else if (!info.metaKey && inputs.
|
|
7501
|
+
inputs.setMetaKey(true);
|
|
7502
|
+
} else if (!info.metaKey && inputs.getMetaKey() && this._metaKeyTimeout === -1) {
|
|
7502
7503
|
this._metaKeyTimeout = this.timers.setTimeout(this._setMetaKeyTimeout, 150);
|
|
7503
7504
|
}
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
inputs.isDragging = false;
|
|
7505
|
+
if (!inputs.getIsPointing()) {
|
|
7506
|
+
inputs.setIsDragging(false);
|
|
7507
7507
|
}
|
|
7508
7508
|
const instanceState = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
|
|
7509
7509
|
const pageState = this.store.get(this._getCurrentPageStateId());
|
|
@@ -7512,23 +7512,23 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7512
7512
|
case "pinch": {
|
|
7513
7513
|
if (cameraOptions.isLocked) return;
|
|
7514
7514
|
clearTimeout(this._longPressTimeout);
|
|
7515
|
-
this.
|
|
7515
|
+
this.inputs.updateFromEvent(info);
|
|
7516
7516
|
switch (info.name) {
|
|
7517
7517
|
case "pinch_start": {
|
|
7518
|
-
if (inputs.
|
|
7519
|
-
if (!inputs.
|
|
7520
|
-
this._pinchStart = this.getCamera().z;
|
|
7518
|
+
if (inputs.getIsPinching()) return;
|
|
7519
|
+
if (!inputs.getIsEditing()) {
|
|
7521
7520
|
if (!this._selectedShapeIdsAtPointerDown.length) {
|
|
7522
7521
|
this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds];
|
|
7523
7522
|
}
|
|
7524
7523
|
this._didPinch = true;
|
|
7525
|
-
inputs.
|
|
7524
|
+
inputs.setIsPinching(true);
|
|
7526
7525
|
this.interrupt();
|
|
7527
7526
|
}
|
|
7527
|
+
this.emit("event", info);
|
|
7528
7528
|
return;
|
|
7529
7529
|
}
|
|
7530
7530
|
case "pinch": {
|
|
7531
|
-
if (!inputs.
|
|
7531
|
+
if (!inputs.getIsPinching()) return;
|
|
7532
7532
|
const {
|
|
7533
7533
|
point: { z = 1 },
|
|
7534
7534
|
delta: { x: dx, y: dy }
|
|
@@ -7552,11 +7552,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7552
7552
|
),
|
|
7553
7553
|
{ immediate: true }
|
|
7554
7554
|
);
|
|
7555
|
+
this.emit("event", info);
|
|
7555
7556
|
return;
|
|
7556
7557
|
}
|
|
7557
7558
|
case "pinch_end": {
|
|
7558
|
-
if (!inputs.
|
|
7559
|
-
inputs.
|
|
7559
|
+
if (!inputs.getIsPinching()) return this;
|
|
7560
|
+
inputs.setIsPinching(false);
|
|
7560
7561
|
const { _selectedShapeIdsAtPointerDown: shapesToReselect } = this;
|
|
7561
7562
|
this.setSelectedShapes(this._selectedShapeIdsAtPointerDown);
|
|
7562
7563
|
this._selectedShapeIdsAtPointerDown = [];
|
|
@@ -7570,13 +7571,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7570
7571
|
});
|
|
7571
7572
|
}
|
|
7572
7573
|
}
|
|
7574
|
+
this.emit("event", info);
|
|
7573
7575
|
return;
|
|
7574
7576
|
}
|
|
7575
7577
|
}
|
|
7576
7578
|
}
|
|
7577
7579
|
case "wheel": {
|
|
7578
7580
|
if (cameraOptions.isLocked) return;
|
|
7579
|
-
this.
|
|
7581
|
+
this.inputs.updateFromEvent(info);
|
|
7580
7582
|
const { panSpeed, zoomSpeed } = cameraOptions;
|
|
7581
7583
|
let wheelBehavior = cameraOptions.wheelBehavior;
|
|
7582
7584
|
const inputMode = this.user.getUserPreferences().inputMode;
|
|
@@ -7594,7 +7596,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7594
7596
|
if (info.ctrlKey) behavior = wheelBehavior === "pan" ? "zoom" : "pan";
|
|
7595
7597
|
switch (behavior) {
|
|
7596
7598
|
case "zoom": {
|
|
7597
|
-
const { x, y } = this.inputs.
|
|
7599
|
+
const { x, y } = this.inputs.getCurrentScreenPoint();
|
|
7598
7600
|
let delta = dz;
|
|
7599
7601
|
if (wheelBehavior === "zoom") {
|
|
7600
7602
|
if (Math.abs(dy) > 10) {
|
|
@@ -7608,6 +7610,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7608
7610
|
immediate: true
|
|
7609
7611
|
});
|
|
7610
7612
|
this.maybeTrackPerformance("Zooming");
|
|
7613
|
+
this.root.handleEvent(info);
|
|
7614
|
+
this.emit("event", info);
|
|
7611
7615
|
return;
|
|
7612
7616
|
}
|
|
7613
7617
|
case "pan": {
|
|
@@ -7615,6 +7619,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7615
7619
|
immediate: true
|
|
7616
7620
|
});
|
|
7617
7621
|
this.maybeTrackPerformance("Panning");
|
|
7622
|
+
this.root.handleEvent(info);
|
|
7623
|
+
this.emit("event", info);
|
|
7618
7624
|
return;
|
|
7619
7625
|
}
|
|
7620
7626
|
}
|
|
@@ -7622,14 +7628,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7622
7628
|
break;
|
|
7623
7629
|
}
|
|
7624
7630
|
case "pointer": {
|
|
7625
|
-
if (inputs.
|
|
7626
|
-
this.
|
|
7631
|
+
if (inputs.getIsPinching()) return;
|
|
7632
|
+
this.inputs.updateFromEvent(info);
|
|
7627
7633
|
const { isPen } = info;
|
|
7628
7634
|
const { isPenMode } = instanceState;
|
|
7629
7635
|
switch (info.name) {
|
|
7630
7636
|
case "pointer_down": {
|
|
7631
7637
|
if (isPenMode && !isPen) return;
|
|
7632
|
-
if (!this.inputs.
|
|
7638
|
+
if (!this.inputs.getIsPanning()) {
|
|
7633
7639
|
this._longPressTimeout = this.timers.setTimeout(() => {
|
|
7634
7640
|
const vsb = this.getViewportScreenBounds();
|
|
7635
7641
|
this.dispatch({
|
|
@@ -7638,7 +7644,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7638
7644
|
// viewport bounds, and will be again when this event is handled...
|
|
7639
7645
|
// so we need to counter-adjust from the stored value so that the
|
|
7640
7646
|
// new value is set correctly.
|
|
7641
|
-
point: this.inputs.
|
|
7647
|
+
point: this.inputs.getOriginScreenPoint().clone().addXY(vsb.x, vsb.y),
|
|
7642
7648
|
name: "long_press"
|
|
7643
7649
|
});
|
|
7644
7650
|
}, this.options.longPressDurationMs);
|
|
@@ -7646,21 +7652,21 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7646
7652
|
this._selectedShapeIdsAtPointerDown = this.getSelectedShapeIds();
|
|
7647
7653
|
if (info.button === import_constants.LEFT_MOUSE_BUTTON) this.capturedPointerId = info.pointerId;
|
|
7648
7654
|
inputs.buttons.add(info.button);
|
|
7649
|
-
inputs.
|
|
7650
|
-
inputs.
|
|
7655
|
+
inputs.setIsPointing(true);
|
|
7656
|
+
inputs.setIsDragging(false);
|
|
7651
7657
|
if (!isPenMode && isPen) this.updateInstanceState({ isPenMode: true });
|
|
7652
7658
|
if (info.button === import_constants.STYLUS_ERASER_BUTTON) {
|
|
7653
7659
|
this._restoreToolId = this.getCurrentToolId();
|
|
7654
7660
|
this.complete();
|
|
7655
7661
|
this.setCurrentTool("eraser");
|
|
7656
7662
|
} else if (info.button === import_constants.MIDDLE_MOUSE_BUTTON) {
|
|
7657
|
-
if (!this.inputs.
|
|
7663
|
+
if (!this.inputs.getIsPanning()) {
|
|
7658
7664
|
this._prevCursor = this.getInstanceState().cursor.type;
|
|
7659
7665
|
}
|
|
7660
|
-
this.inputs.
|
|
7666
|
+
this.inputs.setIsPanning(true);
|
|
7661
7667
|
clearTimeout(this._longPressTimeout);
|
|
7662
7668
|
}
|
|
7663
|
-
if (this.inputs.
|
|
7669
|
+
if (this.inputs.getIsPanning()) {
|
|
7664
7670
|
this.stopCameraAnimation();
|
|
7665
7671
|
this.setCursor({ type: "grabbing", rotation: 0 });
|
|
7666
7672
|
return this;
|
|
@@ -7670,8 +7676,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7670
7676
|
case "pointer_move": {
|
|
7671
7677
|
if (!isPen && isPenMode) return;
|
|
7672
7678
|
const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
|
|
7673
|
-
if (this.inputs.
|
|
7674
|
-
const
|
|
7679
|
+
if (this.inputs.getIsPanning() && this.inputs.getIsPointing()) {
|
|
7680
|
+
const currentScreenPoint = this.inputs.getCurrentScreenPoint();
|
|
7681
|
+
const previousScreenPoint = this.inputs.getPreviousScreenPoint();
|
|
7675
7682
|
const offset = import_Vec.Vec.Sub(currentScreenPoint, previousScreenPoint);
|
|
7676
7683
|
this.setCamera(new import_Vec.Vec(cx + offset.x / cz, cy + offset.y / cz, cz), {
|
|
7677
7684
|
immediate: true
|
|
@@ -7679,15 +7686,15 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7679
7686
|
this.maybeTrackPerformance("Panning");
|
|
7680
7687
|
return;
|
|
7681
7688
|
}
|
|
7682
|
-
if (inputs.
|
|
7683
|
-
inputs.
|
|
7689
|
+
if (inputs.getIsPointing() && !inputs.getIsDragging() && import_Vec.Vec.Dist2(inputs.getOriginPagePoint(), inputs.getCurrentPagePoint()) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
|
|
7690
|
+
inputs.setIsDragging(true);
|
|
7684
7691
|
clearTimeout(this._longPressTimeout);
|
|
7685
7692
|
}
|
|
7686
7693
|
break;
|
|
7687
7694
|
}
|
|
7688
7695
|
case "pointer_up": {
|
|
7689
|
-
inputs.
|
|
7690
|
-
inputs.
|
|
7696
|
+
inputs.setIsDragging(false);
|
|
7697
|
+
inputs.setIsPointing(false);
|
|
7691
7698
|
clearTimeout(this._longPressTimeout);
|
|
7692
7699
|
inputs.buttons.delete(info.button);
|
|
7693
7700
|
if (instanceState.isPenMode && !isPen) return;
|
|
@@ -7695,12 +7702,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7695
7702
|
this.capturedPointerId = null;
|
|
7696
7703
|
info.button = 0;
|
|
7697
7704
|
}
|
|
7698
|
-
if (inputs.
|
|
7705
|
+
if (inputs.getIsPanning()) {
|
|
7699
7706
|
if (!inputs.keys.has("Space")) {
|
|
7700
|
-
inputs.
|
|
7701
|
-
inputs.
|
|
7707
|
+
inputs.setIsPanning(false);
|
|
7708
|
+
inputs.setIsSpacebarPanning(false);
|
|
7702
7709
|
}
|
|
7703
|
-
const slideDirection = this.inputs.
|
|
7710
|
+
const slideDirection = this.inputs.getPointerVelocity();
|
|
7704
7711
|
const slideSpeed = Math.min(2, slideDirection.len());
|
|
7705
7712
|
switch (info.button) {
|
|
7706
7713
|
case import_constants.LEFT_MOUSE_BUTTON: {
|
|
@@ -7737,51 +7744,58 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7737
7744
|
switch (info.name) {
|
|
7738
7745
|
case "key_down": {
|
|
7739
7746
|
inputs.keys.add(info.code);
|
|
7740
|
-
if (
|
|
7741
|
-
if (!
|
|
7742
|
-
this.
|
|
7743
|
-
|
|
7744
|
-
this.inputs.isPanning = true;
|
|
7745
|
-
this.inputs.isSpacebarPanning = true;
|
|
7746
|
-
clearTimeout(this._longPressTimeout);
|
|
7747
|
-
this.setCursor({ type: this.inputs.isPointing ? "grabbing" : "grab", rotation: 0 });
|
|
7748
|
-
}
|
|
7749
|
-
if (this.inputs.isSpacebarPanning) {
|
|
7750
|
-
let offset;
|
|
7751
|
-
switch (info.code) {
|
|
7752
|
-
case "ArrowUp": {
|
|
7753
|
-
offset = new import_Vec.Vec(0, -1);
|
|
7754
|
-
break;
|
|
7747
|
+
if (this.options.spacebarPanning) {
|
|
7748
|
+
if (info.code === "Space" && !info.ctrlKey) {
|
|
7749
|
+
if (!this.inputs.getIsPanning()) {
|
|
7750
|
+
this._prevCursor = instanceState.cursor.type;
|
|
7755
7751
|
}
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
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
|
+
});
|
|
7759
|
+
}
|
|
7760
|
+
if (this.inputs.getIsSpacebarPanning()) {
|
|
7761
|
+
let offset;
|
|
7762
|
+
switch (info.code) {
|
|
7763
|
+
case "ArrowUp": {
|
|
7764
|
+
offset = new import_Vec.Vec(0, -1);
|
|
7765
|
+
break;
|
|
7766
|
+
}
|
|
7767
|
+
case "ArrowRight": {
|
|
7768
|
+
offset = new import_Vec.Vec(1, 0);
|
|
7769
|
+
break;
|
|
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
|
+
}
|
|
7763
7779
|
}
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
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 } });
|
|
7767
7784
|
}
|
|
7768
7785
|
}
|
|
7769
|
-
if (offset) {
|
|
7770
|
-
const bounds = this.getViewportPageBounds();
|
|
7771
|
-
const next = bounds.clone().translate(offset.mulV({ x: bounds.w, y: bounds.h }));
|
|
7772
|
-
this._animateToViewport(next, { animation: { duration: 320 } });
|
|
7773
|
-
}
|
|
7774
7786
|
}
|
|
7775
7787
|
break;
|
|
7776
7788
|
}
|
|
7777
7789
|
case "key_up": {
|
|
7778
7790
|
inputs.keys.delete(info.code);
|
|
7779
|
-
if (
|
|
7780
|
-
if (
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7791
|
+
if (this.options.spacebarPanning) {
|
|
7792
|
+
if (info.code === "Space") {
|
|
7793
|
+
if (this.inputs.buttons.has(import_constants.MIDDLE_MOUSE_BUTTON)) {
|
|
7794
|
+
} else {
|
|
7795
|
+
this.inputs.setIsPanning(false);
|
|
7796
|
+
this.inputs.setIsSpacebarPanning(false);
|
|
7797
|
+
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7798
|
+
}
|
|
7785
7799
|
}
|
|
7786
7800
|
}
|
|
7787
7801
|
break;
|
|
@@ -7834,8 +7848,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7834
7848
|
}
|
|
7835
7849
|
_init = __decoratorStart(_a);
|
|
7836
7850
|
__decorateElement(_init, 1, "getIsShapeHiddenCache", _getIsShapeHiddenCache_dec, Editor);
|
|
7837
|
-
__decorateElement(_init, 1, "
|
|
7838
|
-
__decorateElement(_init, 1, "
|
|
7851
|
+
__decorateElement(_init, 1, "canUndo", _canUndo_dec, Editor);
|
|
7852
|
+
__decorateElement(_init, 1, "canRedo", _canRedo_dec, Editor);
|
|
7839
7853
|
__decorateElement(_init, 1, "getPath", _getPath_dec, Editor);
|
|
7840
7854
|
__decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
|
|
7841
7855
|
__decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
|
|
@@ -7870,6 +7884,9 @@ __decorateElement(_init, 1, "getCamera", _getCamera_dec, Editor);
|
|
|
7870
7884
|
__decorateElement(_init, 1, "getViewportPageBoundsForFollowing", _getViewportPageBoundsForFollowing_dec, Editor);
|
|
7871
7885
|
__decorateElement(_init, 1, "getCameraForFollowing", _getCameraForFollowing_dec, Editor);
|
|
7872
7886
|
__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);
|
|
7873
7890
|
__decorateElement(_init, 1, "getViewportScreenBounds", _getViewportScreenBounds_dec, Editor);
|
|
7874
7891
|
__decorateElement(_init, 1, "getViewportScreenCenter", _getViewportScreenCenter_dec, Editor);
|
|
7875
7892
|
__decorateElement(_init, 1, "getViewportPageBounds", _getViewportPageBounds_dec, Editor);
|