Feat(nodes): add initialWidth and initialHeight (#3953)
* feat(react/svelte): add initialWidth/initialHeight closes #3793 * chore(packages): update changelogs
This commit is contained in:
@@ -5,7 +5,7 @@ import { InputNode } from '../Nodes/InputNode';
|
||||
import { DefaultNode } from '../Nodes/DefaultNode';
|
||||
import { GroupNode } from '../Nodes/GroupNode';
|
||||
import { OutputNode } from '../Nodes/OutputNode';
|
||||
import type { NodeTypes } from '../../types';
|
||||
import type { Node, NodeTypes } from '../../types';
|
||||
|
||||
export const arrowKeyDiffs: Record<string, XYPosition> = {
|
||||
ArrowUp: { x: 0, y: -1 },
|
||||
@@ -20,3 +20,22 @@ export const builtinNodeTypes: NodeTypes = {
|
||||
output: OutputNode as ComponentType<NodeProps>,
|
||||
group: GroupNode as ComponentType<NodeProps>,
|
||||
};
|
||||
|
||||
export function getNodeInlineStyleDimensions<NodeType extends Node = Node>(
|
||||
node: NodeType
|
||||
): {
|
||||
width: number | string | undefined;
|
||||
height: number | string | undefined;
|
||||
} {
|
||||
if (!node.computed) {
|
||||
return {
|
||||
width: node.width ?? node.initialWidth ?? node.style?.width,
|
||||
height: node.height ?? node.initialHeight ?? node.style?.height,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
width: node.width ?? node.style?.width,
|
||||
height: node.height ?? node.style?.height,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user