1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Added bg-color mark, added color grid selectors

This commit is contained in:
Dan Brown
2022-01-12 15:33:59 +00:00
parent 1018b5627e
commit 56d7864bdf
6 changed files with 98 additions and 7 deletions

View File

@ -30,6 +30,20 @@ marks.subscript = {
close: '</sub>',
};
marks.text_color = {
open(state, mark, parent, index) {
return `<span style="color: ${mark.attrs.color};">`
},
close: '</span>',
};
marks.background_color = {
open(state, mark, parent, index) {
return `<span style="background-color: ${mark.attrs.color};">`
},
close: '</span>',
};
function writeNodeAsHtml(state, node) {
const html = docToHtml({ content: [node] });
@ -43,11 +57,11 @@ function writeNodeAsHtml(state, node) {
// or element that cannot be represented in commonmark without losing
// formatting or content.
for (const [nodeType, serializerFunction] of Object.entries(nodes)) {
nodes[nodeType] = function(state, node) {
nodes[nodeType] = function(state, node, parent, index) {
if (node.attrs.align) {
writeNodeAsHtml(state, node);
} else {
serializerFunction(state, node);
serializerFunction(state, node, parent, index);
}
}
}