Skip to content

Commit 6a3742f

Browse files
authored
feat(PdfReader): support wasm mode (#770)
* refactor: 移动样式兼容 wasm 模式 * refactor: 增加 invisible 样式确保不要提前渲染 * chore: bump version 10.0.10
1 parent b6b7001 commit 6a3742f

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/components/BootstrapBlazor.PdfReader/BootstrapBlazor.PdfReader.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.0.9</Version>
4+
<Version>10.0.10</Version>
55
</PropertyGroup>
66

77
<PropertyGroup>

src/components/BootstrapBlazor.PdfReader/PdfReader.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
<span class="bb-view-subject">@_docTitle</span>
1515
</div>
16-
<div class="bb-view-group bb-view-toolbar-main">
16+
<div class="bb-view-group bb-view-toolbar-main invisible">
1717
<div class="bb-view-group bb-view-group-page">
1818
<input type="text" class="bb-view-num" value="1" /><span class="bb-view-slash">/</span>
1919
<div class="bb-view-pagesCount"></div>
@@ -42,7 +42,7 @@
4242
<div class="bb-view-icon bb-view-rotate-right" title="@Localizer["RotateRight"]"><i class="fa-solid fa-fw fa-rotate-right"></i></div>
4343
</div>
4444
</div>
45-
<div class="bb-view-group bb-view-controls">
45+
<div class="bb-view-group bb-view-controls invisible">
4646
@if (ShowDownload)
4747
{
4848
<div class="bb-view-icon bb-view-download" title="@Localizer["Download"]" @onclick="OnDownload"><i class="fa-solid fa-fw fa-arrow-right-to-bracket fa-rotate-90"></i></div>
@@ -98,7 +98,7 @@
9898
</div>
9999
</div>
100100
</div>
101-
<div class="bb-view-pdf-info">
101+
<div class="bb-view-pdf-info invisible">
102102
<div class="bb-view-pdf-backdrop"></div>
103103
<div class="bb-view-pdf-dialog">
104104
<div class="bb-view-pdf-dialog-title mb-3">@Localizer["DocumentProperties"]</div>

src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (pdfjsLib != null) {
99
}
1010

1111
export async function init(id, invoke, options) {
12-
await addLink('./_content/BootstrapBlazor.PdfReader/css/pdf_viewer.css');
12+
await addLink('./_content/BootstrapBlazor.PdfReader/css/pdf_reader.css');
1313

1414
const el = document.getElementById(id);
1515
if (el === null) {
@@ -371,6 +371,9 @@ const addEventBus = (el, pdfViewer, eventBus, invoke, options) => {
371371

372372
const addToolbarEventHandlers = (el, pdfViewer, invoke, options) => {
373373
const toolbar = el.querySelector(".bb-view-toolbar");
374+
[...el.querySelectorAll('.invisible')].forEach(i => {
375+
i.classList.remove('invisible');
376+
});
374377

375378
EventHandler.on(toolbar, "click", '.bb-view-bar', e => {
376379
const thumbnailsEl = el.querySelector(".bb-view-thumbnails");

src/components/BootstrapBlazor.PdfReader/PdfReader.razor.css renamed to src/components/BootstrapBlazor.PdfReader/wwwroot/css/pdf_reader.css

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import url('pdf_viewer.css');
2+
13
.bb-pdf-reader {
24
--bb-pdf-view-height: 600px;
35
--bb-pdf-toolbar-height: 60px;
@@ -163,20 +165,20 @@
163165
flex-basis: 300px;
164166
}
165167

166-
::deep .bb-view-thumbnail-item {
168+
.bb-view-thumbnail-item {
167169
display: block;
168170
text-align: center;
169171
}
170172

171-
::deep .bb-view-thumbnail-item:not(:last-child) {
173+
.bb-view-thumbnail-item:not(:last-child) {
172174
margin-block-end: 1rem;
173175
}
174176

175-
::deep .bb-view-thumbnail-item.active img {
177+
.bb-view-thumbnail-item.active img {
176178
border: 2px solid #0d6efd;
177179
}
178180

179-
::deep .bb-view-thumbnail-item img {
181+
.bb-view-thumbnail-item img {
180182
width: 128px;
181183
padding: 1px;
182184
cursor: pointer;
@@ -185,13 +187,13 @@
185187
margin: 0 auto;
186188
}
187189

188-
::deep .bb-view-thumbnail-item .bb-view-thumbnail-group {
190+
.bb-view-thumbnail-item .bb-view-thumbnail-group {
189191
display: flex;
190192
flex-direction: column;
191193
justify-content: center;
192194
}
193195

194-
::deep .bb-view-thumbnail-item .bb-view-thumbnail-group label {
196+
.bb-view-thumbnail-item .bb-view-thumbnail-group label {
195197
color: #fff;
196198
}
197199

0 commit comments

Comments
 (0)