Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.38k stars 314 forks source link

Avoid data attribute namespace conflicts #456

Closed vanillajonathan closed 10 months ago

Ionaru commented 2 years ago

What problem does this solve?

Also would be a breaking change.

vanillajonathan commented 2 years ago

The problem it solves is it avoids any potential conflicts when using other libraries and code that might also use data attributes by putting all EasyMDE-related data attributes in its own namespace.

This is also done by Bootstrap.

Data attributes for all JavaScript plugins are now namespaced to help distinguish Bootstrap functionality from third parties and your own code. For example, we use data-bs-toggle instead of data-toggle.

https://getbootstrap.com/docs/5.2/migration/#javascript

It is not a breaking change since the data-img-src (now data-mde-img-src) attribute is not part of the public API, it is not mentioned anywhere in the documentation, it is an internal concern only.

Ionaru commented 2 years ago

Even though it is not documented, it is still part of the public API and can be used for styling purposes (see here: https://github.com/Ionaru/easy-markdown-editor/blob/master/src/css/easymde.css#L368).

There's a reasonable chance other developers have used that attribute to hook in extra functionality or style an element in the 2 years data-img-src has existed.

vanillajonathan commented 2 years ago

I see. I was not aware it was considered part of the public API. The data attribute is not mentioned in the documentation.

If you don't want to merge it, consider assigning the PR to a Project or a Label for the upcoming major rewrite.

Ionaru commented 2 years ago

Ref #447

vanillajonathan commented 2 years ago

Yeah, I saw that post. Good that you made a ref to it. GitHub includes "Projects" and "Labels" too which can be assigned to issues and pull requests.