@tldraw/editor 5.5.0-canary.9fdbdab733d6 → 5.5.0-canary.a0cd8f2a2e07
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 -11
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +15 -4
- package/dist-cjs/lib/editor/Editor.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 +46 -60
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/shared/resizeBox.js +21 -16
- package/dist-cjs/lib/editor/shapes/shared/resizeBox.js.map +2 -2
- package/dist-cjs/lib/hooks/useCursor.js +12 -8
- package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js +10 -1
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +12 -5
- 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 +14 -11
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +17 -5
- package/dist-esm/lib/editor/Editor.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 +46 -60
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/shared/resizeBox.mjs +21 -16
- package/dist-esm/lib/editor/shapes/shared/resizeBox.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCursor.mjs +12 -8
- package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs +10 -1
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +13 -6
- 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/package.json +16 -18
- package/src/lib/editor/Editor.ts +38 -9
- 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 +79 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +51 -78
- package/src/lib/editor/shapes/shared/resizeBox.ts +21 -16
- package/src/lib/hooks/useCursor.ts +14 -7
- package/src/lib/test/useCursor.test.tsx +36 -0
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +26 -1
- package/src/lib/utils/sync/LocalIndexedDb.ts +10 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +73 -0
- package/src/lib/utils/sync/TLLocalSyncClient.ts +24 -8
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -4579,6 +4579,8 @@ export declare const EditorContext: React_3.Context<Editor | null>;
|
|
|
4579
4579
|
* - Reaction (`react(...)` from `@tldraw/state`): `this.register(react(...))`
|
|
4580
4580
|
* - DOM listener: `this.register(() => el.removeEventListener(...))`
|
|
4581
4581
|
* - Other resource (cache, index, child manager): `this.register(() => x.dispose())`
|
|
4582
|
+
* - Resource held only part of the time (a listener attached while subscribers exist):
|
|
4583
|
+
* `this.register(...)` on attach and `this.unregister(...)` on detach, see `PerformanceManager`
|
|
4582
4584
|
*
|
|
4583
4585
|
* For timeouts, intervals, and animation frames prefer `editor.timers` (context-grouped
|
|
4584
4586
|
* and auto-disposed) over raw `setTimeout`. For cleanup on the editor itself rather than a
|
|
@@ -4598,11 +4600,18 @@ export declare abstract class EditorManager {
|
|
|
4598
4600
|
* make a resource "see itself out". Returns the same function for convenience.
|
|
4599
4601
|
*/
|
|
4600
4602
|
protected register(dispose: () => void): () => void;
|
|
4603
|
+
/**
|
|
4604
|
+
* Run a registered teardown now instead of at `dispose()`. A teardown that is no longer
|
|
4605
|
+
* registered (already run by `dispose()`, or never registered) is skipped, so nothing is
|
|
4606
|
+
* torn down twice.
|
|
4607
|
+
*/
|
|
4608
|
+
protected unregister(dispose: () => void): void;
|
|
4601
4609
|
/**
|
|
4602
4610
|
* Subscribe to an editor bus event and register the matching unsubscribe, so the listener
|
|
4603
|
-
* is removed automatically on `dispose()`.
|
|
4611
|
+
* is removed automatically on `dispose()`. Returns that unsubscribe, for passing to
|
|
4612
|
+
* {@link EditorManager.unregister} to detach it before `dispose()`.
|
|
4604
4613
|
*/
|
|
4605
|
-
protected addEditorEvent<E extends keyof TLEventMap>(event: E, fn: (...args: TLEventMap[E]) => void): void;
|
|
4614
|
+
protected addEditorEvent<E extends keyof TLEventMap>(event: E, fn: (...args: TLEventMap[E]) => void): () => void;
|
|
4606
4615
|
/* Excluded from this release type: dispose */
|
|
4607
4616
|
}
|
|
4608
4617
|
|
|
@@ -5990,17 +5999,11 @@ export declare class PerformanceApiAdapter {
|
|
|
5990
5999
|
*
|
|
5991
6000
|
* @public
|
|
5992
6001
|
*/
|
|
5993
|
-
export declare class PerformanceManager {
|
|
6002
|
+
export declare class PerformanceManager extends EditorManager {
|
|
5994
6003
|
/* Excluded from this release type: emitter */
|
|
5995
|
-
private editor;
|
|
5996
6004
|
private activeInteraction;
|
|
5997
6005
|
private activeCamera;
|
|
5998
|
-
private
|
|
5999
|
-
private shapeCreatedCleanup;
|
|
6000
|
-
private shapeEditedCleanup;
|
|
6001
|
-
private shapeDeletedCleanup;
|
|
6002
|
-
private loafObserver;
|
|
6003
|
-
constructor(editor: Editor);
|
|
6006
|
+
private readonly lazyCleanups;
|
|
6004
6007
|
/**
|
|
6005
6008
|
* Subscribe to a performance event. Returns an unsubscribe function.
|
|
6006
6009
|
*
|
|
@@ -6034,11 +6037,11 @@ export declare class PerformanceManager {
|
|
|
6034
6037
|
private _onShapesEdited;
|
|
6035
6038
|
private _onShapesDeleted;
|
|
6036
6039
|
private _startLoafObserver;
|
|
6037
|
-
private _stopLoafObserver;
|
|
6038
6040
|
private _needsFrameListener;
|
|
6039
6041
|
private _needsLoafObserver;
|
|
6040
6042
|
private _maybeAttachLazyListeners;
|
|
6041
6043
|
private _maybeDetachLazyListeners;
|
|
6044
|
+
private _detachLazy;
|
|
6042
6045
|
}
|
|
6043
6046
|
|
|
6044
6047
|
/**
|
package/dist-cjs/index.js
CHANGED
|
@@ -392,7 +392,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
392
392
|
var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
|
|
393
393
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
394
394
|
"@tldraw/editor",
|
|
395
|
-
"5.5.0-canary.
|
|
395
|
+
"5.5.0-canary.a0cd8f2a2e07",
|
|
396
396
|
"cjs"
|
|
397
397
|
);
|
|
398
398
|
//# sourceMappingURL=index.js.map
|
|
@@ -3657,7 +3657,9 @@ class Editor extends import_eventemitter3.default {
|
|
|
3657
3657
|
const id = typeof page === "string" ? page : page.id;
|
|
3658
3658
|
const freshPage = this.getPage(id);
|
|
3659
3659
|
if (!freshPage) return this;
|
|
3660
|
-
const prevCamera = {
|
|
3660
|
+
const prevCamera = {
|
|
3661
|
+
...this.store.get(import_tlschema.CameraRecordType.createId(freshPage.id)) ?? this.getCamera()
|
|
3662
|
+
};
|
|
3661
3663
|
const content = this.getContentFromCurrentPage(this.getSortedChildIdsForParent(freshPage.id));
|
|
3662
3664
|
this.run(() => {
|
|
3663
3665
|
const pages = this.getPages();
|
|
@@ -3666,7 +3668,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
3666
3668
|
this.setCurrentPage(createId);
|
|
3667
3669
|
this.setCamera(prevCamera);
|
|
3668
3670
|
if (content) {
|
|
3669
|
-
return this.putContentOntoCurrentPage(content);
|
|
3671
|
+
return this.putContentOntoCurrentPage(content, { preservePosition: true });
|
|
3670
3672
|
}
|
|
3671
3673
|
});
|
|
3672
3674
|
return this;
|
|
@@ -6030,11 +6032,20 @@ class Editor extends import_eventemitter3.default {
|
|
|
6030
6032
|
initialShape: options.initialShape,
|
|
6031
6033
|
initialBounds: options.initialBounds,
|
|
6032
6034
|
isAspectRatioLocked: options.isAspectRatioLocked,
|
|
6033
|
-
initialPageTransform: options.initialPageTransform
|
|
6035
|
+
initialPageTransform: options.initialPageTransform,
|
|
6036
|
+
dragHandle: options.dragHandle,
|
|
6037
|
+
mode: options.mode,
|
|
6038
|
+
// this is one frame of the same resize, not a new one, so don't fire start/end again
|
|
6039
|
+
skipStartAndEndCallbacks: options.skipStartAndEndCallbacks
|
|
6034
6040
|
});
|
|
6035
6041
|
if (Math.sign(scale.x) * Math.sign(scale.y) < 0) {
|
|
6036
6042
|
const parentRotation = this.getShapeParentTransform(id).rotation();
|
|
6037
|
-
const
|
|
6043
|
+
const parentDelta = (0, import_utils2.shortAngleDist)(
|
|
6044
|
+
import_Mat.Mat.Cast(options.initialPageTransform).rotation() - options.initialShape.rotation,
|
|
6045
|
+
parentRotation
|
|
6046
|
+
);
|
|
6047
|
+
const initialParentRotation = parentRotation - parentDelta;
|
|
6048
|
+
const rotation = 2 * options.scaleAxisRotation - options.initialShape.rotation - 2 * initialParentRotation - parentDelta;
|
|
6038
6049
|
this.updateShapes([{ id, type, rotation }]);
|
|
6039
6050
|
}
|
|
6040
6051
|
const preScaleShapePageCenter = import_Mat.Mat.applyToPoint(
|