mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-24 07:42:07 +03:00
Got underline working in editor
Major step, since this is the first inline HTML element which needed advanced parsing out on the markdown side, since not commonmark supported.
This commit is contained in:
@ -3,6 +3,7 @@ import {schema as basicSchema} from "prosemirror-schema-basic";
|
||||
import {addListNodes} from "prosemirror-schema-list";
|
||||
|
||||
const baseNodes = addListNodes(basicSchema.spec.nodes, "paragraph block*", "block");
|
||||
const baseMarks = basicSchema.spec.marks;
|
||||
|
||||
const nodeCallout = {
|
||||
attrs: {
|
||||
@ -18,19 +19,30 @@ const nodeCallout = {
|
||||
{tag: 'p.callout.warning', attrs: {type: 'warning'}, priority: 75,},
|
||||
{tag: 'p.callout', attrs: {type: 'info'}, priority: 75},
|
||||
],
|
||||
toDOM: function(node) {
|
||||
toDOM(node) {
|
||||
const type = node.attrs.type || 'info';
|
||||
return ['p', {class: 'callout ' + type}, 0];
|
||||
}
|
||||
};
|
||||
|
||||
const markUnderline = {
|
||||
parseDOM: [{tag: "u"}, {style: "text-decoration=underline"}],
|
||||
toDOM() {
|
||||
return ["span", {style: "text-decoration: underline;"}, 0];
|
||||
}
|
||||
}
|
||||
|
||||
const customNodes = baseNodes.append({
|
||||
callout: nodeCallout,
|
||||
});
|
||||
|
||||
const customMarks = baseMarks.append({
|
||||
underline: markUnderline,
|
||||
});
|
||||
|
||||
const schema = new Schema({
|
||||
nodes: customNodes,
|
||||
marks: basicSchema.spec.marks
|
||||
marks: customMarks,
|
||||
})
|
||||
|
||||
export default schema;
|
Reference in New Issue
Block a user