mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
MD Editor: Finished conversion to Typescript
This commit is contained in:
27
resources/js/markdown/markdown.ts
Normal file
27
resources/js/markdown/markdown.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import MarkdownIt from 'markdown-it';
|
||||
// @ts-ignore
|
||||
import mdTasksLists from 'markdown-it-task-lists';
|
||||
|
||||
export class Markdown {
|
||||
protected renderer: MarkdownIt;
|
||||
|
||||
constructor() {
|
||||
this.renderer = new MarkdownIt({html: true});
|
||||
this.renderer.use(mdTasksLists, {label: true});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the front-end render used to convert Markdown to HTML.
|
||||
*/
|
||||
getRenderer(): MarkdownIt {
|
||||
return this.renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given Markdown to HTML.
|
||||
*/
|
||||
render(markdown: string): string {
|
||||
return this.renderer.render(markdown);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user