Skip to content

Commit

Permalink
Merge pull request #3003 from Lenghak/main
Browse files Browse the repository at this point in the history
fix: #3002
  • Loading branch information
zbeyens authored Mar 1, 2024
2 parents 72ec557 + 74c1c04 commit 9763f35
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-llamas-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/plate-cloud": patch
---

fix: #3002
6 changes: 3 additions & 3 deletions packages/cloud/src/cloud/types.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<string, Upload>;
};

Expand All @@ -18,7 +18,7 @@ export type FinishUploadsOptions = { maxTimeoutInMs?: number };

export type CloudEditorProps<V extends Value = Value> = {
cloud: {
client: Client;
client: portiveClient.Client;
uploadFiles: (msg: any) => void;
uploadStore: ReturnType<typeof createUploadStore>;
genericFileHandlers?: {
Expand Down
9 changes: 6 additions & 3 deletions packages/cloud/src/cloud/uploadFiles.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -28,7 +31,7 @@ export const uploadFile = <V extends Value = Value>(
) => {
const id = `#${nanoid()}`;
const { client } = editor.cloud;
uploadFileToPortive({
portiveClient.uploadFile({
client,
file,
onBeforeFetch(e) {
Expand Down
6 changes: 3 additions & 3 deletions packages/cloud/src/cloud/withCloud.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cloud/src/image/withCloudImage.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 }
);
Expand Down

0 comments on commit 9763f35

Please sign in to comment.