mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Refactored markdown editor logic
Split out the markdown editor logic into seperate components to provide a more orgranised heirachy with feature-specific files.
This commit is contained in:
30
resources/js/markdown/markdown.js
Normal file
30
resources/js/markdown/markdown.js
Normal file
@ -0,0 +1,30 @@
|
||||
import MarkdownIt from "markdown-it";
|
||||
import mdTasksLists from 'markdown-it-task-lists';
|
||||
|
||||
export class Markdown {
|
||||
|
||||
constructor() {
|
||||
this.renderer = new MarkdownIt({html: true});
|
||||
this.renderer.use(mdTasksLists, {label: true});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the front-end render used to convert markdown to HTML.
|
||||
* @returns {MarkdownIt}
|
||||
*/
|
||||
getRenderer() {
|
||||
return this.renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given Markdown to HTML.
|
||||
* @param {String} markdown
|
||||
* @returns {String}
|
||||
*/
|
||||
render(markdown) {
|
||||
return this.renderer.render(markdown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user