Rosey/markdown-draft-js

Provide the code for the remarkableMentionPlugin

Opened this issue · 3 comments

Hi Rosey,

Thank you for the work on this great plugin. Would it be possible to provide the code to the remarkableMentionPlugin in the docs? I'm trying to create a plugin to convert the htmltag to DraftJS, but I can't figure out how to write the plugin. The remarkable plugin docs are very cryptic.

In your code snippet, where does blockEntities.mention_open come from? Is this something created in your plugin?

What in the world is the item argument passed to the mention_open method?

I know you're very busy, but if you have the time to dump the code for the plugin somewhere, it would be super helpful to understanding how the conversion from markdownToDraft can be extended.

Thank you :)

Hi @Rosey,

I have the same issue.

Hi @isabellachen, If you find a way to convert a mention html tag to DraftJS can you please share the code?

I'll let you know if I find a way!!

@isabellachen, I may found the code:

...
    var markdown = 'Test @[Rose](1)';
    var conversionResult = markdownToDraft(markdown, {
      remarkablePlugins: [mentionWrapper],
      blockEntities: {
        mention_open: function (item) {
          return {
            type: 'MENTION',
            mutability: 'IMMUTABLE',
            data: {
              id: item.id,
              name: item.name
            }
          };
        }
      }
    });
...

From here: https://github.com/Rosey/markdown-draft-js/blob/master/test/markdown-to-draft.spec.js#L415

I opened PR #118 adding a link to the code definition of mentionWrapper.