Alex-D / Trumbowyg

A lightweight and amazing WYSIWYG JavaScript editor under 10kB
https://alex-d.github.io/Trumbowyg
MIT License
3.99k stars 612 forks source link

Editor Icons Fail to Display if Page URL Contains Query String #1237

Open nmchapin opened 3 years ago

nmchapin commented 3 years ago

When loading SVG icons for the editor from a file, the icons will fail to display if the page contains a query string. This regression was introduced in version 2.22 after the following line was introduced:

https://github.com/Alex-D/Trumbowyg/blob/ad5912734a71667ba69e992641900cab7d7db414/src/trumbowyg.js#L264

In the previous version, this line used a different argument for splitting the HREF of the current page. It looked like this:

t.svgPath = !!t.doc.querySelector('base') ? window.location.href.split('#')[0] : '';

As you can see, the HREF is split on the pound character. This allowed icons to be correctly referenced by the editor in their respective USE tags. So, for instance, a URL for referencing the "Bold" icon would look like this:

http://localhost/object/edit?page=2#trumbowyg-bold

But, due to the regression, this URL looks like this:

http://localhost/object/edit#trumbowyg-bold

Alex-D commented 3 years ago

Hi!

You right! The origin commit is: https://github.com/Alex-D/Trumbowyg/commit/0cff83e49ec8e491f06e580ac6a1ac672cb9059d

I did not understand why I've done this change.

I think I should roll back this in the next version.

phuongnle commented 1 year ago

Hi @Alex-D

I think I should roll back this in the next version.

Do you plan to do it in the near future?

And there's also a PR for this issue as well #1279

Thanks for the great lib btw ❤️