chore: Editor refactor (#3286)
* cleanup * add context * EventEmitter allows removal of toolbar props from extensions * Move to 'packages' of extensions Remove EmojiTrigger extension * types * iteration * fix render flashing * fix: Missing nodes in collection descriptions
This commit is contained in:
@@ -3,7 +3,7 @@ import { Optional } from "utility-types";
|
||||
import embeds from "@shared/editor/embeds";
|
||||
import { isInternalUrl } from "@shared/utils/urls";
|
||||
import ErrorBoundary from "~/components/ErrorBoundary";
|
||||
import { Props as EditorProps } from "~/editor";
|
||||
import type { Props as EditorProps, Editor as SharedEditor } from "~/editor";
|
||||
import useDictionary from "~/hooks/useDictionary";
|
||||
import useToasts from "~/hooks/useToasts";
|
||||
import { uploadFile } from "~/utils/files";
|
||||
@@ -11,7 +11,7 @@ import history from "~/utils/history";
|
||||
import { isModKey } from "~/utils/keyboard";
|
||||
import { isHash } from "~/utils/urls";
|
||||
|
||||
const SharedEditor = React.lazy(
|
||||
const LazyLoadedEditor = React.lazy(
|
||||
() =>
|
||||
import(
|
||||
/* webpackChunkName: "shared-editor" */
|
||||
@@ -27,6 +27,7 @@ export type Props = Optional<
|
||||
| "embeds"
|
||||
| "dictionary"
|
||||
| "onShowToast"
|
||||
| "extensions"
|
||||
> & {
|
||||
shareId?: string | undefined;
|
||||
embedsDisabled?: boolean;
|
||||
@@ -35,7 +36,7 @@ export type Props = Optional<
|
||||
onPublish?: (event: React.MouseEvent) => any;
|
||||
};
|
||||
|
||||
function Editor(props: Props, ref: React.Ref<any>) {
|
||||
function Editor(props: Props, ref: React.Ref<SharedEditor>) {
|
||||
const { id, shareId } = props;
|
||||
const { showToast } = useToasts();
|
||||
const dictionary = useDictionary();
|
||||
@@ -84,19 +85,12 @@ function Editor(props: Props, ref: React.Ref<any>) {
|
||||
[shareId]
|
||||
);
|
||||
|
||||
const onShowToast = React.useCallback(
|
||||
(message: string) => {
|
||||
showToast(message);
|
||||
},
|
||||
[showToast]
|
||||
);
|
||||
|
||||
return (
|
||||
<ErrorBoundary reloadOnChunkMissing>
|
||||
<SharedEditor
|
||||
<LazyLoadedEditor
|
||||
ref={ref}
|
||||
uploadFile={onUploadFile}
|
||||
onShowToast={onShowToast}
|
||||
onShowToast={showToast}
|
||||
embeds={embeds}
|
||||
dictionary={dictionary}
|
||||
{...props}
|
||||
|
||||
Reference in New Issue
Block a user