fix(editor): improve pdf embed viewer UX (#11641)

Closes: [BS-3101](https://linear.app/affine-design/issue/BS-3101/pdf-embed-模式的选中框选-和点开看详情有比较大的问题)

### What's Changed!

* Fixed disable pointer event in native pdf viewer by dragging
* Disable opening peek view with pdf viewer in readonly and sharing modes
This commit is contained in:
fundon
2025-04-15 08:51:02 +00:00
parent 0df584bd5e
commit 8ca675b2ec
8 changed files with 203 additions and 61 deletions

View File

@@ -28,7 +28,7 @@ import { checkAttachmentBlob, downloadAttachmentBlob } from './utils';
@Peekable({
enableOn: ({ model }: AttachmentBlockComponent) => {
return model.props.type.endsWith('pdf');
return !model.doc.readonly && model.props.type.endsWith('pdf');
},
})
export class AttachmentBlockComponent extends CaptionedBlockComponent<AttachmentBlockModel> {

View File

@@ -146,17 +146,20 @@ const embedConfig: AttachmentEmbedConfig[] = [
// More options: https://tinytip.co/tips/html-pdf-params/
// https://chromium.googlesource.com/chromium/src/+/refs/tags/121.0.6153.1/chrome/browser/resources/pdf/open_pdf_params_parser.ts
const parameters = '#toolbar=0';
return html`<iframe
style="width: 100%; color-scheme: auto;"
height="480"
src=${blobUrl + parameters}
loading="lazy"
scrolling="no"
frameborder="no"
allowTransparency
allowfullscreen
type="application/pdf"
></iframe>`;
return html`
<iframe
style="width: 100%; color-scheme: auto;"
height="480"
src=${blobUrl + parameters}
loading="lazy"
scrolling="no"
frameborder="no"
allowTransparency
allowfullscreen
type="application/pdf"
></iframe>
<div class="affine-attachment-embed-event-mask"></div>
`;
},
},
{

View File

@@ -136,4 +136,9 @@ export const styles = css`
width: 100%;
height: 100%;
}
.affine-attachment-embed-event-mask {
position: absolute;
inset: 0;
}
`;