Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support manual redaction #2433

Open
wants to merge 58 commits into
base: main
Choose a base branch
from

Conversation

omar-ahmed42
Copy link
Contributor

Description

Manual Redaction:

  • Text Selection-based redaction:

    • image
    • Users can now redact currently selected text by selecting the text then clicking ctrl + s shortcut or by pressing on apply/save/disk icon in the toolbar.
    • Users can delete/cancel the redacted area by clicking on the box containing the text, then clicking on delete/trash icon or by using the shortcut delete.
    • Users can customize the color of the redacted area/text (after the redaction was applied) by simply clicking on the box containing the text/area then clicking on the color palette icon and choosing the color they want.
    • Users can choose to select the color of redaction before redacting text or applying changes (this only affects newly created redaction areas, to change the color of an existing one; check the previous bullet point).
  • Draw/Area-based redaction:

    • image
    • Users can now redact an area in the page by selecting the then clicking ctrl + s shortcut or by pressing on apply/save/disk icon in the toolbar.
    • Users can delete/cancel the redacted area by clicking on the drawn box, then clicking on delete/trash icon or by using the shortcut delete (requires temporarily turning off drawing mode).
    • Users can customize the color of the redacted area (after the redaction was applied) by simply clicking on the box containing the area then clicking on the color palette icon and choosing the color they want.
    • Users can choose to select the color of redaction before drawing the box or applying changes (this only affects newly created redaction areas, to change the color of an existing one; check the previous bullet point).
  • Page-based redaction:

    • image
    • Users can now redact ENTIRE pages by specifying the page number(s), range(s) or functions.
    • Users can customize the color of page-based redaction (doesn't affect text-based nor draw-based redactions).

Redaction modes:

There are three modes of redaction/operation currently supported

  • Text Selection-based redaction (TEXT)
  • Draw/Area-based redaction (DRAWING)
  • None - by simply not choosing any of the above modes (NONE).

How to use:

  • Text Selection-based redaction: click on this icon in the toolbar image to enable text-selection redaction mode then select the text you want to redact then press ctrl + s or click on the disk/save icon image.

  • Draw/Area-based redaction: click on this icon in the toolbar image to enable draw/area-based redaction then left mouse click (LMB) on the starting point of the rectangle, then once you are satisfied with the rectangle's placement/dimensions then left mouse click (LMB) again to apply the redaction.

    • Example: Left mouse click (LMB) then move mouse to the right then bottom then Left mouse click (LMB).
    • Note: Red box/rectangle borders indicate that you have not yet saved (you need to left click on the page to save) image once saved the borders will become green image (they also become clickable/hover-able when drawing mode is off).
  • Page-based redactions:: Insert the page number(s), range(s) and/or functions (separated by ,) then select your preferred color and click on Redact to submit.
    image

  • Color Customizations:

    • You can change the redaction color for new redactions by clicking on this icon in the toolbar image.
    • You can change the redaction color for existing redactions by hovering over the redaction box then clicking on it (Left mouse click LMB) then clicking on color palette (highlighted in red in the picture) image then select your preferred color.
  • Deletions:

    • You can delete a redacted area by hovering over the redaction box then clicking on it (Left mouse click LMB) then clicking on the trash icon (highlighted in red in the picture) image.

Card in the home page:

image

Closes #465

Checklist

  • I have read the Contribution Guidelines
  • I have performed a self-review of my own code
  • I have attached images of the change if it is UI based
  • I have commented my code, particularly in hard-to-understand areas
  • If my code has heavily changed functionality I have updated relevant docs on Stirling-PDFs doc repo
  • My changes generate no new warnings
  • I have read the section Add New Translation Tags (for new translation tags only)

- Add redact.html which contains the nav-bar, file chooser, outer container and print container (used by PDF.JS viewer) and lastly the footer.
- Add redact.css which is used specifically to style redaction operation and the redaction page (except for PDF.js viewer).
- Add viewer-redact.css which is used to style PDF.js viewer that's used in the page (Changed the background to correspond with Stirling's themes).
- Add redact.js which contains the redaction related logic.
- Add submit button.
- Add hidden redactions input.
- Rename fileSelector from pdf-upload to fileInput.
- Scale x, y, width and height to match PDF page points accurately.
- Fix formula for redaction points and dimensions as x, y, height and width should be the original width rather than the width after adjusting it to the zoom level (zoom level is mainly used for correct display positioning, while scale factor is used for correct positioning in the actual PDF).
- Slightly refactor redact.js for more readability and to reduce code duplication.
…ion-based Redaction mode buttons

