canvu-react 0.4.20 → 0.4.22
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/native.cjs +47 -283
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +1 -19
- package/dist/native.d.ts +1 -19
- package/dist/native.js +47 -283
- package/dist/native.js.map +1 -1
- package/package.json +1 -1
package/dist/native.d.cts
CHANGED
|
@@ -12,16 +12,6 @@ type TimedTrailPoint = {
|
|
|
12
12
|
readonly t: number;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
type NativeVectorToolCursorKind = "crosshair" | "draw" | "marker" | "eraser" | "text";
|
|
16
|
-
type NativeVectorToolCursor = {
|
|
17
|
-
readonly kind: NativeVectorToolCursorKind;
|
|
18
|
-
readonly size: number;
|
|
19
|
-
readonly hotspot: {
|
|
20
|
-
readonly x: number;
|
|
21
|
-
readonly y: number;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
|
|
25
15
|
type PlacementPreview = {
|
|
26
16
|
readonly kind: "rect" | "ellipse" | "architectural-cloud";
|
|
27
17
|
readonly rect: {
|
|
@@ -68,15 +58,8 @@ type NativeInteractionOverlayProps = {
|
|
|
68
58
|
readonly laserTrail?: readonly TimedTrailPoint[];
|
|
69
59
|
readonly eraserPreviewItems?: readonly VectorSceneItem[];
|
|
70
60
|
readonly previewStrokeStyle?: StrokeStyle;
|
|
71
|
-
readonly toolCursor?: {
|
|
72
|
-
readonly cursor: NativeVectorToolCursor;
|
|
73
|
-
readonly point: {
|
|
74
|
-
readonly x: number;
|
|
75
|
-
readonly y: number;
|
|
76
|
-
};
|
|
77
|
-
} | null;
|
|
78
61
|
};
|
|
79
|
-
declare function NativeInteractionOverlay({ camera, width, height, selectedItems, showResizeHandles, placementPreview, eraserTrail, laserTrail, eraserPreviewItems, previewStrokeStyle,
|
|
62
|
+
declare function NativeInteractionOverlay({ camera, width, height, selectedItems, showResizeHandles, placementPreview, eraserTrail, laserTrail, eraserPreviewItems, previewStrokeStyle, }: NativeInteractionOverlayProps): react_jsx_runtime.JSX.Element | null;
|
|
80
63
|
|
|
81
64
|
type NativeSceneRendererProps = {
|
|
82
65
|
readonly items: readonly VectorSceneItem[];
|
|
@@ -241,7 +224,6 @@ type NativeVectorViewportProps = {
|
|
|
241
224
|
readonly onCameraChange?: () => void;
|
|
242
225
|
readonly customPlacement?: NativeCustomShapePlacementOptions;
|
|
243
226
|
readonly customPlacements?: readonly NativeCustomShapePlacementOptions[];
|
|
244
|
-
readonly customCrosshairToolIds?: readonly string[];
|
|
245
227
|
readonly toolbar?: React.ReactNode;
|
|
246
228
|
readonly showStyleInspector?: boolean;
|
|
247
229
|
readonly styleInspectorPlacement?: "bottom" | "top-left";
|
package/dist/native.d.ts
CHANGED
|
@@ -12,16 +12,6 @@ type TimedTrailPoint = {
|
|
|
12
12
|
readonly t: number;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
type NativeVectorToolCursorKind = "crosshair" | "draw" | "marker" | "eraser" | "text";
|
|
16
|
-
type NativeVectorToolCursor = {
|
|
17
|
-
readonly kind: NativeVectorToolCursorKind;
|
|
18
|
-
readonly size: number;
|
|
19
|
-
readonly hotspot: {
|
|
20
|
-
readonly x: number;
|
|
21
|
-
readonly y: number;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
|
|
25
15
|
type PlacementPreview = {
|
|
26
16
|
readonly kind: "rect" | "ellipse" | "architectural-cloud";
|
|
27
17
|
readonly rect: {
|
|
@@ -68,15 +58,8 @@ type NativeInteractionOverlayProps = {
|
|
|
68
58
|
readonly laserTrail?: readonly TimedTrailPoint[];
|
|
69
59
|
readonly eraserPreviewItems?: readonly VectorSceneItem[];
|
|
70
60
|
readonly previewStrokeStyle?: StrokeStyle;
|
|
71
|
-
readonly toolCursor?: {
|
|
72
|
-
readonly cursor: NativeVectorToolCursor;
|
|
73
|
-
readonly point: {
|
|
74
|
-
readonly x: number;
|
|
75
|
-
readonly y: number;
|
|
76
|
-
};
|
|
77
|
-
} | null;
|
|
78
61
|
};
|
|
79
|
-
declare function NativeInteractionOverlay({ camera, width, height, selectedItems, showResizeHandles, placementPreview, eraserTrail, laserTrail, eraserPreviewItems, previewStrokeStyle,
|
|
62
|
+
declare function NativeInteractionOverlay({ camera, width, height, selectedItems, showResizeHandles, placementPreview, eraserTrail, laserTrail, eraserPreviewItems, previewStrokeStyle, }: NativeInteractionOverlayProps): react_jsx_runtime.JSX.Element | null;
|
|
80
63
|
|
|
81
64
|
type NativeSceneRendererProps = {
|
|
82
65
|
readonly items: readonly VectorSceneItem[];
|
|
@@ -241,7 +224,6 @@ type NativeVectorViewportProps = {
|
|
|
241
224
|
readonly onCameraChange?: () => void;
|
|
242
225
|
readonly customPlacement?: NativeCustomShapePlacementOptions;
|
|
243
226
|
readonly customPlacements?: readonly NativeCustomShapePlacementOptions[];
|
|
244
|
-
readonly customCrosshairToolIds?: readonly string[];
|
|
245
227
|
readonly toolbar?: React.ReactNode;
|
|
246
228
|
readonly showStyleInspector?: boolean;
|
|
247
229
|
readonly styleInspectorPlacement?: "bottom" | "top-left";
|
package/dist/native.js
CHANGED
|
@@ -1998,178 +1998,6 @@ function NativeShapeRenderer({ item }) {
|
|
|
1998
1998
|
}
|
|
1999
1999
|
return null;
|
|
2000
2000
|
}
|
|
2001
|
-
var CURSOR_STROKE = "#18181b";
|
|
2002
|
-
var CURSOR_STROKE_WIDTH = 2;
|
|
2003
|
-
var CROSSHAIR_STROKE_WIDTH = 1.5;
|
|
2004
|
-
function NativeDrawCursor() {
|
|
2005
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2006
|
-
/* @__PURE__ */ jsx(
|
|
2007
|
-
Path,
|
|
2008
|
-
{
|
|
2009
|
-
path: "M13 21h8",
|
|
2010
|
-
color: CURSOR_STROKE,
|
|
2011
|
-
style: "stroke",
|
|
2012
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2013
|
-
strokeCap: "round",
|
|
2014
|
-
strokeJoin: "round",
|
|
2015
|
-
antiAlias: true
|
|
2016
|
-
}
|
|
2017
|
-
),
|
|
2018
|
-
/* @__PURE__ */ jsx(
|
|
2019
|
-
Path,
|
|
2020
|
-
{
|
|
2021
|
-
path: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
|
|
2022
|
-
color: CURSOR_STROKE,
|
|
2023
|
-
style: "stroke",
|
|
2024
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2025
|
-
strokeCap: "round",
|
|
2026
|
-
strokeJoin: "round",
|
|
2027
|
-
antiAlias: true
|
|
2028
|
-
}
|
|
2029
|
-
)
|
|
2030
|
-
] });
|
|
2031
|
-
}
|
|
2032
|
-
function NativeMarkerCursor() {
|
|
2033
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2034
|
-
/* @__PURE__ */ jsx(
|
|
2035
|
-
Path,
|
|
2036
|
-
{
|
|
2037
|
-
path: "m9 11-6 6v3h9l3-3",
|
|
2038
|
-
color: CURSOR_STROKE,
|
|
2039
|
-
style: "stroke",
|
|
2040
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2041
|
-
strokeCap: "round",
|
|
2042
|
-
strokeJoin: "round",
|
|
2043
|
-
antiAlias: true
|
|
2044
|
-
}
|
|
2045
|
-
),
|
|
2046
|
-
/* @__PURE__ */ jsx(
|
|
2047
|
-
Path,
|
|
2048
|
-
{
|
|
2049
|
-
path: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",
|
|
2050
|
-
color: CURSOR_STROKE,
|
|
2051
|
-
style: "stroke",
|
|
2052
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2053
|
-
strokeCap: "round",
|
|
2054
|
-
strokeJoin: "round",
|
|
2055
|
-
antiAlias: true
|
|
2056
|
-
}
|
|
2057
|
-
)
|
|
2058
|
-
] });
|
|
2059
|
-
}
|
|
2060
|
-
function NativeEraserCursor() {
|
|
2061
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2062
|
-
/* @__PURE__ */ jsx(
|
|
2063
|
-
Path,
|
|
2064
|
-
{
|
|
2065
|
-
path: "M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",
|
|
2066
|
-
color: CURSOR_STROKE,
|
|
2067
|
-
style: "stroke",
|
|
2068
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2069
|
-
strokeCap: "round",
|
|
2070
|
-
strokeJoin: "round",
|
|
2071
|
-
antiAlias: true
|
|
2072
|
-
}
|
|
2073
|
-
),
|
|
2074
|
-
/* @__PURE__ */ jsx(
|
|
2075
|
-
Path,
|
|
2076
|
-
{
|
|
2077
|
-
path: "m5.082 11.09 8.828 8.828",
|
|
2078
|
-
color: CURSOR_STROKE,
|
|
2079
|
-
style: "stroke",
|
|
2080
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2081
|
-
strokeCap: "round",
|
|
2082
|
-
strokeJoin: "round",
|
|
2083
|
-
antiAlias: true
|
|
2084
|
-
}
|
|
2085
|
-
)
|
|
2086
|
-
] });
|
|
2087
|
-
}
|
|
2088
|
-
function NativeCrosshairCursor() {
|
|
2089
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2090
|
-
/* @__PURE__ */ jsx(
|
|
2091
|
-
Line,
|
|
2092
|
-
{
|
|
2093
|
-
p1: vec(12, 3),
|
|
2094
|
-
p2: vec(12, 21),
|
|
2095
|
-
color: CURSOR_STROKE,
|
|
2096
|
-
style: "stroke",
|
|
2097
|
-
strokeWidth: CROSSHAIR_STROKE_WIDTH,
|
|
2098
|
-
strokeCap: "round",
|
|
2099
|
-
antiAlias: true
|
|
2100
|
-
}
|
|
2101
|
-
),
|
|
2102
|
-
/* @__PURE__ */ jsx(
|
|
2103
|
-
Line,
|
|
2104
|
-
{
|
|
2105
|
-
p1: vec(3, 12),
|
|
2106
|
-
p2: vec(21, 12),
|
|
2107
|
-
color: CURSOR_STROKE,
|
|
2108
|
-
style: "stroke",
|
|
2109
|
-
strokeWidth: CROSSHAIR_STROKE_WIDTH,
|
|
2110
|
-
strokeCap: "round",
|
|
2111
|
-
antiAlias: true
|
|
2112
|
-
}
|
|
2113
|
-
)
|
|
2114
|
-
] });
|
|
2115
|
-
}
|
|
2116
|
-
function NativeTextCursor() {
|
|
2117
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2118
|
-
/* @__PURE__ */ jsx(
|
|
2119
|
-
Line,
|
|
2120
|
-
{
|
|
2121
|
-
p1: vec(12, 4),
|
|
2122
|
-
p2: vec(12, 20),
|
|
2123
|
-
color: CURSOR_STROKE,
|
|
2124
|
-
style: "stroke",
|
|
2125
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2126
|
-
strokeCap: "round",
|
|
2127
|
-
antiAlias: true
|
|
2128
|
-
}
|
|
2129
|
-
),
|
|
2130
|
-
/* @__PURE__ */ jsx(
|
|
2131
|
-
Line,
|
|
2132
|
-
{
|
|
2133
|
-
p1: vec(8, 4),
|
|
2134
|
-
p2: vec(16, 4),
|
|
2135
|
-
color: CURSOR_STROKE,
|
|
2136
|
-
style: "stroke",
|
|
2137
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2138
|
-
strokeCap: "round",
|
|
2139
|
-
antiAlias: true
|
|
2140
|
-
}
|
|
2141
|
-
),
|
|
2142
|
-
/* @__PURE__ */ jsx(
|
|
2143
|
-
Line,
|
|
2144
|
-
{
|
|
2145
|
-
p1: vec(8, 20),
|
|
2146
|
-
p2: vec(16, 20),
|
|
2147
|
-
color: CURSOR_STROKE,
|
|
2148
|
-
style: "stroke",
|
|
2149
|
-
strokeWidth: CURSOR_STROKE_WIDTH,
|
|
2150
|
-
strokeCap: "round",
|
|
2151
|
-
antiAlias: true
|
|
2152
|
-
}
|
|
2153
|
-
)
|
|
2154
|
-
] });
|
|
2155
|
-
}
|
|
2156
|
-
function NativeToolCursorGlyph({
|
|
2157
|
-
cursor
|
|
2158
|
-
}) {
|
|
2159
|
-
if (cursor.kind === "draw") return /* @__PURE__ */ jsx(NativeDrawCursor, {});
|
|
2160
|
-
if (cursor.kind === "marker") return /* @__PURE__ */ jsx(NativeMarkerCursor, {});
|
|
2161
|
-
if (cursor.kind === "eraser") return /* @__PURE__ */ jsx(NativeEraserCursor, {});
|
|
2162
|
-
if (cursor.kind === "text") return /* @__PURE__ */ jsx(NativeTextCursor, {});
|
|
2163
|
-
return /* @__PURE__ */ jsx(NativeCrosshairCursor, {});
|
|
2164
|
-
}
|
|
2165
|
-
function NativeToolCursorRenderer({
|
|
2166
|
-
cursor,
|
|
2167
|
-
point
|
|
2168
|
-
}) {
|
|
2169
|
-
const x = point.x - cursor.hotspot.x;
|
|
2170
|
-
const y = point.y - cursor.hotspot.y;
|
|
2171
|
-
return /* @__PURE__ */ jsx(Group, { transform: [{ translateX: x }, { translateY: y }], children: /* @__PURE__ */ jsx(NativeToolCursorGlyph, { cursor }) });
|
|
2172
|
-
}
|
|
2173
2001
|
|
|
2174
2002
|
// src/native/native-overlay-style.ts
|
|
2175
2003
|
var ERASER_TINT = "#cbd5e1";
|
|
@@ -2226,8 +2054,7 @@ function NativeInteractionOverlay({
|
|
|
2226
2054
|
eraserTrail,
|
|
2227
2055
|
laserTrail,
|
|
2228
2056
|
eraserPreviewItems = [],
|
|
2229
|
-
previewStrokeStyle
|
|
2230
|
-
toolCursor
|
|
2057
|
+
previewStrokeStyle
|
|
2231
2058
|
}) {
|
|
2232
2059
|
const z = camera.zoom;
|
|
2233
2060
|
const camTransform = skiaCameraTransform(z, camera.x, camera.y);
|
|
@@ -2604,7 +2431,7 @@ function NativeInteractionOverlay({
|
|
|
2604
2431
|
] });
|
|
2605
2432
|
}, [laserTrail, z]);
|
|
2606
2433
|
if (width <= 0 || height <= 0) return null;
|
|
2607
|
-
return /* @__PURE__ */
|
|
2434
|
+
return /* @__PURE__ */ jsx(
|
|
2608
2435
|
Canvas,
|
|
2609
2436
|
{
|
|
2610
2437
|
style: {
|
|
@@ -2615,22 +2442,13 @@ function NativeInteractionOverlay({
|
|
|
2615
2442
|
height
|
|
2616
2443
|
},
|
|
2617
2444
|
pointerEvents: "none",
|
|
2618
|
-
children: [
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
] }),
|
|
2626
|
-
toolCursor ? /* @__PURE__ */ jsx(
|
|
2627
|
-
NativeToolCursorRenderer,
|
|
2628
|
-
{
|
|
2629
|
-
cursor: toolCursor.cursor,
|
|
2630
|
-
point: toolCursor.point
|
|
2631
|
-
}
|
|
2632
|
-
) : null
|
|
2633
|
-
]
|
|
2445
|
+
children: /* @__PURE__ */ jsxs(Group, { transform: camTransform, children: [
|
|
2446
|
+
previewElements,
|
|
2447
|
+
laserTrailElements,
|
|
2448
|
+
eraserTrailElements,
|
|
2449
|
+
eraserPreviewElements,
|
|
2450
|
+
selectionElements
|
|
2451
|
+
] })
|
|
2634
2452
|
}
|
|
2635
2453
|
);
|
|
2636
2454
|
}
|
|
@@ -3968,39 +3786,6 @@ function resizeItemByHandle(item, start, handle, currentWorld) {
|
|
|
3968
3786
|
return { ...item, x: nb.x, y: nb.y, bounds: nb };
|
|
3969
3787
|
}
|
|
3970
3788
|
|
|
3971
|
-
// src/native/native-tool-cursors.ts
|
|
3972
|
-
var ICON_SIZE = 24;
|
|
3973
|
-
var CENTER_HOTSPOT = { x: 12, y: 12 };
|
|
3974
|
-
function nativeCursorForVectorToolId(toolId) {
|
|
3975
|
-
switch (toolId) {
|
|
3976
|
-
case "rect":
|
|
3977
|
-
case "ellipse":
|
|
3978
|
-
case "architectural-cloud":
|
|
3979
|
-
case "line":
|
|
3980
|
-
case "arrow":
|
|
3981
|
-
case "laser":
|
|
3982
|
-
case "image":
|
|
3983
|
-
return { kind: "crosshair", size: ICON_SIZE, hotspot: CENTER_HOTSPOT };
|
|
3984
|
-
case "draw":
|
|
3985
|
-
return { kind: "draw", size: ICON_SIZE, hotspot: { x: 4, y: 18 } };
|
|
3986
|
-
case "marker":
|
|
3987
|
-
return { kind: "marker", size: ICON_SIZE, hotspot: { x: 11, y: 14 } };
|
|
3988
|
-
case "eraser":
|
|
3989
|
-
return { kind: "eraser", size: ICON_SIZE, hotspot: { x: 12, y: 14 } };
|
|
3990
|
-
case "text":
|
|
3991
|
-
return { kind: "text", size: ICON_SIZE, hotspot: CENTER_HOTSPOT };
|
|
3992
|
-
default:
|
|
3993
|
-
return null;
|
|
3994
|
-
}
|
|
3995
|
-
}
|
|
3996
|
-
function nativeCrosshairToolCursor() {
|
|
3997
|
-
return { kind: "crosshair", size: ICON_SIZE, hotspot: CENTER_HOTSPOT };
|
|
3998
|
-
}
|
|
3999
|
-
function nativeFallbackToolCursorPoint(size) {
|
|
4000
|
-
if (size.width <= 0 || size.height <= 0) return null;
|
|
4001
|
-
return { x: size.width / 2, y: size.height / 2 };
|
|
4002
|
-
}
|
|
4003
|
-
|
|
4004
3789
|
// src/native/native-vector-interactions.ts
|
|
4005
3790
|
var NATIVE_SELECTION_HANDLE_HIT_RADIUS_PX = 24;
|
|
4006
3791
|
function supportsNativeResizeHandles(item) {
|
|
@@ -4045,6 +3830,19 @@ function hitTestNativeSelectionHandle({
|
|
|
4045
3830
|
);
|
|
4046
3831
|
return handle ? { kind: "resize", handle } : null;
|
|
4047
3832
|
}
|
|
3833
|
+
function pointInNativeSelectedItemBounds(item, worldPoint) {
|
|
3834
|
+
const bounds = normalizeRect(item.bounds);
|
|
3835
|
+
const local = worldToItemLocal(
|
|
3836
|
+
worldPoint.x,
|
|
3837
|
+
worldPoint.y,
|
|
3838
|
+
item.x,
|
|
3839
|
+
item.y,
|
|
3840
|
+
bounds.width,
|
|
3841
|
+
bounds.height,
|
|
3842
|
+
item.rotation ?? 0
|
|
3843
|
+
);
|
|
3844
|
+
return local.x >= 0 && local.x <= bounds.width && local.y >= 0 && local.y <= bounds.height;
|
|
3845
|
+
}
|
|
4048
3846
|
function resolveNativeCustomPlacement(toolId, customPlacement, customPlacements) {
|
|
4049
3847
|
if (customPlacement?.toolId === toolId) return customPlacement;
|
|
4050
3848
|
return customPlacements?.find((placement) => placement.toolId === toolId) ?? null;
|
|
@@ -4145,7 +3943,6 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4145
3943
|
onCameraChange,
|
|
4146
3944
|
customPlacement,
|
|
4147
3945
|
customPlacements = [],
|
|
4148
|
-
customCrosshairToolIds = [],
|
|
4149
3946
|
toolbar,
|
|
4150
3947
|
showStyleInspector = false,
|
|
4151
3948
|
styleInspectorPlacement = "bottom"
|
|
@@ -4168,8 +3965,6 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4168
3965
|
customPlacementRef.current = customPlacement;
|
|
4169
3966
|
const customPlacementsRef = useRef(customPlacements);
|
|
4170
3967
|
customPlacementsRef.current = customPlacements;
|
|
4171
|
-
const customCrosshairToolIdsRef = useRef(customCrosshairToolIds);
|
|
4172
|
-
customCrosshairToolIdsRef.current = customCrosshairToolIds;
|
|
4173
3968
|
const onSelectionChangeRef = useRef(onSelectionChange);
|
|
4174
3969
|
onSelectionChangeRef.current = onSelectionChange;
|
|
4175
3970
|
const itemsRef = useRef(items);
|
|
@@ -4182,7 +3977,6 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4182
3977
|
);
|
|
4183
3978
|
const [eraserTrail, setEraserTrail] = useState([]);
|
|
4184
3979
|
const [laserTrail, setLaserTrail] = useState([]);
|
|
4185
|
-
const [toolCursorPoint, setToolCursorPoint] = useState(null);
|
|
4186
3980
|
const laserClearTimerRef = useRef(null);
|
|
4187
3981
|
const strokeStyleRef = useRef({ ...DEFAULT_STROKE_STYLE });
|
|
4188
3982
|
const markerStrokeStyleRef = useRef({ ...MARKER_TOOL_STYLE });
|
|
@@ -4277,60 +4071,14 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4277
4071
|
setCameraTick((n) => n + 1);
|
|
4278
4072
|
onCameraChangeRef.current?.();
|
|
4279
4073
|
}, []);
|
|
4280
|
-
const
|
|
4281
|
-
const
|
|
4282
|
-
|
|
4283
|
-
|
|
4074
|
+
const onLayout = useCallback((e) => {
|
|
4075
|
+
const { width, height } = e.nativeEvent.layout;
|
|
4076
|
+
setSize({ width, height });
|
|
4077
|
+
}, []);
|
|
4078
|
+
const updateToolCursorPoint = useCallback((_point) => {
|
|
4284
4079
|
}, []);
|
|
4285
|
-
const onLayout = useCallback(
|
|
4286
|
-
(e) => {
|
|
4287
|
-
const { width, height } = e.nativeEvent.layout;
|
|
4288
|
-
const nextSize = { width, height };
|
|
4289
|
-
setSize(nextSize);
|
|
4290
|
-
if (!interactive) {
|
|
4291
|
-
setToolCursorPoint(null);
|
|
4292
|
-
return;
|
|
4293
|
-
}
|
|
4294
|
-
if (!cursorForToolId(toolIdRef.current)) {
|
|
4295
|
-
setToolCursorPoint(null);
|
|
4296
|
-
return;
|
|
4297
|
-
}
|
|
4298
|
-
setToolCursorPoint(
|
|
4299
|
-
(current) => current ?? nativeFallbackToolCursorPoint(nextSize)
|
|
4300
|
-
);
|
|
4301
|
-
},
|
|
4302
|
-
[cursorForToolId, interactive]
|
|
4303
|
-
);
|
|
4304
|
-
const updateToolCursorPoint = useCallback(
|
|
4305
|
-
(point) => {
|
|
4306
|
-
if (!interactive) return;
|
|
4307
|
-
if (!cursorForToolId(toolIdRef.current)) return;
|
|
4308
|
-
setToolCursorPoint(point);
|
|
4309
|
-
},
|
|
4310
|
-
[cursorForToolId, interactive]
|
|
4311
|
-
);
|
|
4312
4080
|
const hideToolCursor = useCallback(() => {
|
|
4313
|
-
setToolCursorPoint(null);
|
|
4314
4081
|
}, []);
|
|
4315
|
-
const showFallbackToolCursor = useCallback(
|
|
4316
|
-
(nextToolId) => {
|
|
4317
|
-
if (!interactive) {
|
|
4318
|
-
setToolCursorPoint(null);
|
|
4319
|
-
return;
|
|
4320
|
-
}
|
|
4321
|
-
if (!cursorForToolId(nextToolId)) {
|
|
4322
|
-
setToolCursorPoint(null);
|
|
4323
|
-
return;
|
|
4324
|
-
}
|
|
4325
|
-
setToolCursorPoint(
|
|
4326
|
-
(current) => current ?? nativeFallbackToolCursorPoint(size)
|
|
4327
|
-
);
|
|
4328
|
-
},
|
|
4329
|
-
[cursorForToolId, interactive, size]
|
|
4330
|
-
);
|
|
4331
|
-
useEffect(() => {
|
|
4332
|
-
showFallbackToolCursor(toolId);
|
|
4333
|
-
}, [showFallbackToolCursor, toolId]);
|
|
4334
4082
|
const selectedItems = useMemo(
|
|
4335
4083
|
() => items.filter((it) => selectedIds.includes(it.id)),
|
|
4336
4084
|
[items, selectedIds]
|
|
@@ -4419,6 +4167,25 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4419
4167
|
onSelectionChangeRef.current?.([hit.id]);
|
|
4420
4168
|
}
|
|
4421
4169
|
} else {
|
|
4170
|
+
const selectedUnlockedItems = currentSelectedIds.map((id) => itemsRef.current.find((item) => item.id === id)).filter((item) => !!item && !item.locked);
|
|
4171
|
+
if (selectedUnlockedItems.some(
|
|
4172
|
+
(item) => pointInNativeSelectedItemBounds(item, { x: worldX, y: worldY })
|
|
4173
|
+
)) {
|
|
4174
|
+
const snapshots = {};
|
|
4175
|
+
for (const item of selectedUnlockedItems) {
|
|
4176
|
+
snapshots[item.id] = item;
|
|
4177
|
+
}
|
|
4178
|
+
const ids = Object.keys(snapshots);
|
|
4179
|
+
if (ids.length > 0) {
|
|
4180
|
+
dragStateRef.current = {
|
|
4181
|
+
kind: "move",
|
|
4182
|
+
ids,
|
|
4183
|
+
snapshots,
|
|
4184
|
+
startWorld: { x: worldX, y: worldY }
|
|
4185
|
+
};
|
|
4186
|
+
return;
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4422
4189
|
onSelectionChangeRef.current?.([]);
|
|
4423
4190
|
dragStateRef.current = {
|
|
4424
4191
|
kind: "marquee",
|
|
@@ -4995,8 +4762,6 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4995
4762
|
[requestRender, size]
|
|
4996
4763
|
);
|
|
4997
4764
|
const activeStyleToolId = toolId === "draw" || toolId === "marker" ? toolId : null;
|
|
4998
|
-
const activeToolCursor = cursorForToolId(toolId);
|
|
4999
|
-
const toolCursor = activeToolCursor && toolCursorPoint ? { cursor: activeToolCursor, point: toolCursorPoint } : null;
|
|
5000
4765
|
return /* @__PURE__ */ jsx(
|
|
5001
4766
|
View,
|
|
5002
4767
|
{
|
|
@@ -5032,8 +4797,7 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
5032
4797
|
eraserPreviewItems: items.filter(
|
|
5033
4798
|
(it) => eraserPreviewIds.includes(it.id)
|
|
5034
4799
|
),
|
|
5035
|
-
previewStrokeStyle: strokeStyleState
|
|
5036
|
-
toolCursor
|
|
4800
|
+
previewStrokeStyle: strokeStyleState
|
|
5037
4801
|
}
|
|
5038
4802
|
),
|
|
5039
4803
|
interactive && showStyleInspector && activeStyleToolId ? /* @__PURE__ */ jsx(
|