Files
outline/app/components/Portal.tsx
Tom Moor 08df14618c Various commenting improvements (#4938)
* fix: New threads attached to previous as replies

* fix: Cannot use floating toolbar properly in comments

* perf: Avoid re-writing history on click in editor

* fix: Comment on text selection

* fix: 'Copy link' on comments uses wrong hostname

* Show comment buttons on input focus rather than non-empty input
Increase maximum sidebar size

* Allow opening comments from document menu

* fix: Clicking comment menu should not focus thread
2023-02-26 11:19:12 -08:00

19 lines
584 B
TypeScript

import * as React from "react";
import { Portal as ReactPortal } from "react-portal";
/**
* A React context that provides a dom node for portals to be rendered into.
*/
export const PortalContext = React.createContext<
HTMLElement | null | undefined
>(undefined);
/**
* A portal component that uses context to render into a different dom node
* or the root of body if no context is available.
*/
export function Portal(props: { children: React.ReactNode }) {
const node = React.useContext(PortalContext);
return <ReactPortal node={node}>{props.children}</ReactPortal>;
}