@widgetic/canvas 0.5.19 → 0.5.21
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/README.md +2 -0
- package/dist/canvas/Canvas.svelte +16 -16
- package/dist/canvas/widgetPreviewGeometry.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# This is a regular Widgetic Frontend project created with SvelteKit.
|
|
2
2
|
|
|
3
|
+
> **Internal building block.** This package is part of Widgetic's own apps and is not a supported integration surface. Partners: use [`@widgetic/ui-sdk`](https://www.npmjs.com/package/@widgetic/ui-sdk) instead.
|
|
4
|
+
|
|
3
5
|
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
|
4
6
|
|
|
5
7
|
## Creating a project
|
|
@@ -5103,7 +5103,7 @@
|
|
|
5103
5103
|
x: opt.e?.clientX ?? 0,
|
|
5104
5104
|
y: opt.e?.clientY ?? 0,
|
|
5105
5105
|
target,
|
|
5106
|
-
scene: canvas.
|
|
5106
|
+
scene: canvas.getScenePoint(opt.e),
|
|
5107
5107
|
};
|
|
5108
5108
|
} else {
|
|
5109
5109
|
videoPointerDown = null;
|
|
@@ -7020,7 +7020,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7020
7020
|
pointerDownHandler: (event: any) => {
|
|
7021
7021
|
if (!canvas || !pendingLibraryShapePath || !pendingLibraryShapeKey) return;
|
|
7022
7022
|
|
|
7023
|
-
const pointer = canvas.
|
|
7023
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7024
7024
|
drawingStartPoint = { x: pointer.x, y: pointer.y };
|
|
7025
7025
|
previewOverlayObjects = [];
|
|
7026
7026
|
|
|
@@ -7054,7 +7054,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7054
7054
|
pointerMoveHandler: (event: any) => {
|
|
7055
7055
|
if (!canvas || !drawingStartPoint || !previewObject) return;
|
|
7056
7056
|
|
|
7057
|
-
const pointer = canvas.
|
|
7057
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7058
7058
|
const shiftHeld = Boolean(event.e?.shiftKey) || isShiftModifierPressed;
|
|
7059
7059
|
const { lockAspectRatio } = getLibraryShapeMeta(pendingLibraryShapeKey ?? '');
|
|
7060
7060
|
|
|
@@ -7096,7 +7096,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7096
7096
|
return;
|
|
7097
7097
|
}
|
|
7098
7098
|
|
|
7099
|
-
const pointer = canvas.
|
|
7099
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7100
7100
|
const shiftHeld = Boolean(event.e?.shiftKey) || isShiftModifierPressed;
|
|
7101
7101
|
const { lockAspectRatio, cornerRadiusMode } = getLibraryShapeMeta(pendingLibraryShapeKey);
|
|
7102
7102
|
|
|
@@ -7446,7 +7446,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7446
7446
|
// Invalidate any pending deferred revert from previous interactions
|
|
7447
7447
|
++_revertGeneration;
|
|
7448
7448
|
|
|
7449
|
-
const pointer = canvas.
|
|
7449
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7450
7450
|
drawingStartPoint = { x: pointer.x, y: pointer.y };
|
|
7451
7451
|
// Don't create preview yet — defer to first pointerMove
|
|
7452
7452
|
// that exceeds MIN_DRAW_DISTANCE to avoid flicker on quick click.
|
|
@@ -7457,7 +7457,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7457
7457
|
return;
|
|
7458
7458
|
}
|
|
7459
7459
|
|
|
7460
|
-
const pointer = canvas.
|
|
7460
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7461
7461
|
|
|
7462
7462
|
const width = Math.abs(pointer.x - drawingStartPoint.x);
|
|
7463
7463
|
const height = Math.abs(pointer.y - drawingStartPoint.y);
|
|
@@ -7517,7 +7517,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7517
7517
|
return;
|
|
7518
7518
|
}
|
|
7519
7519
|
|
|
7520
|
-
const pointer = canvas.
|
|
7520
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7521
7521
|
|
|
7522
7522
|
// Calculate final dimensions based on drag.
|
|
7523
7523
|
// On quick click (no drag), use the estimated placeholder width
|
|
@@ -7598,7 +7598,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7598
7598
|
return;
|
|
7599
7599
|
}
|
|
7600
7600
|
|
|
7601
|
-
const pointer = canvas.
|
|
7601
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7602
7602
|
drawingStartPoint = { x: pointer.x, y: pointer.y };
|
|
7603
7603
|
previewOverlayObjects = [];
|
|
7604
7604
|
|
|
@@ -7721,7 +7721,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7721
7721
|
return;
|
|
7722
7722
|
}
|
|
7723
7723
|
|
|
7724
|
-
const pointer = canvas.
|
|
7724
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7725
7725
|
const shiftFromEvent = Boolean(event.e?.shiftKey);
|
|
7726
7726
|
const bounds = applyShapePreviewForPointer(pointer, shapeType, shiftFromEvent || isShiftModifierPressed);
|
|
7727
7727
|
if (!bounds) {
|
|
@@ -7739,7 +7739,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7739
7739
|
return;
|
|
7740
7740
|
}
|
|
7741
7741
|
|
|
7742
|
-
const pointer = canvas.
|
|
7742
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7743
7743
|
const shiftFinal = Boolean(event.e?.shiftKey) || isShiftModifierPressed;
|
|
7744
7744
|
|
|
7745
7745
|
if (shapeType === 'arrow') {
|
|
@@ -7897,7 +7897,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7897
7897
|
return;
|
|
7898
7898
|
}
|
|
7899
7899
|
|
|
7900
|
-
const pointer = canvas.
|
|
7900
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7901
7901
|
drawingStartPoint = { x: pointer.x, y: pointer.y };
|
|
7902
7902
|
|
|
7903
7903
|
try {
|
|
@@ -7930,7 +7930,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7930
7930
|
return;
|
|
7931
7931
|
}
|
|
7932
7932
|
|
|
7933
|
-
const pointer = canvas.
|
|
7933
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7934
7934
|
const bounds = applyShapePreviewForPointer(pointer, 'rect', Boolean(event.e?.shiftKey));
|
|
7935
7935
|
if (!bounds) {
|
|
7936
7936
|
return;
|
|
@@ -7947,7 +7947,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7947
7947
|
return;
|
|
7948
7948
|
}
|
|
7949
7949
|
|
|
7950
|
-
const pointer = canvas.
|
|
7950
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
7951
7951
|
const bounds =
|
|
7952
7952
|
applyShapePreviewForPointer(pointer, 'rect', Boolean(event.e?.shiftKey)) ?? lastAppliedBounds;
|
|
7953
7953
|
|
|
@@ -8499,7 +8499,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
8499
8499
|
return;
|
|
8500
8500
|
}
|
|
8501
8501
|
|
|
8502
|
-
const pointer = canvas.
|
|
8502
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
8503
8503
|
drawingStartPoint = { x: pointer.x, y: pointer.y };
|
|
8504
8504
|
|
|
8505
8505
|
try {
|
|
@@ -8534,7 +8534,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
8534
8534
|
return;
|
|
8535
8535
|
}
|
|
8536
8536
|
|
|
8537
|
-
const pointer = canvas.
|
|
8537
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
8538
8538
|
const bounds = applyShapePreviewForPointer(pointer, 'rect', Boolean(event.e?.shiftKey));
|
|
8539
8539
|
if (!bounds) {
|
|
8540
8540
|
return;
|
|
@@ -8551,7 +8551,7 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
8551
8551
|
return;
|
|
8552
8552
|
}
|
|
8553
8553
|
|
|
8554
|
-
const pointer = canvas.
|
|
8554
|
+
const pointer = canvas.getScenePoint(event.e);
|
|
8555
8555
|
const bounds =
|
|
8556
8556
|
applyShapePreviewForPointer(pointer, 'rect', Boolean(event.e?.shiftKey)) ?? lastAppliedBounds;
|
|
8557
8557
|
|
|
@@ -28,10 +28,12 @@ export function getWidgetPreviewGeometry(object, canvas, canvasElement) {
|
|
|
28
28
|
// and finish smaller or larger than the shape.
|
|
29
29
|
const halfWidth = (object.width || 1) / 2;
|
|
30
30
|
const halfHeight = (object.height || 1) / 2;
|
|
31
|
+
/** @param {number} x @param {number} y */
|
|
31
32
|
const scenePoint = (x, y) => ({
|
|
32
33
|
x: sceneMatrix[0] * x + sceneMatrix[2] * y + sceneMatrix[4],
|
|
33
34
|
y: sceneMatrix[1] * x + sceneMatrix[3] * y + sceneMatrix[5],
|
|
34
35
|
});
|
|
36
|
+
/** @param {{x: number, y: number}} point */
|
|
35
37
|
const project = (point) => ({
|
|
36
38
|
x: bounds.left + (viewport[0] * point.x + viewport[2] * point.y + viewport[4]) * cssScaleX,
|
|
37
39
|
y: bounds.top + (viewport[1] * point.x + viewport[3] * point.y + viewport[5]) * cssScaleY,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/canvas",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"svelte": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@tailwindcss/typography": "^0.5.19",
|
|
92
|
-
"fabric": "^
|
|
92
|
+
"fabric": "^7.4.0",
|
|
93
93
|
"tailwindcss-animate": "^1.0.7"
|
|
94
94
|
},
|
|
95
95
|
"overrides": {
|