diff --git a/README.md b/README.md index a473f63..00db0aa 100644 --- a/README.md +++ b/README.md @@ -377,6 +377,7 @@ const myHeader: IHeaderOverride = (state, previousDocument, nextDocument) => { | --------- | -------- | | uri | `string` | | fileType? | `string` | +| fileName? | `string` | | fileData? | `string | ArrayBuffer` - **Used Internally - Ignored if passed into props** | --- diff --git a/src/components/FileName.tsx b/src/components/FileName.tsx index d64353b..4df4c46 100644 --- a/src/components/FileName.tsx +++ b/src/components/FileName.tsx @@ -10,16 +10,22 @@ export const FileName: FC<{}> = () => { if (!currentDocument || config?.header?.disableFileName) return null; - let fileName = currentDocument.uri || ""; - fileName = decodeURI(fileName); + let fileName = ""; - if (!config?.header?.retainURLParams) { - fileName = fileName.split("?")[0]; - } + if (currentDocument.fileName) { + fileName = currentDocument.fileName; + } else { + fileName = currentDocument.uri || ""; + fileName = decodeURI(fileName); + + if (!config?.header?.retainURLParams) { + fileName = fileName.split("?")[0]; + } - const splitURL = fileName.split("/"); - if (splitURL.length) { - fileName = splitURL[splitURL.length - 1]; + const splitURL = fileName.split("/"); + if (splitURL.length) { + fileName = splitURL[splitURL.length - 1]; + } } return ( diff --git a/src/plugins/pdf/components/PDFControls.tsx b/src/plugins/pdf/components/PDFControls.tsx index a9a5e0a..ddd7f56 100644 --- a/src/plugins/pdf/components/PDFControls.tsx +++ b/src/plugins/pdf/components/PDFControls.tsx @@ -30,7 +30,7 @@ const PDFControls: FC<{}> = () => { diff --git a/src/types/index.ts b/src/types/index.ts index eb50b4a..adc561b 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -37,6 +37,7 @@ export interface IDocument { uri: string; fileType?: string; fileData?: string | ArrayBuffer; + fileName?: string; } export interface DocRendererProps {