Use inline content disposition for common images and PDFs (#6924)
* Use inline content disposition for common images and PDFs * Add double-click on widgets to download
This commit is contained in:
@@ -4,24 +4,38 @@ import { s } from "../../styles";
|
||||
import { sanitizeUrl } from "../../utils/urls";
|
||||
|
||||
type Props = {
|
||||
/** Icon to display on the left side of the widget */
|
||||
icon: React.ReactNode;
|
||||
/** Title of the widget */
|
||||
title: React.ReactNode;
|
||||
/** Context, displayed to right of title */
|
||||
context?: React.ReactNode;
|
||||
/** URL to open when the widget is clicked */
|
||||
href: string;
|
||||
/** Whether the widget is currently selected */
|
||||
isSelected: boolean;
|
||||
/** Children to display to the right of the context */
|
||||
children?: React.ReactNode;
|
||||
/** Callback fired when the widget is double clicked */
|
||||
onDoubleClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
||||
/** Callback fired when the widget is clicked */
|
||||
onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;
|
||||
/** Callback fired when the widget is clicked */
|
||||
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
||||
};
|
||||
|
||||
export default function Widget(props: Props & ThemeProps<DefaultTheme>) {
|
||||
const className = props.isSelected
|
||||
? "ProseMirror-selectednode widget"
|
||||
: "widget";
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
className={
|
||||
props.isSelected ? "ProseMirror-selectednode widget" : "widget"
|
||||
}
|
||||
className={className}
|
||||
target="_blank"
|
||||
href={sanitizeUrl(props.href)}
|
||||
rel="noreferrer nofollow"
|
||||
onDoubleClick={props.onDoubleClick}
|
||||
onMouseDown={props.onMouseDown}
|
||||
onClick={props.onClick}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user