@tldraw/editor 5.5.0-next.c25ed1f4cf7f → 5.5.0-next.c91b2de0a423
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 +49 -23
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +16 -12
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +42 -3
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +5 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +2 -5
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +3 -3
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +154 -173
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/derivations/bindingsIndex.js +2 -0
- package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +3 -2
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EditorManager.js +11 -2
- package/dist-cjs/lib/editor/managers/EditorManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +49 -63
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js +1 -1
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +24 -24
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +7 -1
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +4 -3
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +4 -4
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/exports/ExportDelay.js +10 -2
- package/dist-cjs/lib/exports/ExportDelay.js.map +2 -2
- package/dist-cjs/lib/exports/FontEmbedder.js +25 -11
- package/dist-cjs/lib/exports/FontEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/StyleEmbedder.js +9 -4
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/fetchCache.js +3 -0
- package/dist-cjs/lib/exports/fetchCache.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgAsImage.js +10 -4
- package/dist-cjs/lib/exports/getSvgAsImage.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +18 -9
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/exports/parseCss.js +1 -1
- package/dist-cjs/lib/exports/parseCss.js.map +1 -1
- package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +24 -0
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useIdentity.js +6 -2
- package/dist-cjs/lib/hooks/useIdentity.js.map +3 -3
- package/dist-cjs/lib/license/LicenseManager.js +9 -1
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/lib/license/LicenseProvider.js +12 -4
- package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
- package/dist-cjs/lib/utils/debug-flags.js +0 -6
- package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
- package/dist-cjs/lib/utils/deepLinks.js +2 -1
- package/dist-cjs/lib/utils/deepLinks.js.map +2 -2
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js +19 -8
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -0
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.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 +49 -23
- package/dist-esm/index.mjs +4 -2
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +17 -13
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +42 -3
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +5 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +2 -5
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +3 -3
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +154 -173
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/derivations/bindingsIndex.mjs +2 -0
- package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +3 -2
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EditorManager.mjs +11 -2
- package/dist-esm/lib/editor/managers/EditorManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +49 -63
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +24 -24
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +7 -1
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +4 -3
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +4 -4
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/exports/ExportDelay.mjs +11 -3
- package/dist-esm/lib/exports/ExportDelay.mjs.map +2 -2
- package/dist-esm/lib/exports/FontEmbedder.mjs +25 -11
- package/dist-esm/lib/exports/FontEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/StyleEmbedder.mjs +9 -4
- package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/fetchCache.mjs +3 -0
- package/dist-esm/lib/exports/fetchCache.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgAsImage.mjs +10 -4
- package/dist-esm/lib/exports/getSvgAsImage.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +18 -9
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/exports/parseCss.mjs +1 -1
- package/dist-esm/lib/exports/parseCss.mjs.map +1 -1
- package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +24 -0
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useIdentity.mjs +7 -3
- package/dist-esm/lib/hooks/useIdentity.mjs.map +3 -3
- package/dist-esm/lib/license/LicenseManager.mjs +9 -1
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseProvider.mjs +13 -5
- package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
- package/dist-esm/lib/utils/debug-flags.mjs +0 -6
- package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
- package/dist-esm/lib/utils/deepLinks.mjs +2 -1
- package/dist-esm/lib/utils/deepLinks.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs +19 -8
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -0
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +9 -1
- package/package.json +8 -11
- package/src/index.ts +5 -1
- package/src/lib/TldrawEditor.tsx +35 -21
- package/src/lib/components/MenuClickCapture.tsx +55 -4
- package/src/lib/components/default-components/DefaultCanvas.tsx +7 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +13 -5
- package/src/lib/components/default-components/DefaultSpinner.tsx +4 -1
- package/src/lib/editor/Editor.test.ts +65 -0
- package/src/lib/editor/Editor.ts +230 -279
- package/src/lib/editor/derivations/bindingsIndex.ts +3 -0
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +1 -0
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +3 -2
- package/src/lib/editor/managers/EditorManager.test.ts +32 -1
- package/src/lib/editor/managers/EditorManager.ts +15 -3
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +80 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +54 -81
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.ts +1 -1
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +32 -36
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +13 -2
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +13 -0
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +6 -4
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +74 -0
- package/src/lib/editor/managers/TextManager/TextManager.ts +6 -5
- package/src/lib/editor/types/external-content.ts +5 -0
- package/src/lib/exports/ExportDelay.tsx +16 -4
- package/src/lib/exports/FontEmbedder.test.ts +99 -0
- package/src/lib/exports/FontEmbedder.ts +32 -11
- package/src/lib/exports/StyleEmbedder.ts +13 -4
- package/src/lib/exports/fetchCache.test.ts +22 -0
- package/src/lib/exports/fetchCache.ts +4 -0
- package/src/lib/exports/getSvgAsImage.ts +13 -5
- package/src/lib/exports/getSvgJsx.test.ts +43 -1
- package/src/lib/exports/getSvgJsx.tsx +28 -16
- package/src/lib/exports/parseCss.test.ts +4 -0
- package/src/lib/exports/parseCss.ts +2 -2
- package/src/lib/hooks/EditorComponentsContext.tsx +2 -1
- package/src/lib/hooks/useCanvasEvents.ts +42 -0
- package/src/lib/hooks/useIdentity.tsx +12 -1
- package/src/lib/license/LicenseManager.ts +13 -1
- package/src/lib/license/LicenseProvider.test.tsx +76 -0
- package/src/lib/license/LicenseProvider.tsx +19 -5
- package/src/lib/test/preserveFocus.test.tsx +81 -0
- package/src/lib/utils/debug-flags.ts +0 -6
- package/src/lib/utils/deepLinks.test.ts +15 -0
- package/src/lib/utils/deepLinks.ts +8 -3
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +93 -1
- package/src/lib/utils/sync/LocalIndexedDb.ts +23 -8
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +21 -1
- package/src/lib/utils/sync/TLLocalSyncClient.ts +6 -0
- package/src/version.ts +3 -3
- package/dist-cjs/lib/primitives/geometry/geometry.bench.js +0 -133
- package/dist-cjs/lib/primitives/geometry/geometry.bench.js.map +0 -7
- package/dist-esm/lib/primitives/geometry/geometry.bench.mjs +0 -132
- package/dist-esm/lib/primitives/geometry/geometry.bench.mjs.map +0 -7
- package/src/lib/primitives/geometry/geometry.bench.ts +0 -179
|
@@ -136,6 +136,10 @@ import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPr
|
|
|
136
136
|
import { OverlayManager } from "./overlays/OverlayManager.mjs";
|
|
137
137
|
import { RootState } from "./tools/RootState.mjs";
|
|
138
138
|
const RENDERING_SHAPES_SORT_CACHE_THRESHOLD = 100;
|
|
139
|
+
const AXIS = {
|
|
140
|
+
horizontal: { val: "x", min: "minX", max: "maxX", dim: "width" },
|
|
141
|
+
vertical: { val: "y", min: "minY", max: "maxY", dim: "height" }
|
|
142
|
+
};
|
|
139
143
|
class Editor extends EventEmitter {
|
|
140
144
|
id = uniqueId();
|
|
141
145
|
constructor({
|
|
@@ -462,7 +466,7 @@ class Editor extends EventEmitter {
|
|
|
462
466
|
}
|
|
463
467
|
}
|
|
464
468
|
if (deleteBindingIds.length) {
|
|
465
|
-
this.
|
|
469
|
+
this.store.remove(deleteBindingIds);
|
|
466
470
|
}
|
|
467
471
|
}
|
|
468
472
|
},
|
|
@@ -1422,6 +1426,7 @@ class Editor extends EventEmitter {
|
|
|
1422
1426
|
* @public
|
|
1423
1427
|
**/
|
|
1424
1428
|
updateDocumentSettings(settings) {
|
|
1429
|
+
if (this.getIsReadonly()) return this;
|
|
1425
1430
|
this.run(
|
|
1426
1431
|
() => {
|
|
1427
1432
|
this.store.put([{ ...this.getDocumentSettings(), ...settings }]);
|
|
@@ -1444,7 +1449,7 @@ class Editor extends EventEmitter {
|
|
|
1444
1449
|
updateInstanceState(partial, historyOptions) {
|
|
1445
1450
|
this._updateInstanceState(partial, { history: "ignore", ...historyOptions });
|
|
1446
1451
|
if (partial.isChangingStyle !== void 0) {
|
|
1447
|
-
clearTimeout(this._isChangingStyleTimeout);
|
|
1452
|
+
this.timers.clearTimeout(this._isChangingStyleTimeout);
|
|
1448
1453
|
if (partial.isChangingStyle === true) {
|
|
1449
1454
|
this._isChangingStyleTimeout = this.timers.setTimeout(() => {
|
|
1450
1455
|
this._updateInstanceState({ isChangingStyle: false }, { history: "ignore" });
|
|
@@ -1581,7 +1586,7 @@ class Editor extends EventEmitter {
|
|
|
1581
1586
|
* @public
|
|
1582
1587
|
*/
|
|
1583
1588
|
select(...shapes) {
|
|
1584
|
-
const ids =
|
|
1589
|
+
const ids = toShapeIds(shapes);
|
|
1585
1590
|
this.setSelectedShapes(ids);
|
|
1586
1591
|
return this;
|
|
1587
1592
|
}
|
|
@@ -1596,7 +1601,7 @@ class Editor extends EventEmitter {
|
|
|
1596
1601
|
* @public
|
|
1597
1602
|
*/
|
|
1598
1603
|
deselect(...shapes) {
|
|
1599
|
-
const ids =
|
|
1604
|
+
const ids = toShapeIds(shapes);
|
|
1600
1605
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
1601
1606
|
if (selectedShapeIds.length > 0 && ids.length > 0) {
|
|
1602
1607
|
this.setSelectedShapes(selectedShapeIds.filter((id) => !ids.includes(id)));
|
|
@@ -1634,7 +1639,7 @@ class Editor extends EventEmitter {
|
|
|
1634
1639
|
}
|
|
1635
1640
|
const ids = this.getSortedChildIdsForParent(parentToSelectWithinId);
|
|
1636
1641
|
if (ids.length <= 0) return this;
|
|
1637
|
-
this.setSelectedShapes(this.
|
|
1642
|
+
this.setSelectedShapes(ids.filter((id) => !this.getShape(id)?.isLocked));
|
|
1638
1643
|
return this;
|
|
1639
1644
|
}
|
|
1640
1645
|
/**
|
|
@@ -1761,13 +1766,14 @@ class Editor extends EventEmitter {
|
|
|
1761
1766
|
});
|
|
1762
1767
|
if (shapesInDirection.length === 0) return currentShapeId;
|
|
1763
1768
|
const lowestScoringShape = minBy(shapesInDirection, ({ center }) => {
|
|
1764
|
-
const distance = Vec.
|
|
1769
|
+
const distance = Vec.Dist(currentCenter, center);
|
|
1765
1770
|
const dirProp = ["left", "right"].includes(direction) ? "x" : "y";
|
|
1766
1771
|
const directionalDistance = Math.abs(center[dirProp] - currentCenter[dirProp]);
|
|
1767
1772
|
const offProp = ["left", "right"].includes(direction) ? "y" : "x";
|
|
1768
1773
|
const offAxisDeviation = Math.abs(center[offProp] - currentCenter[offProp]);
|
|
1769
|
-
const angle =
|
|
1770
|
-
const
|
|
1774
|
+
const angle = (Vec.Angle(currentCenter, center) * (180 / Math.PI) + 360) % 360;
|
|
1775
|
+
const rawAngleDeviation = Math.abs(angle - directionToAngle[direction]);
|
|
1776
|
+
const angleDeviation = Math.min(rawAngleDeviation, 360 - rawAngleDeviation);
|
|
1771
1777
|
return distance * 1 + // Base distance
|
|
1772
1778
|
offAxisDeviation * 2 + // Heavy penalty for off-axis deviation
|
|
1773
1779
|
(distance - directionalDistance) * 1.5 + // Penalty for diagonal distance
|
|
@@ -2105,7 +2111,7 @@ class Editor extends EventEmitter {
|
|
|
2105
2111
|
* @public
|
|
2106
2112
|
*/
|
|
2107
2113
|
setHintingShapes(shapes) {
|
|
2108
|
-
const ids =
|
|
2114
|
+
const ids = toShapeIds(shapes);
|
|
2109
2115
|
this.run(
|
|
2110
2116
|
() => {
|
|
2111
2117
|
this._updateCurrentPageState({ hintingShapeIds: dedupe(ids) });
|
|
@@ -2135,7 +2141,7 @@ class Editor extends EventEmitter {
|
|
|
2135
2141
|
* @public
|
|
2136
2142
|
*/
|
|
2137
2143
|
setErasingShapes(shapes) {
|
|
2138
|
-
const ids =
|
|
2144
|
+
const ids = toShapeIds(shapes).slice();
|
|
2139
2145
|
ids.sort();
|
|
2140
2146
|
const erasingShapeIds = this.getErasingShapeIds();
|
|
2141
2147
|
this.run(
|
|
@@ -2542,7 +2548,7 @@ class Editor extends EventEmitter {
|
|
|
2542
2548
|
setCamera(point, opts) {
|
|
2543
2549
|
const { isLocked } = this._cameraOptions.__unsafe__getWithoutCapture();
|
|
2544
2550
|
if (isLocked && !opts?.force) return this;
|
|
2545
|
-
const _point = Vec.
|
|
2551
|
+
const _point = new Vec(point.x, point.y, point.z ?? this.getZoomLevel());
|
|
2546
2552
|
if (!Number.isFinite(_point.x) || !Number.isFinite(_point.y) || !Number.isFinite(_point.z)) {
|
|
2547
2553
|
throw Error(
|
|
2548
2554
|
`Editor.setCamera: expected finite values, got (${_point.x}, ${_point.y}, ${_point.z}).`
|
|
@@ -2836,11 +2842,14 @@ class Editor extends EventEmitter {
|
|
|
2836
2842
|
_animateViewport(ms) {
|
|
2837
2843
|
if (!this._viewportAnimation) return;
|
|
2838
2844
|
this._viewportAnimation.elapsed += ms;
|
|
2839
|
-
const { elapsed, easing, duration, start, end } = this._viewportAnimation;
|
|
2845
|
+
const { elapsed, easing, duration, start, end, opts } = this._viewportAnimation;
|
|
2840
2846
|
if (elapsed > duration) {
|
|
2841
2847
|
this.off("tick", this._animateViewport);
|
|
2842
2848
|
this._viewportAnimation = null;
|
|
2843
|
-
this._setCamera(
|
|
2849
|
+
this._setCamera(
|
|
2850
|
+
new Vec(-end.x, -end.y, this.getViewportScreenBounds().width / end.width),
|
|
2851
|
+
opts
|
|
2852
|
+
);
|
|
2844
2853
|
return;
|
|
2845
2854
|
}
|
|
2846
2855
|
const remaining = duration - elapsed;
|
|
@@ -2878,7 +2887,8 @@ class Editor extends EventEmitter {
|
|
|
2878
2887
|
duration: duration / animationSpeed,
|
|
2879
2888
|
easing,
|
|
2880
2889
|
start: viewportPageBounds.clone(),
|
|
2881
|
-
end: targetViewportPage.clone()
|
|
2890
|
+
end: targetViewportPage.clone(),
|
|
2891
|
+
opts: rest
|
|
2882
2892
|
};
|
|
2883
2893
|
this.once("stop-camera-animation", () => {
|
|
2884
2894
|
this.off("tick", this._animateViewport);
|
|
@@ -3796,7 +3806,9 @@ class Editor extends EventEmitter {
|
|
|
3796
3806
|
if (ids.length <= 0) return this;
|
|
3797
3807
|
this.run(
|
|
3798
3808
|
() => {
|
|
3799
|
-
this.store.props.assets.remove?.(ids)
|
|
3809
|
+
Promise.resolve(this.store.props.assets.remove?.(ids)).catch(
|
|
3810
|
+
(err) => console.error("Error while removing assets from the asset store:", err)
|
|
3811
|
+
);
|
|
3800
3812
|
this.store.remove(ids);
|
|
3801
3813
|
},
|
|
3802
3814
|
{ history: "ignore" }
|
|
@@ -4178,7 +4190,7 @@ class Editor extends EventEmitter {
|
|
|
4178
4190
|
if (shapes.length === 0) {
|
|
4179
4191
|
return;
|
|
4180
4192
|
}
|
|
4181
|
-
const ids =
|
|
4193
|
+
const ids = toShapeIds(shapes);
|
|
4182
4194
|
const freshShapes = compact(ids.map((id) => this.getShape(id)));
|
|
4183
4195
|
if (freshShapes.length === 1) {
|
|
4184
4196
|
const parentId = freshShapes[0].parentId;
|
|
@@ -4275,12 +4287,14 @@ class Editor extends EventEmitter {
|
|
|
4275
4287
|
*/
|
|
4276
4288
|
getSelectedShapeAtPoint(point) {
|
|
4277
4289
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
4278
|
-
|
|
4290
|
+
if (selectedShapeIds.length === 0) return void 0;
|
|
4291
|
+
const selectedShapeIdSet = new Set(selectedShapeIds);
|
|
4292
|
+
const margin = this.getHitTestMargin();
|
|
4279
4293
|
const sortedShapes = this.getCurrentPageShapesSorted();
|
|
4280
4294
|
for (let i = sortedShapes.length - 1; i >= 0; i--) {
|
|
4281
4295
|
const shape = sortedShapes[i];
|
|
4282
4296
|
if (shape.type === "group") continue;
|
|
4283
|
-
if (!
|
|
4297
|
+
if (!selectedShapeIdSet.has(shape.id)) continue;
|
|
4284
4298
|
if (this.getShapeGeometry(shape).hitTestPoint(
|
|
4285
4299
|
this.getPointInShapeSpace(shape, point),
|
|
4286
4300
|
margin,
|
|
@@ -4378,7 +4392,6 @@ class Editor extends EventEmitter {
|
|
|
4378
4392
|
}
|
|
4379
4393
|
return inMarginClosestToEdgeHit || shape;
|
|
4380
4394
|
} else {
|
|
4381
|
-
if (this.getShapePageBounds(shape).contains(viewportPageBounds)) continue;
|
|
4382
4395
|
if (hitInside ? (
|
|
4383
4396
|
// On hitInside, the distance will be negative for hits inside
|
|
4384
4397
|
// If the distance is positive, check against the outer margin
|
|
@@ -4395,6 +4408,7 @@ class Editor extends EventEmitter {
|
|
|
4395
4408
|
inMarginClosestToEdgeHit = shape;
|
|
4396
4409
|
}
|
|
4397
4410
|
} else if (!inMarginClosestToEdgeHit) {
|
|
4411
|
+
if (this.getShapePageBounds(shape).contains(viewportPageBounds)) continue;
|
|
4398
4412
|
const { area } = geometry;
|
|
4399
4413
|
if (area < inHollowSmallestArea) {
|
|
4400
4414
|
inHollowSmallestArea = area;
|
|
@@ -4405,6 +4419,9 @@ class Editor extends EventEmitter {
|
|
|
4405
4419
|
}
|
|
4406
4420
|
} else {
|
|
4407
4421
|
if (distance < this.getHitTestMargin()) {
|
|
4422
|
+
if (inMarginClosestToEdgeHit && inMarginClosestToEdgeDistance <= distance) {
|
|
4423
|
+
return inMarginClosestToEdgeHit;
|
|
4424
|
+
}
|
|
4408
4425
|
return shape;
|
|
4409
4426
|
}
|
|
4410
4427
|
}
|
|
@@ -4681,7 +4698,7 @@ class Editor extends EventEmitter {
|
|
|
4681
4698
|
* @public
|
|
4682
4699
|
*/
|
|
4683
4700
|
reparentShapes(shapes, parentId, insertIndex) {
|
|
4684
|
-
const ids =
|
|
4701
|
+
const ids = toShapeIds(shapes);
|
|
4685
4702
|
if (ids.length === 0) return this;
|
|
4686
4703
|
const changes = [];
|
|
4687
4704
|
const parentTransform = isPageId(parentId) ? Mat.Identity() : this.getShapePageTransform(parentId);
|
|
@@ -4910,6 +4927,7 @@ class Editor extends EventEmitter {
|
|
|
4910
4927
|
* binding, but the `type`, `toId`, and `fromId` must all be provided.
|
|
4911
4928
|
*/
|
|
4912
4929
|
createBindings(partials) {
|
|
4930
|
+
if (this.getIsReadonly()) return this;
|
|
4913
4931
|
const bindings = [];
|
|
4914
4932
|
for (const partial of partials) {
|
|
4915
4933
|
const fromShape = this.getShape(partial.fromId);
|
|
@@ -4944,6 +4962,7 @@ class Editor extends EventEmitter {
|
|
|
4944
4962
|
* binding is skipped. The changes from the partial are merged into the existing record.
|
|
4945
4963
|
*/
|
|
4946
4964
|
updateBindings(partials) {
|
|
4965
|
+
if (this.getIsReadonly()) return this;
|
|
4947
4966
|
const updated = [];
|
|
4948
4967
|
for (const partial of partials) {
|
|
4949
4968
|
if (!partial) continue;
|
|
@@ -4972,6 +4991,16 @@ class Editor extends EventEmitter {
|
|
|
4972
4991
|
* Delete several bindings by their IDs. If a binding ID doesn't exist, it's ignored.
|
|
4973
4992
|
*/
|
|
4974
4993
|
deleteBindings(bindings, { isolateShapes = false } = {}) {
|
|
4994
|
+
if (this.getIsReadonly()) return this;
|
|
4995
|
+
return this._deleteBindings(bindings, { isolateShapes });
|
|
4996
|
+
}
|
|
4997
|
+
/**
|
|
4998
|
+
* Unguarded so that withIsolatedShapes can transiently isolate shapes for copy and export in
|
|
4999
|
+
* readonly mode; the public deleteBindings is what readonly blocks.
|
|
5000
|
+
*
|
|
5001
|
+
* @internal
|
|
5002
|
+
*/
|
|
5003
|
+
_deleteBindings(bindings, { isolateShapes = false } = {}) {
|
|
4975
5004
|
const ids = bindings.map((binding) => typeof binding === "string" ? binding : binding.id);
|
|
4976
5005
|
if (isolateShapes) {
|
|
4977
5006
|
this.store.atomic(() => {
|
|
@@ -5030,7 +5059,7 @@ class Editor extends EventEmitter {
|
|
|
5030
5059
|
* @param opts - The options for the rotation.
|
|
5031
5060
|
*/
|
|
5032
5061
|
rotateShapesBy(shapes, delta, opts) {
|
|
5033
|
-
const ids =
|
|
5062
|
+
const ids = toShapeIds(shapes);
|
|
5034
5063
|
if (ids.length <= 0) return this;
|
|
5035
5064
|
const snapshot = getRotationSnapshot({ editor: this, ids });
|
|
5036
5065
|
if (!snapshot) return this;
|
|
@@ -5067,6 +5096,14 @@ class Editor extends EventEmitter {
|
|
|
5067
5096
|
}
|
|
5068
5097
|
return workingShape;
|
|
5069
5098
|
}
|
|
5099
|
+
// Counter-rotates the page-space delta into the parent's space; without that a child of a rotated
|
|
5100
|
+
// frame or group would move along its parent's axes instead of the page's.
|
|
5101
|
+
// todo: a shape laid out together with its own parent moves twice, once with the parent and once
|
|
5102
|
+
// on its own; the layout commands should skip shapes whose ancestors are also being laid out
|
|
5103
|
+
getChangesToTranslateShapeByPageDelta(shape, pageDelta) {
|
|
5104
|
+
const localDelta = Vec.From(pageDelta).rot(-this.getShapeParentTransform(shape).rotation());
|
|
5105
|
+
return this.getChangesToTranslateShape(shape, localDelta.add(shape));
|
|
5106
|
+
}
|
|
5070
5107
|
/**
|
|
5071
5108
|
* Move shapes by a delta.
|
|
5072
5109
|
*
|
|
@@ -5079,14 +5116,12 @@ class Editor extends EventEmitter {
|
|
|
5079
5116
|
* @param offset - The offset to apply to the shapes.
|
|
5080
5117
|
*/
|
|
5081
5118
|
nudgeShapes(shapes, offset) {
|
|
5082
|
-
const ids =
|
|
5119
|
+
const ids = toShapeIds(shapes);
|
|
5083
5120
|
if (ids.length <= 0) return this;
|
|
5084
5121
|
const changes = [];
|
|
5085
5122
|
for (const id of ids) {
|
|
5086
5123
|
const shape = this.getShape(id);
|
|
5087
|
-
|
|
5088
|
-
localDelta.rot(-this.getShapeParentTransform(shape).rotation());
|
|
5089
|
-
changes.push(this.getChangesToTranslateShape(shape, localDelta.add(shape)));
|
|
5124
|
+
changes.push(this.getChangesToTranslateShapeByPageDelta(shape, offset));
|
|
5090
5125
|
}
|
|
5091
5126
|
this.updateShapes(changes);
|
|
5092
5127
|
return this;
|
|
@@ -5107,7 +5142,7 @@ class Editor extends EventEmitter {
|
|
|
5107
5142
|
*/
|
|
5108
5143
|
duplicateShapes(shapes, offset) {
|
|
5109
5144
|
this.run(() => {
|
|
5110
|
-
const _ids =
|
|
5145
|
+
const _ids = toShapeIds(shapes);
|
|
5111
5146
|
const ids = this._shouldIgnoreShapeLock ? _ids : this._getUnlockedShapeIds(_ids);
|
|
5112
5147
|
if (ids.length <= 0) return this;
|
|
5113
5148
|
const initialIds = new Set(ids);
|
|
@@ -5216,7 +5251,7 @@ class Editor extends EventEmitter {
|
|
|
5216
5251
|
* @public
|
|
5217
5252
|
*/
|
|
5218
5253
|
moveShapesToPage(shapes, pageId) {
|
|
5219
|
-
const ids =
|
|
5254
|
+
const ids = toShapeIds(shapes);
|
|
5220
5255
|
if (ids.length === 0) return this;
|
|
5221
5256
|
if (this.getIsReadonly()) return this;
|
|
5222
5257
|
const currentPageId = this.getCurrentPageId();
|
|
@@ -5252,7 +5287,7 @@ class Editor extends EventEmitter {
|
|
|
5252
5287
|
* @public
|
|
5253
5288
|
*/
|
|
5254
5289
|
toggleLock(shapes) {
|
|
5255
|
-
const ids =
|
|
5290
|
+
const ids = toShapeIds(shapes);
|
|
5256
5291
|
if (this.getIsReadonly() || ids.length === 0) return this;
|
|
5257
5292
|
let allLocked = true;
|
|
5258
5293
|
const shapesToToggle = [];
|
|
@@ -5291,7 +5326,7 @@ class Editor extends EventEmitter {
|
|
|
5291
5326
|
* @public
|
|
5292
5327
|
*/
|
|
5293
5328
|
sendToBack(shapes) {
|
|
5294
|
-
const ids =
|
|
5329
|
+
const ids = toShapeIds(shapes);
|
|
5295
5330
|
const changes = getReorderingShapesChanges(this, "toBack", ids, {
|
|
5296
5331
|
considerAllShapes: true
|
|
5297
5332
|
});
|
|
@@ -5321,7 +5356,7 @@ class Editor extends EventEmitter {
|
|
|
5321
5356
|
* @public
|
|
5322
5357
|
*/
|
|
5323
5358
|
sendBackward(shapes, opts = {}) {
|
|
5324
|
-
const ids =
|
|
5359
|
+
const ids = toShapeIds(shapes);
|
|
5325
5360
|
const changes = getReorderingShapesChanges(this, "backward", ids, opts);
|
|
5326
5361
|
if (changes) this.updateShapes(changes);
|
|
5327
5362
|
return this;
|
|
@@ -5349,7 +5384,7 @@ class Editor extends EventEmitter {
|
|
|
5349
5384
|
* @public
|
|
5350
5385
|
*/
|
|
5351
5386
|
bringForward(shapes, opts = {}) {
|
|
5352
|
-
const ids =
|
|
5387
|
+
const ids = toShapeIds(shapes);
|
|
5353
5388
|
const changes = getReorderingShapesChanges(this, "forward", ids, opts);
|
|
5354
5389
|
if (changes) this.updateShapes(changes);
|
|
5355
5390
|
return this;
|
|
@@ -5368,7 +5403,7 @@ class Editor extends EventEmitter {
|
|
|
5368
5403
|
* @public
|
|
5369
5404
|
*/
|
|
5370
5405
|
bringToFront(shapes) {
|
|
5371
|
-
const ids =
|
|
5406
|
+
const ids = toShapeIds(shapes);
|
|
5372
5407
|
const changes = getReorderingShapesChanges(this, "toFront", ids);
|
|
5373
5408
|
if (changes) this.updateShapes(changes);
|
|
5374
5409
|
return this;
|
|
@@ -5380,7 +5415,7 @@ class Editor extends EventEmitter {
|
|
|
5380
5415
|
* @internal
|
|
5381
5416
|
*/
|
|
5382
5417
|
getShapeClusters(shapes, type, opts) {
|
|
5383
|
-
const ids =
|
|
5418
|
+
const ids = toShapeIds(shapes);
|
|
5384
5419
|
let freshShapes = compact(ids.map((id) => this.getShape(id)));
|
|
5385
5420
|
if (opts?.filterAxisAligned) {
|
|
5386
5421
|
freshShapes = freshShapes.filter((s) => {
|
|
@@ -5461,7 +5496,7 @@ class Editor extends EventEmitter {
|
|
|
5461
5496
|
*/
|
|
5462
5497
|
flipShapes(shapes, operation) {
|
|
5463
5498
|
if (this.getIsReadonly()) return this;
|
|
5464
|
-
const ids =
|
|
5499
|
+
const ids = toShapeIds(shapes);
|
|
5465
5500
|
const shapesToFlipFirstPass = compact(ids.map((id) => this.getShape(id)));
|
|
5466
5501
|
for (const shape of shapesToFlipFirstPass) {
|
|
5467
5502
|
if (this.isShapeOfType(shape, "group")) {
|
|
@@ -5535,21 +5570,7 @@ class Editor extends EventEmitter {
|
|
|
5535
5570
|
const { clusters: shapeClustersToStack } = this.getShapeClusters(shapes, "stack");
|
|
5536
5571
|
const len = shapeClustersToStack.length;
|
|
5537
5572
|
if (_gap === 0 && len < 3 || len < 2) return this;
|
|
5538
|
-
|
|
5539
|
-
let min;
|
|
5540
|
-
let max;
|
|
5541
|
-
let dim;
|
|
5542
|
-
if (operation === "horizontal") {
|
|
5543
|
-
val = "x";
|
|
5544
|
-
min = "minX";
|
|
5545
|
-
max = "maxX";
|
|
5546
|
-
dim = "width";
|
|
5547
|
-
} else {
|
|
5548
|
-
val = "y";
|
|
5549
|
-
min = "minY";
|
|
5550
|
-
max = "maxY";
|
|
5551
|
-
dim = "height";
|
|
5552
|
-
}
|
|
5573
|
+
const { val, min, max, dim } = AXIS[operation];
|
|
5553
5574
|
let shapeGap = 0;
|
|
5554
5575
|
shapeClustersToStack.sort((a, b) => a.pageBounds[min] - b.pageBounds[min]);
|
|
5555
5576
|
if (_gap === 0) {
|
|
@@ -5588,13 +5609,7 @@ class Editor extends EventEmitter {
|
|
|
5588
5609
|
const delta = new Vec();
|
|
5589
5610
|
delta[val] = v + shapeGap - pageBounds[val];
|
|
5590
5611
|
for (const shape of shapes2) {
|
|
5591
|
-
|
|
5592
|
-
const parent = this.getShapeParent(shape);
|
|
5593
|
-
if (parent) {
|
|
5594
|
-
shapeDelta.rot(-this.getShapePageTransform(parent).rotation());
|
|
5595
|
-
}
|
|
5596
|
-
shapeDelta.add(shape);
|
|
5597
|
-
changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
|
|
5612
|
+
changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
|
|
5598
5613
|
}
|
|
5599
5614
|
v += pageBounds[dim] + shapeGap;
|
|
5600
5615
|
}
|
|
@@ -5674,13 +5689,7 @@ class Editor extends EventEmitter {
|
|
|
5674
5689
|
for (const { shapes: shapes2, pageBounds, nextPageBounds } of shapeClustersToPack) {
|
|
5675
5690
|
const delta = Vec.Sub(nextPageBounds.point, pageBounds.point).add(centerDelta);
|
|
5676
5691
|
for (const shape of shapes2) {
|
|
5677
|
-
|
|
5678
|
-
const parent = this.getShapeParent(shape);
|
|
5679
|
-
if (parent) {
|
|
5680
|
-
shapeDelta.rot(-this.getShapeParentTransform(shape).rotation());
|
|
5681
|
-
}
|
|
5682
|
-
shapeDelta.add(shape);
|
|
5683
|
-
changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
|
|
5692
|
+
changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
|
|
5684
5693
|
}
|
|
5685
5694
|
}
|
|
5686
5695
|
if (changes.length) {
|
|
@@ -5740,13 +5749,7 @@ class Editor extends EventEmitter {
|
|
|
5740
5749
|
}
|
|
5741
5750
|
}
|
|
5742
5751
|
for (const shape of shapes2) {
|
|
5743
|
-
|
|
5744
|
-
const parent = this.getShapeParent(shape);
|
|
5745
|
-
if (parent) {
|
|
5746
|
-
shapeDelta.rot(-this.getShapePageTransform(parent).rotation());
|
|
5747
|
-
}
|
|
5748
|
-
shapeDelta.add(shape);
|
|
5749
|
-
changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
|
|
5752
|
+
changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
|
|
5750
5753
|
}
|
|
5751
5754
|
});
|
|
5752
5755
|
this.updateShapes(changes);
|
|
@@ -5770,27 +5773,13 @@ class Editor extends EventEmitter {
|
|
|
5770
5773
|
if (this.getIsReadonly()) return this;
|
|
5771
5774
|
const { clusters: shapeClustersToDistribute } = this.getShapeClusters(shapes, "distribute");
|
|
5772
5775
|
if (shapeClustersToDistribute.length < 3) return this;
|
|
5773
|
-
|
|
5774
|
-
let min;
|
|
5775
|
-
let max;
|
|
5776
|
-
let dim;
|
|
5777
|
-
if (operation === "horizontal") {
|
|
5778
|
-
val = "x";
|
|
5779
|
-
min = "minX";
|
|
5780
|
-
max = "maxX";
|
|
5781
|
-
dim = "width";
|
|
5782
|
-
} else {
|
|
5783
|
-
val = "y";
|
|
5784
|
-
min = "minY";
|
|
5785
|
-
max = "maxY";
|
|
5786
|
-
dim = "height";
|
|
5787
|
-
}
|
|
5776
|
+
const { val, min, max, dim } = AXIS[operation];
|
|
5788
5777
|
const changes = [];
|
|
5789
5778
|
const first = shapeClustersToDistribute.sort((a, b) => a.pageBounds[min] - b.pageBounds[min])[0];
|
|
5790
5779
|
const last2 = shapeClustersToDistribute.sort((a, b) => b.pageBounds[max] - a.pageBounds[max])[0];
|
|
5791
5780
|
if (first === last2) {
|
|
5792
5781
|
const excludedShapeIds = new Set(first.shapes.map((s) => s.id));
|
|
5793
|
-
const ids =
|
|
5782
|
+
const ids = toShapeIds(shapes);
|
|
5794
5783
|
return this.distributeShapes(
|
|
5795
5784
|
ids.filter((id) => !excludedShapeIds.has(id)),
|
|
5796
5785
|
operation
|
|
@@ -5814,13 +5803,7 @@ class Editor extends EventEmitter {
|
|
|
5814
5803
|
delta[val] = last2.pageBounds[max] - pageBounds[max] - 1;
|
|
5815
5804
|
}
|
|
5816
5805
|
for (const shape of shapes2) {
|
|
5817
|
-
|
|
5818
|
-
const parent = this.getShapeParent(shape);
|
|
5819
|
-
if (parent) {
|
|
5820
|
-
shapeDelta.rot(-this.getShapePageTransform(parent).rotation());
|
|
5821
|
-
}
|
|
5822
|
-
shapeDelta.add(shape);
|
|
5823
|
-
changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
|
|
5806
|
+
changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
|
|
5824
5807
|
}
|
|
5825
5808
|
v += pageBounds[dim] + gap;
|
|
5826
5809
|
}
|
|
@@ -5850,32 +5833,17 @@ class Editor extends EventEmitter {
|
|
|
5850
5833
|
);
|
|
5851
5834
|
if (shapeClustersToStretch.length < 2) return this;
|
|
5852
5835
|
const commonBounds = Box.Common(allBounds);
|
|
5853
|
-
|
|
5854
|
-
let min;
|
|
5855
|
-
let dim;
|
|
5856
|
-
if (operation === "horizontal") {
|
|
5857
|
-
val = "x";
|
|
5858
|
-
min = "minX";
|
|
5859
|
-
dim = "width";
|
|
5860
|
-
} else {
|
|
5861
|
-
val = "y";
|
|
5862
|
-
min = "minY";
|
|
5863
|
-
dim = "height";
|
|
5864
|
-
}
|
|
5836
|
+
const { val, min, dim } = AXIS[operation];
|
|
5865
5837
|
this.run(() => {
|
|
5866
5838
|
shapeClustersToStretch.forEach(({ shapes: shapes2, pageBounds }) => {
|
|
5867
|
-
const
|
|
5868
|
-
|
|
5839
|
+
const pageOffset = new Vec();
|
|
5840
|
+
pageOffset[val] = commonBounds[min] - pageBounds[min];
|
|
5869
5841
|
const scaleOrigin = pageBounds.center.clone();
|
|
5870
5842
|
scaleOrigin[val] = commonBounds[min];
|
|
5871
5843
|
const scale = new Vec(1, 1);
|
|
5872
5844
|
scale[val] = commonBounds[dim] / pageBounds[dim];
|
|
5873
5845
|
for (const shape of shapes2) {
|
|
5874
|
-
|
|
5875
|
-
shapeLocalOffset.rot(-this.getShapeParentTransform(shape).rotation());
|
|
5876
|
-
shapeLocalOffset.add(shape);
|
|
5877
|
-
const changes = this.getChangesToTranslateShape(shape, shapeLocalOffset);
|
|
5878
|
-
this.updateShape(changes);
|
|
5846
|
+
this.updateShape(this.getChangesToTranslateShapeByPageDelta(shape, pageOffset));
|
|
5879
5847
|
this.resizeShape(shape.id, scale, {
|
|
5880
5848
|
initialBounds: this.getShapeGeometry(shape).bounds,
|
|
5881
5849
|
scaleOrigin,
|
|
@@ -5918,7 +5886,7 @@ class Editor extends EventEmitter {
|
|
|
5918
5886
|
const scaleY = targetBounds.height / commonBounds.height;
|
|
5919
5887
|
const scale = new Vec(scaleX, scaleY);
|
|
5920
5888
|
shapeClusters.forEach(({ shapes: shapes2, pageBounds }) => {
|
|
5921
|
-
const
|
|
5889
|
+
const pageOffset = new Vec(
|
|
5922
5890
|
targetBounds.minX - commonBounds.minX + (pageBounds.minX - commonBounds.minX) * (scaleX - 1),
|
|
5923
5891
|
targetBounds.minY - commonBounds.minY + (pageBounds.minY - commonBounds.minY) * (scaleY - 1)
|
|
5924
5892
|
);
|
|
@@ -5927,11 +5895,7 @@ class Editor extends EventEmitter {
|
|
|
5927
5895
|
targetBounds.minY + (pageBounds.minY - commonBounds.minY) * scaleY
|
|
5928
5896
|
);
|
|
5929
5897
|
for (const shape of shapes2) {
|
|
5930
|
-
|
|
5931
|
-
shapeLocalOffset.rot(-this.getShapeParentTransform(shape).rotation());
|
|
5932
|
-
shapeLocalOffset.add(shape);
|
|
5933
|
-
const changes = this.getChangesToTranslateShape(shape, shapeLocalOffset);
|
|
5934
|
-
this.updateShape(changes);
|
|
5898
|
+
this.updateShape(this.getChangesToTranslateShapeByPageDelta(shape, pageOffset));
|
|
5935
5899
|
this.resizeShape(shape.id, scale, {
|
|
5936
5900
|
initialBounds: this.getShapeGeometry(shape).bounds,
|
|
5937
5901
|
scaleOrigin,
|
|
@@ -6350,12 +6314,17 @@ class Editor extends EventEmitter {
|
|
|
6350
6314
|
let remaining = duration;
|
|
6351
6315
|
let t;
|
|
6352
6316
|
const animations = [];
|
|
6317
|
+
const ignoreShapeLock = this._shouldIgnoreShapeLock;
|
|
6353
6318
|
let partial, result;
|
|
6354
6319
|
for (let i = 0, n = partials.length; i < n; i++) {
|
|
6355
6320
|
partial = partials[i];
|
|
6356
6321
|
if (!partial) continue;
|
|
6357
6322
|
const shape = this.getShape(partial.id);
|
|
6358
6323
|
if (!shape) continue;
|
|
6324
|
+
const unlocks = shape.isLocked && Object.hasOwn(partial, "isLocked") && !partial.isLocked;
|
|
6325
|
+
if (!ignoreShapeLock && !unlocks && this.isShapeOrAncestorLocked(shape)) {
|
|
6326
|
+
continue;
|
|
6327
|
+
}
|
|
6359
6328
|
result = {
|
|
6360
6329
|
start: structuredClone(shape),
|
|
6361
6330
|
end: applyPartialToRecordWithProps(structuredClone(shape), partial)
|
|
@@ -6371,7 +6340,7 @@ class Editor extends EventEmitter {
|
|
|
6371
6340
|
(p) => p && animatingShapes2.get(p.id) === animationId
|
|
6372
6341
|
);
|
|
6373
6342
|
if (partialsToUpdate.length) {
|
|
6374
|
-
this.updateShapes(partialsToUpdate);
|
|
6343
|
+
this.run(() => this.updateShapes(partialsToUpdate), { ignoreShapeLock });
|
|
6375
6344
|
}
|
|
6376
6345
|
this.off("tick", handleTick);
|
|
6377
6346
|
return;
|
|
@@ -6404,13 +6373,13 @@ class Editor extends EventEmitter {
|
|
|
6404
6373
|
throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");
|
|
6405
6374
|
}
|
|
6406
6375
|
if (this.getIsReadonly()) return this;
|
|
6407
|
-
const ids =
|
|
6408
|
-
if (ids.length <= 1) return this;
|
|
6376
|
+
const ids = toShapeIds(shapes);
|
|
6409
6377
|
const shapesToGroup = compact(
|
|
6410
6378
|
(this._shouldIgnoreShapeLock ? ids : this._getUnlockedShapeIds(ids)).map(
|
|
6411
6379
|
(id) => this.getShape(id)
|
|
6412
6380
|
)
|
|
6413
6381
|
);
|
|
6382
|
+
if (shapesToGroup.length <= 1) return this;
|
|
6414
6383
|
const sortedShapeIds = shapesToGroup.sort(sortByIndex).map((s) => s.id);
|
|
6415
6384
|
const childBounds = compact(shapesToGroup.map((shape) => this.getShapePageBounds(shape)));
|
|
6416
6385
|
const pageBounds = Box.Common(childBounds);
|
|
@@ -6419,8 +6388,11 @@ class Editor extends EventEmitter {
|
|
|
6419
6388
|
}
|
|
6420
6389
|
const { x, y } = pageBounds.point;
|
|
6421
6390
|
const parentId = this.findCommonAncestor(shapesToGroup) ?? this.getCurrentPageId();
|
|
6422
|
-
if (this.
|
|
6423
|
-
|
|
6391
|
+
if (!this.canCreateShapes([groupId])) {
|
|
6392
|
+
alertMaxShapes(this);
|
|
6393
|
+
return this;
|
|
6394
|
+
}
|
|
6395
|
+
if (this.isIn("select") && !this.isIn("select.idle")) {
|
|
6424
6396
|
this.cancel();
|
|
6425
6397
|
}
|
|
6426
6398
|
const shapesWithRootParent = shapesToGroup.filter((shape) => shape.parentId === parentId).sort(sortByIndex);
|
|
@@ -6448,15 +6420,14 @@ class Editor extends EventEmitter {
|
|
|
6448
6420
|
ungroupShapes(shapes, opts = {}) {
|
|
6449
6421
|
if (this.getIsReadonly()) return this;
|
|
6450
6422
|
const { select = true } = opts;
|
|
6451
|
-
const ids =
|
|
6423
|
+
const ids = toShapeIds(shapes);
|
|
6452
6424
|
const shapesToUngroup = compact(
|
|
6453
6425
|
(this._shouldIgnoreShapeLock ? ids : this._getUnlockedShapeIds(ids)).map(
|
|
6454
6426
|
(id) => this.getShape(id)
|
|
6455
6427
|
)
|
|
6456
6428
|
);
|
|
6457
6429
|
if (shapesToUngroup.length === 0) return this;
|
|
6458
|
-
if (this.
|
|
6459
|
-
if (!this.isIn("select.idle")) {
|
|
6430
|
+
if (this.isIn("select") && !this.isIn("select.idle")) {
|
|
6460
6431
|
this.cancel();
|
|
6461
6432
|
}
|
|
6462
6433
|
const idsToSelect = /* @__PURE__ */ new Set();
|
|
@@ -6470,16 +6441,16 @@ class Editor extends EventEmitter {
|
|
|
6470
6441
|
});
|
|
6471
6442
|
if (groups.length === 0) return this;
|
|
6472
6443
|
this.run(() => {
|
|
6473
|
-
let group;
|
|
6474
6444
|
for (let i = 0, n = groups.length; i < n; i++) {
|
|
6475
|
-
group = groups[i];
|
|
6445
|
+
const group = this.getShape(groups[i].id);
|
|
6446
|
+
if (!group) continue;
|
|
6476
6447
|
const childIds = this.getSortedChildIdsForParent(group.id);
|
|
6477
6448
|
for (let j = 0, n2 = childIds.length; j < n2; j++) {
|
|
6478
6449
|
idsToSelect.add(childIds[j]);
|
|
6479
6450
|
}
|
|
6480
6451
|
this.reparentShapes(childIds, group.parentId, group.index);
|
|
6481
6452
|
}
|
|
6482
|
-
this.deleteShapes(groups.map((
|
|
6453
|
+
this.deleteShapes(groups.map((group) => group.id));
|
|
6483
6454
|
if (select) {
|
|
6484
6455
|
this.select(...idsToSelect);
|
|
6485
6456
|
}
|
|
@@ -6560,14 +6531,14 @@ class Editor extends EventEmitter {
|
|
|
6560
6531
|
}
|
|
6561
6532
|
/** @internal */
|
|
6562
6533
|
_getUnlockedShapeIds(ids) {
|
|
6563
|
-
return ids.filter((id) => !this.
|
|
6534
|
+
return ids.filter((id) => !this.isShapeOrAncestorLocked(id));
|
|
6564
6535
|
}
|
|
6565
6536
|
deleteShapes(_ids) {
|
|
6566
6537
|
if (this.getIsReadonly()) return this;
|
|
6567
6538
|
if (!Array.isArray(_ids)) {
|
|
6568
6539
|
throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");
|
|
6569
6540
|
}
|
|
6570
|
-
const shapeIds =
|
|
6541
|
+
const shapeIds = toShapeIds(_ids);
|
|
6571
6542
|
const shapeIdsToDelete = this._shouldIgnoreShapeLock ? shapeIds : this._getUnlockedShapeIds(shapeIds);
|
|
6572
6543
|
if (shapeIdsToDelete.length === 0) return this;
|
|
6573
6544
|
const allShapeIdsToDelete = new Set(shapeIdsToDelete);
|
|
@@ -6912,7 +6883,7 @@ class Editor extends EventEmitter {
|
|
|
6912
6883
|
* @public
|
|
6913
6884
|
*/
|
|
6914
6885
|
getContentFromCurrentPage(shapes) {
|
|
6915
|
-
const ids =
|
|
6886
|
+
const ids = toShapeIds(shapes);
|
|
6916
6887
|
if (!ids) return;
|
|
6917
6888
|
if (ids.length === 0) return;
|
|
6918
6889
|
const shapeIds = this.getShapeAndDescendantIds(ids);
|
|
@@ -6980,21 +6951,29 @@ class Editor extends EventEmitter {
|
|
|
6980
6951
|
await Promise.allSettled(
|
|
6981
6952
|
content.assets.map(async (asset) => {
|
|
6982
6953
|
if ((asset.type === "image" || asset.type === "video") && !asset.props.src?.startsWith("data:image") && !asset.props.src?.startsWith("data:video") && !asset.props.src?.startsWith("http")) {
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6954
|
+
try {
|
|
6955
|
+
const objectUrl = await this.store.props.assets.resolve(asset, {
|
|
6956
|
+
screenScale: 1,
|
|
6957
|
+
steppedScreenScale: 1,
|
|
6958
|
+
dpr: 1,
|
|
6959
|
+
networkEffectiveType: null,
|
|
6960
|
+
shouldResolveToOriginal: true
|
|
6961
|
+
});
|
|
6962
|
+
if (objectUrl) {
|
|
6963
|
+
const response = await fetch(objectUrl);
|
|
6964
|
+
if (response.ok) {
|
|
6965
|
+
const assetWithDataUrl = structuredClone(asset);
|
|
6966
|
+
assetWithDataUrl.props.src = await FileHelpers.blobToDataUrl(await response.blob());
|
|
6967
|
+
assets.push(assetWithDataUrl);
|
|
6968
|
+
return;
|
|
6969
|
+
}
|
|
6970
|
+
console.warn(`Could not inline asset ${asset.id}: fetch returned ${response.status}`);
|
|
6971
|
+
}
|
|
6972
|
+
} catch (err) {
|
|
6973
|
+
console.warn(`Could not inline asset ${asset.id}`, err);
|
|
6974
|
+
}
|
|
6997
6975
|
}
|
|
6976
|
+
assets.push(asset);
|
|
6998
6977
|
})
|
|
6999
6978
|
);
|
|
7000
6979
|
content.assets = assets;
|
|
@@ -7288,7 +7267,7 @@ class Editor extends EventEmitter {
|
|
|
7288
7267
|
* @public
|
|
7289
7268
|
*/
|
|
7290
7269
|
async getSvgElement(shapes, opts = {}) {
|
|
7291
|
-
const ids = shapes.length === 0 ? this.getCurrentPageShapeIdsSorted() :
|
|
7270
|
+
const ids = shapes.length === 0 ? this.getCurrentPageShapeIdsSorted() : toShapeIds(shapes);
|
|
7292
7271
|
if (ids.length === 0) return void 0;
|
|
7293
7272
|
await this.fonts.loadRequiredFontsForCurrentPage(this.options.maxFontsToLoadBeforeRender);
|
|
7294
7273
|
return exportToSvg(this, ids, opts);
|
|
@@ -7884,22 +7863,22 @@ class Editor extends EventEmitter {
|
|
|
7884
7863
|
const releaseCtrl = this._ctrlKeyTimeout !== -1;
|
|
7885
7864
|
const releaseMeta = this._metaKeyTimeout !== -1;
|
|
7886
7865
|
if (releaseShift) {
|
|
7887
|
-
clearTimeout(this._shiftKeyTimeout);
|
|
7866
|
+
this.timers.clearTimeout(this._shiftKeyTimeout);
|
|
7888
7867
|
this._shiftKeyTimeout = -1;
|
|
7889
7868
|
this.inputs.setShiftKey(false);
|
|
7890
7869
|
}
|
|
7891
7870
|
if (releaseAlt) {
|
|
7892
|
-
clearTimeout(this._altKeyTimeout);
|
|
7871
|
+
this.timers.clearTimeout(this._altKeyTimeout);
|
|
7893
7872
|
this._altKeyTimeout = -1;
|
|
7894
7873
|
this.inputs.setAltKey(false);
|
|
7895
7874
|
}
|
|
7896
7875
|
if (releaseCtrl) {
|
|
7897
|
-
clearTimeout(this._ctrlKeyTimeout);
|
|
7876
|
+
this.timers.clearTimeout(this._ctrlKeyTimeout);
|
|
7898
7877
|
this._ctrlKeyTimeout = -1;
|
|
7899
7878
|
this.inputs.setCtrlKey(false);
|
|
7900
7879
|
}
|
|
7901
7880
|
if (releaseMeta) {
|
|
7902
|
-
clearTimeout(this._metaKeyTimeout);
|
|
7881
|
+
this.timers.clearTimeout(this._metaKeyTimeout);
|
|
7903
7882
|
this._metaKeyTimeout = -1;
|
|
7904
7883
|
this.inputs.setMetaKey(false);
|
|
7905
7884
|
}
|
|
@@ -8013,28 +7992,28 @@ class Editor extends EventEmitter {
|
|
|
8013
7992
|
return;
|
|
8014
7993
|
}
|
|
8015
7994
|
if (info.shiftKey) {
|
|
8016
|
-
clearTimeout(this._shiftKeyTimeout);
|
|
7995
|
+
this.timers.clearTimeout(this._shiftKeyTimeout);
|
|
8017
7996
|
this._shiftKeyTimeout = -1;
|
|
8018
7997
|
inputs.setShiftKey(true);
|
|
8019
7998
|
} else if (!info.shiftKey && inputs.getShiftKey() && this._shiftKeyTimeout === -1) {
|
|
8020
7999
|
this._shiftKeyTimeout = this.timers.setTimeout(this._releaseShiftKey, 150);
|
|
8021
8000
|
}
|
|
8022
8001
|
if (info.altKey) {
|
|
8023
|
-
clearTimeout(this._altKeyTimeout);
|
|
8002
|
+
this.timers.clearTimeout(this._altKeyTimeout);
|
|
8024
8003
|
this._altKeyTimeout = -1;
|
|
8025
8004
|
inputs.setAltKey(true);
|
|
8026
8005
|
} else if (!info.altKey && inputs.getAltKey() && this._altKeyTimeout === -1) {
|
|
8027
8006
|
this._altKeyTimeout = this.timers.setTimeout(this._releaseAltKey, 150);
|
|
8028
8007
|
}
|
|
8029
8008
|
if (info.ctrlKey) {
|
|
8030
|
-
clearTimeout(this._ctrlKeyTimeout);
|
|
8009
|
+
this.timers.clearTimeout(this._ctrlKeyTimeout);
|
|
8031
8010
|
this._ctrlKeyTimeout = -1;
|
|
8032
8011
|
inputs.setCtrlKey(true);
|
|
8033
8012
|
} else if (!info.ctrlKey && inputs.getCtrlKey() && this._ctrlKeyTimeout === -1) {
|
|
8034
8013
|
this._ctrlKeyTimeout = this.timers.setTimeout(this._releaseCtrlKey, 150);
|
|
8035
8014
|
}
|
|
8036
8015
|
if (info.metaKey && info.name !== "key_up") {
|
|
8037
|
-
clearTimeout(this._metaKeyTimeout);
|
|
8016
|
+
this.timers.clearTimeout(this._metaKeyTimeout);
|
|
8038
8017
|
this._metaKeyTimeout = -1;
|
|
8039
8018
|
inputs.setMetaKey(true);
|
|
8040
8019
|
} else if (!info.metaKey && inputs.getMetaKey() && this._metaKeyTimeout === -1) {
|
|
@@ -8048,8 +8027,7 @@ class Editor extends EventEmitter {
|
|
|
8048
8027
|
const cameraOptions = this._cameraOptions.__unsafe__getWithoutCapture();
|
|
8049
8028
|
switch (type) {
|
|
8050
8029
|
case "pinch": {
|
|
8051
|
-
|
|
8052
|
-
clearTimeout(this._longPressTimeout);
|
|
8030
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8053
8031
|
this.inputs.updateFromEvent(info);
|
|
8054
8032
|
switch (info.name) {
|
|
8055
8033
|
case "pinch_start": {
|
|
@@ -8070,6 +8048,7 @@ class Editor extends EventEmitter {
|
|
|
8070
8048
|
}
|
|
8071
8049
|
case "pinch": {
|
|
8072
8050
|
if (!inputs.getIsPinching()) return;
|
|
8051
|
+
if (cameraOptions.isLocked) return;
|
|
8073
8052
|
const {
|
|
8074
8053
|
point: { z = 1 },
|
|
8075
8054
|
delta: { x: dx, y: dy }
|
|
@@ -8125,7 +8104,7 @@ class Editor extends EventEmitter {
|
|
|
8125
8104
|
const { panSpeed, zoomSpeed } = cameraOptions;
|
|
8126
8105
|
let wheelBehavior = cameraOptions.wheelBehavior;
|
|
8127
8106
|
const inputMode = this.user.getUserPreferences().inputMode;
|
|
8128
|
-
if (inputMode !== null) {
|
|
8107
|
+
if (inputMode !== null && wheelBehavior !== "none") {
|
|
8129
8108
|
wheelBehavior = inputMode === "trackpad" ? "pan" : "zoom";
|
|
8130
8109
|
}
|
|
8131
8110
|
if (wheelBehavior !== "none") {
|
|
@@ -8177,12 +8156,12 @@ class Editor extends EventEmitter {
|
|
|
8177
8156
|
}
|
|
8178
8157
|
case "pointer": {
|
|
8179
8158
|
if (inputs.getIsPinching()) return;
|
|
8180
|
-
this.inputs.updateFromEvent(info);
|
|
8181
8159
|
const { isPen } = info;
|
|
8182
8160
|
const { isPenMode } = instanceState;
|
|
8161
|
+
if (isPenMode && !isPen) return;
|
|
8162
|
+
this.inputs.updateFromEvent(info);
|
|
8183
8163
|
switch (info.name) {
|
|
8184
8164
|
case "pointer_down": {
|
|
8185
|
-
if (isPenMode && !isPen) return;
|
|
8186
8165
|
this._releaseDebouncedModifiers();
|
|
8187
8166
|
if (!this.inputs.getIsPanning()) {
|
|
8188
8167
|
this._longPressTimeout = this.timers.setTimeout(() => {
|
|
@@ -8206,11 +8185,12 @@ class Editor extends EventEmitter {
|
|
|
8206
8185
|
inputs.buttons.add(info.button);
|
|
8207
8186
|
inputs.setIsPointing(true);
|
|
8208
8187
|
inputs.setIsDragging(false);
|
|
8188
|
+
this.stopCameraAnimation();
|
|
8209
8189
|
if (!isPenMode && info.isPenDirect) {
|
|
8210
8190
|
this.updateInstanceState({ isPenMode: true });
|
|
8211
8191
|
this.interrupt();
|
|
8212
8192
|
}
|
|
8213
|
-
if (info.button === STYLUS_ERASER_BUTTON) {
|
|
8193
|
+
if (info.button === STYLUS_ERASER_BUTTON && this.getStateDescendant("eraser")) {
|
|
8214
8194
|
this._restoreToolId = this.getCurrentToolId();
|
|
8215
8195
|
this.complete();
|
|
8216
8196
|
this.setCurrentTool("eraser");
|
|
@@ -8219,10 +8199,10 @@ class Editor extends EventEmitter {
|
|
|
8219
8199
|
this._prevCursor = this.getInstanceState().cursor.type;
|
|
8220
8200
|
}
|
|
8221
8201
|
this.inputs.setIsPanning(true);
|
|
8222
|
-
clearTimeout(this._longPressTimeout);
|
|
8202
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8223
8203
|
} else if (info.button === RIGHT_MOUSE_BUTTON && this.options.rightClickPanning) {
|
|
8224
8204
|
this.inputs.setIsRightPointing(true);
|
|
8225
|
-
clearTimeout(this._longPressTimeout);
|
|
8205
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8226
8206
|
return this;
|
|
8227
8207
|
}
|
|
8228
8208
|
if (this.inputs.getIsPanning()) {
|
|
@@ -8233,7 +8213,6 @@ class Editor extends EventEmitter {
|
|
|
8233
8213
|
break;
|
|
8234
8214
|
}
|
|
8235
8215
|
case "pointer_move": {
|
|
8236
|
-
if (!isPen && isPenMode) return;
|
|
8237
8216
|
const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera());
|
|
8238
8217
|
if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
|
|
8239
8218
|
const currentScreenPoint = this.inputs.getCurrentScreenPoint();
|
|
@@ -8264,16 +8243,15 @@ class Editor extends EventEmitter {
|
|
|
8264
8243
|
}
|
|
8265
8244
|
if (inputs.getIsPointing() && !inputs.getIsDragging() && Vec.Dist2(inputs.getOriginPagePoint(), inputs.getCurrentPagePoint()) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
|
|
8266
8245
|
inputs.setIsDragging(true);
|
|
8267
|
-
clearTimeout(this._longPressTimeout);
|
|
8246
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8268
8247
|
}
|
|
8269
8248
|
break;
|
|
8270
8249
|
}
|
|
8271
8250
|
case "pointer_up": {
|
|
8272
8251
|
inputs.setIsDragging(false);
|
|
8273
8252
|
inputs.setIsPointing(false);
|
|
8274
|
-
clearTimeout(this._longPressTimeout);
|
|
8253
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8275
8254
|
inputs.buttons.delete(info.button);
|
|
8276
|
-
if (instanceState.isPenMode && !isPen) return;
|
|
8277
8255
|
if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
|
|
8278
8256
|
this.inputs.setIsRightPointing(false);
|
|
8279
8257
|
this._selectedShapeIdsAtPointerDown = [];
|
|
@@ -8329,7 +8307,7 @@ class Editor extends EventEmitter {
|
|
|
8329
8307
|
});
|
|
8330
8308
|
}
|
|
8331
8309
|
} else {
|
|
8332
|
-
if (info.button === STYLUS_ERASER_BUTTON) {
|
|
8310
|
+
if (info.button === STYLUS_ERASER_BUTTON && this.getStateDescendant("eraser")) {
|
|
8333
8311
|
this.complete();
|
|
8334
8312
|
this.setCurrentTool(this._restoreToolId);
|
|
8335
8313
|
}
|
|
@@ -8356,7 +8334,7 @@ class Editor extends EventEmitter {
|
|
|
8356
8334
|
}
|
|
8357
8335
|
this.inputs.setIsPanning(true);
|
|
8358
8336
|
this.inputs.setIsSpacebarPanning(true);
|
|
8359
|
-
clearTimeout(this._longPressTimeout);
|
|
8337
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8360
8338
|
this.setCursor({
|
|
8361
8339
|
type: this.inputs.getIsPointing() ? "grabbing" : "grab",
|
|
8362
8340
|
rotation: 0
|
|
@@ -8382,7 +8360,7 @@ class Editor extends EventEmitter {
|
|
|
8382
8360
|
break;
|
|
8383
8361
|
}
|
|
8384
8362
|
}
|
|
8385
|
-
if (offset) {
|
|
8363
|
+
if (offset && !cameraOptions.isLocked) {
|
|
8386
8364
|
const bounds = this.getViewportPageBounds();
|
|
8387
8365
|
const next = bounds.clone().translate(offset.mulV({ x: bounds.w, y: bounds.h }));
|
|
8388
8366
|
this._animateToViewport(next, { animation: { duration: 320 } });
|
|
@@ -8422,7 +8400,7 @@ class Editor extends EventEmitter {
|
|
|
8422
8400
|
this.setCurrentTool("select");
|
|
8423
8401
|
}
|
|
8424
8402
|
const { isPenMode } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID);
|
|
8425
|
-
if (info.isPen
|
|
8403
|
+
if (!isPenMode || info.isPen) {
|
|
8426
8404
|
const clickInfo = this._clickManager.handlePointerEvent(info);
|
|
8427
8405
|
if (info.name !== clickInfo.name) {
|
|
8428
8406
|
this.root.handleEvent(info);
|
|
@@ -8444,7 +8422,7 @@ class Editor extends EventEmitter {
|
|
|
8444
8422
|
maybeTrackPerformance(name) {
|
|
8445
8423
|
if (debugFlags.measurePerformance.get()) {
|
|
8446
8424
|
if (this.performanceTracker.isStarted()) {
|
|
8447
|
-
clearTimeout(this.performanceTrackerTimeout);
|
|
8425
|
+
this.timers.clearTimeout(this.performanceTrackerTimeout);
|
|
8448
8426
|
} else {
|
|
8449
8427
|
this.performanceTracker.start(name);
|
|
8450
8428
|
}
|
|
@@ -8713,6 +8691,9 @@ function pushShapeWithDescendants(editor, id, result) {
|
|
|
8713
8691
|
pushShapeWithDescendants(editor, childIds[i], result);
|
|
8714
8692
|
}
|
|
8715
8693
|
}
|
|
8694
|
+
function toShapeIds(shapes) {
|
|
8695
|
+
return typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id);
|
|
8696
|
+
}
|
|
8716
8697
|
function withIsolatedShapes(editor, shapeIds, callback) {
|
|
8717
8698
|
let result;
|
|
8718
8699
|
editor.run(
|
|
@@ -8735,7 +8716,7 @@ function withIsolatedShapes(editor, shapeIds, callback) {
|
|
|
8735
8716
|
}
|
|
8736
8717
|
}
|
|
8737
8718
|
}
|
|
8738
|
-
editor.
|
|
8719
|
+
editor._deleteBindings([...bindingsToRemove], { isolateShapes: true });
|
|
8739
8720
|
try {
|
|
8740
8721
|
result = Result.ok(callback(bindingsWithBoth));
|
|
8741
8722
|
} catch (error) {
|