mirror of
https://github.com/wavetermdev/waveterm
synced 2026-05-24 09:18:27 +00:00
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.
30 lines
866 B
TypeScript
30 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 };
|