Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to specify a custom Media Client in Atlaskit especially @atlaskit/editor-core

Writer 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!!

1

1 Answer

Resolved this using my own answer at

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.