diff --git a/.babelrc b/.babelrc
index 0c352c9772..4696bad1fd 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,18 +1,29 @@
{
- "presets": ["react", "env"],
+ "presets": [
+ "@babel/preset-react",
+ "@babel/preset-flow",
+ [
+ "@babel/preset-env",
+ {
+ "corejs": {
+ "version": "2",
+ "proposals": true
+ },
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
"plugins": [
"lodash",
"styled-components",
- "transform-decorators-legacy",
- "transform-es2015-destructuring",
- "transform-object-rest-spread",
- "transform-regenerator",
- "transform-class-properties",
- "syntax-dynamic-import"
- ],
- "env": {
- "development": {
- "presets": ["react-hmre"]
- }
- }
-}
+ [
+ "@babel/plugin-proposal-decorators",
+ {
+ "legacy": true
+ }
+ ],
+ "@babel/plugin-transform-destructuring",
+ "@babel/plugin-transform-regenerator",
+ "transform-class-properties"
+ ]
+}
\ No newline at end of file
diff --git a/.circleci/config.yml b/.circleci/config.yml
index b837f37db8..8c6bccd76e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -3,7 +3,7 @@ jobs:
build:
working_directory: ~/outline
docker:
- - image: circleci/node:12
+ - image: circleci/node:14
- image: circleci/redis:latest
- image: circleci/postgres:9.6.5-alpine-ram
environment:
@@ -29,12 +29,15 @@ jobs:
- run:
name: migrate
command: ./node_modules/.bin/sequelize db:migrate --url $DATABASE_URL_TEST
- - run:
- name: test
- command: yarn test
- run:
name: lint
command: yarn lint
- run:
name: flow
- command: yarn flow check --max-workers 4
\ No newline at end of file
+ command: yarn flow check --max-workers 4
+ - run:
+ name: test
+ command: yarn test
+ - run:
+ name: build
+ command: yarn build
\ No newline at end of file
diff --git a/.env.sample b/.env.sample
index 379c02fd3f..da9204d2ed 100644
--- a/.env.sample
+++ b/.env.sample
@@ -18,7 +18,6 @@ PORT=3000
FORCE_HTTPS=true
ENABLE_UPDATES=true
-WEBSOCKETS_ENABLED=true
DEBUG=cache,presenters,events
# Third party signin credentials (at least one is required)
@@ -46,6 +45,7 @@ AWS_REGION=xx-xxxx-x
AWS_S3_UPLOAD_BUCKET_URL=http://s3:4569
AWS_S3_UPLOAD_BUCKET_NAME=bucket_name_here
AWS_S3_UPLOAD_MAX_SIZE=26214400
+AWS_S3_FORCE_PATH_STYLE=true
# uploaded s3 objects permission level, default is private
# set to "public-read" to allow public access
AWS_S3_ACL=private
diff --git a/.eslintrc b/.eslintrc
index 65facbe73d..8eeaa95b1d 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -4,7 +4,8 @@
"react-app",
"plugin:import/errors",
"plugin:import/warnings",
- "plugin:flowtype/recommended"
+ "plugin:flowtype/recommended",
+ "plugin:react-hooks/recommended"
],
"plugins": [
"prettier",
@@ -14,6 +15,46 @@
"eqeqeq": 2,
"no-unused-vars": 2,
"no-mixed-operators": "off",
+ "import/order": [
+ "error",
+ {
+ "alphabetize": {
+ "order": "asc"
+ },
+ "pathGroups": [
+ {
+ "pattern": "shared/**",
+ "group": "external",
+ "position": "after"
+ },
+ {
+ "pattern": "stores",
+ "group": "external",
+ "position": "after"
+ },
+ {
+ "pattern": "stores/**",
+ "group": "external",
+ "position": "after"
+ },
+ {
+ "pattern": "models/**",
+ "group": "external",
+ "position": "after"
+ },
+ {
+ "pattern": "scenes/**",
+ "group": "external",
+ "position": "after"
+ },
+ {
+ "pattern": "components/**",
+ "group": "external",
+ "position": "after"
+ }
+ ]
+ }
+ ],
"flowtype/require-valid-file-annotation": [
2,
"always",
@@ -41,8 +82,7 @@
"react": {
"createClass": "createReactClass",
"pragma": "React",
- "version": "detect",
- "flowVersion": "0.86"
+ "version": "detect"
},
"import/resolver": {
"node": {
@@ -60,12 +100,6 @@
"jest": true
},
"globals": {
- "__DEV__": true,
- "SLACK_KEY": true,
- "DEPLOYMENT": true,
- "BASE_URL": true,
- "SENTRY_DSN": true,
- "afterAll": true,
- "Sentry": true
+ "EDITOR_VERSION": true
}
}
\ No newline at end of file
diff --git a/.flowconfig b/.flowconfig
index 88c4cfdef4..23473ecb06 100644
--- a/.flowconfig
+++ b/.flowconfig
@@ -7,6 +7,7 @@
.*/node_modules/tiny-cookie/flow/.*
.*/node_modules/styled-components/.*
.*/node_modules/polished/.*
+.*/node_modules/mobx/.*.flow
.*/node_modules/react-side-effect/.*
.*/node_modules/fbjs/.*
.*/node_modules/config-chain/.*
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 30300b1609..f5852ab567 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,6 @@
{
- "javascript.validate.enable": false
+ "javascript.validate.enable": false,
+ "typescript.validate.enable": false,
+ "editor.formatOnSave": true,
+ "typescript.format.enable": false
}
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 5dc4ecba4c..5f61043c0b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,8 +9,9 @@ WORKDIR $APP_PATH
COPY . $APP_PATH
RUN yarn install --pure-lockfile
+RUN yarn build
RUN cp -r /opt/outline/node_modules /opt/node_modules
-CMD yarn build && yarn start
+CMD yarn start
EXPOSE 3000
diff --git a/LICENSE b/LICENSE
index b2bbcbf56b..0434a877eb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -3,7 +3,7 @@ Business Source License 1.1
Parameters
Licensor: General Outline, Inc.
-Licensed Work: Outline 0.44.0
+Licensed Work: Outline 0.46.0
The Licensed Work is (c) 2020 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: 2023-07-03
+Change Date: 2023-08-12
Change License: Apache License, Version 2.0
diff --git a/Makefile b/Makefile
index a52cbca923..ee874f9a72 100644
--- a/Makefile
+++ b/Makefile
@@ -8,10 +8,12 @@ build:
docker-compose build --pull outline
test:
- docker-compose run --rm outline yarn test
+ docker-compose up -d redis postgres s3
+ yarn test
watch:
- docker-compose run --rm outline yarn test:watch
+ docker-compose up -d redis postgres s3
+ yarn test:watch
destroy:
docker-compose stop
diff --git a/README.md b/README.md
index 2f5c80e827..fad373ed4a 100644
--- a/README.md
+++ b/README.md
@@ -126,7 +126,6 @@ Backend is driven by [Koa](http://koajs.com/) (API, web server), [Sequelize](htt
- `server/commands` - Domain logic, currently being refactored from /models
- `server/emails` - React rendered email templates
- `server/models` - Database models
-- `server/pages` - Server-side rendered public pages
- `server/policies` - Authorization logic
- `server/presenters` - API responses for database models
- `server/test` - Test helps and support
@@ -154,7 +153,7 @@ yarn test:app
Outline is built and maintained by a small team – we'd love your help to fix bugs and add features!
-However, before working on a pull request please let the core team know by creating or commenting in an issue on [GitHub](https://www.github.com/outline/outline/issues), and we'd also love to hear from you in our [Spectrum community](https://spectrum.chat/outline). This way we can ensure that an approach is agreed on before code is written and will hopefully help to get your contributions integrated faster!
+However, before working on a pull request please let the core team know by creating or commenting in an issue on [GitHub](https://www.github.com/outline/outline/issues), and we'd also love to hear from you in the [Discussions](https://www.github.com/outline/outline/discussions). This way we can ensure that an approach is agreed on before code is written and will hopefully help to get your contributions integrated faster!
If you’re looking for ways to get started, here's a list of ways to help us improve Outline:
@@ -162,7 +161,6 @@ If you’re looking for ways to get started, here's a list of ways to help us im
* Performance improvements, both on server and frontend
* Developer happiness and documentation
* Bugs and other issues listed on GitHub
-* Helping others on Spectrum
## License
diff --git a/app.json b/app.json
index 5670a10766..5aa7e99097 100644
--- a/app.json
+++ b/app.json
@@ -39,11 +39,6 @@
"value": "true",
"required": true
},
- "WEBSOCKETS_ENABLED": {
- "value": "true",
- "required": true,
- "description": "Allow realtime data to be pushed to clients over websockets"
- },
"URL": {
"description": "https://{your app name}.herokuapp.com",
"required": true
@@ -97,6 +92,11 @@
"value": "26214400",
"required": false
},
+ "AWS_S3_FORCE_PATH_STYLE": {
+ "description": "Use path-style URL's for connecting to S3 instead of subdomain. This is useful for S3-compatible storage.",
+ "value": "true",
+ "required": false
+ },
"AWS_REGION": {
"value": "us-east-1",
"description": "Region in which the above S3 bucket exists",
diff --git a/app/components/Actions.js b/app/components/Actions.js
index 920f389933..2e3fbf41da 100644
--- a/app/components/Actions.js
+++ b/app/components/Actions.js
@@ -1,7 +1,7 @@
// @flow
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
-import Flex from "shared/components/Flex";
+import Flex from "components/Flex";
export const Action = styled(Flex)`
justify-content: center;
@@ -12,9 +12,13 @@ export const Action = styled(Flex)`
flex-shrink: 0;
a {
- color: ${props => props.theme.text};
+ color: ${(props) => props.theme.text};
height: 24px;
}
+
+ &:empty {
+ display: none;
+ }
`;
export const Separator = styled.div`
@@ -22,7 +26,7 @@ export const Separator = styled.div`
margin-left: 12px;
width: 1px;
height: 28px;
- background: ${props => props.theme.divider};
+ background: ${(props) => props.theme.divider};
`;
const Actions = styled(Flex)`
@@ -31,8 +35,8 @@ const Actions = styled(Flex)`
right: 0;
left: 0;
border-radius: 3px;
- background: ${props => props.theme.background};
- transition: ${props => props.theme.backgroundTransition};
+ background: ${(props) => props.theme.background};
+ transition: ${(props) => props.theme.backgroundTransition};
padding: 12px;
-webkit-backdrop-filter: blur(20px);
diff --git a/app/components/Alert.js b/app/components/Alert.js
deleted file mode 100644
index 629a3c228f..0000000000
--- a/app/components/Alert.js
+++ /dev/null
@@ -1,36 +0,0 @@
-// @flow
-import * as React from "react";
-import { observer } from "mobx-react";
-import Flex from "shared/components/Flex";
-import styled from "styled-components";
-
-type Props = {
- children: React.Node,
- type?: "info" | "success" | "warning" | "danger" | "offline",
-};
-
-@observer
-class Alert extends React.Component {
- defaultProps = {
- type: "info",
- };
-
- render() {
- return (
-
- {this.props.children}
-
- );
- }
-}
-
-const Container = styled(Flex)`
- height: $headerHeight;
- color: ${props => props.theme.white};
- font-size: 14px;
- line-height: 1;
-
- background-color: ${({ theme, type }) => theme.color[type]};
-`;
-
-export default Alert;
diff --git a/app/components/Analytics.js b/app/components/Analytics.js
index 284c203be4..49e4798d09 100644
--- a/app/components/Analytics.js
+++ b/app/components/Analytics.js
@@ -1,6 +1,7 @@
// @flow
/* global ga */
import * as React from "react";
+import env from "env";
type Props = {
children?: React.Node,
@@ -8,19 +9,19 @@ type Props = {
export default class Analytics extends React.Component {
componentDidMount() {
- if (!process.env.GOOGLE_ANALYTICS_ID) return;
+ if (!env.GOOGLE_ANALYTICS_ID) return;
// standard Google Analytics script
window.ga =
window.ga ||
- function() {
+ function () {
// $FlowIssue
(ga.q = ga.q || []).push(arguments);
};
// $FlowIssue
ga.l = +new Date();
- ga("create", process.env.GOOGLE_ANALYTICS_ID, "auto");
+ ga("create", env.GOOGLE_ANALYTICS_ID, "auto");
ga("set", { dimension1: "true" });
ga("send", "pageview");
diff --git a/app/components/Authenticated.js b/app/components/Authenticated.js
index a81a82001e..4b0193f867 100644
--- a/app/components/Authenticated.js
+++ b/app/components/Authenticated.js
@@ -1,9 +1,11 @@
// @flow
-import * as React from "react";
import { observer, inject } from "mobx-react";
+import * as React from "react";
+import { Redirect } from "react-router-dom";
+import { isCustomSubdomain } from "shared/utils/domains";
import AuthStore from "stores/AuthStore";
import LoadingIndicator from "components/LoadingIndicator";
-import { isCustomSubdomain } from "shared/utils/domains";
+import env from "env";
type Props = {
auth: AuthStore,
@@ -22,7 +24,7 @@ const Authenticated = observer(({ auth, children }: Props) => {
// If we're authenticated but viewing a subdomain that doesn't match the
// currently authenticated team then kick the user to the teams subdomain.
if (
- process.env.SUBDOMAINS_ENABLED &&
+ env.SUBDOMAINS_ENABLED &&
team.subdomain &&
isCustomSubdomain(hostname) &&
!hostname.startsWith(`${team.subdomain}.`)
@@ -35,7 +37,7 @@ const Authenticated = observer(({ auth, children }: Props) => {
}
auth.logout(true);
- return null;
+ return ;
});
export default inject("auth")(Authenticated);
diff --git a/app/components/Avatar/Avatar.js b/app/components/Avatar/Avatar.js
index 1066a34a68..46b0e594b0 100644
--- a/app/components/Avatar/Avatar.js
+++ b/app/components/Avatar/Avatar.js
@@ -1,8 +1,8 @@
// @flow
-import * as React from "react";
-import styled from "styled-components";
import { observable } from "mobx";
import { observer } from "mobx-react";
+import * as React from "react";
+import styled from "styled-components";
import placeholder from "./placeholder.png";
type Props = {
@@ -48,8 +48,8 @@ const IconWrapper = styled.div`
position: absolute;
bottom: -2px;
right: -2px;
- background: ${props => props.theme.primary};
- border: 2px solid ${props => props.theme.background};
+ background: ${(props) => props.theme.primary};
+ border: 2px solid ${(props) => props.theme.background};
border-radius: 100%;
width: 20px;
height: 20px;
@@ -57,10 +57,10 @@ const IconWrapper = styled.div`
const CircleImg = styled.img`
display: block;
- width: ${props => props.size}px;
- height: ${props => props.size}px;
+ width: ${(props) => props.size}px;
+ height: ${(props) => props.size}px;
border-radius: 50%;
- border: 2px solid ${props => props.theme.background};
+ border: 2px solid ${(props) => props.theme.background};
flex-shrink: 0;
`;
diff --git a/app/components/Avatar/AvatarWithPresence.js b/app/components/Avatar/AvatarWithPresence.js
index 1d2f6f5cc1..0f1e97b8a2 100644
--- a/app/components/Avatar/AvatarWithPresence.js
+++ b/app/components/Avatar/AvatarWithPresence.js
@@ -1,14 +1,14 @@
// @flow
-import * as React from "react";
+import distanceInWordsToNow from "date-fns/distance_in_words_to_now";
import { observable } from "mobx";
import { observer } from "mobx-react";
+import { EditIcon } from "outline-icons";
+import * as React from "react";
import styled from "styled-components";
-import distanceInWordsToNow from "date-fns/distance_in_words_to_now";
-import Avatar from "components/Avatar";
-import Tooltip from "components/Tooltip";
import User from "models/User";
import UserProfile from "scenes/UserProfile";
-import { EditIcon } from "outline-icons";
+import Avatar from "components/Avatar";
+import Tooltip from "components/Tooltip";
type Props = {
user: User,
@@ -40,14 +40,16 @@ class AvatarWithPresence extends React.Component {
} = this.props;
return (
-
+ <>
{user.name} {isCurrentUser && "(You)"}
{isPresent
- ? isEditing ? "currently editing" : "currently viewing"
+ ? isEditing
+ ? "currently editing"
+ : "currently viewing"
: `viewed ${distanceInWordsToNow(new Date(lastViewedAt))} ago`}
}
@@ -67,7 +69,7 @@ class AvatarWithPresence extends React.Component {
isOpen={this.isOpen}
onRequestClose={this.handleCloseProfile}
/>
-
+ >
);
}
}
@@ -77,7 +79,7 @@ const Centered = styled.div`
`;
const AvatarWrapper = styled.div`
- opacity: ${props => (props.isPresent ? 1 : 0.5)};
+ opacity: ${(props) => (props.isPresent ? 1 : 0.5)};
transition: opacity 250ms ease-in-out;
`;
diff --git a/app/components/Badge.js b/app/components/Badge.js
index d79082e46e..646fede8dd 100644
--- a/app/components/Badge.js
+++ b/app/components/Badge.js
@@ -4,9 +4,9 @@ import styled from "styled-components";
const Badge = styled.span`
margin-left: 10px;
padding: 2px 6px 3px;
- background-color: ${({ admin, theme }) =>
- admin ? theme.primary : theme.textTertiary};
- color: ${({ admin, theme }) => (admin ? theme.white : theme.background)};
+ background-color: ${({ primary, theme }) =>
+ primary ? theme.primary : theme.textTertiary};
+ color: ${({ primary, theme }) => (primary ? theme.white : theme.background)};
border-radius: 4px;
font-size: 11px;
font-weight: 500;
diff --git a/shared/components/Branding.js b/app/components/Branding.js
similarity index 64%
rename from shared/components/Branding.js
rename to app/components/Branding.js
index 610d7c7e09..38a90a3406 100644
--- a/shared/components/Branding.js
+++ b/app/components/Branding.js
@@ -2,15 +2,17 @@
import * as React from "react";
import styled from "styled-components";
import OutlineLogo from "./OutlineLogo";
+import env from "env";
type Props = {
href?: string,
};
-function Branding({ href = process.env.URL }: Props) {
+function Branding({ href = env.URL }: Props) {
return (
- Outline
+
+ Outline
);
}
@@ -24,17 +26,17 @@ const Link = styled.a`
font-size: 14px;
text-decoration: none;
border-top-right-radius: 2px;
- color: ${props => props.theme.text};
+ color: ${(props) => props.theme.text};
display: flex;
align-items: center;
padding: 16px;
svg {
- fill: ${props => props.theme.text};
+ fill: ${(props) => props.theme.text};
}
&:hover {
- background: ${props => props.theme.sidebarBackground};
+ background: ${(props) => props.theme.sidebarBackground};
}
`;
diff --git a/shared/components/Breadcrumb.js b/app/components/Breadcrumb.js
similarity index 72%
rename from shared/components/Breadcrumb.js
rename to app/components/Breadcrumb.js
index baae01d773..08cc104e77 100644
--- a/shared/components/Breadcrumb.js
+++ b/app/components/Breadcrumb.js
@@ -1,17 +1,23 @@
// @flow
-import * as React from "react";
import { observer, inject } from "mobx-react";
-import breakpoint from "styled-components-breakpoint";
-import styled from "styled-components";
+import {
+ PadlockIcon,
+ GoToIcon,
+ MoreIcon,
+ ShapesIcon,
+ EditIcon,
+} from "outline-icons";
+import * as React from "react";
import { Link } from "react-router-dom";
-import { PadlockIcon, GoToIcon, MoreIcon } from "outline-icons";
+import styled from "styled-components";
+import breakpoint from "styled-components-breakpoint";
-import Document from "models/Document";
import CollectionsStore from "stores/CollectionsStore";
-import { collectionUrl } from "utils/routeHelpers";
-import Flex from "shared/components/Flex";
-import BreadcrumbMenu from "./BreadcrumbMenu";
+import Document from "models/Document";
import CollectionIcon from "components/CollectionIcon";
+import Flex from "components/Flex";
+import BreadcrumbMenu from "./BreadcrumbMenu";
+import { collectionUrl } from "utils/routeHelpers";
type Props = {
document: Document,
@@ -27,45 +33,68 @@ const Breadcrumb = observer(({ document, collections, onlyText }: Props) => {
if (onlyText === true) {
return (
-
+ <>
{collection.private && (
-
+ <>
{" "}
-
+ >
)}
{collection.name}
- {path.map(n => (
+ {path.map((n) => (
{n.title}
))}
-
+ >
);
}
+ const isTemplate = document.isTemplate;
+ const isDraft = !document.publishedAt && !isTemplate;
const isNestedDocument = path.length > 1;
const lastPath = path.length ? path[path.length - 1] : undefined;
const menuPath = isNestedDocument ? path.slice(0, -1) : [];
return (
+ {isTemplate && (
+ <>
+
+
+
+ Templates
+
+
+ >
+ )}
+ {isDraft && (
+ <>
+
+
+
+ Drafts
+
+
+ >
+ )}
- {" "}
+
+
{collection.name}
{isNestedDocument && (
-
+ <>
} path={menuPath} />
-
+ >
)}
{lastPath && (
-
+ <>
{" "}
{lastPath.title}
-
+ >
)}
);
@@ -93,7 +122,7 @@ const SmallSlash = styled(GoToIcon)`
export const Slash = styled(GoToIcon)`
flex-shrink: 0;
- fill: ${props => props.theme.divider};
+ fill: ${(props) => props.theme.divider};
`;
const Overflow = styled(MoreIcon)`
@@ -108,7 +137,7 @@ const Overflow = styled(MoreIcon)`
`;
const Crumb = styled(Link)`
- color: ${props => props.theme.text};
+ color: ${(props) => props.theme.text};
font-size: 15px;
height: 24px;
text-overflow: ellipsis;
@@ -123,7 +152,7 @@ const Crumb = styled(Link)`
const CollectionName = styled(Link)`
display: flex;
flex-shrink: 0;
- color: ${props => props.theme.text};
+ color: ${(props) => props.theme.text};
font-size: 15px;
font-weight: 500;
white-space: nowrap;
diff --git a/shared/components/BreadcrumbMenu.js b/app/components/BreadcrumbMenu.js
similarity index 95%
rename from shared/components/BreadcrumbMenu.js
rename to app/components/BreadcrumbMenu.js
index 18aacf2acc..fb372727c7 100644
--- a/shared/components/BreadcrumbMenu.js
+++ b/app/components/BreadcrumbMenu.js
@@ -14,7 +14,7 @@ export default class BreadcrumbMenu extends React.Component {
return (
- {path.map(item => (
+ {path.map((item) => (
{item.title}
diff --git a/app/components/Button.js b/app/components/Button.js
index 45a7e1285a..ba18085f73 100644
--- a/app/components/Button.js
+++ b/app/components/Button.js
@@ -1,16 +1,17 @@
// @flow
+import { ExpandedIcon } from "outline-icons";
+import { darken, lighten } from "polished";
import * as React from "react";
import styled from "styled-components";
-import { darken, lighten } from "polished";
-import { ExpandedIcon } from "outline-icons";
const RealButton = styled.button`
- display: inline-block;
+ display: ${(props) => (props.fullwidth ? "block" : "inline-block")};
+ width: ${(props) => (props.fullwidth ? "100%" : "auto")};
margin: 0;
padding: 0;
border: 0;
- background: ${props => props.theme.buttonBackground};
- color: ${props => props.theme.buttonText};
+ background: ${(props) => props.theme.buttonBackground};
+ color: ${(props) => props.theme.buttonText};
box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 2px;
border-radius: 4px;
font-size: 14px;
@@ -23,7 +24,7 @@ const RealButton = styled.button`
user-select: none;
svg {
- fill: ${props => props.iconColor || props.theme.buttonText};
+ fill: ${(props) => props.iconColor || props.theme.buttonText};
}
&::-moz-focus-inner {
@@ -32,12 +33,12 @@ const RealButton = styled.button`
}
&:hover {
- background: ${props => darken(0.05, props.theme.buttonBackground)};
+ background: ${(props) => darken(0.05, props.theme.buttonBackground)};
}
&:focus {
transition-duration: 0.05s;
- box-shadow: ${props => lighten(0.4, props.theme.buttonBackground)} 0px 0px
+ box-shadow: ${(props) => lighten(0.4, props.theme.buttonBackground)} 0px 0px
0px 3px;
outline: none;
}
@@ -45,10 +46,10 @@ const RealButton = styled.button`
&:disabled {
cursor: default;
pointer-events: none;
- color: ${props => props.theme.white50};
+ color: ${(props) => props.theme.white50};
}
- ${props =>
+ ${(props) =>
props.neutral &&
`
background: ${props.theme.buttonNeutralBackground};
@@ -79,9 +80,9 @@ const RealButton = styled.button`
&:disabled {
color: ${props.theme.textTertiary};
}
- `} ${props =>
- props.danger &&
- `
+ `} ${(props) =>
+ props.danger &&
+ `
background: ${props.theme.danger};
color: ${props.theme.white};
@@ -102,19 +103,20 @@ const Label = styled.span`
white-space: nowrap;
text-overflow: ellipsis;
- ${props => props.hasIcon && "padding-left: 4px;"};
+ ${(props) => props.hasIcon && "padding-left: 4px;"};
`;
export const Inner = styled.span`
display: flex;
padding: 0 8px;
- padding-right: ${props => (props.disclosure ? 2 : 8)}px;
- line-height: ${props => (props.hasIcon ? 24 : 32)}px;
+ padding-right: ${(props) => (props.disclosure ? 2 : 8)}px;
+ line-height: ${(props) => (props.hasIcon ? 24 : 32)}px;
justify-content: center;
align-items: center;
+ min-height: 30px;
- ${props => props.hasIcon && props.hasText && "padding-left: 4px;"};
- ${props => props.hasIcon && !props.hasText && "padding: 0 4px;"};
+ ${(props) => props.hasIcon && props.hasText && "padding-left: 4px;"};
+ ${(props) => props.hasIcon && !props.hasText && "padding: 0 4px;"};
`;
export type Props = {
@@ -126,6 +128,7 @@ export type Props = {
children?: React.Node,
innerRef?: React.ElementRef,
disclosure?: boolean,
+ fullwidth?: boolean,
borderOnHover?: boolean,
};
@@ -152,7 +155,6 @@ function Button({
);
}
-// $FlowFixMe - need to upgrade to get forwardRef
-export default React.forwardRef((props, ref) => (
+export default React.forwardRef((props, ref) => (
));
diff --git a/app/components/ButtonLarge.js b/app/components/ButtonLarge.js
new file mode 100644
index 0000000000..f3611bbd8a
--- /dev/null
+++ b/app/components/ButtonLarge.js
@@ -0,0 +1,13 @@
+// @flow
+import styled from "styled-components";
+import Button, { Inner } from "./Button";
+
+const ButtonLarge = styled(Button)`
+ height: 40px;
+
+ ${Inner} {
+ padding: 4px 16px;
+ }
+`;
+
+export default ButtonLarge;
diff --git a/app/components/CenteredContent.js b/app/components/CenteredContent.js
index aa79a6f76e..0a868cc567 100644
--- a/app/components/CenteredContent.js
+++ b/app/components/CenteredContent.js
@@ -9,6 +9,7 @@ type Props = {
const Container = styled.div`
width: 100%;
+ max-width: 100vw;
padding: 60px 20px;
${breakpoint("tablet")`
diff --git a/app/components/Checkbox.js b/app/components/Checkbox.js
index 8acbaabc8e..85efc12a87 100644
--- a/app/components/Checkbox.js
+++ b/app/components/Checkbox.js
@@ -10,18 +10,19 @@ export type Props = {
labelHidden?: boolean,
className?: string,
note?: string,
+ short?: boolean,
small?: boolean,
};
const LabelText = styled.span`
font-weight: 500;
- margin-left: ${props => (props.small ? "6px" : "10px")};
- ${props => (props.small ? `color: ${props.theme.textSecondary}` : "")};
+ margin-left: ${(props) => (props.small ? "6px" : "10px")};
+ ${(props) => (props.small ? `color: ${props.theme.textSecondary}` : "")};
`;
const Wrapper = styled.div`
padding-bottom: 8px;
- ${props => (props.small ? "font-size: 14px" : "")};
+ ${(props) => (props.small ? "font-size: 14px" : "")};
`;
const Label = styled.label`
@@ -42,7 +43,7 @@ export default function Checkbox({
const wrappedLabel = {label};
return (
-
+ <>
{note && {note}}
-
+ >
);
}
diff --git a/app/components/Collaborators.js b/app/components/Collaborators.js
index ea673d01b8..f632e8f630 100644
--- a/app/components/Collaborators.js
+++ b/app/components/Collaborators.js
@@ -1,14 +1,14 @@
// @flow
-import * as React from "react";
-import { observer, inject } from "mobx-react";
import { sortBy, keyBy } from "lodash";
+import { observer, inject } from "mobx-react";
+import * as React from "react";
import { MAX_AVATAR_DISPLAY } from "shared/constants";
+import DocumentPresenceStore from "stores/DocumentPresenceStore";
+import ViewsStore from "stores/ViewsStore";
+import Document from "models/Document";
import { AvatarWithPresence } from "components/Avatar";
import Facepile from "components/Facepile";
-import Document from "models/Document";
-import ViewsStore from "stores/ViewsStore";
-import DocumentPresenceStore from "stores/DocumentPresenceStore";
type Props = {
views: ViewsStore,
@@ -32,27 +32,27 @@ class Collaborators extends React.Component {
const documentViews = views.inDocument(document.id);
- const presentIds = documentPresence.map(p => p.userId);
+ const presentIds = documentPresence.map((p) => p.userId);
const editingIds = documentPresence
- .filter(p => p.isEditing)
- .map(p => p.userId);
+ .filter((p) => p.isEditing)
+ .map((p) => p.userId);
// ensure currently present via websocket are always ordered first
const mostRecentViewers = sortBy(
documentViews.slice(0, MAX_AVATAR_DISPLAY),
- view => {
+ (view) => {
return presentIds.includes(view.user.id);
}
);
- const viewersKeyedByUserId = keyBy(mostRecentViewers, v => v.user.id);
+ const viewersKeyedByUserId = keyBy(mostRecentViewers, (v) => v.user.id);
const overflow = documentViews.length - mostRecentViewers.length;
return (
v.user)}
+ users={mostRecentViewers.map((v) => v.user)}
overflow={overflow}
- renderAvatar={user => {
+ renderAvatar={(user) => {
const isPresent = presentIds.includes(user.id);
const isEditing = editingIds.includes(user.id);
const { lastViewedAt } = viewersKeyedByUserId[user.id];
diff --git a/app/components/CollectionIcon.js b/app/components/CollectionIcon.js
index c28b497731..3d1e4fda2d 100644
--- a/app/components/CollectionIcon.js
+++ b/app/components/CollectionIcon.js
@@ -1,11 +1,11 @@
// @flow
-import * as React from "react";
import { inject, observer } from "mobx-react";
-import { getLuminance } from "polished";
import { PrivateCollectionIcon, CollectionIcon } from "outline-icons";
+import { getLuminance } from "polished";
+import * as React from "react";
+import UiStore from "stores/UiStore";
import Collection from "models/Collection";
import { icons } from "components/IconPicker";
-import UiStore from "stores/UiStore";
type Props = {
collection: Collection,
diff --git a/app/components/CopyToClipboard.js b/app/components/CopyToClipboard.js
index d6bb97849b..36040e6b98 100644
--- a/app/components/CopyToClipboard.js
+++ b/app/components/CopyToClipboard.js
@@ -1,6 +1,6 @@
// @flow
-import * as React from "react";
import copy from "copy-to-clipboard";
+import * as React from "react";
type Props = {
text: string,
@@ -14,7 +14,7 @@ class CopyToClipboard extends React.PureComponent {
const { text, onCopy, children } = this.props;
const elem = React.Children.only(children);
copy(text, {
- debug: !!__DEV__,
+ debug: process.env.NODE_ENV !== "production",
});
if (onCopy) onCopy();
diff --git a/app/components/DelayedMount.js b/app/components/DelayedMount.js
new file mode 100644
index 0000000000..e127456c98
--- /dev/null
+++ b/app/components/DelayedMount.js
@@ -0,0 +1,24 @@
+// @flow
+import * as React from "react";
+
+type Props = {
+ delay?: number,
+ children: React.Node,
+};
+
+export default function DelayedMount({ delay = 250, children }: Props) {
+ const [isShowing, setShowing] = React.useState(false);
+
+ React.useEffect(() => {
+ const timeout = setTimeout(() => setShowing(true), delay);
+ return () => {
+ clearTimeout(timeout);
+ };
+ }, [delay]);
+
+ if (!isShowing) {
+ return null;
+ }
+
+ return children;
+}
diff --git a/app/components/DocumentHistory/DocumentHistory.js b/app/components/DocumentHistory/DocumentHistory.js
index 47f2cfc7ab..e6ce3c262a 100644
--- a/app/components/DocumentHistory/DocumentHistory.js
+++ b/app/components/DocumentHistory/DocumentHistory.js
@@ -1,23 +1,26 @@
// @flow
-import * as React from "react";
-import { observable, action } from "mobx";
-import { observer, inject } from "mobx-react";
-import type { RouterHistory } from "react-router-dom";
-import styled from "styled-components";
-import { Waypoint } from "react-waypoint";
import ArrowKeyNavigation from "boundless-arrow-key-navigation";
+import { action, observable } from "mobx";
+import { inject, observer } from "mobx-react";
+import { CloseIcon } from "outline-icons";
+import * as React from "react";
+import { type Match, Redirect, type RouterHistory } from "react-router-dom";
+import { Waypoint } from "react-waypoint";
+import styled from "styled-components";
+import breakpoint from "styled-components-breakpoint";
import { DEFAULT_PAGINATION_LIMIT } from "stores/BaseStore";
import DocumentsStore from "stores/DocumentsStore";
import RevisionsStore from "stores/RevisionsStore";
-import Flex from "shared/components/Flex";
+import Button from "components/Button";
+import Flex from "components/Flex";
import { ListPlaceholder } from "components/LoadingPlaceholder";
import Revision from "./components/Revision";
-import { documentHistoryUrl } from "utils/routeHelpers";
+import { documentHistoryUrl, documentUrl } from "utils/routeHelpers";
type Props = {
- match: Object,
+ match: Match,
documents: DocumentsStore,
revisions: RevisionsStore,
history: RouterHistory,
@@ -29,6 +32,7 @@ class DocumentHistory extends React.Component {
@observable isFetching: boolean = false;
@observable offset: number = 0;
@observable allowLoadMore: boolean = true;
+ @observable redirectTo: ?string;
async componentDidMount() {
await this.loadMoreResults();
@@ -86,15 +90,34 @@ class DocumentHistory extends React.Component {
return this.props.revisions.getDocumentRevisions(document.id);
}
+ onCloseHistory = () => {
+ const document = this.props.documents.getByUrl(
+ this.props.match.params.documentSlug
+ );
+
+ this.redirectTo = documentUrl(document);
+ };
+
render() {
const document = this.props.documents.getByUrl(
this.props.match.params.documentSlug
);
const showLoading = (!this.isLoaded && this.isFetching) || !document;
+ if (this.redirectTo) return ;
+
return (
+
+ History
+ }
+ onClick={this.onCloseHistory}
+ borderOnHover
+ neutral
+ />
+
{showLoading ? (
@@ -133,17 +156,43 @@ const Wrapper = styled(Flex)`
top: 0;
right: 0;
z-index: 1;
- min-width: ${props => props.theme.sidebarWidth};
+ min-width: ${(props) => props.theme.sidebarWidth};
height: 100%;
overflow-y: auto;
overscroll-behavior: none;
`;
const Sidebar = styled(Flex)`
- background: ${props => props.theme.background};
- min-width: ${props => props.theme.sidebarWidth};
- border-left: 1px solid ${props => props.theme.divider};
+ display: none;
+ background: ${(props) => props.theme.background};
+ min-width: ${(props) => props.theme.sidebarWidth};
+ border-left: 1px solid ${(props) => props.theme.divider};
z-index: 1;
+
+ ${breakpoint("tablet")`
+ display: flex;
+ `};
+`;
+
+const Title = styled(Flex)`
+ font-size: 16px;
+ font-weight: 600;
+ text-align: center;
+ align-items: center;
+ justify-content: flex-start;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ width: 0;
+ flex-grow: 1;
+`;
+
+const Header = styled(Flex)`
+ align-items: center;
+ position: relative;
+ padding: 12px;
+ border-bottom: 1px solid ${(props) => props.theme.divider};
+ color: ${(props) => props.theme.text};
`;
export default inject("documents", "revisions")(DocumentHistory);
diff --git a/app/components/DocumentHistory/components/Revision.js b/app/components/DocumentHistory/components/Revision.js
index 30ae6c5a28..f776a729eb 100644
--- a/app/components/DocumentHistory/components/Revision.js
+++ b/app/components/DocumentHistory/components/Revision.js
@@ -1,16 +1,16 @@
// @flow
+import format from "date-fns/format";
+import { MoreIcon } from "outline-icons";
import * as React from "react";
import { NavLink } from "react-router-dom";
import styled, { withTheme } from "styled-components";
-import format from "date-fns/format";
-import { MoreIcon } from "outline-icons";
-import Flex from "shared/components/Flex";
-import Time from "shared/components/Time";
-import Avatar from "components/Avatar";
-import RevisionMenu from "menus/RevisionMenu";
import Document from "models/Document";
import Revision from "models/Revision";
+import Avatar from "components/Avatar";
+import Flex from "components/Flex";
+import Time from "components/Time";
+import RevisionMenu from "menus/RevisionMenu";
import { documentHistoryUrl } from "utils/routeHelpers";
@@ -66,7 +66,7 @@ const StyledRevisionMenu = styled(RevisionMenu)`
`;
const StyledNavLink = styled(NavLink)`
- color: ${props => props.theme.text};
+ color: ${(props) => props.theme.text};
display: block;
padding: 8px 16px;
font-size: 15px;
diff --git a/app/components/DocumentList.js b/app/components/DocumentList.js
index d12e730b35..00d0095640 100644
--- a/app/components/DocumentList.js
+++ b/app/components/DocumentList.js
@@ -1,8 +1,8 @@
// @flow
+import ArrowKeyNavigation from "boundless-arrow-key-navigation";
import * as React from "react";
import Document from "models/Document";
import DocumentPreview from "components/DocumentPreview";
-import ArrowKeyNavigation from "boundless-arrow-key-navigation";
type Props = {
documents: Document[],
@@ -17,7 +17,7 @@ export default function DocumentList({ limit, documents, ...rest }: Props) {
mode={ArrowKeyNavigation.mode.VERTICAL}
defaultActiveChildIndex={0}
>
- {items.map(document => (
+ {items.map((document) => (
))}
diff --git a/app/components/PublishingInfo.js b/app/components/DocumentMeta.js
similarity index 76%
rename from app/components/PublishingInfo.js
rename to app/components/DocumentMeta.js
index ce9ef0cae5..4f2366b88f 100644
--- a/app/components/PublishingInfo.js
+++ b/app/components/DocumentMeta.js
@@ -1,25 +1,26 @@
// @flow
-import * as React from "react";
import { inject, observer } from "mobx-react";
+import * as React from "react";
+import { Link } from "react-router-dom";
import styled from "styled-components";
-import Document from "models/Document";
-import Flex from "shared/components/Flex";
-import Time from "shared/components/Time";
-import Breadcrumb from "shared/components/Breadcrumb";
-import CollectionsStore from "stores/CollectionsStore";
import AuthStore from "stores/AuthStore";
+import CollectionsStore from "stores/CollectionsStore";
+import Document from "models/Document";
+import Breadcrumb from "components/Breadcrumb";
+import Flex from "components/Flex";
+import Time from "components/Time";
const Container = styled(Flex)`
- color: ${props => props.theme.textTertiary};
+ color: ${(props) => props.theme.textTertiary};
font-size: 13px;
white-space: nowrap;
overflow: hidden;
`;
const Modified = styled.span`
- color: ${props =>
+ color: ${(props) =>
props.highlight ? props.theme.text : props.theme.textTertiary};
- font-weight: ${props => (props.highlight ? "600" : "400")};
+ font-weight: ${(props) => (props.highlight ? "600" : "400")};
`;
type Props = {
@@ -29,15 +30,17 @@ type Props = {
showPublished?: boolean,
document: Document,
children: React.Node,
+ to?: string,
};
-function PublishingInfo({
+function DocumentMeta({
auth,
collections,
showPublished,
showCollection,
document,
children,
+ to,
...rest
}: Props) {
const {
@@ -103,19 +106,18 @@ function PublishingInfo({
return (
{updatedByMe ? "You" : updatedBy.name}
- {content}
- {showCollection &&
- collection && (
-
- in
-
-
-
-
- )}
+ {to ? {content} : content}
+ {showCollection && collection && (
+
+ in
+
+
+
+
+ )}
{children}
);
}
-export default inject("collections", "auth")(observer(PublishingInfo));
+export default inject("collections", "auth")(observer(DocumentMeta));
diff --git a/app/scenes/Document/components/DocumentMeta.js b/app/components/DocumentMetaWithViews.js
similarity index 61%
rename from app/scenes/Document/components/DocumentMeta.js
rename to app/components/DocumentMetaWithViews.js
index 44542beee4..cde7cff5fb 100644
--- a/app/scenes/Document/components/DocumentMeta.js
+++ b/app/components/DocumentMetaWithViews.js
@@ -1,39 +1,48 @@
// @flow
+import { inject } from "mobx-react";
import * as React from "react";
import styled from "styled-components";
-import { inject } from "mobx-react";
import ViewsStore from "stores/ViewsStore";
import Document from "models/Document";
-import PublishingInfo from "components/PublishingInfo";
+import DocumentMeta from "components/DocumentMeta";
type Props = {|
views: ViewsStore,
document: Document,
isDraft: boolean,
+ to?: string,
|};
-function DocumentMeta({ views, isDraft, document }: Props) {
+function DocumentMetaWithViews({ views, to, isDraft, document }: Props) {
const totalViews = views.countForDocument(document.id);
return (
-
+
{totalViews && !isDraft ? (
-
+ <>
· Viewed{" "}
{totalViews === 1 ? "once" : `${totalViews} times`}
-
+ >
) : null}
);
}
-const Meta = styled(PublishingInfo)`
+const Meta = styled(DocumentMeta)`
margin: -12px 0 2em 0;
font-size: 14px;
+ a {
+ color: inherit;
+
+ &:hover {
+ text-decoration: underline;
+ }
+ }
+
@media print {
display: none;
}
`;
-export default inject("views")(DocumentMeta);
+export default inject("views")(DocumentMetaWithViews);
diff --git a/app/components/DocumentPreview/DocumentPreview.js b/app/components/DocumentPreview/DocumentPreview.js
index 48321d48e4..c7447c4df9 100644
--- a/app/components/DocumentPreview/DocumentPreview.js
+++ b/app/components/DocumentPreview/DocumentPreview.js
@@ -1,18 +1,21 @@
// @flow
-import * as React from "react";
import { observer } from "mobx-react";
-import { Link } from "react-router-dom";
-import { StarredIcon } from "outline-icons";
+import { StarredIcon, PlusIcon } from "outline-icons";
+import * as React from "react";
+import { Link, withRouter, type RouterHistory } from "react-router-dom";
import styled, { withTheme } from "styled-components";
-import Flex from "shared/components/Flex";
-import Badge from "components/Badge";
-import Tooltip from "components/Tooltip";
-import Highlight from "components/Highlight";
-import PublishingInfo from "components/PublishingInfo";
-import DocumentMenu from "menus/DocumentMenu";
import Document from "models/Document";
+import Badge from "components/Badge";
+import Button from "components/Button";
+import DocumentMeta from "components/DocumentMeta";
+import Flex from "components/Flex";
+import Highlight from "components/Highlight";
+import Tooltip from "components/Tooltip";
+import DocumentMenu from "menus/DocumentMenu";
+import { newDocumentUrl } from "utils/routeHelpers";
type Props = {
+ history: RouterHistory,
document: Document,
highlight?: ?string,
context?: ?string,
@@ -20,13 +23,127 @@ type Props = {
showPublished?: boolean,
showPin?: boolean,
showDraft?: boolean,
+ showTemplate?: boolean,
};
+const SEARCH_RESULT_REGEX = /]*>(.*?)<\/b>/gi;
+
+@observer
+class DocumentPreview extends React.Component {
+ handleStar = (ev: SyntheticEvent<>) => {
+ ev.preventDefault();
+ ev.stopPropagation();
+ this.props.document.star();
+ };
+
+ handleUnstar = (ev: SyntheticEvent<>) => {
+ ev.preventDefault();
+ ev.stopPropagation();
+ this.props.document.unstar();
+ };
+
+ replaceResultMarks = (tag: string) => {
+ // don't use SEARCH_RESULT_REGEX here as it causes
+ // an infinite loop to trigger a regex inside it's own callback
+ return tag.replace(/]*>(.*?)<\/b>/gi, "$1");
+ };
+
+ handleNewFromTemplate = (event) => {
+ event.preventDefault();
+ event.stopPropagation();
+
+ const { document } = this.props;
+
+ this.props.history.push(
+ newDocumentUrl(document.collectionId, {
+ templateId: document.id,
+ })
+ );
+ };
+
+ render() {
+ const {
+ document,
+ showCollection,
+ showPublished,
+ showPin,
+ showDraft = true,
+ showTemplate,
+ highlight,
+ context,
+ } = this.props;
+
+ const queryIsInTitle =
+ !!highlight &&
+ !!document.title.toLowerCase().includes(highlight.toLowerCase());
+
+ return (
+
+
+
+ {!document.isDraft &&
+ !document.isArchived &&
+ !document.isTemplate && (
+
+ {document.isStarred ? (
+
+ ) : (
+
+ )}
+
+ )}
+ {document.isDraft && showDraft && (
+
+ Draft
+
+ )}
+ {document.isTemplate && showTemplate && (
+ Template
+ )}
+
+ {document.isTemplate &&
+ !document.isArchived &&
+ !document.isDeleted && (
+ }
+ neutral
+ >
+ New doc
+
+ )}
+
+
+
+
+
+ {!queryIsInTitle && (
+
+ )}
+
+
+ );
+ }
+}
+
const StyledStar = withTheme(styled(({ solid, theme, ...props }) => (
))`
flex-shrink: 0;
- opacity: ${props => (props.solid ? "1 !important" : 0)};
+ opacity: ${(props) => (props.solid ? "1 !important" : 0)};
transition: all 100ms ease-in-out;
&:hover {
@@ -37,7 +154,8 @@ const StyledStar = withTheme(styled(({ solid, theme, ...props }) => (
}
`);
-const StyledDocumentMenu = styled(DocumentMenu)`
+const SecondaryActions = styled(Flex)`
+ align-items: center;
position: absolute;
right: 16px;
top: 50%;
@@ -51,20 +169,25 @@ const DocumentLink = styled(Link)`
border-radius: 8px;
max-height: 50vh;
min-width: 100%;
+ max-width: calc(100vw - 40px);
overflow: hidden;
position: relative;
- ${StyledDocumentMenu} {
+ ${SecondaryActions} {
opacity: 0;
}
&:hover,
&:active,
&:focus {
- background: ${props => props.theme.listItemHoverBackground};
+ background: ${(props) => props.theme.listItemHoverBackground};
outline: none;
- ${StyledStar}, ${StyledDocumentMenu} {
+ ${SecondaryActions} {
+ opacity: 1;
+ }
+
+ ${StyledStar} {
opacity: 0.5;
&:hover {
@@ -82,6 +205,7 @@ const Heading = styled.h3`
margin-bottom: 0.25em;
overflow: hidden;
white-space: nowrap;
+ color: ${(props) => props.theme.text};
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
`;
@@ -99,97 +223,10 @@ const Title = styled(Highlight)`
const ResultContext = styled(Highlight)`
display: block;
- color: ${props => props.theme.textTertiary};
+ color: ${(props) => props.theme.textTertiary};
font-size: 14px;
margin-top: -0.25em;
margin-bottom: 0.25em;
`;
-const SEARCH_RESULT_REGEX = /]*>(.*?)<\/b>/gi;
-
-@observer
-class DocumentPreview extends React.Component {
- star = (ev: SyntheticEvent<>) => {
- ev.preventDefault();
- ev.stopPropagation();
- this.props.document.star();
- };
-
- unstar = (ev: SyntheticEvent<>) => {
- ev.preventDefault();
- ev.stopPropagation();
- this.props.document.unstar();
- };
-
- replaceResultMarks = (tag: string) => {
- // don't use SEARCH_RESULT_REGEX here as it causes
- // an infinite loop to trigger a regex inside it's own callback
- return tag.replace(/]*>(.*?)<\/b>/gi, "$1");
- };
-
- render() {
- const {
- document,
- showCollection,
- showPublished,
- showPin,
- showDraft = true,
- highlight,
- context,
- ...rest
- } = this.props;
-
- const queryIsInTitle =
- !!highlight &&
- !!document.title.toLowerCase().includes(highlight.toLowerCase());
-
- return (
-
-
-
- {!document.isDraft &&
- !document.isArchived && (
-
- {document.isStarred ? (
-
- ) : (
-
- )}
-
- )}
- {document.isDraft &&
- showDraft && (
-
- Draft
-
- )}
-
-
- {!queryIsInTitle && (
-
- )}
-
-
- );
- }
-}
-
-export default DocumentPreview;
+export default withRouter(DocumentPreview);
diff --git a/app/components/DropToImport.js b/app/components/DropToImport.js
index 7276e87bc8..ecb8c78c02 100644
--- a/app/components/DropToImport.js
+++ b/app/components/DropToImport.js
@@ -1,14 +1,14 @@
// @flow
-import * as React from "react";
+import invariant from "invariant";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
-import { withRouter, type RouterHistory } from "react-router-dom";
-import { createGlobalStyle } from "styled-components";
-import invariant from "invariant";
-import importFile from "utils/importFile";
+import * as React from "react";
import Dropzone from "react-dropzone";
+import { withRouter, type RouterHistory, type Match } from "react-router-dom";
+import { createGlobalStyle } from "styled-components";
import DocumentsStore from "stores/DocumentsStore";
import LoadingIndicator from "components/LoadingIndicator";
+import importFile from "utils/importFile";
const EMPTY_OBJECT = {};
let importingLock = false;
@@ -22,7 +22,7 @@ type Props = {
documents: DocumentsStore,
disabled: boolean,
location: Object,
- match: Object,
+ match: Match,
history: RouterHistory,
staticContext: Object,
};
@@ -30,12 +30,12 @@ type Props = {
export const GlobalStyles = createGlobalStyle`
.activeDropZone {
border-radius: 4px;
- background: ${props => props.theme.slateDark};
- svg { fill: ${props => props.theme.white}; }
+ background: ${(props) => props.theme.slateDark};
+ svg { fill: ${(props) => props.theme.white}; }
}
.activeDropZone a {
- color: ${props => props.theme.white} !important;
+ color: ${(props) => props.theme.white} !important;
}
`;
diff --git a/app/components/DropdownMenu/DropdownMenu.js b/app/components/DropdownMenu/DropdownMenu.js
index 7a60cab327..d84939e6aa 100644
--- a/app/components/DropdownMenu/DropdownMenu.js
+++ b/app/components/DropdownMenu/DropdownMenu.js
@@ -1,14 +1,14 @@
// @flow
-import * as React from "react";
import invariant from "invariant";
import { observable } from "mobx";
import { observer } from "mobx-react";
-import { PortalWithState } from "react-portal";
import { MoreIcon } from "outline-icons";
import { rgba } from "polished";
+import * as React from "react";
+import { PortalWithState } from "react-portal";
import styled from "styled-components";
-import Flex from "shared/components/Flex";
import { fadeAndScaleIn } from "shared/styles/animations";
+import Flex from "components/Flex";
import NudeButton from "components/NudeButton";
let previousClosePortal;
@@ -161,7 +161,7 @@ class DropdownMenu extends React.Component {
closeOnEsc
>
{({ closePortal, openPortal, isOpen, portal }) => (
-
+ <>
+ >
)}
@@ -232,7 +232,7 @@ const Label = styled(Flex).attrs({
justify: "center",
align: "center",
})`
- z-index: 1000;
+ z-index: ${(props) => props.theme.depths.menu};
cursor: pointer;
`;
@@ -244,25 +244,25 @@ const Position = styled.div`
${({ top }) => (top !== undefined ? `top: ${top}px` : "")};
${({ bottom }) => (bottom !== undefined ? `bottom: ${bottom}px` : "")};
max-height: 75%;
- z-index: 1000;
- transform: ${props =>
+ z-index: ${(props) => props.theme.depths.menu};
+ transform: ${(props) =>
props.position === "center" ? "translateX(-50%)" : "initial"};
pointer-events: none;
`;
const Menu = styled.div`
animation: ${fadeAndScaleIn} 200ms ease;
- transform-origin: ${props => (props.left !== undefined ? "25%" : "75%")} 0;
+ transform-origin: ${(props) => (props.left !== undefined ? "25%" : "75%")} 0;
backdrop-filter: blur(10px);
- background: ${props => rgba(props.theme.menuBackground, 0.8)};
- border: ${props =>
+ background: ${(props) => rgba(props.theme.menuBackground, 0.8)};
+ border: ${(props) =>
props.theme.menuBorder ? `1px solid ${props.theme.menuBorder}` : "none"};
border-radius: 2px;
padding: 0.5em 0;
min-width: 180px;
overflow: hidden;
overflow-y: auto;
- box-shadow: ${props => props.theme.menuShadow};
+ box-shadow: ${(props) => props.theme.menuShadow};
pointer-events: all;
hr {
@@ -274,4 +274,13 @@ const Menu = styled.div`
}
`;
+export const Header = styled.h3`
+ font-size: 11px;
+ font-weight: 600;
+ text-transform: uppercase;
+ color: ${(props) => props.theme.sidebarText};
+ letter-spacing: 0.04em;
+ margin: 1em 12px 0.5em;
+`;
+
export default DropdownMenu;
diff --git a/app/components/DropdownMenu/DropdownMenuItem.js b/app/components/DropdownMenu/DropdownMenuItem.js
index 0eca7a9da5..88e599a2f9 100644
--- a/app/components/DropdownMenu/DropdownMenuItem.js
+++ b/app/components/DropdownMenu/DropdownMenuItem.js
@@ -1,6 +1,6 @@
// @flow
-import * as React from "react";
import { CheckmarkIcon } from "outline-icons";
+import * as React from "react";
import styled from "styled-components";
type Props = {
@@ -26,11 +26,12 @@ const DropdownMenuItem = ({
{...rest}
>
{selected !== undefined && (
-
+ <>
-
+ />
+
+ >
)}
{children}
@@ -42,9 +43,9 @@ const MenuItem = styled.a`
margin: 0;
padding: 6px 12px;
width: 100%;
- height: 32px;
+ min-height: 32px;
- color: ${props =>
+ color: ${(props) =>
props.disabled ? props.theme.textTertiary : props.theme.textSecondary};
justify-content: left;
align-items: center;
@@ -57,10 +58,10 @@ const MenuItem = styled.a`
}
svg {
- opacity: ${props => (props.disabled ? ".5" : 1)};
+ opacity: ${(props) => (props.disabled ? ".5" : 1)};
}
- ${props =>
+ ${(props) =>
props.disabled
? "pointer-events: none;"
: `
diff --git a/app/components/DropdownMenu/index.js b/app/components/DropdownMenu/index.js
index b1fa231ac0..38b1b84e75 100644
--- a/app/components/DropdownMenu/index.js
+++ b/app/components/DropdownMenu/index.js
@@ -1,3 +1,3 @@
// @flow
-export { default as DropdownMenu } from "./DropdownMenu";
+export { default as DropdownMenu, Header } from "./DropdownMenu";
export { default as DropdownMenuItem } from "./DropdownMenuItem";
diff --git a/app/components/Editor/Editor.js b/app/components/Editor.js
similarity index 56%
rename from app/components/Editor/Editor.js
rename to app/components/Editor.js
index 9e3e80c684..cdba893a95 100644
--- a/app/components/Editor/Editor.js
+++ b/app/components/Editor.js
@@ -1,34 +1,34 @@
// @flow
+import { lighten } from "polished";
import * as React from "react";
import { withRouter, type RouterHistory } from "react-router-dom";
-import { observable } from "mobx";
-import { observer } from "mobx-react";
-import { lighten } from "polished";
import styled, { withTheme } from "styled-components";
-import RichMarkdownEditor from "rich-markdown-editor";
-import { uploadFile } from "utils/uploadFile";
-import isInternalUrl from "utils/isInternalUrl";
-import Tooltip from "components/Tooltip";
import UiStore from "stores/UiStore";
-import embeds from "../../embeds";
+import ErrorBoundary from "components/ErrorBoundary";
+import Tooltip from "components/Tooltip";
+import embeds from "../embeds";
+import isInternalUrl from "utils/isInternalUrl";
+import { uploadFile } from "utils/uploadFile";
+
+const RichMarkdownEditor = React.lazy(() => import("rich-markdown-editor"));
const EMPTY_ARRAY = [];
type Props = {
- id: string,
+ id?: string,
defaultValue?: string,
readOnly?: boolean,
grow?: boolean,
disableEmbeds?: boolean,
- history: RouterHistory,
- forwardedRef: React.Ref,
- ui: UiStore,
+ ui?: UiStore,
};
-@observer
-class Editor extends React.Component {
- @observable redirectTo: ?string;
+type PropsWithRef = Props & {
+ forwardedRef: React.Ref,
+ history: RouterHistory,
+};
+class Editor extends React.Component {
onUploadImage = async (file: File) => {
const result = await uploadFile(file, { documentId: this.props.id });
return result.url;
@@ -62,40 +62,50 @@ class Editor extends React.Component {
};
onShowToast = (message: string) => {
- this.props.ui.showToast(message);
+ if (this.props.ui) {
+ this.props.ui.showToast(message);
+ }
};
render() {
return (
-
+
+
+
);
}
}
const StyledEditor = styled(RichMarkdownEditor)`
- flex-grow: ${props => (props.grow ? 1 : 0)};
+ flex-grow: ${(props) => (props.grow ? 1 : 0)};
justify-content: start;
> div {
- transition: ${props => props.theme.backgroundTransition};
+ transition: ${(props) => props.theme.backgroundTransition};
+ }
+
+ .notice-block.tip,
+ .notice-block.warning {
+ font-weight: 500;
}
p {
a {
- color: ${props => props.theme.link};
- border-bottom: 1px solid ${props => lighten(0.5, props.theme.link)};
+ color: ${(props) => props.theme.text};
+ border-bottom: 1px solid ${(props) => lighten(0.5, props.theme.text)};
+ text-decoration: none !important;
font-weight: 500;
&:hover {
- border-bottom: 1px solid ${props => props.theme.link};
+ border-bottom: 1px solid ${(props) => props.theme.text};
text-decoration: none;
}
}
@@ -104,13 +114,16 @@ const StyledEditor = styled(RichMarkdownEditor)`
const EditorTooltip = ({ children, ...props }) => (
- {children}
+ {children}
);
+const Span = styled.span`
+ outline: none;
+`;
+
const EditorWithRouterAndTheme = withRouter(withTheme(Editor));
-// $FlowIssue - https://github.com/facebook/flow/issues/6103
-export default React.forwardRef((props, ref) => (
+export default React.forwardRef((props, ref) => (
));
diff --git a/app/components/Editor/index.js b/app/components/Editor/index.js
deleted file mode 100644
index cef858bedb..0000000000
--- a/app/components/Editor/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-// @flow
-import Editor from "./Editor";
-export default Editor;
diff --git a/app/components/Empty.js b/app/components/Empty.js
index 4f78753ac8..b7a603c41c 100644
--- a/app/components/Empty.js
+++ b/app/components/Empty.js
@@ -1,20 +1,8 @@
// @flow
-import * as React from "react";
import styled from "styled-components";
-type Props = {
- children: React.Node,
-};
-
-const Empty = (props: Props) => {
- const { children, ...rest } = props;
- return {children};
-};
-
-const Container = styled.div`
- display: flex;
- color: ${props => props.theme.slate};
- text-align: center;
+const Empty = styled.p`
+ color: ${(props) => props.theme.textTertiary};
`;
export default Empty;
diff --git a/app/components/ErrorBoundary.js b/app/components/ErrorBoundary.js
index eb1b60626f..24c087e50f 100644
--- a/app/components/ErrorBoundary.js
+++ b/app/components/ErrorBoundary.js
@@ -1,16 +1,18 @@
// @flow
+import { observable } from "mobx";
+import { observer } from "mobx-react";
import * as React from "react";
import styled from "styled-components";
-import { observer } from "mobx-react";
-import { observable } from "mobx";
-import HelpText from "components/HelpText";
import Button from "components/Button";
import CenteredContent from "components/CenteredContent";
+import HelpText from "components/HelpText";
import PageTitle from "components/PageTitle";
import { githubIssuesUrl } from "../../shared/utils/routeHelpers";
+import env from "env";
type Props = {
children: React.Node,
+ reloadOnChunkMissing?: boolean,
};
@observer
@@ -22,13 +24,25 @@ class ErrorBoundary extends React.Component {
this.error = error;
console.error(error);
+ if (
+ this.props.reloadOnChunkMissing &&
+ error.message &&
+ error.message.match(/chunk/)
+ ) {
+ // If the editor bundle fails to load then reload the entire window. This
+ // can happen if a deploy happens between the user loading the initial JS
+ // bundle and the async-loaded editor JS bundle as the hash will change.
+ window.location.reload(true);
+ return;
+ }
+
if (window.Sentry) {
- Sentry.captureException(error);
+ window.Sentry.captureException(error);
}
}
handleReload = () => {
- window.location.reload();
+ window.location.reload(true);
};
handleShowDetails = () => {
@@ -41,16 +55,16 @@ class ErrorBoundary extends React.Component {
render() {
if (this.error) {
- const isReported = !!window.Sentry;
+ const isReported = !!window.Sentry && env.DEPLOYMENT === "hosted";
return (
Something Unexpected Happened
- Sorry, an unrecoverable error occurred{isReported &&
- " – our engineers have been notified"}. Please try reloading the
- page, it may have been a temporary glitch.
+ Sorry, an unrecoverable error occurred
+ {isReported && " – our engineers have been notified"}. Please try
+ reloading the page, it may have been a temporary glitch.
{this.showDetails &&