From 63dd38fdb24938e80f0d64fc610e4e24f92752c6 Mon Sep 17 00:00:00 2001 From: rxthew Date: Fri, 18 Nov 2022 21:51:44 +0100 Subject: [PATCH 1/4] Add image action to overriden actions --- client/app/components/Input/__tests__/InputTextarea.spec.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/app/components/Input/__tests__/InputTextarea.spec.jsx b/client/app/components/Input/__tests__/InputTextarea.spec.jsx index 5e5f0b24bb..8180d10216 100644 --- a/client/app/components/Input/__tests__/InputTextarea.spec.jsx +++ b/client/app/components/Input/__tests__/InputTextarea.spec.jsx @@ -150,6 +150,7 @@ describe('InputTextarea', () => { { title: 'Bold', expectedArgs: ['bold'] }, // overridden actions { title: 'Link', expectedArgs: ['createLink', sampleUrl] }, + { title: 'Image', expectedArgs: ['insertImage', sampleUrl] }, { title: 'Ordered List', expectedArgs: ['insertOrderedList'] }, { title: 'Unordered List', expectedArgs: ['insertUnorderedList'] }, ]; From 70d008decc549944ad702e306c550debdcd1311f Mon Sep 17 00:00:00 2001 From: rxthew Date: Fri, 18 Nov 2022 21:52:43 +0100 Subject: [PATCH 2/4] Add insertImage to actions, render using faImage. --- client/app/components/Input/InputTextarea.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/app/components/Input/InputTextarea.jsx b/client/app/components/Input/InputTextarea.jsx index 0666cbbed5..aa7aeaf752 100644 --- a/client/app/components/Input/InputTextarea.jsx +++ b/client/app/components/Input/InputTextarea.jsx @@ -5,7 +5,7 @@ import { sanitize } from 'dompurify'; import ReactDOMServer from 'react-dom/server'; import { init, exec } from 'pell'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faLink } from '@fortawesome/free-solid-svg-icons'; +import { faImage, faLink } from '@fortawesome/free-solid-svg-icons'; import css from './InputTextarea.scss'; import inputCss from './Input.scss'; @@ -16,6 +16,11 @@ const handleResult = (type: string) => { if (url) exec('createLink', url); break; } + case 'image': { + const src = window.prompt('Please provide a link to your image.'); + if(src) exec('insertImage',src); + break + } case 'olist': exec('insertOrderedList'); break; @@ -45,6 +50,10 @@ const actions = [ ...action('link'), icon: ReactDOMServer.renderToString(), }, + { + ...action('image'), + icon: ReactDOMServer.renderToString(), + }, ]; const classes = { From 111b522405f9d1e3a057b7500725cce8819dbbf5 Mon Sep 17 00:00:00 2001 From: rxthew Date: Sun, 20 Nov 2022 16:01:19 +0100 Subject: [PATCH 3/4] #2141 - Fix minor linting errors --- client/app/components/Input/InputTextarea.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/app/components/Input/InputTextarea.jsx b/client/app/components/Input/InputTextarea.jsx index aa7aeaf752..660a9eeb4b 100644 --- a/client/app/components/Input/InputTextarea.jsx +++ b/client/app/components/Input/InputTextarea.jsx @@ -18,8 +18,8 @@ const handleResult = (type: string) => { } case 'image': { const src = window.prompt('Please provide a link to your image.'); - if(src) exec('insertImage',src); - break + if (src) exec('insertImage', src); + break; } case 'olist': exec('insertOrderedList'); From f34c7abe9ceee89aeeca6513fe3f5df277c9047a Mon Sep 17 00:00:00 2001 From: rxthew Date: Sat, 26 Nov 2022 12:55:32 +0100 Subject: [PATCH 4/4] #2205 Add max-width to img in strategies & moments --- app/assets/stylesheets/core/containers.scss | 6 ++++++ app/views/moments/show.html.erb | 2 +- app/views/strategies/show.html.erb | 2 +- client/app/components/Input/InputTextarea.scss | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/core/containers.scss b/app/assets/stylesheets/core/containers.scss index 63d89802ad..9f39965e84 100644 --- a/app/assets/stylesheets/core/containers.scss +++ b/app/assets/stylesheets/core/containers.scss @@ -11,3 +11,9 @@ width: 100%; margin: 0; } + +.imageContainer { + img { + max-width: 100%; + } +} diff --git a/app/views/moments/show.html.erb b/app/views/moments/show.html.erb index b5ab5508d0..7876a304b7 100644 --- a/app/views/moments/show.html.erb +++ b/app/views/moments/show.html.erb @@ -20,7 +20,7 @@ <% if @moment.why.present? %> -
+
<% if @moment.fix.present? %>
<%= label_tag t('moments.form.why_legacy') %> diff --git a/app/views/strategies/show.html.erb b/app/views/strategies/show.html.erb index 30c1a00685..f523ac6e64 100644 --- a/app/views/strategies/show.html.erb +++ b/app/views/strategies/show.html.erb @@ -16,7 +16,7 @@
<% if @strategy.description.present? %> -
+
<%= sanitize(@strategy.description) %>
<% end %> diff --git a/client/app/components/Input/InputTextarea.scss b/client/app/components/Input/InputTextarea.scss index b509b683e1..5da2e4f59c 100644 --- a/client/app/components/Input/InputTextarea.scss +++ b/client/app/components/Input/InputTextarea.scss @@ -45,6 +45,10 @@ p { margin: $size-0; } + + img { + max-width: 100%; + } } .dark {