Commit 63aa2880 authored by chris's avatar chris

headings and subtitle

parent d26d6824
......@@ -10,7 +10,8 @@ const blockActive = (type, attrs = {}) => state => {
if (node) {
return node.hasMarkup(type, attrs);
}
console.log("type", $from.end());
// console.log(to <= $from.end() && $from.parent.hasMarkup(type, attrs));
return to <= $from.end() && $from.parent.hasMarkup(type, attrs);
};
......@@ -27,6 +28,72 @@ export default {
setBlockType(state.config.schema.nodes.paragraph)(state, dispatch);
},
select: state => true,
menu: props => <Button key={uuid()} {...props} />
},
subtitle: {
title: "Change to Subtilte",
content: "Subtilte",
active: state => {
return blockActive(state.config.schema.nodes.subtitle)(state);
},
run(state, dispatch) {
setBlockType(state.config.schema.nodes.subtitle)(state, dispatch);
},
select: state => true,
menu: props => <Button key={uuid()} {...props} />
},
heading1: {
title: "Change to heading level 1",
content: "Heading 1",
active: state => {
return blockActive(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,
dispatch
);
},
select: state => true,
menu: props => <Button key={uuid()} {...props} />
},
heading2: {
title: "Change to heading level 2",
content: "Heading 2",
active: state => {
return blockActive(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,
dispatch
);
},
select: state => true,
menu: props => <Button key={uuid()} {...props} />
},
heading3: {
title: "Change to heading level 3",
content: "Heading 3",
active: state => {
return blockActive(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,
dispatch
);
},
select: state => true,
menu: props => <Button key={uuid()} {...props} />
}
......
......@@ -38,9 +38,25 @@
border-right: 1px solid rgba(0, 0, 0, 0.26);
}
.wax-l-editoria .side-menu-inner {
display: flex;
width: 100%;
}
.wax-l-editoria .side-menu {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
margin-top: 15px;
}
.wax-l-editoria .side-menu button {
display: flex;
margin-left: 5%;
flex-direction: column;
width: 90%;
}
.wax-l-editoria .wax-surface-container {
flex: 1;
......
......@@ -34,6 +34,49 @@ const EditoriaSchema = {
toDOM() {
return pDOM;
}
},
subtitle: {
content: "inline*",
group: "block",
priority: 0,
defining: true,
attrs: {
class: { default: "cst" }
},
parseDOM: [
{
tag: "p",
getAttrs(dom) {
return {
class: dom.getAttribute("class")
};
}
}
],
toDOM(node) {
return ["p", node.attrs, 0];
}
},
heading: {
attrs: { class: { default: "ct" }, level: { default: 1 } },
content: "inline*",
group: "block",
defining: true,
parseDOM: [
{ tag: "h1", attrs: { level: 1 } },
{ tag: "h2", attrs: { level: 2 } },
{ tag: "h3", attrs: { level: 3 } },
{ tag: "h4", attrs: { level: 4 } },
{ tag: "h5", attrs: { level: 5 } },
{ 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];
}
}
}
},
marks: {
......
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