feat(layers): add layer management panel
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user