Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 committed Nov 17, 2024
1 parent 4cf188c commit c68f868
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-dragons-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-media': patch
---

Fix error message.
24 changes: 24 additions & 0 deletions apps/www/src/lib/plate/demo/values/mediaValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,33 @@ export const imageValue: any = (
</fragment>
);

export const mediaPlaceholderValue: any = (
<fragment>
<hh2>Upload</hh2>
<hp indent={1} listStyleType="disc">
Easily upload media files by dragging and dropping them into the editor or
using the file picker. The editor provides:
</hp>
<hp indent={1} listStyleType="disc">
Real-time upload status and progress tracking
</hp>
<hp indent={1} listStyleType="disc">
Configurable file size limits and batch upload settings
</hp>
<hp indent={1} listStyleType="disc">
Clear error messages for any upload issues
</hp>
<hp indent={1} listStyleType="disc">
Try it now - drag an image from your desktop or click the upload button in
the toolbar
</hp>
</fragment>
);

export const mediaValue: any = (
<fragment>
{imageValue}
{mediaPlaceholderValue}

<hh2>Embed</hh2>
<hp>Embed various types of content, such as videos and tweets:</hp>
Expand Down
3 changes: 2 additions & 1 deletion apps/www/src/lib/plate/demo/values/usePlaygroundValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export const usePlaygroundValue = (id?: ValueId): Value => {
if (enabled.a) value.push(...linkValue);
if (enabled.hr) value.push(...horizontalRuleValue);
if (enabled.table) value.push(...tableValue);
if (enabled.img || enabled.media_embed) value.push(...mediaValue);
if (enabled.img || enabled.media_embed || enabled.media_placeholder)
value.push(...mediaValue);
if (enabled.column) value.push(...columnValue);
if (enabled.mention) value.push(...mentionValue);
if (enabled.date) value.push(...dateValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const useUploadErrorToast = () => {
if (!uploadError) return;

const { code, data } = uploadError;
console.log('🚀 ~ useEffect ~ data:', data);

switch (code) {
case UploadErrorCode.INVALID_FILE_SIZE: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AllowedFileType } from '../internal/mimes';

import { type FileSize, type MediaItemConfig, UploadErrorCode } from '../type';
import { createUploadError } from './createUploadError';
import { bytesToFileSize, fileSizeToBytes } from './fileSizeToBytes';
import { fileSizeToBytes } from './fileSizeToBytes';

export const validateFileItem = (
files: File[],
Expand Down Expand Up @@ -32,7 +32,7 @@ export const validateFileItem = (
throw createUploadError(UploadErrorCode.TOO_LARGE, {
fileType: key,
files: [f],
maxFileSize: bytesToFileSize(bytes),
maxFileSize: maxFileSize!,
});
}

Expand Down

0 comments on commit c68f868

Please sign in to comment.