Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix types of elements #5649

Merged
merged 1 commit into from
Apr 16, 2024
Merged

fix: fix types of elements #5649

merged 1 commit into from
Apr 16, 2024

Conversation

Aarebecca
Copy link
Contributor

修正元素类型定义

对于节点,通常只需要定义一个类型

  • {Element}StyleProps: 该节点 的 Style 类型,即用户在 node.style 中可配置的属性

⚠️ 如果没有特殊配置,那么大部分情况下,{Element}StyleProps 使用 BaseNodeStyleProps 即可
即:type {Element}StyleProps = BaseNodeStyleProps

如果存在特殊配置,如 Image 节点额外需要 src img 属性,那么可以通过范型传入
即: type ImageStyleProps = BaseNodeStyleProps<{ img?: string | HTMLImageElement }>

对于 Combo,其类型定义与节点类似

对于边来说,类型定义则相对简单,直接在 BaseEdgeStyleProps 上扩展类型即可

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. Fix labels Apr 16, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 16, 2024
@Aarebecca Aarebecca merged commit cd073f7 into v5 Apr 16, 2024
5 checks passed
@Aarebecca Aarebecca deleted the fix/element-types branch April 16, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants