@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
|
@@ -839,6 +839,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
839
839
|
assert(shapeUtil, `No shape util found for type "${type}"`);
|
|
840
840
|
return shapeUtil;
|
|
841
841
|
}
|
|
842
|
+
hasShapeUtil(arg) {
|
|
843
|
+
const type = typeof arg === "string" ? arg : arg.type;
|
|
844
|
+
return hasOwnProperty(this.shapeUtils, type);
|
|
845
|
+
}
|
|
842
846
|
getBindingUtil(arg) {
|
|
843
847
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
844
848
|
const bindingUtil = getOwnProperty(this.bindingUtils, type);
|
|
@@ -5120,6 +5124,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5120
5124
|
scale = new Vec(Math.sign(scale.x) * Math.abs(scale.y), scale.y);
|
|
5121
5125
|
}
|
|
5122
5126
|
}
|
|
5127
|
+
let didResize = false;
|
|
5123
5128
|
if (util.onResize && util.canResize(initialShape)) {
|
|
5124
5129
|
const newPagePoint = this._scalePagePoint(
|
|
5125
5130
|
Mat.applyToPoint(pageTransform, new Vec(0, 0)),
|
|
@@ -5144,24 +5149,28 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5144
5149
|
util.onResizeStart?.(initialShape) ?? void 0
|
|
5145
5150
|
);
|
|
5146
5151
|
}
|
|
5152
|
+
const resizedShape = util.onResize(
|
|
5153
|
+
{ ...initialShape, x, y },
|
|
5154
|
+
{
|
|
5155
|
+
newPoint: newLocalPoint,
|
|
5156
|
+
handle: opts.dragHandle ?? "bottom_right",
|
|
5157
|
+
// don't set isSingle to true for children
|
|
5158
|
+
mode: opts.mode ?? "scale_shape",
|
|
5159
|
+
scaleX: myScale.x,
|
|
5160
|
+
scaleY: myScale.y,
|
|
5161
|
+
initialBounds,
|
|
5162
|
+
initialShape
|
|
5163
|
+
}
|
|
5164
|
+
);
|
|
5165
|
+
if (resizedShape) {
|
|
5166
|
+
didResize = true;
|
|
5167
|
+
}
|
|
5147
5168
|
workingShape = applyPartialToRecordWithProps(workingShape, {
|
|
5148
5169
|
id,
|
|
5149
5170
|
type: initialShape.type,
|
|
5150
5171
|
x: newLocalPoint.x,
|
|
5151
5172
|
y: newLocalPoint.y,
|
|
5152
|
-
...
|
|
5153
|
-
{ ...initialShape, x, y },
|
|
5154
|
-
{
|
|
5155
|
-
newPoint: newLocalPoint,
|
|
5156
|
-
handle: opts.dragHandle ?? "bottom_right",
|
|
5157
|
-
// don't set isSingle to true for children
|
|
5158
|
-
mode: opts.mode ?? "scale_shape",
|
|
5159
|
-
scaleX: myScale.x,
|
|
5160
|
-
scaleY: myScale.y,
|
|
5161
|
-
initialBounds,
|
|
5162
|
-
initialShape
|
|
5163
|
-
}
|
|
5164
|
-
)
|
|
5173
|
+
...resizedShape
|
|
5165
5174
|
});
|
|
5166
5175
|
if (!opts.skipStartAndEndCallbacks) {
|
|
5167
5176
|
workingShape = applyPartialToRecordWithProps(
|
|
@@ -5170,7 +5179,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5170
5179
|
);
|
|
5171
5180
|
}
|
|
5172
5181
|
this.updateShapes([workingShape]);
|
|
5173
|
-
}
|
|
5182
|
+
}
|
|
5183
|
+
if (!didResize) {
|
|
5174
5184
|
const initialPageCenter = Mat.applyToPoint(pageTransform, initialBounds.center);
|
|
5175
5185
|
const newPageCenter = this._scalePagePoint(
|
|
5176
5186
|
initialPageCenter,
|
|
@@ -6889,6 +6899,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
6889
6899
|
}
|
|
6890
6900
|
_flushEventForTick(info) {
|
|
6891
6901
|
if (this.getCrashingError()) return this;
|
|
6902
|
+
this.emit("before-event", info);
|
|
6892
6903
|
const { inputs } = this;
|
|
6893
6904
|
const { type } = info;
|
|
6894
6905
|
if (info.type === "misc") {
|