canvu-react 0.4.65 → 0.4.67
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/chatbot.d.cts +1 -1
- package/dist/chatbot.d.ts +1 -1
- package/dist/react.cjs +241 -79
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +28 -28
- package/dist/react.d.ts +28 -28
- package/dist/react.js +242 -81
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +1 -1
- package/dist/realtime.d.ts +1 -1
- package/dist/realtime.js.map +1 -1
- package/dist/{types-BZUp3LpC.d.ts → types-B-Jdh-n6.d.ts} +166 -1
- package/dist/{types-Bw3REwrb.d.cts → types-D5d-3dvz.d.cts} +166 -1
- package/package.json +1 -1
package/dist/chatbot.d.cts
CHANGED
package/dist/chatbot.d.ts
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -3223,6 +3223,30 @@ function createToolPlugin(options) {
|
|
|
3223
3223
|
}
|
|
3224
3224
|
});
|
|
3225
3225
|
}
|
|
3226
|
+
|
|
3227
|
+
// src/react/merge-by-id.ts
|
|
3228
|
+
function mergeById(baseItems, ...contributions) {
|
|
3229
|
+
const next = [...baseItems];
|
|
3230
|
+
const indexById = /* @__PURE__ */ new Map();
|
|
3231
|
+
for (const [index, item] of next.entries()) {
|
|
3232
|
+
if (!indexById.has(item.id)) {
|
|
3233
|
+
indexById.set(item.id, index);
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
for (const contribution of contributions) {
|
|
3237
|
+
if (!contribution?.length) continue;
|
|
3238
|
+
for (const item of contribution) {
|
|
3239
|
+
const existingIndex = indexById.get(item.id);
|
|
3240
|
+
if (existingIndex !== void 0) {
|
|
3241
|
+
next[existingIndex] = item;
|
|
3242
|
+
continue;
|
|
3243
|
+
}
|
|
3244
|
+
indexById.set(item.id, next.length);
|
|
3245
|
+
next.push(item);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
return next;
|
|
3249
|
+
}
|
|
3226
3250
|
var menuStyle = {
|
|
3227
3251
|
position: "fixed",
|
|
3228
3252
|
zIndex: 1e4,
|
|
@@ -3252,9 +3276,97 @@ var dividerStyle = {
|
|
|
3252
3276
|
margin: "4px 8px",
|
|
3253
3277
|
background: "#e2e8f0"
|
|
3254
3278
|
};
|
|
3279
|
+
var SHAPE_CONTEXT_MENU_ITEM_IDS = {
|
|
3280
|
+
cut: "cut",
|
|
3281
|
+
copy: "copy",
|
|
3282
|
+
duplicate: "duplicate",
|
|
3283
|
+
reorderDivider: "reorder-divider",
|
|
3284
|
+
bringToFront: "bring-to-front",
|
|
3285
|
+
bringForward: "bring-forward",
|
|
3286
|
+
sendBackward: "send-backward",
|
|
3287
|
+
sendToBack: "send-to-back",
|
|
3288
|
+
lockDivider: "lock-divider",
|
|
3289
|
+
toggleLock: "toggle-lock",
|
|
3290
|
+
delete: "delete"
|
|
3291
|
+
};
|
|
3292
|
+
function renderAction(label, onClick, options) {
|
|
3293
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3294
|
+
"button",
|
|
3295
|
+
{
|
|
3296
|
+
type: "button",
|
|
3297
|
+
role: "menuitem",
|
|
3298
|
+
style: {
|
|
3299
|
+
...itemStyle,
|
|
3300
|
+
...options?.danger ? { color: "#b91c1c" } : {}
|
|
3301
|
+
},
|
|
3302
|
+
onMouseEnter: (e) => {
|
|
3303
|
+
e.currentTarget.style.background = options?.danger ? "#fef2f2" : "#f1f5f9";
|
|
3304
|
+
},
|
|
3305
|
+
onMouseLeave: (e) => {
|
|
3306
|
+
e.currentTarget.style.background = "transparent";
|
|
3307
|
+
},
|
|
3308
|
+
onClick,
|
|
3309
|
+
children: label
|
|
3310
|
+
}
|
|
3311
|
+
);
|
|
3312
|
+
}
|
|
3313
|
+
function renderDivider() {
|
|
3314
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, style: dividerStyle });
|
|
3315
|
+
}
|
|
3316
|
+
var DEFAULT_SHAPE_CONTEXT_MENU_ITEMS = [
|
|
3317
|
+
{
|
|
3318
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.cut,
|
|
3319
|
+
render: (ctx) => renderAction("Recortar", ctx.cut)
|
|
3320
|
+
},
|
|
3321
|
+
{
|
|
3322
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.copy,
|
|
3323
|
+
render: (ctx) => renderAction("Copiar", ctx.copy)
|
|
3324
|
+
},
|
|
3325
|
+
{
|
|
3326
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.duplicate,
|
|
3327
|
+
render: (ctx) => renderAction("Duplicar", ctx.duplicate)
|
|
3328
|
+
},
|
|
3329
|
+
{
|
|
3330
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.reorderDivider,
|
|
3331
|
+
render: renderDivider
|
|
3332
|
+
},
|
|
3333
|
+
{
|
|
3334
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.bringToFront,
|
|
3335
|
+
render: (ctx) => renderAction("Trazer para frente", ctx.bringToFront)
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.bringForward,
|
|
3339
|
+
render: (ctx) => renderAction("Avancar uma camada", ctx.bringForward)
|
|
3340
|
+
},
|
|
3341
|
+
{
|
|
3342
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.sendBackward,
|
|
3343
|
+
render: (ctx) => renderAction("Recuar uma camada", ctx.sendBackward)
|
|
3344
|
+
},
|
|
3345
|
+
{
|
|
3346
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.sendToBack,
|
|
3347
|
+
render: (ctx) => renderAction("Enviar para tras", ctx.sendToBack)
|
|
3348
|
+
},
|
|
3349
|
+
{
|
|
3350
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.lockDivider,
|
|
3351
|
+
render: renderDivider
|
|
3352
|
+
},
|
|
3353
|
+
{
|
|
3354
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.toggleLock,
|
|
3355
|
+
render: (ctx) => renderAction(
|
|
3356
|
+
ctx.allSelectedLocked ? "Desbloquear" : "Bloquear",
|
|
3357
|
+
ctx.toggleLock
|
|
3358
|
+
)
|
|
3359
|
+
},
|
|
3360
|
+
{
|
|
3361
|
+
id: SHAPE_CONTEXT_MENU_ITEM_IDS.delete,
|
|
3362
|
+
render: (ctx) => renderAction("Apagar", ctx.delete, { danger: true })
|
|
3363
|
+
}
|
|
3364
|
+
];
|
|
3255
3365
|
function ShapeContextMenu({
|
|
3256
3366
|
x,
|
|
3257
3367
|
y,
|
|
3368
|
+
selectedIds,
|
|
3369
|
+
selectedItems = [],
|
|
3258
3370
|
allSelectedLocked,
|
|
3259
3371
|
onClose,
|
|
3260
3372
|
onToggleLock,
|
|
@@ -3265,7 +3377,10 @@ function ShapeContextMenu({
|
|
|
3265
3377
|
onSendBackward,
|
|
3266
3378
|
onSendToBack,
|
|
3267
3379
|
onDuplicate,
|
|
3268
|
-
onDelete
|
|
3380
|
+
onDelete,
|
|
3381
|
+
items,
|
|
3382
|
+
itemContributions,
|
|
3383
|
+
children
|
|
3269
3384
|
}) {
|
|
3270
3385
|
const rootRef = react.useRef(null);
|
|
3271
3386
|
react.useLayoutEffect(() => {
|
|
@@ -3305,49 +3420,43 @@ function ShapeContextMenu({
|
|
|
3305
3420
|
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
3306
3421
|
};
|
|
3307
3422
|
}, [onClose]);
|
|
3423
|
+
const menuItems = react.useMemo(
|
|
3424
|
+
() => mergeById(items ?? DEFAULT_SHAPE_CONTEXT_MENU_ITEMS, itemContributions),
|
|
3425
|
+
[itemContributions, items]
|
|
3426
|
+
);
|
|
3308
3427
|
const run = (fn) => () => {
|
|
3309
3428
|
fn();
|
|
3310
3429
|
onClose();
|
|
3311
3430
|
};
|
|
3312
|
-
const
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3431
|
+
const resolvedSelectedIds = selectedIds ?? selectedItems.map((item) => item.id);
|
|
3432
|
+
const resolvedAllSelectedLocked = allSelectedLocked ?? (selectedItems.length > 0 && selectedItems.every((item) => item.locked));
|
|
3433
|
+
const menuContext = {
|
|
3434
|
+
position: { x, y },
|
|
3435
|
+
selectedIds: resolvedSelectedIds,
|
|
3436
|
+
selectedItems,
|
|
3437
|
+
allSelectedLocked: resolvedAllSelectedLocked,
|
|
3438
|
+
anySelectedLocked: selectedItems.some((item) => item.locked),
|
|
3439
|
+
close: onClose,
|
|
3440
|
+
cut: run(onCut),
|
|
3441
|
+
copy: run(onCopy),
|
|
3442
|
+
duplicate: run(onDuplicate),
|
|
3443
|
+
toggleLock: run(onToggleLock),
|
|
3444
|
+
bringToFront: run(onBringToFront),
|
|
3445
|
+
bringForward: run(onBringForward),
|
|
3446
|
+
sendBackward: run(onSendBackward),
|
|
3447
|
+
sendToBack: run(onSendToBack),
|
|
3448
|
+
delete: run(onDelete),
|
|
3449
|
+
deleteSelection: run(onDelete)
|
|
3450
|
+
};
|
|
3451
|
+
const content = typeof children === "function" ? children(menuContext) : children !== void 0 ? children : menuItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: item.render(menuContext) }, item.id));
|
|
3452
|
+
const menu = /* @__PURE__ */ jsxRuntime.jsx(
|
|
3332
3453
|
"div",
|
|
3333
3454
|
{
|
|
3334
3455
|
ref: rootRef,
|
|
3335
3456
|
"data-slot": "shape-context-menu",
|
|
3336
3457
|
style: { ...menuStyle, left: x, top: y },
|
|
3337
3458
|
role: "menu",
|
|
3338
|
-
children:
|
|
3339
|
-
renderAction("Recortar", onCut),
|
|
3340
|
-
renderAction("Copiar", onCopy),
|
|
3341
|
-
renderAction("Duplicar", onDuplicate),
|
|
3342
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, style: dividerStyle }),
|
|
3343
|
-
renderAction("Trazer para frente", onBringToFront),
|
|
3344
|
-
renderAction("Avancar uma camada", onBringForward),
|
|
3345
|
-
renderAction("Recuar uma camada", onSendBackward),
|
|
3346
|
-
renderAction("Enviar para tras", onSendToBack),
|
|
3347
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, style: dividerStyle }),
|
|
3348
|
-
renderAction(allSelectedLocked ? "Desbloquear" : "Bloquear", onToggleLock),
|
|
3349
|
-
renderAction("Apagar", onDelete, { danger: true })
|
|
3350
|
-
]
|
|
3459
|
+
children: content
|
|
3351
3460
|
}
|
|
3352
3461
|
);
|
|
3353
3462
|
if (typeof document === "undefined") {
|
|
@@ -5062,6 +5171,7 @@ function VectorToolbarComponent({
|
|
|
5062
5171
|
value,
|
|
5063
5172
|
onChange,
|
|
5064
5173
|
tools,
|
|
5174
|
+
toolContributions,
|
|
5065
5175
|
overflowToolIds = DEFAULT_OVERFLOW_TOOL_IDS,
|
|
5066
5176
|
overflowMenuAriaLabel = "More tools",
|
|
5067
5177
|
"aria-label": ariaLabel = "Canvas tools",
|
|
@@ -5079,7 +5189,10 @@ function VectorToolbarComponent({
|
|
|
5079
5189
|
}) {
|
|
5080
5190
|
const pluginContext = react.useContext(CanvuPluginContext);
|
|
5081
5191
|
const runtimeTools = pluginContext?.resolvedTools;
|
|
5082
|
-
const resolvedTools =
|
|
5192
|
+
const resolvedTools = react.useMemo(
|
|
5193
|
+
() => mergeById(tools ?? runtimeTools ?? DEFAULT_VECTOR_TOOLS, toolContributions),
|
|
5194
|
+
[runtimeTools, toolContributions, tools]
|
|
5195
|
+
);
|
|
5083
5196
|
const { primary: primaryTools, overflow: overflowTools } = splitToolbarTools(
|
|
5084
5197
|
resolvedTools,
|
|
5085
5198
|
overflowToolIds
|
|
@@ -8117,18 +8230,6 @@ function isDefaultMarkerToolStyle(style) {
|
|
|
8117
8230
|
function tagCustomPlacementItem(item, toolId) {
|
|
8118
8231
|
return item.customToolId === toolId ? item : { ...item, customToolId: toolId };
|
|
8119
8232
|
}
|
|
8120
|
-
function mergeToolListById(baseTools, pluginTools) {
|
|
8121
|
-
const next = [...baseTools];
|
|
8122
|
-
for (const tool of pluginTools) {
|
|
8123
|
-
const index = next.findIndex((candidate) => candidate.id === tool.id);
|
|
8124
|
-
if (index >= 0) {
|
|
8125
|
-
next[index] = tool;
|
|
8126
|
-
continue;
|
|
8127
|
-
}
|
|
8128
|
-
next.push(tool);
|
|
8129
|
-
}
|
|
8130
|
-
return next;
|
|
8131
|
-
}
|
|
8132
8233
|
function composePluginEvent(consumerHandler, pluginHandlers) {
|
|
8133
8234
|
const activePluginHandlers = pluginHandlers.filter(
|
|
8134
8235
|
(handler) => handler != null
|
|
@@ -8256,6 +8357,8 @@ var VectorViewport = react.forwardRef(
|
|
|
8256
8357
|
navMenu,
|
|
8257
8358
|
selectionInspector,
|
|
8258
8359
|
selectionInspectorProps,
|
|
8360
|
+
contextMenu: renderContextMenu,
|
|
8361
|
+
contextMenuItems: consumerContextMenuItems,
|
|
8259
8362
|
plugins = [],
|
|
8260
8363
|
onCameraChange: consumerOnCameraChange,
|
|
8261
8364
|
customPlacement: consumerCustomPlacement,
|
|
@@ -8314,7 +8417,7 @@ var VectorViewport = react.forwardRef(
|
|
|
8314
8417
|
let nextTools = [...DEFAULT_VECTOR_TOOLS];
|
|
8315
8418
|
for (const contribution of orderedPluginContributions) {
|
|
8316
8419
|
if (contribution.tools?.length) {
|
|
8317
|
-
nextTools =
|
|
8420
|
+
nextTools = mergeById(nextTools, contribution.tools);
|
|
8318
8421
|
}
|
|
8319
8422
|
if (contribution.toolTransform) {
|
|
8320
8423
|
nextTools = contribution.toolTransform(nextTools);
|
|
@@ -8322,6 +8425,16 @@ var VectorViewport = react.forwardRef(
|
|
|
8322
8425
|
}
|
|
8323
8426
|
return nextTools;
|
|
8324
8427
|
}, [orderedPluginContributions]);
|
|
8428
|
+
const resolvedContextMenuItems = react.useMemo(
|
|
8429
|
+
() => mergeById(
|
|
8430
|
+
DEFAULT_SHAPE_CONTEXT_MENU_ITEMS,
|
|
8431
|
+
...orderedPluginContributions.map(
|
|
8432
|
+
(contribution) => contribution.contextMenuItems
|
|
8433
|
+
),
|
|
8434
|
+
consumerContextMenuItems
|
|
8435
|
+
),
|
|
8436
|
+
[consumerContextMenuItems, orderedPluginContributions]
|
|
8437
|
+
);
|
|
8325
8438
|
const allCustomPlacements = react.useMemo(() => {
|
|
8326
8439
|
const placements = [];
|
|
8327
8440
|
if (consumerCustomPlacement) placements.push(consumerCustomPlacement);
|
|
@@ -8501,7 +8614,7 @@ var VectorViewport = react.forwardRef(
|
|
|
8501
8614
|
isUndoingRef.current = true;
|
|
8502
8615
|
onItemsChangeRef.current?.(next, { motive: "redo" });
|
|
8503
8616
|
}, []);
|
|
8504
|
-
const [
|
|
8617
|
+
const [contextMenuState, setContextMenuState] = react.useState(null);
|
|
8505
8618
|
const [uncontrolledSel, setUncontrolledSel] = react.useState([]);
|
|
8506
8619
|
const isSelectionControlled = onSelectionChange !== void 0;
|
|
8507
8620
|
const controlledSelectedKey = JSON.stringify(selectedIdsProp ?? []);
|
|
@@ -9668,15 +9781,26 @@ var VectorViewport = react.forwardRef(
|
|
|
9668
9781
|
if (!cam) return;
|
|
9669
9782
|
const { worldX, worldY } = screenToWorld(e.clientX, e.clientY);
|
|
9670
9783
|
const lineHitWorld = 10 / cam.zoom;
|
|
9784
|
+
const cur = effectiveSelectedIdsRef.current;
|
|
9671
9785
|
const hit = hitTestWorldPoint(resolvedItemsRef.current, worldX, worldY, {
|
|
9672
9786
|
lineHitWorld,
|
|
9673
9787
|
ignoreLocked: true
|
|
9674
9788
|
});
|
|
9675
9789
|
if (!hit) {
|
|
9676
|
-
|
|
9790
|
+
const selectedUnlockedItems = cur.map((id) => resolvedItemsRef.current.find((item) => item.id === id)).filter((item) => item != null && !item.locked);
|
|
9791
|
+
if (selectedUnlockedItems.some(
|
|
9792
|
+
(item) => pointInSelectedItemBounds(item, worldX, worldY)
|
|
9793
|
+
)) {
|
|
9794
|
+
setContextMenuState({
|
|
9795
|
+
x: e.clientX,
|
|
9796
|
+
y: e.clientY,
|
|
9797
|
+
itemIds: [...cur]
|
|
9798
|
+
});
|
|
9799
|
+
return;
|
|
9800
|
+
}
|
|
9801
|
+
setContextMenuState(null);
|
|
9677
9802
|
return;
|
|
9678
9803
|
}
|
|
9679
|
-
const cur = effectiveSelectedIdsRef.current;
|
|
9680
9804
|
let nextIds;
|
|
9681
9805
|
if (!cur.includes(hit.id)) {
|
|
9682
9806
|
nextIds = e.shiftKey ? [...cur, hit.id] : [hit.id];
|
|
@@ -9684,7 +9808,7 @@ var VectorViewport = react.forwardRef(
|
|
|
9684
9808
|
} else {
|
|
9685
9809
|
nextIds = cur;
|
|
9686
9810
|
}
|
|
9687
|
-
|
|
9811
|
+
setContextMenuState({
|
|
9688
9812
|
x: e.clientX,
|
|
9689
9813
|
y: e.clientY,
|
|
9690
9814
|
itemIds: nextIds
|
|
@@ -10234,7 +10358,7 @@ var VectorViewport = react.forwardRef(
|
|
|
10234
10358
|
if (e.button !== 0) return;
|
|
10235
10359
|
if (editingTextIdRef.current) return;
|
|
10236
10360
|
wrapperRef.current?.focus({ preventScroll: true });
|
|
10237
|
-
|
|
10361
|
+
setContextMenuState(null);
|
|
10238
10362
|
const tool = toolIdRef.current;
|
|
10239
10363
|
if (tool === "hand") return;
|
|
10240
10364
|
if (applePencilNav && e.pointerType === "pen" && navigator.maxTouchPoints > 0 && (tool === "draw" || tool === "marker")) {
|
|
@@ -10654,7 +10778,7 @@ var VectorViewport = react.forwardRef(
|
|
|
10654
10778
|
return;
|
|
10655
10779
|
}
|
|
10656
10780
|
wrapperRef.current?.focus({ preventScroll: true });
|
|
10657
|
-
|
|
10781
|
+
setContextMenuState(null);
|
|
10658
10782
|
const straightLine = tool === "draw" ? createStraightStrokeState(startPoint, e.clientX, e.clientY) : void 0;
|
|
10659
10783
|
const itemId = createShapeId();
|
|
10660
10784
|
const item = createFreehandStrokeItem(
|
|
@@ -10777,7 +10901,7 @@ var VectorViewport = react.forwardRef(
|
|
|
10777
10901
|
return;
|
|
10778
10902
|
}
|
|
10779
10903
|
wrapperRef.current?.focus({ preventScroll: true });
|
|
10780
|
-
|
|
10904
|
+
setContextMenuState(null);
|
|
10781
10905
|
penDetectedRef.current = true;
|
|
10782
10906
|
const straightLine = tool === "draw" ? createStraightStrokeState(startPoint, touch.clientX, touch.clientY) : void 0;
|
|
10783
10907
|
const itemId = createShapeId();
|
|
@@ -11817,6 +11941,66 @@ var VectorViewport = react.forwardRef(
|
|
|
11817
11941
|
const defaultNavMenu = cameraForOverlay ? /* @__PURE__ */ jsxRuntime.jsx(NavMenu, {}) : null;
|
|
11818
11942
|
const resolvedSelectionInspector = selectionInspector === void 0 ? defaultSelectionInspector : selectionInspector;
|
|
11819
11943
|
const resolvedNavMenu = navMenu === void 0 ? defaultNavMenu : navMenu;
|
|
11944
|
+
const contextMenuItemIds = contextMenuState?.itemIds ?? [];
|
|
11945
|
+
const contextMenuSelectedItems = contextMenuState ? contextMenuItemIds.map((id) => items.find((item) => item.id === id)).filter((item) => item != null) : [];
|
|
11946
|
+
const allContextMenuSelectedLocked = contextMenuItemIds.length > 0 && contextMenuItemIds.every((id) => items.find((item) => item.id === id)?.locked);
|
|
11947
|
+
const closeContextMenu = () => setContextMenuState(null);
|
|
11948
|
+
const runContextMenuAction = (fn) => () => {
|
|
11949
|
+
fn();
|
|
11950
|
+
closeContextMenu();
|
|
11951
|
+
};
|
|
11952
|
+
const contextMenuRenderContext = contextMenuState ? {
|
|
11953
|
+
position: { x: contextMenuState.x, y: contextMenuState.y },
|
|
11954
|
+
selectedIds: contextMenuItemIds,
|
|
11955
|
+
selectedItems: contextMenuSelectedItems,
|
|
11956
|
+
allSelectedLocked: allContextMenuSelectedLocked,
|
|
11957
|
+
anySelectedLocked: contextMenuSelectedItems.some((item) => item.locked),
|
|
11958
|
+
close: closeContextMenu,
|
|
11959
|
+
cut: runContextMenuAction(() => cutIds(contextMenuItemIds)),
|
|
11960
|
+
copy: runContextMenuAction(
|
|
11961
|
+
() => copyIdsToInternalClipboard(contextMenuItemIds)
|
|
11962
|
+
),
|
|
11963
|
+
duplicate: runContextMenuAction(() => duplicateIds(contextMenuItemIds)),
|
|
11964
|
+
toggleLock: runContextMenuAction(
|
|
11965
|
+
() => setLockedOnIds(contextMenuItemIds, !allContextMenuSelectedLocked)
|
|
11966
|
+
),
|
|
11967
|
+
bringToFront: runContextMenuAction(
|
|
11968
|
+
() => reorderIds(contextMenuItemIds, "front")
|
|
11969
|
+
),
|
|
11970
|
+
bringForward: runContextMenuAction(
|
|
11971
|
+
() => reorderIds(contextMenuItemIds, "forward")
|
|
11972
|
+
),
|
|
11973
|
+
sendBackward: runContextMenuAction(
|
|
11974
|
+
() => reorderIds(contextMenuItemIds, "backward")
|
|
11975
|
+
),
|
|
11976
|
+
sendToBack: runContextMenuAction(
|
|
11977
|
+
() => reorderIds(contextMenuItemIds, "back")
|
|
11978
|
+
),
|
|
11979
|
+
delete: runContextMenuAction(() => deleteIds(contextMenuItemIds)),
|
|
11980
|
+
deleteSelection: runContextMenuAction(() => deleteIds(contextMenuItemIds)),
|
|
11981
|
+
items: resolvedContextMenuItems
|
|
11982
|
+
} : null;
|
|
11983
|
+
const resolvedContextMenu = interactive && onItemsChange && contextMenuState && contextMenuRenderContext && renderContextMenu !== null ? renderContextMenu ? renderContextMenu(contextMenuRenderContext) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
11984
|
+
ShapeContextMenu,
|
|
11985
|
+
{
|
|
11986
|
+
x: contextMenuState.x,
|
|
11987
|
+
y: contextMenuState.y,
|
|
11988
|
+
selectedIds: contextMenuItemIds,
|
|
11989
|
+
selectedItems: contextMenuSelectedItems,
|
|
11990
|
+
allSelectedLocked: allContextMenuSelectedLocked,
|
|
11991
|
+
items: resolvedContextMenuItems,
|
|
11992
|
+
onClose: closeContextMenu,
|
|
11993
|
+
onToggleLock: () => setLockedOnIds(contextMenuItemIds, !allContextMenuSelectedLocked),
|
|
11994
|
+
onCut: () => cutIds(contextMenuItemIds),
|
|
11995
|
+
onCopy: () => copyIdsToInternalClipboard(contextMenuItemIds),
|
|
11996
|
+
onBringToFront: () => reorderIds(contextMenuItemIds, "front"),
|
|
11997
|
+
onBringForward: () => reorderIds(contextMenuItemIds, "forward"),
|
|
11998
|
+
onSendBackward: () => reorderIds(contextMenuItemIds, "backward"),
|
|
11999
|
+
onSendToBack: () => reorderIds(contextMenuItemIds, "back"),
|
|
12000
|
+
onDuplicate: () => duplicateIds(contextMenuItemIds),
|
|
12001
|
+
onDelete: () => deleteIds(contextMenuItemIds)
|
|
12002
|
+
}
|
|
12003
|
+
) : null;
|
|
11820
12004
|
return /* @__PURE__ */ jsxRuntime.jsx(CanvuPluginContext.Provider, { value: pluginContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(CanvuChromeContext.Provider, { value: chromeContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11821
12005
|
"div",
|
|
11822
12006
|
{
|
|
@@ -11970,30 +12154,7 @@ var VectorViewport = react.forwardRef(
|
|
|
11970
12154
|
}
|
|
11971
12155
|
),
|
|
11972
12156
|
resolvedSelectionInspector,
|
|
11973
|
-
|
|
11974
|
-
ShapeContextMenu,
|
|
11975
|
-
{
|
|
11976
|
-
x: contextMenu.x,
|
|
11977
|
-
y: contextMenu.y,
|
|
11978
|
-
allSelectedLocked: contextMenu.itemIds.length > 0 && contextMenu.itemIds.every(
|
|
11979
|
-
(id) => items.find((i) => i.id === id)?.locked
|
|
11980
|
-
),
|
|
11981
|
-
onClose: () => setContextMenu(null),
|
|
11982
|
-
onToggleLock: () => {
|
|
11983
|
-
const ids = contextMenu.itemIds;
|
|
11984
|
-
const allLocked = ids.length > 0 && ids.every((id) => items.find((i) => i.id === id)?.locked);
|
|
11985
|
-
setLockedOnIds(ids, !allLocked);
|
|
11986
|
-
},
|
|
11987
|
-
onCut: () => cutIds(contextMenu.itemIds),
|
|
11988
|
-
onCopy: () => copyIdsToInternalClipboard(contextMenu.itemIds),
|
|
11989
|
-
onBringToFront: () => reorderIds(contextMenu.itemIds, "front"),
|
|
11990
|
-
onBringForward: () => reorderIds(contextMenu.itemIds, "forward"),
|
|
11991
|
-
onSendBackward: () => reorderIds(contextMenu.itemIds, "backward"),
|
|
11992
|
-
onSendToBack: () => reorderIds(contextMenu.itemIds, "back"),
|
|
11993
|
-
onDuplicate: () => duplicateIds(contextMenu.itemIds),
|
|
11994
|
-
onDelete: () => deleteIds(contextMenu.itemIds)
|
|
11995
|
-
}
|
|
11996
|
-
),
|
|
12157
|
+
resolvedContextMenu,
|
|
11997
12158
|
resolvedNavMenu,
|
|
11998
12159
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11999
12160
|
"div",
|
|
@@ -12030,6 +12191,7 @@ exports.IconSelect = IconSelect;
|
|
|
12030
12191
|
exports.IconText = IconText;
|
|
12031
12192
|
exports.ImagesMenu = ImagesMenu;
|
|
12032
12193
|
exports.NavMenu = NavMenu;
|
|
12194
|
+
exports.SHAPE_CONTEXT_MENU_ITEM_IDS = SHAPE_CONTEXT_MENU_ITEM_IDS;
|
|
12033
12195
|
exports.ShapeContextMenu = ShapeContextMenu;
|
|
12034
12196
|
exports.VectorCanvas = VectorCanvas;
|
|
12035
12197
|
exports.VectorCanvasBody = VectorCanvasBody;
|