@atlaskit/media-viewer 49.2.7 → 49.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/analytics/events/operational/download.js +59 -0
- package/dist/cjs/analytics/index.js +1 -1
- package/dist/cjs/analytics/ufoExperiences.js +1 -1
- package/dist/cjs/components/media-viewer.js +4 -2
- package/dist/cjs/download.js +60 -27
- package/dist/cjs/header.js +4 -2
- package/dist/cjs/item-viewer.js +32 -17
- package/dist/cjs/list.js +11 -3
- package/dist/cjs/media-viewer.js +4 -2
- package/dist/cjs/viewerOptions.js +5 -0
- package/dist/cjs/viewers/archiveSidebar/archive.js +52 -8
- package/dist/cjs/viewers/base-viewer.js +4 -2
- package/dist/cjs/viewers/customViewer/customViewer.js +55 -0
- package/dist/es2019/analytics/events/operational/download.js +55 -0
- package/dist/es2019/analytics/index.js +1 -1
- package/dist/es2019/analytics/ufoExperiences.js +1 -1
- package/dist/es2019/components/media-viewer.js +4 -2
- package/dist/es2019/download.js +53 -24
- package/dist/es2019/header.js +4 -2
- package/dist/es2019/item-viewer.js +30 -17
- package/dist/es2019/list.js +12 -4
- package/dist/es2019/media-viewer.js +4 -2
- package/dist/es2019/viewerOptions.js +1 -0
- package/dist/es2019/viewers/archiveSidebar/archive.js +27 -5
- package/dist/es2019/viewers/base-viewer.js +4 -2
- package/dist/es2019/viewers/customViewer/customViewer.js +37 -0
- package/dist/esm/analytics/events/operational/download.js +53 -0
- package/dist/esm/analytics/index.js +1 -1
- package/dist/esm/analytics/ufoExperiences.js +1 -1
- package/dist/esm/components/media-viewer.js +4 -2
- package/dist/esm/download.js +60 -25
- package/dist/esm/header.js +4 -2
- package/dist/esm/item-viewer.js +32 -17
- package/dist/esm/list.js +12 -4
- package/dist/esm/media-viewer.js +4 -2
- package/dist/esm/viewerOptions.js +1 -0
- package/dist/esm/viewers/archiveSidebar/archive.js +52 -8
- package/dist/esm/viewers/base-viewer.js +4 -2
- package/dist/esm/viewers/customViewer/customViewer.js +46 -0
- package/dist/types/analytics/events/index.d.ts +2 -1
- package/dist/types/analytics/events/operational/_mediaFile.d.ts +1 -1
- package/dist/types/analytics/events/operational/download.d.ts +9 -0
- package/dist/types/components/media-viewer.d.ts +1 -1
- package/dist/types/components/types.d.ts +2 -0
- package/dist/types/download.d.ts +7 -11
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/header.d.ts +3 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/item-viewer.d.ts +7 -2
- package/dist/types/list.d.ts +3 -1
- package/dist/types/media-viewer.d.ts +2 -0
- package/dist/types/viewerOptions.d.ts +21 -0
- package/dist/types/viewers/archiveSidebar/types.d.ts +4 -0
- package/dist/types/viewers/audio.d.ts +2 -0
- package/dist/types/viewers/base-viewer.d.ts +2 -0
- package/dist/types/viewers/codeViewer/index.d.ts +2 -0
- package/dist/types/viewers/customViewer/customViewer.d.ts +12 -0
- package/dist/types/viewers/doc/index.d.ts +2 -0
- package/dist/types/viewers/image/index.d.ts +1 -1
- package/dist/types/viewers/video.d.ts +2 -0
- package/dist/types-ts4.5/analytics/events/index.d.ts +2 -1
- package/dist/types-ts4.5/analytics/events/operational/_mediaFile.d.ts +1 -1
- package/dist/types-ts4.5/analytics/events/operational/download.d.ts +9 -0
- package/dist/types-ts4.5/components/media-viewer.d.ts +1 -1
- package/dist/types-ts4.5/components/types.d.ts +2 -0
- package/dist/types-ts4.5/download.d.ts +7 -11
- package/dist/types-ts4.5/errors.d.ts +2 -2
- package/dist/types-ts4.5/header.d.ts +3 -2
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/item-viewer.d.ts +7 -2
- package/dist/types-ts4.5/list.d.ts +3 -1
- package/dist/types-ts4.5/media-viewer.d.ts +2 -0
- package/dist/types-ts4.5/viewerOptions.d.ts +21 -0
- package/dist/types-ts4.5/viewers/archiveSidebar/types.d.ts +4 -0
- package/dist/types-ts4.5/viewers/audio.d.ts +2 -0
- package/dist/types-ts4.5/viewers/base-viewer.d.ts +2 -0
- package/dist/types-ts4.5/viewers/codeViewer/index.d.ts +2 -0
- package/dist/types-ts4.5/viewers/customViewer/customViewer.d.ts +12 -0
- package/dist/types-ts4.5/viewers/doc/index.d.ts +2 -0
- package/dist/types-ts4.5/viewers/image/index.d.ts +1 -1
- package/dist/types-ts4.5/viewers/video.d.ts +2 -0
- package/package.json +6 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FileState } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaFileEventPayload } from './_mediaFile';
|
|
3
|
+
import { type MediaViewerFailureAttributes } from '../..';
|
|
4
|
+
import { type MediaViewerError } from '../../../errors';
|
|
5
|
+
import { type MediaTraceContext, type SuccessAttributes, type WithFileAttributes, type WithTraceContext } from '@atlaskit/media-common';
|
|
6
|
+
export type DownloadFailedEventPayload = MediaFileEventPayload<MediaViewerFailureAttributes, 'downloadFailed'>;
|
|
7
|
+
export type DownloadSucceededEventPayload = MediaFileEventPayload<SuccessAttributes & WithFileAttributes & WithTraceContext, 'downloadSucceeded'>;
|
|
8
|
+
export declare const createDownloadSucceededEventPayload: (fileState?: FileState, traceContext?: MediaTraceContext) => DownloadSucceededEventPayload;
|
|
9
|
+
export declare const createDownloadFailedEventPayload: (fileId: string, error: MediaViewerError, fileState?: FileState, traceContext?: MediaTraceContext) => DownloadFailedEventPayload;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type MediaViewerProps } from './types';
|
|
3
3
|
import type { MediaViewerWithMediaClientConfigProps } from './types';
|
|
4
|
-
export declare const MediaViewerBase: ({ featureFlags, onClose, selectedItem, collectionName, items, extensions, contextId, }: MediaViewerProps) => JSX.Element;
|
|
4
|
+
export declare const MediaViewerBase: ({ featureFlags, onClose, selectedItem, collectionName, items, extensions, contextId, viewerOptions, }: MediaViewerProps) => JSX.Element;
|
|
5
5
|
export declare const MediaViewerWithMediaClient: (props: MediaViewerWithMediaClientConfigProps) => JSX.Element;
|
|
@@ -2,6 +2,7 @@ import { type Identifier, type MediaClient } from '@atlaskit/media-client';
|
|
|
2
2
|
import type { WithMediaClientConfigProps } from '@atlaskit/media-client-react';
|
|
3
3
|
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
4
4
|
import { type ReactNode } from 'react';
|
|
5
|
+
import { type ViewerOptionsProps } from '../viewerOptions';
|
|
5
6
|
export type FileStateFlags = {
|
|
6
7
|
wasStatusProcessing: boolean;
|
|
7
8
|
wasStatusUploading: boolean;
|
|
@@ -24,6 +25,7 @@ export interface MediaViewerProps {
|
|
|
24
25
|
readonly featureFlags?: MediaFeatureFlags;
|
|
25
26
|
readonly extensions?: MediaViewerExtensions;
|
|
26
27
|
readonly contextId?: string;
|
|
28
|
+
readonly viewerOptions?: ViewerOptionsProps;
|
|
27
29
|
}
|
|
28
30
|
export type MediaMessage = {
|
|
29
31
|
source: 'media';
|
package/dist/types/download.d.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { type FileState, type Identifier, type MediaClient } from '@atlaskit/media-client';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { type MediaViewerError } from './errors';
|
|
5
|
-
type DownloadButtonProps = React.ComponentProps<typeof MediaButton> & {
|
|
6
|
-
analyticspayload: Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
export declare function DownloadButton({ analyticspayload, onClick: providedOnClick, ...rest }: DownloadButtonProps): JSX.Element;
|
|
9
|
-
export declare const createItemDownloader: (file: FileState, mediaClient: MediaClient, collectionName?: string) => () => Promise<void>;
|
|
3
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
4
|
+
import { MediaViewerError } from './errors';
|
|
10
5
|
export type ErrorViewDownloadButtonProps = {
|
|
11
6
|
fileState: FileState;
|
|
12
7
|
mediaClient: MediaClient;
|
|
13
8
|
error: MediaViewerError;
|
|
14
9
|
collectionName?: string;
|
|
10
|
+
traceContext: MediaTraceContext;
|
|
15
11
|
};
|
|
16
|
-
export declare const ErrorViewDownloadButton: (
|
|
12
|
+
export declare const ErrorViewDownloadButton: ({ fileState, mediaClient, error, traceContext, collectionName, }: ErrorViewDownloadButtonProps) => JSX.Element;
|
|
17
13
|
export type ToolbarDownloadButtonProps = {
|
|
18
14
|
state: FileState;
|
|
19
15
|
identifier: Identifier;
|
|
20
16
|
mediaClient: MediaClient;
|
|
17
|
+
traceContext: MediaTraceContext;
|
|
21
18
|
};
|
|
22
|
-
export declare const ToolbarDownloadButton: (
|
|
19
|
+
export declare const ToolbarDownloadButton: ({ state, mediaClient, identifier, traceContext, }: ToolbarDownloadButtonProps) => JSX.Element | null;
|
|
23
20
|
export declare const DisabledToolbarDownloadButton: JSX.Element;
|
|
24
|
-
export {};
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export declare class ArchiveViewerError extends MediaViewerError {
|
|
|
13
13
|
constructor(primaryReason: ArchiveViewerErrorReason, secondaryError?: Error | undefined, zipEntry?: ZipEntry | undefined);
|
|
14
14
|
}
|
|
15
15
|
export declare function isArchiveViewerError(err: Error): err is ArchiveViewerError;
|
|
16
|
-
export type MediaViewerErrorReason = 'collection-fetch-metadata' | 'header-fetch-metadata' | 'itemviewer-onerror' | 'itemviewer-fetch-metadata' | 'itemviewer-file-error-status' | 'itemviewer-file-failed-processing-status' | 'imageviewer-external-onerror' | 'imageviewer-fetch-url' | 'imageviewer-src-onerror' | 'audioviewer-fetch-url' | 'audioviewer-missing-artefact' | 'audioviewer-playback' | 'videoviewer-fetch-url' | 'videoviewer-missing-artefact' | 'videoviewer-playback' | 'docviewer-fetch-url' | 'docviewer-fetch-pdf' | 'codeviewer-fetch-src' | 'codeviewer-load-src' | 'codeviewer-file-size-exceeds' | 'codeviewer-parse-email' | 'svg-img-error' | 'svg-binary-fetch' | 'svg-unknown-error' | 'unsupported';
|
|
17
|
-
export type ArchiveViewerErrorReason = 'archiveviewer-bundle-loader' | 'archiveviewer-read-binary' | 'archiveviewer-create-url' | 'archiveviewer-imageviewer-onerror' | 'archiveviewer-videoviewer-onerror' | 'archiveviewer-audioviewer-onerror' | 'archiveviewer-docviewer-onerror' | 'archiveviewer-codeviewer-onerror' | 'archiveviewer-codeviewer-file-size-exceeds' | 'archiveviewer-missing-name-src' | 'archiveviewer-unsupported' | 'archiveviewer-encrypted-entry';
|
|
16
|
+
export type MediaViewerErrorReason = 'collection-fetch-metadata' | 'header-fetch-metadata' | 'itemviewer-onerror' | 'itemviewer-fetch-metadata' | 'itemviewer-file-error-status' | 'itemviewer-file-failed-processing-status' | 'imageviewer-external-onerror' | 'imageviewer-fetch-url' | 'imageviewer-src-onerror' | 'audioviewer-fetch-url' | 'audioviewer-missing-artefact' | 'audioviewer-playback' | 'videoviewer-fetch-url' | 'videoviewer-missing-artefact' | 'videoviewer-playback' | 'docviewer-fetch-url' | 'docviewer-fetch-pdf' | 'codeviewer-fetch-src' | 'codeviewer-load-src' | 'codeviewer-file-size-exceeds' | 'codeviewer-parse-email' | 'svg-img-error' | 'svg-binary-fetch' | 'svg-unknown-error' | 'unsupported' | 'custom-viewer-error' | 'download';
|
|
17
|
+
export type ArchiveViewerErrorReason = 'archiveviewer-bundle-loader' | 'archiveviewer-read-binary' | 'archiveviewer-create-url' | 'archiveviewer-imageviewer-onerror' | 'archiveviewer-videoviewer-onerror' | 'archiveviewer-audioviewer-onerror' | 'archiveviewer-docviewer-onerror' | 'archiveviewer-codeviewer-onerror' | 'archiveviewer-codeviewer-file-size-exceeds' | 'archiveviewer-missing-name-src' | 'archiveviewer-unsupported' | 'archiveviewer-encrypted-entry' | 'archiveviewer-customrenderer-onerror';
|
|
18
18
|
export type PrimaryErrorReason = MediaViewerErrorReason | ArchiveViewerErrorReason;
|
|
19
19
|
export type SecondaryErrorReason = MediaClientErrorReason | 'unknown' | 'nativeError' | undefined;
|
|
20
20
|
export declare function getPrimaryErrorReason(error: MediaViewerError): PrimaryErrorReason;
|
package/dist/types/header.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type Identifier } from '@atlaskit/media-client';
|
|
3
3
|
import { type WrappedComponentProps } from 'react-intl-next';
|
|
4
4
|
import { type MediaViewerExtensions } from './components/types';
|
|
5
|
-
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
5
|
+
import { type MediaFeatureFlags, type MediaTraceContext } from '@atlaskit/media-common';
|
|
6
6
|
export type Props = {
|
|
7
7
|
readonly identifier: Identifier;
|
|
8
8
|
readonly onClose?: () => void;
|
|
@@ -12,7 +12,8 @@ export type Props = {
|
|
|
12
12
|
readonly featureFlags?: MediaFeatureFlags;
|
|
13
13
|
readonly onSetArchiveSideBarVisible?: (isVisible: boolean) => void;
|
|
14
14
|
readonly isArchiveSideBarVisible?: boolean;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
15
16
|
};
|
|
16
|
-
export declare const Header: ({ isArchiveSideBarVisible, extensions, isSidebarVisible, onSidebarButtonClick, identifier, onSetArchiveSideBarVisible, }: Props & WrappedComponentProps) => JSX.Element;
|
|
17
|
+
export declare const Header: ({ isArchiveSideBarVisible, extensions, isSidebarVisible, onSidebarButtonClick, identifier, onSetArchiveSideBarVisible, traceContext, }: Props & WrappedComponentProps) => JSX.Element;
|
|
17
18
|
declare const _default: React.FC<Props>;
|
|
18
19
|
export default _default;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { default as MediaViewer } from './components/media-viewer-loader';
|
|
2
2
|
export type { MediaViewerExtensions, MediaViewerExtensionsActions, MediaViewerProps, MediaMessage, } from './components/types';
|
|
3
|
+
export type { ViewerOptionsProps, CustomRendererConfig, CustomRendererStateProps, CustomRendererProps, ArchiveFileItem, } from './viewerOptions';
|
|
@@ -4,24 +4,29 @@ import { type WithShowControlMethodProp } from '@atlaskit/media-ui';
|
|
|
4
4
|
import { Outcome } from './domain';
|
|
5
5
|
import { MediaViewerError } from './errors';
|
|
6
6
|
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
7
|
-
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
7
|
+
import { type MediaFeatureFlags, type MediaTraceContext } from '@atlaskit/media-common';
|
|
8
|
+
import { type ViewerOptionsProps } from './viewerOptions';
|
|
8
9
|
export type Props = Readonly<{
|
|
9
10
|
identifier: Identifier;
|
|
10
11
|
onClose?: () => void;
|
|
11
12
|
previewCount: number;
|
|
12
13
|
contextId?: string;
|
|
13
14
|
featureFlags?: MediaFeatureFlags;
|
|
15
|
+
viewerOptions?: ViewerOptionsProps;
|
|
16
|
+
traceContext: MediaTraceContext;
|
|
14
17
|
}> & WithAnalyticsEventsProps & WithShowControlMethodProp;
|
|
15
18
|
export type FileItem = FileState | 'external-image';
|
|
16
19
|
export type State = Outcome<FileItem, MediaViewerError>;
|
|
17
20
|
export declare const isExternalImageItem: (fileItem: FileItem) => fileItem is "external-image";
|
|
18
21
|
export declare const isFileStateItem: (fileItem: FileItem) => fileItem is FileState;
|
|
19
22
|
export declare const MAX_FILE_SIZE_SUPPORTED_BY_CODEVIEWER: number;
|
|
20
|
-
export declare const ItemViewerBase: ({ identifier, showControls, onClose, previewCount, contextId, createAnalyticsEvent, }: Props) => React.ReactElement | null;
|
|
23
|
+
export declare const ItemViewerBase: ({ identifier, showControls, onClose, previewCount, contextId, createAnalyticsEvent, viewerOptions, traceContext, }: Props) => React.ReactElement | null;
|
|
21
24
|
export declare const ItemViewer: React.ForwardRefExoticComponent<Omit<Readonly<{
|
|
22
25
|
identifier: Identifier;
|
|
23
26
|
onClose?: (() => void) | undefined;
|
|
24
27
|
previewCount: number;
|
|
25
28
|
contextId?: string | undefined;
|
|
26
29
|
featureFlags?: MediaFeatureFlags | undefined;
|
|
30
|
+
viewerOptions?: ViewerOptionsProps | undefined;
|
|
31
|
+
traceContext: MediaTraceContext;
|
|
27
32
|
}> & WithShowControlMethodProp, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
|
package/dist/types/list.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type Identifier } from '@atlaskit/media-client';
|
|
|
3
3
|
import { type WithShowControlMethodProp } from '@atlaskit/media-ui';
|
|
4
4
|
import { type MediaViewerExtensions } from './components/types';
|
|
5
5
|
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
6
|
+
import { type ViewerOptionsProps } from './viewerOptions';
|
|
6
7
|
export type Props = Readonly<{
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onNavigationChange?: (selectedItem: Identifier) => void;
|
|
@@ -13,10 +14,11 @@ export type Props = Readonly<{
|
|
|
13
14
|
isSidebarVisible?: boolean;
|
|
14
15
|
contextId?: string;
|
|
15
16
|
featureFlags?: MediaFeatureFlags;
|
|
17
|
+
viewerOptions?: ViewerOptionsProps;
|
|
16
18
|
} & WithShowControlMethodProp>;
|
|
17
19
|
export type State = {
|
|
18
20
|
selectedItem: Identifier;
|
|
19
21
|
previewCount: number;
|
|
20
22
|
isArchiveSideBarVisible: boolean;
|
|
21
23
|
};
|
|
22
|
-
export declare const List: ({ defaultSelectedItem, onClose, showControls, extensions, onSidebarButtonClick, contextId, featureFlags, isSidebarVisible, onNavigationChange, items, }: Props) => JSX.Element;
|
|
24
|
+
export declare const List: ({ defaultSelectedItem, onClose, showControls, extensions, onSidebarButtonClick, contextId, featureFlags, isSidebarVisible, onNavigationChange, items, viewerOptions, }: Props) => JSX.Element;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type Identifier } from '@atlaskit/media-client';
|
|
3
3
|
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
4
4
|
import { type MediaViewerExtensions } from './components/types';
|
|
5
|
+
import { type ViewerOptionsProps } from './viewerOptions';
|
|
5
6
|
export type Props = {
|
|
6
7
|
onClose?: () => void;
|
|
7
8
|
selectedItem?: Identifier;
|
|
@@ -10,5 +11,6 @@ export type Props = {
|
|
|
10
11
|
extensions?: MediaViewerExtensions;
|
|
11
12
|
contextId?: string;
|
|
12
13
|
innerRef?: React.Ref<HTMLDivElement>;
|
|
14
|
+
viewerOptions?: ViewerOptionsProps;
|
|
13
15
|
};
|
|
14
16
|
export declare const MediaViewer: React.ComponentType<Props>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type NonErrorFileState } from '@atlaskit/media-client';
|
|
3
|
+
export interface ViewerOptionsProps {
|
|
4
|
+
customRenderers?: CustomRendererConfig[];
|
|
5
|
+
}
|
|
6
|
+
export interface CustomRendererConfig {
|
|
7
|
+
shouldUseCustomRenderer: (props: CustomRendererStateProps) => boolean;
|
|
8
|
+
renderContent: (props: CustomRendererProps) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export interface CustomRendererStateProps {
|
|
11
|
+
fileItem: NonErrorFileState;
|
|
12
|
+
archiveFileItem?: ArchiveFileItem;
|
|
13
|
+
}
|
|
14
|
+
export interface CustomRendererProps extends CustomRendererStateProps {
|
|
15
|
+
getBinaryContent: () => Promise<Blob>;
|
|
16
|
+
onLoad: () => void;
|
|
17
|
+
onError: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface ArchiveFileItem {
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { type MediaClient, type FileState, type ErrorFileState } from '@atlaskit/media-client';
|
|
2
2
|
import { type ArchiveViewerError } from '../../errors';
|
|
3
|
+
import { type ViewerOptionsProps } from '../../viewerOptions';
|
|
4
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
5
|
export type ArchiveViewerProps = {
|
|
4
6
|
item: Exclude<FileState, ErrorFileState>;
|
|
5
7
|
mediaClient: MediaClient;
|
|
6
8
|
collectionName?: string;
|
|
7
9
|
onError: (error: ArchiveViewerError) => void;
|
|
8
10
|
onSuccess: () => void;
|
|
11
|
+
viewerOptions?: ViewerOptionsProps;
|
|
12
|
+
traceContext: MediaTraceContext;
|
|
9
13
|
};
|
|
@@ -4,6 +4,7 @@ import { Outcome } from '../domain';
|
|
|
4
4
|
import { MediaViewerError } from '../errors';
|
|
5
5
|
import { type BaseState, BaseViewer } from './base-viewer';
|
|
6
6
|
import { type WithShowControlMethodProp } from '@atlaskit/media-ui';
|
|
7
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
7
8
|
export type Props = Readonly<{
|
|
8
9
|
item: FileState;
|
|
9
10
|
mediaClient: MediaClient;
|
|
@@ -11,6 +12,7 @@ export type Props = Readonly<{
|
|
|
11
12
|
previewCount: number;
|
|
12
13
|
onCanPlay: () => void;
|
|
13
14
|
onError: (error: MediaViewerError) => void;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
14
16
|
} & WithShowControlMethodProp>;
|
|
15
17
|
export type State = BaseState<string> & {
|
|
16
18
|
coverUrl?: string;
|
|
@@ -2,10 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { type MediaClient, type FileState } from '@atlaskit/media-client';
|
|
3
3
|
import { type Outcome } from '../domain';
|
|
4
4
|
import { type MediaViewerError } from '../errors';
|
|
5
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
5
6
|
export type BaseProps = {
|
|
6
7
|
mediaClient: MediaClient;
|
|
7
8
|
item: FileState;
|
|
8
9
|
collectionName?: string;
|
|
10
|
+
traceContext: MediaTraceContext;
|
|
9
11
|
};
|
|
10
12
|
export type BaseState<Content> = {
|
|
11
13
|
content: Outcome<Content, MediaViewerError>;
|
|
@@ -4,6 +4,7 @@ import { Outcome } from '../../domain';
|
|
|
4
4
|
import { MediaViewerError } from '../../errors';
|
|
5
5
|
import { type Props as RendererProps } from './codeViewerRenderer';
|
|
6
6
|
import { BaseViewer } from '../base-viewer';
|
|
7
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
7
8
|
export type Props = {
|
|
8
9
|
mediaClient: MediaClient;
|
|
9
10
|
item: Exclude<FileState, ErrorFileState>;
|
|
@@ -11,6 +12,7 @@ export type Props = {
|
|
|
11
12
|
onClose?: () => void;
|
|
12
13
|
onError: (error: MediaViewerError) => void;
|
|
13
14
|
onSuccess: () => void;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
14
16
|
};
|
|
15
17
|
export declare class CodeViewer extends BaseViewer<string, Props> {
|
|
16
18
|
static CodeViewerComponent: ComponentClass<RendererProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { FileState, MediaClient, NonErrorFileState } from '@atlaskit/media-client';
|
|
3
|
+
import { MediaViewerError } from '../../errors';
|
|
4
|
+
import type { CustomRendererConfig } from '../../viewerOptions';
|
|
5
|
+
export type Props = {
|
|
6
|
+
mediaClient: MediaClient;
|
|
7
|
+
item: NonErrorFileState;
|
|
8
|
+
customRendererConfig: CustomRendererConfig;
|
|
9
|
+
onError: (error: MediaViewerError, fileItem?: FileState) => void;
|
|
10
|
+
onSuccess: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const CustomViewer: ({ mediaClient, item, customRendererConfig, onSuccess, onError, }: Props) => JSX.Element;
|
|
@@ -3,6 +3,7 @@ import { type MediaClient, type FileState } from '@atlaskit/media-client';
|
|
|
3
3
|
import { Outcome } from '../../domain';
|
|
4
4
|
import { MediaViewerError } from '../../errors';
|
|
5
5
|
import { BaseViewer } from '../base-viewer';
|
|
6
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
6
7
|
export type Props = {
|
|
7
8
|
mediaClient: MediaClient;
|
|
8
9
|
item: FileState;
|
|
@@ -10,6 +11,7 @@ export type Props = {
|
|
|
10
11
|
onClose?: () => void;
|
|
11
12
|
onError: (error: MediaViewerError) => void;
|
|
12
13
|
onSuccess: () => void;
|
|
14
|
+
traceContext: MediaTraceContext;
|
|
13
15
|
};
|
|
14
16
|
export type State = {
|
|
15
17
|
content: Outcome<string, MediaViewerError>;
|
|
@@ -13,7 +13,7 @@ export type ImageViewerProps = {
|
|
|
13
13
|
onError: (error: MediaViewerError) => void;
|
|
14
14
|
onClose?: () => void;
|
|
15
15
|
contextId?: string;
|
|
16
|
-
traceContext
|
|
16
|
+
traceContext: MediaTraceContext;
|
|
17
17
|
};
|
|
18
18
|
export interface ImageViewerContent {
|
|
19
19
|
objectUrl: ObjectUrl;
|
|
@@ -4,6 +4,7 @@ import { type WithShowControlMethodProp } from '@atlaskit/media-ui';
|
|
|
4
4
|
import { Outcome } from '../domain';
|
|
5
5
|
import { MediaViewerError } from '../errors';
|
|
6
6
|
import { type BaseState, BaseViewer } from './base-viewer';
|
|
7
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
7
8
|
export type Props = Readonly<{
|
|
8
9
|
item: FileState;
|
|
9
10
|
mediaClient: MediaClient;
|
|
@@ -11,6 +12,7 @@ export type Props = Readonly<{
|
|
|
11
12
|
previewCount: number;
|
|
12
13
|
onCanPlay: () => void;
|
|
13
14
|
onError: (error: MediaViewerError) => void;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
14
16
|
} & WithShowControlMethodProp>;
|
|
15
17
|
export type State = BaseState<string> & {
|
|
16
18
|
isHDActive: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CommencedEventPayload } from './operational/commenced';
|
|
2
2
|
import { type LoadFailedEventPayload } from './operational/loadFailed';
|
|
3
|
+
import { type DownloadFailedEventPayload, type DownloadSucceededEventPayload } from './operational/download';
|
|
3
4
|
import { type LoadSucceededEventPayload } from './operational/loadSucceeded';
|
|
4
5
|
import { type PreviewUnsupportedEventPayload } from './operational/previewUnsupported';
|
|
5
6
|
import { type ZipEntryLoadFailedEventPayload } from './operational/zipEntryLoadFailed';
|
|
@@ -13,4 +14,4 @@ import { type FailedPreviewDownloadButtonClickedEventPayload } from './ui/failed
|
|
|
13
14
|
import { type NavigatedEventPayload } from './ui/navigated';
|
|
14
15
|
import { type ZoomInButtonClickEventPayload } from './ui/zoomInButtonClicked';
|
|
15
16
|
import { type ZoomOutButtonClickEventPayload } from './ui/zoomOutButtonClicked';
|
|
16
|
-
export type MediaViewerEventPayload = CommencedEventPayload | LoadFailedEventPayload | LoadSucceededEventPayload | PreviewUnsupportedEventPayload | ZipEntryLoadFailedEventPayload | ZipEntryLoadSucceededEventPayload | ModalEventPayload | PdfPasswordInputScreenEventPayload | PasswordPdfScreenEventPayload | ClosedEventPayload | DownloadButtonClickedEventPayload | FailedPreviewDownloadButtonClickedEventPayload | NavigatedEventPayload | ZoomInButtonClickEventPayload | ZoomOutButtonClickEventPayload;
|
|
17
|
+
export type MediaViewerEventPayload = CommencedEventPayload | LoadFailedEventPayload | LoadSucceededEventPayload | PreviewUnsupportedEventPayload | ZipEntryLoadFailedEventPayload | ZipEntryLoadSucceededEventPayload | ModalEventPayload | PdfPasswordInputScreenEventPayload | PasswordPdfScreenEventPayload | ClosedEventPayload | DownloadButtonClickedEventPayload | FailedPreviewDownloadButtonClickedEventPayload | NavigatedEventPayload | ZoomInButtonClickEventPayload | ZoomOutButtonClickEventPayload | DownloadFailedEventPayload | DownloadSucceededEventPayload;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type OperationalEventPayload, type OperationalAttributes } from '@atlaskit/media-common';
|
|
2
2
|
/** common definition used by other mediaFile events */
|
|
3
|
-
export type MediaFileEventPayload<Attributes extends OperationalAttributes, Action extends 'commenced' | 'loadSucceeded' | 'loadFailed' | 'previewUnsupported' | 'zipEntryLoadSucceeded' | 'zipEntryLoadFailed'> = OperationalEventPayload<Attributes, Action, 'mediaFile'>;
|
|
3
|
+
export type MediaFileEventPayload<Attributes extends OperationalAttributes, Action extends 'commenced' | 'loadSucceeded' | 'loadFailed' | 'previewUnsupported' | 'zipEntryLoadSucceeded' | 'zipEntryLoadFailed' | 'downloadSucceeded' | 'downloadFailed'> = OperationalEventPayload<Attributes, Action, 'mediaFile'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FileState } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaFileEventPayload } from './_mediaFile';
|
|
3
|
+
import { type MediaViewerFailureAttributes } from '../..';
|
|
4
|
+
import { type MediaViewerError } from '../../../errors';
|
|
5
|
+
import { type MediaTraceContext, type SuccessAttributes, type WithFileAttributes, type WithTraceContext } from '@atlaskit/media-common';
|
|
6
|
+
export type DownloadFailedEventPayload = MediaFileEventPayload<MediaViewerFailureAttributes, 'downloadFailed'>;
|
|
7
|
+
export type DownloadSucceededEventPayload = MediaFileEventPayload<SuccessAttributes & WithFileAttributes & WithTraceContext, 'downloadSucceeded'>;
|
|
8
|
+
export declare const createDownloadSucceededEventPayload: (fileState?: FileState, traceContext?: MediaTraceContext) => DownloadSucceededEventPayload;
|
|
9
|
+
export declare const createDownloadFailedEventPayload: (fileId: string, error: MediaViewerError, fileState?: FileState, traceContext?: MediaTraceContext) => DownloadFailedEventPayload;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type MediaViewerProps } from './types';
|
|
3
3
|
import type { MediaViewerWithMediaClientConfigProps } from './types';
|
|
4
|
-
export declare const MediaViewerBase: ({ featureFlags, onClose, selectedItem, collectionName, items, extensions, contextId, }: MediaViewerProps) => JSX.Element;
|
|
4
|
+
export declare const MediaViewerBase: ({ featureFlags, onClose, selectedItem, collectionName, items, extensions, contextId, viewerOptions, }: MediaViewerProps) => JSX.Element;
|
|
5
5
|
export declare const MediaViewerWithMediaClient: (props: MediaViewerWithMediaClientConfigProps) => JSX.Element;
|
|
@@ -2,6 +2,7 @@ import { type Identifier, type MediaClient } from '@atlaskit/media-client';
|
|
|
2
2
|
import type { WithMediaClientConfigProps } from '@atlaskit/media-client-react';
|
|
3
3
|
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
4
4
|
import { type ReactNode } from 'react';
|
|
5
|
+
import { type ViewerOptionsProps } from '../viewerOptions';
|
|
5
6
|
export type FileStateFlags = {
|
|
6
7
|
wasStatusProcessing: boolean;
|
|
7
8
|
wasStatusUploading: boolean;
|
|
@@ -24,6 +25,7 @@ export interface MediaViewerProps {
|
|
|
24
25
|
readonly featureFlags?: MediaFeatureFlags;
|
|
25
26
|
readonly extensions?: MediaViewerExtensions;
|
|
26
27
|
readonly contextId?: string;
|
|
28
|
+
readonly viewerOptions?: ViewerOptionsProps;
|
|
27
29
|
}
|
|
28
30
|
export type MediaMessage = {
|
|
29
31
|
source: 'media';
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { type FileState, type Identifier, type MediaClient } from '@atlaskit/media-client';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { type MediaViewerError } from './errors';
|
|
5
|
-
type DownloadButtonProps = React.ComponentProps<typeof MediaButton> & {
|
|
6
|
-
analyticspayload: Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
export declare function DownloadButton({ analyticspayload, onClick: providedOnClick, ...rest }: DownloadButtonProps): JSX.Element;
|
|
9
|
-
export declare const createItemDownloader: (file: FileState, mediaClient: MediaClient, collectionName?: string) => () => Promise<void>;
|
|
3
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
4
|
+
import { MediaViewerError } from './errors';
|
|
10
5
|
export type ErrorViewDownloadButtonProps = {
|
|
11
6
|
fileState: FileState;
|
|
12
7
|
mediaClient: MediaClient;
|
|
13
8
|
error: MediaViewerError;
|
|
14
9
|
collectionName?: string;
|
|
10
|
+
traceContext: MediaTraceContext;
|
|
15
11
|
};
|
|
16
|
-
export declare const ErrorViewDownloadButton: (
|
|
12
|
+
export declare const ErrorViewDownloadButton: ({ fileState, mediaClient, error, traceContext, collectionName, }: ErrorViewDownloadButtonProps) => JSX.Element;
|
|
17
13
|
export type ToolbarDownloadButtonProps = {
|
|
18
14
|
state: FileState;
|
|
19
15
|
identifier: Identifier;
|
|
20
16
|
mediaClient: MediaClient;
|
|
17
|
+
traceContext: MediaTraceContext;
|
|
21
18
|
};
|
|
22
|
-
export declare const ToolbarDownloadButton: (
|
|
19
|
+
export declare const ToolbarDownloadButton: ({ state, mediaClient, identifier, traceContext, }: ToolbarDownloadButtonProps) => JSX.Element | null;
|
|
23
20
|
export declare const DisabledToolbarDownloadButton: JSX.Element;
|
|
24
|
-
export {};
|
|
@@ -13,8 +13,8 @@ export declare class ArchiveViewerError extends MediaViewerError {
|
|
|
13
13
|
constructor(primaryReason: ArchiveViewerErrorReason, secondaryError?: Error | undefined, zipEntry?: ZipEntry | undefined);
|
|
14
14
|
}
|
|
15
15
|
export declare function isArchiveViewerError(err: Error): err is ArchiveViewerError;
|
|
16
|
-
export type MediaViewerErrorReason = 'collection-fetch-metadata' | 'header-fetch-metadata' | 'itemviewer-onerror' | 'itemviewer-fetch-metadata' | 'itemviewer-file-error-status' | 'itemviewer-file-failed-processing-status' | 'imageviewer-external-onerror' | 'imageviewer-fetch-url' | 'imageviewer-src-onerror' | 'audioviewer-fetch-url' | 'audioviewer-missing-artefact' | 'audioviewer-playback' | 'videoviewer-fetch-url' | 'videoviewer-missing-artefact' | 'videoviewer-playback' | 'docviewer-fetch-url' | 'docviewer-fetch-pdf' | 'codeviewer-fetch-src' | 'codeviewer-load-src' | 'codeviewer-file-size-exceeds' | 'codeviewer-parse-email' | 'svg-img-error' | 'svg-binary-fetch' | 'svg-unknown-error' | 'unsupported';
|
|
17
|
-
export type ArchiveViewerErrorReason = 'archiveviewer-bundle-loader' | 'archiveviewer-read-binary' | 'archiveviewer-create-url' | 'archiveviewer-imageviewer-onerror' | 'archiveviewer-videoviewer-onerror' | 'archiveviewer-audioviewer-onerror' | 'archiveviewer-docviewer-onerror' | 'archiveviewer-codeviewer-onerror' | 'archiveviewer-codeviewer-file-size-exceeds' | 'archiveviewer-missing-name-src' | 'archiveviewer-unsupported' | 'archiveviewer-encrypted-entry';
|
|
16
|
+
export type MediaViewerErrorReason = 'collection-fetch-metadata' | 'header-fetch-metadata' | 'itemviewer-onerror' | 'itemviewer-fetch-metadata' | 'itemviewer-file-error-status' | 'itemviewer-file-failed-processing-status' | 'imageviewer-external-onerror' | 'imageviewer-fetch-url' | 'imageviewer-src-onerror' | 'audioviewer-fetch-url' | 'audioviewer-missing-artefact' | 'audioviewer-playback' | 'videoviewer-fetch-url' | 'videoviewer-missing-artefact' | 'videoviewer-playback' | 'docviewer-fetch-url' | 'docviewer-fetch-pdf' | 'codeviewer-fetch-src' | 'codeviewer-load-src' | 'codeviewer-file-size-exceeds' | 'codeviewer-parse-email' | 'svg-img-error' | 'svg-binary-fetch' | 'svg-unknown-error' | 'unsupported' | 'custom-viewer-error' | 'download';
|
|
17
|
+
export type ArchiveViewerErrorReason = 'archiveviewer-bundle-loader' | 'archiveviewer-read-binary' | 'archiveviewer-create-url' | 'archiveviewer-imageviewer-onerror' | 'archiveviewer-videoviewer-onerror' | 'archiveviewer-audioviewer-onerror' | 'archiveviewer-docviewer-onerror' | 'archiveviewer-codeviewer-onerror' | 'archiveviewer-codeviewer-file-size-exceeds' | 'archiveviewer-missing-name-src' | 'archiveviewer-unsupported' | 'archiveviewer-encrypted-entry' | 'archiveviewer-customrenderer-onerror';
|
|
18
18
|
export type PrimaryErrorReason = MediaViewerErrorReason | ArchiveViewerErrorReason;
|
|
19
19
|
export type SecondaryErrorReason = MediaClientErrorReason | 'unknown' | 'nativeError' | undefined;
|
|
20
20
|
export declare function getPrimaryErrorReason(error: MediaViewerError): PrimaryErrorReason;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type Identifier } from '@atlaskit/media-client';
|
|
3
3
|
import { type WrappedComponentProps } from 'react-intl-next';
|
|
4
4
|
import { type MediaViewerExtensions } from './components/types';
|
|
5
|
-
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
5
|
+
import { type MediaFeatureFlags, type MediaTraceContext } from '@atlaskit/media-common';
|
|
6
6
|
export type Props = {
|
|
7
7
|
readonly identifier: Identifier;
|
|
8
8
|
readonly onClose?: () => void;
|
|
@@ -12,7 +12,8 @@ export type Props = {
|
|
|
12
12
|
readonly featureFlags?: MediaFeatureFlags;
|
|
13
13
|
readonly onSetArchiveSideBarVisible?: (isVisible: boolean) => void;
|
|
14
14
|
readonly isArchiveSideBarVisible?: boolean;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
15
16
|
};
|
|
16
|
-
export declare const Header: ({ isArchiveSideBarVisible, extensions, isSidebarVisible, onSidebarButtonClick, identifier, onSetArchiveSideBarVisible, }: Props & WrappedComponentProps) => JSX.Element;
|
|
17
|
+
export declare const Header: ({ isArchiveSideBarVisible, extensions, isSidebarVisible, onSidebarButtonClick, identifier, onSetArchiveSideBarVisible, traceContext, }: Props & WrappedComponentProps) => JSX.Element;
|
|
17
18
|
declare const _default: React.FC<Props>;
|
|
18
19
|
export default _default;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { default as MediaViewer } from './components/media-viewer-loader';
|
|
2
2
|
export type { MediaViewerExtensions, MediaViewerExtensionsActions, MediaViewerProps, MediaMessage, } from './components/types';
|
|
3
|
+
export type { ViewerOptionsProps, CustomRendererConfig, CustomRendererStateProps, CustomRendererProps, ArchiveFileItem, } from './viewerOptions';
|
|
@@ -4,24 +4,29 @@ import { type WithShowControlMethodProp } from '@atlaskit/media-ui';
|
|
|
4
4
|
import { Outcome } from './domain';
|
|
5
5
|
import { MediaViewerError } from './errors';
|
|
6
6
|
import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
7
|
-
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
7
|
+
import { type MediaFeatureFlags, type MediaTraceContext } from '@atlaskit/media-common';
|
|
8
|
+
import { type ViewerOptionsProps } from './viewerOptions';
|
|
8
9
|
export type Props = Readonly<{
|
|
9
10
|
identifier: Identifier;
|
|
10
11
|
onClose?: () => void;
|
|
11
12
|
previewCount: number;
|
|
12
13
|
contextId?: string;
|
|
13
14
|
featureFlags?: MediaFeatureFlags;
|
|
15
|
+
viewerOptions?: ViewerOptionsProps;
|
|
16
|
+
traceContext: MediaTraceContext;
|
|
14
17
|
}> & WithAnalyticsEventsProps & WithShowControlMethodProp;
|
|
15
18
|
export type FileItem = FileState | 'external-image';
|
|
16
19
|
export type State = Outcome<FileItem, MediaViewerError>;
|
|
17
20
|
export declare const isExternalImageItem: (fileItem: FileItem) => fileItem is "external-image";
|
|
18
21
|
export declare const isFileStateItem: (fileItem: FileItem) => fileItem is FileState;
|
|
19
22
|
export declare const MAX_FILE_SIZE_SUPPORTED_BY_CODEVIEWER: number;
|
|
20
|
-
export declare const ItemViewerBase: ({ identifier, showControls, onClose, previewCount, contextId, createAnalyticsEvent, }: Props) => React.ReactElement | null;
|
|
23
|
+
export declare const ItemViewerBase: ({ identifier, showControls, onClose, previewCount, contextId, createAnalyticsEvent, viewerOptions, traceContext, }: Props) => React.ReactElement | null;
|
|
21
24
|
export declare const ItemViewer: React.ForwardRefExoticComponent<Omit<Readonly<{
|
|
22
25
|
identifier: Identifier;
|
|
23
26
|
onClose?: (() => void) | undefined;
|
|
24
27
|
previewCount: number;
|
|
25
28
|
contextId?: string | undefined;
|
|
26
29
|
featureFlags?: MediaFeatureFlags | undefined;
|
|
30
|
+
viewerOptions?: ViewerOptionsProps | undefined;
|
|
31
|
+
traceContext: MediaTraceContext;
|
|
27
32
|
}> & WithShowControlMethodProp, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
|
|
@@ -3,6 +3,7 @@ import { type Identifier } from '@atlaskit/media-client';
|
|
|
3
3
|
import { type WithShowControlMethodProp } from '@atlaskit/media-ui';
|
|
4
4
|
import { type MediaViewerExtensions } from './components/types';
|
|
5
5
|
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
6
|
+
import { type ViewerOptionsProps } from './viewerOptions';
|
|
6
7
|
export type Props = Readonly<{
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onNavigationChange?: (selectedItem: Identifier) => void;
|
|
@@ -13,10 +14,11 @@ export type Props = Readonly<{
|
|
|
13
14
|
isSidebarVisible?: boolean;
|
|
14
15
|
contextId?: string;
|
|
15
16
|
featureFlags?: MediaFeatureFlags;
|
|
17
|
+
viewerOptions?: ViewerOptionsProps;
|
|
16
18
|
} & WithShowControlMethodProp>;
|
|
17
19
|
export type State = {
|
|
18
20
|
selectedItem: Identifier;
|
|
19
21
|
previewCount: number;
|
|
20
22
|
isArchiveSideBarVisible: boolean;
|
|
21
23
|
};
|
|
22
|
-
export declare const List: ({ defaultSelectedItem, onClose, showControls, extensions, onSidebarButtonClick, contextId, featureFlags, isSidebarVisible, onNavigationChange, items, }: Props) => JSX.Element;
|
|
24
|
+
export declare const List: ({ defaultSelectedItem, onClose, showControls, extensions, onSidebarButtonClick, contextId, featureFlags, isSidebarVisible, onNavigationChange, items, viewerOptions, }: Props) => JSX.Element;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type Identifier } from '@atlaskit/media-client';
|
|
3
3
|
import { type MediaFeatureFlags } from '@atlaskit/media-common';
|
|
4
4
|
import { type MediaViewerExtensions } from './components/types';
|
|
5
|
+
import { type ViewerOptionsProps } from './viewerOptions';
|
|
5
6
|
export type Props = {
|
|
6
7
|
onClose?: () => void;
|
|
7
8
|
selectedItem?: Identifier;
|
|
@@ -10,5 +11,6 @@ export type Props = {
|
|
|
10
11
|
extensions?: MediaViewerExtensions;
|
|
11
12
|
contextId?: string;
|
|
12
13
|
innerRef?: React.Ref<HTMLDivElement>;
|
|
14
|
+
viewerOptions?: ViewerOptionsProps;
|
|
13
15
|
};
|
|
14
16
|
export declare const MediaViewer: React.ComponentType<Props>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type NonErrorFileState } from '@atlaskit/media-client';
|
|
3
|
+
export interface ViewerOptionsProps {
|
|
4
|
+
customRenderers?: CustomRendererConfig[];
|
|
5
|
+
}
|
|
6
|
+
export interface CustomRendererConfig {
|
|
7
|
+
shouldUseCustomRenderer: (props: CustomRendererStateProps) => boolean;
|
|
8
|
+
renderContent: (props: CustomRendererProps) => React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export interface CustomRendererStateProps {
|
|
11
|
+
fileItem: NonErrorFileState;
|
|
12
|
+
archiveFileItem?: ArchiveFileItem;
|
|
13
|
+
}
|
|
14
|
+
export interface CustomRendererProps extends CustomRendererStateProps {
|
|
15
|
+
getBinaryContent: () => Promise<Blob>;
|
|
16
|
+
onLoad: () => void;
|
|
17
|
+
onError: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface ArchiveFileItem {
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { type MediaClient, type FileState, type ErrorFileState } from '@atlaskit/media-client';
|
|
2
2
|
import { type ArchiveViewerError } from '../../errors';
|
|
3
|
+
import { type ViewerOptionsProps } from '../../viewerOptions';
|
|
4
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
5
|
export type ArchiveViewerProps = {
|
|
4
6
|
item: Exclude<FileState, ErrorFileState>;
|
|
5
7
|
mediaClient: MediaClient;
|
|
6
8
|
collectionName?: string;
|
|
7
9
|
onError: (error: ArchiveViewerError) => void;
|
|
8
10
|
onSuccess: () => void;
|
|
11
|
+
viewerOptions?: ViewerOptionsProps;
|
|
12
|
+
traceContext: MediaTraceContext;
|
|
9
13
|
};
|
|
@@ -4,6 +4,7 @@ import { Outcome } from '../domain';
|
|
|
4
4
|
import { MediaViewerError } from '../errors';
|
|
5
5
|
import { type BaseState, BaseViewer } from './base-viewer';
|
|
6
6
|
import { type WithShowControlMethodProp } from '@atlaskit/media-ui';
|
|
7
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
7
8
|
export type Props = Readonly<{
|
|
8
9
|
item: FileState;
|
|
9
10
|
mediaClient: MediaClient;
|
|
@@ -11,6 +12,7 @@ export type Props = Readonly<{
|
|
|
11
12
|
previewCount: number;
|
|
12
13
|
onCanPlay: () => void;
|
|
13
14
|
onError: (error: MediaViewerError) => void;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
14
16
|
} & WithShowControlMethodProp>;
|
|
15
17
|
export type State = BaseState<string> & {
|
|
16
18
|
coverUrl?: string;
|
|
@@ -2,10 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { type MediaClient, type FileState } from '@atlaskit/media-client';
|
|
3
3
|
import { type Outcome } from '../domain';
|
|
4
4
|
import { type MediaViewerError } from '../errors';
|
|
5
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
5
6
|
export type BaseProps = {
|
|
6
7
|
mediaClient: MediaClient;
|
|
7
8
|
item: FileState;
|
|
8
9
|
collectionName?: string;
|
|
10
|
+
traceContext: MediaTraceContext;
|
|
9
11
|
};
|
|
10
12
|
export type BaseState<Content> = {
|
|
11
13
|
content: Outcome<Content, MediaViewerError>;
|
|
@@ -4,6 +4,7 @@ import { Outcome } from '../../domain';
|
|
|
4
4
|
import { MediaViewerError } from '../../errors';
|
|
5
5
|
import { type Props as RendererProps } from './codeViewerRenderer';
|
|
6
6
|
import { BaseViewer } from '../base-viewer';
|
|
7
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
7
8
|
export type Props = {
|
|
8
9
|
mediaClient: MediaClient;
|
|
9
10
|
item: Exclude<FileState, ErrorFileState>;
|
|
@@ -11,6 +12,7 @@ export type Props = {
|
|
|
11
12
|
onClose?: () => void;
|
|
12
13
|
onError: (error: MediaViewerError) => void;
|
|
13
14
|
onSuccess: () => void;
|
|
15
|
+
traceContext: MediaTraceContext;
|
|
14
16
|
};
|
|
15
17
|
export declare class CodeViewer extends BaseViewer<string, Props> {
|
|
16
18
|
static CodeViewerComponent: ComponentClass<RendererProps>;
|