Merge branch 'dev'
This commit is contained in:
commit
e7f655c901
|
|
@ -297,7 +297,7 @@ export class FolkShape extends FolkElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
static GAP = 8; // minimum gap between shapes
|
static GAP = 8; // minimum gap between shapes
|
||||||
static pushExemptTags = new Set(["folk-arrow", "folk-slide"]);
|
static pushExemptTags = new Set(["folk-arrow", "folk-slide", "folk-shape"]);
|
||||||
|
|
||||||
#highlighted = false;
|
#highlighted = false;
|
||||||
get highlighted() {
|
get highlighted() {
|
||||||
|
|
|
||||||
|
|
@ -3828,10 +3828,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect bounding boxes of all visible shapes on the canvas
|
// Collect bounding boxes of all visible shapes on the canvas
|
||||||
|
// Only includes rApps and embedded content — slides, drawings, and arrows are excluded
|
||||||
function getExistingShapeRects() {
|
function getExistingShapeRects() {
|
||||||
return [...canvasContent.children]
|
return [...canvasContent.children]
|
||||||
.filter(el => el.tagName && el.tagName.includes('-') &&
|
.filter(el => el.tagName && el.tagName.includes('-') &&
|
||||||
!el.tagName.toLowerCase().includes('arrow') &&
|
!FolkShape.pushExemptTags.has(el.tagName.toLowerCase()) &&
|
||||||
|
!el.dataset?.wbDrawing &&
|
||||||
typeof el.x === 'number' && typeof el.width === 'number' &&
|
typeof el.x === 'number' && typeof el.width === 'number' &&
|
||||||
el.width > 0)
|
el.width > 0)
|
||||||
.map(el => ({ x: el.x, y: el.y, width: el.width, height: el.height }));
|
.map(el => ({ x: el.x, y: el.y, width: el.width, height: el.height }));
|
||||||
|
|
@ -6869,6 +6871,7 @@
|
||||||
for (const el of canvasContent.children) {
|
for (const el of canvasContent.children) {
|
||||||
if (!(el instanceof FolkShape)) continue;
|
if (!(el instanceof FolkShape)) continue;
|
||||||
if (FolkShape.pushExemptTags.has(el.tagName.toLowerCase())) continue;
|
if (FolkShape.pushExemptTags.has(el.tagName.toLowerCase())) continue;
|
||||||
|
if (el.dataset?.wbDrawing) continue; // wb drawings can overlap freely
|
||||||
shapes.push(el);
|
shapes.push(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6889,16 +6892,31 @@
|
||||||
if (push < REPEL_THRESHOLD) continue;
|
if (push < REPEL_THRESHOLD) continue;
|
||||||
|
|
||||||
const half = push / 2;
|
const half = push / 2;
|
||||||
|
const aLocked = a.locked;
|
||||||
|
const bLocked = b.locked;
|
||||||
|
if (aLocked && bLocked) continue; // both locked, skip
|
||||||
if (ox < oy) {
|
if (ox < oy) {
|
||||||
// Push apart horizontally
|
// Push apart horizontally
|
||||||
const sign = (a.x + a.width / 2) < (b.x + b.width / 2) ? -1 : 1;
|
const sign = (a.x + a.width / 2) < (b.x + b.width / 2) ? -1 : 1;
|
||||||
a.x += sign * half;
|
if (aLocked) {
|
||||||
b.x -= sign * half;
|
b.x -= sign * push;
|
||||||
|
} else if (bLocked) {
|
||||||
|
a.x += sign * push;
|
||||||
|
} else {
|
||||||
|
a.x += sign * half;
|
||||||
|
b.x -= sign * half;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Push apart vertically
|
// Push apart vertically
|
||||||
const sign = (a.y + a.height / 2) < (b.y + b.height / 2) ? -1 : 1;
|
const sign = (a.y + a.height / 2) < (b.y + b.height / 2) ? -1 : 1;
|
||||||
a.y += sign * half;
|
if (aLocked) {
|
||||||
b.y -= sign * half;
|
b.y -= sign * push;
|
||||||
|
} else if (bLocked) {
|
||||||
|
a.y += sign * push;
|
||||||
|
} else {
|
||||||
|
a.y += sign * half;
|
||||||
|
b.y -= sign * half;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue