Open envygeeks opened 8 years ago
Hmm, interesting. Sounds like an issue. Contributions are welcome! ✨
@envygeeks did you get this to work? I am looking for the same behaviour.
@nickspiel we ended up just building our own convert class that runs 100% of the time before content is spawned and storing the current language as a state, showdown and html2markdown (I can't remember the actual lib name, that might be it) did the trick real well.
Yeah, I considered doing the same in my app (Vuejs). I might dig into the medium-editor plugin tonight and see if I can make a PR. Makes sense to have this plugin handle the conversion on both ends.
I found the same problem as initializing with markdown content. Prepopulate should be consider as a feature in the future release?
The plugin is supposed to be called on init, according to this line.
And in fact, it does do that on the demo page (where the ME has content in it already).
Can any of you provide a demo where this is failing? Thanks!
Supposed we will use textarea as the provider of initial content which we stored via markdown source in it.
<textarea id="content">## Markdown Medium Editor\n\n**Hello**</textarea>
<div id="editor"></div>
<script>
markDownEl = $('#content');
mdEditor = new MediumEditor($('#editor'), {
extensions: {
markdown: new MeMarkdown(function (md) {
markDownEl.textContent = md;
})
}
});
</script>
When the "#editor" initialized, the default content will be disappeared.
@chenillen In this case it simply works as expected, because there is no relation between textarea :arrow_right: ME.
What you're experiencing is #42, which is not solved yet.
I finally added the markdown2html initializer after initializes the editor, convert the default markdown content to HTML( which I put another library instead. :-<
Thanks btw.
@chenillen I think we can add in ME Markdown an optional function to be called to convert the Markdown into HTML. For example:
new MeMarkdown({
markdownToHtml: markdown2html
// or
markdownToHtml: md => yourOwnMarkdownConverter(md)
}, function (md) {
markDownEl.textContent = md;
})
@IonicaBizau that could be awesome, we can save lots of logics 👍
Given you initialize
MediumEditor
with default content,MEMarkdown
doesn't convert to Markdown from the HTML thatMediumEdtior
receives via it's element, resulting inMEMarkdown
simply passing HTML. This was discovered during component updates via React.