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

Intercept urls from cms #75

Open
Alexnortung opened this issue Feb 13, 2023 · 2 comments
Open

Intercept urls from cms #75

Alexnortung opened this issue Feb 13, 2023 · 2 comments

Comments

@Alexnortung
Copy link

Purpose

  • New feature

Description

I think it should be possible to intercept urls, in case you use a CMS that provides the editorjs blocks. The idea is that a CMS might only give you a relative path to a given media resource, so the url would not be correct when rendering with this library.

I doesn't seem like there is a solution right now other than making a custom renderer.

Possible solution

A prop for a prefix for urls that starts with /
Or a prop for a function that can intercept the urls, example:

const getCmsUrl = (url: string) => {
  if (!url.startsWith('/') return url;
  return `${cmsUrl}${url}`;
}
@lightningspirit
Copy link
Contributor

Hello @Alexnortung, thank you for your report. 💯

You can find a similar proposal in #52 but, as I described in the comment, I find there's an issue in regards to how (some?) CMSes are dealing with uploading data. If you look at the spec of Editor.js Image plugin you can find the following:

file - uploaded file data. Must contain an url field with full public path to the uploaded image. Also, can contain any additional fields you want to store. For example, width, height, id etc. All additional fields will be saved at the file object of output data.

Which clearly states that the full path must be provided, hence I think that, if you find any CMS providing Editor.js functionality but not dealing with the spec, you should open a report in their side. You can also link to this comment, if you find it useful.

If you find anything else we can help you with, please let me know.

@Alexnortung
Copy link
Author

Thanks, this makes sense! I will look into it when I am back on work on Monday.

Thanks for the library btw, it is very useful!

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