robindijkhof / overleaf-textarea

This plugin displays your tex source in a textarea so plugins like grammarly can check it.
GNU General Public License v3.0
513 stars 31 forks source link

Add button to control plugin on page #68

Open Caian opened 2 years ago

Caian commented 2 years ago

This PR implements the suggestion from #21. It creates a button in the toolbar-pdf-left that allows the plugin to be toggled on and off. Additionally, the code has been refactored so the toggle only affects its own page.

Screenshot from 2022-01-07 13-36-02

Possible TODOs:

robindijkhof commented 2 years ago

Could use the same icon as the plugin does.

Caian commented 2 years ago

Could use the same icon as the plugin does.

Done:

Screenshot from 2022-01-07 16-49-37

But it is hard to see. Maybe a new asset should be created instead of one of the icons.

robindijkhof commented 2 years ago

Hi, guess you are right. You can download a white version over here: https://fonts.google.com/icons?selected=Material+Icons&icon.query=spellcheck

Caian commented 2 years ago

I added the white icon to the button and also linked it with the dark theme, so the light theme will show the standard black icon:

Screenshot from 2022-01-13 09-59-15

Screenshot from 2022-01-13 09-59-31

qingping95 commented 2 years ago

This is indeed a critical feature, when will it be available? Or how to use it now?

Caian commented 2 years ago

The button now has a global behavior, like the active checkbox.

mo6zes commented 2 years ago

For anyone that can't wait till this PR gets merged, it's also possible to add a bookmarklet which toggles the visibility of the textarea. Benefit of this method is that toggling is instant. For easy acces you can put it in your bookmarks toolbar, this way toggling is only one click away.

Just add a new bookmark and give the following as if it is the url: javascript: (() => { var element = document.getElementById("spellcheck"); element.style.display = element.style.display === 'none' ? '' : 'none'; })();

robindijkhof commented 2 years ago

I finally had the time to check this out. However, I'm not seeing the icon when building/running local. Am I missing anything?

robindijkhof commented 2 years ago

Also, I think buttons are never cleaned up. For example, when switching tex files, a new button is added.

Caian commented 2 years ago

Also, I think buttons are never cleaned up. For example, when switching tex files, a new button is added.

Buttons are not cleaned up otherwise trying to toggle the text area off would make the button disappear. Nonetheless the button element is named and it is created only if it does not exist. Unfortunately I could not reproduce this scenario, here I can only see one button even switching .tex files.

modaresimr commented 2 years ago

very excellent pull request. I hope to have it soon.