feat(core): add status to pdf viewer (#12349)
Closes: [BS-3439](https://linear.app/affine-design/issue/BS-3439/pdf-独立页面split-view-中的-status-组件) Related to: [BS-3143](https://linear.app/affine-design/issue/BS-3143/更新-loading-和错误样式) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a dedicated error handling and reload interface for PDF attachments, allowing users to retry loading PDFs when errors occur. - **Refactor** - Improved PDF viewer interface with clearer loading and error states. - Enhanced attachment type detection for better performance and maintainability. - Streamlined attachment preview logic for more direct and efficient model retrieval. - Simplified internal PDF metadata handling and control flow for improved clarity. - Clarified conditional rendering logic in attachment viewer components. - Introduced explicit loading state management and refined rendering logic in attachment pages. - **Style** - Updated and added styles for PDF viewer controls and error status display. - **Tests** - Added end-to-end tests validating PDF preview error handling and attachment not-found scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -37,9 +37,7 @@ export class PDF extends Entity<AttachmentBlockModel> {
|
||||
readonly state$ = LiveData.from<PDFRendererState>(
|
||||
// @ts-expect-error type alias
|
||||
from(downloadBlobToBuffer(this.props)).pipe(
|
||||
switchMap(buffer => {
|
||||
return this.renderer.ob$('open', { data: buffer });
|
||||
}),
|
||||
switchMap(data => this.renderer.ob$('open', { data })),
|
||||
map(meta => ({ status: PDFStatus.Opened, meta })),
|
||||
// @ts-expect-error type alias
|
||||
startWith({ status: PDFStatus.Opening }),
|
||||
|
||||
@@ -15,5 +15,5 @@ export function configurePDFModule(framework: Framework) {
|
||||
|
||||
export { PDF, type PDFRendererState, PDFStatus } from './entities/pdf';
|
||||
export { PDFPage } from './entities/pdf-page';
|
||||
export { PDFRenderer } from './renderer';
|
||||
export { type PDFMeta, PDFRenderer } from './renderer';
|
||||
export { PDFService } from './services/pdf';
|
||||
|
||||
Reference in New Issue
Block a user