@tldraw/editor 3.14.0-canary.ae54a012ca55 → 3.14.0-canary.b1a9df6c4d78
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 +14 -99
- package/dist-cjs/index.js +1 -4
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +27 -66
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +1 -3
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +2 -3
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +10 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +6 -10
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +3 -3
- 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/primitives/geometry/Geometry2d.js +2 -6
- package/dist-cjs/lib/primitives/geometry/Geometry2d.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 +14 -99
- package/dist-esm/index.mjs +1 -4
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +27 -66
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +1 -3
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +2 -3
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +10 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +6 -10
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +3 -3
- 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/primitives/geometry/Geometry2d.mjs +2 -6
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +11 -10
- package/package.json +7 -7
- package/src/index.ts +0 -5
- package/src/lib/editor/Editor.ts +35 -76
- package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +1 -3
- package/src/lib/editor/managers/TextManager/TextManager.ts +2 -4
- package/src/lib/editor/shapes/ShapeUtil.ts +15 -47
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +17 -22
- package/src/lib/editor/tools/StateNode.ts +3 -3
- package/src/lib/editor/types/emit-types.ts +0 -4
- package/src/lib/primitives/geometry/Geometry2d.ts +2 -7
- package/src/version.ts +3 -3
- package/dist-cjs/lib/utils/reparenting.js +0 -232
- package/dist-cjs/lib/utils/reparenting.js.map +0 -7
- package/dist-esm/lib/utils/reparenting.mjs +0 -216
- package/dist-esm/lib/utils/reparenting.mjs.map +0 -7
- package/src/lib/utils/reparenting.ts +0 -383
|
@@ -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, _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;
|
|
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, _getSelectionScreenBounds_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,
|
|
@@ -158,7 +158,7 @@ import { TextManager } from "./managers/TextManager/TextManager.mjs";
|
|
|
158
158
|
import { TickManager } from "./managers/TickManager/TickManager.mjs";
|
|
159
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], _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) {
|
|
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], _getSelectionScreenBounds_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,
|
|
@@ -1676,12 +1676,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1676
1676
|
getSelectionPageBounds() {
|
|
1677
1677
|
return this.getShapesPageBounds(this.getSelectedShapeIds());
|
|
1678
1678
|
}
|
|
1679
|
-
/**
|
|
1680
|
-
* The bounds of the selection bounding box in the current page space.
|
|
1681
|
-
*
|
|
1682
|
-
* @readonly
|
|
1683
|
-
* @public
|
|
1684
|
-
*/
|
|
1685
1679
|
getSelectionScreenBounds() {
|
|
1686
1680
|
const bounds = this.getSelectionPageBounds();
|
|
1687
1681
|
if (!bounds) return void 0;
|
|
@@ -4165,7 +4159,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4165
4159
|
if (!id) return void 0;
|
|
4166
4160
|
const freshShape = this.getShape(id);
|
|
4167
4161
|
if (freshShape === void 0 || !isShapeId(freshShape.parentId)) return void 0;
|
|
4168
|
-
return this.
|
|
4162
|
+
return this.store.get(freshShape.parentId);
|
|
4169
4163
|
}
|
|
4170
4164
|
/**
|
|
4171
4165
|
* If siblingShape and targetShape are siblings, this returns targetShape. If targetShape has an
|
|
@@ -4297,9 +4291,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4297
4291
|
if (!pagePoint) continue;
|
|
4298
4292
|
const newPoint = invertedParentTransform.applyToPoint(pagePoint);
|
|
4299
4293
|
const newRotation = pageTransform.rotation() - parentPageRotation;
|
|
4300
|
-
if (shape.id === parentId) {
|
|
4301
|
-
throw Error("Attempted to reparent a shape to itself!");
|
|
4302
|
-
}
|
|
4303
4294
|
changes.push({
|
|
4304
4295
|
id: shape.id,
|
|
4305
4296
|
type: shape.type,
|
|
@@ -4392,10 +4383,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4392
4383
|
}
|
|
4393
4384
|
return shapeIds;
|
|
4394
4385
|
}
|
|
4395
|
-
/** @deprecated Use {@link Editor.getDraggingOverShape} instead */
|
|
4396
|
-
getDroppingOverShape(point, droppingShapes) {
|
|
4397
|
-
return this.getDraggingOverShape(point, droppingShapes);
|
|
4398
|
-
}
|
|
4399
4386
|
/**
|
|
4400
4387
|
* Get the shape that some shapes should be dropped on at a given point.
|
|
4401
4388
|
*
|
|
@@ -4406,20 +4393,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4406
4393
|
*
|
|
4407
4394
|
* @public
|
|
4408
4395
|
*/
|
|
4409
|
-
|
|
4410
|
-
const
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4396
|
+
getDroppingOverShape(point, droppingShapes = []) {
|
|
4397
|
+
const currentPageShapesSorted = this.getCurrentPageShapesSorted();
|
|
4398
|
+
for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) {
|
|
4399
|
+
const shape = currentPageShapesSorted[i];
|
|
4400
|
+
if (
|
|
4401
|
+
// ignore hidden shapes
|
|
4402
|
+
this.isShapeHidden(shape) || // don't allow dropping on selected shapes
|
|
4403
|
+
this.getSelectedShapeIds().includes(shape.id) || // only allow shapes that can receive children
|
|
4404
|
+
!this.getShapeUtil(shape).canDropShapes(shape, droppingShapes) || // don't allow dropping a shape on itself or one of it's children
|
|
4405
|
+
droppingShapes.find((s) => s.id === shape.id || this.hasAncestor(shape, s.id))
|
|
4406
|
+
) {
|
|
4407
|
+
continue;
|
|
4408
|
+
}
|
|
4409
|
+
const maskedPageBounds = this.getShapeMaskedPageBounds(shape.id);
|
|
4410
|
+
if (maskedPageBounds && maskedPageBounds.containsPoint(point) && this.getShapeGeometry(shape).hitTestPoint(this.getPointInShapeSpace(shape, point), 0, true)) {
|
|
4411
|
+
return shape;
|
|
4423
4412
|
}
|
|
4424
4413
|
}
|
|
4425
4414
|
}
|
|
@@ -4696,8 +4685,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4696
4685
|
*/
|
|
4697
4686
|
duplicateShapes(shapes, offset) {
|
|
4698
4687
|
this.run(() => {
|
|
4699
|
-
const
|
|
4700
|
-
const ids = this._shouldIgnoreShapeLock ? _ids : this._getUnlockedShapeIds(_ids);
|
|
4688
|
+
const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
4701
4689
|
if (ids.length <= 0) return this;
|
|
4702
4690
|
const initialIds = new Set(ids);
|
|
4703
4691
|
const shapeIdSet = this.getShapeAndDescendantIds(ids);
|
|
@@ -4761,7 +4749,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4761
4749
|
shape.index = index;
|
|
4762
4750
|
});
|
|
4763
4751
|
const shapesToCreate = shapesToCreateWithOriginals.map(({ shape }) => shape);
|
|
4764
|
-
|
|
4752
|
+
const maxShapesReached = shapesToCreate.length + this.getCurrentPageShapeIds().size > this.options.maxShapesPerPage;
|
|
4753
|
+
if (maxShapesReached) {
|
|
4765
4754
|
alertMaxShapes(this);
|
|
4766
4755
|
return;
|
|
4767
4756
|
}
|
|
@@ -5776,26 +5765,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5776
5765
|
getInitialMetaForShape(_shape) {
|
|
5777
5766
|
return {};
|
|
5778
5767
|
}
|
|
5779
|
-
/**
|
|
5780
|
-
* Get whether the provided shape can be created.
|
|
5781
|
-
*
|
|
5782
|
-
* @param shape - The shape or shape IDs to check.
|
|
5783
|
-
*
|
|
5784
|
-
* @public
|
|
5785
|
-
*/
|
|
5786
|
-
canCreateShape(shape) {
|
|
5787
|
-
return this.canCreateShapes([shape]);
|
|
5788
|
-
}
|
|
5789
|
-
/**
|
|
5790
|
-
* Get whether the provided shapes can be created.
|
|
5791
|
-
*
|
|
5792
|
-
* @param shapes - The shapes or shape IDs to create.
|
|
5793
|
-
*
|
|
5794
|
-
* @public
|
|
5795
|
-
*/
|
|
5796
|
-
canCreateShapes(shapes) {
|
|
5797
|
-
return shapes.length + this.getCurrentPageShapeIds().size <= this.options.maxShapesPerPage;
|
|
5798
|
-
}
|
|
5799
5768
|
/**
|
|
5800
5769
|
* Create a single shape.
|
|
5801
5770
|
*
|
|
@@ -5849,8 +5818,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5849
5818
|
let parentId = this.getFocusedGroupId();
|
|
5850
5819
|
for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) {
|
|
5851
5820
|
const parent = currentPageShapesSorted[i];
|
|
5852
|
-
|
|
5853
|
-
if (util.canReceiveNewChildrenOfType(parent, partial.type) && !this.isShapeHidden(parent) && this.isPointInShape(
|
|
5821
|
+
if (!this.isShapeHidden(parent) && this.getShapeUtil(parent).canReceiveNewChildrenOfType(parent, partial.type) && this.isPointInShape(
|
|
5854
5822
|
parent,
|
|
5855
5823
|
// If no parent is provided, then we can treat the
|
|
5856
5824
|
// shape's provided x/y as being in the page's space.
|
|
@@ -5925,8 +5893,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5925
5893
|
...shape.meta
|
|
5926
5894
|
};
|
|
5927
5895
|
});
|
|
5928
|
-
this.emit("created-shapes", shapeRecordsToCreate);
|
|
5929
|
-
this.emit("edit");
|
|
5930
5896
|
this.store.put(shapeRecordsToCreate);
|
|
5931
5897
|
});
|
|
5932
5898
|
return this;
|
|
@@ -6168,8 +6134,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6168
6134
|
updated = this.getShapeUtil(shape).onBeforeUpdate?.(shape, updated) ?? updated;
|
|
6169
6135
|
updates.push(updated);
|
|
6170
6136
|
}
|
|
6171
|
-
this.emit("edited-shapes", updates);
|
|
6172
|
-
this.emit("edit");
|
|
6173
6137
|
this.store.put(updates);
|
|
6174
6138
|
});
|
|
6175
6139
|
}
|
|
@@ -6191,8 +6155,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6191
6155
|
allShapeIdsToDelete.add(childId);
|
|
6192
6156
|
});
|
|
6193
6157
|
}
|
|
6194
|
-
this.emit("deleted-shapes", [...allShapeIdsToDelete]);
|
|
6195
|
-
this.emit("edit");
|
|
6196
6158
|
return this.run(() => this.store.remove([...allShapeIdsToDelete]));
|
|
6197
6159
|
}
|
|
6198
6160
|
deleteShape(_id) {
|
|
@@ -6961,9 +6923,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6961
6923
|
previousScreenPoint,
|
|
6962
6924
|
previousPagePoint,
|
|
6963
6925
|
currentScreenPoint,
|
|
6964
|
-
currentPagePoint
|
|
6965
|
-
originScreenPoint,
|
|
6966
|
-
originPagePoint
|
|
6926
|
+
currentPagePoint
|
|
6967
6927
|
} = this.inputs;
|
|
6968
6928
|
const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID);
|
|
6969
6929
|
const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera());
|
|
@@ -6981,8 +6941,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6981
6941
|
this.inputs.isPen = info.type === "pointer" && info.isPen;
|
|
6982
6942
|
if (info.name === "pointer_down" || this.inputs.isPinching) {
|
|
6983
6943
|
pointerVelocity.set(0, 0);
|
|
6984
|
-
originScreenPoint.setTo(currentScreenPoint);
|
|
6985
|
-
originPagePoint.setTo(currentPagePoint);
|
|
6944
|
+
this.inputs.originScreenPoint.setTo(currentScreenPoint);
|
|
6945
|
+
this.inputs.originPagePoint.setTo(currentPagePoint);
|
|
6986
6946
|
}
|
|
6987
6947
|
this.run(
|
|
6988
6948
|
() => {
|
|
@@ -7835,6 +7795,7 @@ __decorateElement(_init, 1, "getCurrentPageShapesInReadingOrder", _getCurrentPag
|
|
|
7835
7795
|
__decorateElement(_init, 1, "getOnlySelectedShapeId", _getOnlySelectedShapeId_dec, Editor);
|
|
7836
7796
|
__decorateElement(_init, 1, "getOnlySelectedShape", _getOnlySelectedShape_dec, Editor);
|
|
7837
7797
|
__decorateElement(_init, 1, "getSelectionPageBounds", _getSelectionPageBounds_dec, Editor);
|
|
7798
|
+
__decorateElement(_init, 1, "getSelectionScreenBounds", _getSelectionScreenBounds_dec, Editor);
|
|
7838
7799
|
__decorateElement(_init, 1, "getSelectionRotation", _getSelectionRotation_dec, Editor);
|
|
7839
7800
|
__decorateElement(_init, 1, "getSelectionRotatedPageBounds", _getSelectionRotatedPageBounds_dec, Editor);
|
|
7840
7801
|
__decorateElement(_init, 1, "getSelectionRotatedScreenBounds", _getSelectionRotatedScreenBounds_dec, Editor);
|