canvu-react 0.4.43 → 0.4.45
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 +51 -4
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +51 -4
- package/dist/native.js.map +1 -1
- package/dist/realtime.cjs +82 -12
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +82 -12
- package/dist/realtime.js.map +1 -1
- package/dist/realtimeNative.cjs +85 -15
- package/dist/realtimeNative.cjs.map +1 -1
- package/dist/realtimeNative.js +85 -15
- package/dist/realtimeNative.js.map +1 -1
- package/package.json +1 -1
package/dist/native.js
CHANGED
|
@@ -957,6 +957,9 @@ function rebuildItemSvg(item) {
|
|
|
957
957
|
}
|
|
958
958
|
return item;
|
|
959
959
|
}
|
|
960
|
+
function applyStrokeToItem(item, patch) {
|
|
961
|
+
return rebuildItemSvg({ ...item, ...patch });
|
|
962
|
+
}
|
|
960
963
|
function createRectangleItem(id, bounds, style) {
|
|
961
964
|
const r = normalizeRect(bounds);
|
|
962
965
|
const s = { ...DEFAULT_STROKE_STYLE, ...style };
|
|
@@ -5191,6 +5194,14 @@ function isPlacementTool(toolId) {
|
|
|
5191
5194
|
function isDefaultMarkerToolStyle(style) {
|
|
5192
5195
|
return style.stroke === MARKER_TOOL_STYLE.stroke && style.strokeWidth === MARKER_TOOL_STYLE.strokeWidth && style.strokeOpacity === MARKER_TOOL_STYLE.strokeOpacity;
|
|
5193
5196
|
}
|
|
5197
|
+
function getNativeStyleInspectorToolId(item) {
|
|
5198
|
+
const kind = item.toolKind;
|
|
5199
|
+
if (kind === "marker") return "marker";
|
|
5200
|
+
if (kind === "draw" || kind === "pencil" || kind === "brush" || kind === "rect" || kind === "ellipse" || kind === "architectural-cloud" || kind === "line" || kind === "arrow") {
|
|
5201
|
+
return "draw";
|
|
5202
|
+
}
|
|
5203
|
+
return null;
|
|
5204
|
+
}
|
|
5194
5205
|
function placementPreviewForTool(toolId, start, end) {
|
|
5195
5206
|
if (toolId === "rect" || toolId === "ellipse" || toolId === "architectural-cloud") {
|
|
5196
5207
|
return { kind: toolId, rect: rectFromCorners(start, end) };
|
|
@@ -5454,12 +5465,45 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
5454
5465
|
() => items.filter((it) => selectedIds.includes(it.id)),
|
|
5455
5466
|
[items, selectedIds]
|
|
5456
5467
|
);
|
|
5468
|
+
const selectedStyleInspectorState = useMemo(() => {
|
|
5469
|
+
const styleableItems = selectedItems.filter(
|
|
5470
|
+
(item) => !item.locked && getNativeStyleInspectorToolId(item) !== null
|
|
5471
|
+
);
|
|
5472
|
+
if (styleableItems.length === 0) return null;
|
|
5473
|
+
const toolId2 = styleableItems.every((item) => item.toolKind === "marker") ? "marker" : "draw";
|
|
5474
|
+
const primaryItem = toolId2 === "marker" ? styleableItems[0] : styleableItems.find((item) => item.toolKind !== "marker") ?? styleableItems[0];
|
|
5475
|
+
if (!primaryItem) return null;
|
|
5476
|
+
return {
|
|
5477
|
+
toolId: toolId2,
|
|
5478
|
+
value: resolveStrokeStyle(primaryItem)
|
|
5479
|
+
};
|
|
5480
|
+
}, [selectedItems]);
|
|
5457
5481
|
const sceneItems = useMemo(() => {
|
|
5458
5482
|
if (eraserPreviewIds.length === 0) return items;
|
|
5459
5483
|
const hidden = new Set(eraserPreviewIds);
|
|
5460
5484
|
return items.filter((it) => !hidden.has(it.id));
|
|
5461
5485
|
}, [items, eraserPreviewIds]);
|
|
5462
5486
|
const showResizeHandles = interactive && selectedItems.length === 1 && !selectedItems[0]?.locked && supportsNativeResizeHandles(selectedItems[0]);
|
|
5487
|
+
const patchSelectedItemsStrokeStyle = useCallback(
|
|
5488
|
+
(patch) => {
|
|
5489
|
+
const change = onItemsChangeRef.current;
|
|
5490
|
+
if (!change) return;
|
|
5491
|
+
const selectedIdSet = new Set(selectedIdsRef.current);
|
|
5492
|
+
if (selectedIdSet.size === 0) return;
|
|
5493
|
+
let changed = false;
|
|
5494
|
+
const nextItems = itemsRef.current.map((item) => {
|
|
5495
|
+
if (!selectedIdSet.has(item.id) || item.locked || getNativeStyleInspectorToolId(item) === null) {
|
|
5496
|
+
return item;
|
|
5497
|
+
}
|
|
5498
|
+
changed = true;
|
|
5499
|
+
return applyStrokeToItem(item, patch);
|
|
5500
|
+
});
|
|
5501
|
+
if (!changed) return;
|
|
5502
|
+
change(nextItems);
|
|
5503
|
+
patchCurrentStrokeStyle(patch);
|
|
5504
|
+
},
|
|
5505
|
+
[patchCurrentStrokeStyle]
|
|
5506
|
+
);
|
|
5463
5507
|
const lastPinchDist = useRef(null);
|
|
5464
5508
|
const lastPanPoint = useRef(null);
|
|
5465
5509
|
const beginDragAtScreenPoint = useCallback(
|
|
@@ -6205,6 +6249,9 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
6205
6249
|
[requestRender, size]
|
|
6206
6250
|
);
|
|
6207
6251
|
const activeStyleToolId = toolId === "draw" || toolId === "marker" ? toolId : null;
|
|
6252
|
+
const styleInspectorToolId = selectedStyleInspectorState?.toolId ?? activeStyleToolId;
|
|
6253
|
+
const styleInspectorValue = selectedStyleInspectorState?.value ?? strokeStyleState;
|
|
6254
|
+
const styleInspectorChange = selectedStyleInspectorState ? patchSelectedItemsStrokeStyle : patchCurrentStrokeStyle;
|
|
6208
6255
|
const nativeLinkDialogLabels = {
|
|
6209
6256
|
...DEFAULT_NATIVE_LINK_TOOL_DIALOG_LABELS,
|
|
6210
6257
|
...linkToolDialogLabels ?? {}
|
|
@@ -6271,7 +6318,7 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
6271
6318
|
children: overlay
|
|
6272
6319
|
}
|
|
6273
6320
|
) : null,
|
|
6274
|
-
interactive && showStyleInspector &&
|
|
6321
|
+
interactive && showStyleInspector && styleInspectorToolId ? /* @__PURE__ */ jsx(
|
|
6275
6322
|
View,
|
|
6276
6323
|
{
|
|
6277
6324
|
pointerEvents: "box-none",
|
|
@@ -6294,9 +6341,9 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
6294
6341
|
children: /* @__PURE__ */ jsx(
|
|
6295
6342
|
NativeVectorStyleInspector,
|
|
6296
6343
|
{
|
|
6297
|
-
toolId:
|
|
6298
|
-
value:
|
|
6299
|
-
onChange:
|
|
6344
|
+
toolId: styleInspectorToolId,
|
|
6345
|
+
value: styleInspectorValue,
|
|
6346
|
+
onChange: styleInspectorChange
|
|
6300
6347
|
}
|
|
6301
6348
|
)
|
|
6302
6349
|
}
|