Files
outline/shared/styles/globals.ts
T
UmbraCi 79d646b904 feat(editor): support image corner drag resizing with aspect ratio lock (#12690)
* feat(editor): support image corner drag resizing with aspect ratio lock

- Implement circular corner drag handles (ResizeTopLeft, ResizeTopRight, ResizeBottomLeft, ResizeBottomRight) using theme selection color.

- Update useDragResize hook to track coordinates as {x,y} object and handle aspect-ratio locked sizing for corner drags.

- Set overflow: visible on ImageWrapper to prevent corner handles from being clipped, and fade them in on hover.

* refactor(editor): simplify ResizeCorner styles by removing background and shadow properties

* fix(editor): fix corner resize speed and sync inputs in real-time

* fix(editor): improve corner resize cursor tracking and drag cursors

Project corner drag deltas onto the aspect-ratio vector so resizing
follows the pointer at 1x speed. Add a body class and global cursor
styles during image/media resize drags.

* refactor(editor): use relative import path inside shared directory

* fix(editor): resolve typescript type mismatch on dragging property in PDF component
2026-06-24 21:05:50 -04:00

172 lines
3.8 KiB
TypeScript

import { createGlobalStyle } from "styled-components";
import styledNormalize from "styled-normalize";
import { breakpoints, depths, s } from ".";
import { EditorStyleHelper } from "../editor/styles/EditorStyleHelper";
type Props = {
staticHTML?: boolean;
useCursorPointer?: boolean;
};
export default createGlobalStyle<Props>`
${styledNormalize}
* {
box-sizing: border-box;
}
html {
--line-height-body: 1.5;
--font-size-body: 16px;
}
html,
body {
width: 100%;
${(props) => (props.staticHTML ? "" : "height: 100%;")}
margin: 0;
padding: 0;
print-color-adjust: exact;
--pointer: ${(props) => (props.useCursorPointer ? "pointer" : "default")};
--scrollbar-width: calc(100vw - 100cqw);
overscroll-behavior-x: none;
@media print {
background: none !important;
}
--line-height-p: var(--line-height-body);
--line-height-h: 1.25;
}
body,
button,
input,
optgroup,
select,
textarea {
font-family: ${s("fontFamily")};
}
body {
font-size: var(--font-size-body);
line-height: var(--line-height-body);
color: ${s("text")};
overscroll-behavior-y: none;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
${(props) => (props.staticHTML ? "" : "width: 100vw;")}
overflow-x: hidden;
padding-right: calc(0 - var(--removed-body-scroll-bar-size)) !important;
}
@media (min-width: ${breakpoints.tablet}px) {
html,
body {
min-height: ${(props) => (props.staticHTML ? "0" : "100vh")};
}
}
@media (min-width: ${breakpoints.tablet}px) and (display-mode: standalone) {
body:after {
content: "";
display: block;
position: fixed;
top: 0;
left: 0;
right: 0;
height: 1px;
background: ${(props) => props.theme.titleBarDivider};
z-index: ${depths.titleBarDivider};
}
}
a {
color: ${(props) => props.theme.link};
text-decoration: none;
cursor: pointer;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 500;
line-height: var(--line-height-h);
margin-top: 1em;
margin-bottom: 0.5em;
}
h1 { font-size: 36px; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }
p,
dl,
ol,
ul,
pre,
blockquote {
margin-top: 1em;
margin-bottom: 1em;
}
hr {
border: 0;
height: 0;
border-top: 1px solid ${s("divider")};
}
:focus-visible {
outline-color: ${s("accent")};
outline-offset: -1px;
outline-width: initial;
}
:root {
--sat: env(safe-area-inset-top);
--sar: env(safe-area-inset-right);
--sab: env(safe-area-inset-bottom);
--sal: env(safe-area-inset-left);
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
/* Mermaid.js injects these into the root of the page. It's very annoying, but we have to deal with it or they affect layout */
[id^="doffscreen-mermaid"] {
position: absolute !important;
left: -9999px !important;
top: -9999px !important;
}
/* Table row/column drag and drop cursor */
&.${EditorStyleHelper.tableDragging},
&.${EditorStyleHelper.tableDragging} *,
&.${EditorStyleHelper.tableDragging} *::before,
&.${EditorStyleHelper.tableDragging} *::after {
cursor: grabbing !important;
}
/* Image/media resize drag cursor */
&.${EditorStyleHelper.resizeDragging},
&.${EditorStyleHelper.resizeDragging} *,
&.${EditorStyleHelper.resizeDragging} *::before,
&.${EditorStyleHelper.resizeDragging} *::after {
cursor: var(--resize-drag-cursor) !important;
}
`;