Skip to content

TagSpaces is an offline, open source, document manager with tagging support

feat: add open link dialog

Ilian Sapundshiev5860763337f8
diff --git a/app/components/LocationManager.tsx b/app/components/LocationManager.tsx
index d78ee1930..91fd65f6b 100644
--- a/app/components/LocationManager.tsx
+++ b/app/components/LocationManager.tsx
@@ -111,6 +111,7 @@ interface Props {
openLocation: (location: Location) => void;
openFileNatively: (path: string) => void;
openDirectory: (path: string) => void;
+ toggleOpenLinkDialog: () => void;
showInFileManager: (path: string) => void;
createDirectoryIndex: (
path: string,
@@ -640,6 +641,8 @@ class LocationManager extends React.Component<Props, State> {
open={this.state.locationManagerMenuOpened}
onClose={this.handleCloseLocationManagerMenu}
openURLExternally={this.props.openURLExternally}
+ showCreateLocationDialog={this.showCreateLocationDialog}
+ toggleOpenLinkDialog={this.props.toggleOpenLinkDialog}
/>
{!AppConfig.locationsReadOnly && (
<div style={{ width: '100%', textAlign: 'center', marginBottom: 10 }}>
@@ -837,6 +840,7 @@ function mapDispatchToProps(dispatch) {
openFsEntry: AppActions.openFsEntry,
showNotification: AppActions.showNotification,
reflectCreateEntries: AppActions.reflectCreateEntries,
+ toggleOpenLinkDialog: AppActions.toggleOpenLinkDialog,
moveFiles: IOActions.moveFiles,
uploadFiles: IOActions.uploadFiles,
openURLExternally: AppActions.openURLExternally,
diff --git a/app/components/dialogs/OpenLinkDialog.tsx b/app/components/dialogs/OpenLinkDialog.tsx
new file mode 100644
index 000000000..b5b7927b7
--- /dev/null
+++ b/app/components/dialogs/OpenLinkDialog.tsx
@@ -0,0 +1,148 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React, { useState, useEffect } from 'react';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import Button from '@material-ui/core/Button';
+import TextField from '@material-ui/core/TextField';
+import DialogActions from '@material-ui/core/DialogActions';
+import DialogContent from '@material-ui/core/DialogContent';
+import DialogTitle from '@material-ui/core/DialogTitle';
+import FormControl from '@material-ui/core/FormControl';
+import Dialog from '@material-ui/core/Dialog';
+import i18n from '-/services/i18n';
+import { actions as AppActions } from '-/reducers/app';
+
+interface Props {
+ open: boolean;
+ onClose: () => void;
+ fullScreen?: boolean;
+ openLink: (linkURL: string) => void;
+}
+
+const OpenLinkDialog = (props: Props) => {
+ const [inputError, setInputError] = useState(false);
+ const [disableConfirmButton, setDisableConfirmButton] = useState(true);
+ const [linkURL, setLinkURL] = useState('');
+ const { open, onClose, fullScreen } = props;
+
+ useEffect(() => {
+ handleValidation();
+ });
+
+ function handleValidation() {
+ let validURL = true;
+ try {
+ // eslint-disable-next-line no-new
+ new URL(linkURL);
+ } catch (e) {
+ validURL = false;
+ }
+ if (validURL) {
+ setInputError(false);
+ setDisableConfirmButton(false);
+ } else {
+ setInputError(true);
+ setDisableConfirmButton(true);
+ }
+ }
+
+ function onConfirm() {
+ if (!disableConfirmButton && linkURL) {
+ props.openLink(linkURL);
+ resetState();
+ props.onClose();
+ }
+ }
+
+ function onCancel() {
+ resetState();
+ props.onClose();
+ }
+
+ function resetState() {
+ setLinkURL('');
+ setInputError(false);
+ setDisableConfirmButton(true);
+ }
+
+ return (
+ <Dialog
+ open={open}
+ onClose={onClose}
+ fullScreen={fullScreen}
+ onKeyDown={event => {
+ if (event.key === 'Enter' || event.keyCode === 13) {
+ event.preventDefault();
+ event.stopPropagation();
+ onConfirm();
+ } else if (event.key === 'Escape') {
+ onClose();
+ }
+ }}
+ >
+ <DialogTitle>{i18n.t('core:openLink')}</DialogTitle>
+ <DialogContent style={{ minWidth: 400 }}>
+ <FormControl fullWidth={true} error={inputError}>
+ <TextField
+ fullWidth
+ margin="dense"
+ autoFocus
+ name="name"
+ label={i18n.t('core:link')}
+ onChange={event => {
+ const { target } = event;
+ setLinkURL(target.value);
+ }}
+ value={linkURL}
+ data-tid="directoryName"
+ />
+ </FormControl>
+ </DialogContent>
+ <DialogActions>
+ <Button
+ data-tid="closeOpenLinkDialog"
+ onClick={onCancel}
+ color="primary"
+ >
+ {i18n.t('core:cancel')}
+ </Button>
+ <Button
+ disabled={disableConfirmButton}
+ onClick={onConfirm}
+ data-tid="confirmOpenLink"
+ color="primary"
+ >
+ {i18n.t('core:open')}
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+};
+
+function mapActionCreatorsToProps(dispatch) {
+ return bindActionCreators(
+ {
+ openLink: AppActions.openLink
+ },
+ dispatch
+ );
+}
+
+export default connect(undefined, mapActionCreatorsToProps)(OpenLinkDialog);
diff --git a/app/components/menus/LocationManagerMenu.tsx b/app/components/menus/LocationManagerMenu.tsx
index 51607c604..9193ef021 100644
--- a/app/components/menus/LocationManagerMenu.tsx
+++ b/app/components/menus/LocationManagerMenu.tsx
@@ -21,6 +21,8 @@ import ListItemText from '@material-ui/core/ListItemText';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
+import CreateLocationIcon from '@material-ui/icons/CreateNewFolder';
+import OpenLinkIcon from '@material-ui/icons/Link';
import HelpIcon from '@material-ui/icons/Help';
import i18n from '-/services/i18n';
import AppConfig from '-/config';
@@ -30,14 +32,42 @@ interface Props {
open: boolean;
anchorEl: Element;
onClose: () => void;
+ showCreateLocationDialog: () => void;
+ toggleOpenLinkDialog: () => void;
openURLExternally: (url: string, skipConfirmation?: boolean) => void;
}
const LocationManagerMenu = (props: Props) => (
<div style={{ overflowY: 'hidden' }}>
<Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
+ {!AppConfig.locationsReadOnly && (
+ <MenuItem
+ data-tid="locationManagerMenuCreateLocation"
+ onClick={() => {
+ props.onClose();
+ props.showCreateLocationDialog();
+ }}
+ >
+ <ListItemIcon>
+ <CreateLocationIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:createLocationTitle')} />
+ </MenuItem>
+ )}
<MenuItem
- data-tid="locationManagerHelp"
+ data-tid="locationManagerMenuOpenLink"
+ onClick={() => {
+ props.onClose();
+ props.toggleOpenLinkDialog();
+ }}
+ >
+ <ListItemIcon>
+ <OpenLinkIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:openLink')} />
+ </MenuItem>
+ <MenuItem
+ data-tid="locationManagerMenuHelp"
onClick={() => {
props.onClose();
props.openURLExternally(AppConfig.documentationLinks.locations, true);
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index 8672936e8..f657bf606 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -68,6 +68,7 @@ import {
isUploadDialogOpened,
isCreateFileDialogOpened,
isSettingsDialogOpened,
+ isOpenLinkDialogOpened,
isReadOnlyMode,
isProgressOpened,
getOpenedFiles,
@@ -161,6 +162,7 @@ interface Props {
isProgressDialogOpened: boolean;
toggleSelectDirectoryDialog: () => void;
toggleUploadDialog: () => void;
+ toggleOpenLinkDialog: () => void;
toggleProgressDialog: () => void;
resetProgress: () => void;
isEditTagDialogOpened: boolean;
@@ -202,6 +204,7 @@ interface Props {
setLeftVerticalSplitSize: (splitSize: number) => void;
setMainVerticalSplitSize: (splitSize: string) => void;
isLocationManagerPanelOpened: boolean;
+ isOpenLinkDialogOpened: boolean;
isTagLibraryPanelOpened: boolean;
isSearchPanelOpened: boolean;
isPerspectivesPanelOpened: boolean;
@@ -287,6 +290,17 @@ const EditEntryTagDialogAsync = props => (
</React.Suspense>
);
+const OpenLinkDialog = React.lazy(() =>
+ import(
+ /* webpackChunkName: "OpenLinkDialog" */ '../components/dialogs/OpenLinkDialog'
+ )
+);
+const OpenLinkDialogAsync = props => (
+ <React.Suspense fallback={<LoadingLazy />}>
+ <OpenLinkDialog {...props} />
+ </React.Suspense>
+);
+
const SelectDirectoryDialog = React.lazy(() =>
import(
/* webpackChunkName: "LicenseDialog" */ '../components/dialogs/SelectDirectoryDialog'
@@ -569,6 +583,7 @@ class MainPage extends Component<Props, State> {
isCreateDirectoryOpened,
isEditTagDialogOpened,
isUploadProgressDialogOpened,
+ isOpenLinkDialogOpened,
isProgressDialogOpened,
toggleOnboardingDialog,
toggleSettingsDialog,
@@ -582,6 +597,7 @@ class MainPage extends Component<Props, State> {
toggleUploadDialog,
toggleProgressDialog,
toggleEditTagDialog,
+ toggleOpenLinkDialog,
setFirstRun,
openURLExternally,
directoryPath
@@ -635,6 +651,12 @@ class MainPage extends Component<Props, State> {
onClose={toggleEditTagDialog}
/>
)}
+ {isOpenLinkDialogOpened && (
+ <OpenLinkDialogAsync
+ open={isOpenLinkDialogOpened}
+ onClose={toggleOpenLinkDialog}
+ />
+ )}
{isSelectDirectoryDialogOpened && (
<SelectDirectoryAsync
open={isSelectDirectoryDialogOpened}
@@ -897,6 +919,7 @@ function mapStateToProps(state) {
isLicenseDialogOpened: isLicenseDialogOpened(state),
isThirdPartyLibsDialogOpened: isThirdPartyLibsDialogOpened(state),
isUploadProgressDialogOpened: isUploadDialogOpened(state),
+ isOpenLinkDialogOpened: isOpenLinkDialogOpened(state),
isProgressDialogOpened: isProgressOpened(state),
isIndexing: isIndexing(state),
isReadOnlyMode: isReadOnlyMode(state),
@@ -945,6 +968,7 @@ function mapDispatchToProps(dispatch) {
toggleThirdPartyLibsDialog: AppActions.toggleThirdPartyLibsDialog,
toggleAboutDialog: AppActions.toggleAboutDialog,
toggleOnboardingDialog: AppActions.toggleOnboardingDialog,
+ toggleOpenLinkDialog: AppActions.toggleOpenLinkDialog,
setLastSelectedEntry: AppActions.setLastSelectedEntry,
setSelectedEntries: AppActions.setSelectedEntries,
setGeneratingThumbnails: AppActions.setGeneratingThumbnails,
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 355ab81e8..c04a784d7 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -489,5 +489,8 @@
"goforward": "Go Forward",
"switchSimpleMode": "Simpe Mode",
"switchAdvancedMode": "Advanced Mode",
+ "openLink": "Open Link",
+ "invalidLink": "Invalid Link",
+ "link": "Link",
"-": "-"
}
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 5f34a8a03..559dff210 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -94,6 +94,7 @@ export const types = {
TOGGLE_ONBOARDING_DIALOG: 'APP/TOGGLE_ONBOARDING_DIALOG',
TOGGLE_KEYBOARD_DIALOG: 'APP/TOGGLE_KEYBOARD_DIALOG',
TOGGLE_LICENSE_DIALOG: 'APP/TOGGLE_LICENSE_DIALOG',
+ TOGGLE_OPENLINK_DIALOG: 'APP/TOGGLE_OPENLINK_DIALOG',
TOGGLE_THIRD_PARTY_LIBS_DIALOG: 'APP/TOGGLE_THIRD_PARTY_LIBS_DIALOG',
TOGGLE_SETTINGS_DIALOG: 'APP/TOGGLE_SETTINGS_DIALOG',
TOGGLE_CREATE_DIRECTORY_DIALOG: 'APP/TOGGLE_CREATE_DIRECTORY_DIALOG',
@@ -198,6 +199,7 @@ export const initialState = {
openedFiles: [],
editTagDialogOpened: false,
aboutDialogOpened: false,
+ openLinkDialogOpened: false,
onboardingDialogOpened: false,
keysDialogOpened: false,
createFileDialogOpened: false,
@@ -315,6 +317,12 @@ export default (state: any = initialState, action: any) => {
onboardingDialogOpened: !state.onboardingDialogOpened
};
}
+ case types.TOGGLE_OPENLINK_DIALOG: {
+ return {
+ ...state,
+ openLinkDialogOpened: !state.openLinkDialogOpened
+ };
+ }
case types.TOGGLE_KEYBOARD_DIALOG: {
return { ...state, keysDialogOpened: !state.keysDialogOpened };
}
@@ -765,6 +773,7 @@ export const actions = {
toggleAboutDialog: () => ({ type: types.TOGGLE_ABOUT_DIALOG }),
toggleOnboardingDialog: () => ({ type: types.TOGGLE_ONBOARDING_DIALOG }),
toggleKeysDialog: () => ({ type: types.TOGGLE_KEYBOARD_DIALOG }),
+ toggleOpenLinkDialog: () => ({ type: types.TOGGLE_OPENLINK_DIALOG }),
toggleLicenseDialog: () => ({ type: types.TOGGLE_LICENSE_DIALOG }),
toggleThirdPartyLibsDialog: () => ({
type: types.TOGGLE_THIRD_PARTY_LIBS_DIALOG
@@ -1740,8 +1749,9 @@ export const actions = {
);
} else if (lid && lid.length > 0) {
const locationId = decodeURIComponent(lid);
- const directoryPath = decodeURIComponent(dPath);
- const entryPath = decodeURIComponent(ePath);
+ const directoryPath = dPath && decodeURIComponent(dPath);
+ const entryPath = ePath && decodeURIComponent(ePath);
+ // Check for relative paths
const targetLocation: Location = getLocation(getState(), locationId);
if (targetLocation) {
let openLocationTimer = 1000;
@@ -1754,7 +1764,7 @@ export const actions = {
}
setTimeout(() => {
if (isCloudLocation) {
- if (directoryPath) {
+ if (directoryPath && directoryPath.length > 0) {
const dirFullPath = directoryPath;
dispatch(actions.loadDirectoryContent(dirFullPath));
}
@@ -1778,17 +1788,46 @@ export const actions = {
);
}
} else {
+ // local files case
let locationPath = '';
- if (targetLocation && targetLocation.path) {
- locationPath = targetLocation.path;
+ if (
+ targetLocation &&
+ (targetLocation.path || targetLocation.paths)
+ ) {
+ locationPath = targetLocation.path || targetLocation.paths[0];
}
- if (directoryPath) {
- const dirFullPath = locationPath + '/' + directoryPath;
+ if (directoryPath && directoryPath.length > 0) {
+ if (
+ directoryPath.includes('../') ||
+ directoryPath.includes('..\\')
+ ) {
+ dispatch(
+ actions.showNotification(
+ i18n.t('core:invalidLink'),
+ 'warning',
+ true
+ )
+ );
+ return true;
+ }
+ const dirFullPath =
+ locationPath + PlatformIO.getDirSeparator() + directoryPath;
dispatch(actions.loadDirectoryContent(dirFullPath));
}
- if (entryPath) {
- const entryFullPath = locationPath + '/' + entryPath; // TODO dir sep
+ if (entryPath && entryPath.length > 0) {
+ if (entryPath.includes('../') || entryPath.includes('..\\')) {
+ dispatch(
+ actions.showNotification(
+ i18n.t('core:invalidLink'),
+ 'warning',
+ true
+ )
+ );
+ return true;
+ }
+ const entryFullPath =
+ locationPath + PlatformIO.getDirSeparator() + entryPath;
getAllPropertiesPromise(entryFullPath)
.then((fsEntry: FileSystemEntry) => {
if (fsEntry) {
@@ -1799,7 +1838,7 @@ export const actions = {
.catch(() =>
dispatch(
actions.showNotification(
- i18n.t('core:Invalid link'),
+ i18n.t('core:invalidLink'),
'warning',
true
)
@@ -1810,14 +1849,14 @@ export const actions = {
}, openLocationTimer);
} else {
dispatch(
- actions.showNotification(i18n.t('core:Invalid link'), 'warning', true)
+ actions.showNotification(i18n.t('core:invalidLink'), 'warning', true)
);
}
} else if (
// External URL case
decodedURI.startsWith('http://') ||
- decodedURI.startsWith('https://') ||
- decodedURI.startsWith('file://')
+ decodedURI.startsWith('https://')
+ // decodedURI.startsWith('file://')
) {
dispatch(actions.openURLExternally(decodedURI));
} else {
@@ -1905,6 +1944,8 @@ export const isSelectDirectoryDialogOpened = (state: any) =>
state.app.selectDirectoryDialogOpened;
export const isUploadDialogOpened = (state: any) =>
state.app.uploadDialogOpened;
+export const isOpenLinkDialogOpened = (state: any) =>
+ state.app.openLinkDialogOpened;
export const isProgressOpened = (state: any) => state.app.progressDialogOpened;
export const getOpenedFiles = (state: any) => state.app.openedFiles;
export const getNotificationStatus = (state: any) =>
diff --git a/app/services/electron-menus.ts b/app/services/electron-menus.ts
index 2f4a69e8a..00bd9bdcf 100644
--- a/app/services/electron-menus.ts
+++ b/app/services/electron-menus.ts
@@ -80,42 +80,24 @@ export default function buildDesktopMenu(mainPageProps: any) {
{
label: i18n.t('core:newFileNote'),
// accelerator: 'CommandOrControl+Alt+N',
- click: () => {
- mainPageProps.toggleCreateFileDialog();
- }
- },
- /* {
- label: i18n.t('core:createMarkdown'),
- accelerator: '',
- // click: createMDFile
+ click: mainPageProps.toggleCreateFileDialog
},
{
- label: i18n.t('core:createRichTextFile'),
+ label: i18n.t('core:createDirectory'),
accelerator: '',
- // click: createHTMLFile
+ click: mainPageProps.showCreateDirectoryDialog
},
- */
{
type: 'separator'
},
{
- label: i18n.t('core:createDirectory'),
- accelerator: '',
- click: () => {
- mainPageProps.showCreateDirectoryDialog();
- }
+ label: i18n.t('core:openLink'),
+ accelerator: 'Ctrl+o',
+ click: mainPageProps.toggleOpenLinkDialog
},
{
type: 'separator'
},
- // {
- // label: i18n.t('core:openTagSpacesID'),
- // accelerator: 'Ctrl+o',
- // click: () => {
- // // const url = ;
- // // console.log('URL: ' + url);
- // }
- // },
/* {
label: i18n.t('core:saveFile'),
accelerator: mainPageProps.keyBindings.saveDocument,
@@ -177,23 +159,17 @@ export default function buildDesktopMenu(mainPageProps: any) {
{
label: i18n.t('core:showLocationManager'),
accelerator: mainPageProps.keyBindings.showLocationManager,
- click: () => {
- mainPageProps.openLocationManagerPanel();
- }
+ click: mainPageProps.openLocationManagerPanel
},
{
label: i18n.t('core:showTagLibrary'),
accelerator: mainPageProps.keyBindings.showTagLibrary,
- click: () => {
- mainPageProps.openTagLibraryPanel();
- }
+ click: mainPageProps.openTagLibraryPanel
},
{
label: i18n.t('core:showSearch'),
accelerator: mainPageProps.keyBindings.showSearch,
- click: () => {
- mainPageProps.openSearchPanel();
- }
+ click: mainPageProps.openSearchPanel
},
{
label: i18n.t('core:showDevTools'),
@@ -235,23 +211,17 @@ export default function buildDesktopMenu(mainPageProps: any) {
{
label: i18n.t('core:zoomReset'),
accelerator: 'CmdOrCtrl+0',
- click: () => {
- mainPageProps.setZoomResetApp();
- }
+ click: mainPageProps.setZoomResetApp
},
{
label: i18n.t('core:zoomIn'),
accelerator: 'CmdOrCtrl+Plus',
- click: () => {
- mainPageProps.setZoomInApp();
- }
+ click: mainPageProps.setZoomInApp
},
{
label: i18n.t('core:zoomOut'),
accelerator: 'CmdOrCtrl+-',
- click: () => {
- mainPageProps.setZoomOutApp();
- }
+ click: mainPageProps.setZoomOutApp
},
{
label: i18n.t('core:toggleFullScreen'),
@@ -270,9 +240,7 @@ export default function buildDesktopMenu(mainPageProps: any) {
},
{
label: i18n.t('core:settings'),
- click: () => {
- mainPageProps.toggleSettingsDialog();
- }
+ click: mainPageProps.toggleSettingsDialog
}
]
},
@@ -282,22 +250,15 @@ export default function buildDesktopMenu(mainPageProps: any) {
{
label: '&' + i18n.t('core:documentation'),
accelerator: mainPageProps.keyBindings.showHelp,
- click: () => {
- // mainPageProps.openURLExternally(AppConfig.documentationLinks.general);
- mainPageProps.openHelpFeedbackPanel();
- }
+ click: mainPageProps.openHelpFeedbackPanel
},
{
label: '&' + i18n.t('core:shortcutKeys'),
- click: () => {
- mainPageProps.toggleKeysDialog();
- }
+ click: mainPageProps.toggleKeysDialog
},
{
label: 'Welcome Wizzard',
- click: () => {
- mainPageProps.toggleOnboardingDialog();
- }
+ click: mainPageProps.toggleOnboardingDialog
},
{
label: '&' + i18n.t('core:whatsNew'),
@@ -361,21 +322,15 @@ export default function buildDesktopMenu(mainPageProps: any) {
},
{
label: '&' + i18n.t('core:license'),
- click: () => {
- mainPageProps.toggleLicenseDialog();
- }
+ click: mainPageProps.toggleLicenseDialog
},
{
label: '&' + i18n.t('core:thirdPartyLibs'),
- click: () => {
- mainPageProps.toggleThirdPartyLibsDialog();
- }
+ click: mainPageProps.toggleThirdPartyLibsDialog
},
{
label: '&' + i18n.t('core:aboutTagSpaces'),
- click: () => {
- mainPageProps.toggleAboutDialog();
- }
+ click: mainPageProps.toggleAboutDialog
}
]
}
diff --git a/app/utils/misc.ts b/app/utils/misc.ts
index 949d763ab..98a4062ca 100644
--- a/app/utils/misc.ts
+++ b/app/utils/misc.ts
@@ -76,15 +76,6 @@ export function immutablySwapItems(
return results;
}
-export function hasURLProtocol(url: string) {
- return (
- url.startsWith('http://') ||
- url.startsWith('https://') ||
- url.startsWith('file://') ||
- url.startsWith('data:')
- );
-}
-
export function arrayBufferToDataURL(arrayBuffer: any, mime: string) {
const blob = new Blob([arrayBuffer], { type: mime });
const url = window.URL || window.webkitURL;