From 5dd2b37f49a457938c89f41d535e63f62538145a Mon Sep 17 00:00:00 2001 From: Brandon Owens Date: Wed, 28 Feb 2024 08:32:47 -0500 Subject: [PATCH] Image size saving fix (#377) * Update ImageBlock.ts * Update index.ts * Update image styling Update the image styling to not show the image containers background. --- .../Editor/Extensions/ImageBlock/ImageBlock.ts | 12 +++++++++++- .../src/pages/api/admin/images/[slug]/index.ts | 7 ++++++- source/elegant/src/utils/Hooks/useEditor.tsx | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/elegant/src/components/Editor/Extensions/ImageBlock/ImageBlock.ts b/source/elegant/src/components/Editor/Extensions/ImageBlock/ImageBlock.ts index 7185a750..71029afa 100644 --- a/source/elegant/src/components/Editor/Extensions/ImageBlock/ImageBlock.ts +++ b/source/elegant/src/components/Editor/Extensions/ImageBlock/ImageBlock.ts @@ -66,7 +66,17 @@ export const ImageBlock = Image.extend({ }, renderHTML({ HTMLAttributes }) { - return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)] + return [ + 'div', + {class: "my-8 shadow-xl rounded-xl"}, + [ + 'img', + { + class: "rounded-xl", + ...HTMLAttributes + } + ] + ] }, addCommands() { diff --git a/source/elegant/src/pages/api/admin/images/[slug]/index.ts b/source/elegant/src/pages/api/admin/images/[slug]/index.ts index 4c0aa50a..421ac1a8 100644 --- a/source/elegant/src/pages/api/admin/images/[slug]/index.ts +++ b/source/elegant/src/pages/api/admin/images/[slug]/index.ts @@ -18,7 +18,12 @@ export default async function handler( const response = await fetch( `https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_SLUG}/${REPO_BRANCH}/${ MONOREPO_PATH ? MONOREPO_PATH + '/' : '' - }public/images/${req.query?.slug}` + }public/images/${req.query?.slug}`, + { + headers: { + authorization: `token ${session.access_token}` + } + } ); if (response.status === 200 && response.body) { diff --git a/source/elegant/src/utils/Hooks/useEditor.tsx b/source/elegant/src/utils/Hooks/useEditor.tsx index a1519038..1d0ff16b 100644 --- a/source/elegant/src/utils/Hooks/useEditor.tsx +++ b/source/elegant/src/utils/Hooks/useEditor.tsx @@ -81,7 +81,7 @@ export const useEditor = ({ ...rhfMethods }) => { renderHTML({ HTMLAttributes }) { return [ 'div', - {class: "my-8 shadow-xl"}, + {class: "my-8 shadow-xl rounded-xl"}, [ 'img', {