@tldraw/editor 3.14.0-canary.e099968e8b09 → 3.14.0-canary.e2a8e4a03aff
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 +74 -63
- package/dist-cjs/index.js +8 -10
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/config/TLSessionStateSnapshot.js +1 -12
- package/dist-cjs/lib/config/TLSessionStateSnapshot.js.map +3 -3
- package/dist-cjs/lib/editor/Editor.js +80 -73
- 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 +22 -22
- package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js +16 -16
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js.map +2 -2
- package/dist-cjs/lib/editor/managers/{ClickManager.js → ClickManager/ClickManager.js} +1 -1
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/{EdgeScrollManager.js → EdgeScrollManager/EdgeScrollManager.js} +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/{FontManager.js → FontManager/FontManager.js} +1 -2
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/{HistoryManager.js → HistoryManager/HistoryManager.js} +64 -6
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/{ScribbleManager.js → ScribbleManager/ScribbleManager.js} +1 -1
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/{TextManager.js → TextManager/TextManager.js} +73 -42
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/{TickManager.js → TickManager/TickManager.js} +1 -1
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/{UserPreferencesManager.js → UserPreferencesManager/UserPreferencesManager.js} +1 -1
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +7 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +1 -1
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/tools/StateNode.js +3 -3
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +1 -1
- package/dist-cjs/lib/hooks/useCanvasEvents.js +1 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +0 -6
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/utils/areShapesContentEqual.js +1 -1
- package/dist-cjs/lib/utils/areShapesContentEqual.js.map +2 -2
- package/dist-cjs/lib/utils/reorderShapes.js +11 -10
- package/dist-cjs/lib/utils/reorderShapes.js.map +2 -2
- package/dist-cjs/lib/utils/richText.js +7 -2
- package/dist-cjs/lib/utils/richText.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 +74 -63
- package/dist-esm/index.mjs +12 -10
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/config/TLSessionStateSnapshot.mjs +1 -1
- package/dist-esm/lib/config/TLSessionStateSnapshot.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +80 -73
- 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 +22 -22
- package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs +16 -16
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/{ClickManager.mjs → ClickManager/ClickManager.mjs} +1 -1
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/{EdgeScrollManager.mjs → EdgeScrollManager/EdgeScrollManager.mjs} +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/{FontManager.mjs → FontManager/FontManager.mjs} +1 -2
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/{HistoryManager.mjs → HistoryManager/HistoryManager.mjs} +60 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/{ScribbleManager.mjs → ScribbleManager/ScribbleManager.mjs} +1 -1
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/{TextManager.mjs → TextManager/TextManager.mjs} +73 -42
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/{TickManager.mjs → TickManager/TickManager.mjs} +1 -1
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/{UserPreferencesManager.mjs → UserPreferencesManager/UserPreferencesManager.mjs} +1 -1
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +7 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +1 -1
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/tools/StateNode.mjs +3 -3
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +1 -1
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +1 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +0 -6
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/utils/areShapesContentEqual.mjs +1 -1
- package/dist-esm/lib/utils/areShapesContentEqual.mjs.map +2 -2
- package/dist-esm/lib/utils/reorderShapes.mjs +11 -10
- package/dist-esm/lib/utils/reorderShapes.mjs.map +2 -2
- package/dist-esm/lib/utils/richText.mjs +8 -3
- package/dist-esm/lib/utils/richText.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +433 -482
- package/package.json +8 -9
- package/src/index.ts +15 -8
- package/src/lib/config/TLSessionStateSnapshot.ts +1 -1
- package/src/lib/editor/Editor.test.ts +252 -3
- package/src/lib/editor/Editor.ts +81 -72
- package/src/lib/editor/bindings/BindingUtil.ts +6 -0
- package/src/lib/editor/derivations/bindingsIndex.ts +27 -26
- package/src/lib/editor/derivations/parentsToChildren.ts +28 -25
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +442 -0
- package/src/lib/editor/managers/{ClickManager.ts → ClickManager/ClickManager.ts} +3 -3
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +374 -0
- package/src/lib/editor/managers/{EdgeScrollManager.ts → EdgeScrollManager/EdgeScrollManager.ts} +3 -3
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +455 -0
- package/src/lib/editor/managers/{FocusManager.ts → FocusManager/FocusManager.ts} +1 -1
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +263 -0
- package/src/lib/editor/managers/{FontManager.ts → FontManager/FontManager.ts} +2 -3
- package/src/lib/editor/managers/{HistoryManager.test.ts → HistoryManager/HistoryManager.test.ts} +388 -1
- package/src/lib/editor/managers/{HistoryManager.ts → HistoryManager/HistoryManager.ts} +73 -2
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +624 -0
- package/src/lib/editor/managers/{ScribbleManager.ts → ScribbleManager/ScribbleManager.ts} +2 -2
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +485 -0
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +407 -0
- package/src/lib/editor/managers/{TextManager.ts → TextManager/TextManager.ts} +119 -87
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +314 -0
- package/src/lib/editor/managers/{TickManager.ts → TickManager/TickManager.ts} +2 -2
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +591 -0
- package/src/lib/editor/managers/{UserPreferencesManager.ts → UserPreferencesManager/UserPreferencesManager.ts} +2 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +2 -1
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -1
- package/src/lib/editor/tools/StateNode.ts +3 -3
- package/src/lib/editor/types/emit-types.ts +4 -0
- package/src/lib/editor/types/external-content.ts +11 -2
- package/src/lib/exports/getSvgJsx.tsx +1 -1
- package/src/lib/hooks/useCanvasEvents.ts +0 -1
- package/src/lib/primitives/Box.ts +0 -8
- package/src/lib/utils/areShapesContentEqual.ts +1 -2
- package/src/lib/utils/reorderShapes.ts +10 -13
- package/src/lib/utils/richText.ts +10 -4
- package/src/version.ts +3 -3
- package/dist-cjs/lib/editor/managers/ClickManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/EdgeScrollManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/FocusManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/FontManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/HistoryManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/ScribbleManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/Stack.js +0 -82
- package/dist-cjs/lib/editor/managers/Stack.js.map +0 -7
- package/dist-cjs/lib/editor/managers/TextManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/TickManager.js.map +0 -7
- package/dist-cjs/lib/editor/managers/UserPreferencesManager.js.map +0 -7
- package/dist-esm/lib/editor/managers/ClickManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/EdgeScrollManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/FocusManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/FontManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/HistoryManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/ScribbleManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/Stack.mjs +0 -62
- package/dist-esm/lib/editor/managers/Stack.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/TextManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/TickManager.mjs.map +0 -7
- package/dist-esm/lib/editor/managers/UserPreferencesManager.mjs.map +0 -7
- package/src/lib/editor/managers/ScribbleManager.test.ts +0 -32
- package/src/lib/editor/managers/Stack.ts +0 -71
- /package/dist-cjs/lib/editor/managers/{FocusManager.js → FocusManager/FocusManager.js} +0 -0
- /package/dist-esm/lib/editor/managers/{FocusManager.mjs → FocusManager/FocusManager.mjs} +0 -0
|
@@ -46,7 +46,7 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
|
|
|
46
46
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
47
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
48
48
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
49
|
-
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,
|
|
49
|
+
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, _getIsMenuOpen_dec, _getOpenMenus_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
|
|
50
50
|
import {
|
|
51
51
|
EMPTY_ARRAY,
|
|
52
52
|
atom,
|
|
@@ -147,18 +147,18 @@ import { bindingsIndex } from "./derivations/bindingsIndex.mjs";
|
|
|
147
147
|
import { notVisibleShapes } from "./derivations/notVisibleShapes.mjs";
|
|
148
148
|
import { parentsToChildren } from "./derivations/parentsToChildren.mjs";
|
|
149
149
|
import { deriveShapeIdsInCurrentPage } from "./derivations/shapeIdsInCurrentPage.mjs";
|
|
150
|
-
import { ClickManager } from "./managers/ClickManager.mjs";
|
|
151
|
-
import { EdgeScrollManager } from "./managers/EdgeScrollManager.mjs";
|
|
152
|
-
import { FocusManager } from "./managers/FocusManager.mjs";
|
|
153
|
-
import { FontManager } from "./managers/FontManager.mjs";
|
|
154
|
-
import { HistoryManager } from "./managers/HistoryManager.mjs";
|
|
155
|
-
import { ScribbleManager } from "./managers/ScribbleManager.mjs";
|
|
150
|
+
import { ClickManager } from "./managers/ClickManager/ClickManager.mjs";
|
|
151
|
+
import { EdgeScrollManager } from "./managers/EdgeScrollManager/EdgeScrollManager.mjs";
|
|
152
|
+
import { FocusManager } from "./managers/FocusManager/FocusManager.mjs";
|
|
153
|
+
import { FontManager } from "./managers/FontManager/FontManager.mjs";
|
|
154
|
+
import { HistoryManager } from "./managers/HistoryManager/HistoryManager.mjs";
|
|
155
|
+
import { ScribbleManager } from "./managers/ScribbleManager/ScribbleManager.mjs";
|
|
156
156
|
import { SnapManager } from "./managers/SnapManager/SnapManager.mjs";
|
|
157
|
-
import { TextManager } from "./managers/TextManager.mjs";
|
|
158
|
-
import { TickManager } from "./managers/TickManager.mjs";
|
|
159
|
-
import { UserPreferencesManager } from "./managers/UserPreferencesManager.mjs";
|
|
157
|
+
import { TextManager } from "./managers/TextManager/TextManager.mjs";
|
|
158
|
+
import { TickManager } from "./managers/TickManager/TickManager.mjs";
|
|
159
|
+
import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPreferencesManager.mjs";
|
|
160
160
|
import { RootState } from "./tools/RootState.mjs";
|
|
161
|
-
class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getOpenMenus_dec = [computed], _getIsMenuOpen_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getCurrentPageShapesInReadingOrder_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed],
|
|
161
|
+
class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getOpenMenus_dec = [computed], _getIsMenuOpen_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getCurrentPageShapesInReadingOrder_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], _getNotVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
|
|
162
162
|
constructor({
|
|
163
163
|
store,
|
|
164
164
|
user,
|
|
@@ -336,7 +336,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
336
336
|
__publicField(this, "_currentPageShapeIds");
|
|
337
337
|
/* --------------------- Shapes --------------------- */
|
|
338
338
|
__publicField(this, "_shapeGeometryCaches", {});
|
|
339
|
-
__publicField(this, "
|
|
339
|
+
__publicField(this, "_notVisibleShapes", notVisibleShapes(this));
|
|
340
340
|
// Parents and children
|
|
341
341
|
/**
|
|
342
342
|
* A cache of parents to children.
|
|
@@ -357,6 +357,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
357
357
|
__publicField(this, "externalContentHandlers", {
|
|
358
358
|
text: null,
|
|
359
359
|
files: null,
|
|
360
|
+
"file-replace": null,
|
|
360
361
|
embed: null,
|
|
361
362
|
"svg-text": null,
|
|
362
363
|
url: null,
|
|
@@ -473,6 +474,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
473
474
|
this.disposables.add(() => this.user.dispose());
|
|
474
475
|
this.getContainer = getContainer;
|
|
475
476
|
this.textMeasure = new TextManager(this);
|
|
477
|
+
this.disposables.add(() => this.textMeasure.dispose());
|
|
476
478
|
this.fonts = new FontManager(this, fontAssetUrls);
|
|
477
479
|
this._tickManager = new TickManager(this);
|
|
478
480
|
class NewRoot extends RootState {
|
|
@@ -593,20 +595,21 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
593
595
|
shape: {
|
|
594
596
|
afterChange: (shapeBefore, shapeAfter) => {
|
|
595
597
|
for (const binding of this.getBindingsInvolvingShape(shapeAfter)) {
|
|
596
|
-
if (areShapesContentEqual(shapeBefore, shapeAfter)) continue;
|
|
597
598
|
invalidBindingTypes.add(binding.type);
|
|
598
599
|
if (binding.fromId === shapeAfter.id) {
|
|
599
600
|
this.getBindingUtil(binding).onAfterChangeFromShape?.({
|
|
600
601
|
binding,
|
|
601
602
|
shapeBefore,
|
|
602
|
-
shapeAfter
|
|
603
|
+
shapeAfter,
|
|
604
|
+
reason: "self"
|
|
603
605
|
});
|
|
604
606
|
}
|
|
605
607
|
if (binding.toId === shapeAfter.id) {
|
|
606
608
|
this.getBindingUtil(binding).onAfterChangeToShape?.({
|
|
607
609
|
binding,
|
|
608
610
|
shapeBefore,
|
|
609
|
-
shapeAfter
|
|
611
|
+
shapeAfter,
|
|
612
|
+
reason: "self"
|
|
610
613
|
});
|
|
611
614
|
}
|
|
612
615
|
}
|
|
@@ -620,14 +623,16 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
620
623
|
this.getBindingUtil(binding).onAfterChangeFromShape?.({
|
|
621
624
|
binding,
|
|
622
625
|
shapeBefore: descendantShape,
|
|
623
|
-
shapeAfter: descendantShape
|
|
626
|
+
shapeAfter: descendantShape,
|
|
627
|
+
reason: "ancestry"
|
|
624
628
|
});
|
|
625
629
|
}
|
|
626
630
|
if (binding.toId === descendantShape.id) {
|
|
627
631
|
this.getBindingUtil(binding).onAfterChangeToShape?.({
|
|
628
632
|
binding,
|
|
629
633
|
shapeBefore: descendantShape,
|
|
630
|
-
shapeAfter: descendantShape
|
|
634
|
+
shapeAfter: descendantShape,
|
|
635
|
+
reason: "ancestry"
|
|
631
636
|
});
|
|
632
637
|
}
|
|
633
638
|
}
|
|
@@ -1671,6 +1676,19 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1671
1676
|
getSelectionPageBounds() {
|
|
1672
1677
|
return this.getShapesPageBounds(this.getSelectedShapeIds());
|
|
1673
1678
|
}
|
|
1679
|
+
/**
|
|
1680
|
+
* The bounds of the selection bounding box in the current page space.
|
|
1681
|
+
*
|
|
1682
|
+
* @readonly
|
|
1683
|
+
* @public
|
|
1684
|
+
*/
|
|
1685
|
+
getSelectionScreenBounds() {
|
|
1686
|
+
const bounds = this.getSelectionPageBounds();
|
|
1687
|
+
if (!bounds) return void 0;
|
|
1688
|
+
const { x, y } = this.pageToScreen(bounds.point);
|
|
1689
|
+
const zoom = this.getZoomLevel();
|
|
1690
|
+
return new Box(x, y, bounds.width * zoom, bounds.height * zoom);
|
|
1691
|
+
}
|
|
1674
1692
|
/**
|
|
1675
1693
|
* @internal
|
|
1676
1694
|
*/
|
|
@@ -3529,41 +3547,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3529
3547
|
typeof shape === "string" ? shape : shape.id
|
|
3530
3548
|
);
|
|
3531
3549
|
}
|
|
3532
|
-
/**
|
|
3533
|
-
* Get the geometry of a shape in page-space.
|
|
3534
|
-
*
|
|
3535
|
-
* @example
|
|
3536
|
-
* ```ts
|
|
3537
|
-
* editor.getShapePageGeometry(myShape)
|
|
3538
|
-
* editor.getShapePageGeometry(myShapeId)
|
|
3539
|
-
* editor.getShapePageGeometry(myShapeId, { context: "arrow" })
|
|
3540
|
-
* ```
|
|
3541
|
-
*
|
|
3542
|
-
* @param shape - The shape (or shape id) to get the geometry for.
|
|
3543
|
-
* @param opts - Additional options about the request for geometry. Passed to {@link ShapeUtil.getGeometry}.
|
|
3544
|
-
*
|
|
3545
|
-
* @public
|
|
3546
|
-
*/
|
|
3547
|
-
getShapePageGeometry(shape, opts) {
|
|
3548
|
-
const context = opts?.context ?? "none";
|
|
3549
|
-
if (!this._shapePageGeometryCaches[context]) {
|
|
3550
|
-
this._shapePageGeometryCaches[context] = this.store.createComputedCache(
|
|
3551
|
-
"bounds",
|
|
3552
|
-
(shape2) => {
|
|
3553
|
-
const geometry = this.getShapeGeometry(shape2.id, opts);
|
|
3554
|
-
const pageTransform = this.getShapePageTransform(shape2.id);
|
|
3555
|
-
return geometry.transform(pageTransform);
|
|
3556
|
-
},
|
|
3557
|
-
{
|
|
3558
|
-
// we only depend directly on the shape id, and changing geometry/transform will update us anyway
|
|
3559
|
-
areRecordsEqual: () => true
|
|
3560
|
-
}
|
|
3561
|
-
);
|
|
3562
|
-
}
|
|
3563
|
-
return this._shapePageGeometryCaches[context].get(
|
|
3564
|
-
typeof shape === "string" ? shape : shape.id
|
|
3565
|
-
);
|
|
3566
|
-
}
|
|
3567
3550
|
_getShapeHandlesCache() {
|
|
3568
3551
|
return this.store.createComputedCache(
|
|
3569
3552
|
"handles",
|
|
@@ -3657,7 +3640,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3657
3640
|
}
|
|
3658
3641
|
_getShapePageBoundsCache() {
|
|
3659
3642
|
return this.store.createComputedCache("pageBoundsCache", (shape) => {
|
|
3660
|
-
|
|
3643
|
+
const pageTransform = this.getShapePageTransform(shape);
|
|
3644
|
+
if (!pageTransform) return void 0;
|
|
3645
|
+
const geometry = this.getShapeGeometry(shape);
|
|
3646
|
+
return Box.FromPoints(pageTransform.applyToPoints(geometry.vertices));
|
|
3661
3647
|
});
|
|
3662
3648
|
}
|
|
3663
3649
|
/**
|
|
@@ -3714,12 +3700,11 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3714
3700
|
(shape2) => this.isShapeOfType(shape2, "frame")
|
|
3715
3701
|
);
|
|
3716
3702
|
if (frameAncestors.length === 0) return void 0;
|
|
3717
|
-
const pageMask = frameAncestors.map(
|
|
3718
|
-
(s)
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
).reduce((acc, b) => {
|
|
3703
|
+
const pageMask = frameAncestors.map((s) => {
|
|
3704
|
+
const geometry = this.getShapeGeometry(s.id);
|
|
3705
|
+
const pageTransform = this.getShapePageTransform(s.id);
|
|
3706
|
+
return pageTransform.applyToPoints(geometry.vertices);
|
|
3707
|
+
}).reduce((acc, b) => {
|
|
3723
3708
|
if (!(b && acc)) return void 0;
|
|
3724
3709
|
const intersection = intersectPolygonPolygon(acc, b);
|
|
3725
3710
|
if (intersection) {
|
|
@@ -3883,17 +3868,24 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3883
3868
|
}
|
|
3884
3869
|
return void 0;
|
|
3885
3870
|
}
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3871
|
+
/**
|
|
3872
|
+
* Check whether a shape or its parent is locked.
|
|
3873
|
+
*
|
|
3874
|
+
* @param shape - The shape (or shape id) to check.
|
|
3875
|
+
*
|
|
3876
|
+
* @public
|
|
3877
|
+
*/
|
|
3878
|
+
isShapeOrAncestorLocked(shape) {
|
|
3879
|
+
const _shape = shape && this.getShape(shape);
|
|
3880
|
+
if (_shape === void 0) return false;
|
|
3881
|
+
if (_shape.isLocked) return true;
|
|
3882
|
+
return this.isShapeOrAncestorLocked(this.getShapeParent(_shape));
|
|
3891
3883
|
}
|
|
3892
|
-
|
|
3893
|
-
return
|
|
3884
|
+
getNotVisibleShapes() {
|
|
3885
|
+
return this._notVisibleShapes.get();
|
|
3894
3886
|
}
|
|
3895
3887
|
getCulledShapes() {
|
|
3896
|
-
const notVisibleShapes2 = this.
|
|
3888
|
+
const notVisibleShapes2 = this.getNotVisibleShapes();
|
|
3897
3889
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
3898
3890
|
const editingId = this.getEditingShapeId();
|
|
3899
3891
|
const culledShapes = new Set(notVisibleShapes2);
|
|
@@ -4038,18 +4030,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4038
4030
|
* @example
|
|
4039
4031
|
* ```ts
|
|
4040
4032
|
* editor.getShapesAtPoint({ x: 100, y: 100 })
|
|
4041
|
-
* editor.getShapesAtPoint({ x: 100, y: 100 }, { hitInside: true,
|
|
4033
|
+
* editor.getShapesAtPoint({ x: 100, y: 100 }, { hitInside: true, margin: 8 })
|
|
4042
4034
|
* ```
|
|
4043
4035
|
*
|
|
4044
4036
|
* @param point - The page point to test.
|
|
4045
4037
|
* @param opts - The options for the hit point testing.
|
|
4046
4038
|
*
|
|
4039
|
+
* @returns An array of shapes at the given point, sorted in reverse order of their absolute z-index (top-most shape first).
|
|
4040
|
+
*
|
|
4047
4041
|
* @public
|
|
4048
4042
|
*/
|
|
4049
4043
|
getShapesAtPoint(point, opts = {}) {
|
|
4050
|
-
return this.
|
|
4051
|
-
(shape) => !this.isShapeHidden(shape) && this.isPointInShape(shape, point, opts)
|
|
4052
|
-
);
|
|
4044
|
+
return this.getCurrentPageShapesSorted().filter((shape) => !this.isShapeHidden(shape) && this.isPointInShape(shape, point, opts)).reverse();
|
|
4053
4045
|
}
|
|
4054
4046
|
/**
|
|
4055
4047
|
* Test whether a point (in the current page space) will will a shape. This method takes into account masks,
|
|
@@ -4699,7 +4691,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4699
4691
|
*/
|
|
4700
4692
|
duplicateShapes(shapes, offset) {
|
|
4701
4693
|
this.run(() => {
|
|
4702
|
-
const
|
|
4694
|
+
const _ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
4695
|
+
const ids = this._shouldIgnoreShapeLock ? _ids : this._getUnlockedShapeIds(_ids);
|
|
4703
4696
|
if (ids.length <= 0) return this;
|
|
4704
4697
|
const initialIds = new Set(ids);
|
|
4705
4698
|
const shapeIdSet = this.getShapeAndDescendantIds(ids);
|
|
@@ -5907,6 +5900,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5907
5900
|
...shape.meta
|
|
5908
5901
|
};
|
|
5909
5902
|
});
|
|
5903
|
+
this.emit("created-shapes", shapeRecordsToCreate);
|
|
5904
|
+
this.emit("edit");
|
|
5910
5905
|
this.store.put(shapeRecordsToCreate);
|
|
5911
5906
|
});
|
|
5912
5907
|
return this;
|
|
@@ -6148,6 +6143,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6148
6143
|
updated = this.getShapeUtil(shape).onBeforeUpdate?.(shape, updated) ?? updated;
|
|
6149
6144
|
updates.push(updated);
|
|
6150
6145
|
}
|
|
6146
|
+
this.emit("edited-shapes", updates);
|
|
6147
|
+
this.emit("edit");
|
|
6151
6148
|
this.store.put(updates);
|
|
6152
6149
|
});
|
|
6153
6150
|
}
|
|
@@ -6169,6 +6166,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6169
6166
|
allShapeIdsToDelete.add(childId);
|
|
6170
6167
|
});
|
|
6171
6168
|
}
|
|
6169
|
+
this.emit("deleted-shapes", [...allShapeIdsToDelete]);
|
|
6170
|
+
this.emit("edit");
|
|
6172
6171
|
return this.run(() => this.store.remove([...allShapeIdsToDelete]));
|
|
6173
6172
|
}
|
|
6174
6173
|
deleteShape(_id) {
|
|
@@ -6512,6 +6511,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6512
6511
|
async putExternalContent(info) {
|
|
6513
6512
|
return this.externalContentHandlers[info.type]?.(info);
|
|
6514
6513
|
}
|
|
6514
|
+
/**
|
|
6515
|
+
* Handle replacing external content.
|
|
6516
|
+
*
|
|
6517
|
+
* @param info - Info about the external content.
|
|
6518
|
+
*/
|
|
6519
|
+
async replaceExternalContent(info) {
|
|
6520
|
+
return this.externalContentHandlers[info.type]?.(info);
|
|
6521
|
+
}
|
|
6515
6522
|
/**
|
|
6516
6523
|
* Get content that can be exported for the given shape ids.
|
|
6517
6524
|
*
|
|
@@ -7838,7 +7845,7 @@ __decorateElement(_init, 1, "_getShapePageBoundsCache", __getShapePageBoundsCach
|
|
|
7838
7845
|
__decorateElement(_init, 1, "_getShapeClipPathCache", __getShapeClipPathCache_dec, Editor);
|
|
7839
7846
|
__decorateElement(_init, 1, "_getShapeMaskCache", __getShapeMaskCache_dec, Editor);
|
|
7840
7847
|
__decorateElement(_init, 1, "_getShapeMaskedPageBoundsCache", __getShapeMaskedPageBoundsCache_dec, Editor);
|
|
7841
|
-
__decorateElement(_init, 1, "
|
|
7848
|
+
__decorateElement(_init, 1, "getNotVisibleShapes", _getNotVisibleShapes_dec, Editor);
|
|
7842
7849
|
__decorateElement(_init, 1, "getCulledShapes", _getCulledShapes_dec, Editor);
|
|
7843
7850
|
__decorateElement(_init, 1, "getCurrentPageBounds", _getCurrentPageBounds_dec, Editor);
|
|
7844
7851
|
__decorateElement(_init, 1, "getCurrentPageShapes", _getCurrentPageShapes_dec, Editor);
|