feat: anchor - copy link to clipboard

This commit is contained in:
NGPixel
2017-05-22 13:32:52 -04:00
parent 45d94e7e94
commit 13bdb2edb7
10 changed files with 117 additions and 14 deletions

View File

@@ -20,7 +20,7 @@ var mkdown = md({
html: true,
linkify: true,
typography: true,
highlight (str, lang) {
highlight(str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' + hljs.highlight(lang, str, true).value + '</code></pre>'
@@ -206,6 +206,13 @@ const parseContent = (content) => {
cr(elm).replaceWith(txtLink)
})
// -> Add anchor handler
cr('a.toc-anchor').each((i, elm) => {
let hashText = cr(elm).attr('href').slice(1)
cr(elm).attr('v-on:click.stop.prevent', "$store.dispatch('anchorOpen', '" + hashText + "')")
})
// -> Re-attach blockquote styling classes to their parents
cr.root().children('blockquote').each((i, elm) => {
@@ -313,7 +320,7 @@ module.exports = {
* @param {String} content Markdown-formatted content
* @return {Object} Object containing meta, html and tree data
*/
parse (content) {
parse(content) {
return {
meta: parseMeta(content),
html: parseContent(content),