Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2017-02-25 13:16:26 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
b0e849f4137772a424be55d022324cfd7761d3ff
b0e849f4
1 parent
af3c0e43
Added checkbox sytax parsing to markdown lists
Closes #319
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
resources/assets/js/directives.js
resources/assets/sass/_text.scss
resources/assets/js/directives.js
View file @
b0e849f
...
...
@@ -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
* Handles the logic for just the editor input field.
...
...
@@ -231,13 +244,13 @@ export default function (ngApp, events) {
element
=
element
.
find
(
'textarea'
).
first
();
let
content
=
element
.
val
();
scope
.
mdModel
=
content
;
scope
.
mdChange
(
markdown
(
content
));
scope
.
mdChange
(
markdown
(
content
,
{
renderer
:
renderer
}
));
element
.
on
(
'change input'
,
(
event
)
=>
{
content
=
element
.
val
();
$timeout
(()
=>
{
scope
.
mdModel
=
content
;
scope
.
mdChange
(
markdown
(
content
));
scope
.
mdChange
(
markdown
(
content
,
{
renderer
:
renderer
}
));
});
});
...
...
resources/assets/sass/_text.scss
View file @
b0e849f
...
...
@@ -281,6 +281,14 @@ ol {
overflow
:
hidden
;
}
li
.checkbox-item
{
list-style
:
none
;
margin-left
:
-
(
$-m
*
1
.3
);
input
[
type
=
"checkbox"
]
{
margin-right
:
$-xs
;
}
}
/*
* Generic text styling classes
*/
...
...
Please
register
or
sign in
to post a comment