@tldraw/editor 3.15.0-canary.8789e24bb6fc → 3.15.0-canary.88957190ec4c
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 +109 -2
- package/dist-cjs/index.js +3 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +4 -26
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js +53 -0
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js.map +7 -0
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js +27 -15
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +3 -3
- package/dist-cjs/lib/editor/Editor.js +64 -35
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +20 -1
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- package/dist-cjs/lib/hooks/useEditorComponents.js +2 -0
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +2 -2
- package/dist-cjs/lib/license/Watermark.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 +109 -2
- package/dist-esm/index.mjs +5 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +4 -26
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs +23 -0
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs.map +7 -0
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +17 -15
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +64 -35
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +20 -1
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +4 -0
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +2 -2
- package/dist-esm/lib/license/Watermark.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +19 -25
- package/package.json +7 -7
- package/src/index.ts +5 -0
- package/src/lib/components/Shape.tsx +6 -21
- package/src/lib/components/default-components/DefaultShapeWrapper.tsx +35 -0
- package/src/lib/components/default-components/DefaultSpinner.tsx +12 -12
- package/src/lib/editor/Editor.ts +71 -35
- package/src/lib/editor/shapes/ShapeUtil.ts +57 -0
- package/src/lib/editor/tools/StateNode.test.ts +285 -0
- package/src/lib/editor/tools/StateNode.ts +27 -1
- package/src/lib/editor/types/misc-types.ts +19 -0
- package/src/lib/hooks/useEditorComponents.tsx +8 -2
- package/src/lib/license/Watermark.tsx +2 -2
- package/src/version.ts +3 -3
- package/src/lib/test/currentToolIdMask.test.ts +0 -49
|
@@ -2323,28 +2323,11 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2323
2323
|
{ history: "ignore" }
|
|
2324
2324
|
);
|
|
2325
2325
|
const { currentScreenPoint, currentPagePoint } = this.inputs;
|
|
2326
|
-
const { screenBounds } = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
|
|
2327
2326
|
if (currentScreenPoint.x / z - x !== currentPagePoint.x || currentScreenPoint.y / z - y !== currentPagePoint.y) {
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
// weird but true: we need to put the screen point back into client space
|
|
2333
|
-
point: import_Vec.Vec.AddXY(currentScreenPoint, screenBounds.x, screenBounds.y),
|
|
2334
|
-
pointerId: import_constants.INTERNAL_POINTER_IDS.CAMERA_MOVE,
|
|
2335
|
-
ctrlKey: this.inputs.ctrlKey,
|
|
2336
|
-
altKey: this.inputs.altKey,
|
|
2337
|
-
shiftKey: this.inputs.shiftKey,
|
|
2338
|
-
metaKey: this.inputs.metaKey,
|
|
2339
|
-
accelKey: (0, import_keyboard.isAccelKey)(this.inputs),
|
|
2340
|
-
button: 0,
|
|
2341
|
-
isPen: this.getInstanceState().isPenMode ?? false
|
|
2342
|
-
};
|
|
2343
|
-
if (opts?.immediate) {
|
|
2344
|
-
this._flushEventForTick(event);
|
|
2345
|
-
} else {
|
|
2346
|
-
this.dispatch(event);
|
|
2347
|
-
}
|
|
2327
|
+
this.updatePointer({
|
|
2328
|
+
immediate: opts?.immediate,
|
|
2329
|
+
pointerId: import_constants.INTERNAL_POINTER_IDS.CAMERA_MOVE
|
|
2330
|
+
});
|
|
2348
2331
|
}
|
|
2349
2332
|
this._tickCameraState();
|
|
2350
2333
|
});
|
|
@@ -3313,19 +3296,24 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3313
3296
|
*/
|
|
3314
3297
|
deletePage(page) {
|
|
3315
3298
|
const id = typeof page === "string" ? page : page.id;
|
|
3316
|
-
this.run(
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3299
|
+
this.run(
|
|
3300
|
+
() => {
|
|
3301
|
+
if (this.getIsReadonly()) return;
|
|
3302
|
+
const pages = this.getPages();
|
|
3303
|
+
if (pages.length === 1) return;
|
|
3304
|
+
const deletedPage = this.getPage(id);
|
|
3305
|
+
if (!deletedPage) return;
|
|
3306
|
+
if (id === this.getCurrentPageId()) {
|
|
3307
|
+
const index = pages.findIndex((page2) => page2.id === id);
|
|
3308
|
+
const next = pages[index - 1] ?? pages[index + 1];
|
|
3309
|
+
this.setCurrentPage(next.id);
|
|
3310
|
+
}
|
|
3311
|
+
const shapes = this.getSortedChildIdsForParent(deletedPage.id);
|
|
3312
|
+
this.deleteShapes(shapes);
|
|
3313
|
+
this.store.remove([deletedPage.id]);
|
|
3314
|
+
},
|
|
3315
|
+
{ ignoreShapeLock: true }
|
|
3316
|
+
);
|
|
3329
3317
|
return this;
|
|
3330
3318
|
}
|
|
3331
3319
|
/**
|
|
@@ -3939,7 +3927,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3939
3927
|
const geometry = this.getShapeGeometry(shape);
|
|
3940
3928
|
const isGroup = geometry instanceof import_Group2d.Group2d;
|
|
3941
3929
|
const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
|
|
3942
|
-
if (this.isShapeOfType(shape, "frame") || this.isShapeOfType(shape, "
|
|
3930
|
+
if (this.isShapeOfType(shape, "frame") || (this.isShapeOfType(shape, "note") || this.isShapeOfType(shape, "arrow") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") && this.getShapeUtil(shape).getText(shape)?.trim()) {
|
|
3943
3931
|
for (const childGeometry of geometry.children) {
|
|
3944
3932
|
if (childGeometry.isLabel && childGeometry.isPointInBounds(pointInShapeSpace)) {
|
|
3945
3933
|
return shape;
|
|
@@ -7028,6 +7016,47 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7028
7016
|
this.dispatch({ type: "misc", name: "complete" });
|
|
7029
7017
|
return this;
|
|
7030
7018
|
}
|
|
7019
|
+
/**
|
|
7020
|
+
* Dispatch a pointer move event in the current position of the pointer. This is useful when
|
|
7021
|
+
* external circumstances have changed (e.g. the camera moved or a shape was moved) and you want
|
|
7022
|
+
* the current interaction to respond to that change.
|
|
7023
|
+
*
|
|
7024
|
+
* @example
|
|
7025
|
+
* ```ts
|
|
7026
|
+
* editor.updatePointer()
|
|
7027
|
+
* ```
|
|
7028
|
+
*
|
|
7029
|
+
* @param options - The options for updating the pointer.
|
|
7030
|
+
* @returns The editor instance.
|
|
7031
|
+
* @public
|
|
7032
|
+
*/
|
|
7033
|
+
updatePointer(options) {
|
|
7034
|
+
const event = {
|
|
7035
|
+
type: "pointer",
|
|
7036
|
+
target: "canvas",
|
|
7037
|
+
name: "pointer_move",
|
|
7038
|
+
point: options?.point ?? // weird but true: what `inputs` calls screen-space is actually viewport space. so
|
|
7039
|
+
// we need to convert back into true screen space first. we should fix this...
|
|
7040
|
+
import_Vec.Vec.Add(
|
|
7041
|
+
this.inputs.currentScreenPoint,
|
|
7042
|
+
this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID).screenBounds
|
|
7043
|
+
),
|
|
7044
|
+
pointerId: options?.pointerId ?? 0,
|
|
7045
|
+
button: options?.button ?? 0,
|
|
7046
|
+
isPen: options?.isPen ?? this.inputs.isPen,
|
|
7047
|
+
shiftKey: options?.shiftKey ?? this.inputs.shiftKey,
|
|
7048
|
+
altKey: options?.altKey ?? this.inputs.altKey,
|
|
7049
|
+
ctrlKey: options?.ctrlKey ?? this.inputs.ctrlKey,
|
|
7050
|
+
metaKey: options?.metaKey ?? this.inputs.metaKey,
|
|
7051
|
+
accelKey: options?.accelKey ?? (0, import_keyboard.isAccelKey)(this.inputs)
|
|
7052
|
+
};
|
|
7053
|
+
if (options?.immediate) {
|
|
7054
|
+
this._flushEventForTick(event);
|
|
7055
|
+
} else {
|
|
7056
|
+
this.dispatch(event);
|
|
7057
|
+
}
|
|
7058
|
+
return this;
|
|
7059
|
+
}
|
|
7031
7060
|
/**
|
|
7032
7061
|
* Puts the editor into focused mode.
|
|
7033
7062
|
*
|