Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion not done when pane MediumEditor created with default content. #28

Open
envygeeks opened this issue Sep 3, 2016 · 11 comments
Labels

Comments

@envygeeks
Copy link

Given you initialize MediumEditor with default content, MEMarkdown doesn't convert to Markdown from the HTML that MediumEdtior receives via it's element, resulting in MEMarkdown simply passing HTML. This was discovered during component updates via React.

@IonicaBizau
Copy link
Owner

Hmm, interesting. Sounds like an issue. Contributions are welcome! ✨

@IonicaBizau IonicaBizau added the bug label Sep 3, 2016
@nickspiel
Copy link

@envygeeks did you get this to work? I am looking for the same behaviour.

@envygeeks
Copy link
Author

@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.

@nickspiel
Copy link

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.

@chenillen
Copy link

I found the same problem as initializing with markdown content. Prepopulate should be consider as a feature in the future release?

@IonicaBizau
Copy link
Owner

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!

@chenillen
Copy link

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.

@IonicaBizau
Copy link
Owner

@chenillen In this case it simply works as expected, because there is no relation between textarea ➡️ ME.

What you're experiencing is #42, which is not solved yet.

@chenillen
Copy link

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.

@IonicaBizau
Copy link
Owner

@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;
})

@chenillen
Copy link

@IonicaBizau that could be awesome, we can save lots of logics 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants