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

When a mark has more MD "marks" inside, the mark is duplicated (on MDX) #1082

Closed
filipesmedeiros opened this issue Apr 19, 2024 · 1 comment · Fixed by #1154
Closed

When a mark has more MD "marks" inside, the mark is duplicated (on MDX) #1082

filipesmedeiros opened this issue Apr 19, 2024 · 1 comment · Fixed by #1154
Labels
enhancement New feature or request

Comments

@filipesmedeiros
Copy link

filipesmedeiros commented Apr 19, 2024

Hey!

When you create a mark, and mark a piece of content/text with it, it gets wrapped with the (or whatever name). All good. Like this:

<Mark>Some marked text.</Mark>

But if you have something inside that mark, like a link, it will actually override the content with a weird markup:

<Mark>Some </Mark>[<Mark>marked</Mark>](https://example.com)<Mark> text</Mark>

instead of

<Mark>Some [marked](http://example.com) text.</Mark>

If I manually go to the MDX file and correct it, the WYSIWYG editor render the same as before (correctly), but every time I save the file, it overrides again with the whacky markup.

I am not sure if this happens with other inner marks like bold. I can test if necessary.

Thank you so much for this tool!

@emmatown emmatown added the enhancement New feature or request label Apr 26, 2024
@filipesmedeiros
Copy link
Author

filipesmedeiros commented Apr 27, 2024

After investigating a bit further, I found out that this is not a new discovery, it seems:

// TODO: this should handle marks spanning over multiple text nodes properly

Now, I believe this is coming directly from ProseMirror. It is sending us a structure like:

[
  {
    "type": "text",
    "marks": [
      {
        "type": "Highlight",
        "attrs": {
          "props": { "value": { "variant": "success" }, "extraFiles": [] }
        }
      }
    ],
    "text": "something "
  },
  {
    "type": "text",
    "marks": [
      {
        "type": "Highlight",
        "attrs": {
          "props": { "value": { "variant": "success" }, "extraFiles": [] }
        }
      },
      { "type": "bold" }
    ],
    "text": "bold"
  }
]

for this MDX: <Highlight variant="success">something **bold**</Highlight>.

So we would need to "glue together" all nodes inside a custom mark that are in a row.

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

Successfully merging a pull request may close this issue.

2 participants