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:
Tom Moor
2022-03-30 19:10:34 -07:00
committed by GitHub
parent c5b9a742c0
commit 6f2a4488e8
30 changed files with 517 additions and 581 deletions

View File

@@ -1,15 +1,12 @@
import { EditorView } from "prosemirror-view";
import * as React from "react";
import styled from "styled-components";
import { CommandFactory } from "@shared/editor/lib/Extension";
import { MenuItem } from "@shared/editor/types";
import { useEditor } from "./EditorContext";
import ToolbarButton from "./ToolbarButton";
import ToolbarSeparator from "./ToolbarSeparator";
import Tooltip from "./Tooltip";
type Props = {
commands: Record<string, CommandFactory>;
view: EditorView;
items: MenuItem[];
};
@@ -20,7 +17,8 @@ const FlexibleWrapper = styled.div`
`;
function ToolbarMenu(props: Props) {
const { view, items } = props;
const { commands, view } = useEditor();
const { items } = props;
const { state } = view;
return (
@@ -38,7 +36,7 @@ function ToolbarMenu(props: Props) {
return (
<Tooltip tooltip={item.tooltip} key={index}>
<ToolbarButton
onClick={() => item.name && props.commands[item.name](item.attrs)}
onClick={() => item.name && commands[item.name](item.attrs)}
active={isActive}
>
<Icon color="currentColor" />