- Now, when one button is clicked, the other is automatically deselected, ensuring only one mode can be active at a time.
- Support page-based redactions by providing page numbers, page ranges and functions.
- Rename pageNumbers's input id to be more meaningful
@reecebrowne
Copy link
Contributor

A further potential improvement would be to have the "apply redaction" button (currently save Icon) appear next to selected text in the page, similar to the delete/colour selection toolbar you have implemented already, this saves the user scrolling up to the top of the page to apply redactions and also makes functionality a little more clear.

Additionally there is a minor bug with the delete/colour select toolbar. Currently it is quite easy for a redaction box/text selection to appear over the toolbar for nearby redactions making the buttons impossible to click

Great progress so far. It's looking good!

@omar-ahmed42
Copy link
Contributor Author

we already know the context that this is the redaction page so the icons don't need to be redaction specific but rather tell the use what kind of redaction it is.

Makes perfect sense

just remove the custom overlay of the eraser you have added.

Sure

As for the area based selection I think this is the slightly better choice of icon https://fonts.google.com/icons?selected=Material+Symbols+Outlined:pageless:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=area&icon.size=24&icon.color=%23e8eaed as it still conveys the box idea but is a bit more obviously an icon than just a square. As with the other icon I don't think the custom eraser version is necessary.

I agree, this seems much clearer

I think perhaps this is abetter icon https://fonts.google.com/icons?selected=Material+Symbols+Outlined:approval:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=apply&icon.size=24&icon.color=%23e8eaed or perhaps just a simple check https://fonts.google.com/icons?selected=Material+Symbols+Outlined:check:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=tick&icon.size=24&icon.color=%23e8eaed

I feel like the first icon you mentioned fits our use case perfectly, but I might go with the second one as it would be more intuitive to almost all the users

I think this is better placed directly next to the text selection icon and only shown when text select mode is active to make it clear it is related only to that feature and serves no purpose on box redaction

To make sure I understand, let's visualize them as follows:

  1. [text-selection-icon][check-icon_hidden][area-selection-icon]
  2. On enabling text-selection mode:
    • [text-selection-icon][check-icon-visible][area-selection-icon]
      Is that is or did I miss something?

Could you move the "redact" button that downloads the completed file to your toolbar and use this icon for it instead of the word "redact" please? https://fonts.google.com/icons?selected=Material+Symbols+Outlined:download:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=download&icon.size=24&icon.color=%23e8eaed

Sure thing!

@omar-ahmed42
Copy link
Contributor Author

A further potential improvement would be to have the "apply redaction" button (currently save Icon) appear next to selected text in the page

This is actually a fantastic improvement! I might take a look at it but I think this might take some time but that's okay

Additionally there is a minor bug with the delete/colour select toolbar. Currently it is quite easy for a redaction box/text selection to appear over the toolbar for nearby redactions making the buttons impossible to click

Great observation! I will take a look it

@reecebrowne
Copy link
Contributor

I feel like the first icon you mentioned fits our use case perfectly, but I might go with the second one as it would be more intuitive to almost all the users
Yes I think the check is probably the better choice, lets go with that

I think this is better placed directly next to the text selection icon and only shown when text select mode is active to make it clear it is related only to that feature and serves no purpose on box redaction

To make sure I understand, let's visualize them as follows:

  1. [text-selection-icon][check-icon_hidden][area-selection-icon]

  2. On enabling text-selection mode:

    • [text-selection-icon][check-icon-visible][area-selection-icon]
      Is that is or did I miss something?

Yes I think that will just help to make it really obvious that button is related to the text selection feature and only activates when in that mode. I think maybe consider trying green for that button to make it clearer it's a "confirm" action. Feel free to go with your gut on what feels clear and looks good on that though as it may look off in practice.

@reecebrowne
Copy link
Contributor

A further potential improvement would be to have the "apply redaction" button (currently save Icon) appear next to selected text in the page

This is actually a fantastic improvement! I might take a look at it but I think this might take some time but that's okay

Yeah I don't think it's necessary to the feature, just a nice UI upgrade, so perhaps that could be a suggestion for additional improvements in a new branch after release if you feel it may be a bigger job.

- Add download button that calls a hidden submitBtn.
- Add a loading spinner that gets triggered on downloadBtn click after 100 ms (100 ms is enough time for the submitBtn to be disabled), why this approach? this is a workaround, so that we would not modify downloader.js
- Fix a bug that caused redaction overlay to be behind other redaction boxes when there's overlapping between them.
@omar-ahmed42
Copy link
Contributor Author

omar-ahmed42 commented Dec 16, 2024

I added the download button as you instructed, and I also added a loading spinner for a better user experience as the processing on the server side might take some time for any reason (especially when the conversion option is checked), so a feedback for the user would be provided as the user might think that the page froze. (This spinner entirely revolves around whether the hidden submission button is disabled or not, there are other ways but they would require applying modifications to downloader.js, and I preferred to not modify downloader.js).

As for the "check" button, I added it and made it not displayed unless text selection mode is activated, but I didn't really add it next to the text selection box, why? I attempted to add it next to the text selection button but this would keep shifting the buttons each time it's pressed which I felt might not be pleasant to the user (there's the option of moving the text selection button to the end, but look wise, it looked better next to the drawing button as it is), so I moved the check button to the right of the color palette and made it green, this way it would be visible to the user and catch their attention even though it's 2 buttons away from the text-selection button.

This way the user knows that the text selection's position will never change, this way, it would be a familiar position/placement for the user making it easier in the long term for the user's muscle memory (as it remembers the exact position with minimum mental calculations), at the same time, if we ever needed to add any temporary buttons related to specific features, the user now would know where to find them. (Especially if we were to add undo/redo buttons)

It looks like this:
image

As for:

Additionally there is a minor bug with the delete/colour select toolbar. Currently it is quite easy for a redaction box/text selection to appear over the toolbar for nearby redactions making the buttons impossible to click

I successfully fixed

Yeah I don't think it's necessary to the feature, just a nice UI upgrade, so perhaps that could be a suggestion for additional improvements in a new branch after release if you feel it may be a bigger job.

I agree, it's really a nice UI upgrade, I might work on it in a new branch as I feel like this one might take some time.
Also, if you have any notes, ideas or questions, please, let me know!

I also wanted to say thanks for your notes! they were helpful!

@reecebrowne
Copy link
Contributor

/deploypr

Copy link
Contributor

🚀 PR Test Deployment

Your PR has been deployed for testing!

🔗 Test URL: http://185.252.234.121:2433

This deployment will be automatically cleaned up when the PR is closed.

@reecebrowne
Copy link
Contributor

reecebrowne commented Dec 16, 2024

Looking better and better. I think you made the right call on the confirm redaction button.

The main issue now is the double scrolling which is a bit confusing (main page scroll and view window scroll). I think perhaps we should ditch the drag and drop file uploader for this feature and integrate a file upload into the viewer instead, alongside any other features that are still in the window above the viewer. This way the viewer can take up the whole page below the Stirling PDF toolbar, I think that will be a cleaner layout for this feature

- Hide nav bar, footer and form on file selection.
- Add a properties button in the toolbar to give users the choice to change their page settings.
@Frooodle
Copy link
Member

/deploypr :)

Copy link
Contributor

🚀 PR Test Deployment

Your PR has been deployed for testing!

🔗 Test URL: http://185.252.234.121:2433

This deployment will be automatically cleaned up when the PR is closed.

@reecebrowne
Copy link
Contributor

Hi @omar-ahmed42
This is looking good. Am I correct in saying that the following is a tool for redacting entire pages?
image

I think there is some clarity lacking here either way.

Also, could we bring back the Stirling toolbar at the top, there's no way off this page right now.

@omar-ahmed42
Copy link
Contributor Author

omar-ahmed42 commented Dec 18, 2024

Hi @reecebrowne

This is looking good. Am I correct in saying that the following is a tool for redacting entire pages?

It is, I thought of calling it "Page-based Redaction" but this won't represent the checkbox "Convert PDF to PDF-Image ... etc", so I thought I would go with "Properties" to be more generic.

Also, could we bring back the Stirling toolbar at the top, there's no way off this page right now.

Bringing the nav bar back would bring the second scroll back 😅, we could instead make Stirling clickable and redirect the user to the home page, and upon clicking on it, a popup should come up "You will be redirected to the home page ["Cancel"] ["Proceed"]", why the popup? there's a possibility of mis-clicking on the Stirling icon by the user and if that happens the user will lose all the progress made so far, so we can say that's some kind of a protective measure, what do you think?

@reecebrowne
Copy link
Contributor

It is, I thought of calling it "Page-based Redaction" but this won't represent the checkbox "Convert PDF to PDF-Image ... etc", so I thought I would go with "Properties" to be more generic.

I think just make convert to image a seperate option on the main toolbar rather than in this submenu

Bringing the nav bar back would bring the second scroll back 😅, we could instead make Stirling clickable and redirect the user to the home page, and upon clicking on it, a popup should come up "You will be redirected to the home page ["Cancel"] ["Proceed"]", why the popup? there's a possibility of mis-clicking on the Stirling icon by the user and if that happens the user will lose all the progress made so far, so we can say that's some kind of a protective measure, what do you think?

It shouldn't bring back the scroll issue if handled right, you can turn off scroll on the page and you can set the height of the viewer dynamically to be 100% of parent - the height of the nav to prevent overflow.
Here's a mockup I put together with a couple of quick css edits in the browser. No second scroller needed. Can talk you through it if you need.
image

@omar-ahmed42
Copy link
Contributor Author

I think just make convert to image a seperate option on the main toolbar rather than in this submenu

I'm thinking more of a dropdown? this way the user would know what this option does (if it's just a button the user might not figure out what it does without a tutorial)

or we can have 2 buttons, 1 for page based redactions (the one above), and the other would be a generic button containing options and fields related to the file or the operations in general, why? We might need in the future to integrate extra features that might not have a specific category into the feature, example: output filename, in this case, the user will find the generic ones over there, what do you think?

Example:
image

  • The circle denotes the button for page-based redaction.
  • The square denotes the properties/settings button.

Let me know what you think

It shouldn't bring back the scroll issue if handled right, you can turn off scroll on the page and you can set the height of the viewer dynamically to be 100% of parent - the height of the nav to prevent overflow.
Here's a mockup I put together with a couple of quick css edits in the browser. No second scroller needed. Can talk you through it if you need.

I think I managed to accomplish that after reading your instructions, thanks for your help!

@reecebrowne
Copy link
Contributor

I'm thinking more of a dropdown? this way the user would know what this option does (if it's just a button the user might not figure out what it does without a tutorial)

Convert to image should be a simple enough concept to convey via a tooltip, we also have an existing icon for it so I wouldn't be too worried about this.

or we can have 2 buttons, 1 for page based redactions (the one above), and the other would be a generic button containing options and fields related to the file or the operations in general, why? We might need in the future to integrate extra features that might not have a specific category into the feature, example: output filename, in this case, the user will find the generic ones over there, what do you think?

Page based redactions should definitely be it's own thing, some kind of dropdown or submenu is necessary for functionality but it's not really something I think should be bundled into a settings/properties menu.
If you think there's some value in a settings menu for other reasons in additional features I'm not against the menu existing but I think you're bundling key features away in a slightly confusing place with the stuff that's already in. Stuff like output filename is a good example of something that would make sense in such a submenu, key redaction features should be directly in the toolbar

I think I managed to accomplish that after reading your instructions, thanks for your help!

Code looks good, thanks for sorting that.

@omar-ahmed42
Copy link
Contributor Author

I agree with you everything you mentioned.

Toolbar: You can see that I added a new button as instructed, when it's in green it indicates being "checked" when in red, it indicates being unchecked:

image

image

Page based redaction:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API-related issues or pull requests Back End Issues related to back-end development enhancement New feature or request Front End Issues or pull requests related to front-end development Java Pull requests that update Java code size:XXL This PR changes 1000+ lines, ignoring generated files. Translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] anonymize PDFs via UI redaction (Drawing black rectangle etc)
3 participants