@mocanvas/editor 4.7.1 → 4.8.1
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 +11 -0
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -8466,6 +8466,17 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
8466
8466
|
* `getOverlayShapeIds()`; `undefined` where the shape is unclipped.
|
|
8467
8467
|
*/
|
|
8468
8468
|
getOverlayClips(): readonly (ClipRect | undefined)[];
|
|
8469
|
+
/**
|
|
8470
|
+
* Run `fn` as one operation: one history entry, and one notification to the
|
|
8471
|
+
* store's listeners however many writes it makes.
|
|
8472
|
+
*
|
|
8473
|
+
* It has to open an operation on the *store*, not just a signal transaction.
|
|
8474
|
+
* A `transact` alone batches recomputation and nothing else, so every write
|
|
8475
|
+
* inside still opened and closed an operation of its own — two
|
|
8476
|
+
* `updateShapes` calls in one `run` reached a listener as two notifications,
|
|
8477
|
+
* the first of them carrying a half-applied state that was never an intended
|
|
8478
|
+
* state of the document. A sync binding published that state to its peers.
|
|
8479
|
+
*/
|
|
8469
8480
|
run<T>(fn: () => T, opts?: {
|
|
8470
8481
|
history?: "record" | "ignore" | "record-preserveRedoStack";
|
|
8471
8482
|
}): T;
|
package/dist/index.js
CHANGED
|
@@ -8201,8 +8201,19 @@ var Editor = class extends EventEmitter {
|
|
|
8201
8201
|
return this._overlayClips.get();
|
|
8202
8202
|
}
|
|
8203
8203
|
// ---- batching / history ------------------------------------------------
|
|
8204
|
+
/**
|
|
8205
|
+
* Run `fn` as one operation: one history entry, and one notification to the
|
|
8206
|
+
* store's listeners however many writes it makes.
|
|
8207
|
+
*
|
|
8208
|
+
* It has to open an operation on the *store*, not just a signal transaction.
|
|
8209
|
+
* A `transact` alone batches recomputation and nothing else, so every write
|
|
8210
|
+
* inside still opened and closed an operation of its own — two
|
|
8211
|
+
* `updateShapes` calls in one `run` reached a listener as two notifications,
|
|
8212
|
+
* the first of them carrying a half-applied state that was never an intended
|
|
8213
|
+
* state of the document. A sync binding published that state to its peers.
|
|
8214
|
+
*/
|
|
8204
8215
|
run(fn, opts = {}) {
|
|
8205
|
-
return
|
|
8216
|
+
return this.store.atomic(() => {
|
|
8206
8217
|
if (opts.history === "ignore") return this.history.ignore(fn);
|
|
8207
8218
|
return fn();
|
|
8208
8219
|
});
|
|
@@ -8870,6 +8881,7 @@ var Editor = class extends EventEmitter {
|
|
|
8870
8881
|
if (shape && !shape.isLocked) collect(id);
|
|
8871
8882
|
}
|
|
8872
8883
|
if (toDelete.size === 0) return this;
|
|
8884
|
+
this.emit("deleted-shapes", [...toDelete]);
|
|
8873
8885
|
this.run(() => {
|
|
8874
8886
|
const ps = this.getCurrentPageState();
|
|
8875
8887
|
const selected = ps.selectedShapeIds.filter((id) => !toDelete.has(id));
|
|
@@ -8878,7 +8890,6 @@ var Editor = class extends EventEmitter {
|
|
|
8878
8890
|
if (ps.editingShapeId && toDelete.has(ps.editingShapeId)) this.setEditingShape(null);
|
|
8879
8891
|
this.store.remove([...toDelete]);
|
|
8880
8892
|
});
|
|
8881
|
-
this.emit("deleted-shapes", [...toDelete]);
|
|
8882
8893
|
return this;
|
|
8883
8894
|
}
|
|
8884
8895
|
/**
|