Commit 38b18739 authored by chris's avatar chris

build a basic menubar with options

parent b52abfd5
import React, { Component } from "react";
import styled from "styled-components";
import { Wax, createSchema } from "wax-prosemirror-core";
import { defaultSchema } from "wax-prosemirror-schema";
import { MainMenuBar } from "wax-prosemirror-components";
import "wax-prosemirror-layouts/defaultLayout.css";
import "wax-prosemirror-themes/defaultTheme.css";
......@@ -14,19 +11,6 @@ const options = {
schema: new createSchema(defaultSchema)
};
const MainEditor = styled.div`
${"" /* style override*/};
`;
const menuItems = [
"undo",
"redo",
"strong",
"image",
"table",
"tableDropDownOptions"
];
class Default extends Component {
render() {
return (
......@@ -37,12 +21,6 @@ class Default extends Component {
theme="default"
layout="default"
debug
renderLayout={({ editor, ...props }) => (
<React.Fragment>
<MainMenuBar menuItems={menuItems} {...props} />
<MainEditor className="main-editor">{editor}</MainEditor>
</React.Fragment>
)}
/>
);
}
......
import React from "react";
import map from "lodash/map";
import { forEach, map } from "lodash";
import classes from "./MenuBar.css";
import menu from "./menu";
......@@ -11,8 +11,18 @@ const filtered = (menu, menuItems) =>
return obj;
}, {});
const setMenuItems = (menu, menuItems) => {
let items = menuItems;
if (menuItems.length === 0) {
forEach(menu, (key, index) => {
items.push(index);
});
}
return filtered(menu, items);
};
const MainMenuBar = ({
menuItems,
menuItems = [],
children,
state,
dispatch,
......@@ -23,7 +33,7 @@ const MainMenuBar = ({
{children && <span className={classes.group}>{children}</span>}
{
<span className={classes.group}>
{map(filtered(menu, menuItems), item =>
{map(setMenuItems(menu, menuItems), item =>
item.menu({ state, dispatch, item, fileUpload })
)}
</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment