Files
outline/app/menus/NewDocumentMenu.tsx
T
Tom Moor fed1d4c869 Speed up creating a new document (#13310)
* perf: Preload editor chunks when creating a new document

The document scene, multiplayer editor, and editor itself each sit behind
a separate lazy boundary, so their chunks were downloaded one after the
other and only once the create request had resolved. Start them in
parallel on intent instead.

* perf: Don't wait for collaborative sync to edit an empty document

A newly created document has no cached content, so the read-only cache
editor shown while syncing renders identically to the live one – yet the
editable document stayed hidden until the websocket had connected,
authenticated and loaded. Only show the cache when there is content.

* fix: Right sidebar flashing open when a document loads

A history panel left in the persisted UI state is cleared in an effect,
by which point the sidebar has already rendered open for a frame and has
to animate away again. Derive the open state from the panel that will
actually be displayed instead.
2026-08-05 19:08:21 -04:00

37 lines
996 B
TypeScript

import { observer } from "mobx-react";
import { PlusIcon } from "outline-icons";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import Button from "~/components/Button";
import Tooltip from "~/components/Tooltip";
import useCurrentTeam from "~/hooks/useCurrentTeam";
import usePolicy from "~/hooks/usePolicy";
import { preloadEditor } from "~/routes/scenes";
import { newDocumentPath } from "~/utils/routeHelpers";
function NewDocumentMenu() {
const { t } = useTranslation();
const team = useCurrentTeam();
const can = usePolicy(team);
if (!can.createDocument) {
return null;
}
return (
<Tooltip content={t("New document")} shortcut="n" placement="bottom">
<Button
as={Link}
to={newDocumentPath()}
icon={<PlusIcon />}
onPointerEnter={preloadEditor}
onFocus={preloadEditor}
>
{t("New doc")}
</Button>
</Tooltip>
);
}
export default observer(NewDocumentMenu);