-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): renderer loading deferred into own fn
- Loading branch information
1 parent
5add68d
commit fa1e04c
Showing
3 changed files
with
33 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ReactiveVar } from 'meteor/reactive-var' | ||
import { TaskRenderers } from './TaskRenderers' | ||
import { LeaMarkdown } from '../../api/markdown/LeaMarkdown' | ||
import { defaultMarkdownRenderer } from './defaultMarkdownRenderer' | ||
|
||
// register markdown renderer | ||
const defaultMarkdownRendererName = 'default' | ||
const renderersLoaded = new ReactiveVar() | ||
|
||
export const initTaskRenderers = () => { | ||
if (renderersLoaded.get()) { | ||
return renderersLoaded | ||
} | ||
|
||
LeaMarkdown.addRenderer(defaultMarkdownRendererName, defaultMarkdownRenderer()) | ||
|
||
TaskRenderers.init({ | ||
markdown: { | ||
renderer: async txt => { | ||
const mdOptions = { input: txt, renderer: defaultMarkdownRendererName } | ||
return LeaMarkdown.parse(mdOptions) | ||
} | ||
} | ||
}) | ||
.then(() => renderersLoaded.set(true)) | ||
.catch(e => console.error(e)) | ||
|
||
return renderersLoaded | ||
} |