-
Notifications
You must be signed in to change notification settings - Fork 355
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
Add SaveAsHandler for custom save as behavior #1000
base: 8.11
Are you sure you want to change the base?
Conversation
Hi @uwohlfeil, Thanks for making this PR! We will add this to our following sprint to review. Our next sprint starts next Monday. Once we have completed our review we will provide feedback. Thanks for taking the time to submit this, you will hear from us soon. |
I have added a few corrections in the area of the German translation: Incorrect translations
OptimizationThis translations are not wrong but we think they can be optimized.
IdeasThe toolbar names are a little bit confusing and very long.
|
We currently have the problem that the thumbnail multiselect checkbox input control is slightly shifted to the right. This makes it impossible to select the checkbox in the left part of the framed area. The problem seems to be the css rule "position: absolute". We suspect that our solution is not correct, but we hope that it shows the problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for you feedback and additions! Most of this looks good. For the checkbox issue, we are working on implementing a fix already so you can leave the css change out for now. The only other changes would be to use const
instead of var
in var handler = getSaveAsHandler();
src/components/Choice/Choice.scss
Outdated
@@ -10,6 +10,10 @@ | |||
align-items: center; | |||
} | |||
|
|||
.ui__choice__input input { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have investigated the issue causing the checkboxes to go off-centre. We'll be implementing a fix for this soon. This particular CSS selector might affect other inputs so it would be best to leave this out for now.
@@ -53,7 +54,12 @@ const FileAttachmentPanel = () => { | |||
{fileAttachments.embeddedFiles.map((file, idx) => renderAttachment( | |||
file.filename, | |||
() => { | |||
saveAs(file.blob, file.filename); | |||
if (getSaveAsHandler() !== null) { | |||
var handler = getSaveAsHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a const here instead of a var
@@ -67,7 +68,12 @@ const ReplyAttachmentList = ({ files, isEditing, fileDeleted }) => { | |||
e.stopPropagation(); | |||
|
|||
const fileData = file.url ? file.url : await decompressFileContent(file); | |||
saveAs(fileData, file.name); | |||
if (getSaveAsHandler() !== null) { | |||
var handler = getSaveAsHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a const here instead of a var
|
||
export default () => (fileMeta) => { | ||
const { fileData, fileName } = fileMeta; | ||
saveAs(fileData, fileName); | ||
if (getSaveAsHandler() !== null) { | ||
var handler = getSaveAsHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a const here instead of a var
src/helpers/downloadPdf.js
Outdated
@@ -238,7 +239,12 @@ export default async (dispatch, options = {}, documentViewerKey = 1) => { | |||
} else { | |||
file = new File([arr], downloadName, { type: downloadType }); | |||
} | |||
saveAs(file, downloadName); | |||
if (getSaveAsHandler() !== null) { | |||
var handler = getSaveAsHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a const here instead of a var
@@ -78,12 +79,22 @@ const extractPages = (pageNumbers, dispatch) => { | |||
title, | |||
confirmBtnText, | |||
onConfirm: () => extractPagesWithAnnotations(pageNumbers).then((file) => { | |||
saveAs(file, 'extractedDocument.pdf'); | |||
if (getSaveAsHandler() !== null) { | |||
var handler = getSaveAsHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a const here instead of a var
}), | ||
secondaryBtnText, | ||
onSecondary: () => { | ||
extractPagesWithAnnotations(pageNumbers).then((file) => { | ||
saveAs(file, 'extractedDocument.pdf'); | ||
if (getSaveAsHandler() !== null) { | ||
var handler = getSaveAsHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a const here instead of a var
@carlopdftron |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After further review, it would be better to use the same model that we use for other APIs to get/set the saveAsHandler with Redux.
Please refer to 101fb32 to see how we use customApplyRedactionsHandler to do something similar to this.
This way, there would be no need for the saveAs helper functions.
This pull request is a proposal for an extended functionality in the area of the 'save as' functionality.
Currently the
saveAs
function of thefile-saver library
is always triggered here. In some cases, it may be useful to implement this event individually in the context of customizing. E.g. in the context of a document management system, the result should not be saved locally but stored directly as a new file in the DMS. There can also be problems in the context of the IFrame attribute sandbox (IFrame in IFrame case).See also:
https://community.apryse.com/t/intercept-overwrite-download-function-in-webviewer/7245