fix: Capture drop events in clickable padding below editor (#3376)

* fix: Capture drop events in clickable padding below editor

* fix: Inconsistency in drop handling
This commit is contained in:
Tom Moor
2022-04-15 09:03:25 -07:00
committed by GitHub
parent 0ecfa95efc
commit cf58d8e3e1
4 changed files with 82 additions and 23 deletions

View File

@@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next";
import { useRouteMatch } from "react-router-dom";
import fullPackage from "@shared/editor/packages/full";
import Document from "~/models/Document";
import ClickablePadding from "~/components/ClickablePadding";
import { RefHandle } from "~/components/ContentEditable";
import DocumentMetaWithViews from "~/components/DocumentMetaWithViews";
import Editor, { Props as EditorProps } from "~/components/Editor";
@@ -40,6 +39,17 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
const titleRef = React.useRef<RefHandle>(null);
const { t } = useTranslation();
const match = useRouteMatch();
const {
document,
title,
onChangeTitle,
isDraft,
shareId,
readOnly,
children,
multiplayer,
...rest
} = props;
const focusAtStart = React.useCallback(() => {
if (ref.current) {
@@ -47,12 +57,6 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
}
}, [ref]);
const focusAtEnd = React.useCallback(() => {
if (ref.current) {
ref.current.focusAtEnd();
}
}, [ref]);
const handleBlur = React.useCallback(() => {
props.onSave({ autosave: true });
}, [props]);
@@ -70,17 +74,6 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
[focusAtStart, ref]
);
const {
document,
title,
onChangeTitle,
isDraft,
shareId,
readOnly,
children,
multiplayer,
...rest
} = props;
const EditorComponent = multiplayer ? MultiplayerEditor : Editor;
return (
@@ -121,7 +114,6 @@ function DocumentEditor(props: Props, ref: React.RefObject<any>) {
grow
{...rest}
/>
{!readOnly && <ClickablePadding onClick={focusAtEnd} grow />}
{children}
</Flex>
);