mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-03-12 05:15:37 +08:00
parent
af3c0e43a5
commit
b0e849f413
@ -214,6 +214,19 @@ export default function (ngApp, events) {
|
|||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
let renderer = new markdown.Renderer();
|
||||||
|
// Custom markdown checkbox list item
|
||||||
|
// Attribution: https://github.com/chjj/marked/issues/107#issuecomment-44542001
|
||||||
|
renderer.listitem = function(text) {
|
||||||
|
if (/^\s*\[[x ]\]\s*/.test(text)) {
|
||||||
|
text = text
|
||||||
|
.replace(/^\s*\[ \]\s*/, '<input type="checkbox"/>')
|
||||||
|
.replace(/^\s*\[x\]\s*/, '<input type="checkbox" checked/>');
|
||||||
|
return `<li class="checkbox-item">${text}</li>`;
|
||||||
|
}
|
||||||
|
return `<li>${text}</li>`;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Markdown input
|
* Markdown input
|
||||||
* Handles the logic for just the editor input field.
|
* Handles the logic for just the editor input field.
|
||||||
@ -231,13 +244,13 @@ export default function (ngApp, events) {
|
|||||||
element = element.find('textarea').first();
|
element = element.find('textarea').first();
|
||||||
let content = element.val();
|
let content = element.val();
|
||||||
scope.mdModel = content;
|
scope.mdModel = content;
|
||||||
scope.mdChange(markdown(content));
|
scope.mdChange(markdown(content, {renderer: renderer}));
|
||||||
|
|
||||||
element.on('change input', (event) => {
|
element.on('change input', (event) => {
|
||||||
content = element.val();
|
content = element.val();
|
||||||
$timeout(() => {
|
$timeout(() => {
|
||||||
scope.mdModel = content;
|
scope.mdModel = content;
|
||||||
scope.mdChange(markdown(content));
|
scope.mdChange(markdown(content, {renderer: renderer}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -281,6 +281,14 @@ ol {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li.checkbox-item {
|
||||||
|
list-style: none;
|
||||||
|
margin-left: - ($-m * 1.3);
|
||||||
|
input[type="checkbox"] {
|
||||||
|
margin-right: $-xs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic text styling classes
|
* Generic text styling classes
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user