How to specify a custom Media Client in Atlaskit especially @atlaskit/editor-core
Sophia Terry
I'm trying to use @atlaskit/editor-core in my own project and want to specify my own Fileserver/MediaClient. Atlassian does provide a function, where I could mock the client and instead of really mocking it injecting my own client this way... but is this really the best option?
Since the documentation on @atlaskit/editor-core is fairly small, I do not know where else to look...
Findings so far: with the following line the mocking can be enabled.
import { mediaMock } from '@atlaskit/media-test-helpers'
mediaMock.enable()Minimal Example:
import React from 'react';
import { MediaProvider } from '@atlaskit/editor-common';
import { Editor } from '@atlaskit/editor-core';
import { MediaClientConfig } from '@atlaskit/media-core';
import { mediaMock, mediaPickerAuthProvider } from '@atlaskit/media-test-helpers';
mediaMock.enable();
// Crreating basic MediaProvider
const collection = 'sample-collection';
const mediaClientConfig: MediaClientConfig = { authProvider: mediaPickerAuthProvider(),
};
const mediaProvider = Promise.resolve<MediaProvider>({ uploadParams: { collection }, viewMediaClientConfig: mediaClientConfig, uploadMediaClientConfig: mediaClientConfig,
});
export const EditorMinimal = () => { return ( <Editor appearance="full-page" media={{ provider: mediaProvider, allowResizing: true, allowMediaSingle: true, useMediaPickerPopup: false, allowDropzoneDropLine: true, isCopyPasteEnabled: true, }} /> );
};Any link, direction, advise or starting point will be appreciated!!
11 Answer
Resolved this using my own answer at