2024-06-25 23:56:37 +02:00
|
|
|
// Copyright 2024, Command Line Inc.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2024-07-23 22:50:23 +02:00
|
|
|
import { LayoutTreeState } from "frontend/layout/index";
|
2024-06-25 23:56:37 +02:00
|
|
|
|
|
|
|
function findLeafIdFromBlockId(layoutTree: LayoutTreeState<TabLayoutData>, blockId: string): string {
|
|
|
|
if (layoutTree?.leafs == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
for (let leaf of layoutTree.leafs) {
|
|
|
|
if (leaf.data.blockId == blockId) {
|
|
|
|
return leaf.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-08-01 22:46:06 +02:00
|
|
|
function isBlockMagnified(layoutTree: LayoutTreeState<TabLayoutData>, blockId: string): boolean {
|
|
|
|
if (layoutTree?.leafs == null || layoutTree.magnifiedNodeId == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (let leaf of layoutTree.leafs) {
|
|
|
|
if (leaf.data.blockId == blockId) {
|
|
|
|
return layoutTree.magnifiedNodeId == leaf.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
export { findLeafIdFromBlockId, isBlockMagnified };
|