mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
e85b0d205e
This PR is a large refactoring of the layout code to move as much of the layout state logic as possible into a unified model class, with atoms and derived atoms to notify the display logic of changes. It also fixes some latent bugs in the node resize code, significantly speeds up response times for resizing and dragging, and sets us up to fully replace the React-DnD library in the future.
31 lines
866 B
TypeScript
31 lines
866 B
TypeScript
// Copyright 2024, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { LayoutModel } from "@/layout/index";
|
|
|
|
function findLeafIdFromBlockId(layoutModel: LayoutModel, blockId: string): string {
|
|
if (layoutModel?.leafs == null) {
|
|
return null;
|
|
}
|
|
for (const leaf of layoutModel.leafs) {
|
|
if (leaf.data.blockId == blockId) {
|
|
return leaf.id;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function isBlockMagnified(layoutModel: LayoutModel, blockId: string): boolean {
|
|
if (layoutModel?.leafs == null || layoutModel.treeState.magnifiedNodeId == null) {
|
|
return false;
|
|
}
|
|
for (const leaf of layoutModel.leafs) {
|
|
if (leaf.data.blockId == blockId) {
|
|
return layoutModel.treeState.magnifiedNodeId == leaf.id;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
export { findLeafIdFromBlockId, isBlockMagnified };
|