@tldraw/editor 3.8.0-canary.99db1910391e → 3.8.0-canary.9b13f6b7554c
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 +142 -46
- package/dist-cjs/index.js +3 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +25 -14
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager.js +1 -0
- package/dist-cjs/lib/editor/managers/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js +66 -0
- package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js.map +7 -0
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/options.js +2 -1
- package/dist-cjs/lib/options.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 +142 -46
- package/dist-esm/index.mjs +3 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +25 -14
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager.mjs +1 -0
- package/dist-esm/lib/editor/managers/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs +46 -0
- package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs.map +7 -0
- package/dist-esm/lib/options.mjs +2 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +2 -1
- package/package.json +7 -7
- package/src/index.ts +15 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/editor/Editor.ts +50 -23
- package/src/lib/editor/managers/TextManager.ts +1 -0
- package/src/lib/editor/shapes/ShapeUtil.ts +30 -1
- package/src/lib/editor/shapes/shared/resizeScaled.ts +61 -0
- package/src/lib/editor/types/emit-types.ts +1 -0
- package/src/lib/editor/types/external-content.ts +90 -50
- package/src/lib/options.ts +6 -0
- package/src/version.ts +3 -3
|
@@ -813,6 +813,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
813
813
|
(0, import_utils.assert)(shapeUtil, `No shape util found for type "${type}"`);
|
|
814
814
|
return shapeUtil;
|
|
815
815
|
}
|
|
816
|
+
hasShapeUtil(arg) {
|
|
817
|
+
const type = typeof arg === "string" ? arg : arg.type;
|
|
818
|
+
return (0, import_utils.hasOwnProperty)(this.shapeUtils, type);
|
|
819
|
+
}
|
|
816
820
|
getBindingUtil(arg) {
|
|
817
821
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
818
822
|
const bindingUtil = (0, import_utils.getOwnProperty)(this.bindingUtils, type);
|
|
@@ -5094,6 +5098,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5094
5098
|
scale = new import_Vec.Vec(Math.sign(scale.x) * Math.abs(scale.y), scale.y);
|
|
5095
5099
|
}
|
|
5096
5100
|
}
|
|
5101
|
+
let didResize = false;
|
|
5097
5102
|
if (util.onResize && util.canResize(initialShape)) {
|
|
5098
5103
|
const newPagePoint = this._scalePagePoint(
|
|
5099
5104
|
import_Mat.Mat.applyToPoint(pageTransform, new import_Vec.Vec(0, 0)),
|
|
@@ -5118,24 +5123,28 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5118
5123
|
util.onResizeStart?.(initialShape) ?? void 0
|
|
5119
5124
|
);
|
|
5120
5125
|
}
|
|
5126
|
+
const resizedShape = util.onResize(
|
|
5127
|
+
{ ...initialShape, x, y },
|
|
5128
|
+
{
|
|
5129
|
+
newPoint: newLocalPoint,
|
|
5130
|
+
handle: opts.dragHandle ?? "bottom_right",
|
|
5131
|
+
// don't set isSingle to true for children
|
|
5132
|
+
mode: opts.mode ?? "scale_shape",
|
|
5133
|
+
scaleX: myScale.x,
|
|
5134
|
+
scaleY: myScale.y,
|
|
5135
|
+
initialBounds,
|
|
5136
|
+
initialShape
|
|
5137
|
+
}
|
|
5138
|
+
);
|
|
5139
|
+
if (resizedShape) {
|
|
5140
|
+
didResize = true;
|
|
5141
|
+
}
|
|
5121
5142
|
workingShape = applyPartialToRecordWithProps(workingShape, {
|
|
5122
5143
|
id,
|
|
5123
5144
|
type: initialShape.type,
|
|
5124
5145
|
x: newLocalPoint.x,
|
|
5125
5146
|
y: newLocalPoint.y,
|
|
5126
|
-
...
|
|
5127
|
-
{ ...initialShape, x, y },
|
|
5128
|
-
{
|
|
5129
|
-
newPoint: newLocalPoint,
|
|
5130
|
-
handle: opts.dragHandle ?? "bottom_right",
|
|
5131
|
-
// don't set isSingle to true for children
|
|
5132
|
-
mode: opts.mode ?? "scale_shape",
|
|
5133
|
-
scaleX: myScale.x,
|
|
5134
|
-
scaleY: myScale.y,
|
|
5135
|
-
initialBounds,
|
|
5136
|
-
initialShape
|
|
5137
|
-
}
|
|
5138
|
-
)
|
|
5147
|
+
...resizedShape
|
|
5139
5148
|
});
|
|
5140
5149
|
if (!opts.skipStartAndEndCallbacks) {
|
|
5141
5150
|
workingShape = applyPartialToRecordWithProps(
|
|
@@ -5144,7 +5153,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5144
5153
|
);
|
|
5145
5154
|
}
|
|
5146
5155
|
this.updateShapes([workingShape]);
|
|
5147
|
-
}
|
|
5156
|
+
}
|
|
5157
|
+
if (!didResize) {
|
|
5148
5158
|
const initialPageCenter = import_Mat.Mat.applyToPoint(pageTransform, initialBounds.center);
|
|
5149
5159
|
const newPageCenter = this._scalePagePoint(
|
|
5150
5160
|
initialPageCenter,
|
|
@@ -6863,6 +6873,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
6863
6873
|
}
|
|
6864
6874
|
_flushEventForTick(info) {
|
|
6865
6875
|
if (this.getCrashingError()) return this;
|
|
6876
|
+
this.emit("before-event", info);
|
|
6866
6877
|
const { inputs } = this;
|
|
6867
6878
|
const { type } = info;
|
|
6868
6879
|
if (info.type === "misc") {
|