Commit 2fb15ed3 authored by chris's avatar chris

add prosemirror marks

parent 1c402f08
import React, { Component } from "react";
import { Wax, CreateSchema } from "wax-prosemirror-core";
import { DefaultSchema } from "wax-prosemirror-schema";
import { EditoriaSchema } from "wax-prosemirror-schema";
import { MainMenuBar } from "wax-prosemirror-components";
import "wax-prosemirror-layouts/defaultLayout.css";
import "wax-prosemirror-themes/defaultTheme.css";
......@@ -9,7 +9,7 @@ const plugins = [];
const keys = {};
const options = {
schema: new CreateSchema(DefaultSchema)
schema: new CreateSchema(EditoriaSchema)
};
class Editoria extends Component {
......
const pDOM = ["p", 0],
brDOM = ["br"];
const defaultSchema = {
const DefaultSchema = {
nodes: {
doc: {
content: "block+"
......@@ -32,4 +32,4 @@ const defaultSchema = {
marks: {}
};
export default defaultSchema;
export default DefaultSchema;
// Npdes
const pDOM = ["p", 0],
brDOM = ["br"];
//Marks
const emDOM = ["em", 0],
strongDOM = ["strong", 0],
codeDOM = ["code", 0];
const EditoriaSchema = {
nodes: {
doc: {
content: "block+"
},
text: {
group: "inline"
},
hard_break: {
inline: true,
group: "inline",
selectable: false,
parseDOM: [{ tag: "br" }],
toDOM() {
return brDOM;
}
},
paragraph: {
content: "inline*",
group: "block",
parseDOM: [{ tag: "p" }],
toDOM() {
return pDOM;
}
}
},
marks: {
link: {
attrs: {
href: {},
title: { default: null }
},
inclusive: false,
parseDOM: [
{
tag: "a[href]",
getAttrs(dom) {
return {
href: dom.getAttribute("href"),
title: dom.getAttribute("title")
};
}
}
],
toDOM(node) {
let { href, title } = node.attrs;
return ["a", { href, title }, 0];
}
},
em: {
parseDOM: [{ tag: "i" }, { tag: "em" }, { style: "font-style=italic" }],
toDOM() {
return emDOM;
}
},
strong: {
parseDOM: [
{ tag: "strong" },
{
tag: "b",
getAttrs: node => node.style.fontWeight != "normal" && null
},
{
style: "font-weight",
getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
}
],
toDOM() {
return strongDOM;
}
},
code: {
parseDOM: [{ tag: "code" }],
toDOM() {
return codeDOM;
}
}
}
};
export default EditoriaSchema;
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