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

need for mergeHtmlAndAttachment in markdown resolved() method? #67

Open jywarren opened 6 years ago

jywarren commented 6 years ago

I'm loving the new options.mergeHtmlAndAttachment ability to intercept and custom-format attachments -- https://github.com/bevacqua/woofmark/blob/b58efb794f7610c92d70bec435cfd021ab45673c/src/html/linkOrImageOrAttachment.js#L51

We have done so for a custom rendering of CSV files, for example, with the following code:

https://github.com/publiclab/PublicLab.Editor/blob/f5f5492e5188963b0d6b672fc60093cef34c065c/src/adapters/PublicLab.Woofmark.js#L144-L146

However, this only works in HTML mode, not markdown mode. So when dragging in an attachment in HTML mode, this custom formatter works great. But in markdown mode it is rendered as:

  [attachment-1]: /system/images/photos/000/024/808/original/114634.csv "114634.csv"

Do we need to port the mergeHtmlAndAttachment method implementation from /html/linkOrImageOrAttachment.js over to /markdown/linkOrImageOrAttachment.js to get this working in both modes?

jywarren commented 6 years ago

Could we insert a catch here:

https://github.com/bevacqua/woofmark/blob/b58efb794f7610c92d70bec435cfd021ab45673c/src/markdown/linkOrImageOrAttachment.js#L119

and defer to a custom mergeHtmlAndAttachment or corresponding mergeMarkdownAndAttachment at that point instead of going to renderLink?

@bevacqua what do you think about this way forward? Thanks!

bevacqua commented 6 years ago

It sounds like you want a different function that lets you add custom handling of links, that could be used internally to manage attachments, and exposed so that people can add their own kinds of special "attachment" links

jywarren commented 6 years ago

that sounds reasonable -- then it could be checked for and used in both "markdown" and "html" code -- how about formatAttachment()? -- thanks!!

On Sun, May 6, 2018 at 9:48 AM, Nicolás Bevacqua notifications@github.com wrote:

It sounds like you want a different function that lets you add custom handling of links, that could be used internally to manage attachments, and exposed so that people can add their own kinds of special "attachment" links

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bevacqua/woofmark/issues/67#issuecomment-386880691, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ-3RvuW7a1zO1WK-09spwKGjCLj5ks5tvv81gaJpZM4TvkPO .