Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ const nextConfig = {
destination: '/?utm_source=shoptalk&utm_medium=podcast&utm_campaign=steve_shoptalk_2025',
permanent: true,
},
{
source: '/hanselminutes',
destination:
'/?utm_source=hanselminutes&utm_medium=paid_podcast&utm_campaign=ad_hanselminutes_2025',
permanent: true,
},
]
},
async rewrites() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function PdfEditor({ pdf }: { pdf: Pdf }) {
const pdfEditorComponents = useMemo<TLComponents>(
() => ({
PageMenu: null,
InFrontOfTheCanvas: () => <PageOverlayScreen pdf={pdf} />,
Overlays: () => <PageOverlayScreen pdf={pdf} />,
SharePanel: () => (
<div
style={{
Expand Down Expand Up @@ -189,22 +189,19 @@ const PageOverlayScreen = track(function PageOverlayScreen({ pdf }: { pdf: Pdf }
const editor = useEditor()

const viewportPageBounds = editor.getViewportPageBounds()
const viewportScreenBounds = editor.getViewportScreenBounds()

const relevantPageBounds = pdf.pages
.map((page) => {
if (!viewportPageBounds.collides(page.bounds)) return null
const topLeft = editor.pageToViewport(page.bounds)
const bottomRight = editor.pageToViewport({ x: page.bounds.maxX, y: page.bounds.maxY })
return new Box(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y)
return page.bounds
})
.filter((bounds): bounds is Box => bounds !== null)

function pathForPageBounds(bounds: Box) {
return `M ${bounds.x} ${bounds.y} L ${bounds.maxX} ${bounds.y} L ${bounds.maxX} ${bounds.maxY} L ${bounds.x} ${bounds.maxY} Z`
}

const viewportPath = `M 0 0 L ${viewportScreenBounds.w} 0 L ${viewportScreenBounds.w} ${viewportScreenBounds.h} L 0 ${viewportScreenBounds.h} Z`
const viewportPath = `M ${viewportPageBounds.x} ${viewportPageBounds.y} L ${viewportPageBounds.maxX} ${viewportPageBounds.y} L ${viewportPageBounds.maxX} ${viewportPageBounds.maxY} L ${viewportPageBounds.x} ${viewportPageBounds.maxY} Z`

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,28 @@

.PdfEditor .PageOverlayScreen-screen {
pointer-events: none;
fill: var(--color-background);
fill: var(--tl-color-background);
fill-opacity: 0.8;
stroke: none;
}
.PdfEditor .PageOverlayScreen-outline {
position: absolute;
pointer-events: none;
/* border: 1px solid var(--color-overlay); */
box-shadow: var(--shadow-2);
box-shadow: var(--tl-shadow-2);
}
.PdfEditor .ExportPdfButton {
font: inherit;
background: var(--color-primary);
background: var(--tl-color-primary);
border: none;
color: var(--color-selected-contrast);
color: var(--tl-color-selected-contrast);
font-size: 1rem;
padding: 0.5rem 1rem;
border-radius: 6px;
margin: 6px;
margin-bottom: 0;
pointer-events: all;
z-index: var(--layer-panels);
border: 2px solid var(--color-background);
z-index: var(--tl-layer-panels);
border: 2px solid var(--tl-color-background);
cursor: pointer;
}
.PdfEditor .ExportPdfButton:hover {
Expand Down
9 changes: 3 additions & 6 deletions apps/examples/src/examples/pdf-editor/PdfEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function PdfEditor({ pdf }: { pdf: Pdf }) {
const components = useMemo<TLComponents>(
() => ({
PageMenu: null,
InFrontOfTheCanvas: () => <PageOverlayScreen pdf={pdf} />,
Overlays: () => <PageOverlayScreen pdf={pdf} />,
SharePanel: () => <ExportPdfButton pdf={pdf} />,
}),
[pdf]
Expand Down Expand Up @@ -147,22 +147,19 @@ const PageOverlayScreen = track(function PageOverlayScreen({ pdf }: { pdf: Pdf }
const editor = useEditor()

const viewportPageBounds = editor.getViewportPageBounds()
const viewportScreenBounds = editor.getViewportScreenBounds()

const relevantPageBounds = pdf.pages
.map((page) => {
if (!viewportPageBounds.collides(page.bounds)) return null
const topLeft = editor.pageToViewport(page.bounds)
const bottomRight = editor.pageToViewport({ x: page.bounds.maxX, y: page.bounds.maxY })
return new Box(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y)
return page.bounds
})
.filter((bounds): bounds is Box => bounds !== null)

function pathForPageBounds(bounds: Box) {
return `M ${bounds.x} ${bounds.y} L ${bounds.maxX} ${bounds.y} L ${bounds.maxX} ${bounds.maxY} L ${bounds.x} ${bounds.maxY} Z`
}

const viewportPath = `M 0 0 L ${viewportScreenBounds.w} 0 L ${viewportScreenBounds.w} ${viewportScreenBounds.h} L 0 ${viewportScreenBounds.h} Z`
const viewportPath = `M ${viewportPageBounds.x} ${viewportPageBounds.y} L ${viewportPageBounds.maxX} ${viewportPageBounds.y} L ${viewportPageBounds.maxX} ${viewportPageBounds.maxY} L ${viewportPageBounds.x} ${viewportPageBounds.maxY} Z`

return (
<>
Expand Down
1 change: 0 additions & 1 deletion apps/examples/src/examples/pdf-editor/pdf-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
.PdfEditor .PageOverlayScreen-outline {
position: absolute;
pointer-events: none;
/* border: 1px solid var(--tl-color-overlay); */
box-shadow: var(--tl-shadow-2);
}
.PdfEditor .ExportPdfButton {
Expand Down
Loading