I did a live editor with docsify. Am I reinventing the wheel? #2513
ed-parsadanyan
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone. I was experimenting with docsify.js recently and wanted to make it a part of one API service (basically you make api requests and get pages with docsify included.
As part of one endpoint, I wanted to give a user an ability to edit the existing file right in a browser (something similar to what stackedit.io offers)
After some wrestling with doscify and creating a tiny plugin, I was able to achieve the goal:
![image](https://private-user-images.githubusercontent.com/10472129/386186402-51bf0aba-9e4c-4605-bef7-f288b2a5f5d1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDAwNTUwNzgsIm5iZiI6MTc0MDA1NDc3OCwicGF0aCI6Ii8xMDQ3MjEyOS8zODYxODY0MDItNTFiZjBhYmEtOWU0Yy00NjA1LWJlZjctZjI4OGIyYTVmNWQxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjIwVDEyMzI1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE0OTlkYzNlYWJlNjZlMGFlMjYwZWIyMjc1ZGM3Y2FkOTdjY2JjY2QzOGQ5MDcyMWJmZDI0MDJmMWQ1N2Y3MzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.dGczFouNEyZ_GR9d0yOv7lEqjFiGealVIWjT9bBBHU0)
The plugin is passed in the
window.$docsify
then, there's an event listener
editor.addEventListener('input', updatePreview);
which forces the re-rendering:Am I reinventing the wheel? Should I convert this into a separate standalone plugin?
Beta Was this translation helpful? Give feedback.
All reactions