bevacqua / woofmark

:dog2: Barking up the DOM tree. A modular, progressive, and beautiful Markdown and HTML editor

Home Page:https://bevacqua.github.io/woofmark

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bureaucracy options set validate: 'image', failing non-image attachments

jywarren opened this issue · comments

Finally got this bug!

This needs to be set to upload.validate || 'image', to properly set validator as in README: https://github.com/bevacqua/woofmark#optionsattachments.

https://github.com/bevacqua/woofmark/blob/master/src/prompts/prompt.js#L116

I also found that after solving that, I got options.mergeHtmlAndAttachment is not a function on this line:

parts = options.mergeHtmlAndAttachment(chunks.before + chunks.selection + chunks.after, link);

That's because that should be specified here:

mergeHtmlAndAttachment: options.mergeHtmlAndAttachment,

But that doesn't seem to appear anywhere else in the codebase. I think it could be from a previous version of the API, but it seems to be pretty simple:

options.mergeHtmlAndAttachment(chunks.before + chunks.selection + chunks.after, link);

And it expects:

      chunks.before = parts.before;
      chunks.selection = parts.selection;
      chunks.after = parts.after;

I'm going to try just adding a default that wraps it in an <a> tag.

Happy to submit a PR shortly.

There may be a more up-to-date way to do this, perhaps modeling on what happens in https://github.com/bevacqua/woofmark/blob/2d932112d44c7f72ccc9e23daf6749b9cc8bcdde/src/markdown/linkOrImageOrAttachment.js -- but it's a bit obscure to me, so I'll stick with a minimal change for now.

Fix submitted in #46!