@mocanvas/editor 4.4.0 → 4.4.2
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/index.d.ts +10 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -8739,7 +8739,16 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
8739
8739
|
getSharedStyles(): SharedStyleMap;
|
|
8740
8740
|
/** Move shapes by a page-space offset. */
|
|
8741
8741
|
nudgeShapes(ids: readonly ShapeId[], offset: VecLike): this;
|
|
8742
|
-
/**
|
|
8742
|
+
/**
|
|
8743
|
+
* Rotate shapes by `delta` radians around the center of their common page
|
|
8744
|
+
* bounds.
|
|
8745
|
+
*
|
|
8746
|
+
* The resulting rotation is canonicalized into `[0, 2π)`. Without that, an
|
|
8747
|
+
* angle that only ever accumulates leaves two documents that look identical
|
|
8748
|
+
* carrying different numbers — and `rotation` is persisted and sent over the
|
|
8749
|
+
* wire, so a diff, a parity check and a sync merge all see a difference that
|
|
8750
|
+
* is not on screen.
|
|
8751
|
+
*/
|
|
8743
8752
|
rotateShapesBy(ids: readonly ShapeId[], delta: number, center?: VecLike): this;
|
|
8744
8753
|
/** Mirror shapes across the center of their common bounds. Positions flip; geometry is not mirrored. */
|
|
8745
8754
|
flipShapes(ids: readonly ShapeId[], operation: "horizontal" | "vertical"): this;
|
package/dist/index.js
CHANGED
|
@@ -9234,7 +9234,16 @@ var Editor = class extends EventEmitter {
|
|
|
9234
9234
|
}
|
|
9235
9235
|
return this.updateShapes(updates);
|
|
9236
9236
|
}
|
|
9237
|
-
/**
|
|
9237
|
+
/**
|
|
9238
|
+
* Rotate shapes by `delta` radians around the center of their common page
|
|
9239
|
+
* bounds.
|
|
9240
|
+
*
|
|
9241
|
+
* The resulting rotation is canonicalized into `[0, 2π)`. Without that, an
|
|
9242
|
+
* angle that only ever accumulates leaves two documents that look identical
|
|
9243
|
+
* carrying different numbers — and `rotation` is persisted and sent over the
|
|
9244
|
+
* wire, so a diff, a parity check and a sync merge all see a difference that
|
|
9245
|
+
* is not on screen.
|
|
9246
|
+
*/
|
|
9238
9247
|
rotateShapesBy(ids, delta, center) {
|
|
9239
9248
|
const shapes = ids.map((id) => this.getShape(id)).filter((s) => !!s && !s.isLocked);
|
|
9240
9249
|
if (shapes.length === 0) return this;
|
|
@@ -9245,7 +9254,7 @@ var Editor = class extends EventEmitter {
|
|
|
9245
9254
|
const m = this.getShapePageTransform(shape);
|
|
9246
9255
|
const newPagePos = Vec.RotWith(new Vec(m.e, m.f), c, delta);
|
|
9247
9256
|
const parentPoint = this.getPointInParentSpace(shape, newPagePos);
|
|
9248
|
-
updates.push({ id: shape.id, type: shape.type, x: parentPoint.x, y: parentPoint.y, rotation: shape.rotation + delta });
|
|
9257
|
+
updates.push({ id: shape.id, type: shape.type, x: parentPoint.x, y: parentPoint.y, rotation: canonicalizeRotation(shape.rotation + delta) });
|
|
9249
9258
|
}
|
|
9250
9259
|
return this.updateShapes(updates);
|
|
9251
9260
|
}
|