diff --git a/.changeset/lovely-llamas-call.md b/.changeset/lovely-llamas-call.md new file mode 100644 index 0000000000..a80bcffe5d --- /dev/null +++ b/.changeset/lovely-llamas-call.md @@ -0,0 +1,5 @@ +--- +"@udecode/plate-cloud": patch +--- + +fix: #3002 diff --git a/packages/cloud/src/cloud/types.ts b/packages/cloud/src/cloud/types.ts index 26af68d3f0..12c03c6c93 100644 --- a/packages/cloud/src/cloud/types.ts +++ b/packages/cloud/src/cloud/types.ts @@ -1,4 +1,4 @@ -import { Client, ClientOptions } from '@portive/client'; +import * as portiveClient from '@portive/client'; import { PlateEditor, Value } from '@udecode/plate-common'; import { Upload } from '../upload'; @@ -7,7 +7,7 @@ import { createUploadStore } from '../upload/createUploadStore'; /** * Specifies just the `options` part of the CloudPlugin */ -export type CloudPlugin = ClientOptions & { +export type CloudPlugin = portiveClient.ClientOptions & { uploadStoreInitialValue?: Record; }; @@ -18,7 +18,7 @@ export type FinishUploadsOptions = { maxTimeoutInMs?: number }; export type CloudEditorProps = { cloud: { - client: Client; + client: portiveClient.Client; uploadFiles: (msg: any) => void; uploadStore: ReturnType; genericFileHandlers?: { diff --git a/packages/cloud/src/cloud/uploadFiles.ts b/packages/cloud/src/cloud/uploadFiles.ts index f906f6287b..6937400ba9 100644 --- a/packages/cloud/src/cloud/uploadFiles.ts +++ b/packages/cloud/src/cloud/uploadFiles.ts @@ -1,9 +1,12 @@ -import { ClientFile, uploadFile as uploadFileToPortive } from '@portive/client'; +import * as portiveClient from '@portive/client'; import { nanoid, Value } from '@udecode/plate-common'; import { FileEvent, PlateCloudEditor, ProgressEvent } from './types'; -const createFileEvent = (id: string, clientFile: ClientFile): FileEvent => { +const createFileEvent = ( + id: string, + clientFile: portiveClient.ClientFile +): FileEvent => { if (clientFile.type === 'image') { return { id, @@ -28,7 +31,7 @@ export const uploadFile = ( ) => { const id = `#${nanoid()}`; const { client } = editor.cloud; - uploadFileToPortive({ + portiveClient.uploadFile({ client, file, onBeforeFetch(e) { diff --git a/packages/cloud/src/cloud/withCloud.ts b/packages/cloud/src/cloud/withCloud.ts index 3629f47699..5a10ea6d98 100644 --- a/packages/cloud/src/cloud/withCloud.ts +++ b/packages/cloud/src/cloud/withCloud.ts @@ -1,4 +1,4 @@ -import { Client, createClient } from '@portive/client'; +import * as portiveClient from '@portive/client'; import { PlateEditor, Value, WithPlatePlugin } from '@udecode/plate-common'; import { createUploadStore } from '../upload/createUploadStore'; @@ -20,9 +20,9 @@ export const withCloud = < const { apiKey, authToken, apiOrigin, uploadStoreInitialValue } = plugin.options; - let client: Client; + let client: portiveClient.Client; try { - client = createClient({ apiKey, authToken, apiOrigin }); + client = portiveClient.createClient({ apiKey, authToken, apiOrigin }); } catch (error) { console.error(error); } diff --git a/packages/cloud/src/image/withCloudImage.ts b/packages/cloud/src/image/withCloudImage.ts index ce1c2f9cfe..1b962f9498 100644 --- a/packages/cloud/src/image/withCloudImage.ts +++ b/packages/cloud/src/image/withCloudImage.ts @@ -1,4 +1,4 @@ -import { resizeIn } from '@portive/client'; +import * as portiveClient from '@portive/client'; import { insertNode, Value, WithPlatePlugin } from '@udecode/plate-common'; import Defer from 'p-defer'; @@ -51,7 +51,7 @@ export const withCloudImage = < editor.cloud.imageFileHandlers = { onStart(e) { - const { width, height } = resizeIn( + const { width, height } = portiveClient.resizeIn( { width: e.width, height: e.height }, { width: maxInitialWidth, height: maxInitialHeight } );