feat(layers): add layer management panel

This commit is contained in:
syntaxbullet
2026-07-03 17:26:50 +02:00
parent ba3f253ee5
commit fedeaffa57
27 changed files with 1525 additions and 156 deletions

View File

@@ -22,6 +22,7 @@ export function handleArtboardSelection(options: {
}
const artboard = [...options.document.artboards].reverse().find((candidate) => {
if (!candidate.visible || candidate.locked) return false;
const bounds = candidate.bounds;
return point.x >= bounds.x && point.x <= bounds.x + bounds.w && point.y >= bounds.y && point.y <= bounds.y + bounds.h;
});
@@ -37,6 +38,7 @@ export function handleArtboardSelection(options: {
function findTopmostLayerAtPoint(document: ImageDocument, point: { x: number; y: number }) {
for (const artboard of [...document.artboards].reverse()) {
if (!artboard.visible || artboard.locked) continue;
const layerId = findTopmostLayerInTreeAtPoint(document, [...artboard.layers].reverse(), point);
if (layerId) return { artboardId: artboard.id, layerId };
}
@@ -46,6 +48,7 @@ function findTopmostLayerAtPoint(document: ImageDocument, point: { x: number; y:
function findTopmostLayerInTreeAtPoint(document: ImageDocument, layers: Layer[], point: { x: number; y: number }): string | undefined {
for (const layer of layers) {
if (!layer.visible || layer.locked) continue;
if (layer.type === "group") {
const childId = findTopmostLayerInTreeAtPoint(document, [...layer.children].reverse(), point);
if (childId) return childId;