mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
Merge branch 'main' into codegen-bot/import-validation-behavior-options
This commit is contained in:
commit
ee285bc4d5
131 files changed
+2416
-1611
No files matched your search
@@ -72,6 +72,7 @@
|
||||
"ignoreTypeValueShadow": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-require-imports": "off",
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
@@ -85,6 +86,7 @@
|
||||
"error",
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"caughtErrorsIgnorePattern": "^_",
|
||||
"args": "after-used",
|
||||
"ignoreRestSiblings": true
|
||||
}
|
||||
@@ -185,4 +187,4 @@
|
||||
"typescript": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,8 +106,8 @@ export const startTyping = createAction({
|
||||
}, 250);
|
||||
|
||||
window.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Escape") {
|
||||
intervalId && clearInterval(intervalId);
|
||||
if (event.key === "Escape" && intervalId) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1215,7 +1215,7 @@ export const leaveDocument = createAction({
|
||||
} as UserMembership);
|
||||
|
||||
toast.success(t("You have left the shared document"));
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Could not leave document"));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -57,13 +57,15 @@ export const createTeam = createAction({
|
||||
perform: ({ t, event, stores }) => {
|
||||
event?.preventDefault();
|
||||
event?.stopPropagation();
|
||||
|
||||
const { user } = stores.auth;
|
||||
user &&
|
||||
if (user) {
|
||||
stores.dialogs.openModal({
|
||||
title: t("Create a workspace"),
|
||||
fullscreen: true,
|
||||
content: <TeamNew user={user} />,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as Popover from "@radix-ui/react-popover";
|
||||
import filter from "lodash/filter";
|
||||
import isEqual from "lodash/isEqual";
|
||||
import orderBy from "lodash/orderBy";
|
||||
@@ -5,15 +6,16 @@ import uniq from "lodash/uniq";
|
||||
import { observer } from "mobx-react";
|
||||
import { useState, useMemo, useEffect, useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { usePopoverState, PopoverDisclosure } from "reakit/Popover";
|
||||
import styled from "styled-components";
|
||||
import { depths, s } from "@shared/styles";
|
||||
import Document from "~/models/Document";
|
||||
import { AvatarSize, AvatarWithPresence } from "~/components/Avatar";
|
||||
import DocumentViews from "~/components/DocumentViews";
|
||||
import Facepile from "~/components/Facepile";
|
||||
import NudeButton from "~/components/NudeButton";
|
||||
import Popover from "~/components/Popover";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { fadeAndScaleIn } from "~/styles/animations";
|
||||
|
||||
type Props = {
|
||||
/** The document to display live collaborators for */
|
||||
@@ -22,6 +24,21 @@ type Props = {
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
// Styled components to match the original Popover styling
|
||||
const StyledPopoverContent = styled(Popover.Content)`
|
||||
animation: ${fadeAndScaleIn} 200ms ease;
|
||||
transform-origin: 75% 0;
|
||||
background: ${s("menuBackground")};
|
||||
border-radius: 6px;
|
||||
padding: 12px 24px;
|
||||
max-height: 75vh;
|
||||
box-shadow: ${s("menuShadow")};
|
||||
z-index: ${depths.modal};
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
outline: none;
|
||||
`;
|
||||
|
||||
/**
|
||||
* Displays a list of live collaborators for a document, including their avatars
|
||||
* and presence status.
|
||||
@@ -32,6 +49,7 @@ function Collaborators(props: Props) {
|
||||
const user = useCurrentUser();
|
||||
const currentUserId = user?.id;
|
||||
const [requestedUserIds, setRequestedUserIds] = useState<string[]>([]);
|
||||
const [popoverOpen, setPopoverOpen] = useState(false);
|
||||
const { users, presence, ui } = useStores();
|
||||
const { document } = props;
|
||||
const { observingUserId } = ui;
|
||||
@@ -94,11 +112,6 @@ function Collaborators(props: Props) {
|
||||
}
|
||||
}, [missingUserIds, requestedUserIds, users]);
|
||||
|
||||
const popover = usePopoverState({
|
||||
gutter: 0,
|
||||
placement: "bottom-end",
|
||||
});
|
||||
|
||||
// Memoize onClick handler to avoid inline function creation
|
||||
const handleAvatarClick = useCallback(
|
||||
(
|
||||
@@ -150,28 +163,33 @@ function Collaborators(props: Props) {
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PopoverDisclosure {...popover}>
|
||||
{(popoverProps) => (
|
||||
<NudeButton
|
||||
width={Math.min(collaborators.length, limit) * AvatarSize.Large}
|
||||
height={AvatarSize.Large}
|
||||
{...popoverProps}
|
||||
>
|
||||
<Facepile
|
||||
size={AvatarSize.Large}
|
||||
limit={limit}
|
||||
overflow={Math.max(0, collaborators.length - limit)}
|
||||
users={collaborators}
|
||||
renderAvatar={renderAvatar}
|
||||
/>
|
||||
</NudeButton>
|
||||
)}
|
||||
</PopoverDisclosure>
|
||||
<Popover {...popover} width={300} aria-label={t("Viewers")} tabIndex={0}>
|
||||
{popover.visible && <DocumentViews document={document} />}
|
||||
</Popover>
|
||||
</>
|
||||
<Popover.Root open={popoverOpen} onOpenChange={setPopoverOpen}>
|
||||
<Popover.Trigger asChild>
|
||||
<NudeButton
|
||||
width={Math.min(collaborators.length, limit) * AvatarSize.Large}
|
||||
height={AvatarSize.Large}
|
||||
>
|
||||
<Facepile
|
||||
size={AvatarSize.Large}
|
||||
limit={limit}
|
||||
overflow={Math.max(0, collaborators.length - limit)}
|
||||
users={collaborators}
|
||||
renderAvatar={renderAvatar}
|
||||
/>
|
||||
</NudeButton>
|
||||
</Popover.Trigger>
|
||||
<Popover.Portal>
|
||||
<StyledPopoverContent
|
||||
side="bottom"
|
||||
align="end"
|
||||
sideOffset={0}
|
||||
aria-label={t("Viewers")}
|
||||
style={{ width: 300 }}
|
||||
>
|
||||
<DocumentViews document={document} />
|
||||
</StyledPopoverContent>
|
||||
</Popover.Portal>
|
||||
</Popover.Root>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,9 @@ const InnerContextMenu = (props: InnerContextMenuProps) => {
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
scrollElement && !props.isSubMenu && enableBodyScroll(scrollElement);
|
||||
if (scrollElement && !props.isSubMenu) {
|
||||
enableBodyScroll(scrollElement);
|
||||
}
|
||||
};
|
||||
}, [props.isSubMenu, props.visible]);
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ function DocumentCopy({ document, onSubmit }: Props) {
|
||||
|
||||
toast.success(t("Document copied"));
|
||||
onSubmit(result);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Couldn’t copy the document, try again?"));
|
||||
}
|
||||
};
|
||||
|
||||
+80
-75
@@ -1,9 +1,9 @@
|
||||
import * as Dialog from "@radix-ui/react-dialog";
|
||||
import { observer } from "mobx-react";
|
||||
import { CloseIcon, BackIcon } from "outline-icons";
|
||||
import { transparentize } from "polished";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Dialog, DialogBackdrop, useDialogState } from "reakit/Dialog";
|
||||
import styled, { DefaultTheme } from "styled-components";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import { depths, s } from "@shared/styles";
|
||||
@@ -37,9 +37,6 @@ const Modal: React.FC<Props> = ({
|
||||
style,
|
||||
onRequestClose,
|
||||
}: Props) => {
|
||||
const dialog = useDialogState({
|
||||
animated: 250,
|
||||
});
|
||||
const [depth, setDepth] = React.useState(0);
|
||||
const wasOpen = usePrevious(isOpen);
|
||||
const isMobile = useMobile();
|
||||
@@ -48,14 +45,12 @@ const Modal: React.FC<Props> = ({
|
||||
React.useEffect(() => {
|
||||
if (!wasOpen && isOpen) {
|
||||
setDepth(openModals++);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
if (wasOpen && !isOpen) {
|
||||
setDepth(openModals--);
|
||||
dialog.hide();
|
||||
}
|
||||
}, [dialog, wasOpen, isOpen]);
|
||||
}, [wasOpen, isOpen]);
|
||||
|
||||
useUnmount(() => {
|
||||
if (isOpen) {
|
||||
@@ -68,78 +63,75 @@ const Modal: React.FC<Props> = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<DialogBackdrop {...dialog}>
|
||||
{(backdropProps) => (
|
||||
<Backdrop $fullscreen={fullscreen} {...backdropProps}>
|
||||
<Dialog
|
||||
{...dialog}
|
||||
aria-label={typeof title === "string" ? title : undefined}
|
||||
preventBodyScroll
|
||||
hideOnEsc
|
||||
hideOnClickOutside={!fullscreen}
|
||||
hide={onRequestClose}
|
||||
<Dialog.Root
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => !open && onRequestClose()}
|
||||
>
|
||||
<Dialog.Portal>
|
||||
<StyledOverlay $fullscreen={fullscreen}>
|
||||
<StyledContent
|
||||
onEscapeKeyDown={onRequestClose}
|
||||
onPointerDownOutside={fullscreen ? undefined : onRequestClose}
|
||||
aria-describedby={undefined}
|
||||
>
|
||||
{(dialogProps) =>
|
||||
fullscreen || isMobile ? (
|
||||
<Fullscreen
|
||||
$nested={!!depth}
|
||||
style={
|
||||
isMobile
|
||||
? undefined
|
||||
: {
|
||||
marginLeft: `${depth * 12}px`,
|
||||
}
|
||||
}
|
||||
{...dialogProps}
|
||||
>
|
||||
<Content>
|
||||
<Centered onClick={(ev) => ev.stopPropagation()} column>
|
||||
{title && (
|
||||
<Text size="xlarge" weight="bold">
|
||||
{title}
|
||||
</Text>
|
||||
)}
|
||||
<ErrorBoundary>{children}</ErrorBoundary>
|
||||
</Centered>
|
||||
</Content>
|
||||
<Close onClick={onRequestClose}>
|
||||
<CloseIcon size={32} />
|
||||
</Close>
|
||||
<Back onClick={onRequestClose}>
|
||||
<BackIcon size={32} />
|
||||
<Text>{t("Back")} </Text>
|
||||
</Back>
|
||||
</Fullscreen>
|
||||
) : (
|
||||
<Small {...dialogProps}>
|
||||
<Centered
|
||||
onClick={(ev) => ev.stopPropagation()}
|
||||
// maxHeight needed for proper overflow behavior in Safari
|
||||
style={{ maxHeight: "65vh" }}
|
||||
column
|
||||
reverse
|
||||
>
|
||||
<SmallContent style={style} shadow>
|
||||
<ErrorBoundary component="div">{children}</ErrorBoundary>
|
||||
</SmallContent>
|
||||
<Header>
|
||||
{title && <Text size="large">{title}</Text>}
|
||||
<NudeButton onClick={onRequestClose}>
|
||||
<CloseIcon />
|
||||
</NudeButton>
|
||||
</Header>
|
||||
{fullscreen || isMobile ? (
|
||||
<Fullscreen
|
||||
$nested={!!depth}
|
||||
style={
|
||||
isMobile
|
||||
? undefined
|
||||
: {
|
||||
marginLeft: `${depth * 12}px`,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Content>
|
||||
<Centered onClick={(ev) => ev.stopPropagation()} column>
|
||||
{title && (
|
||||
<Text size="xlarge" weight="bold">
|
||||
{title}
|
||||
</Text>
|
||||
)}
|
||||
<ErrorBoundary>{children}</ErrorBoundary>
|
||||
</Centered>
|
||||
</Small>
|
||||
)
|
||||
}
|
||||
</Dialog>
|
||||
</Backdrop>
|
||||
)}
|
||||
</DialogBackdrop>
|
||||
</Content>
|
||||
<Close onClick={onRequestClose}>
|
||||
<CloseIcon size={32} />
|
||||
</Close>
|
||||
<Back onClick={onRequestClose}>
|
||||
<BackIcon size={32} />
|
||||
<Text>{t("Back")} </Text>
|
||||
</Back>
|
||||
</Fullscreen>
|
||||
) : (
|
||||
<Small>
|
||||
<Centered
|
||||
onClick={(ev) => ev.stopPropagation()}
|
||||
// maxHeight needed for proper overflow behavior in Safari
|
||||
style={{ maxHeight: "65vh" }}
|
||||
column
|
||||
reverse
|
||||
>
|
||||
<SmallContent style={style} shadow>
|
||||
<ErrorBoundary component="div">{children}</ErrorBoundary>
|
||||
</SmallContent>
|
||||
<Header>
|
||||
{title && <Text size="large">{title}</Text>}
|
||||
<NudeButton onClick={onRequestClose}>
|
||||
<CloseIcon />
|
||||
</NudeButton>
|
||||
</Header>
|
||||
</Centered>
|
||||
</Small>
|
||||
)}
|
||||
</StyledContent>
|
||||
</StyledOverlay>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
);
|
||||
};
|
||||
|
||||
const Backdrop = styled(Flex)<{ $fullscreen?: boolean }>`
|
||||
const StyledOverlay = styled(Dialog.Overlay)<{ $fullscreen?: boolean }>`
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
@@ -153,11 +145,24 @@ const Backdrop = styled(Flex)<{ $fullscreen?: boolean }>`
|
||||
transition: opacity 50ms ease-in-out;
|
||||
opacity: 0;
|
||||
|
||||
&[data-enter] {
|
||||
&[data-state="open"] {
|
||||
opacity: 1;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledContent = styled(Dialog.Content)`
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: ${depths.modal};
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
outline: none;
|
||||
`;
|
||||
|
||||
type FullscreenProps = {
|
||||
$nested: boolean;
|
||||
theme: DefaultTheme;
|
||||
|
||||
@@ -23,15 +23,13 @@ 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, isOpen }: Props,
|
||||
{ onRequestClose }: Props,
|
||||
ref: React.RefObject<HTMLDivElement>
|
||||
) {
|
||||
const context = useActionContext();
|
||||
@@ -82,7 +80,7 @@ function Notifications(
|
||||
<PaginatedList<Notification>
|
||||
fetch={notifications.fetchPage}
|
||||
options={{ archived: false }}
|
||||
items={isOpen ? notifications.orderedData : undefined}
|
||||
items={notifications.orderedData}
|
||||
renderItem={(item) => (
|
||||
<NotificationListItem
|
||||
key={item.id}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import * as Popover from "@radix-ui/react-popover";
|
||||
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
||||
import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { usePopoverState, PopoverDisclosure } from "reakit/Popover";
|
||||
import styled from "styled-components";
|
||||
import { depths } from "@shared/styles";
|
||||
import Popover from "~/components/Popover";
|
||||
import { depths, s } from "@shared/styles";
|
||||
import { fadeAndSlideUp } from "~/styles/animations";
|
||||
import Notifications from "./Notifications";
|
||||
|
||||
type Props = {
|
||||
@@ -14,44 +15,71 @@ type Props = {
|
||||
const NotificationsPopover: React.FC = ({ children }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const scrollableRef = React.useRef<HTMLDivElement>(null);
|
||||
const closeRef = React.useRef<HTMLButtonElement>(null);
|
||||
|
||||
const popover = usePopoverState({
|
||||
gutter: 0,
|
||||
placement: "top-start",
|
||||
unstable_fixed: true,
|
||||
});
|
||||
|
||||
// Reset scroll position to the top when popover is opened
|
||||
React.useEffect(() => {
|
||||
if (popover.visible && scrollableRef.current) {
|
||||
scrollableRef.current.scrollTop = 0;
|
||||
const handleRequestClose = React.useCallback(() => {
|
||||
if (closeRef.current) {
|
||||
closeRef.current.click();
|
||||
}
|
||||
}, [popover.visible]);
|
||||
}, []);
|
||||
|
||||
const handleAutoFocus = React.useCallback((event: Event) => {
|
||||
// Prevent focus from moving to the popover content
|
||||
event.preventDefault();
|
||||
|
||||
// Reset scroll position to the top when popover is opened
|
||||
if (scrollableRef.current) {
|
||||
scrollableRef.current.scrollTop = 0;
|
||||
scrollableRef.current.focus();
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PopoverDisclosure {...popover}>{children}</PopoverDisclosure>
|
||||
<StyledPopover
|
||||
{...popover}
|
||||
scrollable={false}
|
||||
mobilePosition="bottom"
|
||||
aria-label={t("Notifications")}
|
||||
unstable_initialFocusRef={scrollableRef}
|
||||
shrink
|
||||
flex
|
||||
>
|
||||
<Notifications
|
||||
onRequestClose={popover.hide}
|
||||
isOpen={popover.visible}
|
||||
ref={scrollableRef}
|
||||
/>
|
||||
</StyledPopover>
|
||||
</>
|
||||
<Popover.Root>
|
||||
<Popover.Trigger asChild>{children}</Popover.Trigger>
|
||||
<Popover.Portal>
|
||||
<StyledContent
|
||||
side="top"
|
||||
align="start"
|
||||
sideOffset={0}
|
||||
avoidCollisions={true}
|
||||
aria-label={t("Notifications")}
|
||||
onOpenAutoFocus={handleAutoFocus}
|
||||
>
|
||||
<Notifications
|
||||
onRequestClose={handleRequestClose}
|
||||
ref={scrollableRef}
|
||||
/>
|
||||
<VisuallyHidden>
|
||||
<Popover.Close ref={closeRef} />
|
||||
</VisuallyHidden>
|
||||
</StyledContent>
|
||||
</Popover.Portal>
|
||||
</Popover.Root>
|
||||
);
|
||||
};
|
||||
|
||||
const StyledPopover = styled(Popover)`
|
||||
const StyledContent = styled(Popover.Content)`
|
||||
z-index: ${depths.menu};
|
||||
display: flex;
|
||||
animation: ${fadeAndSlideUp} 200ms ease;
|
||||
transform-origin: 75% 0;
|
||||
background: ${s("menuBackground")};
|
||||
border-radius: 6px;
|
||||
padding: 6px 0;
|
||||
max-height: 75vh;
|
||||
box-shadow: ${s("menuShadow")};
|
||||
width: 380px;
|
||||
overflow: hidden;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
position: fixed;
|
||||
z-index: ${depths.menu};
|
||||
top: 50px;
|
||||
left: 8px;
|
||||
right: 8px;
|
||||
width: auto;
|
||||
}
|
||||
`;
|
||||
|
||||
export default observer(NotificationsPopover);
|
||||
@@ -107,9 +107,11 @@ const Reaction: React.FC<Props> = ({
|
||||
const handleClick = React.useCallback(
|
||||
(event: React.SyntheticEvent<HTMLButtonElement>) => {
|
||||
event.stopPropagation();
|
||||
active
|
||||
? void onRemoveReaction(reaction.emoji)
|
||||
: void onAddReaction(reaction.emoji);
|
||||
if (active) {
|
||||
void onRemoveReaction(reaction.emoji);
|
||||
} else {
|
||||
void onAddReaction(reaction.emoji);
|
||||
}
|
||||
},
|
||||
[reaction, active, onAddReaction, onRemoveReaction]
|
||||
);
|
||||
|
||||
@@ -41,7 +41,7 @@ const ReactionList: React.FC<Props> = ({
|
||||
const loadReactedUsersData = async () => {
|
||||
try {
|
||||
await model.loadReactedUsersData();
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
Logger.warn("Could not prefetch reaction data");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ const ViewReactionsDialog: React.FC<Props> = ({ model }) => {
|
||||
const loadReactedUsersData = async () => {
|
||||
try {
|
||||
await model.loadReactedUsersData();
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Could not load reactions"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ import type Collection from "~/models/Collection";
|
||||
import type Document from "~/models/Document";
|
||||
import Share from "~/models/Share";
|
||||
import Flex from "~/components/Flex";
|
||||
import NudeButton from "~/components/NudeButton";
|
||||
import Scrollable from "~/components/Scrollable";
|
||||
import Text from "~/components/Text";
|
||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||
@@ -230,7 +231,9 @@ const AccessTooltip = ({
|
||||
{children}
|
||||
</Text>
|
||||
<Tooltip content={content ?? t("Access inherited from collection")}>
|
||||
<QuestionMarkIcon size={18} />
|
||||
<NudeButton size={18}>
|
||||
<QuestionMarkIcon size={18} />
|
||||
</NudeButton>
|
||||
</Tooltip>
|
||||
</Flex>
|
||||
);
|
||||
|
||||
@@ -54,7 +54,7 @@ function DocumentMembersList({ document, invitedInSession }: Props) {
|
||||
})
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Could not remove user"));
|
||||
}
|
||||
},
|
||||
@@ -74,7 +74,7 @@ function DocumentMembersList({ document, invitedInSession }: Props) {
|
||||
userName: userToUpdate.name,
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Could not update user"));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -64,6 +64,19 @@ function PublicAccess({ document, share, sharedParent }: Props) {
|
||||
[share]
|
||||
);
|
||||
|
||||
const handleShowLastModifiedChanged = React.useCallback(
|
||||
async (event) => {
|
||||
try {
|
||||
await share?.save({
|
||||
showLastUpdated: event.currentTarget.checked,
|
||||
});
|
||||
} catch (err) {
|
||||
toast.error(err.message);
|
||||
}
|
||||
},
|
||||
[share]
|
||||
);
|
||||
|
||||
const handlePublishedChange = React.useCallback(
|
||||
async (event) => {
|
||||
try {
|
||||
@@ -177,7 +190,9 @@ function PublicAccess({ document, share, sharedParent }: Props) {
|
||||
"Disable this setting to discourage search engines from indexing the page"
|
||||
)}
|
||||
>
|
||||
<QuestionMarkIcon size={18} />
|
||||
<NudeButton size={18}>
|
||||
<QuestionMarkIcon size={18} />
|
||||
</NudeButton>
|
||||
</Tooltip>
|
||||
</Text>
|
||||
}
|
||||
@@ -193,6 +208,34 @@ function PublicAccess({ document, share, sharedParent }: Props) {
|
||||
/>
|
||||
)}
|
||||
|
||||
{share?.published && (
|
||||
<ListItem
|
||||
title={
|
||||
<Text type="tertiary" as={Flex}>
|
||||
{t("Show last modified")}
|
||||
<Tooltip
|
||||
content={t(
|
||||
"Display the last modified timestamp on the shared page"
|
||||
)}
|
||||
>
|
||||
<NudeButton size={18}>
|
||||
<QuestionMarkIcon size={18} />
|
||||
</NudeButton>
|
||||
</Tooltip>
|
||||
</Text>
|
||||
}
|
||||
actions={
|
||||
<Switch
|
||||
aria-label={t("Show last modified")}
|
||||
checked={share?.showLastUpdated ?? false}
|
||||
onChange={handleShowLastModifiedChanged}
|
||||
width={26}
|
||||
height={14}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{sharedParent?.published ? (
|
||||
<ShareLinkInput type="text" disabled defaultValue={shareUrl}>
|
||||
{copyButton}
|
||||
|
||||
@@ -246,7 +246,12 @@ const Sidebar = React.forwardRef<HTMLDivElement, Props>(function _Sidebar(
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Notifications />
|
||||
<NotificationsPopover>
|
||||
<SidebarButton
|
||||
position="bottom"
|
||||
image={<NotificationIcon />}
|
||||
/>
|
||||
</NotificationsPopover>
|
||||
</SidebarButton>
|
||||
)}
|
||||
</AccountMenu>
|
||||
@@ -261,14 +266,6 @@ const Sidebar = React.forwardRef<HTMLDivElement, Props>(function _Sidebar(
|
||||
);
|
||||
});
|
||||
|
||||
const Notifications = () => (
|
||||
<NotificationsPopover>
|
||||
{(rest: SidebarButtonProps) => (
|
||||
<SidebarButton {...rest} position="bottom" image={<NotificationIcon />} />
|
||||
)}
|
||||
</NotificationsPopover>
|
||||
);
|
||||
|
||||
const Backdrop = styled.a`
|
||||
animation: ${fadeIn} 250ms ease-in-out;
|
||||
position: fixed;
|
||||
|
||||
@@ -120,7 +120,11 @@ function InnerDocumentLink(
|
||||
const handleDisclosureClick = React.useCallback(
|
||||
(ev) => {
|
||||
ev?.preventDefault();
|
||||
expanded ? setCollapsed() : setExpanded();
|
||||
if (expanded) {
|
||||
setCollapsed();
|
||||
} else {
|
||||
setExpanded();
|
||||
}
|
||||
},
|
||||
[setCollapsed, setExpanded, expanded]
|
||||
);
|
||||
|
||||
+64
-54
@@ -1,3 +1,4 @@
|
||||
import * as RadixSwitch from "@radix-ui/react-switch";
|
||||
import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import { s } from "@shared/styles";
|
||||
@@ -5,7 +6,11 @@ import { LabelText } from "~/components/Input";
|
||||
import Text from "~/components/Text";
|
||||
import { undraggableOnDesktop } from "~/styles";
|
||||
|
||||
interface Props extends React.HTMLAttributes<HTMLInputElement> {
|
||||
interface Props
|
||||
extends Omit<
|
||||
React.ComponentProps<typeof RadixSwitch.Root>,
|
||||
"checked" | "onCheckedChange" | "onChange"
|
||||
> {
|
||||
/** Width of the switch. Defaults to 32. */
|
||||
width?: number;
|
||||
/** Height of the switch. Defaults to 18 */
|
||||
@@ -22,6 +27,8 @@ interface Props extends React.HTMLAttributes<HTMLInputElement> {
|
||||
checked?: boolean;
|
||||
/** Whether the switch is disabled */
|
||||
disabled?: boolean;
|
||||
/** Callback when the switch state changes */
|
||||
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
}
|
||||
|
||||
function Switch(
|
||||
@@ -33,26 +40,39 @@ function Switch(
|
||||
disabled,
|
||||
className,
|
||||
note,
|
||||
checked,
|
||||
onChange,
|
||||
...props
|
||||
}: Props,
|
||||
ref: React.Ref<HTMLInputElement>
|
||||
ref: React.Ref<React.ElementRef<typeof RadixSwitch.Root>>
|
||||
) {
|
||||
const handleCheckedChange = React.useCallback(
|
||||
(checkedState: boolean) => {
|
||||
if (onChange) {
|
||||
// Create a synthetic event to maintain compatibility with existing code
|
||||
const syntheticEvent = {
|
||||
target: { id: props.id, name: props.name, checked: checkedState },
|
||||
currentTarget: { checked: checkedState },
|
||||
} as React.ChangeEvent<HTMLInputElement>;
|
||||
onChange(syntheticEvent);
|
||||
}
|
||||
},
|
||||
[onChange, props.id, props.name]
|
||||
);
|
||||
|
||||
const component = (
|
||||
<Input
|
||||
<StyledSwitchRoot
|
||||
ref={ref}
|
||||
checked={checked}
|
||||
onCheckedChange={handleCheckedChange}
|
||||
disabled={disabled}
|
||||
width={width}
|
||||
height={height}
|
||||
className={label ? undefined : className}
|
||||
{...props}
|
||||
>
|
||||
<HiddenInput
|
||||
ref={ref}
|
||||
type="checkbox"
|
||||
width={width}
|
||||
height={height}
|
||||
disabled={disabled}
|
||||
{...props}
|
||||
/>
|
||||
<Slider width={width} height={height} />
|
||||
</Input>
|
||||
<StyledSwitchThumb width={width} height={height} />
|
||||
</StyledSwitchRoot>
|
||||
);
|
||||
|
||||
if (label) {
|
||||
@@ -110,60 +130,50 @@ const Label = styled.label<{
|
||||
${(props) => (props.disabled ? `opacity: 0.75;` : "")}
|
||||
`;
|
||||
|
||||
const Input = styled.label<{ width: number; height: number }>`
|
||||
const StyledSwitchRoot = styled(RadixSwitch.Root)<{
|
||||
width: number;
|
||||
height: number;
|
||||
}>`
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: ${(props) => props.width}px;
|
||||
height: ${(props) => props.height}px;
|
||||
flex-shrink: 0;
|
||||
`;
|
||||
|
||||
const Slider = styled.span<{ width: number; height: number }>`
|
||||
position: absolute;
|
||||
cursor: var(--pointer);
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: ${(props) => props.theme.slate};
|
||||
-webkit-transition: 0.4s;
|
||||
transition: 0.4s;
|
||||
border-radius: ${(props) => props.height}px;
|
||||
border: none;
|
||||
cursor: var(--pointer);
|
||||
transition: background-color 0.4s;
|
||||
padding: 0 4px;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: ${(props) => props.height - 8}px;
|
||||
width: ${(props) => props.height - 8}px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
-webkit-transition: 0.4s;
|
||||
transition: 0.4s;
|
||||
}
|
||||
`;
|
||||
|
||||
const HiddenInput = styled.input<{ width: number; height: number }>`
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
visibility: hidden;
|
||||
|
||||
&:disabled + ${Slider} {
|
||||
opacity: 0.75;
|
||||
cursor: default;
|
||||
&:focus {
|
||||
box-shadow: 0 0 1px ${s("accent")};
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:checked + ${Slider} {
|
||||
&[data-state="checked"] {
|
||||
background-color: ${s("accent")};
|
||||
}
|
||||
|
||||
&:focus + ${Slider} {
|
||||
box-shadow: 0 0 1px ${s("accent")};
|
||||
&:disabled {
|
||||
opacity: 0.75;
|
||||
cursor: default;
|
||||
}
|
||||
`;
|
||||
|
||||
&:checked + ${Slider}:before {
|
||||
const StyledSwitchThumb = styled(RadixSwitch.Thumb)<{
|
||||
width: number;
|
||||
height: number;
|
||||
}>`
|
||||
display: block;
|
||||
width: ${(props) => props.height - 8}px;
|
||||
height: ${(props) => props.height - 8}px;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.4s;
|
||||
transform: translateX(0);
|
||||
will-change: transform;
|
||||
|
||||
&[data-state="checked"] {
|
||||
transform: translateX(${(props) => props.width - props.height}px);
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -159,10 +159,16 @@ class WebsocketProvider extends Component<Props> {
|
||||
if (document?.updatedAt === documentDescriptor.updatedAt) {
|
||||
continue;
|
||||
}
|
||||
if (!document && !event.fetchIfMissing) {
|
||||
if (!document) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event.invalidatedPolicies) {
|
||||
event.invalidatedPolicies.forEach((policyId) => {
|
||||
policies.remove(policyId);
|
||||
});
|
||||
}
|
||||
|
||||
// otherwise, grab the latest version of the document
|
||||
try {
|
||||
document = await documents.fetch(documentId, {
|
||||
@@ -207,10 +213,16 @@ class WebsocketProvider extends Component<Props> {
|
||||
if (collection?.updatedAt === collectionDescriptor.updatedAt) {
|
||||
continue;
|
||||
}
|
||||
if (!collection?.documents && !event.fetchIfMissing) {
|
||||
if (!collection?.documents) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event.invalidatedPolicies) {
|
||||
event.invalidatedPolicies.forEach((policyId) => {
|
||||
policies.remove(policyId);
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await collection?.fetchDocuments({
|
||||
force: true,
|
||||
|
||||
@@ -190,7 +190,7 @@ const LinkEditor: React.FC<Props> = ({
|
||||
|
||||
try {
|
||||
onClickLink(getHref(), event);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(dictionary.openLinkError);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
import { NodeSelection } from "prosemirror-state";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import Flex from "@shared/components/Flex";
|
||||
import Text from "@shared/components/Text";
|
||||
import { EditorStyleHelper } from "@shared/editor/styles/EditorStyleHelper";
|
||||
import { extraArea } from "@shared/styles";
|
||||
import Input, { NativeInput, Outline } from "~/components/Input";
|
||||
import { useEditor } from "./EditorContext";
|
||||
|
||||
type Dimension = {
|
||||
width: string;
|
||||
height: string;
|
||||
changed: "width" | "height" | "none";
|
||||
};
|
||||
|
||||
export function MediaDimension() {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const boundsRef = useRef<{
|
||||
width: { min: number; max: number };
|
||||
height: { min: number; max: number };
|
||||
}>();
|
||||
const { view, commands } = useEditor();
|
||||
const { state } = view;
|
||||
const { selection } = state;
|
||||
|
||||
// This component will be rendered only when the selection is image or video (NodeSelection types).
|
||||
const node = (selection as NodeSelection).node;
|
||||
const nodeType = node.type.name,
|
||||
width = node.attrs.width as number,
|
||||
height = node.attrs.height as number;
|
||||
|
||||
const [localDimension, setLocalDimension] = useState<Dimension>(() => ({
|
||||
width: String(width),
|
||||
height: String(height),
|
||||
changed: "none",
|
||||
}));
|
||||
const [error, setError] = useState<{ width: boolean; height: boolean }>({
|
||||
width: false,
|
||||
height: false,
|
||||
});
|
||||
|
||||
if (!boundsRef.current && ref.current) {
|
||||
const docWidth = parseInt(
|
||||
getComputedStyle(ref.current).getPropertyValue("--document-width")
|
||||
);
|
||||
const maxWidth = docWidth - EditorStyleHelper.padding * 2;
|
||||
const constrainedWidth = Math.min(width, maxWidth); // Ensure media width does not exceed the max width of the editor.
|
||||
const aspectRatio = height / constrainedWidth;
|
||||
|
||||
const maxHeight = Math.round(maxWidth * aspectRatio);
|
||||
boundsRef.current = {
|
||||
width: { min: 50, max: maxWidth },
|
||||
height: { min: 50, max: maxHeight },
|
||||
};
|
||||
}
|
||||
|
||||
const reset = useCallback(() => {
|
||||
setLocalDimension({
|
||||
width: String(width),
|
||||
height: String(height),
|
||||
changed: "none",
|
||||
});
|
||||
setError({ width: false, height: false });
|
||||
}, [width, height]);
|
||||
|
||||
const isOutsideBounds = useCallback(
|
||||
(type: "width" | "height", value: number) => {
|
||||
const bounds = boundsRef.current!;
|
||||
return value < bounds[type].min || value > bounds[type].max;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(type: "width" | "height") => (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { value } = e.target;
|
||||
const isNumber = /^\d+$/.test(value);
|
||||
|
||||
if (value && (!isNumber || value === "0")) {
|
||||
return;
|
||||
}
|
||||
|
||||
setError((prev) => {
|
||||
if (!prev.width && !prev.height) {
|
||||
return prev;
|
||||
}
|
||||
return { width: false, height: false };
|
||||
});
|
||||
|
||||
setLocalDimension((prev) => {
|
||||
if (type === "width") {
|
||||
return {
|
||||
...prev,
|
||||
width: value,
|
||||
changed: "width",
|
||||
};
|
||||
}
|
||||
return {
|
||||
...prev,
|
||||
height: value,
|
||||
changed: "height",
|
||||
};
|
||||
});
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleBlur = useCallback(() => {
|
||||
const localWidthAsNumber = localDimension.width
|
||||
? parseInt(localDimension.width, 10)
|
||||
: undefined,
|
||||
localHeightAsNumber = localDimension.height
|
||||
? parseInt(localDimension.height, 10)
|
||||
: undefined;
|
||||
|
||||
const isUnchanged =
|
||||
!localWidthAsNumber ||
|
||||
!localHeightAsNumber ||
|
||||
(localWidthAsNumber === width && localHeightAsNumber === height);
|
||||
|
||||
const isError =
|
||||
error.width ||
|
||||
error.height ||
|
||||
(localDimension.changed === "width" &&
|
||||
localWidthAsNumber &&
|
||||
isOutsideBounds("width", localWidthAsNumber)); // check width bounds here since 'onChange' error checker is debounced.
|
||||
|
||||
if (isUnchanged || isError) {
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
const maxWidth = boundsRef.current!.width.max;
|
||||
// For images resized to the full width of the editor, natural width will be shown in the toolbar.
|
||||
// So, we constrain it here for computing aspect ratio.
|
||||
const constrainedWidth = Math.min(width, maxWidth);
|
||||
|
||||
const aspectRatio =
|
||||
localDimension.changed === "width"
|
||||
? height / constrainedWidth
|
||||
: constrainedWidth / height;
|
||||
|
||||
const finalWidth =
|
||||
localDimension.changed === "width"
|
||||
? localWidthAsNumber
|
||||
: Math.round(aspectRatio * localHeightAsNumber);
|
||||
const finalHeight =
|
||||
localDimension.changed === "height"
|
||||
? localHeightAsNumber
|
||||
: Math.round(aspectRatio * localWidthAsNumber);
|
||||
|
||||
if (nodeType === "image") {
|
||||
commands["resizeImage"]({
|
||||
width: finalWidth,
|
||||
height: finalHeight,
|
||||
});
|
||||
}
|
||||
}, [commands, width, height, localDimension, nodeType, error, reset]);
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === "Enter") {
|
||||
handleBlur();
|
||||
} else if (e.key === "Escape") {
|
||||
reset();
|
||||
}
|
||||
},
|
||||
[handleBlur, reset]
|
||||
);
|
||||
|
||||
// Sync dimension changes from outside.
|
||||
useEffect(() => {
|
||||
if (
|
||||
width !== Number(localDimension.width) ||
|
||||
height !== Number(localDimension.height)
|
||||
) {
|
||||
reset();
|
||||
}
|
||||
}, [width, height, reset]);
|
||||
|
||||
// hacky debounce for checking error.
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(() => {
|
||||
const isWidthError = localDimension.width
|
||||
? Number(localDimension.width) !== width &&
|
||||
isOutsideBounds("width", Number(localDimension.width))
|
||||
: false;
|
||||
const isHeightError = localDimension.height
|
||||
? Number(localDimension.height) !== height &&
|
||||
isOutsideBounds("height", Number(localDimension.height))
|
||||
: false;
|
||||
|
||||
if (isWidthError || isHeightError) {
|
||||
setError({
|
||||
width: isWidthError,
|
||||
height: isHeightError,
|
||||
});
|
||||
}
|
||||
}, 200);
|
||||
|
||||
return () => clearTimeout(timeout);
|
||||
}, [width, height, localDimension, isOutsideBounds]);
|
||||
|
||||
return (
|
||||
<StyledFlex ref={ref} align="center">
|
||||
<StyledInput
|
||||
value={localDimension.width}
|
||||
onChange={handleChange("width")}
|
||||
onBlur={handleBlur}
|
||||
onKeyDown={handleKeyDown}
|
||||
$error={error.width}
|
||||
/>
|
||||
<Text size="xsmall" type="tertiary">
|
||||
x
|
||||
</Text>
|
||||
<StyledInput
|
||||
value={localDimension.height}
|
||||
onChange={handleChange("height")}
|
||||
onBlur={handleBlur}
|
||||
onKeyDown={handleKeyDown}
|
||||
$error={error.height}
|
||||
/>
|
||||
</StyledFlex>
|
||||
);
|
||||
}
|
||||
|
||||
const StyledFlex = styled(Flex)`
|
||||
pointer-events: all;
|
||||
position: relative;
|
||||
|
||||
${extraArea(4)}
|
||||
`;
|
||||
|
||||
const StyledInput = styled(Input)<{ $error?: boolean }>`
|
||||
width: 50px;
|
||||
z-index: 1;
|
||||
|
||||
${Outline} {
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
${NativeInput} {
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
|
||||
${(props) => props.$error && `color: ${props.theme.danger}`};
|
||||
}
|
||||
`;
|
||||
@@ -221,6 +221,9 @@ export default function SelectionToolbar(props: Props) {
|
||||
if (item.name === "separator") {
|
||||
return true;
|
||||
}
|
||||
if (item.name === "dimensions") {
|
||||
return item.visible ?? false;
|
||||
}
|
||||
if (item.name && !commands[item.name]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import Template from "~/components/ContextMenu/Template";
|
||||
import { TooltipProvider } from "~/components/TooltipContext";
|
||||
import { MenuItem as TMenuItem } from "~/types";
|
||||
import { useEditor } from "./EditorContext";
|
||||
import { MediaDimension } from "./MediaDimension";
|
||||
import ToolbarButton from "./ToolbarButton";
|
||||
import ToolbarSeparator from "./ToolbarSeparator";
|
||||
import Tooltip from "./Tooltip";
|
||||
@@ -98,7 +99,7 @@ function ToolbarMenu(props: Props) {
|
||||
if (item.name === "separator" && item.visible !== false) {
|
||||
return <ToolbarSeparator key={index} />;
|
||||
}
|
||||
if (item.visible === false || !item.icon) {
|
||||
if (item.visible === false || (!item.skipIcon && !item.icon)) {
|
||||
return null;
|
||||
}
|
||||
const isActive = item.active ? item.active(state) : false;
|
||||
@@ -109,7 +110,9 @@ function ToolbarMenu(props: Props) {
|
||||
shortcut={item.shortcut}
|
||||
content={item.label === item.tooltip ? undefined : item.tooltip}
|
||||
>
|
||||
{item.children ? (
|
||||
{item.name === "dimensions" ? (
|
||||
<MediaDimension key={index} />
|
||||
) : item.children ? (
|
||||
<ToolbarDropdown active={isActive && !item.label} item={item} />
|
||||
) : (
|
||||
<ToolbarButton
|
||||
|
||||
@@ -299,7 +299,7 @@ export default class FindAndReplaceExtension extends Extension {
|
||||
|
||||
this.results.push({ from, to, type });
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_err) {
|
||||
// Invalid RegExp
|
||||
}
|
||||
});
|
||||
|
||||
@@ -293,9 +293,11 @@ export default class PasteHandler extends Extension {
|
||||
currentPos += node.nodeSize;
|
||||
});
|
||||
} else {
|
||||
singleNode
|
||||
? tr.replaceSelectionWith(singleNode, this.shiftKey)
|
||||
: tr.replaceSelection(slice);
|
||||
if (singleNode) {
|
||||
tr.replaceSelectionWith(singleNode, this.shiftKey);
|
||||
} else {
|
||||
tr.replaceSelection(slice);
|
||||
}
|
||||
}
|
||||
|
||||
view.dispatch(
|
||||
@@ -550,7 +552,7 @@ function parseSingleIframeSrc(html: string) {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_err) {
|
||||
// Ignore the million ways parsing could fail.
|
||||
}
|
||||
return undefined;
|
||||
|
||||
@@ -513,7 +513,7 @@ export class Editor extends React.PureComponent<
|
||||
},
|
||||
this.elementRef.current || undefined
|
||||
);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
// querySelector will throw an error if the hash begins with a number
|
||||
// or contains a period. This is protected against now by safeSlugify
|
||||
// however previous links may be in the wild.
|
||||
|
||||
@@ -59,6 +59,15 @@ export default function imageMenuItems(
|
||||
{
|
||||
name: "separator",
|
||||
},
|
||||
{
|
||||
name: "dimensions",
|
||||
tooltip: dictionary.dimensions,
|
||||
visible: !isFullWidthAligned(state),
|
||||
skipIcon: true,
|
||||
},
|
||||
{
|
||||
name: "separator",
|
||||
},
|
||||
{
|
||||
name: "downloadImage",
|
||||
tooltip: dictionary.downloadImage,
|
||||
|
||||
@@ -35,6 +35,7 @@ export default function useDictionary() {
|
||||
deleteRow: t("Delete"),
|
||||
deleteTable: t("Delete table"),
|
||||
deleteAttachment: t("Delete file"),
|
||||
dimensions: t("Width x Height"),
|
||||
download: t("Download"),
|
||||
downloadAttachment: t("Download file"),
|
||||
replaceAttachment: t("Replace file"),
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function useEditorClickHandlers({ shareId }: Params) {
|
||||
try {
|
||||
const url = new URL(href);
|
||||
navigateTo = url.pathname + url.hash;
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
navigateTo = href;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export function setPostLoginPath(path: string) {
|
||||
|
||||
try {
|
||||
sessionStorage.setItem(key, path);
|
||||
} catch (e) {
|
||||
} catch (_err) {
|
||||
// If the session storage is full or inaccessible, we can't do anything about it.
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export function usePostLoginPath() {
|
||||
let path;
|
||||
try {
|
||||
path = sessionStorage.getItem(key) || getCookie(key);
|
||||
} catch (e) {
|
||||
} catch (_err) {
|
||||
// Expected error if the session storage is full or inaccessible.
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ export function usePostLoginPath() {
|
||||
const cleanup = history.listen(() => {
|
||||
try {
|
||||
sessionStorage.removeItem(key);
|
||||
} catch (e) {
|
||||
} catch (_err) {
|
||||
// Expected error if the session storage is full or inaccessible.
|
||||
}
|
||||
removeCookie(key);
|
||||
|
||||
@@ -60,6 +60,10 @@ class Share extends Model implements Searchable {
|
||||
@observable
|
||||
allowIndexing: boolean;
|
||||
|
||||
@Field
|
||||
@observable
|
||||
showLastUpdated: boolean;
|
||||
|
||||
@observable
|
||||
views: number;
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@ class Team extends Model {
|
||||
@observable
|
||||
name: string;
|
||||
|
||||
@Field
|
||||
@observable
|
||||
description: string | null;
|
||||
|
||||
@Field
|
||||
@observable
|
||||
avatarUrl: string;
|
||||
|
||||
@@ -165,7 +165,7 @@ function CommentThreadItem({
|
||||
setReadOnly();
|
||||
comment.data = data;
|
||||
await comment.save();
|
||||
} catch (error) {
|
||||
} catch (_err) {
|
||||
setEditing();
|
||||
toast.error(t("Error updating comment"));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { mergeRefs } from "react-merge-refs";
|
||||
import { useHistory, useRouteMatch } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import Text from "@shared/components/Text";
|
||||
import { richExtensions, withComments } from "@shared/editor/nodes";
|
||||
import { TeamPreference } from "@shared/types";
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
@@ -13,6 +15,7 @@ import { RefHandle } from "~/components/ContentEditable";
|
||||
import { useDocumentContext } from "~/components/DocumentContext";
|
||||
import Editor, { Props as EditorProps } from "~/components/Editor";
|
||||
import Flex from "~/components/Flex";
|
||||
import Time from "~/components/Time";
|
||||
import { withUIExtensions } from "~/editor/extensions";
|
||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
@@ -229,16 +232,26 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
|
||||
onBlur={handleBlur}
|
||||
placeholder={t("Untitled")}
|
||||
/>
|
||||
{!shareId && (
|
||||
{shareId ? (
|
||||
document.updatedAt ? (
|
||||
<SharedMeta type="tertiary">
|
||||
{t("Last updated")} <Time dateTime={document.updatedAt} addSuffix />
|
||||
</SharedMeta>
|
||||
) : null
|
||||
) : (
|
||||
<DocumentMeta
|
||||
document={document}
|
||||
to={{
|
||||
pathname:
|
||||
match.path === matchDocumentHistory
|
||||
? documentPath(document)
|
||||
: documentHistoryPath(document),
|
||||
state: { sidebarContext },
|
||||
}}
|
||||
to={
|
||||
shareId
|
||||
? undefined
|
||||
: {
|
||||
pathname:
|
||||
match.path === matchDocumentHistory
|
||||
? documentPath(document)
|
||||
: documentHistoryPath(document),
|
||||
state: { sidebarContext },
|
||||
}
|
||||
}
|
||||
rtl={direction === "rtl"}
|
||||
/>
|
||||
)}
|
||||
@@ -274,4 +287,9 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
|
||||
);
|
||||
}
|
||||
|
||||
const SharedMeta = styled(Text)`
|
||||
margin: -12px 0 2em 0;
|
||||
font-size: 14px;
|
||||
`;
|
||||
|
||||
export default observer(React.forwardRef(DocumentEditor));
|
||||
@@ -21,7 +21,9 @@ function MarkAsViewed(props: Props) {
|
||||
}, MARK_AS_VIEWED_AFTER);
|
||||
|
||||
return () => {
|
||||
viewTimeout.current && clearTimeout(viewTimeout.current);
|
||||
if (viewTimeout.current) {
|
||||
clearTimeout(viewTimeout.current);
|
||||
}
|
||||
};
|
||||
}, [document]);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ function DocumentMove({ document }: Props) {
|
||||
toast.success(t("Document moved"));
|
||||
|
||||
dialogs.closeAllModals();
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Couldn’t move the document, try again?"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ function DocumentNew({ template }: Props) {
|
||||
: documentEditPath(document),
|
||||
location.state
|
||||
);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Couldn’t create the document, try again?"));
|
||||
history.goBack();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ function DocumentPublish({ document }: Props) {
|
||||
toast.success(t("Document published"));
|
||||
|
||||
dialogs.closeAllModals();
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Couldn’t publish the document, try again?"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,6 +38,7 @@ import { BackButton } from "./components/BackButton";
|
||||
import { Background } from "./components/Background";
|
||||
import { Centered } from "./components/Centered";
|
||||
import { Notices } from "./components/Notices";
|
||||
import WorkspaceSetup from "./components/WorkspaceSetup";
|
||||
import { getRedirectUrl, navigateToSubdomain } from "./urls";
|
||||
|
||||
type Props = {
|
||||
@@ -191,12 +192,18 @@ function Login({ children, onBack }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
const firstRun =
|
||||
config.providers.length === 0 && !isCloudHosted && !config.name;
|
||||
const hasMultipleProviders = config.providers.length > 1;
|
||||
const defaultProvider = find(
|
||||
config.providers,
|
||||
(provider) => provider.id === auth.lastSignedIn && !isCreate
|
||||
);
|
||||
|
||||
if (firstRun) {
|
||||
return <WorkspaceSetup onBack={onBack} />;
|
||||
}
|
||||
|
||||
if (emailLinkSentTo) {
|
||||
return (
|
||||
<Background>
|
||||
|
||||
@@ -93,7 +93,9 @@ function Authorize() {
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
timeoutRef.current && window.clearTimeout(timeoutRef.current);
|
||||
if (timeoutRef.current) {
|
||||
window.clearTimeout(timeoutRef.current);
|
||||
}
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { s } from "@shared/styles";
|
||||
import ButtonLarge from "~/components/ButtonLarge";
|
||||
import ChangeLanguage from "~/components/ChangeLanguage";
|
||||
import Flex from "~/components/Flex";
|
||||
import Heading from "~/components/Heading";
|
||||
import Input from "~/components/Input";
|
||||
import Text from "~/components/Text";
|
||||
import { detectLanguage } from "~/utils/language";
|
||||
import { BackButton } from "./BackButton";
|
||||
import { Background } from "./Background";
|
||||
import { Centered } from "./Centered";
|
||||
|
||||
const WorkspaceSetup = ({ onBack }: { onBack?: () => void }) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Background>
|
||||
<BackButton onBack={onBack} />
|
||||
<ChangeLanguage locale={detectLanguage()} />
|
||||
<Centered
|
||||
as="form"
|
||||
action="/api/installation.create"
|
||||
method="POST"
|
||||
gap={12}
|
||||
>
|
||||
<StyledHeading centered>{t("Create workspace")}</StyledHeading>
|
||||
<Content>
|
||||
{t(
|
||||
"Setup your workspace by providing a name and details for admin login. You can change these later."
|
||||
)}
|
||||
</Content>
|
||||
<Flex column gap={12} style={{ width: "100%" }}>
|
||||
<Input
|
||||
name="teamName"
|
||||
type="text"
|
||||
label={t("Workspace name")}
|
||||
placeholder="Acme, Inc"
|
||||
required
|
||||
autoFocus
|
||||
flex
|
||||
/>
|
||||
<Input
|
||||
name="userName"
|
||||
type="text"
|
||||
label={t("Admin name")}
|
||||
required
|
||||
flex
|
||||
/>
|
||||
<Input
|
||||
name="userEmail"
|
||||
type="email"
|
||||
label={t("Admin email")}
|
||||
required
|
||||
flex
|
||||
/>
|
||||
</Flex>
|
||||
<ButtonLarge type="submit" fullwidth>
|
||||
{t("Continue")} →
|
||||
</ButtonLarge>
|
||||
</Centered>
|
||||
</Background>
|
||||
);
|
||||
};
|
||||
|
||||
const StyledHeading = styled(Heading)`
|
||||
margin: 0;
|
||||
`;
|
||||
|
||||
const Content = styled(Text)`
|
||||
color: ${s("textSecondary")};
|
||||
text-align: center;
|
||||
margin-top: -8px;
|
||||
`;
|
||||
|
||||
export default WorkspaceSetup;
|
||||
@@ -44,6 +44,7 @@ function Details() {
|
||||
team.preferences?.customTheme?.accentText
|
||||
);
|
||||
const [name, setName] = useState(team.name);
|
||||
const [description, setDescription] = useState(team.description || "");
|
||||
const [subdomain, setSubdomain] = useState(team.subdomain);
|
||||
const [publicBranding, setPublicBranding] = useState(
|
||||
team.preferences?.publicBranding
|
||||
@@ -94,6 +95,7 @@ function Details() {
|
||||
try {
|
||||
await team.save({
|
||||
name,
|
||||
description,
|
||||
subdomain,
|
||||
defaultCollectionId,
|
||||
preferences: {
|
||||
@@ -112,6 +114,7 @@ function Details() {
|
||||
tocPosition,
|
||||
team,
|
||||
name,
|
||||
description,
|
||||
subdomain,
|
||||
defaultCollectionId,
|
||||
publicBranding,
|
||||
@@ -210,6 +213,19 @@ function Details() {
|
||||
required
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
label={t("Description")}
|
||||
name="description"
|
||||
description={t("A short description of your workspace.")}
|
||||
>
|
||||
<Input
|
||||
id="description"
|
||||
value={description}
|
||||
onChange={(ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setDescription(ev.target.value);
|
||||
}}
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
label={t("Theme")}
|
||||
name="accent"
|
||||
@@ -246,12 +262,12 @@ function Details() {
|
||||
flex
|
||||
/>
|
||||
</SettingRow>
|
||||
{team.avatarUrl && (
|
||||
{(team.avatarUrl || team.description) && (
|
||||
<SettingRow
|
||||
name={TeamPreference.PublicBranding}
|
||||
label={t("Public branding")}
|
||||
description={t(
|
||||
"Show your team’s logo on public pages like login and shared documents."
|
||||
"Show your workspace logo, description, and branding on publicly shared pages."
|
||||
)}
|
||||
>
|
||||
<Switch
|
||||
|
||||
@@ -160,8 +160,8 @@ function DropToImport({ disabled, onSubmit, children, format }: Props) {
|
||||
</Text>
|
||||
</div>
|
||||
<Flex justify="flex-end">
|
||||
<Button disabled={!file} onClick={handleStartImport}>
|
||||
{t("Start import")}
|
||||
<Button disabled={!file || isImporting} onClick={handleStartImport}>
|
||||
{isImporting ? t("Uploading") + "…" : t("Start import")}
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -216,7 +216,7 @@ export const ViewGroupMembersDialog = observer(function ({
|
||||
icon: <Avatar model={user} size={AvatarSize.Toast} />,
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Could not remove user"));
|
||||
}
|
||||
},
|
||||
@@ -326,7 +326,7 @@ const AddPeopleToGroupDialog = observer(function ({
|
||||
icon: <Avatar model={user} size={AvatarSize.Toast} />,
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
toast.error(t("Could not add user"));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,42 +1,34 @@
|
||||
import * as Collapsible from "@radix-ui/react-collapsible";
|
||||
import { QuestionMarkIcon } from "outline-icons";
|
||||
import * as React from "react";
|
||||
import {
|
||||
useDisclosureState,
|
||||
Disclosure,
|
||||
DisclosureContent,
|
||||
} from "reakit/Disclosure";
|
||||
import styled, { useTheme } from "styled-components";
|
||||
import Button from "~/components/Button";
|
||||
import Text from "~/components/Text";
|
||||
|
||||
type Props = {
|
||||
children?: React.ReactNode;
|
||||
title: React.ReactNode;
|
||||
title: string;
|
||||
};
|
||||
|
||||
const HelpDisclosure: React.FC<Props> = ({ title, children }: Props) => {
|
||||
const disclosure = useDisclosureState({ animated: true });
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Disclosure {...disclosure}>
|
||||
{(props) => (
|
||||
<StyledButton
|
||||
icon={<QuestionMarkIcon color={theme.textSecondary} />}
|
||||
neutral
|
||||
aria-label={title}
|
||||
borderOnHover
|
||||
{...props}
|
||||
/>
|
||||
)}
|
||||
</Disclosure>
|
||||
<HelpContent {...disclosure}>
|
||||
<Collapsible.Root>
|
||||
<Collapsible.Trigger asChild>
|
||||
<StyledButton
|
||||
icon={<QuestionMarkIcon color={theme.textSecondary} />}
|
||||
neutral
|
||||
aria-label={title}
|
||||
borderOnHover
|
||||
/>
|
||||
</Collapsible.Trigger>
|
||||
<HelpContent>
|
||||
<Text as="p" type="secondary">
|
||||
{children}
|
||||
</Text>
|
||||
</HelpContent>
|
||||
</>
|
||||
</Collapsible.Root>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -46,12 +38,37 @@ const StyledButton = styled(Button)`
|
||||
right: 50px;
|
||||
`;
|
||||
|
||||
const HelpContent = styled(DisclosureContent)`
|
||||
transition: opacity 250ms ease-in-out;
|
||||
opacity: 0;
|
||||
const HelpContent = styled(Collapsible.Content)`
|
||||
overflow: hidden;
|
||||
|
||||
&[data-enter] {
|
||||
opacity: 1;
|
||||
&[data-state="open"] {
|
||||
animation: slideDown 250ms ease-out;
|
||||
}
|
||||
|
||||
&[data-state="closed"] {
|
||||
animation: slideUp 250ms ease-out;
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
height: var(--radix-collapsible-content-height);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
height: var(--radix-collapsible-content-height);
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Trans } from "react-i18next";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { FileOperationFormat } from "@shared/types";
|
||||
import env from "~/env";
|
||||
import useStores from "~/hooks/useStores";
|
||||
@@ -6,12 +6,13 @@ import DropToImport from "./DropToImport";
|
||||
import HelpDisclosure from "./HelpDisclosure";
|
||||
|
||||
function ImportJSONDialog() {
|
||||
const { t } = useTranslation();
|
||||
const { dialogs } = useStores();
|
||||
const appName = env.APP_NAME;
|
||||
|
||||
return (
|
||||
<>
|
||||
<HelpDisclosure title={<Trans>How does this work?</Trans>}>
|
||||
<HelpDisclosure title={t("How does this work?")}>
|
||||
<Trans
|
||||
defaults="You can import a zip file that was previously exported from the JSON option in another instance. In {{ appName }}, open <em>Export</em> in the Settings sidebar and click on <em>Export Data</em>."
|
||||
values={{ appName }}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Trans } from "react-i18next";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import { FileOperationFormat } from "@shared/types";
|
||||
import env from "~/env";
|
||||
import useStores from "~/hooks/useStores";
|
||||
@@ -6,12 +6,13 @@ import DropToImport from "./DropToImport";
|
||||
import HelpDisclosure from "./HelpDisclosure";
|
||||
|
||||
function ImportMarkdownDialog() {
|
||||
const { t } = useTranslation();
|
||||
const { dialogs } = useStores();
|
||||
const appName = env.APP_NAME;
|
||||
|
||||
return (
|
||||
<>
|
||||
<HelpDisclosure title={<Trans>How does this work?</Trans>}>
|
||||
<HelpDisclosure title={t("How does this work?")}>
|
||||
<Trans
|
||||
defaults="You can import a zip file that was previously exported from an Outline installation – collections, documents, and images will be imported. In Outline, open <em>Export</em> in the Settings sidebar and click on <em>Export Data</em>."
|
||||
components={{
|
||||
|
||||
@@ -99,15 +99,17 @@ export default class GroupMembershipsStore extends Store<GroupMembership> {
|
||||
documentId?: string;
|
||||
groupId: string;
|
||||
}) {
|
||||
collectionId
|
||||
? await client.post("/collections.remove_group", {
|
||||
id: collectionId,
|
||||
groupId,
|
||||
})
|
||||
: await client.post("/documents.remove_group", {
|
||||
id: documentId,
|
||||
groupId,
|
||||
});
|
||||
if (collectionId) {
|
||||
await client.post("/collections.remove_group", {
|
||||
id: collectionId,
|
||||
groupId,
|
||||
});
|
||||
} else {
|
||||
await client.post("/documents.remove_group", {
|
||||
id: documentId,
|
||||
groupId,
|
||||
});
|
||||
}
|
||||
|
||||
this.removeAll(
|
||||
collectionId
|
||||
|
||||
@@ -84,9 +84,7 @@ export default class NotificationsStore extends Store<Notification> {
|
||||
get orderedData(): Notification[] {
|
||||
return sortBy(
|
||||
orderBy(Array.from(this.data.values()), "createdAt", "desc"),
|
||||
(item) => {
|
||||
item.viewedAt ? 1 : -1;
|
||||
}
|
||||
(item) => (item.viewedAt ? 1 : -1)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -129,8 +129,10 @@ export default class RootStore {
|
||||
Object.getOwnPropertyNames(this)
|
||||
.filter((key) => ["auth", "ui"].includes(key) === false)
|
||||
.forEach((key: keyof RootStore) => {
|
||||
// @ts-expect-error clear exists on all stores
|
||||
"clear" in this[key] && this[key].clear();
|
||||
if ("clear" in this[key]) {
|
||||
// @ts-expect-error clear exists on all stores
|
||||
this[key].clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import { Location, LocationDescriptor } from "history";
|
||||
import { TFunction } from "i18next";
|
||||
import {
|
||||
@@ -177,10 +176,10 @@ export type WebsocketEntityDeletedEvent = {
|
||||
};
|
||||
|
||||
export type WebsocketEntitiesEvent = {
|
||||
fetchIfMissing?: boolean;
|
||||
documentIds: { id: string; updatedAt?: string }[];
|
||||
collectionIds: { id: string; updatedAt?: string }[];
|
||||
groupIds: { id: string; updatedAt?: string }[];
|
||||
invalidatedPolicies: string[];
|
||||
teamIds: string[];
|
||||
event: string;
|
||||
};
|
||||
|
||||
@@ -127,7 +127,7 @@ class ApiClient {
|
||||
cache: "no-cache",
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
if (window.navigator.onLine) {
|
||||
throw new NetworkError("A network error occurred, try again?");
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
||||
// download.js v3.0, by dandavis; 2008-2014. [CCBY2] see http://danml.com/download.html for tests/usage
|
||||
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
|
||||
// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
|
||||
@@ -53,7 +54,7 @@ export default function download(
|
||||
: new B([x], {
|
||||
type: m,
|
||||
});
|
||||
} catch (y) {
|
||||
} catch (_err) {
|
||||
if (BB) {
|
||||
b = new BB();
|
||||
b.append([x]);
|
||||
@@ -112,7 +113,7 @@ export default function download(
|
||||
) {
|
||||
try {
|
||||
return saver("data:" + m + ";base64," + self.btoa(blob));
|
||||
} catch (y) {
|
||||
} catch (_err) {
|
||||
return saver("data:" + m + "," + encodeURIComponent(blob));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import Desktop from "./Desktop";
|
||||
export function formatNumber(number: number, locale: string) {
|
||||
try {
|
||||
return new Intl.NumberFormat(locale).format(number);
|
||||
} catch (e) {
|
||||
} catch (_err) {
|
||||
return number.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ export function isHash(href: string) {
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_err) {
|
||||
// failed to parse as url
|
||||
}
|
||||
|
||||
|
||||
+16
-13
@@ -49,21 +49,21 @@
|
||||
"> 0.25%, not dead"
|
||||
],
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "3.817.0",
|
||||
"@aws-sdk/lib-storage": "3.817.0",
|
||||
"@aws-sdk/s3-presigned-post": "3.817.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.817.0",
|
||||
"@aws-sdk/signature-v4-crt": "^3.816.0",
|
||||
"@babel/core": "^7.27.1",
|
||||
"@aws-sdk/client-s3": "3.821.0",
|
||||
"@aws-sdk/lib-storage": "3.821.0",
|
||||
"@aws-sdk/s3-presigned-post": "3.821.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.821.0",
|
||||
"@aws-sdk/signature-v4-crt": "^3.821.0",
|
||||
"@babel/core": "^7.27.4",
|
||||
"@babel/plugin-proposal-decorators": "^7.27.1",
|
||||
"@babel/plugin-transform-class-properties": "^7.27.1",
|
||||
"@babel/plugin-transform-destructuring": "^7.27.1",
|
||||
"@babel/plugin-transform-regenerator": "^7.27.1",
|
||||
"@babel/plugin-transform-destructuring": "^7.27.3",
|
||||
"@babel/plugin-transform-regenerator": "^7.27.4",
|
||||
"@babel/preset-env": "^7.27.2",
|
||||
"@babel/preset-react": "^7.27.1",
|
||||
"@benrbray/prosemirror-math": "^0.2.2",
|
||||
"@bull-board/api": "^6.7.10",
|
||||
"@bull-board/koa": "^6.7.10",
|
||||
"@bull-board/koa": "^6.9.6",
|
||||
"@css-inline/css-inline-wasm": "^0.14.3",
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/modifiers": "^6.0.1",
|
||||
@@ -86,7 +86,10 @@
|
||||
"@octokit/auth-app": "^6.1.3",
|
||||
"@outlinewiki/koa-passport": "^4.2.1",
|
||||
"@outlinewiki/passport-azure-ad-oauth2": "^0.1.0",
|
||||
"@radix-ui/react-collapsible": "^1.1.11",
|
||||
"@radix-ui/react-popover": "^1.1.14",
|
||||
"@radix-ui/react-select": "^2.1.4",
|
||||
"@radix-ui/react-switch": "^1.2.5",
|
||||
"@radix-ui/react-tooltip": "^1.2.7",
|
||||
"@radix-ui/react-visually-hidden": "^1.2.2",
|
||||
"@renderlesskit/react": "^0.11.0",
|
||||
@@ -227,7 +230,7 @@
|
||||
"scroll-into-view-if-needed": "^3.1.0",
|
||||
"semver": "^7.7.2",
|
||||
"sequelize": "^6.37.3",
|
||||
"sequelize-cli": "^6.6.2",
|
||||
"sequelize-cli": "^6.6.3",
|
||||
"sequelize-encrypted": "^1.0.0",
|
||||
"sequelize-strict-attributes": "^1.0.2",
|
||||
"sequelize-typescript": "^2.1.6",
|
||||
@@ -332,8 +335,8 @@
|
||||
"@types/utf8": "^3.0.3",
|
||||
"@types/validator": "^13.15.0",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.33.0",
|
||||
"@typescript-eslint/parser": "^8.33.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^29.7.0",
|
||||
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
||||
@@ -365,7 +368,7 @@
|
||||
"react-refresh": "^0.17.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"rollup-plugin-webpack-stats": "^2.0.5",
|
||||
"terser": "^5.39.0",
|
||||
"terser": "^5.40.0",
|
||||
"typescript": "^5.8.3",
|
||||
"vite-plugin-static-copy": "^0.17.0",
|
||||
"yarn-deduplicate": "^6.0.2"
|
||||
|
||||
@@ -103,7 +103,7 @@ const emailCallback = async (ctx: APIContext<T.EmailCallbackReq>) => {
|
||||
|
||||
try {
|
||||
user = await getUserForEmailSigninToken(token as string);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
ctx.redirect(`/?notice=expired-token`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export function ImportDialog({ integrationId, onSubmit }: Props) {
|
||||
</div>
|
||||
<Flex justify="flex-end">
|
||||
<Button onClick={handleStartImport} disabled={submitting}>
|
||||
{t("Start import")}
|
||||
{submitting ? t("Uploading") + "…" : t("Start import")}
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -148,7 +148,7 @@ if (env.SLACK_CLIENT_ID && env.SLACK_CLIENT_SECRET) {
|
||||
parsedState = SlackUtils.parseState<{
|
||||
collectionId: string;
|
||||
}>(state);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
throw ValidationError("Invalid state");
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ function getKeyFromContext(ctx: APIContext<T.FilesGetReq>): string {
|
||||
|
||||
try {
|
||||
JWT.verify(sig, env.SECRET_KEY);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
throw AuthenticationError("Invalid signature");
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ async function accountProvisioner({
|
||||
// The account could not be provisioned for the provided teamId
|
||||
// check to see if we can try authentication using email matching only
|
||||
if (err.id === "invalid_authentication") {
|
||||
const authenticationProvider = await AuthenticationProvider.findOne({
|
||||
const authProvider = await AuthenticationProvider.findOne({
|
||||
where: {
|
||||
name: authenticationProviderParams.name,
|
||||
teamId: teamParams.teamId,
|
||||
@@ -116,11 +116,11 @@ async function accountProvisioner({
|
||||
order: [["enabled", "DESC"]],
|
||||
});
|
||||
|
||||
if (authenticationProvider) {
|
||||
if (authProvider) {
|
||||
emailMatchOnly = true;
|
||||
result = {
|
||||
authenticationProvider,
|
||||
team: authenticationProvider.team,
|
||||
authenticationProvider: authProvider,
|
||||
team: authProvider.team,
|
||||
isNewTeam: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export default async function documentDuplicator({
|
||||
|
||||
async function duplicateChildDocuments(
|
||||
original: Document,
|
||||
duplicated: Document
|
||||
duplicatedDocument: Document
|
||||
) {
|
||||
const childDocuments = await original.findChildDocuments(
|
||||
{
|
||||
@@ -77,7 +77,7 @@ export default async function documentDuplicator({
|
||||
|
||||
for (const childDocument of childDocuments) {
|
||||
const duplicatedChildDocument = await documentCreator({
|
||||
parentDocumentId: duplicated.id,
|
||||
parentDocumentId: duplicatedDocument.id,
|
||||
icon: childDocument.icon,
|
||||
color: childDocument.color,
|
||||
title: childDocument.title,
|
||||
|
||||
@@ -194,9 +194,13 @@ export default async function loadDocument({
|
||||
|
||||
if (document.deletedAt) {
|
||||
// don't send data if user cannot restore deleted doc
|
||||
user && authorize(user, "restore", document);
|
||||
if (user) {
|
||||
authorize(user, "restore", document);
|
||||
}
|
||||
} else {
|
||||
user && authorize(user, "read", document);
|
||||
if (user) {
|
||||
authorize(user, "read", document);
|
||||
}
|
||||
}
|
||||
|
||||
if (document.isTrialImport) {
|
||||
|
||||
@@ -193,11 +193,11 @@ async function documentMover({
|
||||
|
||||
document.collection = newCollection;
|
||||
result.documents.push(
|
||||
...documents.map((document) => {
|
||||
...documents.map((doc) => {
|
||||
if (newCollection) {
|
||||
document.collection = newCollection;
|
||||
doc.collection = newCollection;
|
||||
}
|
||||
return document;
|
||||
return doc;
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -110,14 +110,14 @@ describe("teamProvisioner", () => {
|
||||
|
||||
let error;
|
||||
try {
|
||||
const subdomain = faker.internet.domainWord();
|
||||
const testSubdomain = faker.internet.domainWord();
|
||||
await teamProvisioner({
|
||||
teamId: exampleTeam.id,
|
||||
name: "name",
|
||||
subdomain,
|
||||
subdomain: testSubdomain,
|
||||
authenticationProvider: {
|
||||
name: "google",
|
||||
providerId: `${subdomain}.com`,
|
||||
providerId: `${testSubdomain}.com`,
|
||||
},
|
||||
ip,
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ async function teamProvisioner({
|
||||
}
|
||||
|
||||
// This team + auth provider combination has not been seen before in self hosted
|
||||
const team = await Team.findByPk(teamId, {
|
||||
const existingTeam = await Team.findByPk(teamId, {
|
||||
rejectOnEmpty: true,
|
||||
});
|
||||
|
||||
@@ -91,14 +91,14 @@ async function teamProvisioner({
|
||||
// new team is allowed then assign the authentication provider to the
|
||||
// existing team
|
||||
if (domain) {
|
||||
if (await team.isDomainAllowed(domain)) {
|
||||
authP = await team.$create<AuthenticationProvider>(
|
||||
if (await existingTeam.isDomainAllowed(domain)) {
|
||||
authP = await existingTeam.$create<AuthenticationProvider>(
|
||||
"authenticationProvider",
|
||||
authenticationProvider
|
||||
);
|
||||
return {
|
||||
authenticationProvider: authP,
|
||||
team,
|
||||
team: existingTeam,
|
||||
isNewTeam: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,7 +46,9 @@ export default async function userInviter({
|
||||
email: emails,
|
||||
},
|
||||
});
|
||||
const existingEmails = existingUsers.map((user) => user.email);
|
||||
const existingEmails = existingUsers.map(
|
||||
(existingUser) => existingUser.email
|
||||
);
|
||||
const filteredInvites = normalizedInvites.filter(
|
||||
(invite) => !existingEmails.includes(invite.email)
|
||||
);
|
||||
|
||||
@@ -136,7 +136,7 @@ export default async function userProvisioner({
|
||||
// that's never been active before.
|
||||
const isInvite = existingUser.isInvited;
|
||||
|
||||
const auth = await sequelize.transaction(async (transaction) => {
|
||||
const userAuth = await sequelize.transaction(async (transaction) => {
|
||||
if (isInvite) {
|
||||
await Event.create(
|
||||
{
|
||||
@@ -198,7 +198,7 @@ export default async function userProvisioner({
|
||||
|
||||
return {
|
||||
user: existingUser,
|
||||
authentication: auth,
|
||||
authentication: userAuth,
|
||||
isNewUser: isInvite,
|
||||
};
|
||||
} else if (!authentication && !team?.allowedDomains.length) {
|
||||
|
||||
@@ -246,7 +246,7 @@ export class Mailer {
|
||||
pass: testAccount.pass,
|
||||
},
|
||||
};
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface EmailProps {
|
||||
|
||||
export default abstract class BaseEmail<
|
||||
T extends EmailProps,
|
||||
S extends Record<string, any> | void = void
|
||||
S extends Record<string, unknown> | void = void
|
||||
> {
|
||||
private props: T;
|
||||
private metadata?: NotificationMetadata;
|
||||
|
||||
@@ -21,7 +21,7 @@ type Props = EmailProps & {
|
||||
/**
|
||||
* Email sent to an external user when an admin sends them an invite.
|
||||
*/
|
||||
export default class InviteEmail extends BaseEmail<Props, Record<string, any>> {
|
||||
export default class InviteEmail extends BaseEmail<Props, void> {
|
||||
protected get category() {
|
||||
return EmailMessageCategory.Invitation;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ type Props = EmailProps & {
|
||||
/**
|
||||
* Email sent to a user when they request a magic sign-in link.
|
||||
*/
|
||||
export default class SigninEmail extends BaseEmail<Props, Record<string, any>> {
|
||||
export default class SigninEmail extends BaseEmail<Props, void> {
|
||||
protected get category() {
|
||||
return EmailMessageCategory.Authentication;
|
||||
}
|
||||
|
||||
+52
-3
@@ -16,7 +16,11 @@ import {
|
||||
import uniq from "lodash/uniq";
|
||||
import { languages } from "@shared/i18n";
|
||||
import { Day, Hour } from "@shared/utils/time";
|
||||
import { CannotUseWith, CannotUseWithout } from "@server/utils/validators";
|
||||
import {
|
||||
CannotUseWith,
|
||||
CannotUseWithout,
|
||||
CannotUseWithAny,
|
||||
} from "@server/utils/validators";
|
||||
import Deprecated from "./models/decorators/Deprecated";
|
||||
import { getArg } from "./utils/args";
|
||||
import { Public, PublicEnvironmentRegister } from "./utils/decorators/Public";
|
||||
@@ -79,8 +83,53 @@ export class Environment {
|
||||
allow_underscores: true,
|
||||
protocols: ["postgres", "postgresql"],
|
||||
})
|
||||
@CannotUseWithAny([
|
||||
"DATABASE_HOST",
|
||||
"DATABASE_PORT",
|
||||
"DATABASE_NAME",
|
||||
"DATABASE_USER",
|
||||
"DATABASE_PASSWORD",
|
||||
])
|
||||
public DATABASE_URL = environment.DATABASE_URL ?? "";
|
||||
|
||||
/**
|
||||
* Database host for individual component configuration.
|
||||
*/
|
||||
@IsOptional()
|
||||
@CannotUseWith("DATABASE_URL")
|
||||
public DATABASE_HOST = this.toOptionalString(environment.DATABASE_HOST);
|
||||
|
||||
/**
|
||||
* Database port for individual component configuration.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@CannotUseWith("DATABASE_URL")
|
||||
public DATABASE_PORT = this.toOptionalNumber(environment.DATABASE_PORT);
|
||||
|
||||
/**
|
||||
* Database name for individual component configuration.
|
||||
*/
|
||||
@IsOptional()
|
||||
@CannotUseWith("DATABASE_URL")
|
||||
public DATABASE_NAME = this.toOptionalString(environment.DATABASE_NAME);
|
||||
|
||||
/**
|
||||
* Database user for individual component configuration.
|
||||
*/
|
||||
@IsOptional()
|
||||
@CannotUseWith("DATABASE_URL")
|
||||
public DATABASE_USER = this.toOptionalString(environment.DATABASE_USER);
|
||||
|
||||
/**
|
||||
* Database password for individual component configuration.
|
||||
*/
|
||||
@IsOptional()
|
||||
@CannotUseWith("DATABASE_URL")
|
||||
public DATABASE_PASSWORD = this.toOptionalString(
|
||||
environment.DATABASE_PASSWORD
|
||||
);
|
||||
|
||||
/**
|
||||
* An optional database schema.
|
||||
*/
|
||||
@@ -709,7 +758,7 @@ export class Environment {
|
||||
protected toBoolean(value: string) {
|
||||
try {
|
||||
return value ? !!JSON.parse(value) : false;
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
throw new Error(
|
||||
`"${value}" could not be parsed as a boolean, must be "true" or "false"`
|
||||
);
|
||||
@@ -731,7 +780,7 @@ export class Environment {
|
||||
protected toOptionalBoolean(value: string | undefined) {
|
||||
try {
|
||||
return value ? !!JSON.parse(value) : undefined;
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ type LogCategory =
|
||||
| "database"
|
||||
| "utils"
|
||||
| "plugins";
|
||||
|
||||
type Extra = Record<string, any>;
|
||||
|
||||
class Logger {
|
||||
|
||||
@@ -79,7 +79,7 @@ export default function auth(options: AuthenticationOptions = {}) {
|
||||
authentication = await OAuthAuthentication.findByAccessToken(token, {
|
||||
rejectOnEmpty: true,
|
||||
});
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
throw AuthenticationError("Invalid access token");
|
||||
}
|
||||
if (!authentication) {
|
||||
@@ -114,7 +114,7 @@ export default function auth(options: AuthenticationOptions = {}) {
|
||||
|
||||
try {
|
||||
apiKey = await ApiKey.findByToken(token);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
throw AuthenticationError("Invalid API key");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.addColumn('teams', 'description', {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
});
|
||||
},
|
||||
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.removeColumn('teams', 'description');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn("shares", "showLastUpdated", {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.removeColumn("shares", "showLastUpdated");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -114,6 +114,14 @@ class Share extends IdModel<
|
||||
@Column
|
||||
domain: string | null;
|
||||
|
||||
@Default(true)
|
||||
@Column
|
||||
allowIndexing: boolean;
|
||||
|
||||
@Default(false)
|
||||
@Column
|
||||
showLastUpdated: boolean;
|
||||
|
||||
// hooks
|
||||
|
||||
@BeforeUpdate
|
||||
@@ -185,10 +193,6 @@ class Share extends IdModel<
|
||||
@Column(DataType.UUID)
|
||||
documentId: string;
|
||||
|
||||
@Default(true)
|
||||
@Column
|
||||
allowIndexing: boolean;
|
||||
|
||||
revoke(ctx: APIContext) {
|
||||
const { user } = ctx.context.auth;
|
||||
this.revokedAt = new Date();
|
||||
|
||||
@@ -79,6 +79,14 @@ class Team extends ParanoidModel<
|
||||
@Column
|
||||
name: string;
|
||||
|
||||
@AllowNull
|
||||
@Length({
|
||||
max: TeamValidation.maxDescriptionLength,
|
||||
msg: `Team description must be ${TeamValidation.maxDescriptionLength} characters or less`,
|
||||
})
|
||||
@Column(DataType.TEXT)
|
||||
description: string | null;
|
||||
|
||||
@IsLowercase
|
||||
@Unique
|
||||
@Length({
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import { AllowNull, Column, IsDate } from "sequelize-typescript";
|
||||
import ParanoidModel from "./ParanoidModel";
|
||||
|
||||
class ArchivableModel<
|
||||
TModelAttributes extends {} = any,
|
||||
TCreationAttributes extends {} = TModelAttributes
|
||||
TModelAttributes extends object = any,
|
||||
TCreationAttributes extends object = TModelAttributes
|
||||
> extends ParanoidModel<TModelAttributes, TCreationAttributes> {
|
||||
/** Whether the document is archived, and if so when. */
|
||||
@AllowNull
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import {
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
@@ -11,8 +10,8 @@ import {
|
||||
import Model from "./Model";
|
||||
|
||||
class IdModel<
|
||||
TModelAttributes extends {} = any,
|
||||
TCreationAttributes extends {} = TModelAttributes
|
||||
TModelAttributes extends object = any,
|
||||
TCreationAttributes extends object = TModelAttributes
|
||||
> extends Model<TModelAttributes, TCreationAttributes> {
|
||||
@IsUUID(4)
|
||||
@PrimaryKey
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import isEqual from "fast-deep-equal";
|
||||
import isArray from "lodash/isArray";
|
||||
import isObject from "lodash/isObject";
|
||||
@@ -43,8 +42,8 @@ type EventOptions = EventOverrideOptions & {
|
||||
export type HookContext = APIContext["context"] & { event?: EventOptions };
|
||||
|
||||
class Model<
|
||||
TModelAttributes extends {} = any,
|
||||
TCreationAttributes extends {} = TModelAttributes
|
||||
TModelAttributes extends object = any,
|
||||
TCreationAttributes extends object = TModelAttributes
|
||||
> extends SequelizeModel<TModelAttributes, TCreationAttributes> {
|
||||
/**
|
||||
* The namespace to use for events - defaults to the table name if none is provided.
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import { DeletedAt } from "sequelize-typescript";
|
||||
import IdModel from "./IdModel";
|
||||
|
||||
class ParanoidModel<
|
||||
TModelAttributes extends {} = any,
|
||||
TCreationAttributes extends {} = TModelAttributes
|
||||
TModelAttributes extends object = any,
|
||||
TCreationAttributes extends object = TModelAttributes
|
||||
> extends IdModel<TModelAttributes, TCreationAttributes> {
|
||||
@DeletedAt
|
||||
deletedAt: Date | null;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
|
||||
const Deprecated =
|
||||
(message?: string) => (target: Object, propertyKey: string) => {
|
||||
(message?: string) => (_target: object, propertyKey: string) => {
|
||||
if (process.env[propertyKey]) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
|
||||
@@ -29,7 +29,7 @@ export default function TextLength({
|
||||
Node.fromJSON(schema, value),
|
||||
schema
|
||||
);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
throw new Error("Invalid data");
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -100,7 +100,9 @@ function wrapInNativeError(err: any): Error {
|
||||
try {
|
||||
errMsg = JSON.stringify(err);
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (e) {}
|
||||
} catch (_err) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
const newError = InternalError(`Non-error thrown: ${errMsg}`);
|
||||
// err maybe an object, try to copy the name, message and stack to the new error instance
|
||||
|
||||
@@ -122,7 +122,7 @@ export class CanCan {
|
||||
|
||||
try {
|
||||
response = this.can(performer, ability.action, target);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
response = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ type Options = {
|
||||
includeText?: boolean;
|
||||
/** Always include the data of the document in the payload. */
|
||||
includeData?: boolean;
|
||||
|
||||
includeUpdatedAt?: boolean;
|
||||
};
|
||||
|
||||
async function presentDocument(
|
||||
@@ -75,6 +77,10 @@ async function presentDocument(
|
||||
res.lastViewedAt = document.views[0].updatedAt;
|
||||
}
|
||||
|
||||
if (options.isPublic && !options.includeUpdatedAt) {
|
||||
delete res.updatedAt;
|
||||
}
|
||||
|
||||
if (!options.isPublic) {
|
||||
const source = await document.$get("import");
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ export default function presentShare(share: Share, isAdmin = false) {
|
||||
createdBy: presentUser(share.user),
|
||||
includeChildDocuments: share.includeChildDocuments,
|
||||
allowIndexing: share.allowIndexing,
|
||||
showLastUpdated: share.showLastUpdated,
|
||||
lastAccessedAt: share.lastAccessedAt || undefined,
|
||||
views: share.views || 0,
|
||||
domain: share.domain,
|
||||
|
||||
@@ -4,6 +4,7 @@ export default function presentTeam(team: Team) {
|
||||
return {
|
||||
id: team.id,
|
||||
name: team.name,
|
||||
description: team.description,
|
||||
avatarUrl: team.avatarUrl,
|
||||
sharing: team.sharing,
|
||||
memberCollectionCreate: team.memberCollectionCreate,
|
||||
|
||||
@@ -62,7 +62,7 @@ export default class WebsocketsProcessor {
|
||||
|
||||
return socketio.to(channels).emit("entities", {
|
||||
event: event.name,
|
||||
fetchIfMissing: true,
|
||||
invalidatedPolicies: [document.id],
|
||||
documentIds: [
|
||||
{
|
||||
id: document.id,
|
||||
@@ -124,7 +124,7 @@ export default class WebsocketsProcessor {
|
||||
|
||||
return socketio.to(channels).emit("entities", {
|
||||
event: event.name,
|
||||
fetchIfMissing: true,
|
||||
invalidatedPolicies: [document.id],
|
||||
documentIds: [
|
||||
{
|
||||
id: document.id,
|
||||
@@ -177,6 +177,7 @@ export default class WebsocketsProcessor {
|
||||
documents.forEach((document) => {
|
||||
socketio.to(`collection-${document.collectionId}`).emit("entities", {
|
||||
event: event.name,
|
||||
invalidatedPolicies: [document.id],
|
||||
documentIds: [
|
||||
{
|
||||
id: document.id,
|
||||
|
||||
@@ -579,6 +579,7 @@ router.post(
|
||||
presentDocument(ctx, document, {
|
||||
isPublic,
|
||||
shareId,
|
||||
includeUpdatedAt: share?.showLastUpdated,
|
||||
}),
|
||||
teamFromCtx?.id === document.teamId ? teamFromCtx : document.$get("team"),
|
||||
]);
|
||||
|
||||
@@ -53,6 +53,7 @@ export const SharesUpdateSchema = BaseSchema.extend({
|
||||
includeChildDocuments: z.boolean().optional(),
|
||||
published: z.boolean().optional(),
|
||||
allowIndexing: z.boolean().optional(),
|
||||
showLastUpdated: z.boolean().optional(),
|
||||
urlId: z
|
||||
.string()
|
||||
.regex(UrlHelper.SHARE_URL_SLUG_REGEX, {
|
||||
|
||||
@@ -235,8 +235,14 @@ router.post(
|
||||
validate(T.SharesUpdateSchema),
|
||||
transaction(),
|
||||
async (ctx: APIContext<T.SharesUpdateReq>) => {
|
||||
const { id, includeChildDocuments, published, urlId, allowIndexing } =
|
||||
ctx.input.body;
|
||||
const {
|
||||
id,
|
||||
includeChildDocuments,
|
||||
published,
|
||||
urlId,
|
||||
allowIndexing,
|
||||
showLastUpdated,
|
||||
} = ctx.input.body;
|
||||
|
||||
const { user } = ctx.state.auth;
|
||||
authorize(user, "share", user.team);
|
||||
@@ -267,6 +273,10 @@ router.post(
|
||||
share.allowIndexing = allowIndexing;
|
||||
}
|
||||
|
||||
if (showLastUpdated !== undefined) {
|
||||
share.showLastUpdated = showLastUpdated;
|
||||
}
|
||||
|
||||
await share.saveWithCtx(ctx);
|
||||
|
||||
ctx.body = {
|
||||
|
||||
@@ -6,6 +6,8 @@ export const TeamsUpdateSchema = BaseSchema.extend({
|
||||
body: z.object({
|
||||
/** Team name */
|
||||
name: z.string().optional(),
|
||||
/** Team description */
|
||||
description: z.string().nullish(),
|
||||
/** Avatar URL */
|
||||
avatarUrl: z.string().nullish(),
|
||||
/** The subdomain to access the team */
|
||||
|
||||
@@ -20,7 +20,7 @@ export const UrlsUnfurlSchema = BaseSchema.extend({
|
||||
return ValidateURL.isValidMentionUrl(val);
|
||||
}
|
||||
return isUrl(val);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -273,7 +273,7 @@ router.get(
|
||||
});
|
||||
user = res.user;
|
||||
email = res.email;
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
ctx.redirect(`/?notice=expired-token`);
|
||||
return;
|
||||
}
|
||||
|
||||
+10
-6
@@ -182,7 +182,7 @@ export const renderShare = async (ctx: Context, next: Next) => {
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
// If the share or document does not exist, return a 404.
|
||||
ctx.status = 404;
|
||||
}
|
||||
@@ -190,14 +190,18 @@ export const renderShare = async (ctx: Context, next: Next) => {
|
||||
// Allow shares to be embedded in iframes on other websites
|
||||
ctx.remove("X-Frame-Options");
|
||||
|
||||
const publicBranding =
|
||||
team?.getPreference(TeamPreference.PublicBranding) ?? false;
|
||||
|
||||
// Inject share information in SSR HTML
|
||||
return renderApp(ctx, next, {
|
||||
title: document?.title,
|
||||
description: document?.getSummary(),
|
||||
title:
|
||||
document?.title || (publicBranding && team?.name ? team.name : undefined),
|
||||
description:
|
||||
document?.getSummary() ||
|
||||
(publicBranding && team?.description ? team.description : undefined),
|
||||
shortcutIcon:
|
||||
team?.getPreference(TeamPreference.PublicBranding) && team.avatarUrl
|
||||
? team.avatarUrl
|
||||
: undefined,
|
||||
publicBranding && team?.avatarUrl ? team.avatarUrl : undefined,
|
||||
analytics,
|
||||
isShare: true,
|
||||
rootShareId,
|
||||
|
||||
@@ -47,7 +47,7 @@ export const renderEmbed = async (ctx: Context, next: Next) => {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = new URL(url);
|
||||
} catch (err) {
|
||||
} catch (_err) {
|
||||
ctx.throw(400, "Invalid URL provided");
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ ${iframeCheckScript(ctx)}
|
||||
</head>
|
||||
<body>
|
||||
<a href="${parsed}" class="dropbox-embed">
|
||||
<script type="text/javascript" src="${dropboxJs}"
|
||||
<script type="text/javascript" src="${dropboxJs}"
|
||||
id="dropboxjs" data-app-key="${env.DROPBOX_APP_KEY}"></script>
|
||||
${resizeObserverScript(ctx)}
|
||||
</body>
|
||||
@@ -184,7 +184,7 @@ ${resizeObserverScript(ctx)}
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
html, body, iframe {
|
||||
html, body, iframe {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
@@ -216,14 +216,14 @@ ${resizeObserverScript(ctx)}
|
||||
border-color: rgb(35, 38, 41) !important;
|
||||
background-color: rgb(22, 25, 28) !important;
|
||||
}
|
||||
|
||||
|
||||
[class$="_pinner"],
|
||||
[class$="_board"] {
|
||||
color: #e6e6e6 !important;
|
||||
}
|
||||
[class$="_button"] {
|
||||
border-color: rgb(38, 42, 50) !important;
|
||||
background-color: rgba(3, 58, 120, 0.1) !important;
|
||||
background-color: rgba(3, 58, 120, 0.1) !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -232,8 +232,8 @@ ${iframeCheckScript(ctx)}
|
||||
</head>
|
||||
<body>
|
||||
<div class="pinterest-container">
|
||||
<a
|
||||
data-pin-do="${pinType}"
|
||||
<a
|
||||
data-pin-do="${pinType}"
|
||||
data-pin-board-width="100%"
|
||||
href="${url}"
|
||||
style="width:100%;max-width:none;"
|
||||
|
||||
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user