chore: Upgrade flow (#1854)

* wip: upgrade flow

* chore: More sealed props improvements

* Final fixes
This commit is contained in:
Tom Moor
2021-01-29 21:36:09 -08:00
committed by GitHub
parent ce2b246e60
commit 32f0589190
38 changed files with 191 additions and 96 deletions

View File

@@ -61,7 +61,7 @@ type Props = {
document: Document,
revision: Revision,
readOnly: boolean,
onCreateLink: (title: string) => string,
onCreateLink: (title: string) => Promise<string>,
onSearchLink: (term: string) => any,
theme: Theme,
auth: AuthStore,

View File

@@ -9,24 +9,24 @@ import parseTitle from "shared/utils/parseTitle";
import Document from "models/Document";
import ClickablePadding from "components/ClickablePadding";
import DocumentMetaWithViews from "components/DocumentMetaWithViews";
import Editor from "components/Editor";
import Editor, { type Props as EditorProps } from "components/Editor";
import Flex from "components/Flex";
import HoverPreview from "components/HoverPreview";
import Star, { AnimatedStar } from "components/Star";
import { isModKey } from "utils/keyboard";
import { documentHistoryUrl } from "utils/routeHelpers";
type Props = {
type Props = {|
...EditorProps,
onChangeTitle: (event: SyntheticInputEvent<>) => void,
title: string,
defaultValue: string,
document: Document,
isDraft: boolean,
isShare: boolean,
readOnly?: boolean,
onSave: ({ publish?: boolean, done?: boolean, autosave?: boolean }) => mixed,
grow?: boolean,
onSave: ({ done?: boolean, autosave?: boolean, publish?: boolean }) => any,
innerRef: { current: any },
};
|};
@observer
class DocumentEditor extends React.Component<Props> {
@@ -98,6 +98,7 @@ class DocumentEditor extends React.Component<Props> {
isShare,
readOnly,
innerRef,
...rest
} = this.props;
const { emoji } = parseTitle(title);
@@ -135,12 +136,12 @@ class DocumentEditor extends React.Component<Props> {
/>
<Editor
ref={innerRef}
autoFocus={title && !this.props.defaultValue}
autoFocus={!!title && !this.props.defaultValue}
placeholder="…the rest is up to you"
onHoverLink={this.handleLinkActive}
scrollTo={window.location.hash}
grow
{...this.props}
{...rest}
/>
{!readOnly && <ClickablePadding onClick={this.focusAtEnd} grow />}
{this.activeLinkEvent && !isShare && readOnly && (

View File

@@ -240,7 +240,6 @@ class Header extends React.Component<Props> {
<Button
onClick={this.handleSave}
disabled={savingIsDisabled}
isSaving={isSaving}
neutral={isDraft}
>
{isDraft ? t("Save Draft") : t("Done Editing")}
@@ -311,7 +310,6 @@ class Header extends React.Component<Props> {
>
<Button
onClick={this.handlePublish}
title={t("Publish document")}
disabled={publishingIsDisabled}
>
{isPublishing ? `${t("Publishing")}` : t("Publish")}

View File

@@ -7,11 +7,11 @@ import Document from "models/Document";
import DocumentMeta from "components/DocumentMeta";
import type { NavigationNode } from "types";
type Props = {
type Props = {|
document: Document | NavigationNode,
anchor?: string,
showCollection?: boolean,
};
|};
const DocumentLink = styled(Link)`
display: block;