-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Custom editor components don't render markdown #6797
Comments
Will there ever be support on this, I still don't have this working and it is pretty standard behavior which I'm trying to achieve. Also this is a use-case documented in the documentation but it's not working properly! |
@alianza we'll figure out what to do. I ran out of time last time. You're right that something could be improved, I'm trying to first figure out exactly what. Component is similar to example on documentation https://decapcms.org/docs/custom-widgets/#registereditorcomponent Example has info what function In conclusion, function I'll use this issue to correct documentation example, otherwise it should provide an answer p.s. you don't need to parse your entire html, just markdown. As: |
* /decaporg/decap-cms/issues/7102 documentation for publish mode possible values * fix: /decaporg/decap-cms/issues/6797 registerEditorComponent example
Is it worth leaving this issue open to improve this? It seems like a gap to me in the custom widget functionality. Since we can add a Markdown widget to the custom widget, it should be possible (with code changes, of course) to also use the Markdown preview widget in |
Describe the bug
Custom editor components registered with
CMS.registerEditorComponent()
don't render their markdown content in the preview window. So if you use the markdown plugin in a custom editor component it just displays the raw markdown in the preview window. E.g. the example<details/>
tag custom editor component from the documentation ofregisterEditorComponent
(https://decapcms.org/docs/custom-widgets/#registereditorcomponent), after you fix thedetails
variable names that are wrong -> decaporg/decap-website#13. The widget works but markdown content is not rendered, see screenshot below.The rest of the page renders all markdown fine. Repo: https://github.com/alianza/portfolio-v2
A working fix but not ideal because of increased initial loading times is to load a library like
marked
(could not findremark
cdn equivalent) via cdn and returnmarked.parse(markdownContent)
in thetoPreview()
method of the custom editor component. Then it renders correctly in the preview window!A nicer solution would be if this would just work out of the box, or if we could use the
remark
markdown parser used by the CMS internally to render markdown content so we don't have to load a 3rd party library for that on the side.To Reproduce
Steps to reproduce the behavior:
npm install
local_backend
to true inpublic/admin/config.yml
npm run dev
http://localhost:3000/admin/index.html
Expected behavior
Markdown content is rendered in preview pane
Screenshots
![image](https://private-user-images.githubusercontent.com/1502192/243818326-e41665f8-d27d-4a5f-9ade-785cb10448c1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMDkwMDQsIm5iZiI6MTczOTMwODcwNCwicGF0aCI6Ii8xNTAyMTkyLzI0MzgxODMyNi1lNDE2NjVmOC1kMjdkLTRhNWYtOWFkZS03ODVjYjEwNDQ4YzEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMjExODI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTkyYjJmY2MwMmVmZjU4MjczMTliOTg1NTY4NTI1NDBhNTVlOTQ0MWUzMjA1NGRlNmNkNzA1OTkxNTRkMTU0OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Zm4dBpnHVnQV3xKOYgfQZ6KSY5-jVoNyFaF15AByK90)
Applicable Versions:
netlify-cms-app 2.15.72
netlify-cms-core 2.55.2
netlify-cms 2.10.192
CMS configuration
The text was updated successfully, but these errors were encountered: