Future-Scholars / paperlib

An open-source academic paper management tool.
https://paperlib.app
GNU General Public License v3.0
1.52k stars 67 forks source link

Feat: Add custom CSS support #571

Closed charlieJ107 closed 1 month ago

charlieJ107 commented 3 months ago

Fix #273

This PR provides a field for custom CSS styles in the preference settings page and sets the provided CSS value when every window renders.

GeoffreyChen777 commented 3 months ago

@charlieJ107 Hi, is this ready for review?

charlieJ107 commented 3 months ago

@charlieJ107 Hi, is this ready for review?

Not yet. I'm working on the preference page UI, but some things from somewhere else are delaying things. Thanks for being patient, and I'll notify you here as soon as it's ready for review.

charlieJ107 commented 2 months ago

@GeoffreyChen777 Hi, since currently the CSS syntax is optional and could be a complex feature that is not a responsibility of paper management tool, I think this PR is ready for review at the moment.

I do intend to add a warning on the UI indicate that adding custom CSS could be dangerous and may crash the programme and only users familiar with related technology should touch this feature.

GeoffreyChen777 commented 2 months ago

CSS would not crash the app, I think it's unnecessary to validate CSS syntax.

GeoffreyChen777 commented 2 months ago

My suggestion is that:

  1. add two methods in the windowManagementService:
    • insertCustomCSS(windowId: string, css: string): we just enforce that one window only has one custom css. So first delete the old custom css with the corresponding key. Then insert the new css. and store the key as a private member.
    • removeCustomCSS(windowId): delete the custom css with the given window id.
  2. In the UI, when the textarea changes, call PLMainAPI.windowManagementService.insertCustomCSS to insert (overwrite) css.
  3. Update preference when we insert the custom css. Store a windowId-css pair in the preference.

That would be a much easier solution.