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!!
Resolved this using my own answer at https://community.developer.atlassian.com/t/atlaskit-editor-core-custom-file-endpoint-file-upload-service/45558
If possible could you pls provide sample where you have update mediastore.
Update: I managed to solve this by going to the node_modules directory. There there is the media-client (@atlaskit/media-client) where it is feasable to rewrite the mediastore class (there is a es2019 module) and then compile the rewrites to the other modules (esm and cjs). Then after that I patched the module so that the changes are persistent. But keep in Mind, this is a very hacky Solution.
Thanks, Umang
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.