mirror of
https://github.com/outline/outline.git
synced 2026-11-22 14:01:41 +03:00
* shares.info, collections.info, documents.info * shares.list, shares.create, shares.update * shares.sitemap * parity with existing document shared screen * collection share popover * parent share and table * collection scene * collection link in sidebar * sidebar and breadcrumb collection link click * collection link click in editor * meta * more meta + 404 page * map internal link, remove showLastUpdated option * fix shares.list pagination * show last updated * shareLoader tests * lint * sidebar context for collection link * badge in shares table * fix existing tests * tsc * update failing test snapshot * env * signed url for collection attachments * include collection content in SSR for screen readers * search * drafts can be shared * review * tsc, remove old shared-doc scene * tweaks * DRY * refactor loader * Remove share/collection urls * fix: Collection overview should not be editable when viewing shared link and logged in * Tweak public breadcrumb * fix: Deleted documents should never be exposed through share * empty sharedTree array where includeChildDocuments is false * revert includeChildDocs guard for logical correctness + SSR bug fix * fix: check document is part of share --------- Co-authored-by: Tom Moor <tom@getoutline.com>
106 lines
2.7 KiB
TypeScript
106 lines
2.7 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import { DocumentIcon } from "outline-icons";
|
|
import { Link } from "react-router-dom";
|
|
import styled from "styled-components";
|
|
import Icon from "@shared/components/Icon";
|
|
import { s, hover, ellipsis } from "@shared/styles";
|
|
import { IconType, NavigationNode } from "@shared/types";
|
|
import { determineIconType } from "@shared/utils/icon";
|
|
import Document from "~/models/Document";
|
|
import Flex from "~/components/Flex";
|
|
import { SidebarContextType } from "~/components/Sidebar/components/SidebarContext";
|
|
import { sharedModelPath } from "~/utils/routeHelpers";
|
|
import useClickIntent from "~/hooks/useClickIntent";
|
|
import useStores from "~/hooks/useStores";
|
|
import { useCallback } from "react";
|
|
|
|
type Props = {
|
|
shareId?: string;
|
|
document: Document | NavigationNode;
|
|
anchor?: string;
|
|
showCollection?: boolean;
|
|
sidebarContext?: SidebarContextType;
|
|
};
|
|
|
|
const DocumentLink = styled(Link)`
|
|
display: block;
|
|
margin: 2px -8px;
|
|
padding: 6px 8px;
|
|
border-radius: 8px;
|
|
max-height: 50vh;
|
|
min-width: 100%;
|
|
overflow: hidden;
|
|
position: relative;
|
|
cursor: var(--pointer);
|
|
|
|
&:${hover},
|
|
&:active,
|
|
&:focus {
|
|
background: ${s("listItemHoverBackground")};
|
|
}
|
|
`;
|
|
|
|
const Content = styled(Flex)`
|
|
color: ${s("textSecondary")};
|
|
margin-left: -4px;
|
|
`;
|
|
|
|
const Title = styled.div`
|
|
${ellipsis()}
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
line-height: 1.25;
|
|
padding-top: 3px;
|
|
color: ${s("text")};
|
|
font-family: ${s("fontFamily")};
|
|
`;
|
|
|
|
function ReferenceListItem({
|
|
document,
|
|
showCollection,
|
|
anchor,
|
|
shareId,
|
|
sidebarContext,
|
|
...rest
|
|
}: Props) {
|
|
const { documents } = useStores();
|
|
const prefetchDocument = useCallback(async () => {
|
|
await documents.prefetchDocument(document.id);
|
|
}, [documents, document.id]);
|
|
const { handleMouseEnter, handleMouseLeave } =
|
|
useClickIntent(prefetchDocument);
|
|
const { icon, color } = document;
|
|
const isEmoji = determineIconType(icon) === IconType.Emoji;
|
|
const title =
|
|
document instanceof Document ? document.titleWithDefault : document.title;
|
|
|
|
return (
|
|
<DocumentLink
|
|
onMouseEnter={handleMouseEnter}
|
|
onMouseLeave={handleMouseLeave}
|
|
to={{
|
|
pathname: shareId
|
|
? sharedModelPath(shareId, document.url)
|
|
: document.url,
|
|
hash: anchor ? `d-${anchor}` : undefined,
|
|
state: {
|
|
title: document.title,
|
|
sidebarContext,
|
|
},
|
|
}}
|
|
{...rest}
|
|
>
|
|
<Content gap={4} dir="auto">
|
|
{icon ? (
|
|
<Icon value={icon} color={color ?? undefined} />
|
|
) : (
|
|
<DocumentIcon />
|
|
)}
|
|
<Title>{isEmoji ? title.replace(icon!, "") : title}</Title>
|
|
</Content>
|
|
</DocumentLink>
|
|
);
|
|
}
|
|
|
|
export default observer(ReferenceListItem);
|