voidlabs / mosaico

Mosaico - Responsive Email Template Editor
https://mosaico.io
GNU General Public License v3.0
1.71k stars 504 forks source link

Can I use other plugins when creating templates? #287

Closed K1nesis closed 7 years ago

K1nesis commented 7 years ago

Hi,

I tried to use other plugins when creating templates, but failed.

So I want to know if I can use other JS plugins when I create a template?

If so, what should I do?

Any advice would be useful.

Thanks in advance!

bago commented 7 years ago

I can't understand the question/issue.

K1nesis commented 7 years ago

@bago

Thanks for the prompt reply.I'm sorry for my poor English.

May I know if we could import external js & css files into the mosaic block? We are going to build a mobile touch slider block using swiper.js. Here is the link for swiper for your reference: http://idangero.us/swiper/#.WLLZehKGMck

Here is the screenshot that we used this template in mosaic. The external CSS & JS file did not work at all.

image

Thanks again.

bago commented 7 years ago

You can't use javascript in email: most email client will block it. Most email server will mark it as spam.

K1nesis commented 7 years ago

All right,i know that we can't use javascript in email.

Actually i have other uses. I'm trying to make it an editor instead of an email . Just making content and push to users in other ways. From your answer I know that you didn't achieve the function. I'll try it another way.

Mosaico is really a great work! Thank you for sharing the great open source works!

bago commented 7 years ago

I'm sorry I never thought about this as we developed it for use as an email editor. In theory it should work. Maybe you need absolute paths as mosaico only deals with relative img src in templates and not other "sources" (script/link rel)

K1nesis commented 7 years ago

I'm glad to receive your advice. The problem I am facing now is that swiper must be initialized before it can work.

Here is the code in template html:

<script type="text/javascript">
  window.onload=function(){
  var mySwiper = new Swiper('.swiper-container',{
    loop: true,
    autoplay: 3000,
  });

}
</script>
</body>

Mosaico ignores the code so that it did not work. So is there any way to get mosaicoto execute it?

bago commented 7 years ago

maybe scripts are cleaned by jquery html parsing to avoid injection. Maybe you have to replace them to something else before "parsing" and then restore them later: https://github.com/voidlabs/mosaico/blob/master/src/js/template-loader.js#L168

If you want to use Mosaico for non-email stuff you will have to learn how mosaico internals works and be prepared to do a lot of changes/improvements. Some of them are "logical" ones (e.g: are scripts expected to run while editing? you probably don't want to edit a slider while it automatically slide to the next view).

K1nesis commented 7 years ago

Thank you for answering a lot of my questions! I don't have any other questions.

Thank you very nuch indeed!