fix: range error raise if heading level >= 6 (#5373)

This commit is contained in:
Lucas.Xu 2024-05-21 09:21:50 +08:00 committed by GitHub
parent d303d5affd
commit c67e266174
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -92,8 +92,9 @@ Map<String, BlockComponentBuilder> getEditorBuilderMap({
final factor = pageStyle.fontLayout.factor;
final headingPaddings = pageStyle.lineHeightLayout.headingPaddings
.map((e) => e * factor);
final level = node.attributes[HeadingBlockKeys.level] ?? 6;
return EdgeInsets.only(top: headingPaddings.elementAt(level));
int level = node.attributes[HeadingBlockKeys.level] ?? 6;
level = level.clamp(1, 6);
return EdgeInsets.only(top: headingPaddings.elementAt(level - 1));
}
return const EdgeInsets.only(top: 12.0, bottom: 4.0);