Skip to content

Commit 75a9372

Browse files
committed
feat(EmbedPDF): add IsKeepCurrentDocument parameter
1 parent 622fe26 commit 75a9372

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

src/components/BootstrapBlazor.EmbedPDF/EmbedPDF.razor.cs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,82 @@
44
namespace BootstrapBlazor.Components;
55

66
/// <summary>
7-
/// EmbedPDF 组件
7+
/// <para lang="zh">EmbedPDF 组件</para>
8+
/// <para lang="en">EmbedPDF component</para>
89
/// </summary>
910
[JSModuleAutoLoader("./_content/BootstrapBlazor.EmbedPDF/EmbedPDF.razor.js", JSObjectReference = true)]
1011
public partial class EmbedPDF
1112
{
1213
/// <summary>
13-
/// 获得/设置 PDF 文档路径
14+
/// <para lang="zh">获得/设置 PDF 文档路径</para>
15+
/// <para lang="en">Gets or sets the PDF document URL</para>
1416
/// </summary>
1517
[Parameter]
1618
public string? Url { get; set; }
1719

1820
/// <summary>
19-
/// 获得/设置 PDF 组件高度 默认 600px
21+
/// <para lang="zh">获得/设置 PDF 组件高度 默认 600px</para>
22+
/// <para lang="en">Gets or sets the PDF component height, default is 600px</para>
2023
/// </summary>
2124
[Parameter]
2225
public string ViewHeight { get; set; } = "600px";
2326

2427
/// <summary>
25-
/// 获得/设置 是否显示外边框
28+
/// <para lang="zh">获得/设置 是否显示外边框</para>
29+
/// <para lang="en">Gets or sets a value indicating whether to show border</para>
2630
/// </summary>
2731
[Parameter]
2832
public bool ShowBorder { get; set; } = true;
2933

3034
/// <summary>
31-
/// 获得/设置 标签显示模式 默认值 <see cref="EmbedPDFTabBarMode.Always"/>
35+
/// <para lang="zh">获得/设置 标签显示模式 默认值 <see cref="EmbedPDFTabBarMode.Always"/></para>
36+
/// <para lang="en">Gets or sets the tab bar display mode, default is <see cref="EmbedPDFTabBarMode.Always"/></para>
3237
/// </summary>
3338
[Parameter]
3439
public EmbedPDFTabBarMode TabBarMode { get; set; } = EmbedPDFTabBarMode.Always;
3540

3641
/// <summary>
37-
/// 获得/设置 标签显示模式 默认值 <see cref="EmbedPDFTabBarMode.Always"/>
42+
/// <para lang="zh">获得/设置 滚动策略 默认值 <see cref="EmbedPDFScrollStrategy.Vertical"/></para>
43+
/// <para lang="en">Gets or sets the scroll strategy, default is <see cref="EmbedPDFScrollStrategy.Vertical"/></para>
3844
/// </summary>
3945
[Parameter]
4046
public EmbedPDFScrollStrategy ScrollStrategy { get; set; } = EmbedPDFScrollStrategy.Vertical;
4147

4248
/// <summary>
43-
/// 获得/设置 主题样式 默认 <see cref="EmbedPDFTheme.System"/>
49+
/// <para lang="zh">获得/设置 主题样式 默认 <see cref="EmbedPDFTheme.System"/></para>
50+
/// <para lang="en">Gets or sets the theme style, default is <see cref="EmbedPDFTheme.System"/></para>
4451
/// </summary>
4552
[Parameter]
4653
public EmbedPDFTheme Theme { get; set; }
4754

4855
/// <summary>
49-
/// 获得/设置 语言 默认 null 未设置
56+
/// <para lang="zh">获得/设置 语言 默认 null 未设置</para>
57+
/// <para lang="en">Gets or sets the language, default is null</para>
5058
/// </summary>
5159
[Parameter]
5260
public string? Language { get; set; }
5361

5462
/// <summary>
55-
/// 获得/设置 当前页码
63+
/// <para lang="zh">获得/设置 当前页码</para>
64+
/// <para lang="en">Gets or sets the current page number</para>
5665
/// </summary>
5766
[Parameter]
5867
public uint CurrentPage { get; set; }
5968

6069
/// <summary>
61-
/// 获得/设置 页码之间的间隙 默认 null 未设置 使用默认值 20
70+
/// <para lang="zh">获得/设置 页码之间的间隙 默认 null 未设置 使用默认值 20</para>
71+
/// <para lang="en">Gets or sets the gap between pages, default is null and uses default value 20</para>
6272
/// </summary>
6373
[Parameter]
6474
public uint PageGap { get; set; }
6575

76+
/// <summary>
77+
/// <para lang="zh">获得/设置 重新设置 Url 时是否保持当前打开文档 默认 false</para>
78+
/// <para lang="en">Gets or sets a value indicating whether to keep the current opened document when resetting the URL, default is false</para>
79+
/// </summary>
80+
[Parameter]
81+
public uint IsKeepCurrentDocument { get; set; }
82+
6683
private string? StyleString => CssBuilder.Default()
6784
.AddClass("border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); overflow: hidden;", ShowBorder)
6885
.AddClass($"height: {ViewHeight};", !string.IsNullOrEmpty(ViewHeight))
@@ -91,7 +108,6 @@ protected override void OnParametersSet()
91108
/// <inheritdoc/>
92109
/// </summary>
93110
/// <param name="firstRender"></param>
94-
/// <returns></returns>
95111
protected override async Task OnAfterRenderAsync(bool firstRender)
96112
{
97113
await base.OnAfterRenderAsync(firstRender);
@@ -108,7 +124,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
108124
if (_url != Url)
109125
{
110126
_url = Url;
111-
await InvokeVoidAsync("setUrl", Id, _url);
127+
await InvokeVoidAsync("setUrl", Id, _url, IsKeepCurrentDocument);
112128
}
113129
if (_theme != Theme)
114130
{
@@ -130,7 +146,6 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
130146
/// <summary>
131147
/// <inheritdoc/>
132148
/// </summary>
133-
/// <returns></returns>
134149
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, new
135150
{
136151
TabBar = TabBarMode.ToDescriptionString(),

0 commit comments

Comments
 (0)