@woven-canvas/core 1.0.15 → 1.1.0
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/build/_tsup-dts-rollup.d.cts +8 -0
- package/build/_tsup-dts-rollup.d.ts +8 -0
- package/build/index.cjs +37 -1
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +36 -1
- package/build/index.js.map +1 -1
- package/package.json +3 -3
package/build/index.d.cts
CHANGED
|
@@ -141,6 +141,7 @@ export { createBlock } from './_tsup-dts-rollup.cjs';
|
|
|
141
141
|
export { deselectAll } from './_tsup-dts-rollup.cjs';
|
|
142
142
|
export { deselectBlock } from './_tsup-dts-rollup.cjs';
|
|
143
143
|
export { detectEmbedProvider } from './_tsup-dts-rollup.cjs';
|
|
144
|
+
export { filterRoots } from './_tsup-dts-rollup.cjs';
|
|
144
145
|
export { findFrameAtPoint } from './_tsup-dts-rollup.cjs';
|
|
145
146
|
export { generateUuidBySeed } from './_tsup-dts-rollup.cjs';
|
|
146
147
|
export { getBlockDef } from './_tsup-dts-rollup.cjs';
|
package/build/index.d.ts
CHANGED
|
@@ -141,6 +141,7 @@ export { createBlock } from './_tsup-dts-rollup.js';
|
|
|
141
141
|
export { deselectAll } from './_tsup-dts-rollup.js';
|
|
142
142
|
export { deselectBlock } from './_tsup-dts-rollup.js';
|
|
143
143
|
export { detectEmbedProvider } from './_tsup-dts-rollup.js';
|
|
144
|
+
export { filterRoots } from './_tsup-dts-rollup.js';
|
|
144
145
|
export { findFrameAtPoint } from './_tsup-dts-rollup.js';
|
|
145
146
|
export { generateUuidBySeed } from './_tsup-dts-rollup.js';
|
|
146
147
|
export { getBlockDef } from './_tsup-dts-rollup.js';
|
package/build/index.js
CHANGED
|
@@ -483,6 +483,7 @@ var BlockDef = z.object({
|
|
|
483
483
|
canScale: z.boolean().default(true),
|
|
484
484
|
snappable: z.boolean().default(true),
|
|
485
485
|
interactable: z.boolean().default(true),
|
|
486
|
+
showOperations: z.boolean().default(true),
|
|
486
487
|
excludeFromRankBounds: z.boolean().default(false),
|
|
487
488
|
connectors: BlockDefConnectors.default(BlockDefConnectors.parse({}))
|
|
488
489
|
});
|
|
@@ -3165,6 +3166,21 @@ function getDescendants(ctx, parentId) {
|
|
|
3165
3166
|
}
|
|
3166
3167
|
return result;
|
|
3167
3168
|
}
|
|
3169
|
+
function filterRoots(ctx, entityIds) {
|
|
3170
|
+
const idSet = new Set(entityIds);
|
|
3171
|
+
return entityIds.filter((entityId) => {
|
|
3172
|
+
if (!hasComponent3(ctx, entityId, Block)) return false;
|
|
3173
|
+
let current = Block.read(ctx, entityId).parentId;
|
|
3174
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3175
|
+
while (current !== null && hasComponent3(ctx, current, Block)) {
|
|
3176
|
+
if (idSet.has(current)) return false;
|
|
3177
|
+
if (visited.has(current)) break;
|
|
3178
|
+
visited.add(current);
|
|
3179
|
+
current = Block.read(ctx, current).parentId;
|
|
3180
|
+
}
|
|
3181
|
+
return true;
|
|
3182
|
+
});
|
|
3183
|
+
}
|
|
3168
3184
|
function cascadeDelete(ctx, entityId) {
|
|
3169
3185
|
const children = getBackrefs(ctx, entityId, Block, "parentId");
|
|
3170
3186
|
for (const childId of children) {
|
|
@@ -5799,6 +5815,7 @@ var blockSystem = defineEditorSystem({ phase: "update" }, (ctx) => {
|
|
|
5799
5815
|
}
|
|
5800
5816
|
}
|
|
5801
5817
|
});
|
|
5818
|
+
on(ctx, DuplicateSelected, duplicateSelected);
|
|
5802
5819
|
on(ctx, BringForwardSelected, bringForwardSelected);
|
|
5803
5820
|
on(ctx, SendBackwardSelected, sendBackwardSelected);
|
|
5804
5821
|
on(ctx, SetCursor, (ctx2, payload) => {
|
|
@@ -5824,6 +5841,23 @@ function deselectAllBlocks(ctx) {
|
|
|
5824
5841
|
deselectBlock(ctx, entityId);
|
|
5825
5842
|
}
|
|
5826
5843
|
}
|
|
5844
|
+
var DUPLICATE_OFFSET = 20;
|
|
5845
|
+
function duplicateSelected(ctx) {
|
|
5846
|
+
const selectedBlocks = [...selectedBlocksQuery4.current(ctx)];
|
|
5847
|
+
if (selectedBlocks.length === 0) return;
|
|
5848
|
+
cloneEntities(ctx, selectedBlocks, [0, 0], crypto.randomUUID());
|
|
5849
|
+
const grid = Grid.read(ctx);
|
|
5850
|
+
const offset = grid.enabled && grid.colWidth > 0 && grid.rowHeight > 0 ? [grid.colWidth, grid.rowHeight] : [DUPLICATE_OFFSET, DUPLICATE_OFFSET];
|
|
5851
|
+
for (const entityId of filterRoots(ctx, selectedBlocks)) {
|
|
5852
|
+
const worldPos = Block.getWorldPosition(ctx, entityId);
|
|
5853
|
+
Vec25.add(worldPos, offset);
|
|
5854
|
+
Block.setWorldPosition(ctx, entityId, worldPos);
|
|
5855
|
+
}
|
|
5856
|
+
const { transformBoxId } = TransformBoxStateSingleton.read(ctx);
|
|
5857
|
+
if (transformBoxId !== null) {
|
|
5858
|
+
UpdateTransformBox.spawn(ctx, { transformBoxId });
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
5827
5861
|
function bringForwardSelected(ctx) {
|
|
5828
5862
|
const selectedBlocks = [...selectedBlocksQuery4.current(ctx)];
|
|
5829
5863
|
if (selectedBlocks.length === 0) return;
|
|
@@ -5861,7 +5895,6 @@ function sendBackwardSelected(ctx) {
|
|
|
5861
5895
|
}
|
|
5862
5896
|
}
|
|
5863
5897
|
function cloneEntities(ctx, entityIds, offset, seed) {
|
|
5864
|
-
const rootSet = new Set(entityIds);
|
|
5865
5898
|
const allEntityIdsSet = new Set(entityIds);
|
|
5866
5899
|
for (const entityId of entityIds) {
|
|
5867
5900
|
for (const descendant of getDescendants(ctx, entityId)) {
|
|
@@ -5869,6 +5902,7 @@ function cloneEntities(ctx, entityIds, offset, seed) {
|
|
|
5869
5902
|
}
|
|
5870
5903
|
}
|
|
5871
5904
|
entityIds = [...allEntityIdsSet];
|
|
5905
|
+
const rootSet = new Set(filterRoots(ctx, entityIds));
|
|
5872
5906
|
const { componentsById } = getResources13(ctx);
|
|
5873
5907
|
const documentComponents = new Map([...componentsById].filter(([, def]) => def.sync === "document"));
|
|
5874
5908
|
const syncedComponentId = Synced7._getComponentId(ctx);
|
|
@@ -7283,6 +7317,7 @@ export {
|
|
|
7283
7317
|
deselectBlock,
|
|
7284
7318
|
detectEmbedProvider,
|
|
7285
7319
|
field37 as field,
|
|
7320
|
+
filterRoots,
|
|
7286
7321
|
findFrameAtPoint,
|
|
7287
7322
|
generateUuidBySeed,
|
|
7288
7323
|
getBackrefs5 as getBackrefs,
|