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

Accept HTML template elements as previewTemplate option #18

Open
MagnusOxlund opened this issue Sep 3, 2024 · 2 comments
Open

Accept HTML template elements as previewTemplate option #18

MagnusOxlund opened this issue Sep 3, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@MagnusOxlund
Copy link

MagnusOxlund commented Sep 3, 2024

Currently, options.previewTemplate expects a string (e.g., HTMLElement serialized using innerHTML):

https://github.com/NicolasCARPi/dropzone/blob/master/src/options.js#L553C1-L567C43:

  /**
   * A string that contains the template used for each dropped
   * file. Change it to fulfill your needs but make sure to properly
   * provide all elements.
   *
   * If you want to use an actual HTML element instead of providing a String
   * as a config option, you could create a div with the id `tpl`,
   * put the template inside it and provide the element like this:
   *
   *     document
   *       .querySelector('#tpl')
   *       .innerHTML
   *
   */
  previewTemplate: defaultPreviewTemplate,

I think it would be a natural progression to accept and automatically instantiate an HTMLTemplateElement here in addition to serialized HTML.

@NicolasCARPi
Copy link
Owner

Hello,

Yes, but I'd suggest to have it as another option, such as previewTemplateElement maybe. Want to work on a PR for this?

@MagnusOxlund
Copy link
Author

My developer time is owed elsewhere for the next while, but I'll be happy to submit a PR later if it remains up for grabs.

@NicolasCARPi NicolasCARPi added the enhancement New feature or request label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants