mirror of
https://github.com/outline/outline.git
synced 2026-06-14 03:45:00 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b555dab9dc |
@@ -13,7 +13,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Close unsigned PRs
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const now = new Date();
|
||||
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
github.event.pull_request.head.repo.full_name == github.repository)
|
||||
steps:
|
||||
- name: Checkout Branch
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v2
|
||||
- name: Compress Images
|
||||
id: calibre
|
||||
uses: calibreapp/image-actions@main
|
||||
@@ -48,7 +48,6 @@ jobs:
|
||||
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
# For non-Pull Requests, run in compressOnly mode and we'll PR after.
|
||||
compressOnly: ${{ github.event_name != 'pull_request' }}
|
||||
minPctChange: "10"
|
||||
- name: Create Pull Request
|
||||
# If it's not a Pull Request then commit any changes as a new PR.
|
||||
if: |
|
||||
|
||||
+13
-13
@@ -25,9 +25,9 @@ jobs:
|
||||
node-version: [20.x, 22.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v5
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: "yarn"
|
||||
@@ -38,8 +38,8 @@ jobs:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
cache: "yarn"
|
||||
@@ -50,8 +50,8 @@ jobs:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
cache: "yarn"
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
server: ${{ steps.filter.outputs.server }}
|
||||
app: ${{ steps.filter.outputs.app }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
@@ -92,8 +92,8 @@ jobs:
|
||||
matrix:
|
||||
test-group: [app, shared]
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
cache: "yarn"
|
||||
@@ -124,8 +124,8 @@ jobs:
|
||||
shard: [1, 2, 3, 4]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
cache: "yarn"
|
||||
@@ -141,8 +141,8 @@ jobs:
|
||||
if: ${{ needs.changes.outputs.app == 'true' && github.repository == 'outline/outline' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
cache: "yarn"
|
||||
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
runs-on: ubicloud-standard-8-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
runs-on: ubicloud-standard-8
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
run-linters:
|
||||
if: startsWith(github.actor, 'codegen-sh')
|
||||
name: Run linters
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
# Give the default GITHUB_TOKEN write permission to commit and push the
|
||||
# added or changed files to the repository.
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
cache: "yarn"
|
||||
- run: yarn install --frozen-lockfile --prefer-offline
|
||||
- run: yarn lint --fix
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "Applied automatic fixes"
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v10
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
stale-pr-message: "This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days"
|
||||
stale-issue-message: "This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days"
|
||||
|
||||
+4
-2
@@ -20,7 +20,8 @@
|
||||
"moduleNameMapper": {
|
||||
"^~/(.*)$": "<rootDir>/app/$1",
|
||||
"^@shared/(.*)$": "<rootDir>/shared/$1",
|
||||
"^.*[.](gif|ttf|eot|svg)$": "<rootDir>/__test__/fileMock.js"
|
||||
"^.*[.](gif|ttf|eot|svg)$": "<rootDir>/__test__/fileMock.js",
|
||||
"^uuid$": "<rootDir>/node_modules/uuid/dist/index.js"
|
||||
},
|
||||
"modulePaths": ["<rootDir>/app"],
|
||||
"setupFiles": ["<rootDir>/__mocks__/window.js"],
|
||||
@@ -47,7 +48,8 @@
|
||||
"moduleNameMapper": {
|
||||
"^~/(.*)$": "<rootDir>/app/$1",
|
||||
"^@shared/(.*)$": "<rootDir>/shared/$1",
|
||||
"^.*[.](gif|ttf|eot|svg)$": "<rootDir>/__test__/fileMock.js"
|
||||
"^.*[.](gif|ttf|eot|svg)$": "<rootDir>/__test__/fileMock.js",
|
||||
"^uuid$": "<rootDir>/node_modules/uuid/dist/index.js"
|
||||
},
|
||||
"setupFiles": ["<rootDir>/__mocks__/window.js"],
|
||||
"testEnvironment": "jsdom",
|
||||
|
||||
+8
-8
@@ -6,7 +6,7 @@ ARG APP_PATH
|
||||
WORKDIR $APP_PATH
|
||||
|
||||
# ---
|
||||
FROM node:22.21.0-slim AS runner
|
||||
FROM node:22-slim AS runner
|
||||
|
||||
LABEL org.opencontainers.image.source="https://github.com/outline/outline"
|
||||
|
||||
@@ -16,9 +16,9 @@ ENV NODE_ENV=production
|
||||
|
||||
# Create a non-root user compatible with Debian and BusyBox based images
|
||||
RUN addgroup --gid 1001 nodejs && \
|
||||
adduser --uid 1001 --ingroup nodejs nodejs && \
|
||||
mkdir -p /var/lib/outline && \
|
||||
chown -R nodejs:nodejs /var/lib/outline
|
||||
adduser --uid 1001 --ingroup nodejs nodejs && \
|
||||
mkdir -p /var/lib/outline && \
|
||||
chown -R nodejs:nodejs /var/lib/outline
|
||||
|
||||
COPY --from=base --chown=nodejs:nodejs $APP_PATH/build ./build
|
||||
COPY --from=base $APP_PATH/server ./server
|
||||
@@ -29,13 +29,13 @@ COPY --from=base $APP_PATH/package.json ./package.json
|
||||
|
||||
# Install wget to healthcheck the server
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
&& apt-get install -y wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data
|
||||
RUN mkdir -p "$FILE_STORAGE_LOCAL_ROOT_DIR" && \
|
||||
chown -R nodejs:nodejs "$FILE_STORAGE_LOCAL_ROOT_DIR" && \
|
||||
chmod 1777 "$FILE_STORAGE_LOCAL_ROOT_DIR"
|
||||
chown -R nodejs:nodejs "$FILE_STORAGE_LOCAL_ROOT_DIR" && \
|
||||
chmod 1777 "$FILE_STORAGE_LOCAL_ROOT_DIR"
|
||||
|
||||
VOLUME /var/lib/outline/data
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
ARG APP_PATH=/opt/outline
|
||||
FROM node:22.21.0 AS deps
|
||||
FROM node:22 AS deps
|
||||
|
||||
ARG APP_PATH
|
||||
WORKDIR $APP_PATH
|
||||
|
||||
@@ -3,7 +3,7 @@ Business Source License 1.1
|
||||
Parameters
|
||||
|
||||
Licensor: General Outline, Inc.
|
||||
Licensed Work: Outline 1.0.1
|
||||
Licensed Work: Outline 0.87.4
|
||||
The Licensed Work is (c) 2025 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: 2029-10-29
|
||||
Change Date: 2029-09-18
|
||||
|
||||
Change License: Apache License, Version 2.0
|
||||
|
||||
|
||||
@@ -5,13 +5,6 @@
|
||||
{
|
||||
"files": ["**/*.{jsx,tsx}"],
|
||||
"rules": {
|
||||
"no-restricted-globals": [
|
||||
"error",
|
||||
{
|
||||
"name": "crypto",
|
||||
"message": "Do not use, does not work in environments without SSL."
|
||||
}
|
||||
],
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
|
||||
@@ -176,21 +176,6 @@ export const toggleDebugLogging = createAction({
|
||||
},
|
||||
});
|
||||
|
||||
export const toggleDebugSafeArea = createAction({
|
||||
name: () => "Toggle menu safe area debugging",
|
||||
icon: <ToolsIcon />,
|
||||
section: DeveloperSection,
|
||||
visible: () => env.ENVIRONMENT === "development",
|
||||
perform: ({ stores }) => {
|
||||
stores.ui.toggleDebugSafeArea();
|
||||
toast.message(
|
||||
stores.ui.debugSafeArea
|
||||
? "Menu safe area debugging enabled"
|
||||
: "Menu safe area debugging disabled"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
export const toggleFeatureFlag = createAction({
|
||||
name: "Toggle feature flag",
|
||||
icon: <BeakerIcon />,
|
||||
@@ -224,7 +209,6 @@ export const developer = createAction({
|
||||
children: [
|
||||
copyId,
|
||||
toggleDebugLogging,
|
||||
toggleDebugSafeArea,
|
||||
toggleFeatureFlag,
|
||||
createToast,
|
||||
createTestUsers,
|
||||
|
||||
@@ -22,7 +22,6 @@ export const inviteUser = createAction({
|
||||
perform: ({ t }) => {
|
||||
stores.dialogs.openModal({
|
||||
title: t("Invite to workspace"),
|
||||
width: "500px",
|
||||
content: <Invite onSubmit={stores.dialogs.closeAllModals} />,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { LocationDescriptor } from "history";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import flattenDeep from "lodash/flattenDeep";
|
||||
import { toast } from "sonner";
|
||||
import { Optional } from "utility-types";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
Action,
|
||||
ActionContext,
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import useBoolean from "~/hooks/useBoolean";
|
||||
import Initials from "./Initials";
|
||||
import Tooltip from "../Tooltip";
|
||||
|
||||
export enum AvatarSize {
|
||||
Small = 16,
|
||||
@@ -23,7 +22,6 @@ export interface IAvatar {
|
||||
avatarUrl: string | null;
|
||||
color?: string;
|
||||
initial?: string;
|
||||
name?: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
@@ -44,8 +42,6 @@ type Props = {
|
||||
className?: string;
|
||||
/** Optional style */
|
||||
style?: React.CSSProperties;
|
||||
/** Whether to show a tooltip */
|
||||
showTooltip?: boolean;
|
||||
};
|
||||
|
||||
function Avatar(props: Props) {
|
||||
@@ -54,13 +50,12 @@ function Avatar(props: Props) {
|
||||
style,
|
||||
variant = AvatarVariant.Round,
|
||||
className,
|
||||
showTooltip,
|
||||
...rest
|
||||
} = props;
|
||||
const src = props.src || model?.avatarUrl;
|
||||
const [error, handleError] = useBoolean(false);
|
||||
|
||||
const content = (
|
||||
return (
|
||||
<Relative
|
||||
style={style}
|
||||
$variant={variant}
|
||||
@@ -78,12 +73,6 @@ function Avatar(props: Props) {
|
||||
)}
|
||||
</Relative>
|
||||
);
|
||||
|
||||
return showTooltip ? (
|
||||
<Tooltip content={props.alt || model?.name || ""}>{content}</Tooltip>
|
||||
) : (
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
Avatar.defaultProps = {
|
||||
|
||||
@@ -26,7 +26,6 @@ export function GroupAvatar({
|
||||
return (
|
||||
<Squircle color={color ?? theme.text} size={size} className={className}>
|
||||
<GroupIcon
|
||||
data-fixed-color
|
||||
color={backgroundColor ?? theme.background}
|
||||
size={size * 0.75}
|
||||
/>
|
||||
|
||||
@@ -32,8 +32,6 @@ function Dialogs() {
|
||||
}}
|
||||
title={modal.title}
|
||||
style={modal.style}
|
||||
width={modal.width}
|
||||
height={modal.height}
|
||||
>
|
||||
{modal.content}
|
||||
</Modal>
|
||||
|
||||
@@ -3,7 +3,6 @@ import concat from "lodash/concat";
|
||||
import difference from "lodash/difference";
|
||||
import fill from "lodash/fill";
|
||||
import filter from "lodash/filter";
|
||||
import flatten from "lodash/flatten";
|
||||
import includes from "lodash/includes";
|
||||
import map from "lodash/map";
|
||||
import { observer } from "mobx-react";
|
||||
@@ -28,6 +27,7 @@ import Text from "~/components/Text";
|
||||
import useMobile from "~/hooks/useMobile";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { ancestors, descendants, flattenTree } from "~/utils/tree";
|
||||
import flatten from "lodash/flatten";
|
||||
|
||||
type Props = {
|
||||
/** Action taken upon submission of selected item, could be publish, move etc. */
|
||||
@@ -49,13 +49,8 @@ function DocumentExplorer({ onSubmit, onSelect, items, defaultValue }: Props) {
|
||||
const [searchTerm, setSearchTerm] = React.useState<string>();
|
||||
const [selectedNode, selectNode] = React.useState<NavigationNode | null>(
|
||||
() => {
|
||||
if (!defaultValue) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Search through all nodes in the tree, not just top-level items
|
||||
const allNodes = flatten(items.map(flattenTree));
|
||||
const node = allNodes.find((item) => item.id === defaultValue);
|
||||
const node =
|
||||
defaultValue && items.find((item) => item.id === defaultValue);
|
||||
return node || null;
|
||||
}
|
||||
);
|
||||
@@ -64,9 +59,7 @@ function DocumentExplorer({ onSubmit, onSelect, items, defaultValue }: Props) {
|
||||
const [activeNode, setActiveNode] = React.useState<number>(0);
|
||||
const [expandedNodes, setExpandedNodes] = React.useState<string[]>(() => {
|
||||
if (defaultValue) {
|
||||
// Search through all nodes in the tree, not just top-level items
|
||||
const allNodes = flatten(items.map(flattenTree));
|
||||
const node = allNodes.find((item) => item.id === defaultValue);
|
||||
const node = items.find((item) => item.id === defaultValue);
|
||||
if (node) {
|
||||
return ancestors(node).map((ancestorNode) => ancestorNode.id);
|
||||
}
|
||||
@@ -111,6 +104,19 @@ function DocumentExplorer({ onSubmit, onSelect, items, defaultValue }: Props) {
|
||||
);
|
||||
}, [items.length]);
|
||||
|
||||
React.useEffect(() => {
|
||||
onSelect(selectedNode);
|
||||
}, [selectedNode, onSelect]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (defaultValue && selectedNode && listRef) {
|
||||
const index = nodes.findIndex((node) => node.id === selectedNode.id);
|
||||
if (index > 0) {
|
||||
setTimeout(() => listRef.current?.scrollToItem(index, "center"), 50);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
function getNodes() {
|
||||
function includeDescendants(item: NavigationNode): NavigationNode[] {
|
||||
return expandedNodes.includes(item.id)
|
||||
@@ -124,19 +130,6 @@ function DocumentExplorer({ onSubmit, onSelect, items, defaultValue }: Props) {
|
||||
}
|
||||
|
||||
const nodes = getNodes();
|
||||
|
||||
React.useEffect(() => {
|
||||
onSelect(selectedNode);
|
||||
}, [selectedNode, onSelect]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (defaultValue && selectedNode && listRef) {
|
||||
const index = nodes.findIndex((node) => node.id === selectedNode.id);
|
||||
if (index > 0) {
|
||||
setTimeout(() => listRef.current?.scrollToItem(index, "center"), 50);
|
||||
}
|
||||
}
|
||||
}, [defaultValue, selectedNode, nodes]);
|
||||
const baseDepth = nodes.reduce(
|
||||
(min, node) => (node.depth ? Math.min(min, node.depth) : min),
|
||||
Infinity
|
||||
|
||||
@@ -32,7 +32,6 @@ function EditableTitle(
|
||||
const [isEditing, setIsEditing] = React.useState(rest.isEditing || false);
|
||||
const [originalValue, setOriginalValue] = React.useState(title);
|
||||
const [value, setValue] = React.useState(title);
|
||||
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
||||
|
||||
React.useImperativeHandle(ref, () => ({
|
||||
setIsEditing,
|
||||
@@ -66,10 +65,6 @@ function EditableTitle(
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
if (isSubmitting) {
|
||||
return;
|
||||
}
|
||||
|
||||
const trimmedValue = value.trim();
|
||||
|
||||
if (trimmedValue === originalValue || trimmedValue.length === 0) {
|
||||
@@ -79,22 +74,18 @@ function EditableTitle(
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
await onSubmit(trimmedValue);
|
||||
setOriginalValue(trimmedValue);
|
||||
setIsEditing(false);
|
||||
} catch (error) {
|
||||
setValue(value);
|
||||
setIsEditing(true);
|
||||
|
||||
setValue(originalValue);
|
||||
toast.error(error.message);
|
||||
throw error;
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
setIsEditing(false);
|
||||
}
|
||||
},
|
||||
[originalValue, value, onCancel, onSubmit, isSubmitting]
|
||||
[originalValue, value, onCancel, onSubmit]
|
||||
);
|
||||
|
||||
const handleKeyDown = React.useCallback(
|
||||
|
||||
@@ -25,7 +25,6 @@ function ExportDialog({ collection, onSubmit }: Props) {
|
||||
);
|
||||
const [includeAttachments, setIncludeAttachments] =
|
||||
React.useState<boolean>(true);
|
||||
const [includePrivate, setIncludePrivate] = React.useState<boolean>(true);
|
||||
const user = useCurrentUser();
|
||||
const { collections } = useStores();
|
||||
const { t } = useTranslation();
|
||||
@@ -45,13 +44,6 @@ function ExportDialog({ collection, onSubmit }: Props) {
|
||||
[]
|
||||
);
|
||||
|
||||
const handleIncludePrivateChange = React.useCallback(
|
||||
(ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setIncludePrivate(ev.target.checked);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (collection) {
|
||||
await collection.export(format, includeAttachments);
|
||||
@@ -67,7 +59,7 @@ function ExportDialog({ collection, onSubmit }: Props) {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await collections.export({ format, includeAttachments, includePrivate });
|
||||
await collections.export(format, includeAttachments);
|
||||
toast.success(t("Export started"));
|
||||
}
|
||||
onSubmit();
|
||||
@@ -131,62 +123,37 @@ function ExportDialog({ collection, onSubmit }: Props) {
|
||||
<Text as="p" size="small" weight="bold">
|
||||
{item.title}
|
||||
</Text>
|
||||
<Text size="small" type="secondary">
|
||||
{item.description}
|
||||
</Text>
|
||||
<Text size="small">{item.description}</Text>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</Flex>
|
||||
<HR />
|
||||
<Flex gap={12} column>
|
||||
<Option>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="includeAttachments"
|
||||
checked={includeAttachments}
|
||||
onChange={handleIncludeAttachmentsChange}
|
||||
/>
|
||||
<div>
|
||||
<Text as="p" size="small" weight="bold">
|
||||
{t("Include attachments")}
|
||||
</Text>
|
||||
<Text size="small" type="secondary">
|
||||
{t("Including uploaded images and files in the exported data")}.
|
||||
</Text>{" "}
|
||||
</div>
|
||||
</Option>
|
||||
<Option>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="includePrivate"
|
||||
checked={includePrivate}
|
||||
onChange={handleIncludePrivateChange}
|
||||
/>
|
||||
<div>
|
||||
<Text as="p" size="small" weight="bold">
|
||||
{t("Include private collections")}
|
||||
</Text>
|
||||
</div>
|
||||
</Option>
|
||||
</Flex>
|
||||
<hr />
|
||||
<Option>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="includeAttachments"
|
||||
checked={includeAttachments}
|
||||
onChange={handleIncludeAttachmentsChange}
|
||||
/>
|
||||
<div>
|
||||
<Text as="p" size="small" weight="bold">
|
||||
{t("Include attachments")}
|
||||
</Text>
|
||||
<Text size="small">
|
||||
{t("Including uploaded images and files in the exported data")}.
|
||||
</Text>{" "}
|
||||
</div>
|
||||
</Option>
|
||||
</ConfirmationDialog>
|
||||
);
|
||||
}
|
||||
|
||||
const HR = styled.hr`
|
||||
margin: 16px 0;
|
||||
`;
|
||||
|
||||
const Option = styled.label`
|
||||
display: flex;
|
||||
align-items: start;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
|
||||
input {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import styled from "styled-components";
|
||||
import User from "~/models/User";
|
||||
import { Avatar, AvatarSize } from "~/components/Avatar";
|
||||
import Flex from "~/components/Flex";
|
||||
import { s } from "@shared/styles";
|
||||
|
||||
type Props = {
|
||||
/** The users to display */
|
||||
@@ -22,8 +21,6 @@ type Props = {
|
||||
model: User;
|
||||
}
|
||||
>;
|
||||
/** Whether to show tooltips on hover, defaults to true */
|
||||
showTooltip?: boolean;
|
||||
};
|
||||
|
||||
function Facepile({
|
||||
@@ -32,7 +29,6 @@ function Facepile({
|
||||
size = AvatarSize.Large,
|
||||
limit = 8,
|
||||
renderAvatar = Avatar,
|
||||
showTooltip = true,
|
||||
...rest
|
||||
}: Props) {
|
||||
const { t } = useTranslation();
|
||||
@@ -55,7 +51,6 @@ function Facepile({
|
||||
<Component
|
||||
key={model.id}
|
||||
{...{
|
||||
showTooltip,
|
||||
model,
|
||||
size,
|
||||
style: {
|
||||
@@ -106,11 +101,6 @@ const Avatars = styled(Flex)`
|
||||
align-items: center;
|
||||
flex-direction: row-reverse;
|
||||
cursor: var(--pointer);
|
||||
|
||||
*:hover {
|
||||
clip-path: none !important;
|
||||
box-shadow: 0 0 0 2px ${s("background")};
|
||||
}
|
||||
`;
|
||||
|
||||
export default observer(Facepile);
|
||||
|
||||
@@ -13,7 +13,6 @@ import useStores from "~/hooks/useStores";
|
||||
import LoadingIndicator from "../LoadingIndicator";
|
||||
import { CARD_MARGIN } from "./Components";
|
||||
import HoverPreviewDocument from "./HoverPreviewDocument";
|
||||
import HoverPreviewGroup from "./HoverPreviewGroup";
|
||||
import HoverPreviewIssue from "./HoverPreviewIssue";
|
||||
import HoverPreviewLink from "./HoverPreviewLink";
|
||||
import HoverPreviewMention from "./HoverPreviewMention";
|
||||
@@ -133,13 +132,6 @@ const HoverPreviewDesktop = observer(
|
||||
lastActive={data.lastActive}
|
||||
email={data.email}
|
||||
/>
|
||||
) : data.type === UnfurlResourceType.Group ? (
|
||||
<HoverPreviewGroup
|
||||
ref={cardRef}
|
||||
name={data.name}
|
||||
memberCount={data.memberCount}
|
||||
users={data.users}
|
||||
/>
|
||||
) : data.type === UnfurlResourceType.Document ? (
|
||||
<HoverPreviewDocument
|
||||
ref={cardRef}
|
||||
@@ -303,10 +295,10 @@ const Pointer = styled.div<{ top: number; left: number; direction: Direction }>`
|
||||
|
||||
&:before {
|
||||
border: 8px solid transparent;
|
||||
${({ direction }) =>
|
||||
${({ direction, theme }) =>
|
||||
direction === Direction.UP
|
||||
? `border-bottom-color: rgba(0, 0, 0, 0.1)`
|
||||
: `border-top-color: rgba(0, 0, 0, 0.1)`};
|
||||
? `border-bottom-color: ${theme.menuBorder || "rgba(0, 0, 0, 0.1)"}`
|
||||
: `border-top-color: ${theme.menuBorder || "rgba(0, 0, 0, 0.1)"}`};
|
||||
${({ direction }) =>
|
||||
direction === Direction.UP ? "right: -1px" : "left: -1px"};
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
import * as React from "react";
|
||||
import { UnfurlResourceType, UnfurlResponse } from "@shared/types";
|
||||
import { MAX_AVATAR_DISPLAY } from "@shared/constants";
|
||||
import User from "~/models/User";
|
||||
import Facepile from "~/components/Facepile";
|
||||
import Flex from "~/components/Flex";
|
||||
import {
|
||||
Preview,
|
||||
Title,
|
||||
Info,
|
||||
Card,
|
||||
CardContent,
|
||||
Description,
|
||||
} from "./Components";
|
||||
import ErrorBoundary from "../ErrorBoundary";
|
||||
|
||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.Group], "type">;
|
||||
|
||||
const HoverPreviewGroup = React.forwardRef(function _HoverPreviewGroup(
|
||||
{ name, memberCount, users }: Props,
|
||||
ref: React.Ref<HTMLDivElement>
|
||||
) {
|
||||
return (
|
||||
<Preview as="div">
|
||||
<Card fadeOut={false} ref={ref}>
|
||||
<CardContent>
|
||||
<ErrorBoundary showTitle={false} reloadOnChunkMissing={false}>
|
||||
<Flex column gap={2} align="start">
|
||||
<Title>{name}</Title>
|
||||
<Info>
|
||||
{memberCount === 1 ? "1 member" : `${memberCount} members`}
|
||||
</Info>
|
||||
{users.length > 0 && (
|
||||
<Description>
|
||||
<Facepile
|
||||
users={users.map(
|
||||
(member) =>
|
||||
({
|
||||
id: member.id,
|
||||
name: member.name,
|
||||
avatarUrl: member.avatarUrl,
|
||||
color: member.color,
|
||||
initial: member.name ? member.name[0] : "?",
|
||||
}) as User
|
||||
)}
|
||||
overflow={Math.max(0, memberCount - users.length)}
|
||||
limit={MAX_AVATAR_DISPLAY}
|
||||
/>
|
||||
</Description>
|
||||
)}
|
||||
</Flex>
|
||||
</ErrorBoundary>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Preview>
|
||||
);
|
||||
});
|
||||
|
||||
export default HoverPreviewGroup;
|
||||
@@ -7,7 +7,7 @@ import { Preview, Title, Info, Card, CardContent } from "./Components";
|
||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.Mention], "type">;
|
||||
|
||||
const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
|
||||
{ avatarUrl, name, lastActive, color }: Props,
|
||||
{ avatarUrl, name, lastActive, color, email }: Props,
|
||||
ref: React.Ref<HTMLDivElement>
|
||||
) {
|
||||
return (
|
||||
@@ -25,6 +25,7 @@ const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
|
||||
/>
|
||||
<Flex column gap={2} justify="center">
|
||||
<Title>{name}</Title>
|
||||
{email && <Info>{email}</Info>}
|
||||
<Info>{lastActive}</Info>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as VisuallyHidden from "@radix-ui/react-visually-hidden";
|
||||
import { QuestionMarkIcon } from "outline-icons";
|
||||
import { transparentize } from "polished";
|
||||
import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import { s } from "@shared/styles";
|
||||
@@ -341,9 +342,9 @@ function Option({
|
||||
{option.description && (
|
||||
<>
|
||||
|
||||
<Text type="tertiary" size="small" ellipsis>
|
||||
<Description type="tertiary" size="small" ellipsis>
|
||||
– {option.description}
|
||||
</Text>
|
||||
</Description>
|
||||
</>
|
||||
)}
|
||||
</OptionContainer>
|
||||
@@ -359,6 +360,15 @@ const OptionContainer = styled(Flex)`
|
||||
min-height: 24px;
|
||||
`;
|
||||
|
||||
const Description = styled(Text)`
|
||||
@media (hover: hover) {
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: ${(props) => transparentize(0.5, props.theme.accentText)};
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const IconWrapper = styled.span`
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
+53
-370
@@ -1,19 +1,7 @@
|
||||
import { observer } from "mobx-react";
|
||||
import * as Dialog from "@radix-ui/react-dialog";
|
||||
import styled, { css, Keyframes, keyframes } from "styled-components";
|
||||
import {
|
||||
ComponentProps,
|
||||
createContext,
|
||||
forwardRef,
|
||||
HTMLAttributes,
|
||||
ReactNode,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
||||
import { isInternalUrl } from "@shared/utils/urls";
|
||||
import { Error as ImageError } from "@shared/editor/components/Image";
|
||||
import {
|
||||
@@ -23,8 +11,6 @@ import {
|
||||
DownloadIcon,
|
||||
LinkIcon,
|
||||
NextIcon,
|
||||
ZoomInIcon,
|
||||
ZoomOutIcon,
|
||||
} from "outline-icons";
|
||||
import { depths, extraArea, s } from "@shared/styles";
|
||||
import NudeButton from "./NudeButton";
|
||||
@@ -42,14 +28,6 @@ import useSwipe from "~/hooks/useSwipe";
|
||||
import { toast } from "sonner";
|
||||
import { findIndex } from "lodash";
|
||||
import { LightboxImage } from "@shared/editor/lib/Lightbox";
|
||||
import {
|
||||
TransformWrapper,
|
||||
TransformComponent,
|
||||
useTransformEffect,
|
||||
ReactZoomPanPinchRef,
|
||||
} from "react-zoom-pan-pinch";
|
||||
import { transparentize } from "polished";
|
||||
import { mergeRefs } from "react-merge-refs";
|
||||
|
||||
export enum LightboxStatus {
|
||||
READY_TO_OPEN,
|
||||
@@ -64,9 +42,6 @@ export enum ImageStatus {
|
||||
LOADING,
|
||||
ERROR,
|
||||
LOADED,
|
||||
MIN_ZOOM,
|
||||
MAX_ZOOM,
|
||||
ZOOMED,
|
||||
}
|
||||
type Status = {
|
||||
lightbox: LightboxStatus | null;
|
||||
@@ -94,129 +69,11 @@ type Props = {
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
const ZoomPanPinchContext = createContext({ isImagePanning: false });
|
||||
type ZoomablePannablePinchableProps = {
|
||||
children: ReactNode;
|
||||
panningDisabled: boolean;
|
||||
disabled: boolean;
|
||||
onClose?: () => void;
|
||||
};
|
||||
|
||||
const ZoomablePannablePinchable = forwardRef<
|
||||
ReactZoomPanPinchRef,
|
||||
ZoomablePannablePinchableProps
|
||||
>(({ children, panningDisabled, disabled, onClose }, ref) => {
|
||||
const { isPanning, ...panningHandlers } = usePanning();
|
||||
const wrapperRef = useRef<ReactZoomPanPinchRef>(null);
|
||||
const scale = wrapperRef.current?.instance.transformState.scale ?? 1;
|
||||
|
||||
const wrapperProps = useMemo(
|
||||
() =>
|
||||
({
|
||||
onClick: (event) => {
|
||||
if (scale > 1) {
|
||||
return;
|
||||
}
|
||||
if (event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
["IMG", "INPUT", "BUTTON", "A"].includes(
|
||||
(event.target as Element).tagName
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
onClose?.();
|
||||
},
|
||||
}) satisfies HTMLAttributes<HTMLDivElement>,
|
||||
[onClose, scale]
|
||||
);
|
||||
|
||||
return (
|
||||
<ZoomPanPinchContext.Provider value={{ isImagePanning: isPanning }}>
|
||||
<TransformWrapper
|
||||
ref={mergeRefs([ref, wrapperRef])}
|
||||
disabled={disabled}
|
||||
doubleClick={{ disabled: true }}
|
||||
minScale={1}
|
||||
maxScale={8}
|
||||
panning={{
|
||||
disabled: panningDisabled,
|
||||
}}
|
||||
{...panningHandlers}
|
||||
>
|
||||
<TransformComponent
|
||||
wrapperStyle={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
cursor: isPanning ? "grabbing" : scale > 1 ? "grab" : "zoom-out",
|
||||
}}
|
||||
contentStyle={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
padding: "56px",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
wrapperProps={wrapperProps}
|
||||
>
|
||||
{children}
|
||||
</TransformComponent>
|
||||
</TransformWrapper>
|
||||
</ZoomPanPinchContext.Provider>
|
||||
);
|
||||
});
|
||||
|
||||
function usePanning() {
|
||||
const [isPanning, setPanning] = useState(false);
|
||||
const dragged = useRef(false);
|
||||
|
||||
const onPanningStart: ComponentProps<
|
||||
typeof TransformWrapper
|
||||
>["onPanningStart"] = (ref) => {
|
||||
const zoomedIn = ref.state.scale > 1;
|
||||
if (zoomedIn) {
|
||||
setPanning(ref.instance.isPanning);
|
||||
}
|
||||
};
|
||||
|
||||
const onPanning: ComponentProps<
|
||||
typeof TransformWrapper
|
||||
>["onPanning"] = () => {
|
||||
dragged.current = true;
|
||||
};
|
||||
|
||||
const onPanningStop: ComponentProps<
|
||||
typeof TransformWrapper
|
||||
>["onPanningStop"] = (ref, event) => {
|
||||
setPanning(ref.instance.isPanning);
|
||||
if (dragged.current) {
|
||||
dragged.current = false;
|
||||
} else if (event.target instanceof HTMLImageElement) {
|
||||
const zoomedOut = Math.abs(ref.state.scale - 1) < 0.001;
|
||||
if (zoomedOut) {
|
||||
ref.zoomIn();
|
||||
} else {
|
||||
ref.resetTransform();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
isPanning,
|
||||
onPanningStart,
|
||||
onPanning,
|
||||
onPanningStop,
|
||||
};
|
||||
}
|
||||
|
||||
function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
const isIdle = useIdle(3 * Second.ms);
|
||||
const { t } = useTranslation();
|
||||
const imgRef = useRef<HTMLImageElement | null>(null);
|
||||
const overlayRef = useRef<HTMLDivElement | null>(null);
|
||||
const contentRef = useRef<HTMLDivElement | null>(null);
|
||||
const [status, setStatus] = useState<Status>({ lightbox: null, image: null });
|
||||
const animation = useRef<Animation | null>(null);
|
||||
const finalImage = useRef<{
|
||||
@@ -224,7 +81,6 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
width: number;
|
||||
height: number;
|
||||
} | null>(null);
|
||||
const zoomPanPinchRef = useRef<ReactZoomPanPinchRef>(null);
|
||||
|
||||
const currentImageIndex = findIndex(
|
||||
images,
|
||||
@@ -275,18 +131,6 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
}
|
||||
}, [status.image, status.lightbox]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
status.lightbox === LightboxStatus.OPENED &&
|
||||
status.image === ImageStatus.LOADED
|
||||
) {
|
||||
setStatus({
|
||||
lightbox: LightboxStatus.OPENED,
|
||||
image: ImageStatus.MIN_ZOOM,
|
||||
});
|
||||
}
|
||||
}, [status.lightbox, status.image]);
|
||||
|
||||
useEffect(() => {
|
||||
if (status.lightbox === LightboxStatus.READY_TO_CLOSE) {
|
||||
setupFadeOut();
|
||||
@@ -304,15 +148,6 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
}
|
||||
}, [status.lightbox]);
|
||||
|
||||
useEffect(() => {
|
||||
if (status.image === ImageStatus.MIN_ZOOM) {
|
||||
// It was observed that focus went to `body` as the zoom out button was disabled
|
||||
// upon clicking it. This stopped navigating to next/previous image using arrow keys.
|
||||
// So focusing the content div here to restore the functionality.
|
||||
contentRef.current?.focus();
|
||||
}
|
||||
}, [status.image]);
|
||||
|
||||
const rememberImagePosition = () => {
|
||||
if (imgRef.current) {
|
||||
const lightboxImgDOMRect = imgRef.current.getBoundingClientRect();
|
||||
@@ -426,13 +261,7 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
};
|
||||
|
||||
const setupZoomOut = () => {
|
||||
if (
|
||||
imgRef.current &&
|
||||
!(
|
||||
status.image === ImageStatus.ZOOMED ||
|
||||
status.image === ImageStatus.MAX_ZOOM
|
||||
)
|
||||
) {
|
||||
if (imgRef.current) {
|
||||
// in lightbox
|
||||
const lightboxImgDOMRect = imgRef.current.getBoundingClientRect();
|
||||
const {
|
||||
@@ -527,11 +356,7 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
};
|
||||
|
||||
const prev = () => {
|
||||
if (
|
||||
status.lightbox === LightboxStatus.OPENED &&
|
||||
(status.image === ImageStatus.MIN_ZOOM ||
|
||||
status.image === ImageStatus.ERROR)
|
||||
) {
|
||||
if (status.lightbox === LightboxStatus.OPENED) {
|
||||
const prevIndex = currentImageIndex - 1;
|
||||
if (prevIndex < 0) {
|
||||
return;
|
||||
@@ -541,11 +366,7 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
};
|
||||
|
||||
const next = () => {
|
||||
if (
|
||||
status.lightbox === LightboxStatus.OPENED &&
|
||||
(status.image === ImageStatus.MIN_ZOOM ||
|
||||
status.image === ImageStatus.ERROR)
|
||||
) {
|
||||
if (status.lightbox === LightboxStatus.OPENED) {
|
||||
const nextIndex = currentImageIndex + 1;
|
||||
if (nextIndex >= images.length) {
|
||||
return;
|
||||
@@ -679,7 +500,7 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
onAnimationStart={handleFadeStart}
|
||||
onAnimationEnd={handleFadeEnd}
|
||||
/>
|
||||
<StyledContent onKeyDown={handleKeyDown} ref={contentRef}>
|
||||
<StyledContent onKeyDown={handleKeyDown}>
|
||||
<VisuallyHidden.Root>
|
||||
<Dialog.Title>{t("Lightbox")}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
@@ -687,52 +508,10 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
</Dialog.Description>
|
||||
</VisuallyHidden.Root>
|
||||
<Actions animation={animation.current}>
|
||||
<Tooltip content={t("Zoom in")} placement="bottom">
|
||||
<ActionButton
|
||||
tabIndex={-1}
|
||||
disabled={
|
||||
status.image === ImageStatus.MAX_ZOOM ||
|
||||
status.image === ImageStatus.ERROR
|
||||
}
|
||||
onClick={() => {
|
||||
if (zoomPanPinchRef.current) {
|
||||
zoomPanPinchRef.current.zoomIn();
|
||||
}
|
||||
}}
|
||||
aria-label={t("Zoom in")}
|
||||
size={32}
|
||||
icon={<ZoomInIcon />}
|
||||
borderOnHover
|
||||
neutral
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip content={t("Zoom out")} placement="bottom">
|
||||
<ActionButton
|
||||
tabIndex={-1}
|
||||
disabled={
|
||||
!(
|
||||
status.image === ImageStatus.ZOOMED ||
|
||||
status.image === ImageStatus.MAX_ZOOM
|
||||
)
|
||||
}
|
||||
onClick={() => {
|
||||
if (zoomPanPinchRef.current) {
|
||||
zoomPanPinchRef.current.zoomOut();
|
||||
}
|
||||
}}
|
||||
aria-label={t("Zoom out")}
|
||||
size={32}
|
||||
icon={<ZoomOutIcon />}
|
||||
borderOnHover
|
||||
neutral
|
||||
/>
|
||||
</Tooltip>
|
||||
<Separator />
|
||||
<Tooltip content={t("Copy link")} placement="bottom">
|
||||
<CopyToClipboard text={imgRef.current?.src ?? ""}>
|
||||
<ActionButton
|
||||
<Button
|
||||
tabIndex={-1}
|
||||
disabled={status.image === ImageStatus.ERROR}
|
||||
aria-label={t("Copy link")}
|
||||
size={32}
|
||||
icon={<LinkIcon />}
|
||||
@@ -742,9 +521,8 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
</CopyToClipboard>
|
||||
</Tooltip>
|
||||
<Tooltip content={t("Download")} placement="bottom">
|
||||
<ActionButton
|
||||
<Button
|
||||
tabIndex={-1}
|
||||
disabled={status.image === ImageStatus.ERROR}
|
||||
onClick={download}
|
||||
aria-label={t("Download")}
|
||||
size={32}
|
||||
@@ -756,7 +534,7 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
<Separator />
|
||||
<Dialog.Close asChild>
|
||||
<Tooltip content={t("Close")} shortcut="Esc" placement="bottom">
|
||||
<ActionButton
|
||||
<Button
|
||||
tabIndex={-1}
|
||||
onClick={close}
|
||||
aria-label={t("Close")}
|
||||
@@ -768,87 +546,49 @@ function Lightbox({ images, activeImage, onUpdate, onClose }: Props) {
|
||||
</Tooltip>
|
||||
</Dialog.Close>
|
||||
</Actions>
|
||||
{currentImageIndex > 0 &&
|
||||
!(
|
||||
status.image === ImageStatus.ZOOMED ||
|
||||
status.image === ImageStatus.MAX_ZOOM
|
||||
) && (
|
||||
<Nav dir="left" $hidden={isIdle} animation={animation.current}>
|
||||
<NavButton onClick={prev} size={32} aria-label={t("Previous")}>
|
||||
<BackIcon size={32} />
|
||||
</NavButton>
|
||||
</Nav>
|
||||
)}
|
||||
<ZoomablePannablePinchable
|
||||
panningDisabled={
|
||||
!(
|
||||
status.image === ImageStatus.ZOOMED ||
|
||||
status.image === ImageStatus.MAX_ZOOM
|
||||
)
|
||||
{currentImageIndex > 0 && (
|
||||
<Nav dir="left" $hidden={isIdle} animation={animation.current}>
|
||||
<NavButton onClick={prev} size={32} aria-label={t("Previous")}>
|
||||
<BackIcon size={32} />
|
||||
</NavButton>
|
||||
</Nav>
|
||||
)}
|
||||
<Image
|
||||
ref={imgRef}
|
||||
src={activeImage.getSrc()}
|
||||
alt={activeImage.getAlt()}
|
||||
onLoading={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.LOADING,
|
||||
})
|
||||
}
|
||||
disabled={status.image === ImageStatus.ERROR}
|
||||
ref={zoomPanPinchRef}
|
||||
onClose={close}
|
||||
>
|
||||
<Image
|
||||
ref={imgRef}
|
||||
src={activeImage.getSrc()}
|
||||
alt={activeImage.getAlt()}
|
||||
onLoading={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.LOADING,
|
||||
})
|
||||
}
|
||||
onLoad={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.LOADED,
|
||||
})
|
||||
}
|
||||
onError={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.ERROR,
|
||||
})
|
||||
}
|
||||
onSwipeRight={prev}
|
||||
onSwipeLeft={next}
|
||||
onSwipeUp={close}
|
||||
onSwipeDown={close}
|
||||
status={status}
|
||||
animation={animation.current}
|
||||
onMinZoom={() => {
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.MIN_ZOOM,
|
||||
});
|
||||
}}
|
||||
onZoom={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.ZOOMED,
|
||||
})
|
||||
}
|
||||
onMaxZoom={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.MAX_ZOOM,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</ZoomablePannablePinchable>
|
||||
{currentImageIndex < images.length - 1 &&
|
||||
!(
|
||||
status.image === ImageStatus.ZOOMED ||
|
||||
status.image === ImageStatus.MAX_ZOOM
|
||||
) && (
|
||||
<Nav dir="right" $hidden={isIdle} animation={animation.current}>
|
||||
<NavButton onClick={next} size={32} aria-label={t("Next")}>
|
||||
<NextIcon size={32} />
|
||||
</NavButton>
|
||||
</Nav>
|
||||
)}
|
||||
onLoad={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.LOADED,
|
||||
})
|
||||
}
|
||||
onError={() =>
|
||||
setStatus({
|
||||
lightbox: status.lightbox,
|
||||
image: ImageStatus.ERROR,
|
||||
})
|
||||
}
|
||||
onSwipeRight={prev}
|
||||
onSwipeLeft={next}
|
||||
onSwipeUp={close}
|
||||
onSwipeDown={close}
|
||||
status={status}
|
||||
animation={animation.current}
|
||||
/>
|
||||
{currentImageIndex < images.length - 1 && (
|
||||
<Nav dir="right" $hidden={isIdle} animation={animation.current}>
|
||||
<NavButton onClick={next} size={32} aria-label={t("Next")}>
|
||||
<NextIcon size={32} />
|
||||
</NavButton>
|
||||
</Nav>
|
||||
)}
|
||||
</StyledContent>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
@@ -867,9 +607,6 @@ type ImageProps = {
|
||||
onSwipeDown: () => void;
|
||||
status: Status;
|
||||
animation: Animation | null;
|
||||
onMinZoom: () => void;
|
||||
onZoom: () => void;
|
||||
onMaxZoom: () => void;
|
||||
};
|
||||
|
||||
const Image = forwardRef<HTMLImageElement, ImageProps>(function _Image(
|
||||
@@ -885,9 +622,6 @@ const Image = forwardRef<HTMLImageElement, ImageProps>(function _Image(
|
||||
onSwipeDown,
|
||||
status,
|
||||
animation,
|
||||
onMinZoom,
|
||||
onZoom,
|
||||
onMaxZoom,
|
||||
}: ImageProps,
|
||||
ref
|
||||
) {
|
||||
@@ -900,25 +634,6 @@ const Image = forwardRef<HTMLImageElement, ImageProps>(function _Image(
|
||||
onSwipeDown,
|
||||
});
|
||||
|
||||
const { isImagePanning } = useContext(ZoomPanPinchContext);
|
||||
|
||||
useTransformEffect(({ state, instance }) => {
|
||||
const minScale = instance.props.minScale ?? 1;
|
||||
const maxScale = instance.props.maxScale ?? 8;
|
||||
const { scale } = state;
|
||||
if (scale === minScale && status.image === ImageStatus.ZOOMED) {
|
||||
onMinZoom();
|
||||
} else if (scale === maxScale && status.image === ImageStatus.ZOOMED) {
|
||||
onMaxZoom();
|
||||
} else if (
|
||||
scale > minScale &&
|
||||
scale < maxScale &&
|
||||
status.image !== ImageStatus.ZOOMED
|
||||
) {
|
||||
onZoom();
|
||||
}
|
||||
});
|
||||
|
||||
const [hidden, setHidden] = useState(
|
||||
status.image === null || status.image === ImageStatus.LOADING
|
||||
);
|
||||
@@ -953,15 +668,9 @@ const Image = forwardRef<HTMLImageElement, ImageProps>(function _Image(
|
||||
onError={onError}
|
||||
onLoad={onLoad}
|
||||
$hidden={hidden}
|
||||
$zoomedIn={
|
||||
status.image === ImageStatus.ZOOMED ||
|
||||
status.image === ImageStatus.MAX_ZOOM
|
||||
}
|
||||
$zoomedOut={status.image === ImageStatus.MIN_ZOOM}
|
||||
$panning={isImagePanning}
|
||||
/>
|
||||
<Caption>
|
||||
{status.image === ImageStatus.MIN_ZOOM &&
|
||||
{status.image === ImageStatus.LOADED &&
|
||||
status.lightbox === LightboxStatus.OPENED ? (
|
||||
<Fade>{alt}</Fade>
|
||||
) : null}
|
||||
@@ -1017,25 +726,12 @@ const StyledOverlay = styled(Dialog.Overlay)<{
|
||||
|
||||
const StyledImg = styled.img<{
|
||||
$hidden: boolean;
|
||||
$zoomedIn: boolean;
|
||||
$zoomedOut: boolean;
|
||||
$panning: boolean;
|
||||
animation: Animation | null;
|
||||
}>`
|
||||
visibility: ${(props) => (props.$hidden ? "hidden" : "visible")};
|
||||
pointer-events: auto !important;
|
||||
max-width: 100%;
|
||||
min-height: 0;
|
||||
object-fit: contain;
|
||||
cursor: ${(props) =>
|
||||
props.$panning
|
||||
? "grabbing"
|
||||
: props.$zoomedOut
|
||||
? "zoom-in"
|
||||
: props.$zoomedIn
|
||||
? "zoom-out"
|
||||
: "default"};
|
||||
|
||||
${(props) =>
|
||||
props.animation?.zoomIn
|
||||
? css`
|
||||
@@ -1047,12 +743,7 @@ const StyledImg = styled.img<{
|
||||
animation: ${props.animation.zoomOut.apply()}
|
||||
${props.animation.zoomOut.duration}ms;
|
||||
`
|
||||
: props.animation?.fadeOut
|
||||
? css`
|
||||
animation: ${props.animation.fadeOut.apply()}
|
||||
${props.animation.fadeOut.duration}ms;
|
||||
`
|
||||
: ""}
|
||||
: ""}
|
||||
`;
|
||||
|
||||
const StyledContent = styled(Dialog.Content)`
|
||||
@@ -1063,10 +754,7 @@ const StyledContent = styled(Dialog.Content)`
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
outline: none;
|
||||
`;
|
||||
|
||||
const ActionButton = styled(Button)`
|
||||
background: transparent;
|
||||
padding: 56px;
|
||||
`;
|
||||
|
||||
const Actions = styled.div<{
|
||||
@@ -1079,10 +767,6 @@ const Actions = styled.div<{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
z-index: ${depths.modal};
|
||||
background: ${(props) => transparentize(0.2, props.theme.background)};
|
||||
backdrop-filter: blur(4px);
|
||||
border-radius: 6px;
|
||||
|
||||
${(props) =>
|
||||
props.animation === null
|
||||
@@ -1110,7 +794,6 @@ const Nav = styled.div<{
|
||||
position: absolute;
|
||||
${(props) => (props.dir === "left" ? "left: 0;" : "right: 0;")}
|
||||
transition: opacity 500ms ease-in-out;
|
||||
z-index: ${depths.modal};
|
||||
${(props) => props.$hidden && "opacity: 0;"}
|
||||
${(props) =>
|
||||
props.animation === null
|
||||
|
||||
@@ -11,12 +11,9 @@ import {
|
||||
} from "~/components/primitives/Menu";
|
||||
import * as Components from "~/components/primitives/components/Menu";
|
||||
import { MenuItem } from "~/types";
|
||||
import { MouseSafeArea } from "~/components/MouseSafeArea";
|
||||
import { createRef } from "react";
|
||||
|
||||
export function toMenuItems(items: MenuItem[]) {
|
||||
const filteredItems = filterMenuItems(items);
|
||||
const parentRef = createRef<HTMLDivElement>();
|
||||
|
||||
if (!filteredItems.length) {
|
||||
return null;
|
||||
@@ -91,10 +88,7 @@ export function toMenuItems(items: MenuItem[]) {
|
||||
icon={icon}
|
||||
disabled={item.disabled}
|
||||
/>
|
||||
<SubMenuContent ref={parentRef}>
|
||||
<MouseSafeArea parentRef={parentRef} />
|
||||
{submenuItems}
|
||||
</SubMenuContent>
|
||||
<SubMenuContent>{submenuItems}</SubMenuContent>
|
||||
</SubMenu>
|
||||
);
|
||||
}
|
||||
|
||||
+14
-21
@@ -22,8 +22,6 @@ type Props = {
|
||||
isOpen: boolean;
|
||||
title?: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
onRequestClose: () => void;
|
||||
};
|
||||
|
||||
@@ -32,8 +30,6 @@ const Modal: React.FC<Props> = ({
|
||||
isOpen,
|
||||
title = "Untitled",
|
||||
style,
|
||||
width,
|
||||
height,
|
||||
onRequestClose,
|
||||
}: Props) => {
|
||||
const wasOpen = usePrevious(isOpen);
|
||||
@@ -61,7 +57,7 @@ const Modal: React.FC<Props> = ({
|
||||
>
|
||||
{isMobile ? (
|
||||
<Mobile>
|
||||
<MobileContent>
|
||||
<Content>
|
||||
<Centered onClick={(ev) => ev.stopPropagation()} column>
|
||||
{title && (
|
||||
<Text size="xlarge" weight="bold">
|
||||
@@ -70,7 +66,7 @@ const Modal: React.FC<Props> = ({
|
||||
)}
|
||||
<ErrorBoundary>{children}</ErrorBoundary>
|
||||
</Centered>
|
||||
</MobileContent>
|
||||
</Content>
|
||||
<Close onClick={onRequestClose}>
|
||||
<CloseIcon size={32} />
|
||||
</Close>
|
||||
@@ -80,7 +76,7 @@ const Modal: React.FC<Props> = ({
|
||||
</Back>
|
||||
</Mobile>
|
||||
) : (
|
||||
<Wrapper $width={width} $height={height}>
|
||||
<Small>
|
||||
<Centered
|
||||
onClick={(ev) => ev.stopPropagation()}
|
||||
// maxHeight needed for proper overflow behavior in Safari
|
||||
@@ -88,9 +84,9 @@ const Modal: React.FC<Props> = ({
|
||||
column
|
||||
reverse
|
||||
>
|
||||
<DesktopContent style={style} shadow>
|
||||
<SmallContent style={style} shadow>
|
||||
<ErrorBoundary component="div">{children}</ErrorBoundary>
|
||||
</DesktopContent>
|
||||
</SmallContent>
|
||||
<Header>
|
||||
{title && <Text size="large">{title}</Text>}
|
||||
<NudeButton onClick={onRequestClose}>
|
||||
@@ -98,7 +94,7 @@ const Modal: React.FC<Props> = ({
|
||||
</NudeButton>
|
||||
</Header>
|
||||
</Centered>
|
||||
</Wrapper>
|
||||
</Small>
|
||||
)}
|
||||
</StyledContent>
|
||||
</Dialog.Portal>
|
||||
@@ -146,7 +142,7 @@ const Mobile = styled.div`
|
||||
outline: none;
|
||||
`;
|
||||
|
||||
const MobileContent = styled(Scrollable)`
|
||||
const Content = styled(Scrollable)`
|
||||
width: 100%;
|
||||
padding: 8vh 12px;
|
||||
|
||||
@@ -155,10 +151,6 @@ const MobileContent = styled(Scrollable)`
|
||||
`};
|
||||
`;
|
||||
|
||||
const DesktopContent = styled(Scrollable)`
|
||||
padding: 8px 24px 24px;
|
||||
`;
|
||||
|
||||
const Centered = styled(Flex)`
|
||||
width: 640px;
|
||||
max-width: 100%;
|
||||
@@ -215,17 +207,14 @@ const Header = styled(Flex)`
|
||||
padding: 24px 24px 12px;
|
||||
`;
|
||||
|
||||
const Wrapper = styled.div<{
|
||||
$width?: number | string;
|
||||
$height?: number | string;
|
||||
}>`
|
||||
const Small = styled.div`
|
||||
animation: ${fadeAndScaleIn} 250ms ease;
|
||||
|
||||
margin: 25vh auto auto auto;
|
||||
width: 75vw;
|
||||
min-width: 350px;
|
||||
max-width: ${(props) => props.$width || "450px"};
|
||||
max-height: ${(props) => props.$height || "70vh"};
|
||||
max-width: 450px;
|
||||
max-height: 65vh;
|
||||
z-index: ${depths.modal};
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@@ -248,4 +237,8 @@ const Wrapper = styled.div<{
|
||||
}
|
||||
`;
|
||||
|
||||
const SmallContent = styled(Scrollable)`
|
||||
padding: 8px 24px 24px;
|
||||
`;
|
||||
|
||||
export default observer(Modal);
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { useMousePosition } from "~/hooks/useMousePosition";
|
||||
import usePrevious from "~/hooks/usePrevious";
|
||||
import useStores from "~/hooks/useStores";
|
||||
|
||||
type Positions = {
|
||||
/** Sub-menu x */
|
||||
x: number;
|
||||
/** Sub-menu y */
|
||||
y: number;
|
||||
/** Sub-menu height */
|
||||
h: number;
|
||||
/** Sub-menu width */
|
||||
w: number;
|
||||
/** Mouse x */
|
||||
mouseX: number;
|
||||
/** Mouse y */
|
||||
mouseY: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Component to cover the area between the mouse cursor and the sub-menu, to
|
||||
* allow moving cursor to lower parts of sub-menu without the sub-menu
|
||||
* disappearing.
|
||||
*/
|
||||
export const MouseSafeArea = observer(function MouseSafeArea_(props: {
|
||||
parentRef: React.RefObject<HTMLElement | null>;
|
||||
}) {
|
||||
const {
|
||||
x = 0,
|
||||
y = 0,
|
||||
height: h = 0,
|
||||
width: w = 0,
|
||||
} = props.parentRef.current?.getBoundingClientRect() || {};
|
||||
const { ui } = useStores();
|
||||
const [mouseX, mouseY] = useMousePosition();
|
||||
const [isVisible, setIsVisible] = React.useState(true);
|
||||
const positions = { x, y, h, w, mouseX, mouseY };
|
||||
const distance = Math.abs(mouseX - x);
|
||||
const prevDistance = usePrevious(distance) ?? distance;
|
||||
|
||||
// Hide the safe area if the mouse is moving _away_ from the menu
|
||||
React.useEffect(() => {
|
||||
if (distance > prevDistance) {
|
||||
setIsVisible(false);
|
||||
} else if (distance < prevDistance) {
|
||||
setIsVisible(true);
|
||||
}
|
||||
}, [distance, prevDistance]);
|
||||
|
||||
if (!isVisible) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
backgroundColor: ui.debugSafeArea ? "rgba(255,0,0,0.2)" : undefined,
|
||||
right: getRight(positions),
|
||||
left: getLeft(positions),
|
||||
height: h,
|
||||
width: getWidth(positions),
|
||||
clipPath: getClipPath(positions),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
const buffer = 10;
|
||||
|
||||
const getLeft = ({ x, mouseX }: Positions) =>
|
||||
mouseX > x ? undefined : -Math.max(x - mouseX + buffer, buffer) + "px";
|
||||
|
||||
const getRight = ({ x, w, mouseX }: Positions) =>
|
||||
mouseX > x ? -Math.max(mouseX - (x + w) + buffer, buffer) + "px" : undefined;
|
||||
|
||||
const getWidth = ({ x, w, mouseX }: Positions) =>
|
||||
mouseX > x
|
||||
? Math.max(mouseX - (x + w - buffer), buffer) + "px"
|
||||
: Math.max(x - mouseX + buffer, buffer) + "px";
|
||||
|
||||
const getClipPath = ({ x, y, h, mouseX, mouseY }: Positions) =>
|
||||
mouseX > x
|
||||
? `polygon(0% 0%, 0% 100%, 100% ${
|
||||
(100 * (mouseY - y)) / h + 5
|
||||
}%, 100% ${(100 * (mouseY - y)) / h - buffer}%)`
|
||||
: `polygon(100% 0%, 0% ${(100 * (mouseY - y)) / h - buffer}%, 0% ${
|
||||
(100 * (mouseY - y)) / h + 5
|
||||
}%, 100% 100%)`;
|
||||
@@ -47,7 +47,7 @@ function SharedSidebar({ share }: Props) {
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledSidebar $hoverTransition={!teamAvailable} canResize={false}>
|
||||
<StyledSidebar $hoverTransition={!teamAvailable}>
|
||||
{teamAvailable && (
|
||||
<SidebarButton
|
||||
title={team.name}
|
||||
@@ -57,7 +57,9 @@ function SharedSidebar({ share }: Props) {
|
||||
onClick={() =>
|
||||
history.push(user ? homePath() : sharedModelPath(shareId))
|
||||
}
|
||||
/>
|
||||
>
|
||||
<ToggleSidebar />
|
||||
</SidebarButton>
|
||||
)}
|
||||
<ScrollContainer topShadow flex>
|
||||
<TopSection>
|
||||
@@ -144,8 +146,7 @@ const StyledSidebar = styled(Sidebar)<{ $hoverTransition: boolean }>`
|
||||
${({ $hoverTransition }) =>
|
||||
$hoverTransition &&
|
||||
`
|
||||
@media (hover: hover) {
|
||||
&:${hover} {
|
||||
&: ${hover} {
|
||||
${StyledSearchPopover} {
|
||||
width: 85%;
|
||||
}
|
||||
@@ -153,7 +154,6 @@ const StyledSidebar = styled(Sidebar)<{ $hoverTransition: boolean }>`
|
||||
${ToggleWrapper} {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
`}
|
||||
|
||||
@@ -25,15 +25,13 @@ import { useTranslation } from "react-i18next";
|
||||
const ANIMATION_MS = 250;
|
||||
|
||||
type Props = {
|
||||
hidden?: boolean;
|
||||
/** Whether the sidebar can be resized and collapsed, defaults to true. */
|
||||
canResize?: boolean;
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
hidden?: boolean;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const Sidebar = React.forwardRef<HTMLDivElement, Props>(function _Sidebar(
|
||||
{ children, hidden = false, canResize = true, className }: Props,
|
||||
{ children, hidden = false, className }: Props,
|
||||
ref: React.RefObject<HTMLDivElement>
|
||||
) {
|
||||
const [isCollapsing, setCollapsing] = React.useState(false);
|
||||
@@ -45,7 +43,7 @@ const Sidebar = React.forwardRef<HTMLDivElement, Props>(function _Sidebar(
|
||||
const user = useCurrentUser({ rejectOnEmpty: false });
|
||||
const isMobile = useMobile();
|
||||
const width = ui.sidebarWidth;
|
||||
const collapsed = ui.sidebarIsClosed && canResize;
|
||||
const collapsed = ui.sidebarIsClosed;
|
||||
const maxWidth = theme.sidebarMaxWidth;
|
||||
const minWidth = theme.sidebarMinWidth + 16; // padding
|
||||
|
||||
@@ -256,12 +254,10 @@ const Sidebar = React.forwardRef<HTMLDivElement, Props>(function _Sidebar(
|
||||
</SidebarButton>
|
||||
</AccountMenu>
|
||||
)}
|
||||
{canResize && (
|
||||
<ResizeBorder
|
||||
onMouseDown={handleMouseDown}
|
||||
onDoubleClick={ui.sidebarIsClosed ? undefined : handleReset}
|
||||
/>
|
||||
)}
|
||||
<ResizeBorder
|
||||
onMouseDown={handleMouseDown}
|
||||
onDoubleClick={ui.sidebarIsClosed ? undefined : handleReset}
|
||||
/>
|
||||
</Container>
|
||||
{ui.mobileSidebarVisible && <Backdrop onClick={ui.toggleMobileSidebar} />}
|
||||
</TooltipProvider>
|
||||
|
||||
@@ -86,33 +86,27 @@ const CollectionLink: React.FC<Props> = ({
|
||||
editableTitleRef.current?.setIsEditing(true);
|
||||
}, [editableTitleRef]);
|
||||
|
||||
const newChildTitleRef = React.useRef<RefHandle>(null);
|
||||
const [isAddingNewChild, setIsAddingNewChild, closeAddingNewChild] =
|
||||
useBoolean();
|
||||
|
||||
const handleNewDoc = React.useCallback(
|
||||
async (input) => {
|
||||
try {
|
||||
newChildTitleRef.current?.setIsEditing(false);
|
||||
const newDocument = await documents.create(
|
||||
{
|
||||
collectionId: collection.id,
|
||||
title: input,
|
||||
fullWidth: user.getPreference(UserPreference.FullWidthDocuments),
|
||||
data: ProsemirrorHelper.getEmptyDocument(),
|
||||
},
|
||||
{ publish: true }
|
||||
);
|
||||
collection?.addDocument(newDocument);
|
||||
const newDocument = await documents.create(
|
||||
{
|
||||
collectionId: collection.id,
|
||||
title: input,
|
||||
fullWidth: user.getPreference(UserPreference.FullWidthDocuments),
|
||||
data: ProsemirrorHelper.getEmptyDocument(),
|
||||
},
|
||||
{ publish: true }
|
||||
);
|
||||
collection?.addDocument(newDocument);
|
||||
|
||||
closeAddingNewChild();
|
||||
history.push({
|
||||
pathname: documentEditPath(newDocument),
|
||||
state: { sidebarContext },
|
||||
});
|
||||
} catch (_err) {
|
||||
newChildTitleRef.current?.setIsEditing(true);
|
||||
}
|
||||
closeAddingNewChild();
|
||||
history.push({
|
||||
pathname: documentEditPath(newDocument),
|
||||
state: { sidebarContext },
|
||||
});
|
||||
},
|
||||
[user, sidebarContext, closeAddingNewChild, history, collection, documents]
|
||||
);
|
||||
@@ -198,7 +192,6 @@ const CollectionLink: React.FC<Props> = ({
|
||||
onCancel={closeAddingNewChild}
|
||||
onSubmit={handleNewDoc}
|
||||
maxLength={DocumentValidation.maxTitleLength}
|
||||
ref={newChildTitleRef}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -22,7 +22,7 @@ function Disclosure({ onClick, root, expanded, ...rest }: Props) {
|
||||
aria-label={expanded ? t("Collapse") : t("Expand")}
|
||||
{...rest}
|
||||
>
|
||||
<StyledCollapsedIcon $expanded={expanded} size={20} />
|
||||
<StyledCollapsedIcon expanded={expanded} size={20} />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -52,13 +52,13 @@ const Button = styled(NudeButton)<{ $root?: boolean }>`
|
||||
`;
|
||||
|
||||
const StyledCollapsedIcon = styled(CollapsedIcon)<{
|
||||
$expanded?: boolean;
|
||||
expanded?: boolean;
|
||||
}>`
|
||||
transition:
|
||||
opacity 100ms ease,
|
||||
transform 100ms ease,
|
||||
fill 50ms !important;
|
||||
${(props) => !props.$expanded && "transform: rotate(-90deg);"};
|
||||
${(props) => !props.expanded && "transform: rotate(-90deg);"};
|
||||
`;
|
||||
|
||||
// Enables identifying this component within styled components
|
||||
|
||||
@@ -281,36 +281,30 @@ function InnerDocumentLink(
|
||||
[setExpanded, setCollapsed, hasChildren, expanded]
|
||||
);
|
||||
|
||||
const newChildTitleRef = React.useRef<RefHandle>(null);
|
||||
const [isAddingNewChild, setIsAddingNewChild, closeAddingNewChild] =
|
||||
useBoolean();
|
||||
|
||||
const handleNewDoc = React.useCallback(
|
||||
async (input) => {
|
||||
try {
|
||||
newChildTitleRef.current?.setIsEditing(false);
|
||||
const newDocument = await documents.create(
|
||||
{
|
||||
collectionId: collection?.id,
|
||||
parentDocumentId: node.id,
|
||||
fullWidth:
|
||||
doc?.fullWidth ??
|
||||
user.getPreference(UserPreference.FullWidthDocuments),
|
||||
title: input,
|
||||
data: ProsemirrorHelper.getEmptyDocument(),
|
||||
},
|
||||
{ publish: true }
|
||||
);
|
||||
collection?.addDocument(newDocument, node.id);
|
||||
const newDocument = await documents.create(
|
||||
{
|
||||
collectionId: collection?.id,
|
||||
parentDocumentId: node.id,
|
||||
fullWidth:
|
||||
doc?.fullWidth ??
|
||||
user.getPreference(UserPreference.FullWidthDocuments),
|
||||
title: input,
|
||||
data: ProsemirrorHelper.getEmptyDocument(),
|
||||
},
|
||||
{ publish: true }
|
||||
);
|
||||
collection?.addDocument(newDocument, node.id);
|
||||
|
||||
closeAddingNewChild();
|
||||
history.push({
|
||||
pathname: documentEditPath(newDocument),
|
||||
state: { sidebarContext },
|
||||
});
|
||||
} catch (_err) {
|
||||
newChildTitleRef.current?.setIsEditing(true);
|
||||
}
|
||||
closeAddingNewChild();
|
||||
history.push({
|
||||
pathname: documentEditPath(newDocument),
|
||||
state: { sidebarContext },
|
||||
});
|
||||
},
|
||||
[
|
||||
documents,
|
||||
@@ -326,62 +320,6 @@ function InnerDocumentLink(
|
||||
|
||||
const contextMenuAction = useDocumentMenuAction({ documentId: node.id });
|
||||
|
||||
const labelElement = React.useMemo(
|
||||
() => (
|
||||
<EditableTitle
|
||||
title={title}
|
||||
onSubmit={handleTitleChange}
|
||||
isEditing={isEditing}
|
||||
onEditing={setIsEditing}
|
||||
canUpdate={canUpdate}
|
||||
maxLength={DocumentValidation.maxTitleLength}
|
||||
ref={editableTitleRef}
|
||||
/>
|
||||
),
|
||||
[title, handleTitleChange, isEditing, setIsEditing, canUpdate]
|
||||
);
|
||||
|
||||
const menuElement = React.useMemo(
|
||||
() =>
|
||||
document && !isMoving && !isEditing && !isDraggingAnyDocument ? (
|
||||
<Fade>
|
||||
{can.createChildDocument && (
|
||||
<Tooltip content={t("New doc")}>
|
||||
<NudeButton
|
||||
aria-label={t("New nested document")}
|
||||
onClick={(ev) => {
|
||||
ev.preventDefault();
|
||||
setIsAddingNewChild();
|
||||
setExpanded();
|
||||
}}
|
||||
>
|
||||
<PlusIcon />
|
||||
</NudeButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
<DocumentMenu
|
||||
document={document}
|
||||
onRename={handleRename}
|
||||
onOpen={handleMenuOpen}
|
||||
onClose={handleMenuClose}
|
||||
/>
|
||||
</Fade>
|
||||
) : undefined,
|
||||
[
|
||||
document,
|
||||
isMoving,
|
||||
isEditing,
|
||||
isDraggingAnyDocument,
|
||||
can.createChildDocument,
|
||||
t,
|
||||
setIsAddingNewChild,
|
||||
setExpanded,
|
||||
handleRename,
|
||||
handleMenuOpen,
|
||||
handleMenuClose,
|
||||
]
|
||||
);
|
||||
|
||||
return (
|
||||
<ActionContextProvider
|
||||
value={{
|
||||
@@ -407,7 +345,17 @@ function InnerDocumentLink(
|
||||
contextAction={contextMenuAction}
|
||||
to={toPath}
|
||||
icon={iconElement}
|
||||
label={labelElement}
|
||||
label={
|
||||
<EditableTitle
|
||||
title={title}
|
||||
onSubmit={handleTitleChange}
|
||||
isEditing={isEditing}
|
||||
onEditing={setIsEditing}
|
||||
canUpdate={canUpdate}
|
||||
maxLength={DocumentValidation.maxTitleLength}
|
||||
ref={editableTitleRef}
|
||||
/>
|
||||
}
|
||||
isActive={isActiveCheck}
|
||||
isActiveDrop={isOverReparent && canDropToReparent}
|
||||
depth={depth}
|
||||
@@ -416,7 +364,35 @@ function InnerDocumentLink(
|
||||
scrollIntoViewIfNeeded={sidebarContext === "collections"}
|
||||
isDraft={isDraft}
|
||||
ref={ref}
|
||||
menu={menuElement}
|
||||
menu={
|
||||
document &&
|
||||
!isMoving &&
|
||||
!isEditing &&
|
||||
!isDraggingAnyDocument ? (
|
||||
<Fade>
|
||||
{can.createChildDocument && (
|
||||
<Tooltip content={t("New doc")}>
|
||||
<NudeButton
|
||||
aria-label={t("New nested document")}
|
||||
onClick={(ev) => {
|
||||
ev.preventDefault();
|
||||
setIsAddingNewChild();
|
||||
setExpanded();
|
||||
}}
|
||||
>
|
||||
<PlusIcon />
|
||||
</NudeButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
<DocumentMenu
|
||||
document={document}
|
||||
onRename={handleRename}
|
||||
onOpen={handleMenuOpen}
|
||||
onClose={handleMenuClose}
|
||||
/>
|
||||
</Fade>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
</DropToImport>
|
||||
</div>
|
||||
@@ -438,7 +414,6 @@ function InnerDocumentLink(
|
||||
onCancel={closeAddingNewChild}
|
||||
onSubmit={handleNewDoc}
|
||||
maxLength={DocumentValidation.maxTitleLength}
|
||||
ref={newChildTitleRef}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -8,32 +8,19 @@ import Relative from "./Relative";
|
||||
import SharedWithMeLink from "./SharedWithMeLink";
|
||||
import SidebarContext, { groupSidebarContext } from "./SidebarContext";
|
||||
import SidebarLink from "./SidebarLink";
|
||||
import { RequestResponse } from "~/hooks/usePaginatedRequest";
|
||||
import GroupMembership from "~/models/GroupMembership";
|
||||
import { t } from "i18next";
|
||||
import { toast } from "sonner";
|
||||
|
||||
type Props = {
|
||||
/** The group to render */
|
||||
group: Group;
|
||||
/** The response from the group memberships request */
|
||||
response: RequestResponse<GroupMembership>;
|
||||
};
|
||||
|
||||
const GroupLink: React.FC<Props> = ({ group, response }) => {
|
||||
const GroupLink: React.FC<Props> = ({ group }) => {
|
||||
const locationSidebarContext = useLocationSidebarContext();
|
||||
const sidebarContext = groupSidebarContext(group.id);
|
||||
const { loading, next, end, error } = response;
|
||||
const [expanded, setExpanded] = React.useState(
|
||||
locationSidebarContext === sidebarContext
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (error) {
|
||||
toast.error(t("Could not load shared documents"));
|
||||
}
|
||||
}, [error, t]);
|
||||
|
||||
const handleDisclosureClick = React.useCallback((ev) => {
|
||||
ev?.preventDefault();
|
||||
setExpanded((e) => !e);
|
||||
@@ -63,14 +50,6 @@ const GroupLink: React.FC<Props> = ({ group, response }) => {
|
||||
depth={1}
|
||||
/>
|
||||
))}
|
||||
{!end && (
|
||||
<SidebarLink
|
||||
onClick={next}
|
||||
label={`${t("Show more")}…`}
|
||||
disabled={loading}
|
||||
depth={0}
|
||||
/>
|
||||
)}
|
||||
</Folder>
|
||||
</SidebarContext.Provider>
|
||||
</Relative>
|
||||
|
||||
@@ -41,7 +41,7 @@ export const Header: React.FC<Props> = ({ id, title, children }: Props) => {
|
||||
<H3>
|
||||
<Button onClick={handleClick} disabled={!id}>
|
||||
{title}
|
||||
{id && <Disclosure $expanded={expanded} size={20} />}
|
||||
{id && <Disclosure expanded={expanded} size={20} />}
|
||||
</Button>
|
||||
</H3>
|
||||
{expanded && (firstRender ? children : <Fade>{children}</Fade>)}
|
||||
@@ -91,12 +91,12 @@ const Button = styled.button`
|
||||
}
|
||||
`;
|
||||
|
||||
const Disclosure = styled(CollapsedIcon)<{ $expanded?: boolean }>`
|
||||
const Disclosure = styled(CollapsedIcon)<{ expanded?: boolean }>`
|
||||
transition:
|
||||
opacity 100ms ease,
|
||||
transform 100ms ease,
|
||||
fill 50ms !important;
|
||||
${(props) => !props.$expanded && "transform: rotate(-90deg);"};
|
||||
${({ expanded }) => !expanded && "transform: rotate(-90deg);"};
|
||||
opacity: 0;
|
||||
`;
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ function SharedWithMe() {
|
||||
const history = useHistory();
|
||||
const locationSidebarContext = useLocationSidebarContext();
|
||||
|
||||
const gmResponse = usePaginatedRequest<GroupMembership>(
|
||||
groupMemberships.fetchAll
|
||||
);
|
||||
usePaginatedRequest<GroupMembership>(groupMemberships.fetchAll);
|
||||
|
||||
const { loading, next, end, error, page } =
|
||||
usePaginatedRequest<UserMembership>(userMemberships.fetchPage, {
|
||||
@@ -110,7 +108,7 @@ function SharedWithMe() {
|
||||
<Flex column>
|
||||
<Header id="shared" title={t("Shared with me")}>
|
||||
{user.groupsWithDocumentMemberships.map((group) => (
|
||||
<GroupLink key={group.id} group={group} response={gmResponse} />
|
||||
<GroupLink key={group.id} group={group} />
|
||||
))}
|
||||
<Relative>
|
||||
{reorderProps.isDragging && (
|
||||
|
||||
@@ -85,8 +85,11 @@ function StarredDocumentLink({
|
||||
const { collections, documents } = useStores();
|
||||
|
||||
const document = documents.get(documentId);
|
||||
if (!document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const documentCollection = document?.collectionId
|
||||
const documentCollection = document.collectionId
|
||||
? collections.get(document.collectionId)
|
||||
: undefined;
|
||||
const childDocuments = documentCollection
|
||||
@@ -94,11 +97,7 @@ function StarredDocumentLink({
|
||||
: [];
|
||||
const hasChildDocuments = childDocuments.length > 0;
|
||||
const displayChildDocuments = expanded && !isDragging;
|
||||
const contextMenuAction = useDocumentMenuAction({ documentId });
|
||||
|
||||
if (!document) {
|
||||
return null;
|
||||
}
|
||||
const contextMenuAction = useDocumentMenuAction({ documentId: document.id });
|
||||
|
||||
return (
|
||||
<ActionContextProvider
|
||||
|
||||
@@ -7,28 +7,18 @@ export default function useCollectionDocuments(
|
||||
collection: Collection | undefined,
|
||||
activeDocument: Document | undefined
|
||||
) {
|
||||
const insertDraftDocument = useMemo(
|
||||
() =>
|
||||
activeDocument &&
|
||||
activeDocument.isActive &&
|
||||
activeDocument.isDraft &&
|
||||
activeDocument.collectionId === collection?.id &&
|
||||
!activeDocument.parentDocumentId,
|
||||
[
|
||||
activeDocument?.isActive,
|
||||
activeDocument?.isDraft,
|
||||
activeDocument?.collectionId,
|
||||
activeDocument?.parentDocumentId,
|
||||
collection?.id,
|
||||
]
|
||||
);
|
||||
|
||||
return useMemo(() => {
|
||||
if (!collection?.sortedDocuments) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return insertDraftDocument && activeDocument
|
||||
const insertDraftDocument =
|
||||
activeDocument?.isActive &&
|
||||
activeDocument?.isDraft &&
|
||||
activeDocument?.collectionId === collection.id &&
|
||||
!activeDocument?.parentDocumentId;
|
||||
|
||||
return insertDraftDocument
|
||||
? sortNavigationNodes(
|
||||
[activeDocument.asNavigationNode, ...collection.sortedDocuments],
|
||||
collection.sort,
|
||||
@@ -36,9 +26,14 @@ export default function useCollectionDocuments(
|
||||
)
|
||||
: collection.sortedDocuments;
|
||||
}, [
|
||||
insertDraftDocument,
|
||||
activeDocument?.isActive,
|
||||
activeDocument?.isDraft,
|
||||
activeDocument?.collectionId,
|
||||
activeDocument?.parentDocumentId,
|
||||
activeDocument?.asNavigationNode,
|
||||
collection,
|
||||
collection?.sortedDocuments,
|
||||
collection?.id,
|
||||
collection?.sort,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import breakpoint from "styled-components-breakpoint";
|
||||
import { s } from "@shared/styles";
|
||||
import Button, { Inner } from "~/components/Button";
|
||||
import Flex from "~/components/Flex";
|
||||
import Text from "~/components/Text";
|
||||
import { transparentize } from "polished";
|
||||
|
||||
export const SelectItem = forwardRef<
|
||||
HTMLDivElement,
|
||||
@@ -116,10 +114,6 @@ const ItemContainer = styled(Flex)`
|
||||
color: ${s("accentText")};
|
||||
fill: ${s("accentText")};
|
||||
}
|
||||
|
||||
${Text} {
|
||||
color: ${(props) => transparentize(0.5, props.theme.accentText)};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ const BaseMenuItemCSS = css<BaseMenuItemProps>`
|
||||
box-shadow: none;
|
||||
cursor: var(--pointer);
|
||||
|
||||
svg:not([data-fixed-color]) {
|
||||
svg {
|
||||
color: ${props.theme.accentText};
|
||||
fill: ${props.theme.accentText};
|
||||
}
|
||||
@@ -66,18 +66,22 @@ const BaseMenuItemCSS = css<BaseMenuItemProps>`
|
||||
${(props) =>
|
||||
!props.disabled &&
|
||||
`
|
||||
&:focus-visible {
|
||||
color: ${props.theme.accentText};
|
||||
background: ${props.$dangerous ? props.theme.danger : props.theme.accent};
|
||||
outline-color: ${
|
||||
props.$dangerous ? props.theme.danger : props.theme.accent
|
||||
};
|
||||
box-shadow: none;
|
||||
cursor: var(--pointer);
|
||||
|
||||
svg:not([data-fixed-color]) {
|
||||
@media (hover: hover) {
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:focus-visible {
|
||||
color: ${props.theme.accentText};
|
||||
fill: ${props.theme.accentText};
|
||||
background: ${props.$dangerous ? props.theme.danger : props.theme.accent};
|
||||
outline-color: ${
|
||||
props.$dangerous ? props.theme.danger : props.theme.accent
|
||||
};
|
||||
box-shadow: none;
|
||||
cursor: var(--pointer);
|
||||
|
||||
svg {
|
||||
color: ${props.theme.accentText};
|
||||
fill: ${props.theme.accentText};
|
||||
}
|
||||
}
|
||||
}
|
||||
`}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useCallback } from "react";
|
||||
import useDictionary from "~/hooks/useDictionary";
|
||||
import getMenuItems from "../menus/block";
|
||||
import { useEditor } from "./EditorContext";
|
||||
@@ -14,25 +13,20 @@ function BlockMenu(props: Props) {
|
||||
const dictionary = useDictionary();
|
||||
const { elementRef } = useEditor();
|
||||
|
||||
const renderMenuItem = useCallback(
|
||||
(item, _index, options) => (
|
||||
<SuggestionsMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
icon={item.icon}
|
||||
title={item.title}
|
||||
shortcut={item.shortcut}
|
||||
/>
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<SuggestionsMenu
|
||||
{...props}
|
||||
filterable
|
||||
trigger="/"
|
||||
renderMenuItem={renderMenuItem}
|
||||
renderMenuItem={(item, _index, options) => (
|
||||
<SuggestionsMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
icon={item.icon}
|
||||
title={item.title}
|
||||
shortcut={item.shortcut}
|
||||
/>
|
||||
)}
|
||||
items={getMenuItems(dictionary, elementRef)}
|
||||
/>
|
||||
);
|
||||
|
||||
+34
-28
@@ -3,57 +3,71 @@ import { Node } from "prosemirror-model";
|
||||
import { Selection, TextSelection } from "prosemirror-state";
|
||||
import { EditorView } from "prosemirror-view";
|
||||
import { useCallback, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import styled from "styled-components";
|
||||
import { getMatchingEmbed } from "@shared/editor/lib/embeds";
|
||||
import Flex from "~/components/Flex";
|
||||
import Tooltip from "~/components/Tooltip";
|
||||
import Input from "~/editor/components/Input";
|
||||
import { Dictionary } from "~/hooks/useDictionary";
|
||||
import useEmbeds from "~/hooks/useEmbeds";
|
||||
import ToolbarButton from "./ToolbarButton";
|
||||
|
||||
type Props = {
|
||||
node: Node;
|
||||
view: EditorView;
|
||||
dictionary: Dictionary;
|
||||
autoFocus?: boolean;
|
||||
};
|
||||
|
||||
export function MediaLinkEditor({ node, view, dictionary, autoFocus }: Props) {
|
||||
const url = (node.attrs.href ?? node.attrs.src) as string;
|
||||
export function EmbedLinkEditor({ node, view, dictionary }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const embeds = useEmbeds();
|
||||
|
||||
const url = node.attrs.href as string;
|
||||
const [localUrl, setLocalUrl] = useState(url);
|
||||
|
||||
const moveSelectionToEnd = useCallback(() => {
|
||||
const { state, dispatch } = view;
|
||||
|
||||
const nextSelection = Selection.findFrom(
|
||||
state.tr.doc.resolve(state.selection.from),
|
||||
1,
|
||||
true
|
||||
);
|
||||
|
||||
const selection = nextSelection ?? TextSelection.create(state.tr.doc, 0);
|
||||
|
||||
dispatch(state.tr.setSelection(selection));
|
||||
view.focus();
|
||||
}, [view]);
|
||||
|
||||
const openLink = useCallback(() => {
|
||||
const openEmbed = useCallback(() => {
|
||||
window.open(url, "_blank");
|
||||
}, [url]);
|
||||
|
||||
const remove = useCallback(() => {
|
||||
const removeEmbed = useCallback(() => {
|
||||
const { state, dispatch } = view;
|
||||
dispatch(state.tr.deleteSelection());
|
||||
}, [view]);
|
||||
|
||||
const update = useCallback(() => {
|
||||
const { state } = view;
|
||||
const hrefType = node.type.name === "image" ? "src" : "href";
|
||||
const tr = state.tr.setNodeMarkup(state.selection.from, undefined, {
|
||||
...node.attrs,
|
||||
[hrefType]: localUrl,
|
||||
});
|
||||
const updateEmbed = useCallback(() => {
|
||||
const matchingEmbed = getMatchingEmbed(embeds, localUrl);
|
||||
|
||||
if (!matchingEmbed) {
|
||||
toast.error(t("Sorry, invalid embed link"));
|
||||
return;
|
||||
}
|
||||
|
||||
const { state, dispatch } = view;
|
||||
dispatch(
|
||||
state.tr.setNodeMarkup(state.selection.from, undefined, {
|
||||
...node.attrs,
|
||||
href: localUrl,
|
||||
})
|
||||
);
|
||||
|
||||
view.dispatch(tr);
|
||||
moveSelectionToEnd();
|
||||
}, [localUrl, node, view, moveSelectionToEnd]);
|
||||
}, [t, localUrl, embeds, node, view, moveSelectionToEnd]);
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
@@ -64,7 +78,7 @@ export function MediaLinkEditor({ node, view, dictionary, autoFocus }: Props) {
|
||||
switch (event.key) {
|
||||
case "Enter": {
|
||||
event.preventDefault();
|
||||
update();
|
||||
updateEmbed();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,13 +89,12 @@ export function MediaLinkEditor({ node, view, dictionary, autoFocus }: Props) {
|
||||
}
|
||||
}
|
||||
},
|
||||
[update, moveSelectionToEnd]
|
||||
[updateEmbed, moveSelectionToEnd]
|
||||
);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<Input
|
||||
autoFocus={autoFocus}
|
||||
value={localUrl}
|
||||
placeholder={dictionary.pasteLink}
|
||||
onChange={(e) => setLocalUrl(e.target.value)}
|
||||
@@ -89,19 +102,13 @@ export function MediaLinkEditor({ node, view, dictionary, autoFocus }: Props) {
|
||||
readOnly={!view.editable}
|
||||
/>
|
||||
<Tooltip content={dictionary.openLink}>
|
||||
<ToolbarButton onClick={openLink} disabled={!localUrl}>
|
||||
<ToolbarButton onClick={openEmbed} disabled={!localUrl}>
|
||||
<OpenIcon />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
{view.editable && (
|
||||
<Tooltip
|
||||
content={
|
||||
node.type.name === "embed"
|
||||
? dictionary.deleteEmbed
|
||||
: dictionary.deleteImage
|
||||
}
|
||||
>
|
||||
<ToolbarButton onClick={remove}>
|
||||
<Tooltip content={dictionary.deleteEmbed}>
|
||||
<ToolbarButton onClick={removeEmbed}>
|
||||
<TrashIcon />
|
||||
</ToolbarButton>
|
||||
</Tooltip>
|
||||
@@ -114,5 +121,4 @@ const Wrapper = styled(Flex)`
|
||||
pointer-events: all;
|
||||
gap: 6px;
|
||||
padding: 6px;
|
||||
min-width: 350px;
|
||||
`;
|
||||
@@ -1,5 +1,5 @@
|
||||
import capitalize from "lodash/capitalize";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { emojiMartToGemoji, snakeCase } from "@shared/editor/lib/emoji";
|
||||
import { search as emojiSearch } from "@shared/utils/emoji";
|
||||
import EmojiMenuItem from "./EmojiMenuItem";
|
||||
@@ -45,23 +45,18 @@ const EmojiMenu = (props: Props) => {
|
||||
[search]
|
||||
);
|
||||
|
||||
const renderMenuItem = useCallback(
|
||||
(item, _index, options) => (
|
||||
<EmojiMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
title={item.description}
|
||||
emoji={item.emoji}
|
||||
/>
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<SuggestionsMenu
|
||||
{...props}
|
||||
filterable={false}
|
||||
renderMenuItem={renderMenuItem}
|
||||
renderMenuItem={(item, _index, options) => (
|
||||
<EmojiMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
title={item.description}
|
||||
emoji={item.emoji}
|
||||
/>
|
||||
)}
|
||||
items={items}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -47,18 +47,12 @@ function usePosition({
|
||||
}) {
|
||||
const { view } = useEditor();
|
||||
const { selection } = view.state;
|
||||
const [menuWidth, setMenuWidth] = React.useState(0);
|
||||
const menuHeight = 36;
|
||||
const menuWidth = menuRef.current?.offsetWidth ?? 0;
|
||||
const menuHeight = menuRef.current?.offsetHeight ?? 0;
|
||||
|
||||
// Measure the menu width after DOM updates to ensure accurate positioning
|
||||
React.useLayoutEffect(() => {
|
||||
if (menuRef.current) {
|
||||
const width = menuRef.current.offsetWidth;
|
||||
if (width !== menuWidth) {
|
||||
setMenuWidth(width);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!active || !menuRef.current) {
|
||||
return defaultPosition;
|
||||
}
|
||||
|
||||
// based on the start and end of the selection calculate the position at
|
||||
// the center top
|
||||
@@ -80,7 +74,7 @@ function usePosition({
|
||||
right: Math.max(fromPos.right, toPos.right),
|
||||
};
|
||||
|
||||
const offsetParent = menuRef.current?.offsetParent
|
||||
const offsetParent = menuRef.current.offsetParent
|
||||
? menuRef.current.offsetParent.getBoundingClientRect()
|
||||
: ({
|
||||
width: window.innerWidth,
|
||||
@@ -105,16 +99,12 @@ function usePosition({
|
||||
if (position !== null) {
|
||||
const element = view.nodeDOM(position);
|
||||
const bounds = (element as HTMLElement).getBoundingClientRect();
|
||||
selectionBounds.top = bounds.top + menuHeight;
|
||||
selectionBounds.top = bounds.top;
|
||||
selectionBounds.left = bounds.right;
|
||||
selectionBounds.right = bounds.right;
|
||||
}
|
||||
}
|
||||
|
||||
if (!active || !menuRef.current || !menuHeight) {
|
||||
return defaultPosition;
|
||||
}
|
||||
|
||||
// tables are an oddity, and need their own positioning logic
|
||||
const isColSelection =
|
||||
selection instanceof ColumnSelection && selection.isColSelection();
|
||||
@@ -176,8 +166,6 @@ function usePosition({
|
||||
top: Math.round(top - menuHeight - offsetParent.top),
|
||||
offset: 0,
|
||||
visible: true,
|
||||
blockSelection: false,
|
||||
maxWidth: "100%",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -222,12 +210,8 @@ function usePosition({
|
||||
top: Math.round(top - offsetParent.top),
|
||||
offset: Math.round(offset),
|
||||
maxWidth: Math.min(window.innerWidth, offsetParent.width) - margin * 2,
|
||||
blockSelection: !!(
|
||||
codeBlock ||
|
||||
isColSelection ||
|
||||
isRowSelection ||
|
||||
noticeBlock
|
||||
),
|
||||
blockSelection:
|
||||
codeBlock || isColSelection || isRowSelection || noticeBlock,
|
||||
visible: true,
|
||||
};
|
||||
}
|
||||
@@ -298,7 +282,7 @@ const FloatingToolbar = React.forwardRef(function FloatingToolbar_(
|
||||
ref={menuRef}
|
||||
$offset={position.offset}
|
||||
style={{
|
||||
minWidth: props.width,
|
||||
width: props.width,
|
||||
maxWidth: `${position.maxWidth}px`,
|
||||
top: `${position.top}px`,
|
||||
left: `${position.left}px`,
|
||||
@@ -319,7 +303,7 @@ type WrapperProps = {
|
||||
const arrow = (props: WrapperProps) =>
|
||||
props.arrow
|
||||
? css`
|
||||
&::after {
|
||||
&::before {
|
||||
content: "";
|
||||
display: block;
|
||||
width: 24px;
|
||||
@@ -327,14 +311,11 @@ const arrow = (props: WrapperProps) =>
|
||||
transform: translateX(-50%) rotate(45deg);
|
||||
background: ${s("menuBackground")};
|
||||
border-radius: 3px;
|
||||
z-index: 0;
|
||||
z-index: -1;
|
||||
position: absolute;
|
||||
bottom: -2px;
|
||||
bottom: -3px;
|
||||
left: calc(50% - ${props.$offset || 0}px);
|
||||
pointer-events: none;
|
||||
|
||||
// clip to show only the bottom right corner
|
||||
clip-path: polygon(100% 50%, 100% 100%, 50% 100%);
|
||||
}
|
||||
`
|
||||
: "";
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import { isEmail } from "class-validator";
|
||||
import { observer } from "mobx-react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { DocumentIcon, PlusIcon, CollectionIcon } from "outline-icons";
|
||||
import { useState, useCallback, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { v4 } from "uuid";
|
||||
import Icon from "@shared/components/Icon";
|
||||
import { MenuItem } from "@shared/editor/types";
|
||||
import { MentionType } from "@shared/types";
|
||||
import parseDocumentSlug from "@shared/utils/parseDocumentSlug";
|
||||
import { Avatar, AvatarSize, GroupAvatar } from "~/components/Avatar";
|
||||
import { Avatar, AvatarSize } from "~/components/Avatar";
|
||||
import DocumentBreadcrumb from "~/components/DocumentBreadcrumb";
|
||||
import Flex from "~/components/Flex";
|
||||
import {
|
||||
DocumentsSection,
|
||||
UserSection,
|
||||
CollectionsSection,
|
||||
GroupSection,
|
||||
} from "~/actions/sections";
|
||||
import useRequest from "~/hooks/useRequest";
|
||||
import useStores from "~/hooks/useStores";
|
||||
@@ -26,7 +25,6 @@ import SuggestionsMenu, {
|
||||
Props as SuggestionsMenuProps,
|
||||
} from "./SuggestionsMenu";
|
||||
import SuggestionsMenuItem from "./SuggestionsMenuItem";
|
||||
import { runInAction } from "mobx";
|
||||
|
||||
interface MentionItem extends MenuItem {
|
||||
attrs: {
|
||||
@@ -47,7 +45,7 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [items, setItems] = useState<MentionItem[]>([]);
|
||||
const { t } = useTranslation();
|
||||
const { auth, documents, users, collections, groups } = useStores();
|
||||
const { auth, documents, users, collections } = useStores();
|
||||
const actorId = auth.currentUserId;
|
||||
const location = useLocation();
|
||||
const documentId = parseDocumentSlug(location.pathname);
|
||||
@@ -55,17 +53,11 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
|
||||
const { loading, request } = useRequest(
|
||||
useCallback(async () => {
|
||||
const res = await client.post("/suggestions.mention", {
|
||||
query: search,
|
||||
limit: maxResultsInSection,
|
||||
});
|
||||
const res = await client.post("/suggestions.mention", { query: search });
|
||||
|
||||
runInAction(() => {
|
||||
res.data.documents.map(documents.add);
|
||||
res.data.users.map(users.add);
|
||||
res.data.collections.map(collections.add);
|
||||
res.data.groups.map(groups.add);
|
||||
});
|
||||
res.data.documents.map(documents.add);
|
||||
res.data.users.map(users.add);
|
||||
res.data.collections.map(collections.add);
|
||||
}, [search, documents, users, collections])
|
||||
);
|
||||
|
||||
@@ -100,7 +92,7 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
section: UserSection,
|
||||
appendSpace: true,
|
||||
attrs: {
|
||||
id: uuidv4(),
|
||||
id: v4(),
|
||||
type: MentionType.User,
|
||||
modelId: user.id,
|
||||
actorId,
|
||||
@@ -108,32 +100,6 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
},
|
||||
}) as MentionItem
|
||||
)
|
||||
.concat(
|
||||
groups
|
||||
.findByQuery(search, { maxResults: maxResultsInSection })
|
||||
.map((group) => ({
|
||||
name: "mention",
|
||||
icon: (
|
||||
<Flex
|
||||
align="center"
|
||||
justify="center"
|
||||
style={{ width: 24, height: 24, marginRight: 4 }}
|
||||
>
|
||||
<GroupAvatar group={group} size={AvatarSize.Small} />
|
||||
</Flex>
|
||||
),
|
||||
title: group.name,
|
||||
section: GroupSection,
|
||||
appendSpace: true,
|
||||
attrs: {
|
||||
id: uuidv4(),
|
||||
type: MentionType.Group,
|
||||
modelId: group.id,
|
||||
actorId,
|
||||
label: group.name,
|
||||
},
|
||||
}))
|
||||
)
|
||||
.concat(
|
||||
documents
|
||||
.findByQuery(search, { maxResults: maxResultsInSection })
|
||||
@@ -158,7 +124,7 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
section: DocumentsSection,
|
||||
appendSpace: true,
|
||||
attrs: {
|
||||
id: uuidv4(),
|
||||
id: v4(),
|
||||
type: MentionType.Document,
|
||||
modelId: doc.id,
|
||||
actorId,
|
||||
@@ -186,7 +152,7 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
section: CollectionsSection,
|
||||
appendSpace: true,
|
||||
attrs: {
|
||||
id: uuidv4(),
|
||||
id: v4(),
|
||||
type: MentionType.Collection,
|
||||
modelId: collection.id,
|
||||
actorId,
|
||||
@@ -206,9 +172,9 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
priority: -1,
|
||||
appendSpace: true,
|
||||
attrs: {
|
||||
id: uuidv4(),
|
||||
id: v4(),
|
||||
type: MentionType.Document,
|
||||
modelId: uuidv4(),
|
||||
modelId: v4(),
|
||||
actorId,
|
||||
label: search,
|
||||
},
|
||||
@@ -218,17 +184,7 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
setItems(items);
|
||||
setLoaded(true);
|
||||
}
|
||||
}, [
|
||||
t,
|
||||
actorId,
|
||||
loading,
|
||||
search,
|
||||
users,
|
||||
documents,
|
||||
maxResultsInSection,
|
||||
groups,
|
||||
collections,
|
||||
]);
|
||||
}, [t, actorId, loading, search, users, documents, maxResultsInSection]);
|
||||
|
||||
const handleSelect = useCallback(
|
||||
async (item: MentionItem) => {
|
||||
@@ -241,57 +197,29 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
if (!documentId) {
|
||||
return;
|
||||
}
|
||||
if (item.attrs.type === MentionType.User) {
|
||||
// Check if the mentioned user has access to the document
|
||||
const res = await client.post("/documents.users", {
|
||||
id: documentId,
|
||||
userId: item.attrs.modelId,
|
||||
});
|
||||
if (!res.data.length) {
|
||||
const user = users.get(item.attrs.modelId);
|
||||
toast.message(
|
||||
t(
|
||||
"{{ userName }} won't be notified, as they do not have access to this document",
|
||||
{
|
||||
userName: item.attrs.label,
|
||||
}
|
||||
),
|
||||
{
|
||||
icon: <Avatar model={user} size={AvatarSize.Toast} />,
|
||||
duration: 10000,
|
||||
}
|
||||
);
|
||||
}
|
||||
} else if (item.attrs.type === MentionType.Group) {
|
||||
const group = groups.get(item.attrs.modelId);
|
||||
// Check if the mentioned user has access to the document
|
||||
const res = await client.post("/documents.users", {
|
||||
id: documentId,
|
||||
userId: item.attrs.modelId,
|
||||
});
|
||||
|
||||
if (!res.data.length) {
|
||||
const user = users.get(item.attrs.modelId);
|
||||
toast.message(
|
||||
t(
|
||||
`Members of "{{ groupName }}" that have access to this document will be notified`,
|
||||
"{{ userName }} won't be notified, as they do not have access to this document",
|
||||
{
|
||||
groupName: item.attrs.label,
|
||||
userName: item.attrs.label,
|
||||
}
|
||||
),
|
||||
{
|
||||
icon: group ? <GroupAvatar group={group} /> : undefined,
|
||||
icon: <Avatar model={user} size={AvatarSize.Toast} />,
|
||||
duration: 10000,
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
[t, users, documentId, groups]
|
||||
);
|
||||
|
||||
const renderMenuItem = useCallback(
|
||||
(item, _index, options) => (
|
||||
<SuggestionsMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
subtitle={item.subtitle}
|
||||
title={item.title}
|
||||
icon={item.icon}
|
||||
/>
|
||||
),
|
||||
[]
|
||||
[t, users, documentId]
|
||||
);
|
||||
|
||||
// Prevent showing the menu until we have data otherwise it will be positioned
|
||||
@@ -307,7 +235,15 @@ function MentionMenu({ search, isActive, ...rest }: Props) {
|
||||
filterable={false}
|
||||
search={search}
|
||||
onSelect={handleSelect}
|
||||
renderMenuItem={renderMenuItem}
|
||||
renderMenuItem={(item, _index, options) => (
|
||||
<SuggestionsMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
subtitle={item.subtitle}
|
||||
title={item.title}
|
||||
icon={item.icon}
|
||||
/>
|
||||
)}
|
||||
items={items}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { observer } from "mobx-react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { EmailIcon, LinkIcon } from "outline-icons";
|
||||
import React, { useCallback } from "react";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { v4 } from "uuid";
|
||||
import { EmbedDescriptor } from "@shared/editor/embeds";
|
||||
import { MenuItem } from "@shared/editor/types";
|
||||
import { MentionType } from "@shared/types";
|
||||
@@ -27,18 +27,6 @@ type Props = Omit<
|
||||
export const PasteMenu = observer(({ pastedText, embeds, ...props }: Props) => {
|
||||
const items = useItems({ pastedText, embeds });
|
||||
|
||||
const renderMenuItem = useCallback(
|
||||
(item, _index, options) => (
|
||||
<SuggestionsMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
title={item.title}
|
||||
icon={item.icon}
|
||||
/>
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
if (!items) {
|
||||
props.onClose();
|
||||
return null;
|
||||
@@ -49,7 +37,14 @@ export const PasteMenu = observer(({ pastedText, embeds, ...props }: Props) => {
|
||||
{...props}
|
||||
trigger=""
|
||||
filterable={false}
|
||||
renderMenuItem={renderMenuItem}
|
||||
renderMenuItem={(item, _index, options) => (
|
||||
<SuggestionsMenuItem
|
||||
onClick={options.onClick}
|
||||
selected={options.selected}
|
||||
title={item.title}
|
||||
icon={item.icon}
|
||||
/>
|
||||
)}
|
||||
items={items}
|
||||
/>
|
||||
);
|
||||
@@ -87,7 +82,7 @@ function useItems({
|
||||
|
||||
mentionType = integration
|
||||
? determineMentionType({ url, integration })
|
||||
: MentionType.URL;
|
||||
: undefined;
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -102,11 +97,11 @@ function useItems({
|
||||
icon: <EmailIcon />,
|
||||
visible: !!mentionType,
|
||||
attrs: {
|
||||
id: uuidv4(),
|
||||
id: v4(),
|
||||
type: mentionType,
|
||||
label: pastedText,
|
||||
href: pastedText,
|
||||
modelId: uuidv4(),
|
||||
modelId: v4(),
|
||||
actorId: user?.id,
|
||||
},
|
||||
appendSpace: true,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Selection, NodeSelection, TextSelection } from "prosemirror-state";
|
||||
import some from "lodash/some";
|
||||
import { EditorState, NodeSelection, TextSelection } from "prosemirror-state";
|
||||
import * as React from "react";
|
||||
import filterExcessSeparators from "@shared/editor/lib/filterExcessSeparators";
|
||||
import { getMarkRange } from "@shared/editor/queries/getMarkRange";
|
||||
import { isInCode } from "@shared/editor/queries/isInCode";
|
||||
import { isInNotice } from "@shared/editor/queries/isInNotice";
|
||||
import { isMarkActive } from "@shared/editor/queries/isMarkActive";
|
||||
import { isNodeActive } from "@shared/editor/queries/isNodeActive";
|
||||
import {
|
||||
getColumnIndex,
|
||||
@@ -15,6 +17,7 @@ import useBoolean from "~/hooks/useBoolean";
|
||||
import useDictionary from "~/hooks/useDictionary";
|
||||
import useEventListener from "~/hooks/useEventListener";
|
||||
import useMobile from "~/hooks/useMobile";
|
||||
import usePrevious from "~/hooks/usePrevious";
|
||||
import getAttachmentMenuItems from "../menus/attachment";
|
||||
import getCodeMenuItems from "../menus/code";
|
||||
import getDividerMenuItems from "../menus/divider";
|
||||
@@ -26,33 +29,71 @@ import getTableMenuItems from "../menus/table";
|
||||
import getTableColMenuItems from "../menus/tableCol";
|
||||
import getTableRowMenuItems from "../menus/tableRow";
|
||||
import { useEditor } from "./EditorContext";
|
||||
import { MediaLinkEditor } from "./MediaLinkEditor";
|
||||
import { EmbedLinkEditor } from "./EmbedLinkEditor";
|
||||
import FloatingToolbar from "./FloatingToolbar";
|
||||
import LinkEditor from "./LinkEditor";
|
||||
import ToolbarMenu from "./ToolbarMenu";
|
||||
|
||||
type Props = {
|
||||
/** Whether the text direction is right-to-left */
|
||||
rtl: boolean;
|
||||
/** Whether the current document is a template */
|
||||
isTemplate: boolean;
|
||||
/** Whether the toolbar is currently active/visible */
|
||||
isActive: boolean;
|
||||
/** The current selection */
|
||||
selection?: Selection;
|
||||
/** Whether the editor is in read-only mode */
|
||||
readOnly?: boolean;
|
||||
/** Whether the user has permission to add comments */
|
||||
canComment?: boolean;
|
||||
/** Whether the user has permission to update the document */
|
||||
canUpdate?: boolean;
|
||||
/** Callback function when a link is clicked */
|
||||
onOpen: () => void;
|
||||
onClose: () => void;
|
||||
onClickLink: (
|
||||
href: string,
|
||||
event: MouseEvent | React.MouseEvent<HTMLButtonElement>
|
||||
) => void;
|
||||
};
|
||||
|
||||
function useIsActive(state: EditorState) {
|
||||
const { selection, doc } = state;
|
||||
|
||||
if (isMarkActive(state.schema.marks.link)(state)) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
(isNodeActive(state.schema.nodes.code_block)(state) ||
|
||||
isNodeActive(state.schema.nodes.code_fence)(state)) &&
|
||||
selection.from > 0
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isInNotice(state) && selection.from > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!selection || selection.empty) {
|
||||
return false;
|
||||
}
|
||||
if (selection instanceof NodeSelection && selection.node.type.name === "hr") {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
selection instanceof NodeSelection &&
|
||||
["image", "attachment", "embed"].includes(selection.node.type.name)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (selection instanceof NodeSelection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const selectionText = doc.cut(selection.from, selection.to).textContent;
|
||||
if (selection instanceof TextSelection && !selectionText) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const slice = selection.content();
|
||||
const fragment = slice.content;
|
||||
const nodes = (fragment as any).content;
|
||||
|
||||
return some(nodes, (n) => n.content.size);
|
||||
}
|
||||
|
||||
function useIsDragging() {
|
||||
const [isDragging, setDragging, setNotDragging] = useBoolean();
|
||||
useEventListener("dragstart", setDragging);
|
||||
@@ -61,19 +102,25 @@ function useIsDragging() {
|
||||
return isDragging;
|
||||
}
|
||||
|
||||
export function SelectionToolbar(props: Props) {
|
||||
const { readOnly = false } = props;
|
||||
export default function SelectionToolbar(props: Props) {
|
||||
const { onClose, readOnly, onOpen } = props;
|
||||
const { view, commands } = useEditor();
|
||||
const dictionary = useDictionary();
|
||||
const menuRef = React.useRef<HTMLDivElement | null>(null);
|
||||
const isMobile = useMobile();
|
||||
const isActive = props.isActive || isMobile;
|
||||
const isActive = useIsActive(view.state) || isMobile;
|
||||
const isDragging = useIsDragging();
|
||||
const [isEditingImgUrl, setIsEditingImgUrl] = React.useState(false);
|
||||
const previousIsActive = usePrevious(isActive);
|
||||
|
||||
React.useEffect(() => {
|
||||
setIsEditingImgUrl(false);
|
||||
}, [isActive]);
|
||||
// Trigger callbacks when the toolbar is opened or closed
|
||||
if (previousIsActive && !isActive) {
|
||||
onClose();
|
||||
}
|
||||
if (!previousIsActive && isActive) {
|
||||
onOpen();
|
||||
}
|
||||
}, [isActive, onClose, onOpen, previousIsActive]);
|
||||
|
||||
React.useEffect(() => {
|
||||
const handleClickOutside = (ev: MouseEvent): void => {
|
||||
@@ -96,8 +143,6 @@ export function SelectionToolbar(props: Props) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsEditingImgUrl(false);
|
||||
|
||||
const { dispatch } = view;
|
||||
dispatch(
|
||||
view.state.tr.setSelection(new TextSelection(view.state.doc.resolve(0)))
|
||||
@@ -109,7 +154,7 @@ export function SelectionToolbar(props: Props) {
|
||||
return () => {
|
||||
window.removeEventListener("mouseup", handleClickOutside);
|
||||
};
|
||||
}, [isActive, readOnly, view]);
|
||||
}, [isActive, previousIsActive, readOnly, view]);
|
||||
|
||||
const handleOnSelectLink = ({
|
||||
href,
|
||||
@@ -131,14 +176,14 @@ export function SelectionToolbar(props: Props) {
|
||||
);
|
||||
};
|
||||
|
||||
if (isDragging) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { isTemplate, rtl, canComment, canUpdate, ...rest } = props;
|
||||
const { state } = view;
|
||||
const { selection } = state;
|
||||
|
||||
if (isDragging) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isDividerSelection = isNodeActive(state.schema.nodes.hr)(state);
|
||||
const colIndex = getColumnIndex(state);
|
||||
const rowIndex = getRowIndex(state);
|
||||
@@ -160,22 +205,19 @@ export function SelectionToolbar(props: Props) {
|
||||
items = getCodeMenuItems(state, readOnly, dictionary);
|
||||
align = "end";
|
||||
} else if (isTableSelected(state)) {
|
||||
items = getTableMenuItems(state, readOnly, dictionary);
|
||||
items = readOnly ? [] : getTableMenuItems(state, dictionary);
|
||||
} else if (colIndex !== undefined) {
|
||||
items = getTableColMenuItems(state, readOnly, dictionary, {
|
||||
index: colIndex,
|
||||
rtl,
|
||||
});
|
||||
items = readOnly
|
||||
? []
|
||||
: getTableColMenuItems(state, colIndex, rtl, dictionary);
|
||||
} else if (rowIndex !== undefined) {
|
||||
items = getTableRowMenuItems(state, readOnly, dictionary, {
|
||||
index: rowIndex,
|
||||
});
|
||||
items = readOnly ? [] : getTableRowMenuItems(state, rowIndex, dictionary);
|
||||
} else if (isImageSelection) {
|
||||
items = getImageMenuItems(state, readOnly, dictionary);
|
||||
items = readOnly ? [] : getImageMenuItems(state, dictionary);
|
||||
} else if (isAttachmentSelection) {
|
||||
items = getAttachmentMenuItems(state, readOnly, dictionary);
|
||||
items = readOnly ? [] : getAttachmentMenuItems(state, dictionary);
|
||||
} else if (isDividerSelection) {
|
||||
items = getDividerMenuItems(state, readOnly, dictionary);
|
||||
items = getDividerMenuItems(state, dictionary);
|
||||
} else if (readOnly) {
|
||||
items = getReadOnlyMenuItems(state, !!canUpdate, dictionary);
|
||||
} else if (isNoticeSelection && selection.empty) {
|
||||
@@ -210,9 +252,6 @@ export function SelectionToolbar(props: Props) {
|
||||
const showLinkToolbar =
|
||||
link && link.from === selection.from && link.to === selection.to;
|
||||
|
||||
const isEditingMedia =
|
||||
isEmbedSelection || (isImageSelection && isEditingImgUrl);
|
||||
|
||||
return (
|
||||
<FloatingToolbar
|
||||
align={align}
|
||||
@@ -231,22 +270,15 @@ export function SelectionToolbar(props: Props) {
|
||||
onClickLink={props.onClickLink}
|
||||
onSelectLink={handleOnSelectLink}
|
||||
/>
|
||||
) : isEditingMedia ? (
|
||||
<MediaLinkEditor
|
||||
) : isEmbedSelection ? (
|
||||
<EmbedLinkEditor
|
||||
key={`embed-${selection.from}`}
|
||||
node={selection.node}
|
||||
node={(selection as NodeSelection).node}
|
||||
view={view}
|
||||
dictionary={dictionary}
|
||||
autoFocus={isEditingImgUrl}
|
||||
/>
|
||||
) : (
|
||||
<ToolbarMenu
|
||||
items={items}
|
||||
{...rest}
|
||||
handlers={{
|
||||
editImageUrl: () => setIsEditingImgUrl(true),
|
||||
}}
|
||||
/>
|
||||
<ToolbarMenu items={items} {...rest} />
|
||||
)}
|
||||
</FloatingToolbar>
|
||||
);
|
||||
|
||||
@@ -641,10 +641,6 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleOnClick = () => {
|
||||
handleClickItem(item);
|
||||
};
|
||||
|
||||
const currentHeading =
|
||||
"section" in item ? item.section?.({ t }) : undefined;
|
||||
|
||||
@@ -661,7 +657,7 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
|
||||
>
|
||||
{props.renderMenuItem(item as any, index, {
|
||||
selected: index === selectedIndex,
|
||||
onClick: handleOnClick,
|
||||
onClick: () => handleClickItem(item),
|
||||
})}
|
||||
</ListItem>
|
||||
</React.Fragment>
|
||||
|
||||
@@ -3,11 +3,7 @@ import * as React from "react";
|
||||
import scrollIntoView from "scroll-into-view-if-needed";
|
||||
import styled from "styled-components";
|
||||
import { usePortalContext } from "~/components/Portal";
|
||||
import {
|
||||
MenuButton,
|
||||
MenuIconWrapper,
|
||||
MenuLabel,
|
||||
} from "~/components/primitives/components/Menu";
|
||||
import { MenuButton, MenuLabel } from "~/components/primitives/components/Menu";
|
||||
|
||||
export type Props = {
|
||||
/** Whether the item is selected */
|
||||
@@ -64,7 +60,7 @@ function SuggestionsMenuItem({
|
||||
onPointerMove={disabled ? undefined : onPointerMove}
|
||||
$active={selected}
|
||||
>
|
||||
<MenuIconWrapper>{icon}</MenuIconWrapper>
|
||||
{icon}
|
||||
<MenuLabel>
|
||||
{title}
|
||||
{subtitle && (
|
||||
@@ -92,4 +88,4 @@ const Shortcut = styled.span<{ $active?: boolean }>`
|
||||
text-align: right;
|
||||
`;
|
||||
|
||||
export default React.memo(SuggestionsMenuItem);
|
||||
export default SuggestionsMenuItem;
|
||||
|
||||
@@ -20,20 +20,15 @@ import EventBoundary from "@shared/components/EventBoundary";
|
||||
|
||||
type Props = {
|
||||
items: MenuItem[];
|
||||
handlers?: Record<string, (...args: any[]) => void>;
|
||||
};
|
||||
|
||||
/*
|
||||
* Renders a dropdown menu in the floating toolbar.
|
||||
*/
|
||||
function ToolbarDropdown(props: {
|
||||
active: boolean;
|
||||
item: MenuItem;
|
||||
handlers?: Record<string, Function>;
|
||||
}) {
|
||||
function ToolbarDropdown(props: { active: boolean; item: MenuItem }) {
|
||||
const { commands, view } = useEditor();
|
||||
const { t } = useTranslation();
|
||||
const { item, handlers } = props;
|
||||
const { item } = props;
|
||||
const { state } = view;
|
||||
|
||||
const items: TMenuItem[] = useMemo(() => {
|
||||
@@ -42,19 +37,11 @@ function ToolbarDropdown(props: {
|
||||
return;
|
||||
}
|
||||
|
||||
if (commands[menuItem.name]) {
|
||||
commands[menuItem.name](
|
||||
typeof menuItem.attrs === "function"
|
||||
? menuItem.attrs(state)
|
||||
: menuItem.attrs
|
||||
);
|
||||
} else if (handlers && handlers[menuItem.name]) {
|
||||
handlers[menuItem.name](
|
||||
typeof menuItem.attrs === "function"
|
||||
? menuItem.attrs(state)
|
||||
: menuItem.attrs
|
||||
);
|
||||
}
|
||||
commands[menuItem.name](
|
||||
typeof menuItem.attrs === "function"
|
||||
? menuItem.attrs(state)
|
||||
: menuItem.attrs
|
||||
);
|
||||
};
|
||||
|
||||
return item.children
|
||||
@@ -141,7 +128,6 @@ function ToolbarMenu(props: Props) {
|
||||
<MediaDimension key={index} />
|
||||
) : item.children ? (
|
||||
<ToolbarDropdown
|
||||
handlers={props.handlers}
|
||||
active={isActive && !item.label}
|
||||
item={item}
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Plugin, PluginKey } from "prosemirror-state";
|
||||
import Extension from "@shared/editor/lib/Extension";
|
||||
import { isList } from "@shared/editor/queries/isList";
|
||||
import { ProsemirrorHelper } from "@shared/utils/ProsemirrorHelper";
|
||||
|
||||
/**
|
||||
@@ -18,32 +19,33 @@ export default class ClipboardTextSerializer extends Extension {
|
||||
new Plugin({
|
||||
key: new PluginKey("clipboardTextSerializer"),
|
||||
props: {
|
||||
clipboardTextSerializer: (slice) => {
|
||||
// Check if the only node is a code block
|
||||
const isSingleCodeBlock =
|
||||
slice.content.childCount === 1 &&
|
||||
(slice.content.firstChild?.type.name === "code_block" ||
|
||||
slice.content.firstChild?.type.name === "code_fence");
|
||||
clipboardTextSerializer: (slice, view) => {
|
||||
const isMultiline = slice.content.childCount > 1;
|
||||
|
||||
// Check if the only mark is a code mark
|
||||
const marks = new Set<string>();
|
||||
slice.content.descendants((node) => {
|
||||
node.marks.forEach((mark) => marks.add(mark.type.name));
|
||||
});
|
||||
const hasOnlyCodeMark =
|
||||
marks.size === 1 && marks.has("code_inline");
|
||||
|
||||
// This is a cheap way to determine if the content is "complex",
|
||||
// aka it has multiple marks or formatting. In which case we'll use
|
||||
// markdown formatting
|
||||
const hasMultipleListItems = slice.content.content
|
||||
.filter((node) => node.content.content.length > 1)
|
||||
.some((node) => isList(node, view.state.schema));
|
||||
const hasMultipleBlockTypes =
|
||||
[
|
||||
...new Set(
|
||||
slice.content.content
|
||||
.filter((node) => node.content.content.length > 1)
|
||||
.map((node) => node.type.name)
|
||||
),
|
||||
].length > 1;
|
||||
const copyAsMarkdown =
|
||||
isMultiline || hasMultipleBlockTypes || hasMultipleListItems;
|
||||
|
||||
// Use plain text serializer only for code-only content
|
||||
const usePlainText = isSingleCodeBlock || hasOnlyCodeMark;
|
||||
|
||||
return usePlainText
|
||||
? slice.content.content
|
||||
.map((node) => ProsemirrorHelper.toPlainText(node))
|
||||
.join("")
|
||||
: mdSerializer.serialize(slice.content, {
|
||||
return copyAsMarkdown
|
||||
? mdSerializer.serialize(slice.content, {
|
||||
softBreak: true,
|
||||
});
|
||||
})
|
||||
: slice.content.content
|
||||
.map((node) => ProsemirrorHelper.toPlainText(node))
|
||||
.join("");
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { action, observable } from "mobx";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { toggleMark } from "prosemirror-commands";
|
||||
import { Node, Slice } from "prosemirror-model";
|
||||
import {
|
||||
@@ -9,6 +8,7 @@ import {
|
||||
TextSelection,
|
||||
} from "prosemirror-state";
|
||||
import { Decoration, DecorationSet } from "prosemirror-view";
|
||||
import { v4 } from "uuid";
|
||||
import Extension, { WidgetProps } from "@shared/editor/lib/Extension";
|
||||
import { codeLanguages } from "@shared/editor/lib/code";
|
||||
import isMarkdown from "@shared/editor/lib/isMarkdown";
|
||||
@@ -144,7 +144,7 @@ export default class PasteHandler extends Extension {
|
||||
type: MentionType.Document,
|
||||
modelId: document.id,
|
||||
label: document.titleWithDefault,
|
||||
id: uuidv4(),
|
||||
id: v4(),
|
||||
})
|
||||
)
|
||||
);
|
||||
@@ -189,7 +189,7 @@ export default class PasteHandler extends Extension {
|
||||
type: MentionType.Collection,
|
||||
modelId: collection.id,
|
||||
label: collection.name,
|
||||
id: uuidv4(),
|
||||
id: v4(),
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
import some from "lodash/some";
|
||||
import { action, observable } from "mobx";
|
||||
import {
|
||||
EditorState,
|
||||
NodeSelection,
|
||||
Selection,
|
||||
Plugin,
|
||||
TextSelection,
|
||||
} from "prosemirror-state";
|
||||
import { EditorView } from "prosemirror-view";
|
||||
import Extension, { WidgetProps } from "@shared/editor/lib/Extension";
|
||||
import { isInNotice } from "@shared/editor/queries/isInNotice";
|
||||
import { isMarkActive } from "@shared/editor/queries/isMarkActive";
|
||||
import { isNodeActive } from "@shared/editor/queries/isNodeActive";
|
||||
import { SelectionToolbar } from "../components/SelectionToolbar";
|
||||
|
||||
export default class SelectionToolbarExtension extends Extension {
|
||||
get name() {
|
||||
return "selection-toolbar";
|
||||
}
|
||||
|
||||
get allowInReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
get plugins(): Plugin[] {
|
||||
return [
|
||||
new Plugin({
|
||||
view: () => ({
|
||||
update: this.handleUpdate,
|
||||
}),
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@observable
|
||||
state: Selection | boolean = false;
|
||||
|
||||
private handleUpdate = action((view: EditorView) => {
|
||||
const { state } = view;
|
||||
this.state = this.calculateState(state);
|
||||
});
|
||||
|
||||
private calculateState(state: EditorState): Selection | boolean {
|
||||
const { selection, doc, schema } = state;
|
||||
|
||||
if (isMarkActive(schema.marks.link)(state)) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
if (
|
||||
(isNodeActive(schema.nodes.code_block)(state) ||
|
||||
isNodeActive(schema.nodes.code_fence)(state)) &&
|
||||
selection.from > 0
|
||||
) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
if (isInNotice(state) && selection.from > 0) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
if (!selection || selection.empty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
selection instanceof NodeSelection &&
|
||||
selection.node.type.name === "hr"
|
||||
) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
if (
|
||||
selection instanceof NodeSelection &&
|
||||
["image", "attachment", "embed"].includes(selection.node.type.name)
|
||||
) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
if (selection instanceof NodeSelection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const selectionText = doc.cut(selection.from, selection.to).textContent;
|
||||
if (selection instanceof TextSelection && !selectionText) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const slice = selection.content();
|
||||
const fragment = slice.content;
|
||||
const nodes = (fragment as any).content;
|
||||
|
||||
if (some(nodes, (n) => n.content.size)) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
widget = (props: WidgetProps) => {
|
||||
const editorProps = this.editor.props;
|
||||
|
||||
return (
|
||||
<SelectionToolbar
|
||||
{...props}
|
||||
isActive={!!this.state}
|
||||
selection={this.state ? (this.state as Selection) : undefined}
|
||||
canUpdate={editorProps.canUpdate}
|
||||
canComment={editorProps.canComment}
|
||||
isTemplate={editorProps.template === true}
|
||||
onClickLink={editorProps.onClickLink}
|
||||
/>
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { InputRule } from "@shared/editor/lib/InputRule";
|
||||
|
||||
const rightArrow = new InputRule(/->$/, "→");
|
||||
// Note that the suppression of pipe here prevents conflict with table creation rule.
|
||||
const emdash = new InputRule(/(?:^|[^\|])(--\s)$/, "— ");
|
||||
const emdash = new InputRule(/(?:^|[^\|])(--)$/, "—");
|
||||
const oneHalf = new InputRule(/(?:^|\s)(1\/2)$/, "½");
|
||||
const threeQuarters = new InputRule(/(?:^|\s)(3\/4)$/, "¾");
|
||||
const copyright = new InputRule(/\(c\)$/, "©️");
|
||||
|
||||
@@ -10,7 +10,6 @@ import Keys from "~/editor/extensions/Keys";
|
||||
import MentionMenuExtension from "~/editor/extensions/MentionMenu";
|
||||
import PasteHandler from "~/editor/extensions/PasteHandler";
|
||||
import PreventTab from "~/editor/extensions/PreventTab";
|
||||
import SelectionToolbarExtension from "~/editor/extensions/SelectionToolbar";
|
||||
import SmartText from "~/editor/extensions/SmartText";
|
||||
|
||||
type Nodes = (typeof Node | typeof Mark | typeof Extension)[];
|
||||
@@ -25,7 +24,6 @@ export const withUIExtensions = (nodes: Nodes) => [
|
||||
MentionMenuExtension,
|
||||
FindAndReplaceExtension,
|
||||
HoverPreviewsExtension,
|
||||
SelectionToolbarExtension,
|
||||
// Order these default key handlers last
|
||||
PreventTab,
|
||||
Keys,
|
||||
|
||||
+51
-56
@@ -52,16 +52,15 @@ import Logger from "~/utils/Logger";
|
||||
import ComponentView from "./components/ComponentView";
|
||||
import EditorContext from "./components/EditorContext";
|
||||
import { NodeViewRenderer } from "./components/NodeViewRenderer";
|
||||
|
||||
import SelectionToolbar from "./components/SelectionToolbar";
|
||||
import WithTheme from "./components/WithTheme";
|
||||
import isNull from "lodash/isNull";
|
||||
import { isArray, map } from "lodash";
|
||||
import { map } from "lodash";
|
||||
import {
|
||||
LightboxImage,
|
||||
LightboxImageFactory,
|
||||
} from "@shared/editor/lib/Lightbox";
|
||||
import Lightbox from "~/components/Lightbox";
|
||||
import { anchorPlugin } from "@shared/editor/plugins/anchorPlugin";
|
||||
|
||||
export type Props = {
|
||||
/** An optional identifier for the editor context. It is used to persist local settings */
|
||||
@@ -151,6 +150,8 @@ type State = {
|
||||
isRTL: boolean;
|
||||
/** If the editor is currently focused */
|
||||
isEditorFocused: boolean;
|
||||
/** If the toolbar for a text selection is visible */
|
||||
selectionToolbarOpen: boolean;
|
||||
/** Image that's being currently viewed in Lightbox */
|
||||
activeLightboxImage: LightboxImage | null;
|
||||
};
|
||||
@@ -181,6 +182,7 @@ export class Editor extends React.PureComponent<
|
||||
state: State = {
|
||||
isRTL: false,
|
||||
isEditorFocused: false,
|
||||
selectionToolbarOpen: false,
|
||||
activeLightboxImage: null,
|
||||
};
|
||||
|
||||
@@ -268,12 +270,19 @@ export class Editor extends React.PureComponent<
|
||||
this.calculateDir();
|
||||
}
|
||||
|
||||
if (!this.isBlurred && !this.state.isEditorFocused) {
|
||||
if (
|
||||
!this.isBlurred &&
|
||||
!this.state.isEditorFocused &&
|
||||
!this.state.selectionToolbarOpen
|
||||
) {
|
||||
this.isBlurred = true;
|
||||
this.props.onBlur?.();
|
||||
}
|
||||
|
||||
if (this.isBlurred && this.state.isEditorFocused) {
|
||||
if (
|
||||
this.isBlurred &&
|
||||
(this.state.isEditorFocused || this.state.selectionToolbarOpen)
|
||||
) {
|
||||
this.isBlurred = false;
|
||||
this.props.onFocus?.();
|
||||
}
|
||||
@@ -407,7 +416,6 @@ export class Editor extends React.PureComponent<
|
||||
plugins: [
|
||||
...this.keymaps,
|
||||
...this.plugins,
|
||||
anchorPlugin(),
|
||||
dropCursor({
|
||||
color: this.props.theme.cursor,
|
||||
}),
|
||||
@@ -670,36 +678,19 @@ export class Editor extends React.PureComponent<
|
||||
public removeComment = (commentId: string) => {
|
||||
const { state, dispatch } = this.view;
|
||||
const tr = state.tr;
|
||||
let markRemoved = false;
|
||||
|
||||
state.doc.descendants((node, pos) => {
|
||||
if (markRemoved) {
|
||||
return false;
|
||||
if (!node.isInline) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mark = node.marks.find(
|
||||
(m) => m.type === state.schema.marks.comment && m.attrs.id === commentId
|
||||
);
|
||||
|
||||
if (mark) {
|
||||
tr.removeMark(pos, pos + node.nodeSize, mark);
|
||||
markRemoved = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isArray(node.attrs?.marks)) {
|
||||
const existingMarks = node.attrs.marks;
|
||||
const updatedMarks = existingMarks.filter(
|
||||
(mark: any) => mark.attrs.id !== commentId
|
||||
);
|
||||
const attrs = {
|
||||
...node.attrs,
|
||||
marks: updatedMarks,
|
||||
};
|
||||
tr.setNodeMarkup(pos, undefined, attrs);
|
||||
markRemoved = true;
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
dispatch(tr);
|
||||
@@ -708,7 +699,7 @@ export class Editor extends React.PureComponent<
|
||||
/**
|
||||
* Update all marks related to a specific comment in the document.
|
||||
*
|
||||
* @param commentId The id of the comment to update
|
||||
* @param commentId The id of the comment to remove
|
||||
* @param attrs The attributes to update
|
||||
*/
|
||||
public updateComment = (
|
||||
@@ -717,11 +708,10 @@ export class Editor extends React.PureComponent<
|
||||
) => {
|
||||
const { state, dispatch } = this.view;
|
||||
const tr = state.tr;
|
||||
let markUpdated = false;
|
||||
|
||||
state.doc.descendants((node, pos) => {
|
||||
if (markUpdated) {
|
||||
return false;
|
||||
if (!node.isInline) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mark = node.marks.find(
|
||||
@@ -735,27 +725,9 @@ export class Editor extends React.PureComponent<
|
||||
...mark.attrs,
|
||||
...attrs,
|
||||
});
|
||||
|
||||
tr.removeMark(from, to, mark).addMark(from, to, newMark);
|
||||
markUpdated = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isArray(node.attrs?.marks)) {
|
||||
const existingMarks = node.attrs.marks;
|
||||
const updatedMarks = existingMarks.map((mark: any) =>
|
||||
mark.type === "comment" && mark.attrs.id === commentId
|
||||
? { ...mark, attrs: { ...mark.attrs, ...attrs } }
|
||||
: mark
|
||||
);
|
||||
const newAttrs = {
|
||||
...node.attrs,
|
||||
marks: updatedMarks,
|
||||
};
|
||||
tr.setNodeMarkup(pos, undefined, newAttrs);
|
||||
markUpdated = true;
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
|
||||
dispatch(tr);
|
||||
@@ -819,6 +791,23 @@ export class Editor extends React.PureComponent<
|
||||
return false;
|
||||
};
|
||||
|
||||
private handleOpenSelectionToolbar = () => {
|
||||
this.setState((state) => ({
|
||||
...state,
|
||||
selectionToolbarOpen: true,
|
||||
}));
|
||||
};
|
||||
|
||||
private handleCloseSelectionToolbar = () => {
|
||||
if (!this.state.selectionToolbarOpen) {
|
||||
return;
|
||||
}
|
||||
this.setState((state) => ({
|
||||
...state,
|
||||
selectionToolbarOpen: false,
|
||||
}));
|
||||
};
|
||||
|
||||
public render() {
|
||||
const { readOnly, canUpdate, grow, style, className, onKeyDown } =
|
||||
this.props;
|
||||
@@ -848,7 +837,18 @@ export class Editor extends React.PureComponent<
|
||||
ref={this.elementRef}
|
||||
lang=""
|
||||
/>
|
||||
|
||||
{this.view && (
|
||||
<SelectionToolbar
|
||||
rtl={isRTL}
|
||||
readOnly={readOnly}
|
||||
canUpdate={this.props.canUpdate}
|
||||
canComment={this.props.canComment}
|
||||
isTemplate={this.props.template === true}
|
||||
onOpen={this.handleOpenSelectionToolbar}
|
||||
onClose={this.handleCloseSelectionToolbar}
|
||||
onClickLink={this.props.onClickLink}
|
||||
/>
|
||||
)}
|
||||
{this.widgets &&
|
||||
Object.values(this.widgets).map((Widget, index) => (
|
||||
<Widget key={String(index)} rtl={isRTL} readOnly={readOnly} />
|
||||
@@ -880,15 +880,10 @@ const EditorContainer = styled(Styles)<{
|
||||
${(props) =>
|
||||
props.focusedCommentId &&
|
||||
css`
|
||||
span#comment-${props.focusedCommentId} {
|
||||
#comment-${props.focusedCommentId} {
|
||||
background: ${transparentize(0.5, props.theme.brand.marine)};
|
||||
border-bottom: 2px solid ${props.theme.commentMarkBackground};
|
||||
}
|
||||
a#comment-${props.focusedCommentId}
|
||||
~ span.component-image
|
||||
div.image-wrapper {
|
||||
outline: ${props.theme.commentMarkBackground} solid 2px;
|
||||
}
|
||||
`}
|
||||
|
||||
${(props) =>
|
||||
|
||||
@@ -5,12 +5,8 @@ import { Dictionary } from "~/hooks/useDictionary";
|
||||
|
||||
export default function attachmentMenuItems(
|
||||
state: EditorState,
|
||||
readOnly: boolean,
|
||||
dictionary: Dictionary
|
||||
): MenuItem[] {
|
||||
if (readOnly) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
{
|
||||
name: "replaceAttachment",
|
||||
|
||||
@@ -6,12 +6,8 @@ import { Dictionary } from "~/hooks/useDictionary";
|
||||
|
||||
export default function dividerMenuItems(
|
||||
state: EditorState,
|
||||
readOnly: boolean,
|
||||
dictionary: Dictionary
|
||||
): MenuItem[] {
|
||||
if (readOnly) {
|
||||
return [];
|
||||
}
|
||||
const { schema } = state;
|
||||
|
||||
return [
|
||||
|
||||
@@ -6,22 +6,16 @@ import {
|
||||
AlignImageRightIcon,
|
||||
AlignImageCenterIcon,
|
||||
AlignFullWidthIcon,
|
||||
CommentIcon,
|
||||
} from "outline-icons";
|
||||
import { EditorState } from "prosemirror-state";
|
||||
import { isNodeActive } from "@shared/editor/queries/isNodeActive";
|
||||
import { MenuItem } from "@shared/editor/types";
|
||||
import { Dictionary } from "~/hooks/useDictionary";
|
||||
import { metaDisplay } from "@shared/utils/keyboard";
|
||||
|
||||
export default function imageMenuItems(
|
||||
state: EditorState,
|
||||
readOnly: boolean,
|
||||
dictionary: Dictionary
|
||||
): MenuItem[] {
|
||||
if (readOnly) {
|
||||
return [];
|
||||
}
|
||||
const { schema } = state;
|
||||
const isLeftAligned = isNodeActive(schema.nodes.image, {
|
||||
layoutClass: "left-50",
|
||||
@@ -81,32 +75,14 @@ export default function imageMenuItems(
|
||||
visible: !!fetch,
|
||||
},
|
||||
{
|
||||
name: "replaceImage",
|
||||
tooltip: dictionary.replaceImage,
|
||||
icon: <ReplaceIcon />,
|
||||
children: [
|
||||
{
|
||||
name: "replaceImage",
|
||||
label: dictionary.uploadImage,
|
||||
},
|
||||
{
|
||||
name: "editImageUrl",
|
||||
label: dictionary.editImageUrl,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "deleteImage",
|
||||
tooltip: dictionary.deleteImage,
|
||||
icon: <TrashIcon />,
|
||||
},
|
||||
{
|
||||
name: "separator",
|
||||
},
|
||||
{
|
||||
name: "commentOnImage",
|
||||
tooltip: dictionary.comment,
|
||||
shortcut: `${metaDisplay}+⌥+M`,
|
||||
icon: <CommentIcon />,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -6,12 +6,8 @@ import { Dictionary } from "~/hooks/useDictionary";
|
||||
|
||||
export default function tableMenuItems(
|
||||
state: EditorState,
|
||||
readOnly: boolean,
|
||||
dictionary: Dictionary
|
||||
): MenuItem[] {
|
||||
if (readOnly) {
|
||||
return [];
|
||||
}
|
||||
const { schema } = state;
|
||||
const isFullWidth = isNodeActive(schema.nodes.table, {
|
||||
layout: TableLayout.fullWidth,
|
||||
|
||||
@@ -25,18 +25,10 @@ import { ArrowLeftIcon, ArrowRightIcon } from "~/components/Icons/ArrowIcon";
|
||||
|
||||
export default function tableColMenuItems(
|
||||
state: EditorState,
|
||||
readOnly: boolean,
|
||||
dictionary: Dictionary,
|
||||
options: {
|
||||
index: number;
|
||||
rtl: boolean;
|
||||
}
|
||||
index: number,
|
||||
rtl: boolean,
|
||||
dictionary: Dictionary
|
||||
): MenuItem[] {
|
||||
if (readOnly) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const { index, rtl } = options;
|
||||
const { schema, selection } = state;
|
||||
|
||||
if (!(selection instanceof CellSelection)) {
|
||||
|
||||
@@ -19,17 +19,9 @@ import { ArrowDownIcon, ArrowUpIcon } from "~/components/Icons/ArrowIcon";
|
||||
|
||||
export default function tableRowMenuItems(
|
||||
state: EditorState,
|
||||
readOnly: boolean,
|
||||
dictionary: Dictionary,
|
||||
options: {
|
||||
index: number;
|
||||
}
|
||||
index: number,
|
||||
dictionary: Dictionary
|
||||
): MenuItem[] {
|
||||
if (readOnly) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const { index } = options;
|
||||
const { selection } = state;
|
||||
|
||||
if (!(selection instanceof CellSelection)) {
|
||||
|
||||
@@ -32,7 +32,6 @@ export default function useDictionary() {
|
||||
comment: t("Comment"),
|
||||
copy: t("Copy"),
|
||||
createLink: t("Create link"),
|
||||
editImageUrl: t("Edit image URL"),
|
||||
createLinkError: t("Sorry, an error occurred creating the link"),
|
||||
createNewDoc: t("Create a new doc"),
|
||||
createNewChildDoc: t("Create a new child doc"),
|
||||
@@ -109,7 +108,6 @@ export default function useDictionary() {
|
||||
untitled: t("Untitled"),
|
||||
none: t("None"),
|
||||
deleteEmbed: t("Delete embed"),
|
||||
uploadImage: t("Upload an image"),
|
||||
}),
|
||||
[t]
|
||||
);
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import useEventListener from "./useEventListener";
|
||||
|
||||
/**
|
||||
* Mouse position as a tuple of [x, y]
|
||||
*/
|
||||
type MousePosition = [number, number];
|
||||
|
||||
/**
|
||||
* Hook to get the current mouse position
|
||||
*
|
||||
* @returns Mouse position as a tuple of [x, y]
|
||||
*/
|
||||
export const useMousePosition = () => {
|
||||
const [mousePosition, setMousePosition] = useState<MousePosition>([0, 0]);
|
||||
|
||||
const updateMousePosition = useMemo(
|
||||
() => (ev: MouseEvent) => {
|
||||
setMousePosition([ev.clientX, ev.clientY]);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
useEventListener("mousemove", updateMousePosition, undefined, {
|
||||
passive: true,
|
||||
});
|
||||
|
||||
return mousePosition;
|
||||
};
|
||||
@@ -3,7 +3,7 @@ import { useState, useEffect, useCallback } from "react";
|
||||
import { PaginationParams } from "~/types";
|
||||
import useRequest from "./useRequest";
|
||||
|
||||
export type RequestResponse<T> = {
|
||||
type RequestResponse<T> = {
|
||||
/** The return value of the paginated request function. */
|
||||
data: T[] | undefined;
|
||||
/** The request error, if any. */
|
||||
|
||||
@@ -158,7 +158,7 @@ const useSettingsConfig = () => {
|
||||
path: settingsPath("templates"),
|
||||
component: Templates.Component,
|
||||
preload: Templates.preload,
|
||||
enabled: can.updateTemplate,
|
||||
enabled: can.readTemplate,
|
||||
group: t("Workspace"),
|
||||
icon: ShapesIcon,
|
||||
},
|
||||
|
||||
+9
-18
@@ -26,22 +26,13 @@ export default function useSwipe({
|
||||
touchYEnd.current = undefined;
|
||||
};
|
||||
|
||||
const onTouchStartCapture = (e: React.TouchEvent<HTMLImageElement>) => {
|
||||
if (e.touches.length === 1) {
|
||||
// Stop propagation only for single touch gestures, otherwise it prevents
|
||||
// multi-touch gestures like pinch to zoom to take effect
|
||||
e.stopPropagation();
|
||||
touchXStart.current = e.changedTouches[0].screenX;
|
||||
touchYStart.current = e.changedTouches[0].screenY;
|
||||
}
|
||||
const onTouchStart = (e: React.TouchEvent<HTMLImageElement>) => {
|
||||
touchXStart.current = e.changedTouches[0].screenX;
|
||||
touchYStart.current = e.changedTouches[0].screenY;
|
||||
};
|
||||
|
||||
const onTouchMoveCapture = (e: React.TouchEvent<HTMLImageElement>) => {
|
||||
if (
|
||||
isNumber(touchXStart.current) &&
|
||||
isNumber(touchYStart.current) &&
|
||||
e.touches.length === 1
|
||||
) {
|
||||
const onTouchMove = (e: React.TouchEvent<HTMLImageElement>) => {
|
||||
if (isNumber(touchXStart.current) && isNumber(touchYStart.current)) {
|
||||
touchXEnd.current = e.changedTouches[0].screenX;
|
||||
touchYEnd.current = e.changedTouches[0].screenY;
|
||||
const dx = touchXEnd.current - touchXStart.current;
|
||||
@@ -73,13 +64,13 @@ export default function useSwipe({
|
||||
}
|
||||
};
|
||||
|
||||
const onTouchCancelCapture = () => {
|
||||
const onTouchCancel = () => {
|
||||
resetTouchPoints();
|
||||
};
|
||||
|
||||
return {
|
||||
onTouchStartCapture,
|
||||
onTouchMoveCapture,
|
||||
onTouchCancelCapture,
|
||||
onTouchStart,
|
||||
onTouchMove,
|
||||
onTouchCancel,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import invariant from "invariant";
|
||||
import { action, comparer, computed, observable, runInAction } from "mobx";
|
||||
import { action, computed, observable, runInAction } from "mobx";
|
||||
import {
|
||||
CollectionPermission,
|
||||
FileOperationFormat,
|
||||
@@ -156,7 +156,7 @@ export default class Collection extends ParanoidModel {
|
||||
return this.sort.field === "index";
|
||||
}
|
||||
|
||||
@computed({ equals: comparer.structural })
|
||||
@computed
|
||||
get sortedDocuments(): NavigationNode[] | undefined {
|
||||
if (!this.documents) {
|
||||
return undefined;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { addDays, differenceInDays } from "date-fns";
|
||||
import i18n, { t } from "i18next";
|
||||
import capitalize from "lodash/capitalize";
|
||||
import floor from "lodash/floor";
|
||||
import { action, autorun, comparer, computed, observable, set } from "mobx";
|
||||
import { action, autorun, computed, observable, set } from "mobx";
|
||||
import type {
|
||||
JSONObject,
|
||||
NavigationNode,
|
||||
@@ -89,11 +89,6 @@ export default class Document extends ArchivableModel implements Searchable {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
@computed
|
||||
get searchSuppressed(): boolean {
|
||||
return this.isDeleted || this.isArchived;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the original data source, if imported.
|
||||
*/
|
||||
@@ -184,7 +179,7 @@ export default class Document extends ArchivableModel implements Searchable {
|
||||
/**
|
||||
* Parent document that this is a child of, if any.
|
||||
*/
|
||||
@Relation(() => Document, { onArchive: "cascade", onDelete: "cascade" })
|
||||
@Relation(() => Document, { onArchive: "cascade" })
|
||||
parentDocument?: Document;
|
||||
|
||||
@observable
|
||||
@@ -652,7 +647,7 @@ export default class Document extends ArchivableModel implements Searchable {
|
||||
);
|
||||
}
|
||||
|
||||
@computed({ equals: comparer.structural })
|
||||
@computed
|
||||
get asNavigationNode(): NavigationNode {
|
||||
return {
|
||||
type: NavigationNodeType.Document,
|
||||
|
||||
+1
-16
@@ -3,9 +3,8 @@ import GroupMembership from "./GroupMembership";
|
||||
import Model from "./base/Model";
|
||||
import Field from "./decorators/Field";
|
||||
import { GroupPermission } from "@shared/types";
|
||||
import { Searchable } from "./interfaces/Searchable";
|
||||
|
||||
class Group extends Model implements Searchable {
|
||||
class Group extends Model {
|
||||
static modelName = "Group";
|
||||
|
||||
@Field
|
||||
@@ -18,10 +17,6 @@ class Group extends Model implements Searchable {
|
||||
@observable
|
||||
memberCount: number;
|
||||
|
||||
@Field
|
||||
@observable
|
||||
disableMentions: boolean;
|
||||
|
||||
/**
|
||||
* Returns the users that are members of this group.
|
||||
*/
|
||||
@@ -31,16 +26,6 @@ class Group extends Model implements Searchable {
|
||||
return users.inGroup(this.id);
|
||||
}
|
||||
|
||||
@computed
|
||||
get searchContent(): string[] {
|
||||
return [this.name].filter(Boolean);
|
||||
}
|
||||
|
||||
@computed
|
||||
get searchSuppressed(): boolean {
|
||||
return this.disableMentions;
|
||||
}
|
||||
|
||||
@computed
|
||||
get admins() {
|
||||
const { groupUsers } = this.store.rootStore;
|
||||
|
||||
@@ -122,9 +122,6 @@ class Notification extends Model {
|
||||
case NotificationEventType.MentionedInDocument:
|
||||
case NotificationEventType.MentionedInComment:
|
||||
return t("mentioned you in");
|
||||
case NotificationEventType.GroupMentionedInComment:
|
||||
case NotificationEventType.GroupMentionedInDocument:
|
||||
return t("mentioned your group in");
|
||||
case NotificationEventType.CreateComment:
|
||||
return t("left a comment on");
|
||||
case NotificationEventType.ResolveComment:
|
||||
@@ -180,11 +177,9 @@ class Notification extends Model {
|
||||
return collection ? collectionPath(collection.path) : "";
|
||||
}
|
||||
case NotificationEventType.AddUserToDocument:
|
||||
case NotificationEventType.GroupMentionedInDocument:
|
||||
case NotificationEventType.MentionedInDocument: {
|
||||
return this.document?.path;
|
||||
}
|
||||
case NotificationEventType.GroupMentionedInComment:
|
||||
case NotificationEventType.MentionedInComment:
|
||||
case NotificationEventType.ResolveComment:
|
||||
case NotificationEventType.CreateComment:
|
||||
|
||||
@@ -105,11 +105,6 @@ class Share extends Model implements Searchable {
|
||||
return [this.title];
|
||||
}
|
||||
|
||||
@computed
|
||||
get searchSuppressed(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
@computed
|
||||
get sharedCache() {
|
||||
return (
|
||||
|
||||
@@ -68,11 +68,6 @@ class User extends ParanoidModel implements Searchable {
|
||||
return [this.name, this.email].filter(Boolean);
|
||||
}
|
||||
|
||||
@computed
|
||||
get searchSuppressed(): boolean {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
@computed
|
||||
get initial(): string {
|
||||
return (this.name ? this.name[0] : "?").toUpperCase();
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import pick from "lodash/pick";
|
||||
import { observable, action, toJS } from "mobx";
|
||||
import { observable, action } from "mobx";
|
||||
import { JSONObject } from "@shared/types";
|
||||
import type Store from "~/stores/base/Store";
|
||||
import Logger from "~/utils/Logger";
|
||||
import { getFieldsForModel } from "../decorators/Field";
|
||||
import { LifecycleManager } from "../decorators/Lifecycle";
|
||||
import { getRelationsForModelClass } from "../decorators/Relation";
|
||||
import { isEqual } from "lodash";
|
||||
|
||||
export default abstract class Model {
|
||||
static modelName: string;
|
||||
@@ -148,10 +147,6 @@ export default abstract class Model {
|
||||
continue;
|
||||
}
|
||||
// @ts-expect-error TODO
|
||||
if (isEqual(toJS(this[key]), data[key])) {
|
||||
continue;
|
||||
}
|
||||
// @ts-expect-error TODO
|
||||
this[key] = data[key];
|
||||
} catch (error) {
|
||||
Logger.warn(`Error setting ${key} on model`, error);
|
||||
|
||||
@@ -4,6 +4,4 @@
|
||||
export interface Searchable {
|
||||
/** The content to be used for search */
|
||||
get searchContent(): string | string[];
|
||||
|
||||
get searchSuppressed(): boolean;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import Document from "~/models/Document";
|
||||
import Editor from "~/components/Editor";
|
||||
import LoadingIndicator from "~/components/LoadingIndicator";
|
||||
import Text from "~/components/Text";
|
||||
import { MeasuredContainer } from "~/components/MeasuredContainer";
|
||||
import { withUIExtensions } from "~/editor/extensions";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
@@ -82,22 +81,20 @@ function Overview({ collection, shareId }: Props) {
|
||||
{collections.isSaving && <LoadingIndicator />}
|
||||
{(collection.hasDescription || can.update) && (
|
||||
<Suspense fallback={<Placeholder>Loading…</Placeholder>}>
|
||||
<MeasuredContainer name="document">
|
||||
<Editor
|
||||
defaultValue={collection.data}
|
||||
onChange={handleSave}
|
||||
placeholder={`${t("Add a description")}…`}
|
||||
extensions={extensions}
|
||||
maxLength={CollectionValidation.maxDescriptionLength}
|
||||
onCreateLink={onCreateLink}
|
||||
canUpdate={can.update}
|
||||
readOnly={!can.update || !!shareId}
|
||||
userId={user?.id}
|
||||
editorStyle={editorStyle}
|
||||
shareId={shareId}
|
||||
/>
|
||||
<div ref={childRef} />
|
||||
</MeasuredContainer>
|
||||
<Editor
|
||||
defaultValue={collection.data}
|
||||
onChange={handleSave}
|
||||
placeholder={`${t("Add a description")}…`}
|
||||
extensions={extensions}
|
||||
maxLength={CollectionValidation.maxDescriptionLength}
|
||||
onCreateLink={onCreateLink}
|
||||
canUpdate={can.update}
|
||||
readOnly={!can.update || !!shareId}
|
||||
userId={user?.id}
|
||||
editorStyle={editorStyle}
|
||||
shareId={shareId}
|
||||
/>
|
||||
<div ref={childRef} />
|
||||
</Suspense>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as VisuallyHidden from "@radix-ui/react-visually-hidden";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { m } from "framer-motion";
|
||||
import { action } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
@@ -8,6 +7,7 @@ import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import { useTheme } from "styled-components";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { ProsemirrorData } from "@shared/types";
|
||||
import { getEventFiles } from "@shared/utils/files";
|
||||
import { AttachmentValidation, CommentValidation } from "@shared/validations";
|
||||
@@ -107,7 +107,6 @@ function CommentForm({
|
||||
setForceRender((s) => ++s);
|
||||
setInputFocused(false);
|
||||
|
||||
const commentDraft = draft;
|
||||
const comment =
|
||||
thread ??
|
||||
new Comment(
|
||||
@@ -127,9 +126,6 @@ function CommentForm({
|
||||
})
|
||||
.then(() => onSubmit?.())
|
||||
.catch(() => {
|
||||
onSaveDraft(commentDraft);
|
||||
setForceRender((s) => ++s);
|
||||
|
||||
comment.isNew = true;
|
||||
toast.error(t("Error creating comment"));
|
||||
});
|
||||
@@ -146,7 +142,6 @@ function CommentForm({
|
||||
return;
|
||||
}
|
||||
|
||||
const commentDraft = draft;
|
||||
onSaveDraft(undefined);
|
||||
setForceRender((s) => ++s);
|
||||
|
||||
@@ -168,9 +163,6 @@ function CommentForm({
|
||||
.save()
|
||||
.then(() => onSubmit?.())
|
||||
.catch(() => {
|
||||
onSaveDraft(commentDraft);
|
||||
setForceRender((s) => ++s);
|
||||
|
||||
comments.remove(comment.id);
|
||||
comment.isNew = true;
|
||||
toast.error(t("Error creating comment"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { differenceInMilliseconds } from "date-fns";
|
||||
import { runInAction } from "mobx";
|
||||
import { action } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import { DoneIcon } from "outline-icons";
|
||||
import { darken } from "polished";
|
||||
@@ -179,18 +179,18 @@ function CommentThreadItem({
|
||||
);
|
||||
}, []);
|
||||
|
||||
const handleSubmit = async (event: React.FormEvent) => {
|
||||
const handleSubmit = action(async (event: React.FormEvent) => {
|
||||
event.preventDefault();
|
||||
|
||||
try {
|
||||
handleSetReadOnly();
|
||||
runInAction(() => (comment.data = data));
|
||||
comment.data = data;
|
||||
await comment.save();
|
||||
} catch (_err) {
|
||||
setEditing();
|
||||
toast.error(t("Error updating comment"));
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const handleCancel = () => {
|
||||
setData(comment.data);
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
AuthenticationFailed,
|
||||
AuthorizationFailed,
|
||||
DocumentTooLarge,
|
||||
EditorUpdateError,
|
||||
TooManyConnections,
|
||||
} from "@shared/collaboration/CloseEvents";
|
||||
import Fade from "~/components/Fade";
|
||||
@@ -38,10 +37,6 @@ function ConnectionStatus() {
|
||||
title: t("Too many users connected to document"),
|
||||
body: t("Your edits will sync once other users leave the document"),
|
||||
},
|
||||
[EditorUpdateError.code]: {
|
||||
title: t("New version available"),
|
||||
body: t("Please reload the page to update to the latest version"),
|
||||
},
|
||||
};
|
||||
|
||||
const message = ui.multiplayerErrorCode
|
||||
@@ -68,29 +63,20 @@ function ConnectionStatus() {
|
||||
}
|
||||
placement="bottom"
|
||||
>
|
||||
<Fade>
|
||||
<Button width="auto">
|
||||
{message?.title ?? t("Offline")}
|
||||
<Button>
|
||||
<Fade>
|
||||
<DisconnectedIcon />
|
||||
</Button>
|
||||
</Fade>
|
||||
</Fade>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
) : null;
|
||||
}
|
||||
|
||||
const Button = styled(NudeButton)`
|
||||
display: none;
|
||||
background: ${(props) => props.theme.backgroundTertiary};
|
||||
color: ${(props) => props.theme.textSecondary};
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
padding-left: 6px;
|
||||
padding-right: 6px;
|
||||
|
||||
${breakpoint("tablet")`
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
display: block;
|
||||
`};
|
||||
|
||||
@media print {
|
||||
|
||||
@@ -41,7 +41,6 @@ import PlaceholderDocument from "~/components/PlaceholderDocument";
|
||||
import RegisterKeyDown from "~/components/RegisterKeyDown";
|
||||
import { SidebarContextType } from "~/components/Sidebar/components/SidebarContext";
|
||||
import withStores from "~/components/withStores";
|
||||
import { MeasuredContainer } from "~/components/MeasuredContainer";
|
||||
import type { Editor as TEditor } from "~/editor";
|
||||
import { Properties } from "~/types";
|
||||
import { client } from "~/utils/ApiClient";
|
||||
@@ -55,6 +54,7 @@ import Container from "./Container";
|
||||
import Contents from "./Contents";
|
||||
import Editor from "./Editor";
|
||||
import Header from "./Header";
|
||||
import { MeasuredContainer } from "./MeasuredContainer";
|
||||
import Notices from "./Notices";
|
||||
import PublicReferences from "./PublicReferences";
|
||||
import References from "./References";
|
||||
@@ -417,18 +417,6 @@ class DocumentScene extends React.Component<Props> {
|
||||
void this.onSave();
|
||||
});
|
||||
|
||||
handleSelectTemplate = async (template: Document | Revision) => {
|
||||
const doc = this.editor.current?.view.state.doc;
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.replaceSelection(
|
||||
template,
|
||||
ProsemirrorHelper.isEmpty(doc) ? new AllSelection(doc) : undefined
|
||||
);
|
||||
};
|
||||
|
||||
goBack = () => {
|
||||
if (!this.props.readOnly) {
|
||||
this.props.history.push({
|
||||
@@ -545,7 +533,7 @@ class DocumentScene extends React.Component<Props> {
|
||||
}
|
||||
savingIsDisabled={document.isSaving || this.isEmpty}
|
||||
sharedTree={this.props.sharedTree}
|
||||
onSelectTemplate={this.handleSelectTemplate}
|
||||
onSelectTemplate={this.replaceSelection}
|
||||
onSave={this.onSave}
|
||||
/>
|
||||
<Main
|
||||
|
||||
@@ -10,9 +10,9 @@ type Props = {
|
||||
|
||||
export const Footer = ({ document }: Props) => (
|
||||
<FooterWrapper>
|
||||
<KeyboardShortcutsButton />
|
||||
<ConnectionStatus />
|
||||
<SizeWarning document={document} />
|
||||
<KeyboardShortcutsButton />
|
||||
</FooterWrapper>
|
||||
);
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import * as React from "react";
|
||||
import useMeasure from "react-use-measure";
|
||||
|
||||
export const MeasuredContainer = <T extends React.ElementType>({
|
||||
as: As = "div",
|
||||
as: As,
|
||||
name,
|
||||
children,
|
||||
...rest
|
||||
@@ -57,7 +57,6 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
|
||||
const { t } = useTranslation();
|
||||
const currentUser = useCurrentUser();
|
||||
const { presence, auth, ui } = useStores();
|
||||
const [editorVersionBehind, setEditorVersionBehind] = useState(false);
|
||||
const [showCursorNames, setShowCursorNames] = useState(false);
|
||||
const [remoteProvider, setRemoteProvider] =
|
||||
useState<HocuspocusProvider | null>(null);
|
||||
@@ -162,7 +161,7 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
|
||||
ui.setMultiplayerStatus("disconnected", ev.event.code);
|
||||
|
||||
if (ev.event.code === EditorUpdateError.code) {
|
||||
setEditorVersionBehind(true);
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -310,7 +309,6 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
|
||||
)}
|
||||
<Editor
|
||||
{...props}
|
||||
readOnly={props.readOnly || editorVersionBehind}
|
||||
value={undefined}
|
||||
defaultValue={undefined}
|
||||
extensions={extensions}
|
||||
|
||||
@@ -58,9 +58,7 @@ function Invite({ onSubmit }: Props) {
|
||||
onSubmit();
|
||||
|
||||
if (response.length > 0) {
|
||||
toast.success(
|
||||
t("{{ count }} invites sent", { count: response.length })
|
||||
);
|
||||
toast.success(t("We sent out your invites!"));
|
||||
} else {
|
||||
toast.message(t("Those email addresses are already invited"));
|
||||
}
|
||||
@@ -225,8 +223,6 @@ function Invite({ onSubmit }: Props) {
|
||||
labelHidden={index !== 0}
|
||||
onKeyDown={handleKeyDown}
|
||||
onChange={(ev) => handleChange(ev, index)}
|
||||
autoComplete="off"
|
||||
data-1p-ignore
|
||||
value={invite.name}
|
||||
required={!!invite.email}
|
||||
flex
|
||||
|
||||
@@ -56,7 +56,6 @@ function Login({ children, onBack }: Props) {
|
||||
const location = useLocation();
|
||||
const query = useQuery();
|
||||
const notice = query.get("notice");
|
||||
const forceOTP = query.get("forceOTP");
|
||||
|
||||
const { t } = useTranslation();
|
||||
const user = useCurrentUser({ rejectOnEmpty: false });
|
||||
@@ -207,7 +206,7 @@ function Login({ children, onBack }: Props) {
|
||||
(provider) => provider.id === auth.lastSignedIn && !isCreate
|
||||
);
|
||||
const clientType = Desktop.isElectron() ? Client.Desktop : Client.Web;
|
||||
const preferOTP = isPWA || !!forceOTP;
|
||||
const preferOTP = isPWA;
|
||||
|
||||
if (firstRun) {
|
||||
return (
|
||||
@@ -325,7 +324,6 @@ function Login({ children, onBack }: Props) {
|
||||
<AuthenticationProvider
|
||||
isCreate={isCreate}
|
||||
onEmailSuccess={handleEmailSuccess}
|
||||
preferOTP={preferOTP}
|
||||
{...defaultProvider}
|
||||
/>
|
||||
{hasMultipleProviders && (
|
||||
@@ -350,7 +348,6 @@ function Login({ children, onBack }: Props) {
|
||||
key={provider.id}
|
||||
isCreate={isCreate}
|
||||
onEmailSuccess={handleEmailSuccess}
|
||||
preferOTP={preferOTP}
|
||||
neutral={defaultProvider && hasMultipleProviders}
|
||||
{...provider}
|
||||
/>
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { Client } from "@shared/types";
|
||||
import { isPWA } from "@shared/utils/browser";
|
||||
import ButtonLarge from "~/components/ButtonLarge";
|
||||
import InputLarge from "~/components/InputLarge";
|
||||
import PluginIcon from "~/components/PluginIcon";
|
||||
@@ -16,7 +17,6 @@ type Props = React.ComponentProps<typeof ButtonLarge> & {
|
||||
authUrl: string;
|
||||
isCreate: boolean;
|
||||
onEmailSuccess: (email: string) => void;
|
||||
preferOTP: boolean;
|
||||
};
|
||||
|
||||
type AuthState = "initial" | "email" | "code";
|
||||
@@ -28,6 +28,7 @@ function AuthenticationProvider(props: Props) {
|
||||
const [email, setEmail] = React.useState("");
|
||||
const { isCreate, id, name, authUrl, onEmailSuccess, ...rest } = props;
|
||||
const clientType = Desktop.isElectron() ? Client.Desktop : Client.Web;
|
||||
const preferOTP = isPWA;
|
||||
|
||||
const handleChangeEmail = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setEmail(event.target.value);
|
||||
@@ -45,7 +46,7 @@ function AuthenticationProvider(props: Props) {
|
||||
const response = await client.post(event.currentTarget.action, {
|
||||
email,
|
||||
client: clientType,
|
||||
preferOTP: props.preferOTP,
|
||||
preferOTP,
|
||||
});
|
||||
|
||||
if (response.redirect) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { observer } from "mobx-react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import queryString from "query-string";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -7,6 +6,7 @@ import { useHistory, useLocation, useRouteMatch } from "react-router-dom";
|
||||
import { Waypoint } from "react-waypoint";
|
||||
import styled from "styled-components";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { Pagination } from "@shared/constants";
|
||||
import { hideScrollbars } from "@shared/styles";
|
||||
import {
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
SmileyIcon,
|
||||
StarredIcon,
|
||||
UserIcon,
|
||||
GroupIcon,
|
||||
} from "outline-icons";
|
||||
import * as React from "react";
|
||||
import { useTranslation, Trans } from "react-i18next";
|
||||
@@ -71,14 +70,6 @@ function Notifications() {
|
||||
"Receive a notification when someone mentions you in a document or comment"
|
||||
),
|
||||
},
|
||||
{
|
||||
event: NotificationEventType.GroupMentionedInDocument,
|
||||
icon: <GroupIcon />,
|
||||
title: t("Group mentions"),
|
||||
description: t(
|
||||
"Receive a notification when someone mentions a group you are a member of in a document or comment"
|
||||
),
|
||||
},
|
||||
{
|
||||
event: NotificationEventType.ResolveComment,
|
||||
icon: <DoneIcon />,
|
||||
|
||||
@@ -29,7 +29,6 @@ import InputMemberPermissionSelect from "~/components/InputMemberPermissionSelec
|
||||
import { GroupPermission } from "@shared/types";
|
||||
import { EmptySelectValue, Permission } from "~/types";
|
||||
import GroupUser from "~/models/GroupUser";
|
||||
import Switch from "~/components/Switch";
|
||||
|
||||
type Props = {
|
||||
group: Group;
|
||||
@@ -104,9 +103,6 @@ export function CreateGroupDialog() {
|
||||
export function EditGroupDialog({ group, onSubmit }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const [name, setName] = React.useState(group.name);
|
||||
const [disableMentions, setDisableMentions] = React.useState(
|
||||
group.disableMentions || false
|
||||
);
|
||||
const [isSaving, setIsSaving] = React.useState(false);
|
||||
const handleSubmit = React.useCallback(
|
||||
async (ev: React.SyntheticEvent) => {
|
||||
@@ -116,7 +112,6 @@ export function EditGroupDialog({ group, onSubmit }: Props) {
|
||||
try {
|
||||
await group.save({
|
||||
name,
|
||||
disableMentions,
|
||||
});
|
||||
onSubmit();
|
||||
} catch (err) {
|
||||
@@ -125,7 +120,7 @@ export function EditGroupDialog({ group, onSubmit }: Props) {
|
||||
setIsSaving(false);
|
||||
}
|
||||
},
|
||||
[group, onSubmit, name, disableMentions]
|
||||
[group, onSubmit, name]
|
||||
);
|
||||
|
||||
const handleNameChange = React.useCallback(
|
||||
@@ -143,7 +138,7 @@ export function EditGroupDialog({ group, onSubmit }: Props) {
|
||||
often might confuse your team mates.
|
||||
</Trans>
|
||||
</Text>
|
||||
<Flex column>
|
||||
<Flex>
|
||||
<Input
|
||||
type="text"
|
||||
label={t("Name")}
|
||||
@@ -153,15 +148,6 @@ export function EditGroupDialog({ group, onSubmit }: Props) {
|
||||
autoFocus
|
||||
flex
|
||||
/>
|
||||
<Switch
|
||||
id="mentions"
|
||||
label={t("Disable mentions")}
|
||||
note={t(
|
||||
"Prevent this group from being mentionable in documents or comments"
|
||||
)}
|
||||
checked={disableMentions}
|
||||
onChange={setDisableMentions}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
<Button type="submit" disabled={isSaving || !name}>
|
||||
|
||||
@@ -43,13 +43,11 @@ export function MembersTable({ canManage, ...rest }: Props) {
|
||||
<Flex align="center" gap={8}>
|
||||
<Avatar model={user} size={AvatarSize.Large} />{" "}
|
||||
<Flex column>
|
||||
<Text selectable>
|
||||
<Text>
|
||||
{user.name} {currentUser.id === user.id && `(${t("You")})`}
|
||||
</Text>
|
||||
{isMobile && canManage && (
|
||||
<Text type="tertiary" selectable>
|
||||
{user.email}
|
||||
</Text>
|
||||
<Text type="tertiary">{user.email}</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -247,9 +247,9 @@ export default class CollectionsStore extends Store<Collection> {
|
||||
await this.rootStore.documents.fetchRecentlyViewed();
|
||||
}
|
||||
|
||||
export = (options: {
|
||||
format: FileOperationFormat;
|
||||
includeAttachments: boolean;
|
||||
includePrivate: boolean;
|
||||
}) => client.post("/collections.export_all", options);
|
||||
export = (format: FileOperationFormat, includeAttachments: boolean) =>
|
||||
client.post("/collections.export_all", {
|
||||
format,
|
||||
includeAttachments,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { observable, action } from "mobx";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import * as React from "react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
type DialogDefinition = {
|
||||
title: string;
|
||||
content: React.ReactNode;
|
||||
isOpen: boolean;
|
||||
style?: React.CSSProperties;
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
onClose?: () => void;
|
||||
};
|
||||
|
||||
@@ -51,12 +49,14 @@ export default class DialogsStore {
|
||||
content,
|
||||
replace,
|
||||
style,
|
||||
width,
|
||||
height,
|
||||
onClose,
|
||||
}: Omit<DialogDefinition, "isOpen"> & {
|
||||
}: {
|
||||
id?: string;
|
||||
title: string;
|
||||
content: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
replace?: boolean;
|
||||
onClose?: () => void;
|
||||
}) => {
|
||||
setTimeout(
|
||||
action(() => {
|
||||
@@ -70,8 +70,6 @@ export default class DialogsStore {
|
||||
title,
|
||||
content,
|
||||
style,
|
||||
width,
|
||||
height,
|
||||
isOpen: true,
|
||||
onClose,
|
||||
});
|
||||
|
||||
@@ -37,9 +37,6 @@ export default class PinsStore extends Store<Pin> {
|
||||
documentId,
|
||||
collectionId,
|
||||
});
|
||||
if (!res) {
|
||||
return;
|
||||
}
|
||||
invariant(res?.data, "Data should be available");
|
||||
return this.add(res.data);
|
||||
} catch (err) {
|
||||
|
||||
@@ -34,9 +34,6 @@ export default class SubscriptionsStore extends Store<Subscription> {
|
||||
|
||||
try {
|
||||
const res = await client.post(`/${this.apiEndpoint}.info`, options);
|
||||
if (!res) {
|
||||
return;
|
||||
}
|
||||
invariant(res?.data, "Data should be available");
|
||||
return this.add(res.data);
|
||||
} catch (err) {
|
||||
|
||||
@@ -86,9 +86,6 @@ class UiStore {
|
||||
@observable
|
||||
multiplayerErrorCode?: number;
|
||||
|
||||
@observable
|
||||
debugSafeArea = false;
|
||||
|
||||
rootStore: RootStore;
|
||||
|
||||
constructor(rootStore: RootStore) {
|
||||
@@ -251,11 +248,6 @@ class UiStore {
|
||||
this.mobileSidebarVisible = false;
|
||||
};
|
||||
|
||||
@action
|
||||
toggleDebugSafeArea = () => {
|
||||
this.debugSafeArea = !this.debugSafeArea;
|
||||
};
|
||||
|
||||
@computed
|
||||
get readyToShow() {
|
||||
return (
|
||||
|
||||
+14
-10
@@ -22,7 +22,6 @@ import { Searchable } from "~/models/interfaces/Searchable";
|
||||
import type { PaginationParams, PartialExcept, Properties } from "~/types";
|
||||
import { client } from "~/utils/ApiClient";
|
||||
import { AuthorizationError, NotFoundError } from "~/utils/errors";
|
||||
import ParanoidModel from "~/models/base/ParanoidModel";
|
||||
|
||||
export enum RPCAction {
|
||||
Info = "info",
|
||||
@@ -101,13 +100,24 @@ export default abstract class Store<T extends Model> {
|
||||
|
||||
if (!normalized) {
|
||||
return this.orderedData
|
||||
.filter((item: T & Searchable) => !item.searchSuppressed)
|
||||
.filter((item) => {
|
||||
if ("deletedAt" in item && item.deletedAt) {
|
||||
return false;
|
||||
}
|
||||
if ("archivedAt" in item && item.archivedAt) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.slice(0, options?.maxResults);
|
||||
}
|
||||
|
||||
return this.orderedData
|
||||
.filter((item: T & Searchable) => {
|
||||
if (item.searchSuppressed) {
|
||||
if ("deletedAt" in item && item.deletedAt) {
|
||||
return false;
|
||||
}
|
||||
if ("archivedAt" in item && item.archivedAt) {
|
||||
return false;
|
||||
}
|
||||
if ("searchContent" in item) {
|
||||
@@ -202,13 +212,7 @@ export default abstract class Store<T extends Model> {
|
||||
}
|
||||
|
||||
LifecycleManager.executeHooks(model.constructor, "beforeRemove", model);
|
||||
|
||||
if (model instanceof ParanoidModel) {
|
||||
model.deletedAt = new Date().toISOString();
|
||||
} else {
|
||||
this.data.delete(id);
|
||||
}
|
||||
|
||||
this.data.delete(id);
|
||||
LifecycleManager.executeHooks(model.constructor, "afterRemove", model);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -150,6 +150,7 @@ declare module "styled-components" {
|
||||
menuItemSelected: string;
|
||||
menuBackground: string;
|
||||
menuShadow: string;
|
||||
menuBorder?: string;
|
||||
divider: string;
|
||||
titleBarDivider: string;
|
||||
inputBorder: string;
|
||||
|
||||
+31
-32
@@ -41,7 +41,7 @@
|
||||
"url": "https://github.com/sponsors/outline"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.12 <21 || 22"
|
||||
"node": "20 || 22"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -51,21 +51,21 @@
|
||||
"> 0.25%, not dead"
|
||||
],
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "3.917.0",
|
||||
"@aws-sdk/lib-storage": "3.917.0",
|
||||
"@aws-sdk/s3-presigned-post": "3.917.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.917.0",
|
||||
"@aws-sdk/signature-v4-crt": "^3.916.0",
|
||||
"@babel/core": "^7.28.5",
|
||||
"@aws-sdk/client-s3": "3.896.0",
|
||||
"@aws-sdk/lib-storage": "3.896.0",
|
||||
"@aws-sdk/s3-presigned-post": "3.896.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.896.0",
|
||||
"@aws-sdk/signature-v4-crt": "^3.896.0",
|
||||
"@babel/core": "^7.28.4",
|
||||
"@babel/plugin-proposal-decorators": "^7.28.0",
|
||||
"@babel/plugin-transform-class-properties": "^7.27.1",
|
||||
"@babel/plugin-transform-destructuring": "^7.28.5",
|
||||
"@babel/plugin-transform-destructuring": "^7.28.0",
|
||||
"@babel/plugin-transform-regenerator": "^7.28.4",
|
||||
"@babel/preset-env": "^7.28.5",
|
||||
"@babel/preset-react": "^7.28.5",
|
||||
"@babel/preset-env": "^7.28.3",
|
||||
"@babel/preset-react": "^7.27.1",
|
||||
"@benrbray/prosemirror-math": "^0.2.2",
|
||||
"@bull-board/api": "^6.7.10",
|
||||
"@bull-board/koa": "^6.13.0",
|
||||
"@bull-board/koa": "^6.12.0",
|
||||
"@css-inline/css-inline-wasm": "^0.17.0",
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/modifiers": "^6.0.1",
|
||||
@@ -73,9 +73,9 @@
|
||||
"@dotenvx/dotenvx": "^1.49.0",
|
||||
"@emoji-mart/data": "^1.2.1",
|
||||
"@fast-csv/parse": "^5.0.5",
|
||||
"@fortawesome/fontawesome-svg-core": "^7.1.0",
|
||||
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||
"@fortawesome/fontawesome-svg-core": "^7.0.1",
|
||||
"@fortawesome/free-brands-svg-icons": "^7.0.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^7.0.1",
|
||||
"@fortawesome/react-fontawesome": "^0.2.6",
|
||||
"@getoutline/react-roving-tabindex": "^3.2.4",
|
||||
"@hocuspocus/extension-redis": "1.1.2",
|
||||
@@ -133,14 +133,14 @@
|
||||
"diff": "^5.2.0",
|
||||
"email-providers": "^1.14.0",
|
||||
"emoji-mart": "^5.6.0",
|
||||
"emoji-regex": "^10.6.0",
|
||||
"emoji-regex": "^10.5.0",
|
||||
"es6-error": "^4.1.1",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fetch-retry": "^5.0.6",
|
||||
"form-data": "^4.0.4",
|
||||
"fractional-index": "^1.0.0",
|
||||
"framer-motion": "^4.1.17",
|
||||
"fs-extra": "^11.3.2",
|
||||
"fs-extra": "^11.3.1",
|
||||
"fuzzy-search": "^3.2.1",
|
||||
"glob": "^8.1.0",
|
||||
"http-errors": "2.0.0",
|
||||
@@ -149,14 +149,14 @@
|
||||
"i18next-fs-backend": "^2.6.0",
|
||||
"i18next-http-backend": "^2.7.3",
|
||||
"invariant": "^2.2.4",
|
||||
"ioredis": "^5.8.2",
|
||||
"ioredis": "^5.7.0",
|
||||
"is-printable-key-event": "^1.0.0",
|
||||
"jsdom": "^22.1.0",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"jszip": "^3.10.1",
|
||||
"katex": "^0.16.22",
|
||||
"kbar": "0.1.0-beta.48",
|
||||
"koa": "^3.0.3",
|
||||
"koa": "^3.0.1",
|
||||
"koa-body": "^6.0.1",
|
||||
"koa-compress": "^5.1.1",
|
||||
"koa-helmet": "^6.1.0",
|
||||
@@ -179,15 +179,15 @@
|
||||
"mobx-utils": "^4.0.1",
|
||||
"natural-sort": "^1.0.0",
|
||||
"node-fetch": "2.7.0",
|
||||
"nodemailer": "^7.0.7",
|
||||
"nodemailer": "^6.10.1",
|
||||
"octokit": "^3.2.2",
|
||||
"outline-icons": "^3.13.1",
|
||||
"outline-icons": "^3.12.1",
|
||||
"oy-vey": "^0.12.1",
|
||||
"passport": "^0.7.0",
|
||||
"passport-google-oauth2": "^0.2.0",
|
||||
"passport-oauth2": "^1.8.0",
|
||||
"passport-slack-oauth2": "^1.2.0",
|
||||
"patch-package": "^8.0.1",
|
||||
"patch-package": "^8.0.0",
|
||||
"pg": "^8.16.3",
|
||||
"pg-tsquery": "^8.4.2",
|
||||
"pluralize": "^8.0.0",
|
||||
@@ -228,7 +228,6 @@
|
||||
"react-virtualized-auto-sizer": "^1.0.26",
|
||||
"react-waypoint": "^10.3.0",
|
||||
"react-window": "^1.8.11",
|
||||
"react-zoom-pan-pinch": "^3.7.0",
|
||||
"redlock": "^5.0.0-beta.2",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"refractor": "^3.6.0",
|
||||
@@ -262,8 +261,8 @@
|
||||
"ukkonen": "^2.2.0",
|
||||
"umzug": "^3.8.2",
|
||||
"utility-types": "^3.11.0",
|
||||
"uuid": "^11.1.0",
|
||||
"validator": "13.15.20",
|
||||
"uuid": "^8.3.2",
|
||||
"validator": "13.15.15",
|
||||
"vaul": "^1.1.2",
|
||||
"vite": "npm:rolldown-vite@latest",
|
||||
"vite-plugin-pwa": "1.0.3",
|
||||
@@ -278,7 +277,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.28.3",
|
||||
"@babel/preset-typescript": "^7.28.5",
|
||||
"@babel/preset-typescript": "^7.27.1",
|
||||
"@faker-js/faker": "^8.4.1",
|
||||
"@relative-ci/agent": "^4.3.1",
|
||||
"@types/addressparser": "^1.0.3",
|
||||
@@ -313,7 +312,7 @@
|
||||
"@types/markdown-it-emoji": "^3.0.1",
|
||||
"@types/mime-types": "^3.0.1",
|
||||
"@types/natural-sort": "^0.0.24",
|
||||
"@types/node": "20.19.21",
|
||||
"@types/node": "20.17.30",
|
||||
"@types/node-fetch": "^2.6.9",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
"@types/passport-oauth2": "^1.8.0",
|
||||
@@ -330,7 +329,7 @@
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@types/react-virtualized-auto-sizer": "^1.0.8",
|
||||
"@types/react-window": "^1.8.8",
|
||||
"@types/readable-stream": "^4.0.22",
|
||||
"@types/readable-stream": "^4.0.21",
|
||||
"@types/redis-info": "^3.0.3",
|
||||
"@types/refractor": "^3.4.1",
|
||||
"@types/resolve-path": "^1.4.3",
|
||||
@@ -343,7 +342,7 @@
|
||||
"@types/tmp": "^0.2.6",
|
||||
"@types/turndown": "^5.0.5",
|
||||
"@types/utf8": "^3.0.3",
|
||||
"@types/validator": "^13.15.3",
|
||||
"@types/validator": "^13.15.2",
|
||||
"@types/yauzl": "^2.10.3",
|
||||
"babel-jest": "^29.7.0",
|
||||
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
||||
@@ -351,7 +350,7 @@
|
||||
"babel-plugin-tsconfig-paths-module-resolver": "^1.0.4",
|
||||
"browserslist-to-esbuild": "^1.2.0",
|
||||
"concurrently": "^8.2.2",
|
||||
"discord-api-types": "^0.38.30",
|
||||
"discord-api-types": "^0.38.20",
|
||||
"husky": "^8.0.3",
|
||||
"i18next-parser": "^8.13.0",
|
||||
"ioredis-mock": "^8.9.0",
|
||||
@@ -364,9 +363,9 @@
|
||||
"oxlint-tsgolint": "^0.1.6",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"prettier": "^3.6.2",
|
||||
"react-refresh": "^0.18.0",
|
||||
"react-refresh": "^0.17.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"rollup-plugin-webpack-stats": "2.1.6",
|
||||
"rollup-plugin-webpack-stats": "2.1.3",
|
||||
"terser": "^5.43.1",
|
||||
"typescript": "^5.9.2",
|
||||
"yarn-deduplicate": "^6.0.2"
|
||||
@@ -382,6 +381,6 @@
|
||||
"qs": "6.9.7",
|
||||
"prismjs": "1.30.0"
|
||||
},
|
||||
"version": "1.0.1",
|
||||
"version": "0.87.4",
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user