diff --git a/LICENSE b/LICENSE
index cda0806cdd..9d9a38ed1b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -3,7 +3,7 @@ Business Source License 1.1
Parameters
Licensor: General Outline, Inc.
-Licensed Work: Outline 0.80.2
+Licensed Work: Outline 0.81.0
The Licensed Work is (c) 2024 General Outline, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided that
you may not use the Licensed Work for a Document
@@ -15,7 +15,7 @@ Additional Use Grant: You may make use of the Licensed Work, provided that
Licensed Work by creating teams and documents
controlled by such third parties.
-Change Date: 2028-09-26
+Change Date: 2028-11-11
Change License: Apache License, Version 2.0
diff --git a/app/actions/definitions/comments.tsx b/app/actions/definitions/comments.tsx
index 0ed6206eb0..2f430dcd29 100644
--- a/app/actions/definitions/comments.tsx
+++ b/app/actions/definitions/comments.tsx
@@ -1,9 +1,10 @@
-import { DoneIcon, TrashIcon } from "outline-icons";
+import { DoneIcon, SmileyIcon, TrashIcon } from "outline-icons";
import * as React from "react";
import { toast } from "sonner";
import stores from "~/stores";
import Comment from "~/models/Comment";
import CommentDeleteDialog from "~/components/CommentDeleteDialog";
+import ViewReactionsDialog from "~/components/Reactions/ViewReactionsDialog";
import history from "~/utils/history";
import { createAction } from "..";
import { DocumentSection } from "../sections";
@@ -88,3 +89,27 @@ export const unresolveCommentFactory = ({
onUnresolve();
},
});
+
+export const viewCommentReactionsFactory = ({
+ comment,
+}: {
+ comment: Comment;
+}) =>
+ createAction({
+ name: ({ t }) => `${t("View reactions")}`,
+ analyticsName: "View comment reactions",
+ section: DocumentSection,
+ icon: ,
+ visible: () =>
+ stores.policies.abilities(comment.id).read &&
+ comment.reactions.length > 0,
+ perform: ({ t, event }) => {
+ event?.preventDefault();
+ event?.stopPropagation();
+
+ stores.dialogs.openModal({
+ title: t("Reactions"),
+ content: ,
+ });
+ },
+ });
diff --git a/app/actions/definitions/documents.tsx b/app/actions/definitions/documents.tsx
index 99d289b6af..334ad21886 100644
--- a/app/actions/definitions/documents.tsx
+++ b/app/actions/definitions/documents.tsx
@@ -28,6 +28,7 @@ import {
EyeIcon,
PadlockIcon,
GlobeIcon,
+ LogoutIcon,
} from "outline-icons";
import * as React from "react";
import { toast } from "sonner";
@@ -37,6 +38,7 @@ import {
NavigationNode,
} from "@shared/types";
import { getEventFiles } from "@shared/utils/files";
+import UserMembership from "~/models/UserMembership";
import DocumentDelete from "~/scenes/DocumentDelete";
import DocumentMove from "~/scenes/DocumentMove";
import DocumentPermanentDelete from "~/scenes/DocumentPermanentDelete";
@@ -129,11 +131,30 @@ export const createDocumentFromTemplate = createAction({
section: DocumentSection,
icon: ,
keywords: "create",
- visible: ({ currentTeamId, activeDocumentId, stores }) =>
- !!currentTeamId &&
- !!activeDocumentId &&
- !!stores.documents.get(activeDocumentId)?.template &&
- stores.policies.abilities(currentTeamId).createDocument,
+ visible: ({
+ currentTeamId,
+ activeCollectionId,
+ activeDocumentId,
+ stores,
+ }) => {
+ const document = activeDocumentId
+ ? stores.documents.get(activeDocumentId)
+ : undefined;
+
+ if (
+ !currentTeamId ||
+ !document?.isTemplate ||
+ !!document?.isDraft ||
+ !!document?.isDeleted
+ ) {
+ return false;
+ }
+
+ if (activeCollectionId) {
+ return stores.policies.abilities(activeCollectionId).createDocument;
+ }
+ return stores.policies.abilities(currentTeamId).createDocument;
+ },
perform: ({ activeCollectionId, activeDocumentId, sidebarContext }) =>
history.push(
newDocumentPath(activeCollectionId, { templateId: activeDocumentId }),
@@ -1119,6 +1140,42 @@ export const toggleViewerInsights = createAction({
},
});
+export const leaveDocument = createAction({
+ name: ({ t }) => t("Leave document"),
+ analyticsName: "Leave document",
+ section: ActiveDocumentSection,
+ icon: ,
+ visible: ({ currentUserId, activeDocumentId, stores }) => {
+ const membership = stores.userMemberships.orderedData.find(
+ (m) => m.documentId === activeDocumentId && m.userId === currentUserId
+ );
+
+ return !!membership;
+ },
+ perform: async ({ t, location, currentUserId, activeDocumentId, stores }) => {
+ if (!activeDocumentId) {
+ return;
+ }
+
+ const document = stores.documents.get(activeDocumentId);
+
+ try {
+ if (document && location.pathname.startsWith(document.path)) {
+ history.push(homePath());
+ }
+
+ await stores.userMemberships.delete({
+ documentId: activeDocumentId,
+ userId: currentUserId,
+ } as UserMembership);
+
+ toast.success(t("You have left the shared document"));
+ } catch (err) {
+ toast.error(t("Could not leave document"));
+ }
+ },
+});
+
export const rootDocumentActions = [
openDocument,
archiveDocument,
@@ -1137,6 +1194,7 @@ export const rootDocumentActions = [
subscribeDocument,
unsubscribeDocument,
duplicateDocument,
+ leaveDocument,
moveTemplateToWorkspace,
moveDocumentToCollection,
openRandomDocument,
diff --git a/app/actions/definitions/navigation.tsx b/app/actions/definitions/navigation.tsx
index 76d5da3ba9..1283359c5d 100644
--- a/app/actions/definitions/navigation.tsx
+++ b/app/actions/definitions/navigation.tsx
@@ -91,6 +91,15 @@ export const navigateToSettings = createAction({
perform: () => history.push(settingsPath()),
});
+export const navigateToWorkspaceSettings = createAction({
+ name: ({ t }) => t("Settings"),
+ analyticsName: "Navigate to workspace settings",
+ section: NavigationSection,
+ icon: ,
+ visible: () => stores.policies.abilities(stores.auth.team?.id || "").update,
+ perform: () => history.push(settingsPath("details")),
+});
+
export const navigateToProfileSettings = createAction({
name: ({ t }) => t("Profile"),
analyticsName: "Navigate to profile settings",
diff --git a/app/components/CollectionDescription.tsx b/app/components/CollectionDescription.tsx
index fcfe25d27d..b891bc3de3 100644
--- a/app/components/CollectionDescription.tsx
+++ b/app/components/CollectionDescription.tsx
@@ -226,7 +226,7 @@ const Input = styled.div`
}
&[data-editing="true"] {
- background: ${s("secondaryBackground")};
+ background: ${s("backgroundSecondary")};
}
.block-menu-trigger,
diff --git a/app/components/CommandBar/useTemplatesAction.tsx b/app/components/CommandBar/useTemplatesAction.tsx
index 32296531db..16e25618f2 100644
--- a/app/components/CommandBar/useTemplatesAction.tsx
+++ b/app/components/CommandBar/useTemplatesAction.tsx
@@ -2,7 +2,11 @@ import { NewDocumentIcon, ShapesIcon } from "outline-icons";
import * as React from "react";
import Icon from "~/components/Icon";
import { createAction } from "~/actions";
-import { DocumentSection } from "~/actions/sections";
+import {
+ ActiveCollectionSection,
+ DocumentSection,
+ TeamSection,
+} from "~/actions/sections";
import useStores from "~/hooks/useStores";
import history from "~/utils/history";
import { newDocumentPath } from "~/utils/routeHelpers";
@@ -11,26 +15,42 @@ const useTemplatesAction = () => {
const { documents } = useStores();
React.useEffect(() => {
- void documents.fetchTemplates();
+ void documents.fetchAllTemplates();
}, [documents]);
const actions = React.useMemo(
() =>
- documents.templatesAlphabetical.map((item) =>
+ documents.templatesAlphabetical.map((template) =>
createAction({
- name: item.titleWithDefault,
+ name: template.titleWithDefault,
analyticsName: "New document",
- section: DocumentSection,
- icon: item.icon ? (
-
+ section: template.isWorkspaceTemplate
+ ? TeamSection
+ : ActiveCollectionSection,
+ icon: template.icon ? (
+
) : (
),
keywords: "create",
+ visible: ({ currentTeamId, activeCollectionId, stores }) => {
+ if (activeCollectionId) {
+ return (
+ stores.policies.abilities(activeCollectionId).createDocument &&
+ (template.collectionId === activeCollectionId ||
+ template.isWorkspaceTemplate)
+ );
+ }
+ return (
+ !!currentTeamId &&
+ stores.policies.abilities(currentTeamId).createDocument &&
+ template.isWorkspaceTemplate
+ );
+ },
perform: ({ activeCollectionId, sidebarContext }) =>
history.push(
- newDocumentPath(item.collectionId ?? activeCollectionId, {
- templateId: item.id,
+ newDocumentPath(template.collectionId ?? activeCollectionId, {
+ templateId: template.id,
}),
{
sidebarContext,
@@ -49,9 +69,15 @@ const useTemplatesAction = () => {
placeholder: ({ t }) => t("Choose a template"),
section: DocumentSection,
icon: ,
- visible: ({ currentTeamId, stores }) =>
- !!currentTeamId &&
- stores.policies.abilities(currentTeamId).createDocument,
+ visible: ({ currentTeamId, activeCollectionId, stores }) => {
+ if (activeCollectionId) {
+ return stores.policies.abilities(activeCollectionId).createDocument;
+ }
+ return (
+ !!currentTeamId &&
+ stores.policies.abilities(currentTeamId).createDocument
+ );
+ },
children: () => actions,
}),
[actions]
diff --git a/app/components/DocumentContext.tsx b/app/components/DocumentContext.tsx
index 38808b6408..e7584da577 100644
--- a/app/components/DocumentContext.tsx
+++ b/app/components/DocumentContext.tsx
@@ -11,6 +11,9 @@ class DocumentContext {
/** The editor instance for this document */
editor?: Editor;
+ @observable
+ isEditorInitialized: boolean = false;
+
@observable
headings: Heading[] = [];
@@ -31,6 +34,11 @@ class DocumentContext {
this.updateState();
};
+ @action
+ setEditorInitialized = (initialized: boolean) => {
+ this.isEditorInitialized = initialized;
+ };
+
@action
updateState = () => {
this.updateHeadings();
diff --git a/app/components/Editor.tsx b/app/components/Editor.tsx
index 27b07849c5..21a9652ab3 100644
--- a/app/components/Editor.tsx
+++ b/app/components/Editor.tsx
@@ -98,7 +98,7 @@ function Editor(props: Props, ref: React.RefObject | null) {
}
// default search for anything that doesn't look like a URL
- const results = await documents.searchTitles(term);
+ const results = await documents.searchTitles({ query: term });
return sortBy(
results.map(({ document }) => ({
@@ -255,6 +255,7 @@ function Editor(props: Props, ref: React.RefObject | null) {
<>
| null) {
placeholder={props.placeholder || ""}
defaultValue={props.defaultValue || ""}
/>
- {props.editorStyle?.paddingBottom && !props.readOnly && (
-
- )}
+ {props.editorStyle?.paddingBottom &&
+ (!props.readOnly || props.shareId) && (
+
+ )}
>
);
diff --git a/app/components/Emoji.tsx b/app/components/Emoji.tsx
new file mode 100644
index 0000000000..5c5441e9dc
--- /dev/null
+++ b/app/components/Emoji.tsx
@@ -0,0 +1,20 @@
+import styled from "styled-components";
+import { s } from "@shared/styles";
+
+type Props = {
+ /** Width of the containing element. */
+ width?: number | string;
+ /** Height of the containing element. */
+ height?: number | string;
+ /** Controls the rendered emoji size. */
+ size?: number;
+};
+
+export const Emoji = styled.span`
+ font-family: ${s("fontFamilyEmoji")};
+ width: ${({ width }) =>
+ typeof width === "string" ? width : width ? `${width}px` : "auto"};
+ height: ${({ height }) =>
+ typeof height === "string" ? height : height ? `${height}px` : "auto"};
+ font-size: ${({ size }) => size && `${size}px`};
+`;
diff --git a/app/components/ErrorBoundary.tsx b/app/components/ErrorBoundary.tsx
index e2a0dcd1c9..207da6a698 100644
--- a/app/components/ErrorBoundary.tsx
+++ b/app/components/ErrorBoundary.tsx
@@ -138,7 +138,7 @@ class ErrorBoundary extends React.Component {
}
const Pre = styled.pre`
- background: ${s("secondaryBackground")};
+ background: ${s("backgroundSecondary")};
padding: 16px;
border-radius: 4px;
font-size: 12px;
diff --git a/app/components/EventListItem.tsx b/app/components/EventListItem.tsx
index 6f7bbe76cb..06d7c4abdb 100644
--- a/app/components/EventListItem.tsx
+++ b/app/components/EventListItem.tsx
@@ -27,7 +27,7 @@ import { documentHistoryPath } from "~/utils/routeHelpers";
type Props = {
document: Document;
- event: Event;
+ event: Event;
latest?: boolean;
};
diff --git a/app/components/GroupListItem.tsx b/app/components/GroupListItem.tsx
index ac18bc1b6f..8081525808 100644
--- a/app/components/GroupListItem.tsx
+++ b/app/components/GroupListItem.tsx
@@ -75,7 +75,7 @@ const Image = styled(Flex)`
justify-content: center;
width: 32px;
height: 32px;
- background: ${s("secondaryBackground")};
+ background: ${s("backgroundSecondary")};
border-radius: 32px;
`;
diff --git a/app/components/Header.tsx b/app/components/Header.tsx
index f62bdbe492..c2e9c43430 100644
--- a/app/components/Header.tsx
+++ b/app/components/Header.tsx
@@ -16,6 +16,8 @@ import useStores from "~/hooks/useStores";
import { draggableOnDesktop, fadeOnDesktopBackgrounded } from "~/styles";
import Desktop from "~/utils/Desktop";
+export const HEADER_HEIGHT = 64;
+
type Props = {
left?: React.ReactNode;
title: React.ReactNode;
@@ -130,7 +132,7 @@ const Wrapper = styled(Flex)`
padding: 12px;
transition: all 100ms ease-out;
transform: translate3d(0, 0, 0);
- min-height: 64px;
+ min-height: ${HEADER_HEIGHT}px;
justify-content: flex-start;
${draggableOnDesktop()}
diff --git a/app/components/HoverPreview/Components.tsx b/app/components/HoverPreview/Components.tsx
index 8f2b1dffc9..f56cf13625 100644
--- a/app/components/HoverPreview/Components.tsx
+++ b/app/components/HoverPreview/Components.tsx
@@ -61,7 +61,7 @@ export const Label = styled(Text).attrs({ size: "xsmall", weight: "bold" })<{
color?: string;
}>`
background-color: ${(props) =>
- props.color ?? props.theme.secondaryBackground};
+ props.color ?? props.theme.backgroundSecondary};
color: ${(props) =>
props.color ? getTextColor(props.color) : props.theme.text};
width: fit-content;
diff --git a/app/components/HoverPreview/HoverPreview.tsx b/app/components/HoverPreview/HoverPreview.tsx
index 4d1c6ec0bd..c6a79d8f6e 100644
--- a/app/components/HoverPreview/HoverPreview.tsx
+++ b/app/components/HoverPreview/HoverPreview.tsx
@@ -125,6 +125,7 @@ function HoverPreviewDesktop({ element, data, dataLoading, onClose }: Props) {
avatarUrl={data.avatarUrl}
color={data.color}
lastActive={data.lastActive}
+ email={data.email}
/>
) : data.type === UnfurlResourceType.Document ? (
;
const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
- { avatarUrl, name, lastActive, color }: Props,
+ { avatarUrl, name, lastActive, color, email }: Props,
ref: React.Ref
) {
return (
@@ -25,6 +25,7 @@ const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
/>
{name}
+ {email && {email}}
{lastActive}
diff --git a/app/components/IconPicker/components/Emoji.tsx b/app/components/IconPicker/components/Emoji.tsx
deleted file mode 100644
index 2223147282..0000000000
--- a/app/components/IconPicker/components/Emoji.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-import styled from "styled-components";
-import { s } from "@shared/styles";
-
-export const Emoji = styled.span`
- font-family: ${s("fontFamilyEmoji")};
- width: 24px;
- height: 24px;
-`;
diff --git a/app/components/IconPicker/components/EmojiPanel.tsx b/app/components/IconPicker/components/EmojiPanel.tsx
index 1bc22a362a..2297d029e4 100644
--- a/app/components/IconPicker/components/EmojiPanel.tsx
+++ b/app/components/IconPicker/components/EmojiPanel.tsx
@@ -18,11 +18,7 @@ import {
import GridTemplate, { DataNode } from "./GridTemplate";
import SkinTonePicker from "./SkinTonePicker";
-/**
- * This is needed as a constant for react-window.
- * Calculated from the heights of TabPanel and InputSearch.
- */
-const GRID_HEIGHT = 362;
+const GRID_HEIGHT = 410;
const useEmojiState = () => {
const [emojiSkinTone, setEmojiSkinTone] = usePersistedState(
@@ -80,6 +76,7 @@ type Props = {
panelWidth: number;
query: string;
panelActive: boolean;
+ height?: number;
onEmojiChange: (emoji: string) => void;
onQueryChange: (query: string) => void;
};
@@ -90,6 +87,7 @@ const EmojiPanel = ({
panelActive,
onEmojiChange,
onQueryChange,
+ height = GRID_HEIGHT,
}: Props) => {
const { t } = useTranslation();
@@ -159,7 +157,7 @@ const EmojiPanel = ({
diff --git a/app/components/IconPicker/components/GridTemplate.tsx b/app/components/IconPicker/components/GridTemplate.tsx
index c3abc3589c..832a5e1c70 100644
--- a/app/components/IconPicker/components/GridTemplate.tsx
+++ b/app/components/IconPicker/components/GridTemplate.tsx
@@ -4,9 +4,9 @@ import React from "react";
import styled from "styled-components";
import { IconType } from "@shared/types";
import { IconLibrary } from "@shared/utils/IconLibrary";
+import { Emoji } from "~/components/Emoji";
import Text from "~/components/Text";
import { TRANSLATED_CATEGORIES } from "../utils";
-import { Emoji } from "./Emoji";
import Grid from "./Grid";
import { IconButton } from "./IconButton";
@@ -85,7 +85,9 @@ const GridTemplate = (
key={item.id}
onClick={() => onIconSelect({ id: item.id, value: item.value })}
>
- {item.value}
+
+ {item.value}
+
);
});
diff --git a/app/components/IconPicker/components/SkinTonePicker.tsx b/app/components/IconPicker/components/SkinTonePicker.tsx
index 2061fd302d..bea78e3451 100644
--- a/app/components/IconPicker/components/SkinTonePicker.tsx
+++ b/app/components/IconPicker/components/SkinTonePicker.tsx
@@ -5,10 +5,10 @@ import styled from "styled-components";
import { depths, s } from "@shared/styles";
import { EmojiSkinTone } from "@shared/types";
import { getEmojiVariants } from "@shared/utils/emoji";
+import { Emoji } from "~/components/Emoji";
import Flex from "~/components/Flex";
import NudeButton from "~/components/NudeButton";
import { hover } from "~/styles";
-import { Emoji } from "./Emoji";
import { IconButton } from "./IconButton";
const SkinTonePicker = ({
@@ -26,7 +26,7 @@ const SkinTonePicker = ({
);
const menu = useMenuState({
- placement: "bottom",
+ placement: "bottom-end",
});
const handleSkinClick = React.useCallback(
@@ -43,7 +43,9 @@ const SkinTonePicker = ({
diff --git a/app/components/IconPicker/index.tsx b/app/components/IconPicker/index.tsx
index a1261942ee..c087673f21 100644
--- a/app/components/IconPicker/index.tsx
+++ b/app/components/IconPicker/index.tsx
@@ -82,6 +82,7 @@ const IconPicker = ({
modal: true,
unstable_offset: [0, 0],
});
+ const { hide, show, visible } = popover;
const tab = useTabState({ selectedId: defaultTab });
const previouslyVisible = usePrevious(popover.visible);
@@ -96,12 +97,12 @@ const IconPicker = ({
const handleIconChange = React.useCallback(
(ic: string) => {
- popover.hide();
+ hide();
const icType = determineIconType(ic);
const finalColor = icType === IconType.SVG ? chosenColor : null;
onChange(ic, finalColor);
},
- [popover, onChange, chosenColor]
+ [hide, onChange, chosenColor]
);
const handleIconColorChange = React.useCallback(
@@ -118,32 +119,32 @@ const IconPicker = ({
);
const handleIconRemove = React.useCallback(() => {
- popover.hide();
+ hide();
onChange(null, null);
- }, [popover, onChange]);
+ }, [hide, onChange]);
const handlePopoverButtonClick = React.useCallback(
(ev: React.MouseEvent) => {
ev.stopPropagation();
- if (popover.visible) {
- popover.hide();
+ if (visible) {
+ hide();
} else {
- popover.show();
+ show();
}
},
- [popover]
+ [hide, show, visible]
);
// Popover open effect
React.useEffect(() => {
- if (popover.visible && !previouslyVisible) {
+ if (visible && !previouslyVisible) {
onOpen?.();
- } else if (!popover.visible && previouslyVisible) {
+ } else if (!visible && previouslyVisible) {
onClose?.();
setQuery("");
resetDefaultTab();
}
- }, [popover.visible, previouslyVisible, onOpen, onClose, resetDefaultTab]);
+ }, [visible, previouslyVisible, onOpen, onClose, resetDefaultTab]);
// Custom click outside handling rather than using `hideOnClickOutside` from reakit so that we can
// prevent event bubbling.
diff --git a/app/components/InputSelect.tsx b/app/components/InputSelect.tsx
index 3c4214c793..6552c84b8a 100644
--- a/app/components/InputSelect.tsx
+++ b/app/components/InputSelect.tsx
@@ -10,7 +10,7 @@ import * as React from "react";
import { VisuallyHidden } from "reakit/VisuallyHidden";
import styled, { css } from "styled-components";
import { s } from "@shared/styles";
-import Button, { Inner } from "~/components/Button";
+import Button, { Props as ButtonProps, Inner } from "~/components/Button";
import Text from "~/components/Text";
import useMenuHeight from "~/hooks/useMenuHeight";
import useMobile from "~/hooks/useMobile";
@@ -33,7 +33,7 @@ export type Option = {
divider?: boolean;
};
-export type Props = {
+export type Props = Omit, "onChange"> & {
id?: string;
name?: string;
value?: string | null;
@@ -313,7 +313,7 @@ const StyledButton = styled(Button)<{ $nude?: boolean }>`
margin-bottom: 16px;
display: block;
width: 100%;
- cursor: default;
+ cursor: var(--pointer);
&:hover:not(:disabled) {
background: ${s("buttonNeutralBackground")};
diff --git a/app/components/List/Item.tsx b/app/components/List/Item.tsx
index 1ea2d2d042..5dfe31560f 100644
--- a/app/components/List/Item.tsx
+++ b/app/components/List/Item.tsx
@@ -192,7 +192,7 @@ const Wrapper = styled.a<{
&:focus,
&:focus-within {
background: ${(props) =>
- props.$hover ? props.theme.secondaryBackground : "inherit"};
+ props.$hover ? props.theme.backgroundSecondary : "inherit"};
}
cursor: ${(props) =>
diff --git a/app/components/Notifications/Notifications.tsx b/app/components/Notifications/Notifications.tsx
index 95f68d6870..9754e4c43c 100644
--- a/app/components/Notifications/Notifications.tsx
+++ b/app/components/Notifications/Notifications.tsx
@@ -24,13 +24,15 @@ import NotificationListItem from "./NotificationListItem";
type Props = {
/** Callback when the notification panel wants to close. */
onRequestClose: () => void;
+ /** Whether the panel is open or not. */
+ isOpen: boolean;
};
/**
* A panel containing a list of notifications and controls to manage them.
*/
function Notifications(
- { onRequestClose }: Props,
+ { onRequestClose, isOpen }: Props,
ref: React.RefObject
) {
const context = useActionContext();
@@ -72,7 +74,7 @@ function Notifications(
(
{
shrink
flex
>
-
+
>
);
diff --git a/app/components/PaginatedEventList.tsx b/app/components/PaginatedEventList.tsx
index 6de167b0ea..ebfbe5e8fc 100644
--- a/app/components/PaginatedEventList.tsx
+++ b/app/components/PaginatedEventList.tsx
@@ -6,9 +6,11 @@ import PaginatedList from "~/components/PaginatedList";
import EventListItem from "./EventListItem";
type Props = {
- events: Event[];
+ events: Event[];
document: Document;
- fetch: (options: Record | undefined) => Promise;
+ fetch: (
+ options: Record | undefined
+ ) => Promise[]>;
options?: Record;
heading?: React.ReactNode;
empty?: React.ReactNode;
@@ -30,7 +32,7 @@ const PaginatedEventList = React.memo(function PaginatedEventList({
heading={heading}
fetch={fetch}
options={options}
- renderItem={(item: Event, index) => (
+ renderItem={(item: Event, index) => (
Promise;
+ /** Callback when the user intends to remove the reaction. */
+ onRemoveReaction: (emoji: string) => Promise;
+};
+
+const useTooltipContent = ({
+ reactedUsers,
+ currUser,
+ emoji,
+ active,
+}: {
+ reactedUsers: User[];
+ currUser: User;
+ emoji: string;
+ active: boolean;
+}) => {
+ const { t } = useTranslation();
+
+ if (!reactedUsers.length) {
+ return;
+ }
+
+ const transformedEmoji = `:${getEmojiId(emoji)}:`;
+
+ switch (reactedUsers.length) {
+ case 1: {
+ return t("{{ username }} reacted with {{ emoji }}", {
+ username: active ? t("You") : reactedUsers[0].name,
+ emoji: transformedEmoji,
+ });
+ }
+
+ case 2: {
+ const firstUsername = active ? t("You") : reactedUsers[0].name;
+ const secondUsername = active
+ ? reactedUsers.find((user) => user.id !== currUser.id)?.name
+ : reactedUsers[1].name;
+
+ return t(
+ "{{ firstUsername }} and {{ secondUsername }} reacted with {{ emoji }}",
+ {
+ firstUsername,
+ secondUsername,
+ emoji: transformedEmoji,
+ }
+ );
+ }
+
+ default: {
+ const firstUsername = active ? t("You") : reactedUsers[0].name;
+ const count = reactedUsers.length - 1;
+
+ return t(
+ "{{ firstUsername }} and {{ count }} others reacted with {{ emoji }}",
+ {
+ firstUsername,
+ count,
+ emoji: transformedEmoji,
+ }
+ );
+ }
+ }
+};
+
+const Reaction: React.FC = ({
+ reaction,
+ reactedUsers,
+ disabled,
+ onAddReaction,
+ onRemoveReaction,
+}) => {
+ const user = useCurrentUser();
+
+ const active = reaction.userIds.includes(user.id);
+
+ const tooltipContent = useTooltipContent({
+ reactedUsers,
+ currUser: user,
+ emoji: reaction.emoji,
+ active,
+ });
+
+ const handleClick = React.useCallback(
+ (event: React.SyntheticEvent) => {
+ event.stopPropagation();
+ active
+ ? void onRemoveReaction(reaction.emoji)
+ : void onAddReaction(reaction.emoji);
+ },
+ [reaction, active, onAddReaction, onRemoveReaction]
+ );
+
+ const DisplayedEmoji = React.useMemo(
+ () => (
+
+
+ {reaction.emoji}
+ {reaction.userIds.length}
+
+
+ ),
+ [reaction.emoji, reaction.userIds, disabled, active, handleClick]
+ );
+
+ return tooltipContent ? (
+
+ {DisplayedEmoji}
+
+ ) : (
+ <>{DisplayedEmoji}>
+ );
+};
+
+const EmojiButton = styled(NudeButton)<{
+ $active: boolean;
+ disabled: boolean;
+}>`
+ width: auto;
+ height: 28px;
+ padding: 6px;
+ border-radius: 12px;
+ transition: ${s("backgroundTransition")};
+ background: ${s("backgroundTertiary")};
+ pointer-events: ${({ disabled }) => disabled && "none"};
+
+ &: ${hover} {
+ background: ${s("backgroundQuaternary")};
+ }
+
+ ${(props) =>
+ props.$active &&
+ css`
+ background: ${transparentize(0.7, props.theme.accent)};
+
+ &: ${hover} {
+ background: ${transparentize(0.5, props.theme.accent)};
+ }
+ `}
+`;
+
+const Count = styled(Text)`
+ font-size: 11px;
+ color: ${s("buttonNeutralText")};
+ padding-right: 1px;
+ font-variant-numeric: tabular-nums;
+`;
+
+export default observer(Reaction);
diff --git a/app/components/Reactions/ReactionList.tsx b/app/components/Reactions/ReactionList.tsx
new file mode 100644
index 0000000000..fbe5b94697
--- /dev/null
+++ b/app/components/Reactions/ReactionList.tsx
@@ -0,0 +1,87 @@
+import compact from "lodash/compact";
+import { observer } from "mobx-react";
+import React from "react";
+import Comment from "~/models/Comment";
+import useHover from "~/hooks/useHover";
+import useStores from "~/hooks/useStores";
+import Logger from "~/utils/Logger";
+import Flex from "../Flex";
+import { ResizingHeightContainer } from "../ResizingHeightContainer";
+import Reaction from "./Reaction";
+
+type Props = {
+ /** Model for which to show the reactions. */
+ model: Comment;
+ /** Callback when the user intends to add a reaction. */
+ onAddReaction: (emoji: string) => Promise;
+ /** Callback when the user intends to remove a reaction. */
+ onRemoveReaction: (emoji: string) => Promise;
+ /** classname generated by styled-components. */
+ className?: string;
+ /** Picker to render as the last element */
+ picker?: React.ReactElement;
+};
+
+const ReactionList: React.FC = ({
+ model,
+ onAddReaction,
+ onRemoveReaction,
+ className,
+ picker,
+}) => {
+ const { users } = useStores();
+ const listRef = React.useRef(null);
+
+ const hovered = useHover({
+ ref: listRef,
+ duration: 250,
+ });
+
+ React.useEffect(() => {
+ const loadReactedUsersData = async () => {
+ try {
+ await model.loadReactedUsersData();
+ } catch (err) {
+ Logger.warn("Could not prefetch reaction data");
+ }
+ };
+
+ if (hovered) {
+ void loadReactedUsersData();
+ }
+ }, [hovered, model]);
+
+ const hasReactions = !!model.reactions.length;
+ const style = React.useMemo(() => {
+ if (hasReactions) {
+ return { minHeight: 28 };
+ }
+ return undefined;
+ }, [hasReactions]);
+
+ return (
+
+
+ {model.reactions.map((reaction) => {
+ const reactedUsers = compact(
+ reaction.userIds.map((id) => users.get(id))
+ );
+
+ return (
+
+ );
+ })}
+ {picker}
+
+
+ );
+};
+
+export default observer(ReactionList);
diff --git a/app/components/Reactions/ReactionPicker.tsx b/app/components/Reactions/ReactionPicker.tsx
new file mode 100644
index 0000000000..72e329fc25
--- /dev/null
+++ b/app/components/Reactions/ReactionPicker.tsx
@@ -0,0 +1,158 @@
+import { ReactionIcon } from "outline-icons";
+import React from "react";
+import { useTranslation } from "react-i18next";
+import { PopoverDisclosure, usePopoverState } from "reakit";
+import styled from "styled-components";
+import EventBoundary from "@shared/components/EventBoundary";
+import Flex from "~/components/Flex";
+import NudeButton from "~/components/NudeButton";
+import PlaceholderText from "~/components/PlaceholderText";
+import Popover from "~/components/Popover";
+import useMobile from "~/hooks/useMobile";
+import useOnClickOutside from "~/hooks/useOnClickOutside";
+import useWindowSize from "~/hooks/useWindowSize";
+
+const EmojiPanel = React.lazy(
+ () => import("~/components/IconPicker/components/EmojiPanel")
+);
+
+type Props = {
+ /** Callback when an emoji is selected by the user. */
+ onSelect: (emoji: string) => Promise;
+ /** Callback when the picker is opened. */
+ onOpen?: () => void;
+ /** Callback when the picker is closed. */
+ onClose?: () => void;
+ /** Optional classname. */
+ className?: string;
+ size?: number;
+};
+
+const ReactionPicker: React.FC = ({
+ onSelect,
+ onOpen,
+ onClose,
+ className,
+ size,
+}) => {
+ const { t } = useTranslation();
+ const popover = usePopoverState({
+ modal: true,
+ unstable_offset: [0, 0],
+ placement: "bottom-end",
+ });
+
+ const { width: windowWidth } = useWindowSize();
+ const isMobile = useMobile();
+
+ const [query, setQuery] = React.useState("");
+ const contentRef = React.useRef(null);
+
+ const popoverWidth = isMobile ? windowWidth : 300;
+ // In mobile, popover is absolutely positioned to leave 8px on both sides.
+ const panelWidth = isMobile ? windowWidth - 16 : popoverWidth;
+ const { toggle, hide } = popover;
+ const handlePopoverButtonClick = React.useCallback(
+ (ev: React.MouseEvent) => {
+ ev.stopPropagation();
+ toggle();
+ },
+ [toggle]
+ );
+
+ const handleEmojiSelect = React.useCallback(
+ (emoji: string) => {
+ hide();
+ void onSelect(emoji);
+ },
+ [hide, onSelect]
+ );
+
+ // Popover open effect
+ React.useEffect(() => {
+ if (popover.visible) {
+ onOpen?.();
+ } else {
+ onClose?.();
+ }
+ }, [popover.visible, onOpen, onClose]);
+
+ // Custom click outside handling rather than using `hideOnClickOutside` from reakit so that we can
+ // prevent event bubbling.
+ useOnClickOutside(
+ contentRef,
+ (event) => {
+ if (
+ popover.visible &&
+ !popover.unstable_disclosureRef.current?.contains(event.target as Node)
+ ) {
+ event.stopPropagation();
+ event.preventDefault();
+ popover.hide();
+ }
+ },
+ { capture: true }
+ );
+
+ return (
+ <>
+
+ {(props) => (
+
+
+
+ )}
+
+ e.stopPropagation()}
+ hideOnClickOutside={false}
+ >
+ {popover.visible && (
+ }>
+
+
+
+
+ )}
+
+ >
+ );
+};
+
+const Placeholder = React.memo(
+ () => (
+
+
+
+
+
+
+
+ ),
+ () => true
+);
+Placeholder.displayName = "ReactionPickerPlaceholder";
+
+const PopoverButton = styled(NudeButton)`
+ border-radius: 50%;
+`;
+
+export default ReactionPicker;
diff --git a/app/components/Reactions/ViewReactionsDialog.tsx b/app/components/Reactions/ViewReactionsDialog.tsx
new file mode 100644
index 0000000000..f824d43fb9
--- /dev/null
+++ b/app/components/Reactions/ViewReactionsDialog.tsx
@@ -0,0 +1,146 @@
+import compact from "lodash/compact";
+import { observer } from "mobx-react";
+import React from "react";
+import { useTranslation } from "react-i18next";
+import { Tab, TabPanel, useTabState } from "reakit";
+import { toast } from "sonner";
+import styled, { css } from "styled-components";
+import { s } from "@shared/styles";
+import Comment from "~/models/Comment";
+import { Avatar, AvatarSize } from "~/components/Avatar";
+import { Emoji } from "~/components/Emoji";
+import Flex from "~/components/Flex";
+import PlaceholderText from "~/components/PlaceholderText";
+import Text from "~/components/Text";
+import useStores from "~/hooks/useStores";
+import { hover } from "~/styles";
+
+type Props = {
+ /** Model for which to show the reactions. */
+ model: Comment;
+};
+
+const ViewReactionsDialog: React.FC = ({ model }) => {
+ const { t } = useTranslation();
+ const { users } = useStores();
+ const tab = useTabState();
+ const { reactedUsersLoaded } = model;
+
+ React.useEffect(() => {
+ const loadReactedUsersData = async () => {
+ try {
+ await model.loadReactedUsersData();
+ } catch (err) {
+ toast.error(t("Could not load reactions"));
+ }
+ };
+
+ void loadReactedUsersData();
+ }, [t, model]);
+
+ if (!reactedUsersLoaded) {
+ return ;
+ }
+
+ return (
+ <>
+
+ {model.reactions.map((reaction) => (
+
+ {reaction.emoji}
+
+ ))}
+
+ {model.reactions.map((reaction) => {
+ const reactedUsers = compact(
+ reaction.userIds.map((id) => users.get(id))
+ );
+
+ return (
+
+ {reactedUsers.map((user) => (
+
+
+ {user.name}
+
+ ))}
+
+ );
+ })}
+ >
+ );
+};
+
+const PlaceHolder = React.memo(
+ () => (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ ),
+ () => true
+);
+PlaceHolder.displayName = "ViewReactionsPlaceholder";
+
+const TabActionsWrapper = styled(Flex)`
+ border-bottom: 1px solid ${s("inputBorder")};
+`;
+
+const StyledTab = styled(Tab)<{ $active: boolean }>`
+ position: relative;
+ font-weight: 500;
+ font-size: 14px;
+ cursor: var(--pointer);
+ background: none;
+ border: 0;
+ border-radius: 4px 4px 0 0;
+ padding: 8px 12px 10px;
+ user-select: none;
+ transition: background-color 100ms ease;
+
+ &: ${hover} {
+ background-color: ${s("listItemHoverBackground")};
+ }
+
+ ${({ $active }) =>
+ $active &&
+ css`
+ &:after {
+ content: "";
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ height: 1px;
+ background: ${s("textSecondary")};
+ }
+ `}
+`;
+
+const StyledTabPanel = styled(TabPanel)`
+ height: 300px;
+ padding: 5px 0;
+ overflow-y: auto;
+`;
+
+const UserInfo = styled(Flex)`
+ padding: 10px 8px;
+`;
+
+export default observer(ViewReactionsDialog);
diff --git a/app/components/SearchPopover.tsx b/app/components/SearchPopover.tsx
index 0548b91bd1..4ac2bcc523 100644
--- a/app/components/SearchPopover.tsx
+++ b/app/components/SearchPopover.tsx
@@ -19,9 +19,10 @@ import SearchListItem from "./SearchListItem";
interface Props extends React.HTMLAttributes {
shareId: string;
+ className?: string;
}
-function SearchPopover({ shareId }: Props) {
+function SearchPopover({ shareId, className }: Props) {
const { t } = useTranslation();
const { documents } = useStores();
const focusRef = React.useRef(null);
@@ -54,7 +55,8 @@ function SearchPopover({ shareId }: Props) {
const performSearch = React.useCallback(
async ({ query, ...options }) => {
if (query?.length > 0) {
- const response = await documents.search(query, {
+ const response = await documents.search({
+ query,
shareId,
...options,
});
@@ -186,6 +188,7 @@ function SearchPopover({ shareId }: Props) {
onChange={handleSearchInputChange}
onFocus={handleSearchInputFocus}
onKeyDown={handleKeyDown}
+ className={className}
/>
)}
diff --git a/app/components/Sharing/Document/PublicAccess.tsx b/app/components/Sharing/Document/PublicAccess.tsx
index 38353e7099..985250cc82 100644
--- a/app/components/Sharing/Document/PublicAccess.tsx
+++ b/app/components/Sharing/Document/PublicAccess.tsx
@@ -1,12 +1,13 @@
import debounce from "lodash/debounce";
import isEmpty from "lodash/isEmpty";
import { observer } from "mobx-react";
-import { CopyIcon, GlobeIcon, InfoIcon } from "outline-icons";
+import { CopyIcon, GlobeIcon, InfoIcon, QuestionMarkIcon } from "outline-icons";
import * as React from "react";
import { Trans, useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { toast } from "sonner";
import styled, { useTheme } from "styled-components";
+import Flex from "@shared/components/Flex";
import Squircle from "@shared/components/Squircle";
import { s } from "@shared/styles";
import { UrlHelper } from "@shared/utils/UrlHelper";
@@ -50,6 +51,19 @@ function PublicAccess({ document, share, sharedParent }: Props) {
setUrlId(share?.urlId);
}, [share?.urlId]);
+ const handleIndexingChanged = React.useCallback(
+ async (event) => {
+ try {
+ await share?.save({
+ allowIndexing: event.currentTarget.checked,
+ });
+ } catch (err) {
+ toast.error(err.message);
+ }
+ },
+ [share]
+ );
+
const handlePublishedChange = React.useCallback(
async (event) => {
try {
@@ -153,6 +167,32 @@ function PublicAccess({ document, share, sharedParent }: Props) {
/>
+ {share?.published && (
+
+ {t("Search engine indexing")}
+
+
+
+
+ }
+ actions={
+
+ }
+ />
+ )}
+
{sharedParent?.published ? (
{copyButton}
diff --git a/app/components/Sidebar/App.tsx b/app/components/Sidebar/App.tsx
index e3bfd91d47..bddd91648e 100644
--- a/app/components/Sidebar/App.tsx
+++ b/app/components/Sidebar/App.tsx
@@ -94,38 +94,40 @@ function AppSidebar() {
)}
-
- }
- exact={false}
- label={t("Home")}
- />
- }
- label={t("Search")}
- exact={false}
- />
- {can.createDocument && (
+
+
}
- label={
-
- {t("Drafts")}
- {documents.totalDrafts > 0 ? (
-
- {documents.totalDrafts > 25
- ? "25+"
- : documents.totalDrafts}
-
- ) : null}
-
- }
+ to={homePath()}
+ icon={}
+ exact={false}
+ label={t("Home")}
/>
- )}
-
+ }
+ label={t("Search")}
+ exact={false}
+ />
+ {can.createDocument && (
+ }
+ label={
+
+ {t("Drafts")}
+ {documents.totalDrafts > 0 ? (
+
+ {documents.totalDrafts > 25
+ ? "25+"
+ : documents.totalDrafts}
+
+ ) : null}
+
+ }
+ />
+ )}
+
+
@@ -152,6 +154,11 @@ function AppSidebar() {
);
}
+const Overflow = styled.div`
+ overflow: hidden;
+ flex-shrink: 0;
+`;
+
const Drafts = styled(Text)`
margin: 0 4px;
`;
diff --git a/app/components/Sidebar/Shared.tsx b/app/components/Sidebar/Shared.tsx
index 129cd3060a..23dc4ef87d 100644
--- a/app/components/Sidebar/Shared.tsx
+++ b/app/components/Sidebar/Shared.tsx
@@ -1,13 +1,18 @@
import { observer } from "mobx-react";
+import { SidebarIcon } from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import { NavigationNode } from "@shared/types";
+import Flex from "~/components/Flex";
import Scrollable from "~/components/Scrollable";
import SearchPopover from "~/components/SearchPopover";
+import Tooltip from "~/components/Tooltip";
import useCurrentUser from "~/hooks/useCurrentUser";
import useStores from "~/hooks/useStores";
+import { hover } from "~/styles";
import history from "~/utils/history";
+import { metaDisplay } from "~/utils/keyboard";
import { homePath, sharedDocumentPath } from "~/utils/routeHelpers";
import { useTeamContext } from "../TeamContext";
import TeamLogo from "../TeamLogo";
@@ -15,6 +20,7 @@ import Sidebar from "./Sidebar";
import Section from "./components/Section";
import DocumentLink from "./components/SharedDocumentLink";
import SidebarButton from "./components/SidebarButton";
+import ToggleButton from "./components/ToggleButton";
type Props = {
rootNode: NavigationNode;
@@ -27,9 +33,11 @@ function SharedSidebar({ rootNode, shareId }: Props) {
const { ui, documents } = useStores();
const { t } = useTranslation();
+ const teamAvailable = !!team?.name;
+
return (
-
- {team?.name && (
+
+ {teamAvailable && (
}
@@ -38,11 +46,20 @@ function SharedSidebar({ rootNode, shareId }: Props) {
user ? homePath() : sharedDocumentPath(shareId, rootNode.url)
)
}
- />
+ >
+
+
)}
-
+
+
+
+ {!teamAvailable && (
+
+
+
+ )}
-
+
);
}
+const ToggleSidebar = () => {
+ const { t } = useTranslation();
+ const { ui } = useStores();
+
+ return (
+
+ }
+ onClick={() => {
+ ui.toggleCollapsedSidebar();
+ (document.activeElement as HTMLElement)?.blur();
+ }}
+ />
+
+ );
+};
+
const ScrollContainer = styled(Scrollable)`
padding-bottom: 16px;
`;
-const TopSection = styled(Section)`
- // this weird looking && increases the specificity of the style rule
- &&:first-child {
- margin-top: 16px;
- }
+const TopSection = styled(Flex)`
+ padding: 8px;
+ flex-shrink: 0;
+`;
- && {
- margin-bottom: 16px;
- }
+const SearchWrapper = styled.div`
+ width: 100%;
+`;
+
+const StyledSearchPopover = styled(SearchPopover)`
+ width: 100%;
+ transition: width 100ms ease-out;
+ margin: 8px 0;
+`;
+
+const ToggleWrapper = styled.div`
+ position: absolute;
+ right: 0;
+ opacity: 0;
+ transform: translateX(10px);
+ transition: opacity 100ms ease-out, transform 100ms ease-out;
+`;
+
+const StyledSidebar = styled(Sidebar)<{ $hoverTransition: boolean }>`
+ ${({ $hoverTransition }) =>
+ $hoverTransition &&
+ `
+ &: ${hover} {
+ ${StyledSearchPopover} {
+ width: 85%;
+ }
+
+ ${ToggleWrapper} {
+ opacity: 1;
+ transform: translateX(0);
+ }
+ }
+ `}
`;
export default observer(SharedSidebar);
diff --git a/app/components/Sidebar/Sidebar.tsx b/app/components/Sidebar/Sidebar.tsx
index bff82e4072..5245be4043 100644
--- a/app/components/Sidebar/Sidebar.tsx
+++ b/app/components/Sidebar/Sidebar.tsx
@@ -94,9 +94,17 @@ const Sidebar = React.forwardRef(function _Sidebar(
}
}, [ui, isSmallerThanMinimum, minWidth, width, setWidth]);
+ const handleBlur = React.useCallback(() => {
+ setHovering(false);
+ }, []);
+
const handleMouseDown = React.useCallback(
(event) => {
event.preventDefault();
+ if (!document.hasFocus()) {
+ return;
+ }
+
setOffset(event.pageX - width);
setResizing(true);
setAnimating(false);
@@ -104,9 +112,9 @@ const Sidebar = React.forwardRef(function _Sidebar(
[width]
);
- const handlePointerMove = React.useCallback(() => {
+ const handlePointerActivity = React.useCallback(() => {
if (ui.sidebarIsClosed) {
- setHovering(true);
+ setHovering(document.hasFocus());
setPointerMoved(true);
}
}, [ui.sidebarIsClosed]);
@@ -115,7 +123,10 @@ const Sidebar = React.forwardRef(function _Sidebar(
(ev) => {
if (hasPointerMoved) {
setHovering(
- ev.pageX < width && ev.pageY < window.innerHeight && ev.pageY > 0
+ document.hasFocus() &&
+ ev.pageX < width &&
+ ev.pageY < window.innerHeight &&
+ ev.pageY > 0
);
}
},
@@ -153,11 +164,14 @@ const Sidebar = React.forwardRef(function _Sidebar(
document.body.style.cursor = "initial";
}
+ window.addEventListener("blur", handleBlur);
+
return () => {
+ window.removeEventListener("blur", handleBlur);
document.removeEventListener("mousemove", handleDrag);
document.removeEventListener("mouseup", handleStopDrag);
};
- }, [isResizing, handleDrag, handleStopDrag]);
+ }, [isResizing, handleDrag, handleBlur, handleStopDrag]);
const handleReset = React.useCallback(() => {
ui.setSidebarWidth(theme.sidebarWidth);
@@ -193,7 +207,8 @@ const Sidebar = React.forwardRef(function _Sidebar(
$collapsed={collapsed}
$isMobile={isMobile}
className={className}
- onPointerMove={handlePointerMove}
+ onPointerDown={handlePointerActivity}
+ onPointerMove={handlePointerActivity}
onPointerLeave={handlePointerLeave}
column
>
@@ -217,15 +232,7 @@ const Sidebar = React.forwardRef(function _Sidebar(
/>
}
>
-
- {(rest: SidebarButtonProps) => (
- }
- />
- )}
-
+
)}
@@ -240,6 +247,14 @@ const Sidebar = React.forwardRef(function _Sidebar(
);
});
+const Notifications = () => (
+
+ {(rest: SidebarButtonProps) => (
+ } />
+ )}
+
+);
+
const Backdrop = styled.a`
animation: ${fadeIn} 250ms ease-in-out;
position: fixed;
diff --git a/app/components/Sidebar/components/CollectionLink.tsx b/app/components/Sidebar/components/CollectionLink.tsx
index abbe9b9d60..52b6d89079 100644
--- a/app/components/Sidebar/components/CollectionLink.tsx
+++ b/app/components/Sidebar/components/CollectionLink.tsx
@@ -112,6 +112,10 @@ const CollectionLink: React.FC = ({
sidebarContext,
});
+ const handleRename = React.useCallback(() => {
+ editableTitleRef.current?.setIsEditing(true);
+ }, [editableTitleRef]);
+
return (
@@ -157,7 +161,7 @@ const CollectionLink: React.FC = ({
editableTitleRef.current?.setIsEditing(true)}
+ onRename={handleRename}
onOpen={handleMenuOpen}
onClose={handleMenuClose}
/>
diff --git a/app/components/Sidebar/components/CollectionLinkChildren.tsx b/app/components/Sidebar/components/CollectionLinkChildren.tsx
index e74a6bec00..b5874a3ca3 100644
--- a/app/components/Sidebar/components/CollectionLinkChildren.tsx
+++ b/app/components/Sidebar/components/CollectionLinkChildren.tsx
@@ -2,6 +2,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import { useDrop } from "react-dnd";
import { useTranslation } from "react-i18next";
+import { Waypoint } from "react-waypoint";
import { toast } from "sonner";
import styled from "styled-components";
import Collection from "~/models/Collection";
@@ -34,11 +35,13 @@ function CollectionLinkChildren({
expanded,
prefetchDocument,
}: Props) {
+ const pageSize = 250;
const can = usePolicy(collection);
const manualSort = collection.sort.field === "index";
const { documents, dialogs, collections } = useStores();
const { t } = useTranslation();
const childDocuments = useCollectionDocuments(collection, documents.active);
+ const [showing, setShowing] = React.useState(pageSize);
// Drop to reorder document
const [{ isOverReorder, isDraggingAnyDocument }, dropToReorder] = useDrop({
@@ -83,6 +86,18 @@ function CollectionLinkChildren({
}),
});
+ React.useEffect(() => {
+ if (!expanded) {
+ setShowing(pageSize);
+ }
+ }, [expanded]);
+
+ const showMore = React.useCallback(() => {
+ if (childDocuments && childDocuments.length > showing) {
+ setShowing((value) => value + pageSize);
+ }
+ }, [childDocuments, showing]);
+
return (
{isDraggingAnyDocument && can.createDocument && manualSort && (
@@ -98,7 +113,7 @@ function CollectionLinkChildren({
)}
- {childDocuments?.map((node, index) => (
+ {childDocuments?.slice(0, showing).map((node, index) => (
)}
+
);
diff --git a/app/components/Sidebar/components/SidebarButton.tsx b/app/components/Sidebar/components/SidebarButton.tsx
index f4284657d9..f7424053f9 100644
--- a/app/components/Sidebar/components/SidebarButton.tsx
+++ b/app/components/Sidebar/components/SidebarButton.tsx
@@ -59,6 +59,7 @@ const StyledMoreIcon = styled(MoreIcon)`
`;
const Container = styled(Flex)<{ $position: "top" | "bottom" }>`
+ overflow: hidden;
padding-top: ${(props) =>
props.$position === "top" && Desktop.hasInsetTitlebar() ? 36 : 0}px;
${draggableOnDesktop()}
diff --git a/app/components/Sidebar/components/Version.tsx b/app/components/Sidebar/components/Version.tsx
index 0c2174ba3e..f2e8810b2a 100644
--- a/app/components/Sidebar/components/Version.tsx
+++ b/app/components/Sidebar/components/Version.tsx
@@ -2,41 +2,29 @@ import * as React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import Badge from "~/components/Badge";
-import { version } from "../../../../package.json";
+import { client } from "~/utils/ApiClient";
+import Logger from "~/utils/Logger";
+import { version as currentVersion } from "../../../../package.json";
import SidebarLink from "./SidebarLink";
export default function Version() {
- const [releasesBehind, setReleasesBehind] = React.useState(-1);
+ const [versionsBehind, setVersionsBehind] = React.useState(-1);
const { t } = useTranslation();
React.useEffect(() => {
- async function loadReleases() {
- const res = await fetch(
- "https://api.github.com/repos/outline/outline/releases"
- );
- const releases = await res.json();
-
- if (Array.isArray(releases)) {
- const everyNewRelease = releases
- .map((release) => release.tag_name)
- .findIndex((tagName) => tagName === `v${version}`);
-
- const onlyFullNewRelease = releases
- .filter((release) => !release.prerelease)
- .map((release) => release.tag_name)
- .findIndex((tagName) => tagName === `v${version}`);
-
- const computedReleasesBehind = version.includes("pre")
- ? everyNewRelease
- : onlyFullNewRelease;
-
- if (computedReleasesBehind >= 0) {
- setReleasesBehind(computedReleasesBehind);
+ async function loadVersionInfo() {
+ try {
+ // Fetch version info from the server-side proxy
+ const res = await client.post("/installation.info");
+ if (res.data && res.data.versionsBehind >= 0) {
+ setVersionsBehind(res.data.versionsBehind);
}
+ } catch (error) {
+ Logger.error("Failed to load version info", error);
}
}
- void loadReleases();
+ void loadVersionInfo();
}, []);
return (
@@ -45,16 +33,16 @@ export default function Version() {
href="https://github.com/outline/outline/releases"
label={
<>
- v{version}
- {releasesBehind >= 0 && (
+ v{currentVersion}
+ {versionsBehind >= 0 && (
<>
- {releasesBehind === 0
+ {versionsBehind === 0
? t("Up to date")
: t(`{{ releasesBehind }} versions behind`, {
- releasesBehind,
- count: releasesBehind,
+ releasesBehind: versionsBehind,
+ count: versionsBehind,
})}
>
diff --git a/app/components/Table.tsx b/app/components/Table.tsx
index e264a73e86..639a5bf849 100644
--- a/app/components/Table.tsx
+++ b/app/components/Table.tsx
@@ -120,30 +120,33 @@ function Table({
- {headerGroups.map((headerGroup) => (
-
- {headerGroup.headers.map((column) => (
-
- {
+ const groupProps = headerGroup.getHeaderGroupProps();
+ return (
+
+ {headerGroup.headers.map((column) => (
+
- {column.render("Header")}
- {column.isSorted &&
- (column.isSortedDesc ? (
-
- ) : (
-
- ))}
-
-
- ))}
-
- ))}
+
+ {column.render("Header")}
+ {column.isSorted &&
+ (column.isSortedDesc ? (
+
+ ) : (
+
+ ))}
+
+
+ ))}
+
+ );
+ })}
{rows.map((row) => {
@@ -253,7 +256,7 @@ const SortWrapper = styled(Flex)<{ $sortable: boolean }>`
&:hover {
background: ${(props) =>
- props.$sortable ? props.theme.secondaryBackground : "none"};
+ props.$sortable ? props.theme.backgroundSecondary : "none"};
}
`;
diff --git a/app/components/WebsocketProvider.tsx b/app/components/WebsocketProvider.tsx
index 9b19024245..f4d83ef323 100644
--- a/app/components/WebsocketProvider.tsx
+++ b/app/components/WebsocketProvider.tsx
@@ -27,6 +27,7 @@ import withStores from "~/components/withStores";
import {
PartialExcept,
WebsocketCollectionUpdateIndexEvent,
+ WebsocketCommentReactionEvent,
WebsocketEntitiesEvent,
WebsocketEntityDeletedEvent,
} from "~/types";
@@ -351,6 +352,30 @@ class WebsocketProvider extends React.Component {
comments.remove(event.modelId);
});
+ this.socket.on(
+ "comments.add_reaction",
+ (event: WebsocketCommentReactionEvent) => {
+ const comment = comments.get(event.commentId);
+ comment?.updateReaction({
+ type: "add",
+ emoji: event.emoji,
+ user: event.user,
+ });
+ }
+ );
+
+ this.socket.on(
+ "comments.remove_reaction",
+ (event: WebsocketCommentReactionEvent) => {
+ const comment = comments.get(event.commentId);
+ comment?.updateReaction({
+ type: "remove",
+ emoji: event.emoji,
+ user: event.user,
+ });
+ }
+ );
+
this.socket.on("groups.create", (event: PartialExcept) => {
groups.add(event);
});
diff --git a/app/editor/components/FloatingToolbar.tsx b/app/editor/components/FloatingToolbar.tsx
index c153bdb0db..b45173d406 100644
--- a/app/editor/components/FloatingToolbar.tsx
+++ b/app/editor/components/FloatingToolbar.tsx
@@ -7,6 +7,7 @@ import { isCode } from "@shared/editor/lib/isCode";
import { findParentNode } from "@shared/editor/queries/findParentNode";
import { EditorStyleHelper } from "@shared/editor/styles/EditorStyleHelper";
import { depths, s } from "@shared/styles";
+import { HEADER_HEIGHT } from "~/components/Header";
import { Portal } from "~/components/Portal";
import useComponentSize from "~/hooks/useComponentSize";
import useEventListener from "~/hooks/useEventListener";
@@ -130,59 +131,64 @@ function usePosition({
// Images need their own positioning to get the toolbar in the center
if (isImageSelection) {
- const element = view.nodeDOM(selection.from);
+ const element = view.nodeDOM(selection.from) as HTMLElement;
// Images are wrapped which impacts positioning - need to get the element
// specifically tagged as the handle
- const imageElement = (element as HTMLElement).getElementsByClassName(
+ const imageElement = element.getElementsByClassName(
EditorStyleHelper.imageHandle
)[0];
- const { left, top, width } = imageElement.getBoundingClientRect();
+ if (imageElement) {
+ const { left, top, width } = imageElement.getBoundingClientRect();
- return {
- left: Math.round(left + width / 2 - menuWidth / 2 - offsetParent.left),
- top: Math.round(top - menuHeight - offsetParent.top),
- offset: 0,
- visible: true,
- };
- } else {
- // calculate the horizontal center of the selection
- const halfSelection =
- Math.abs(selectionBounds.right - selectionBounds.left) / 2;
- const centerOfSelection = selectionBounds.left + halfSelection;
+ return {
+ left: Math.round(left + width / 2 - menuWidth / 2 - offsetParent.left),
+ top: Math.round(top - menuHeight - offsetParent.top),
+ offset: 0,
+ visible: true,
+ };
+ }
+ }
- // position the menu so that it is centered over the selection except in
- // the cases where it would extend off the edge of the screen. In these
- // instances leave a margin
- const margin = 12;
- const left = Math.min(
- Math.min(
- offsetParent.x + offsetParent.width - menuWidth - margin,
- window.innerWidth - margin
- ),
- Math.max(
- Math.max(offsetParent.x, margin),
- centerOfSelection - menuWidth / 2
- )
- );
- const top = Math.min(
+ // calculate the horizontal center of the selection
+ const halfSelection =
+ Math.abs(selectionBounds.right - selectionBounds.left) / 2;
+ const centerOfSelection = selectionBounds.left + halfSelection;
+
+ // position the menu so that it is centered over the selection except in
+ // the cases where it would extend off the edge of the screen. In these
+ // instances leave a margin
+ const margin = 12;
+ const left = Math.min(
+ Math.min(
+ offsetParent.x + offsetParent.width - menuWidth - margin,
+ window.innerWidth - margin
+ ),
+ Math.max(
+ Math.max(offsetParent.x, margin),
+ centerOfSelection - menuWidth / 2
+ )
+ );
+ const top = Math.max(
+ HEADER_HEIGHT,
+ Math.min(
window.innerHeight - menuHeight - margin,
Math.max(margin, selectionBounds.top - menuHeight)
- );
+ )
+ );
- // if the menu has been offset to not extend offscreen then we should adjust
- // the position of the triangle underneath to correctly point to the center
- // of the selection still
- const offset = left - (centerOfSelection - menuWidth / 2);
- return {
- left: Math.round(left - offsetParent.left),
- top: Math.round(top - offsetParent.top),
- offset: Math.round(offset),
- maxWidth: Math.min(window.innerWidth - margin * 2, offsetParent.width),
- blockSelection: codeBlock || isColSelection || isRowSelection,
- visible: true,
- };
- }
+ // if the menu has been offset to not extend offscreen then we should adjust
+ // the position of the triangle underneath to correctly point to the center
+ // of the selection still
+ const offset = left - (centerOfSelection - menuWidth / 2);
+ return {
+ left: Math.round(left - offsetParent.left),
+ top: Math.round(top - offsetParent.top),
+ offset: Math.round(offset),
+ maxWidth: Math.min(window.innerWidth - margin * 2, offsetParent.width),
+ blockSelection: codeBlock || isColSelection || isRowSelection,
+ visible: true,
+ };
}
const FloatingToolbar = React.forwardRef(function FloatingToolbar_(
diff --git a/app/editor/components/SelectionToolbar.tsx b/app/editor/components/SelectionToolbar.tsx
index 763da2d699..ef596eaf03 100644
--- a/app/editor/components/SelectionToolbar.tsx
+++ b/app/editor/components/SelectionToolbar.tsx
@@ -216,8 +216,7 @@ export default function SelectionToolbar(props: Props) {
const colIndex = getColumnIndex(state);
const rowIndex = getRowIndex(state);
const isTableSelection = colIndex !== undefined && rowIndex !== undefined;
- const link = isMarkActive(state.schema.marks.link)(state);
- const range = getMarkRange(selection.$from, state.schema.marks.link);
+ const link = getMarkRange(selection.$from, state.schema.marks.link);
const isImageSelection =
selection instanceof NodeSelection && selection.node.type.name === "image";
const isAttachmentSelection =
@@ -266,7 +265,8 @@ export default function SelectionToolbar(props: Props) {
return null;
}
- const showLinkToolbar = link && range;
+ const showLinkToolbar =
+ link && link.from === selection.from && link.to === selection.to;
return (
{showLinkToolbar ? (
{
- // Do nothing if the document isn't currently editable
- if (!view.editable) {
- return false;
- }
-
- // Default behavior if there is nothing on the clipboard or were
- // special pasting with no formatting (Shift held)
- if (!event.clipboardData || this.shiftKey) {
+ // Do nothing if the document isn't currently editable or there is no clipboard data
+ if (!view.editable || !event.clipboardData) {
return false;
}
@@ -137,76 +131,6 @@ export default class PasteHandler extends Extension {
return true;
}
- // Check if the clipboard contents can be parsed as a single url
- if (isUrl(text)) {
- // If there is selected text then we want to wrap it in a link to the url
- if (!state.selection.empty) {
- toggleMark(this.editor.schema.marks.link, { href: text })(
- state,
- dispatch
- );
- return true;
- }
-
- // Is this link embeddable? Create an embed!
- const { embeds } = this.editor.props;
- if (
- embeds &&
- this.editor.commands.embed &&
- !isInCode(state) &&
- !isInList(state)
- ) {
- for (const embed of embeds) {
- if (!embed.matchOnInput) {
- continue;
- }
- const matches = embed.matcher(text);
- if (matches) {
- this.editor.commands.embed({
- href: text,
- });
- return true;
- }
- }
- }
-
- // Is the link a link to a document? If so, we can grab the title and insert it.
- if (isDocumentUrl(text)) {
- const slug = parseDocumentSlug(text);
-
- if (slug) {
- void stores.documents
- .fetch(slug)
- .then((document) => {
- if (view.isDestroyed) {
- return;
- }
- if (document) {
- const { hash } = new URL(text);
-
- const hasEmoji =
- determineIconType(document.icon) === IconType.Emoji;
-
- const title = `${hasEmoji ? document.icon + " " : ""}${
- document.titleWithDefault
- }`;
- insertLink(`${document.path}${hash}`, title);
- }
- })
- .catch(() => {
- if (view.isDestroyed) {
- return;
- }
- insertLink(text);
- });
- }
- } else {
- insertLink(text);
- }
-
- return true;
- }
-
// Because VSCode is an especially popular editor that places metadata
// on the clipboard, we can parse it to find out what kind of content
// was pasted.
@@ -215,52 +139,129 @@ export default class PasteHandler extends Extension {
const supportsCodeBlock = !!state.schema.nodes.code_block;
const supportsCodeMark = !!state.schema.marks.code_inline;
- if (pasteCodeLanguage && pasteCodeLanguage !== "markdown") {
- if (text.includes("\n") && supportsCodeBlock) {
- event.preventDefault();
- view.dispatch(
- state.tr
- .replaceSelectionWith(
- state.schema.nodes.code_block.create({
- language: Object.keys(LANGUAGES).includes(
- vscodeMeta.mode
- )
- ? vscodeMeta.mode
- : null,
+ if (!this.shiftKey) {
+ // Check if the clipboard contents can be parsed as a single url
+ if (isUrl(text)) {
+ // If there is selected text then we want to wrap it in a link to the url
+ if (!state.selection.empty) {
+ toggleMark(this.editor.schema.marks.link, { href: text })(
+ state,
+ dispatch
+ );
+ return true;
+ }
+
+ // Is this link embeddable? Create an embed!
+ const { embeds } = this.editor.props;
+ if (
+ embeds &&
+ this.editor.commands.embed &&
+ !isInCode(state) &&
+ !isInList(state)
+ ) {
+ for (const embed of embeds) {
+ if (!embed.matchOnInput) {
+ continue;
+ }
+ const matches = embed.matcher(text);
+ if (matches) {
+ this.editor.commands.embed({
+ href: text,
+ });
+ return true;
+ }
+ }
+ }
+
+ // Is the link a link to a document? If so, we can grab the title and insert it.
+ if (isDocumentUrl(text)) {
+ const slug = parseDocumentSlug(text);
+
+ if (slug) {
+ void stores.documents
+ .fetch(slug)
+ .then((document) => {
+ if (view.isDestroyed) {
+ return;
+ }
+ if (document) {
+ const { hash } = new URL(text);
+
+ const hasEmoji =
+ determineIconType(document.icon) === IconType.Emoji;
+
+ const title = `${
+ hasEmoji ? document.icon + " " : ""
+ }${document.titleWithDefault}`;
+ insertLink(`${document.path}${hash}`, title);
+ }
})
- )
- .insertText(text)
- );
+ .catch(() => {
+ if (view.isDestroyed) {
+ return;
+ }
+ insertLink(text);
+ });
+ }
+ } else {
+ insertLink(text);
+ }
+
return true;
}
- if (supportsCodeMark) {
- event.preventDefault();
- view.dispatch(
- state.tr
- .insertText(text, state.selection.from, state.selection.to)
- .addMark(
- state.selection.from,
- state.selection.to + text.length,
- state.schema.marks.code_inline.create()
- )
- );
- return true;
- }
- }
+ if (pasteCodeLanguage && pasteCodeLanguage !== "markdown") {
+ if (text.includes("\n") && supportsCodeBlock) {
+ event.preventDefault();
+ view.dispatch(
+ state.tr
+ .replaceSelectionWith(
+ state.schema.nodes.code_block.create({
+ language: Object.keys(LANGUAGES).includes(
+ vscodeMeta.mode
+ )
+ ? vscodeMeta.mode
+ : null,
+ })
+ )
+ .insertText(text)
+ );
+ return true;
+ }
- // If the HTML on the clipboard is from Prosemirror then the best
- // compatability is to just use the HTML parser, regardless of
- // whether it "looks" like Markdown, see: outline/outline#2416
- if (html?.includes("data-pm-slice")) {
- return false;
+ if (supportsCodeMark) {
+ event.preventDefault();
+ view.dispatch(
+ state.tr
+ .insertText(
+ text,
+ state.selection.from,
+ state.selection.to
+ )
+ .addMark(
+ state.selection.from,
+ state.selection.to + text.length,
+ state.schema.marks.code_inline.create()
+ )
+ );
+ return true;
+ }
+ }
+
+ // If the HTML on the clipboard is from Prosemirror then the best
+ // compatability is to just use the HTML parser, regardless of
+ // whether it "looks" like Markdown, see: outline/outline#2416
+ if (html?.includes("data-pm-slice")) {
+ return false;
+ }
}
// If the text on the clipboard looks like Markdown OR there is no
// html on the clipboard then try to parse content as Markdown
if (
(isMarkdown(text) && !isDropboxPaper(html)) ||
- pasteCodeLanguage === "markdown"
+ pasteCodeLanguage === "markdown" ||
+ this.shiftKey
) {
event.preventDefault();
diff --git a/app/editor/extensions/SmartText.ts b/app/editor/extensions/SmartText.ts
index 74a4867819..cdc6828347 100644
--- a/app/editor/extensions/SmartText.ts
+++ b/app/editor/extensions/SmartText.ts
@@ -30,19 +30,23 @@ export default class SmartText extends Extension {
}
inputRules() {
- return [
- rightArrow,
- emdash,
- oneHalf,
- threeQuarters,
- copyright,
- registered,
- trademarked,
- ellipsis,
- openDoubleQuote,
- closeDoubleQuote,
- openSingleQuote,
- closeSingleQuote,
- ];
+ if (this.options.userPreferences?.enableSmartText ?? true) {
+ return [
+ rightArrow,
+ emdash,
+ oneHalf,
+ threeQuarters,
+ copyright,
+ registered,
+ trademarked,
+ ellipsis,
+ openDoubleQuote,
+ closeDoubleQuote,
+ openSingleQuote,
+ closeSingleQuote,
+ ];
+ }
+
+ return [];
}
}
diff --git a/app/editor/index.tsx b/app/editor/index.tsx
index 3cbc9403de..771af742a2 100644
--- a/app/editor/index.tsx
+++ b/app/editor/index.tsx
@@ -91,6 +91,10 @@ export type Props = {
scrollTo?: string;
/** Callback for handling uploaded images, should return the url of uploaded file */
uploadFile?: (file: File) => Promise;
+ /** Callback when prosemirror nodes are initialized on document mount. */
+ onInit?: () => void;
+ /** Callback when prosemirror nodes are destroyed on document unmount. */
+ onDestroy?: () => void;
/** Callback when editor is blurred, as native input */
onBlur?: () => void;
/** Callback when editor is focused, as native input */
@@ -176,6 +180,7 @@ export class Editor extends React.PureComponent<
linkToolbarOpen: false,
};
+ isInitialized = false;
isBlurred = true;
extensions: ExtensionManager;
elementRef = React.createRef();
@@ -283,6 +288,7 @@ export class Editor extends React.PureComponent<
window.removeEventListener("theme-changed", this.dispatchThemeChanged);
this.view?.destroy();
this.mutationObserver?.disconnect();
+ this.handleEditorDestroy();
}
private init() {
@@ -482,6 +488,8 @@ export class Editor extends React.PureComponent<
self.handleChange();
}
+ self.handleEditorInit();
+
self.calculateDir();
// Because Prosemirror and React are not linked we must tell React that
@@ -682,7 +690,10 @@ export class Editor extends React.PureComponent<
* @param commentId The id of the comment to remove
* @param attrs The attributes to update
*/
- public updateComment = (commentId: string, attrs: { resolved: boolean }) => {
+ public updateComment = (
+ commentId: string,
+ attrs: { resolved?: boolean; draft?: boolean }
+ ) => {
const { state, dispatch } = this.view;
const tr = state.tr;
@@ -740,6 +751,22 @@ export class Editor extends React.PureComponent<
);
};
+ private handleEditorInit = () => {
+ if (!this.props.onInit || this.isInitialized) {
+ return;
+ }
+
+ this.props.onInit();
+ this.isInitialized = true;
+ };
+
+ private handleEditorDestroy = () => {
+ if (!this.props.onDestroy) {
+ return;
+ }
+ this.props.onDestroy();
+ };
+
private handleEditorBlur = () => {
this.setState({ isEditorFocused: false });
return false;
diff --git a/app/editor/menus/formatting.tsx b/app/editor/menus/formatting.tsx
index e0346c3757..284e075a50 100644
--- a/app/editor/menus/formatting.tsx
+++ b/app/editor/menus/formatting.tsx
@@ -214,7 +214,6 @@ export default function formattingMenuItems(
name: "link",
tooltip: dictionary.createLink,
icon: ,
- active: isMarkActive(schema.marks.link),
attrs: { href: "" },
visible: !isCodeBlock && (!isMobile || !isEmpty),
},
diff --git a/app/editor/menus/readOnly.tsx b/app/editor/menus/readOnly.tsx
index bc096c80c0..0ee5c76647 100644
--- a/app/editor/menus/readOnly.tsx
+++ b/app/editor/menus/readOnly.tsx
@@ -11,10 +11,11 @@ export default function readOnlyMenuItems(
dictionary: Dictionary
): MenuItem[] {
const { schema } = state;
+ const isEmpty = state.selection.empty;
return [
{
- visible: canUpdate,
+ visible: canUpdate && !isEmpty,
name: "comment",
tooltip: dictionary.comment,
label: dictionary.comment,
diff --git a/app/hooks/useHover.ts b/app/hooks/useHover.ts
new file mode 100644
index 0000000000..434c7120c6
--- /dev/null
+++ b/app/hooks/useHover.ts
@@ -0,0 +1,50 @@
+import React from "react";
+import useUnmount from "./useUnmount";
+
+type Props = {
+ /** Ref to the element that needs to be observed. */
+ ref: React.RefObject;
+ /** Duration to wait until it's considered as a hover event. */
+ duration: number;
+};
+
+/**
+ * Hook that will trigger the first time an element is hovered.
+ *
+ * @returns {boolean} hovered - Signals when an element is hovered by the user.
+ */
+const useHover = ({ ref, duration }: Props): boolean => {
+ const [hovered, setHovered] = React.useState(false);
+ const timer = React.useRef();
+
+ const onMouseEnter = React.useCallback(() => {
+ if (timer.current) {
+ clearTimeout(timer.current);
+ }
+
+ timer.current = window.setTimeout(() => setHovered(true), duration);
+ }, [duration]);
+
+ const onMouseLeave = React.useCallback(() => {
+ if (timer.current) {
+ clearTimeout(timer.current);
+ }
+ }, []);
+
+ useUnmount(() => {
+ if (timer.current) {
+ clearTimeout(timer.current);
+ }
+ });
+
+ React.useEffect(() => {
+ if (ref.current) {
+ ref.current.onmouseenter = onMouseEnter;
+ ref.current.onmouseleave = onMouseLeave;
+ }
+ }, [ref, onMouseEnter, onMouseLeave]);
+
+ return hovered;
+};
+
+export default useHover;
diff --git a/app/hooks/useOnClickOutside.ts b/app/hooks/useOnClickOutside.ts
index 6a23447bfe..2a58024da1 100644
--- a/app/hooks/useOnClickOutside.ts
+++ b/app/hooks/useOnClickOutside.ts
@@ -23,6 +23,6 @@ export default function useOnClickOutside(
[ref, callback]
);
- useEventListener("mousedown", listener, window, options);
+ useEventListener("pointerdown", listener, window, options);
useEventListener("touchstart", listener, window, options);
}
diff --git a/app/menus/CollectionMenu.tsx b/app/menus/CollectionMenu.tsx
index 7dc0d9c752..171e4ffc9b 100644
--- a/app/menus/CollectionMenu.tsx
+++ b/app/menus/CollectionMenu.tsx
@@ -124,6 +124,8 @@ function CollectionMenu({
} catch (err) {
toast.error(err.message);
throw err;
+ } finally {
+ ev.target.value = "";
}
},
[history, collection.id, documents]
diff --git a/app/menus/CommentMenu.tsx b/app/menus/CommentMenu.tsx
index 2935601d37..d2205445cf 100644
--- a/app/menus/CommentMenu.tsx
+++ b/app/menus/CommentMenu.tsx
@@ -15,6 +15,7 @@ import {
deleteCommentFactory,
resolveCommentFactory,
unresolveCommentFactory,
+ viewCommentReactionsFactory,
} from "~/actions/definitions/comments";
import useActionContext from "~/hooks/useActionContext";
import usePolicy from "~/hooks/usePolicy";
@@ -66,47 +67,55 @@ function CommentMenu({
{...menu}
/>
-
- ,
- onClick: onEdit,
- visible: can.update && !comment.isResolved,
- },
- actionToMenuItem(
- resolveCommentFactory({
- comment,
- onResolve: () => onUpdate({ resolved: true }),
- }),
- context
- ),
- actionToMenuItem(
- unresolveCommentFactory({
- comment,
- onUnresolve: () => onUpdate({ resolved: false }),
- }),
- context
- ),
- {
- type: "button",
- icon: ,
- title: t("Copy link"),
- onClick: handleCopyLink,
- },
- {
- type: "separator",
- },
- actionToMenuItem(
- deleteCommentFactory({ comment, onDelete }),
- context
- ),
- ]}
- />
-
+ {menu.visible && (
+
+ ,
+ onClick: onEdit,
+ visible: can.update && !comment.isResolved,
+ },
+ actionToMenuItem(
+ resolveCommentFactory({
+ comment,
+ onResolve: () => onUpdate({ resolved: true }),
+ }),
+ context
+ ),
+ actionToMenuItem(
+ unresolveCommentFactory({
+ comment,
+ onUnresolve: () => onUpdate({ resolved: false }),
+ }),
+ context
+ ),
+ actionToMenuItem(
+ viewCommentReactionsFactory({
+ comment,
+ }),
+ context
+ ),
+ {
+ type: "button",
+ icon: ,
+ title: t("Copy link"),
+ onClick: handleCopyLink,
+ },
+ {
+ type: "separator",
+ },
+ actionToMenuItem(
+ deleteCommentFactory({ comment, onDelete }),
+ context
+ ),
+ ]}
+ />
+
+ )}
>
);
}
diff --git a/app/menus/DocumentMenu.tsx b/app/menus/DocumentMenu.tsx
index 97b86ed1e8..4fa6fb70da 100644
--- a/app/menus/DocumentMenu.tsx
+++ b/app/menus/DocumentMenu.tsx
@@ -47,6 +47,7 @@ import {
shareDocument,
copyDocument,
searchInDocument,
+ leaveDocument,
moveTemplate,
} from "~/actions/definitions/documents";
import useActionContext from "~/hooks/useActionContext";
@@ -298,6 +299,7 @@ const MenuContent: React.FC = ({
},
actionToMenuItem(deleteDocument, context),
actionToMenuItem(permanentlyDeleteDocument, context),
+ actionToMenuItem(leaveDocument, context),
]}
/>
{(showDisplayOptions || showToggleEmbeds) && can.update && (
@@ -407,6 +409,8 @@ function DocumentMenu({
} catch (err) {
toast.error(err.message);
throw err;
+ } finally {
+ ev.target.value = "";
}
},
[history, collection, documents, document.id]
diff --git a/app/menus/OrganizationMenu.tsx b/app/menus/OrganizationMenu.tsx
index b487003ccf..1113476a71 100644
--- a/app/menus/OrganizationMenu.tsx
+++ b/app/menus/OrganizationMenu.tsx
@@ -4,7 +4,10 @@ import { useTranslation } from "react-i18next";
import { MenuButton, useMenuState } from "reakit/Menu";
import ContextMenu from "~/components/ContextMenu";
import Template from "~/components/ContextMenu/Template";
-import { navigateToSettings, logout } from "~/actions/definitions/navigation";
+import {
+ navigateToWorkspaceSettings,
+ logout,
+} from "~/actions/definitions/navigation";
import {
createTeam,
createTeamsList,
@@ -45,7 +48,7 @@ const OrganizationMenu: React.FC = ({ children }: Props) => {
createTeam,
desktopLoginTeam,
separator(),
- navigateToSettings,
+ navigateToWorkspaceSettings,
logout,
],
[context]
diff --git a/app/models/Comment.ts b/app/models/Comment.ts
index 4a67ab60c0..fa6e9d529f 100644
--- a/app/models/Comment.ts
+++ b/app/models/Comment.ts
@@ -1,8 +1,12 @@
import { subSeconds } from "date-fns";
-import { computed, observable } from "mobx";
+import invariant from "invariant";
+import uniq from "lodash/uniq";
+import { action, computed, observable } from "mobx";
import { now } from "mobx-utils";
-import type { ProsemirrorData } from "@shared/types";
+import { Pagination } from "@shared/constants";
+import type { ProsemirrorData, ReactionSummary } from "@shared/types";
import User from "~/models/User";
+import { client } from "~/utils/ApiClient";
import Document from "./Document";
import Model from "./base/Model";
import Field from "./decorators/Field";
@@ -26,7 +30,7 @@ class Comment extends Model {
* The Prosemirror data representing the comment content
*/
@Field
- @observable
+ @observable.shallow
data: ProsemirrorData;
/**
@@ -84,6 +88,25 @@ class Comment extends Model {
*/
resolvedById: string | null;
+ /**
+ * Active reactions for this comment.
+ *
+ * Note: This contains just the emoji with the associated user-ids.
+ */
+ @observable
+ reactions: ReactionSummary[];
+
+ /**
+ * Denotes whether the user data for the active reactions are loaded.
+ */
+ @observable
+ reactedUsersLoaded: boolean = false;
+
+ /**
+ * Denotes whether there is an in-flight request for loading reacted users.
+ */
+ private reactedUsersLoading = false;
+
/**
* An array of users that are currently typing a reply in this comments thread.
*/
@@ -124,6 +147,156 @@ class Comment extends Model {
public unresolve() {
return this.store.rootStore.comments.unresolve(this.id);
}
+
+ /**
+ * Add an emoji as a reaction to this comment.
+ *
+ * Optimistically updates the `reactions` cache and invokes the backend API.
+ *
+ * @param {Object} reaction - The reaction data.
+ * @param {string} reaction.emoji - The emoji to add as a reaction.
+ * @param {string} reaction.user - The user who added this reaction.
+ */
+ @action
+ public addReaction = async ({
+ emoji,
+ user,
+ }: {
+ emoji: string;
+ user: User;
+ }) => {
+ this.updateReaction({ type: "add", emoji, user });
+ try {
+ await client.post("/comments.add_reaction", {
+ id: this.id,
+ emoji,
+ });
+ } catch {
+ this.updateReaction({ type: "remove", emoji, user });
+ }
+ };
+
+ /**
+ * Remove an emoji as a reaction from this comment.
+ *
+ * Optimistically updates the `reactions` cache and invokes the backend API.
+ *
+ * @param {Object} reaction - The reaction data.
+ * @param {string} reaction.emoji - The emoji to remove as a reaction.
+ * @param {string} reaction.user - The user who removed this reaction.
+ */
+ @action
+ public removeReaction = async ({
+ emoji,
+ user,
+ }: {
+ emoji: string;
+ user: User;
+ }) => {
+ this.updateReaction({ type: "remove", emoji, user });
+ try {
+ await client.post("/comments.remove_reaction", {
+ id: this.id,
+ emoji,
+ });
+ } catch {
+ this.updateReaction({ type: "add", emoji, user });
+ }
+ };
+
+ /**
+ * Update the `reactions` cache.
+ *
+ * @param {Object} reaction - The reaction data.
+ * @param {string} reaction.type - The type of the action.
+ * @param {string} reaction.emoji - The emoji to update as a reaction.
+ * @param {string} reaction.user - The user who performed this action.
+ */
+ @action
+ public updateReaction = ({
+ type,
+ emoji,
+ user,
+ }: {
+ type: "add" | "remove";
+ emoji: string;
+ user: User;
+ }) => {
+ const reaction = this.reactions.find((r) => r.emoji === emoji);
+
+ // Step 1: Update the reactions cache.
+
+ if (type === "add") {
+ if (!reaction) {
+ this.reactions.push({ emoji, userIds: [user.id] });
+ } else {
+ reaction.userIds = uniq([...reaction.userIds, user.id]);
+ }
+ } else {
+ if (reaction) {
+ reaction.userIds = reaction.userIds.filter((id) => id !== user.id);
+ }
+
+ if (reaction?.userIds.length === 0) {
+ this.reactions = this.reactions.filter(
+ (r) => r.emoji !== reaction.emoji
+ );
+ }
+ }
+
+ // Step 2: Add the user to the store.
+ this.store.rootStore.users.add(user);
+ };
+
+ /**
+ * Load the users for the active reactions.
+ *
+ *
+ * @param {Object} options - Options for loading the data.
+ * @param {string} options.limit - Per request limit for pagination.
+ */
+ @action
+ loadReactedUsersData = async (
+ { limit }: { limit: number } = { limit: Pagination.defaultLimit }
+ ) => {
+ if (this.reactedUsersLoading || this.reactedUsersLoaded) {
+ return;
+ }
+
+ this.reactedUsersLoading = true;
+
+ try {
+ const fetchPage = async (offset: number = 0) => {
+ const res = await client.post("/reactions.list", {
+ commentId: this.id,
+ offset,
+ limit,
+ });
+
+ invariant(res?.data, "Data not available");
+ // @ts-expect-error reaction from server response
+ res.data.map((reaction) =>
+ this.store.rootStore.users.add(reaction.user)
+ );
+
+ return res.pagination;
+ };
+
+ const { total } = await fetchPage();
+
+ const pages = Math.ceil(total / limit);
+ const fetchPages = [];
+ for (let page = 1; page < pages; page++) {
+ fetchPages.push(fetchPage(page * limit));
+ }
+
+ await Promise.all(fetchPages);
+
+ this.reactedUsersLoaded = true;
+ } finally {
+ this.reactedUsersLoading = false;
+ }
+ };
}
export default Comment;
diff --git a/app/models/Document.ts b/app/models/Document.ts
index 19e2a10b58..0fc20c8e0f 100644
--- a/app/models/Document.ts
+++ b/app/models/Document.ts
@@ -254,7 +254,8 @@ export default class Document extends ArchivableModel {
@computed
get path(): string {
- const prefix = this.template ? settingsPath("templates") : "/doc";
+ const prefix =
+ this.template && !this.isDeleted ? settingsPath("templates") : "/doc";
if (!this.title) {
return `${prefix}/untitled-${this.urlId}`;
diff --git a/app/models/Event.ts b/app/models/Event.ts
index 5ead9c48f4..15ecd64dba 100644
--- a/app/models/Event.ts
+++ b/app/models/Event.ts
@@ -1,21 +1,29 @@
+import Collection from "./Collection";
+import Document from "./Document";
import User from "./User";
import Model from "./base/Model";
import Relation from "./decorators/Relation";
-class Event extends Model {
+class Event extends Model {
static modelName = "Event";
id: string;
name: string;
- modelId: string | null | undefined;
+ modelId: string | undefined;
actorIpAddress: string | null | undefined;
- documentId: string;
+ @Relation(() => Document)
+ document: Document;
- collectionId: string | null | undefined;
+ documentId: string | undefined;
+
+ @Relation(() => Collection)
+ collection: Collection;
+
+ collectionId: string | undefined;
@Relation(() => User)
user: User;
@@ -27,13 +35,12 @@ class Event extends Model {
actorId: string;
- data: {
- name: string;
- email: string;
- title: string;
- published: boolean;
- templateId: string;
- };
+ data: Partial | null;
+
+ changes: {
+ attributes: Partial;
+ previous: Partial;
+ } | null;
}
export default Event;
diff --git a/app/models/Share.ts b/app/models/Share.ts
index 6a1e945c73..06d3c9740e 100644
--- a/app/models/Share.ts
+++ b/app/models/Share.ts
@@ -55,6 +55,10 @@ class Share extends Model {
@observable
url: string;
+ @Field
+ @observable
+ allowIndexing: boolean;
+
/** The user that shared the document. */
@Relation(() => User, { onDelete: "null" })
createdBy: User;
diff --git a/app/models/User.ts b/app/models/User.ts
index 461b10651c..0b46d92d96 100644
--- a/app/models/User.ts
+++ b/app/models/User.ts
@@ -50,6 +50,10 @@ class User extends ParanoidModel {
@observable
notificationSettings: NotificationSettings;
+ @Field
+ @observable
+ timezone?: string;
+
@observable
email: string;
diff --git a/app/scenes/ApiKeyNew/index.tsx b/app/scenes/ApiKeyNew/index.tsx
index ecae83735e..a458cd58c8 100644
--- a/app/scenes/ApiKeyNew/index.tsx
+++ b/app/scenes/ApiKeyNew/index.tsx
@@ -112,7 +112,7 @@ function ApiKeyNew({ onSubmit }: Props) {
value={expiryType}
options={expiryOptions}
onChange={handleExpiryTypeChange}
- skipBodyScroll={true}
+ skipBodyScroll
/>
{expiryType === ExpiryType.Custom ? (
;
}
diff --git a/app/scenes/Document/components/CommentEditor.tsx b/app/scenes/Document/components/CommentEditor.tsx
index 32394baff3..b0c1dc8ebc 100644
--- a/app/scenes/Document/components/CommentEditor.tsx
+++ b/app/scenes/Document/components/CommentEditor.tsx
@@ -1,3 +1,4 @@
+import { observer } from "mobx-react";
import * as React from "react";
import { basicExtensions, withComments } from "@shared/editor/nodes";
import HardBreak from "@shared/editor/nodes/HardBreak";
@@ -36,4 +37,4 @@ const CommentEditor = (
);
};
-export default React.forwardRef(CommentEditor);
+export default observer(React.forwardRef(CommentEditor));
diff --git a/app/scenes/Document/components/CommentForm.tsx b/app/scenes/Document/components/CommentForm.tsx
index de95815070..bf6afb9c3b 100644
--- a/app/scenes/Document/components/CommentForm.tsx
+++ b/app/scenes/Document/components/CommentForm.tsx
@@ -27,6 +27,8 @@ import { Bubble } from "./CommentThreadItem";
import { HighlightedText } from "./HighlightText";
type Props = {
+ /** Callback when the form is submitted. */
+ onSubmit?: () => void;
/** Callback when the draft should be saved. */
onSaveDraft: (data: ProsemirrorData | undefined) => void;
/** A draft comment for this thread. */
@@ -59,6 +61,7 @@ function CommentForm({
documentId,
thread,
draft,
+ onSubmit,
onSaveDraft,
onTyping,
onFocus,
@@ -109,6 +112,7 @@ function CommentForm({
createdAt: new Date().toISOString(),
documentId,
data: draft,
+ reactions: [],
},
comments
);
@@ -118,6 +122,7 @@ function CommentForm({
documentId,
data: draft,
})
+ .then(() => onSubmit?.())
.catch(() => {
comment.isNew = true;
toast.error(t("Error creating comment"));
@@ -144,6 +149,7 @@ function CommentForm({
parentCommentId: thread?.id,
documentId,
data: draft,
+ reactions: [],
},
comments
);
@@ -151,11 +157,14 @@ function CommentForm({
comment.id = uuidv4();
comments.add(comment);
- comment.save().catch(() => {
- comments.remove(comment.id);
- comment.isNew = true;
- toast.error(t("Error creating comment"));
- });
+ comment
+ .save()
+ .then(() => onSubmit?.())
+ .catch(() => {
+ comments.remove(comment.id);
+ comment.isNew = true;
+ toast.error(t("Error creating comment"));
+ });
// optimistically update the comment model
comment.isNew = false;
diff --git a/app/scenes/Document/components/CommentSortMenu.tsx b/app/scenes/Document/components/CommentSortMenu.tsx
new file mode 100644
index 0000000000..db8227f3d0
--- /dev/null
+++ b/app/scenes/Document/components/CommentSortMenu.tsx
@@ -0,0 +1,86 @@
+import queryString from "query-string";
+import React from "react";
+import { useTranslation } from "react-i18next";
+import { useHistory, useLocation } from "react-router-dom";
+import styled from "styled-components";
+import { s } from "@shared/styles";
+import { UserPreference } from "@shared/types";
+import InputSelect from "~/components/InputSelect";
+import useCurrentUser from "~/hooks/useCurrentUser";
+import useQuery from "~/hooks/useQuery";
+import { CommentSortType } from "~/types";
+
+const CommentSortMenu = () => {
+ const { t } = useTranslation();
+ const location = useLocation();
+ const history = useHistory();
+ const user = useCurrentUser();
+ const params = useQuery();
+
+ const viewingResolved = params.get("resolved") === "";
+ const value = viewingResolved
+ ? "resolved"
+ : user.getPreference(UserPreference.SortCommentsByOrderInDocument)
+ ? CommentSortType.OrderInDocument
+ : CommentSortType.MostRecent;
+
+ const handleSortTypeChange = (type: CommentSortType) => {
+ user.setPreference(
+ UserPreference.SortCommentsByOrderInDocument,
+ type === CommentSortType.OrderInDocument
+ );
+ void user.save();
+ };
+
+ const showResolved = () => {
+ history.push({
+ search: queryString.stringify({
+ ...queryString.parse(location.search),
+ resolved: "",
+ }),
+ pathname: location.pathname,
+ });
+ };
+
+ const showUnresolved = () => {
+ history.push({
+ search: queryString.stringify({
+ ...queryString.parse(location.search),
+ resolved: undefined,
+ }),
+ pathname: location.pathname,
+ });
+ };
+
+ return (
+