jsakamoto / Toolbelt.Blazor.HotKeys

This is a class library that provides configuration-centric keyboard shortcuts for your Blazor WebAssembly (client-side) apps.
https://jsakamoto.github.io/Toolbelt.Blazor.HotKeys/
Mozilla Public License 2.0
111 stars 14 forks source link

Support to change path of js #15

Open newbe36524 opened 3 years ago

newbe36524 commented 3 years ago

I am developing a Chrome extension with Blazor, and _content folder is forbidden to load in browser extension since it is build in restriction. So, I need to load js from some folder like content instead of _content.

You can check out my source code to see what I am doing at https://github.com/Amazing-Favorites/Amazing-Favorites if you are interested in

jsakamoto commented 3 years ago

Wow, it sounds so cool! And, that's interesting!
Yes, I'll consider supporting creating a browser extension scenario, particularly improve loading JavaScript helper code to be more flexible.

But I'm afraid it will take a while due to this library is just my weekend hobby works.

I appreciate your understanding!

jsakamoto commented 3 years ago

@newbe36524

I released the new version of "Blazor HotKeys", ver.11.1.0.

I made this version to be able to disable automatic injection of the client-side script, instead of changing the path of that.

Maybe you can use "Blazor HotKeys" for your browser extension project with the following step.

  1. Add "Blazor HotKeys" latest version, v.11.1.0, to your project.
<!-- This is "Newbe.BookmarkManager.csproj" file -->
...
  <ItemGroup>
    ...
    <!-- 👇 Add this. -->
    <PackageReference Include="Toolbelt.Blazor.HotKeys" Version="11.1.0" />
  </ItemGroup>
  1. Add <script> tag manually to load the client-side script of "Blazor HotKeys" by yourself.
<!-- This is "wwwroot/index.html" file -->
  ...
  <!-- 👇 Add this. -->
  <script src="content/Toolbelt.Blazor.HotKeys/script.min.js"></script>
</body>
...
  1. Add "HotKeys" service. And when doing that, don't forget to the DisableClientScriptAutoInjection option for the HotKeys service to true.
// This is "Program.cs"
...
public static async Task Main(string[] args)
{
  ...
  // 👇 Add this
  builder.Services.AddHotKeys(options => 
  {
    options.DisableClientScriptAutoInjection = true;
  });
  ...

I hope this will helps you!

newbe36524 commented 3 years ago

WOW, it is cool, I will add a new story to make it done in the next sprint. And I will get back to you if it works.