Commit 06515d75 authored by chris's avatar chris

set left menu enabled

parent 37e43e49
import React from "react";
import { forEach, map } from "lodash";
import SideMenuItems from "./SideMenuItems";
const filtered = (menu, menuItems) =>
Object.keys(menu)
.filter(key => menuItems.includes(key))
.reduce((obj, key) => {
obj[key] = menu[key];
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 SideMenuBar = ({
menuItems = [],
children,
state,
dispatch,
className,
fileUpload
}) => (
<div className={`${className} side-menu-container`}>
<div className="side-menu-inner">
<div className="side-menu">
{
<span>
{map(setMenuItems(SideMenuItems, menuItems), item =>
item.menu({ state, dispatch, item, fileUpload })
)}
</span>
}
</div>
</div>
</div>
);
export default SideMenuBar;
......@@ -18,10 +18,9 @@ export default {
title: "Change to General Text",
// content: icons.paragraph,
content: "General Text",
active: state => {
return blockActive(state.config.schema.nodes.paragraph)(state);
enable: state => {
return setBlockType(state.config.schema.nodes.paragraph)(state);
},
// enable: setBlockType(schema.nodes.paragraph),
run(state, dispatch) {
setBlockType(state.config.schema.nodes.paragraph)(state, dispatch);
},
......@@ -32,8 +31,8 @@ export default {
subtitle: {
title: "Change to Subtilte",
content: "Subtilte",
active: state => {
return blockActive(state.config.schema.nodes.subtitle)(state);
enable: state => {
return setBlockType(state.config.schema.nodes.subtitle)(state);
},
run(state, dispatch) {
setBlockType(state.config.schema.nodes.subtitle)(state, dispatch);
......@@ -44,12 +43,11 @@ export default {
heading1: {
title: "Change to heading level 1",
content: "Heading 1",
active: state => {
return blockActive(state.config.schema.nodes.heading, { level: 1 })(
enable: state => {
return setBlockType(state.config.schema.nodes.heading, { level: 1 })(
state
);
},
// enable: setBlockType(schema.nodes.heading, { level: 1 }),
run(state, dispatch) {
setBlockType(state.config.schema.nodes.heading, { level: 1 })(
state,
......@@ -62,12 +60,11 @@ export default {
heading2: {
title: "Change to heading level 2",
content: "Heading 2",
active: state => {
return blockActive(state.config.schema.nodes.heading, { level: 2 })(
enable: state => {
return setBlockType(state.config.schema.nodes.heading, { level: 2 })(
state
);
},
// enable: setBlockType(schema.nodes.heading, { level: 2 }),
run(state, dispatch) {
setBlockType(state.config.schema.nodes.heading, { level: 2 })(
state,
......@@ -80,12 +77,11 @@ export default {
heading3: {
title: "Change to heading level 3",
content: "Heading 3",
active: state => {
return blockActive(state.config.schema.nodes.heading, { level: 3 })(
enable: state => {
return setBlockType(state.config.schema.nodes.heading, { level: 3 })(
state
);
},
// enable: setBlockType(schema.nodes.heading, { level: 3 }),
run(state, dispatch) {
setBlockType(state.config.schema.nodes.heading, { level: 3 })(
state,
......
......@@ -58,7 +58,7 @@ const EditoriaSchema = {
}
},
heading: {
attrs: { class: { default: "ct" }, level: { default: 1 } },
attrs: { level: { default: 1 } },
content: "inline*",
group: "block",
defining: true,
......@@ -71,11 +71,7 @@ const EditoriaSchema = {
{ tag: "h6", attrs: { level: 6 } }
],
toDOM(node) {
if (node.attrs.level === 1) {
return ["h" + node.attrs.level, node.attrs, 0];
} else {
return ["h" + node.attrs.level, 0];
}
return ["h" + node.attrs.level, 0];
}
}
},
......
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