bevacqua / woofmark

:dog2: Barking up the DOM tree. A modular, progressive, and beautiful Markdown and HTML editor
https://bevacqua.github.io/woofmark
MIT License
1.62k stars 74 forks source link

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

Closed jywarren closed 6 years ago

jywarren commented 7 years ago

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:

https://github.com/bevacqua/woofmark/blob/2d932112d44c7f72ccc9e23daf6749b9cc8bcdde/src/html/linkOrImageOrAttachment.js#L51

That's because that should be specified here:

https://github.com/bevacqua/woofmark/blob/2d932112d44c7f72ccc9e23daf6749b9cc8bcdde/src/bindCommands.js#L74

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.

jywarren commented 7 years ago

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.

jywarren commented 7 years ago

Fix submitted in #46!