Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Aug 5, 2020
1 parent 772fdd9 commit 72f8f69
Showing 1 changed file with 1 addition and 53 deletions.
54 changes: 1 addition & 53 deletions src/editor/SlateEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const SlateEditor = ({
const { slate } = settings;

const [showToolbar, setShowToolbar] = useState(false);
const [showPluginToolbar, setShowPluginToolbar] = useState(false);

const defaultExtensions = slate.extensions;
let editor = React.useMemo(() => {
Expand All @@ -49,8 +48,6 @@ const SlateEditor = ({
// blockProps) then we need to always wrap the editor with them
editor = renderExtensions.reduce((acc, apply) => apply(acc), editor);

editor.showPluginToolbar = showPluginToolbar;

const initial_selection = React.useRef();

/*
Expand Down Expand Up @@ -99,55 +96,6 @@ const SlateEditor = ({
testingEditorRef.current = editor;
}

// const [showForm, setShowForm] = React.useState(false);
// const [selection, setSelection] = React.useState(null);
// const [formData, setFormData] = React.useState({});
// const footnoteContext = React.useMemo(
// () => ({
// getShowForm: () => {
// return showForm || false;
// },
// getSelection: () => {
// return selection || null;
// },
// getFormData: () => {
// return formData || {};
// },
// setShowForm: (val) => {
// setShowForm(val);
// },
// setSelection: (val) => {
// console.log('save selection to', val);
// setSelection(val);
// },
// setFormData: (val) => {
// setFormData(val);
// },
// }),
// [showForm, selection, formData],
// );

// const handleChange = React.useCallback(
// (ev) => {
// // footnoteContext.setSelection(
// // JSON.parse(JSON.stringify(editor.selection)),
// // );
// // TODO: somehow filter to do this only if the selection changed
// onChange(ev);
//
// // if (footnoteContext.getShowForm()) {
// // updateFootnotesContextFromActiveFootnote(editor, footnoteContext, {
// // saveSelection: false,
// // // clearIfNoActiveFootnote: false,
// // });
// // }
// },
// [editor, footnoteContext, onChange],
// );

const pluginToolbarRef = React.useRef();
editor.pluginToolbarRef = pluginToolbarRef;

const [PluginToolbarChildren, setPluginToolbar] = React.useState(null);
editor.setPluginToolbar = setPluginToolbar;

Expand All @@ -160,7 +108,7 @@ const SlateEditor = ({
{/* <SidebarFootnoteForm showForm={showForm} /> */}
<Slate editor={editor} value={value || initialValue} onChange={onChange}>
{PluginToolbarChildren && (
<PluginToolbar selected={selected} ref={pluginToolbarRef}>
<PluginToolbar selected={selected}>
{PluginToolbarChildren}
</PluginToolbar>
)}
Expand Down

0 comments on commit 72f8f69

Please sign in to comment.