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

Option to customize links for serialization #38

Open
siliconeidolon opened this issue Jun 1, 2021 · 0 comments
Open

Option to customize links for serialization #38

siliconeidolon opened this issue Jun 1, 2021 · 0 comments

Comments

@siliconeidolon
Copy link

siliconeidolon commented Jun 1, 2021

I saw that the option to customise the key for link destinations was added to the deserialization function, but it'd be good to have it in the serializer as well.

I expect we'd need to add linkDestinationKey to the serializer options, then use it here:

case nodeTypes.link:
      return `[${children}](${(chunk as BlockType)[linkDestinationKey] || ''})`;

Unfortunately, BlockType expects 'link' only, so I'm not sure whether it would make sense to make that property type more permissive or maybe I'm missing an alternative way to handle this. Happy to submit a PR with some guidance.

Example Slate object:

{
    "type": "a",
    "url": "https://google.co.uk", // referenced by `linkDestinationKey`
    "children": [
        {
            "text": "Google"
        }
    ],
}

Would convert to

[Google](https://google.co.uk)
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

Successfully merging a pull request may close this issue.

1 participant