From 66c5b80e206204e0d2afa9d0993498db98389368 Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Wed, 31 Jan 2024 18:49:54 +0330 Subject: [PATCH] feat(ckeditor): set embedded image captions as default when inserting from media library --- ...editor+strapi-plugin-ckeditor+0.0.10.patch | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/patches/@ckeditor+strapi-plugin-ckeditor+0.0.10.patch b/patches/@ckeditor+strapi-plugin-ckeditor+0.0.10.patch index 34dc48f..53382b2 100644 --- a/patches/@ckeditor+strapi-plugin-ckeditor+0.0.10.patch +++ b/patches/@ckeditor+strapi-plugin-ckeditor+0.0.10.patch @@ -29,18 +29,25 @@ index 73ea2b9..aaead3e 100644 'link', 'strapiMediaLib', 'mediaEmbed', 'blockQuote', 'insertTable', 'codeBlock', '|', diff --git a/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/CKEditorInput/index.js b/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/CKEditorInput/index.js -index e6e1ee3..186b41c 100644 +index e6e1ee3..9059c84 100644 --- a/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/CKEditorInput/index.js +++ b/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/CKEditorInput/index.js -@@ -48,8 +48,10 @@ const CKEditorInput = ({ +@@ -48,8 +48,17 @@ const CKEditorInput = ({ if ( asset.mime.includes('image') ) { const url = sanitize( asset.url ); const alt = sanitize( asset.alt ); + const width = asset.width + const height = asset.height ++ const caption = sanitize(asset.caption || ''); - imageHtmlString += `${ alt }`; -+ imageHtmlString += `${ alt }`; ++ const imgTag = `${ alt }` ++ ++ if(caption && caption.length > 0) { ++ imageHtmlString += `
${imgTag}
${caption}
`; ++ } else { ++ imageHtmlString += imgTag; ++ } } } ); @@ -773,15 +780,16 @@ index b9db460..30b968a 100644 + } `; diff --git a/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/MediaLib/index.js b/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/MediaLib/index.js -index f93afa6..94d177a 100644 +index f93afa6..1ed564e 100644 --- a/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/MediaLib/index.js +++ b/node_modules/@ckeditor/strapi-plugin-ckeditor/admin/src/components/MediaLib/index.js -@@ -11,6 +11,8 @@ const MediaLib = ( { isOpen, onChange, onToggle } ) => { +@@ -11,6 +11,9 @@ const MediaLib = ( { isOpen, onChange, onToggle } ) => { alt: f.alternativeText || f.name, url: prefixFileUrlWithBackendUrl( f.url ), mime: f.mime, + width: f.width, -+ height: f.height ++ height: f.height, ++ caption: f.caption || '', } ) ); onChange( formattedFiles );