@tldraw/editor 3.14.0-canary.33ea232f2305 → 3.14.0-canary.3b2250d26732
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 +114 -15
- package/dist-cjs/index.js +4 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +76 -28
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +3 -1
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +3 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +0 -10
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +13 -6
- 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/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +6 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Group2d.js +11 -6
- package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
- package/dist-cjs/lib/utils/dom.js +1 -1
- package/dist-cjs/lib/utils/dom.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +232 -0
- package/dist-cjs/lib/utils/reparenting.js.map +7 -0
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +114 -15
- package/dist-esm/index.mjs +4 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +76 -28
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +3 -1
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +3 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +0 -10
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +13 -6
- 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 +6 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Group2d.mjs +11 -6
- package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
- package/dist-esm/lib/utils/dom.mjs +1 -1
- package/dist-esm/lib/utils/dom.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +216 -0
- package/dist-esm/lib/utils/reparenting.mjs.map +7 -0
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +17 -11
- package/package.json +7 -7
- package/src/index.ts +6 -0
- package/src/lib/editor/Editor.ts +88 -37
- package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +3 -1
- package/src/lib/editor/managers/TextManager/TextManager.ts +4 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +47 -15
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +25 -17
- 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 +10 -1
- package/src/lib/primitives/geometry/Geometry2d.ts +7 -2
- package/src/lib/primitives/geometry/Group2d.ts +11 -5
- package/src/lib/utils/dom.ts +1 -1
- package/src/lib/utils/reparenting.ts +383 -0
- package/src/version.ts +3 -3
|
@@ -123,8 +123,8 @@ var import_TextManager = require("./managers/TextManager/TextManager");
|
|
|
123
123
|
var import_TickManager = require("./managers/TickManager/TickManager");
|
|
124
124
|
var import_UserPreferencesManager = require("./managers/UserPreferencesManager/UserPreferencesManager");
|
|
125
125
|
var import_RootState = require("./tools/RootState");
|
|
126
|
-
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,
|
|
127
|
-
class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed], _getCanUndo_dec = [import_state.computed], _getCanRedo_dec = [import_state.computed], _getPath_dec = [import_state.computed], _getCurrentTool_dec = [import_state.computed], _getCurrentToolId_dec = [import_state.computed], _getDocumentSettings_dec = [import_state.computed], _getInstanceState_dec = [import_state.computed], _getOpenMenus_dec = [import_state.computed], _getIsMenuOpen_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],
|
|
126
|
+
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;
|
|
127
|
+
class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed], _getCanUndo_dec = [import_state.computed], _getCanRedo_dec = [import_state.computed], _getPath_dec = [import_state.computed], _getCurrentTool_dec = [import_state.computed], _getCurrentToolId_dec = [import_state.computed], _getDocumentSettings_dec = [import_state.computed], _getInstanceState_dec = [import_state.computed], _getOpenMenus_dec = [import_state.computed], _getIsMenuOpen_dec = [import_state.computed], _getPageStates_dec = [import_state.computed], __getPageStatesQuery_dec = [import_state.computed], _getCurrentPageState_dec = [import_state.computed], __getCurrentPageStateId_dec = [import_state.computed], _getSelectedShapeIds_dec = [import_state.computed], _getSelectedShapes_dec = [import_state.computed], _getCurrentPageShapesInReadingOrder_dec = [import_state.computed], _getOnlySelectedShapeId_dec = [import_state.computed], _getOnlySelectedShape_dec = [import_state.computed], _getSelectionPageBounds_dec = [import_state.computed], _getSelectionRotation_dec = [import_state.computed], _getSelectionRotatedPageBounds_dec = [import_state.computed], _getSelectionRotatedScreenBounds_dec = [import_state.computed], _getFocusedGroupId_dec = [import_state.computed], _getFocusedGroup_dec = [import_state.computed], _getEditingShapeId_dec = [import_state.computed], _getEditingShape_dec = [import_state.computed], _getRichTextEditor_dec = [import_state.computed], _getHoveredShapeId_dec = [import_state.computed], _getHoveredShape_dec = [import_state.computed], _getHintingShapeIds_dec = [import_state.computed], _getHintingShape_dec = [import_state.computed], _getErasingShapeIds_dec = [import_state.computed], _getErasingShapes_dec = [import_state.computed], __unsafe_getCameraId_dec = [import_state.computed], _getCamera_dec = [import_state.computed], _getViewportPageBoundsForFollowing_dec = [import_state.computed], _getCameraForFollowing_dec = [import_state.computed], _getZoomLevel_dec = [import_state.computed], _getViewportScreenBounds_dec = [import_state.computed], _getViewportScreenCenter_dec = [import_state.computed], _getViewportPageBounds_dec = [import_state.computed], __getCollaboratorsQuery_dec = [import_state.computed], _getCollaborators_dec = [import_state.computed], _getCollaboratorsOnCurrentPage_dec = [import_state.computed], _getRenderingShapes_dec = [import_state.computed], __getAllPagesQuery_dec = [import_state.computed], _getPages_dec = [import_state.computed], _getCurrentPageId_dec = [import_state.computed], _getCurrentPageShapeIdsSorted_dec = [import_state.computed], __getAllAssetsQuery_dec = [import_state.computed], __getShapeHandlesCache_dec = [import_state.computed], __getShapePageTransformCache_dec = [import_state.computed], __getShapePageBoundsCache_dec = [import_state.computed], __getShapeClipPathCache_dec = [import_state.computed], __getShapeMaskCache_dec = [import_state.computed], __getShapeMaskedPageBoundsCache_dec = [import_state.computed], _getNotVisibleShapes_dec = [import_state.computed], _getCulledShapes_dec = [import_state.computed], _getCurrentPageBounds_dec = [import_state.computed], _getCurrentPageShapes_dec = [import_state.computed], _getCurrentPageShapesSorted_dec = [import_state.computed], _getCurrentPageRenderingShapesSorted_dec = [import_state.computed], __getBindingsIndexCache_dec = [import_state.computed], __getSelectionSharedStyles_dec = [import_state.computed], _getSharedStyles_dec = [(0, import_state.computed)({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [import_state.computed], _getIsFocused_dec = [import_state.computed], _getIsReadonly_dec = [import_state.computed], __setShiftKeyTimeout_dec = [import_utils.bind], __setAltKeyTimeout_dec = [import_utils.bind], __setCtrlKeyTimeout_dec = [import_utils.bind], __setMetaKeyTimeout_dec = [import_utils.bind], _a) {
|
|
128
128
|
constructor({
|
|
129
129
|
store,
|
|
130
130
|
user,
|
|
@@ -323,6 +323,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
323
323
|
__publicField(this, "externalContentHandlers", {
|
|
324
324
|
text: null,
|
|
325
325
|
files: null,
|
|
326
|
+
"file-replace": null,
|
|
326
327
|
embed: null,
|
|
327
328
|
"svg-text": null,
|
|
328
329
|
url: null,
|
|
@@ -1641,6 +1642,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1641
1642
|
getSelectionPageBounds() {
|
|
1642
1643
|
return this.getShapesPageBounds(this.getSelectedShapeIds());
|
|
1643
1644
|
}
|
|
1645
|
+
/**
|
|
1646
|
+
* The bounds of the selection bounding box in the current page space.
|
|
1647
|
+
*
|
|
1648
|
+
* @readonly
|
|
1649
|
+
* @public
|
|
1650
|
+
*/
|
|
1644
1651
|
getSelectionScreenBounds() {
|
|
1645
1652
|
const bounds = this.getSelectionPageBounds();
|
|
1646
1653
|
if (!bounds) return void 0;
|
|
@@ -2781,7 +2788,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2781
2788
|
* @public
|
|
2782
2789
|
*/
|
|
2783
2790
|
updateViewportScreenBounds(screenBounds, center = false) {
|
|
2784
|
-
if (screenBounds instanceof
|
|
2791
|
+
if (!(screenBounds instanceof import_Box.Box)) {
|
|
2785
2792
|
const rect = screenBounds.getBoundingClientRect();
|
|
2786
2793
|
screenBounds = new import_Box.Box(
|
|
2787
2794
|
rect.left || rect.x,
|
|
@@ -4124,7 +4131,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4124
4131
|
if (!id) return void 0;
|
|
4125
4132
|
const freshShape = this.getShape(id);
|
|
4126
4133
|
if (freshShape === void 0 || !(0, import_tlschema.isShapeId)(freshShape.parentId)) return void 0;
|
|
4127
|
-
return this.
|
|
4134
|
+
return this.getShape(freshShape.parentId);
|
|
4128
4135
|
}
|
|
4129
4136
|
/**
|
|
4130
4137
|
* If siblingShape and targetShape are siblings, this returns targetShape. If targetShape has an
|
|
@@ -4256,6 +4263,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4256
4263
|
if (!pagePoint) continue;
|
|
4257
4264
|
const newPoint = invertedParentTransform.applyToPoint(pagePoint);
|
|
4258
4265
|
const newRotation = pageTransform.rotation() - parentPageRotation;
|
|
4266
|
+
if (shape.id === parentId) {
|
|
4267
|
+
throw Error("Attempted to reparent a shape to itself!");
|
|
4268
|
+
}
|
|
4259
4269
|
changes.push({
|
|
4260
4270
|
id: shape.id,
|
|
4261
4271
|
type: shape.type,
|
|
@@ -4348,6 +4358,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4348
4358
|
}
|
|
4349
4359
|
return shapeIds;
|
|
4350
4360
|
}
|
|
4361
|
+
/** @deprecated Use {@link Editor.getDraggingOverShape} instead */
|
|
4362
|
+
getDroppingOverShape(point, droppingShapes) {
|
|
4363
|
+
return this.getDraggingOverShape(point, droppingShapes);
|
|
4364
|
+
}
|
|
4351
4365
|
/**
|
|
4352
4366
|
* Get the shape that some shapes should be dropped on at a given point.
|
|
4353
4367
|
*
|
|
@@ -4358,22 +4372,20 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4358
4372
|
*
|
|
4359
4373
|
* @public
|
|
4360
4374
|
*/
|
|
4361
|
-
|
|
4362
|
-
const
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
if (maskedPageBounds && maskedPageBounds.containsPoint(point) && this.getShapeGeometry(shape).hitTestPoint(this.getPointInShapeSpace(shape, point), 0, true)) {
|
|
4376
|
-
return shape;
|
|
4375
|
+
getDraggingOverShape(point, droppingShapes) {
|
|
4376
|
+
const draggingShapes = (0, import_utils.compact)(droppingShapes.map((s) => this.getShape(s))).filter(
|
|
4377
|
+
(s) => !s.isLocked && !this.isShapeHidden(s)
|
|
4378
|
+
);
|
|
4379
|
+
const maybeDraggingOverShapes = this.getShapesAtPoint(point, {
|
|
4380
|
+
hitInside: true,
|
|
4381
|
+
margin: 0
|
|
4382
|
+
}).filter(
|
|
4383
|
+
(s) => !droppingShapes.includes(s) && !s.isLocked && !this.isShapeHidden(s) && !draggingShapes.includes(s)
|
|
4384
|
+
);
|
|
4385
|
+
for (const maybeDraggingOverShape of maybeDraggingOverShapes) {
|
|
4386
|
+
const shapeUtil = this.getShapeUtil(maybeDraggingOverShape);
|
|
4387
|
+
if (shapeUtil.onDragShapesOver || shapeUtil.onDragShapesIn || shapeUtil.onDragShapesOut || shapeUtil.onDropShapesOver) {
|
|
4388
|
+
return maybeDraggingOverShape;
|
|
4377
4389
|
}
|
|
4378
4390
|
}
|
|
4379
4391
|
}
|
|
@@ -4650,7 +4662,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4650
4662
|
*/
|
|
4651
4663
|
duplicateShapes(shapes, offset) {
|
|
4652
4664
|
this.run(() => {
|
|
4653
|
-
const
|
|
4665
|
+
const _ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
4666
|
+
const ids = this._shouldIgnoreShapeLock ? _ids : this._getUnlockedShapeIds(_ids);
|
|
4654
4667
|
if (ids.length <= 0) return this;
|
|
4655
4668
|
const initialIds = new Set(ids);
|
|
4656
4669
|
const shapeIdSet = this.getShapeAndDescendantIds(ids);
|
|
@@ -4714,8 +4727,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4714
4727
|
shape.index = index;
|
|
4715
4728
|
});
|
|
4716
4729
|
const shapesToCreate = shapesToCreateWithOriginals.map(({ shape }) => shape);
|
|
4717
|
-
|
|
4718
|
-
if (maxShapesReached) {
|
|
4730
|
+
if (!this.canCreateShapes(shapesToCreate)) {
|
|
4719
4731
|
alertMaxShapes(this);
|
|
4720
4732
|
return;
|
|
4721
4733
|
}
|
|
@@ -5730,6 +5742,26 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5730
5742
|
getInitialMetaForShape(_shape) {
|
|
5731
5743
|
return {};
|
|
5732
5744
|
}
|
|
5745
|
+
/**
|
|
5746
|
+
* Get whether the provided shape can be created.
|
|
5747
|
+
*
|
|
5748
|
+
* @param shape - The shape or shape IDs to check.
|
|
5749
|
+
*
|
|
5750
|
+
* @public
|
|
5751
|
+
*/
|
|
5752
|
+
canCreateShape(shape) {
|
|
5753
|
+
return this.canCreateShapes([shape]);
|
|
5754
|
+
}
|
|
5755
|
+
/**
|
|
5756
|
+
* Get whether the provided shapes can be created.
|
|
5757
|
+
*
|
|
5758
|
+
* @param shapes - The shapes or shape IDs to create.
|
|
5759
|
+
*
|
|
5760
|
+
* @public
|
|
5761
|
+
*/
|
|
5762
|
+
canCreateShapes(shapes) {
|
|
5763
|
+
return shapes.length + this.getCurrentPageShapeIds().size <= this.options.maxShapesPerPage;
|
|
5764
|
+
}
|
|
5733
5765
|
/**
|
|
5734
5766
|
* Create a single shape.
|
|
5735
5767
|
*
|
|
@@ -5783,7 +5815,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5783
5815
|
let parentId = this.getFocusedGroupId();
|
|
5784
5816
|
for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) {
|
|
5785
5817
|
const parent = currentPageShapesSorted[i];
|
|
5786
|
-
|
|
5818
|
+
const util = this.getShapeUtil(parent);
|
|
5819
|
+
if (util.canReceiveNewChildrenOfType(parent, partial.type) && !this.isShapeHidden(parent) && this.isPointInShape(
|
|
5787
5820
|
parent,
|
|
5788
5821
|
// If no parent is provided, then we can treat the
|
|
5789
5822
|
// shape's provided x/y as being in the page's space.
|
|
@@ -5858,6 +5891,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5858
5891
|
...shape.meta
|
|
5859
5892
|
};
|
|
5860
5893
|
});
|
|
5894
|
+
this.emit("created-shapes", shapeRecordsToCreate);
|
|
5895
|
+
this.emit("edit");
|
|
5861
5896
|
this.store.put(shapeRecordsToCreate);
|
|
5862
5897
|
});
|
|
5863
5898
|
return this;
|
|
@@ -6099,6 +6134,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6099
6134
|
updated = this.getShapeUtil(shape).onBeforeUpdate?.(shape, updated) ?? updated;
|
|
6100
6135
|
updates.push(updated);
|
|
6101
6136
|
}
|
|
6137
|
+
this.emit("edited-shapes", updates);
|
|
6138
|
+
this.emit("edit");
|
|
6102
6139
|
this.store.put(updates);
|
|
6103
6140
|
});
|
|
6104
6141
|
}
|
|
@@ -6120,6 +6157,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6120
6157
|
allShapeIdsToDelete.add(childId);
|
|
6121
6158
|
});
|
|
6122
6159
|
}
|
|
6160
|
+
this.emit("deleted-shapes", [...allShapeIdsToDelete]);
|
|
6161
|
+
this.emit("edit");
|
|
6123
6162
|
return this.run(() => this.store.remove([...allShapeIdsToDelete]));
|
|
6124
6163
|
}
|
|
6125
6164
|
deleteShape(_id) {
|
|
@@ -6463,6 +6502,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6463
6502
|
async putExternalContent(info) {
|
|
6464
6503
|
return this.externalContentHandlers[info.type]?.(info);
|
|
6465
6504
|
}
|
|
6505
|
+
/**
|
|
6506
|
+
* Handle replacing external content.
|
|
6507
|
+
*
|
|
6508
|
+
* @param info - Info about the external content.
|
|
6509
|
+
*/
|
|
6510
|
+
async replaceExternalContent(info) {
|
|
6511
|
+
return this.externalContentHandlers[info.type]?.(info);
|
|
6512
|
+
}
|
|
6466
6513
|
/**
|
|
6467
6514
|
* Get content that can be exported for the given shape ids.
|
|
6468
6515
|
*
|
|
@@ -6880,7 +6927,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6880
6927
|
previousScreenPoint,
|
|
6881
6928
|
previousPagePoint,
|
|
6882
6929
|
currentScreenPoint,
|
|
6883
|
-
currentPagePoint
|
|
6930
|
+
currentPagePoint,
|
|
6931
|
+
originScreenPoint,
|
|
6932
|
+
originPagePoint
|
|
6884
6933
|
} = this.inputs;
|
|
6885
6934
|
const { screenBounds } = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
|
|
6886
6935
|
const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
|
|
@@ -6898,8 +6947,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6898
6947
|
this.inputs.isPen = info.type === "pointer" && info.isPen;
|
|
6899
6948
|
if (info.name === "pointer_down" || this.inputs.isPinching) {
|
|
6900
6949
|
pointerVelocity.set(0, 0);
|
|
6901
|
-
|
|
6902
|
-
|
|
6950
|
+
originScreenPoint.setTo(currentScreenPoint);
|
|
6951
|
+
originPagePoint.setTo(currentPagePoint);
|
|
6903
6952
|
}
|
|
6904
6953
|
this.run(
|
|
6905
6954
|
() => {
|
|
@@ -7752,7 +7801,6 @@ __decorateElement(_init, 1, "getCurrentPageShapesInReadingOrder", _getCurrentPag
|
|
|
7752
7801
|
__decorateElement(_init, 1, "getOnlySelectedShapeId", _getOnlySelectedShapeId_dec, Editor);
|
|
7753
7802
|
__decorateElement(_init, 1, "getOnlySelectedShape", _getOnlySelectedShape_dec, Editor);
|
|
7754
7803
|
__decorateElement(_init, 1, "getSelectionPageBounds", _getSelectionPageBounds_dec, Editor);
|
|
7755
|
-
__decorateElement(_init, 1, "getSelectionScreenBounds", _getSelectionScreenBounds_dec, Editor);
|
|
7756
7804
|
__decorateElement(_init, 1, "getSelectionRotation", _getSelectionRotation_dec, Editor);
|
|
7757
7805
|
__decorateElement(_init, 1, "getSelectionRotatedPageBounds", _getSelectionRotatedPageBounds_dec, Editor);
|
|
7758
7806
|
__decorateElement(_init, 1, "getSelectionRotatedScreenBounds", _getSelectionRotatedScreenBounds_dec, Editor);
|