Skip to content

Commit 36d17b2

Browse files
committed
doc: 增加 OnFileUpload 回调方法说明
1 parent ee39d9e commit 36d17b2

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<PackageReference Include="BootstrapBlazor.Sortable" Version="9.0.3" />
7171
<PackageReference Include="BootstrapBlazor.Splitting" Version="9.0.3" />
7272
<PackageReference Include="BootstrapBlazor.SvgEditor" Version="9.0.3" />
73-
<PackageReference Include="BootstrapBlazor.SummerNote" Version="9.0.4" />
73+
<PackageReference Include="BootstrapBlazor.SummerNote" Version="9.0.5" />
7474
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.6" />
7575
<PackageReference Include="BootstrapBlazor.Tasks.Dashboard" Version="9.0.0" />
7676
<PackageReference Include="BootstrapBlazor.TcpSocket" Version="9.0.0" />

src/BootstrapBlazor.Server/Components/Samples/Editors.razor.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,11 @@ private async Task InsertHtmlAsync()
111111
await Editor.DoMethodAsync("pasteHTML", $"<h1>{Localizer["DoMethodAsyncPasteHTML"]}</h1>");
112112
}
113113

114-
private async Task<string> OnFileUpload(EditorUploadFile uploadFile)
114+
private async Task OnFileUpload(EditorUploadFile uploadFile)
115115
{
116-
var url = Path.Combine("images", "uploader",
117-
$"{Path.GetFileNameWithoutExtension(uploadFile.FileName)}-{DateTimeOffset.Now:yyyyMMddHHmmss}{Path.GetExtension(uploadFile.FileName)}");
116+
var url = Path.Combine("images", "uploader", $"{Path.GetFileNameWithoutExtension(uploadFile.FileName)}-{DateTimeOffset.Now:yyyyMMddHHmmss}{Path.GetExtension(uploadFile.FileName)}");
118117
var fileName = Path.Combine(WebsiteOption.CurrentValue.WebRootPath, url);
119-
var ret = await uploadFile.SaveToFile(fileName);
120-
return ret ? url : "";
118+
await uploadFile.SaveToFileAsync(fileName);
121119
}
122120

123121
private string? _editorCode;
@@ -176,6 +174,14 @@ private AttributeItem[] GetAttributes() =>
176174
Type = "IEnumerable<EditorToolbarButton>",
177175
ValueList = " — ",
178176
DefaultValue = " — "
177+
},
178+
new()
179+
{
180+
Name = "OnFileUpload",
181+
Description = Localizer["OnFileUploadAttribute"],
182+
Type = "Func<EditorUploadFile, Task>",
183+
ValueList = " — ",
184+
DefaultValue = " — "
179185
}
180186
];
181187
}

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,8 @@
25772577
"DoMethodAsyncButton2": "Update to H2",
25782578
"DoMethodAsyncButton3": "Insert Image",
25792579
"DoMethodAsyncButton4": "Get Code",
2580-
"DoMethodAsyncPasteHTML": "Here is the content inserted by the external button"
2580+
"DoMethodAsyncPasteHTML": "Here is the content inserted by the external button",
2581+
"OnFileUploadAttribute": "File upload callback method"
25812582
},
25822583
"BootstrapBlazor.Server.Components.Samples.EditorForms": {
25832584
"Title": "EditorForm",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,8 @@
25782578
"DoMethodAsyncButton2": "将段落修改为 H2",
25792579
"DoMethodAsyncButton3": "添加一张图片",
25802580
"DoMethodAsyncButton4": "获得组件内容",
2581-
"DoMethodAsyncPasteHTML": "这里是外部按钮插入的内容"
2581+
"DoMethodAsyncPasteHTML": "这里是外部按钮插入的内容",
2582+
"OnFileUploadAttribute": "文件上传回调方法"
25822583
},
25832584
"BootstrapBlazor.Server.Components.Samples.EditorForms": {
25842585
"Title": "EditorForm 表单组件",

0 commit comments

Comments
 (0)