canvu-react 0.4.47 → 0.4.48
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/{asset-hydration-Dc7fsnTG.d.ts → asset-hydration-BSjiek7Q.d.ts} +2 -2
- package/dist/{asset-hydration-Cy_2FyV5.d.cts → asset-hydration-F6aM5C7x.d.cts} +2 -2
- package/dist/{asset-store-TzOPvlgn.d.cts → asset-store-35ysK28r.d.cts} +1 -1
- package/dist/{asset-store-DQPRZEcy.d.ts → asset-store-D_FjW_CN.d.ts} +1 -1
- package/dist/chatbot.d.cts +6 -6
- package/dist/chatbot.d.ts +6 -6
- package/dist/index.cjs +49 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -9
- package/dist/index.d.ts +53 -9
- package/dist/index.js +49 -1
- package/dist/index.js.map +1 -1
- package/dist/{link-item-DwzXOwU5.d.cts → link-item-BMV3VUCr.d.cts} +1 -1
- package/dist/{link-item-IW4GTnxl.d.ts → link-item-COoNNvCu.d.ts} +1 -1
- package/dist/native.cjs +47 -7
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +6 -6
- package/dist/native.d.ts +6 -6
- package/dist/native.js +47 -7
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +259 -18
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +29 -13
- package/dist/react.d.ts +29 -13
- package/dist/react.js +259 -18
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +3 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +8 -8
- package/dist/realtime.d.ts +8 -8
- package/dist/realtime.js +3 -1
- package/dist/realtime.js.map +1 -1
- package/dist/realtimeNative.d.cts +4 -4
- package/dist/realtimeNative.d.ts +4 -4
- package/dist/{shape-builders-Cyh8zvDG.d.ts → shape-builders-BCOAG0pS.d.ts} +1 -1
- package/dist/{shape-builders-CKEMjivV.d.cts → shape-builders-BmLS8CNh.d.cts} +1 -1
- package/dist/tldraw.cjs +3 -1
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.d.cts +1 -1
- package/dist/tldraw.d.ts +1 -1
- package/dist/tldraw.js +3 -1
- package/dist/tldraw.js.map +1 -1
- package/dist/{types-BUPc2Zgw.d.cts → types-6HszqSa5.d.cts} +1 -1
- package/dist/{types-B7xZAKVJ.d.ts → types-BAEHaIYO.d.ts} +43 -6
- package/dist/{types-B82WiQQh.d.ts → types-BMMPUak7.d.ts} +1 -1
- package/dist/{types-BQUbxMgz.d.cts → types-BOQLWyCw.d.cts} +1 -1
- package/dist/{types-CYtq9Pr9.d.ts → types-BtWbGOqh.d.ts} +1 -1
- package/dist/{types-BCCvY6ie.d.cts → types-fJNwEnHf.d.cts} +35 -1
- package/dist/{types-BCCvY6ie.d.ts → types-fJNwEnHf.d.ts} +35 -1
- package/dist/{types-C4wI3Jyc.d.cts → types-uzeExFkd.d.cts} +43 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Rect, V as VectorSceneItem } from './types-
|
|
1
|
+
import { R as Rect, V as VectorSceneItem } from './types-fJNwEnHf.cjs';
|
|
2
2
|
|
|
3
3
|
/** Plugin key under which link metadata is stored on a link item's `pluginData`. */
|
|
4
4
|
declare const LINK_PLUGIN_KEY = "canvuLink";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Rect, V as VectorSceneItem } from './types-
|
|
1
|
+
import { R as Rect, V as VectorSceneItem } from './types-fJNwEnHf.js';
|
|
2
2
|
|
|
3
3
|
/** Plugin key under which link metadata is stored on a link item's `pluginData`. */
|
|
4
4
|
declare const LINK_PLUGIN_KEY = "canvuLink";
|
package/dist/native.cjs
CHANGED
|
@@ -41,7 +41,7 @@ function buildCustomShapeChildrenSvg(inner, intrinsic, bounds) {
|
|
|
41
41
|
const sy = b.height / intrinsic.height;
|
|
42
42
|
return `<g transform="scale(${sx},${sy})">${inner}</g>`;
|
|
43
43
|
}
|
|
44
|
-
function createCustomShapeItem(id, bounds, content) {
|
|
44
|
+
function createCustomShapeItem(id, bounds, content, options = {}) {
|
|
45
45
|
const r = normalizeRect(bounds);
|
|
46
46
|
const intrinsic = { width: r.width, height: r.height };
|
|
47
47
|
const inner = resolveCustomInner(content, intrinsic);
|
|
@@ -53,6 +53,8 @@ function createCustomShapeItem(id, bounds, content) {
|
|
|
53
53
|
toolKind: "custom",
|
|
54
54
|
customIntrinsicSize: intrinsic,
|
|
55
55
|
customInnerSvg: inner,
|
|
56
|
+
...options.resizeHandles !== void 0 ? { customResizeHandles: options.resizeHandles } : {},
|
|
57
|
+
...options.svgClassName ? { svgClassName: options.svgClassName } : {},
|
|
56
58
|
childrenSvg: buildCustomShapeChildrenSvg(inner, intrinsic, r)
|
|
57
59
|
};
|
|
58
60
|
}
|
|
@@ -1595,7 +1597,42 @@ var styles = reactNative.StyleSheet.create({
|
|
|
1595
1597
|
});
|
|
1596
1598
|
|
|
1597
1599
|
// src/interaction/resize-handles.ts
|
|
1598
|
-
var
|
|
1600
|
+
var ALL_RESIZE_HANDLES = [
|
|
1601
|
+
"nw",
|
|
1602
|
+
"n",
|
|
1603
|
+
"ne",
|
|
1604
|
+
"e",
|
|
1605
|
+
"se",
|
|
1606
|
+
"s",
|
|
1607
|
+
"sw",
|
|
1608
|
+
"w"
|
|
1609
|
+
];
|
|
1610
|
+
var CORNER_RESIZE_HANDLES = [
|
|
1611
|
+
"nw",
|
|
1612
|
+
"ne",
|
|
1613
|
+
"se",
|
|
1614
|
+
"sw"
|
|
1615
|
+
];
|
|
1616
|
+
function dedupeHandles(handles) {
|
|
1617
|
+
const allowed = new Set(handles);
|
|
1618
|
+
return ALL_RESIZE_HANDLES.filter((handle) => allowed.has(handle));
|
|
1619
|
+
}
|
|
1620
|
+
function resolveCustomResizeHandles(handles) {
|
|
1621
|
+
if (handles === "corners") return CORNER_RESIZE_HANDLES;
|
|
1622
|
+
if (handles === "all" || handles === void 0) return ALL_RESIZE_HANDLES;
|
|
1623
|
+
return dedupeHandles(handles);
|
|
1624
|
+
}
|
|
1625
|
+
function resolveResizeHandlesForItem(item) {
|
|
1626
|
+
if (!item) return ALL_RESIZE_HANDLES;
|
|
1627
|
+
if (getLinkData(item)) return CORNER_RESIZE_HANDLES;
|
|
1628
|
+
if (item.toolKind === "custom") {
|
|
1629
|
+
return resolveCustomResizeHandles(item.customResizeHandles);
|
|
1630
|
+
}
|
|
1631
|
+
return ALL_RESIZE_HANDLES;
|
|
1632
|
+
}
|
|
1633
|
+
function itemAllowsResizeHandle(item, handle) {
|
|
1634
|
+
return resolveResizeHandlesForItem(item).includes(handle);
|
|
1635
|
+
}
|
|
1599
1636
|
function getHandleWorldPosition(bounds, id) {
|
|
1600
1637
|
const r = normalizeRect(bounds);
|
|
1601
1638
|
const cx = r.x + r.width / 2;
|
|
@@ -1619,7 +1656,7 @@ function getHandleWorldPosition(bounds, id) {
|
|
|
1619
1656
|
return { x: r.x, y: cy };
|
|
1620
1657
|
}
|
|
1621
1658
|
}
|
|
1622
|
-
function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad = 0) {
|
|
1659
|
+
function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad = 0, handles = ALL_RESIZE_HANDLES) {
|
|
1623
1660
|
const r = normalizeRect(bounds);
|
|
1624
1661
|
const pl = worldToItemLocal(
|
|
1625
1662
|
worldX,
|
|
@@ -1633,7 +1670,7 @@ function hitTestResizeHandle(bounds, worldX, worldY, radiusWorld, rotationRad =
|
|
|
1633
1670
|
const localBounds2 = { x: 0, y: 0, width: r.width, height: r.height };
|
|
1634
1671
|
let best = null;
|
|
1635
1672
|
let bestD = radiusWorld;
|
|
1636
|
-
for (const id of
|
|
1673
|
+
for (const id of handles) {
|
|
1637
1674
|
const p = getHandleWorldPosition(localBounds2, id);
|
|
1638
1675
|
const d = Math.hypot(pl.x - p.x, pl.y - p.y);
|
|
1639
1676
|
if (d <= bestD) {
|
|
@@ -3110,7 +3147,8 @@ function hitTestNativeSelectionHandle({
|
|
|
3110
3147
|
worldPoint.x,
|
|
3111
3148
|
worldPoint.y,
|
|
3112
3149
|
handleRadiusWorld,
|
|
3113
|
-
rotation
|
|
3150
|
+
rotation,
|
|
3151
|
+
resolveResizeHandlesForItem(selectedItem)
|
|
3114
3152
|
);
|
|
3115
3153
|
return handle ? { kind: "resize", handle } : null;
|
|
3116
3154
|
}
|
|
@@ -3146,7 +3184,6 @@ function nativeRotationDragStart(input) {
|
|
|
3146
3184
|
startRotation: input.item.rotation ?? 0
|
|
3147
3185
|
};
|
|
3148
3186
|
}
|
|
3149
|
-
var HANDLE_ORDER = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
|
|
3150
3187
|
var ERASER_PREVIEW_OPACITY = 0.3;
|
|
3151
3188
|
var OVERLAY_STROKE_PX = 1.25;
|
|
3152
3189
|
var MARQUEE_DASH_PX = 4;
|
|
@@ -3235,7 +3272,7 @@ function NativeInteractionOverlay({
|
|
|
3235
3272
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.Group, { transform: rotationTransform, origin: rotationOrigin, children: selectionRect }, it.id);
|
|
3236
3273
|
}),
|
|
3237
3274
|
showResizeHandles && bSingle && single && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3238
|
-
|
|
3275
|
+
resolveResizeHandlesForItem(single).map((hid) => {
|
|
3239
3276
|
const p = getHandleWorldPositionRotated(bSingle, hid, rotSingle);
|
|
3240
3277
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNativeSkia.Group, { children: [
|
|
3241
3278
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5032,6 +5069,9 @@ function applyRotationFromPointer(item, startRotation, startPointerAngleRad, poi
|
|
|
5032
5069
|
}
|
|
5033
5070
|
function resizeItemByHandle(item, start, handle, currentWorld) {
|
|
5034
5071
|
const sb = normalizeRect(start.bounds);
|
|
5072
|
+
if (!itemAllowsResizeHandle(item, handle)) {
|
|
5073
|
+
return item;
|
|
5074
|
+
}
|
|
5035
5075
|
const newBoundsRaw = computeNewBoundsForResize(item, sb, handle, currentWorld);
|
|
5036
5076
|
const nb = normalizeRect(newBoundsRaw);
|
|
5037
5077
|
const k = item.toolKind;
|