File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
src/BootstrapBlazor.Server/Components/Components Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 1- @inherits WebSiteModuleComponentBase
1+ @inherits WebSiteModuleComponentBase
22@attribute [JSModuleAutoLoader("Components/Pre.razor.js")]
33@inject IOptions <WebsiteOptions > WebsiteOption
44
55<div @attributes =" @AdditionalAttributes" class =" @ClassString" id =" @Id" data-bb-title =" @CopiedText" >
66 <p class =" loading" >@LoadingText </p >
77 @if (Loaded )
88 {
9- <pre class =" scroll" ><code >@ChildContent </code ></pre >
9+ <pre class =" scroll" style = " @ StyleString " ><code >@ChildContent </code ></pre >
1010 @if (CanCopy )
1111 {
1212 @if (ShowToolbar )
Original file line number Diff line number Diff line change 1- // Licensed to the .NET Foundation under one or more agreements.
1+ // Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the Apache 2.0 License
33// See the LICENSE file in the project root for more information.
44// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -53,6 +53,12 @@ public partial class Pre
5353 [ Parameter ]
5454 public bool ShowToolbar { get ; set ; }
5555
56+ /// <summary>
57+ /// 获得/设置 组件高度 默认 null 不设置高度
58+ /// </summary>
59+ [ Parameter ]
60+ public string ? Height { get ; set ; }
61+
5662 [ Inject ]
5763 [ NotNull ]
5864 private IStringLocalizer < Pre > ? Localizer { get ; set ; }
@@ -67,6 +73,12 @@ public partial class Pre
6773
6874 private string ? CopiedText { get ; set ; }
6975
76+ private string ? StyleString => CssBuilder . Default ( )
77+ . AddClass ( $ "height: { Height } ;", ! string . IsNullOrEmpty ( Height ) )
78+ . AddClass ( "max-height: 260px;" , string . IsNullOrEmpty ( Height ) )
79+ . AddClassFromAttributes ( AdditionalAttributes )
80+ . Build ( ) ;
81+
7082 /// <summary>
7183 /// <inheritdoc/>
7284 /// </summary>
Original file line number Diff line number Diff line change 1- .pre-code {
1+ .pre-code {
22 position : relative;
33 border : 1px solid var (--bs-border-color );
44 border-radius : var (--bs-border-radius );
2222 .pre-code > pre {
2323 color : # e83e8c ;
2424 margin-bottom : 0 ;
25- max-height : 260px ;
2625 }
2726
2827::deep .btn-group {
You can’t perform that action at this time.
0 commit comments