2024-06-25 23:56:37 +02:00
|
|
|
// Copyright 2024, Command Line Inc.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2024-08-15 03:40:41 +02:00
|
|
|
import { LayoutModel } from "@/layout/index";
|
2024-06-25 23:56:37 +02:00
|
|
|
|
2024-08-15 03:40:41 +02:00
|
|
|
function findLeafIdFromBlockId(layoutModel: LayoutModel, blockId: string): string {
|
|
|
|
if (layoutModel?.leafs == null) {
|
2024-06-25 23:56:37 +02:00
|
|
|
return null;
|
|
|
|
}
|
2024-08-15 03:40:41 +02:00
|
|
|
for (const leaf of layoutModel.leafs) {
|
2024-06-25 23:56:37 +02:00
|
|
|
if (leaf.data.blockId == blockId) {
|
|
|
|
return leaf.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-08-15 03:40:41 +02:00
|
|
|
function isBlockMagnified(layoutModel: LayoutModel, blockId: string): boolean {
|
|
|
|
if (layoutModel?.leafs == null || layoutModel.treeState.magnifiedNodeId == null) {
|
2024-08-01 22:46:06 +02:00
|
|
|
return false;
|
|
|
|
}
|
2024-08-15 03:40:41 +02:00
|
|
|
for (const leaf of layoutModel.leafs) {
|
2024-08-01 22:46:06 +02:00
|
|
|
if (leaf.data.blockId == blockId) {
|
2024-08-15 03:40:41 +02:00
|
|
|
return layoutModel.treeState.magnifiedNodeId == leaf.id;
|
2024-08-01 22:46:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
export { findLeafIdFromBlockId, isBlockMagnified };
|