Skip to content

Commit

Permalink
Merge pull request #3708 from udecode/media
Browse files Browse the repository at this point in the history
Media
  • Loading branch information
felixfeng33 authored Nov 5, 2024
2 parents d191026 + 702ad16 commit 2a01d06
Show file tree
Hide file tree
Showing 92 changed files with 4,943 additions and 120 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-peaches-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-ai': patch
---

Missing export
5 changes: 5 additions & 0 deletions .changeset/rare-zebras-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-dnd': patch
---

Add `enableFile` option to check whether to enable the DnD plugin for files dragged in from outside the browser.
15 changes: 15 additions & 0 deletions .changeset/sour-bananas-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@udecode/plate-media': minor
---
ImagePlugin:
- New `initialHeight` and `initialWidth` in `TImageElement` This will display a loading placeholder while the image is still loading, which helps maintain a consistent height.
- New Api: editor.insert.imageFromFiles

PlaceholderPlugin:
- Mew `placeholderId` Used to track what was converted from that placeholder plugin.
- New `insertMedia` Used for inserting the placeholder at once.
- New `validateFiles` utils for validate the files meet the `mediaConfig`.
- If validation fails,stop insert placeholder and save the error message in uploadErrorMessage.
- New `option.multiple` `maxFileCount` Used to limit the number of placeholders inserted.
- New `option.disable` `disabledDndPlugin` Used to using the browser drop.
- New `error` use `editor.useOption` to watch and display a toast message.
2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/ai-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/align-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/basic-elements-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/basic-marks-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/basic-nodes-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/block-menu-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/block-selection-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/column-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/comment-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/copilot-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/date-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/dnd-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/emoji-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/excalidraw-demo.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/font-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/highlight-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/hr-demo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/image-element.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"files": [
{
"content": "'use client';\n\nimport React from 'react';\n\nimport { cn, withRef } from '@udecode/cn';\nimport { withHOC } from '@udecode/plate-common/react';\nimport { Image, ImagePlugin, useMediaState } from '@udecode/plate-media/react';\nimport { ResizableProvider, useResizableStore } from '@udecode/plate-resizable';\n\nimport { Caption, CaptionTextarea } from './caption';\nimport { MediaPopover } from './media-popover';\nimport { PlateElement } from './plate-element';\nimport {\n Resizable,\n ResizeHandle,\n mediaResizeHandleVariants,\n} from './resizable';\n\nexport const ImageElement = withHOC(\n ResizableProvider,\n withRef<typeof PlateElement>(\n ({ children, className, nodeProps, ...props }, ref) => {\n const { align = 'center', focused, readOnly, selected } = useMediaState();\n\n const width = useResizableStore().get.width();\n\n return (\n <MediaPopover plugin={ImagePlugin}>\n <PlateElement\n ref={ref}\n className={cn('py-2.5', className)}\n {...props}\n >\n <figure className=\"group relative m-0\" contentEditable={false}>\n <Resizable\n align={align}\n options={{\n align,\n readOnly,\n }}\n >\n <ResizeHandle\n className={mediaResizeHandleVariants({ direction: 'left' })}\n options={{ direction: 'left' }}\n />\n <Image\n className={cn(\n 'block w-full max-w-full cursor-pointer object-cover px-0',\n 'rounded-sm',\n focused && selected && 'ring-2 ring-ring ring-offset-2'\n )}\n alt=\"\"\n {...nodeProps}\n />\n <ResizeHandle\n className={mediaResizeHandleVariants({\n direction: 'right',\n })}\n options={{ direction: 'right' }}\n />\n </Resizable>\n\n <Caption style={{ width }} align={align}>\n <CaptionTextarea\n readOnly={readOnly}\n placeholder=\"Write a caption...\"\n />\n </Caption>\n </figure>\n\n {children}\n </PlateElement>\n </MediaPopover>\n );\n }\n )\n);\n",
"content": "'use client';\n\nimport React from 'react';\n\nimport { cn, withRef } from '@udecode/cn';\nimport { withHOC } from '@udecode/plate-common/react';\nimport { Image, ImagePlugin, useMediaState } from '@udecode/plate-media/react';\nimport { ResizableProvider, useResizableStore } from '@udecode/plate-resizable';\n\nimport { Caption, CaptionTextarea } from './caption';\nimport { MediaPopover } from './media-popover';\nimport { PlateElement } from './plate-element';\nimport {\n Resizable,\n ResizeHandle,\n mediaResizeHandleVariants,\n} from './resizable';\n\nexport const ImageElement = withHOC(\n ResizableProvider,\n withRef<typeof PlateElement>(\n ({ children, className, nodeProps, ...props }, ref) => {\n const { align = 'center', focused, readOnly, selected } = useMediaState();\n\n const width = useResizableStore().get.width();\n\n return (\n <MediaPopover plugin={ImagePlugin}>\n <PlateElement\n ref={ref}\n className={cn('py-2.5', className)}\n {...props}\n >\n <figure className=\"group relative m-0\" contentEditable={false}>\n <Resizable\n align={align}\n options={{\n align,\n readOnly,\n }}\n >\n <ResizeHandle\n className={mediaResizeHandleVariants({ direction: 'left' })}\n options={{ direction: 'left' }}\n />\n <Image\n className={cn(\n 'block w-full max-w-full cursor-pointer object-cover px-0',\n 'rounded-sm',\n focused && selected && 'ring-2 ring-ring ring-offset-2'\n )}\n alt=\"\"\n {...nodeProps}\n />\n <ResizeHandle\n className={mediaResizeHandleVariants({\n direction: 'right',\n })}\n options={{ direction: 'right' }}\n />\n </Resizable>\n\n <Caption style={{ width }} align={align}>\n <CaptionTextarea\n readOnly={readOnly}\n onFocus={(e) => {\n e.preventDefault();\n }}\n placeholder=\"Write a caption...\"\n />\n </Caption>\n </figure>\n\n {children}\n </PlateElement>\n </MediaPopover>\n );\n }\n )\n);\n",
"path": "plate-ui/image-element.tsx",
"target": "components/plate-ui/image-element.tsx",
"type": "registry:ui"
Expand Down
Loading

0 comments on commit 2a01d06

Please sign in to comment.