mirror of
https://github.com/outline/outline.git
synced 2026-11-26 07:33:19 +03:00
* fix: Allow PDF embed width and height to change independently Adds an aspect ratio lock toggle to the media dimension toolbar for PDF embeds, renders PDFs at their stored aspect ratio, and keeps that ratio when drag resizing. * feat: Add corner resize handles to PDF embeds and persist aspect ratio lock Stores the lock as an optional attachment attribute, where unset means locked, so side handles change only the width of unlocked PDFs. * feat: Consistent resize handles for images, videos, PDFs and embeds All media get side, bottom and corner handles driven by one lock rule. Images and videos stay locked. PDFs and embeds can be unlocked to resize each axis independently. * feat: Show width, height and lock in the embed toolbar * feat: Start embeds unlocked and step media dimensions with arrow keys Embeds start with an unlocked aspect ratio so full-width embeds can still be made taller, while PDFs start locked. Up and down arrows step the dimension inputs by 1, or 10 with shift. * fix: Align the aspect ratio padlock with the dimension digits * fix: Move the aspect ratio lock closer to the dimension inputs * fix: Show the aspect ratio lock state in its tooltip
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { PadlockIcon } from "outline-icons";
|
|
import type * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import styled, { useTheme } from "styled-components";
|
|
import { UnlockedPadlockIcon } from "~/components/Icons/UnlockedPadlockIcon";
|
|
import ToolbarButton from "./ToolbarButton";
|
|
|
|
interface Props extends React.ComponentProps<typeof ToolbarButton> {
|
|
/** Whether the aspect ratio is locked. */
|
|
isLocked: boolean;
|
|
}
|
|
|
|
/**
|
|
* A toolbar button that shows and toggles whether media keeps its aspect ratio.
|
|
*
|
|
* @param props - the component props.
|
|
* @returns the button.
|
|
*/
|
|
export function AspectRatioLockButton({ isLocked, ...rest }: Props) {
|
|
const { t } = useTranslation();
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
<LockButton
|
|
aria-label={t("Lock aspect ratio")}
|
|
aria-pressed={isLocked}
|
|
{...rest}
|
|
>
|
|
{isLocked ? (
|
|
<PadlockIcon size={18} />
|
|
) : (
|
|
<UnlockedPadlockIcon size={18} color={theme.textTertiary} />
|
|
)}
|
|
</LockButton>
|
|
);
|
|
}
|
|
|
|
const LockButton = styled(ToolbarButton)`
|
|
justify-content: center;
|
|
margin-left: -6px;
|
|
|
|
/* The padlock glyph sits above its box center, so align it with the digits. */
|
|
svg {
|
|
transform: translateY(1px);
|
|
}
|
|
`;
|