TikiTDO / trumbowyg_rails

18 stars 21 forks source link

Editor won't start due to problem with svgPath #6

Closed AndKiel closed 8 years ago

AndKiel commented 8 years ago

When trying to initialize trumbowyg like that: $ -> $('.trumbowyg').trumbowyg()

I get:

TypeError: stackLines[Number(...)].match(...) is null http://192.168.13.37/assets/trumbowyg/trumbowyg.self-2531006bb68a51ccd07d714f86693312eb36f552384a75ef975d560d207ae5aa.js?body=1 Line 166

When I provide any svgPath, for example: $ -> $('.trumbowyg').trumbowyg(svgPath: false) it's working (but no icons, just empty buttons).

For now a quick solution for me was putting trumbowyg icons SVG file in public/images and providing path as svgPath parameter.

TikiTDO commented 8 years ago

This is a combination of two problems. One is a bug with how the original library parses URLs, the other is an issue with how rails creates asset digests. I submitted a pull request for the first in the original repo. I'll see if I can come up with something for the second.

snvl1993 commented 8 years ago

@AndKiel, try to set svgPath as below:

$('.trumbowyg').trumbowyg(svgPath: '/assets/trumbowyg/images/icons.svg')

it works for me.

AndKiel commented 8 years ago

@snvl1993, it works in development but in production I get 404.

TikiTDO commented 8 years ago

@AndKiel As long as you are running this code within an erb context you could do something like this:

$('.trumbowyg').trumbowyg(svgPath: '<%= image_path "/images/icons.svg" %>')

It's not very neat but it should get the job done. Once I have some more time I'm going to come back to this and write some sort of migration script that makes the required adjustments automatically on release, but I have no idea when I'll have enough time to do that.