mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
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:
@@ -40,8 +40,11 @@ type ControlButtonProps = {
|
||||
icon: ReactElement<SVGAttributes<SVGElement>>;
|
||||
name: string;
|
||||
onClick: () => void;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
const filterByEnabled = (props: ControlButtonProps) => props.enabled;
|
||||
|
||||
export const ControlButton = ({
|
||||
icon,
|
||||
nameKey,
|
||||
@@ -85,12 +88,13 @@ export const DefaultPeekViewControls = ({
|
||||
const controls = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
icon: <CloseIcon />,
|
||||
nameKey: 'close',
|
||||
name: t['com.affine.peek-view-controls.close'](),
|
||||
icon: <CloseIcon />,
|
||||
onClick: () => peekView.close(),
|
||||
enabled: true,
|
||||
},
|
||||
].filter((opt): opt is ControlButtonProps => Boolean(opt));
|
||||
].filter(filterByEnabled);
|
||||
}, [peekView, t]);
|
||||
return (
|
||||
<div {...rest} className={clsx(styles.root, className)}>
|
||||
@@ -115,42 +119,46 @@ export const DocPeekViewControls = ({
|
||||
const controls = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
icon: <CloseIcon />,
|
||||
nameKey: 'close',
|
||||
name: t['com.affine.peek-view-controls.close'](),
|
||||
icon: <CloseIcon />,
|
||||
onClick: () => peekView.close(),
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
icon: <ExpandFullIcon />,
|
||||
name: t['com.affine.peek-view-controls.open-doc'](),
|
||||
nameKey: 'open',
|
||||
name: t['com.affine.peek-view-controls.open-doc'](),
|
||||
icon: <ExpandFullIcon />,
|
||||
onClick: () => {
|
||||
workbench.openDoc(docRef);
|
||||
peekView.close(false);
|
||||
},
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
icon: <OpenInNewIcon />,
|
||||
nameKey: 'new-tab',
|
||||
name: t['com.affine.peek-view-controls.open-doc-in-new-tab'](),
|
||||
icon: <OpenInNewIcon />,
|
||||
onClick: () => {
|
||||
workbench.openDoc(docRef, { at: 'new-tab' });
|
||||
peekView.close(false);
|
||||
},
|
||||
enabled: true,
|
||||
},
|
||||
BUILD_CONFIG.isElectron && {
|
||||
icon: <SplitViewIcon />,
|
||||
{
|
||||
nameKey: 'split-view',
|
||||
name: t['com.affine.peek-view-controls.open-doc-in-split-view'](),
|
||||
icon: <SplitViewIcon />,
|
||||
onClick: () => {
|
||||
workbench.openDoc(docRef, { at: 'beside' });
|
||||
peekView.close(false);
|
||||
},
|
||||
enabled: BUILD_CONFIG.isElectron,
|
||||
},
|
||||
{
|
||||
icon: <LinkIcon />,
|
||||
nameKey: 'copy-link',
|
||||
name: t['com.affine.peek-view-controls.copy-link'](),
|
||||
icon: <LinkIcon />,
|
||||
onClick: async () => {
|
||||
const preferredMode = docsService.list.getPrimaryMode(docRef.docId);
|
||||
const search = toDocSearchParams({
|
||||
@@ -167,16 +175,18 @@ export const DocPeekViewControls = ({
|
||||
await copyTextToClipboard(url.toString());
|
||||
notify.success({ title: t['Copied link to clipboard']() });
|
||||
},
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
icon: <InformationIcon />,
|
||||
nameKey: 'info',
|
||||
name: t['com.affine.peek-view-controls.open-info'](),
|
||||
icon: <InformationIcon />,
|
||||
onClick: () => {
|
||||
workspaceDialogService.open('doc-info', { docId: docRef.docId });
|
||||
},
|
||||
enabled: true,
|
||||
},
|
||||
].filter((opt): opt is ControlButtonProps => Boolean(opt));
|
||||
].filter(filterByEnabled);
|
||||
}, [
|
||||
t,
|
||||
peekView,
|
||||
@@ -213,10 +223,11 @@ export const AttachmentPeekViewControls = ({
|
||||
const controls = useMemo(() => {
|
||||
const controls = [
|
||||
{
|
||||
icon: <CloseIcon />,
|
||||
nameKey: 'close',
|
||||
name: t['com.affine.peek-view-controls.close'](),
|
||||
icon: <CloseIcon />,
|
||||
onClick: () => peekView.close(),
|
||||
enabled: true,
|
||||
},
|
||||
];
|
||||
if (!type) return controls;
|
||||
@@ -224,42 +235,45 @@ export const AttachmentPeekViewControls = ({
|
||||
return [
|
||||
...controls,
|
||||
// TODO(@fundon): needs to be implemented on mobile
|
||||
BUILD_CONFIG.isDesktopEdition && {
|
||||
icon: <ExpandFullIcon />,
|
||||
name: t['com.affine.peek-view-controls.open-attachment'](),
|
||||
{
|
||||
nameKey: 'open',
|
||||
name: t['com.affine.peek-view-controls.open-attachment'](),
|
||||
icon: <ExpandFullIcon />,
|
||||
onClick: () => {
|
||||
workbench.openAttachment(docId, blockId);
|
||||
peekView.close(false);
|
||||
|
||||
track.$.attachment.$.openAttachmentInFullscreen({ type });
|
||||
},
|
||||
enabled: BUILD_CONFIG.isDesktopEdition,
|
||||
},
|
||||
{
|
||||
icon: <OpenInNewIcon />,
|
||||
nameKey: 'new-tab',
|
||||
name: t['com.affine.peek-view-controls.open-attachment-in-new-tab'](),
|
||||
icon: <OpenInNewIcon />,
|
||||
onClick: () => {
|
||||
workbench.openAttachment(docId, blockId, { at: 'new-tab' });
|
||||
peekView.close(false);
|
||||
|
||||
track.$.attachment.$.openAttachmentInNewTab({ type });
|
||||
},
|
||||
enabled: true,
|
||||
},
|
||||
BUILD_CONFIG.isElectron && {
|
||||
icon: <SplitViewIcon />,
|
||||
{
|
||||
nameKey: 'split-view',
|
||||
name: t[
|
||||
'com.affine.peek-view-controls.open-attachment-in-split-view'
|
||||
](),
|
||||
icon: <SplitViewIcon />,
|
||||
onClick: () => {
|
||||
workbench.openAttachment(docId, blockId, { at: 'beside' });
|
||||
peekView.close(false);
|
||||
|
||||
track.$.attachment.$.openAttachmentInSplitView({ type });
|
||||
},
|
||||
enabled: BUILD_CONFIG.isElectron,
|
||||
},
|
||||
].filter((opt): opt is ControlButtonProps => Boolean(opt));
|
||||
].filter(filterByEnabled);
|
||||
}, [t, peekView, workbench, docId, blockId, type]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user