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

Provide the code for the remarkableMentionPlugin #116

Open
isabellachen opened this issue Mar 12, 2020 · 3 comments
Open

Provide the code for the remarkableMentionPlugin #116

isabellachen opened this issue Mar 12, 2020 · 3 comments

Comments

@isabellachen
Copy link

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 :)

@danielsnider
Copy link
Contributor

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!!

@danielsnider
Copy link
Contributor

danielsnider commented Mar 25, 2020

@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

@danielsnider
Copy link
Contributor

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

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

No branches or pull requests

2 participants