From 2c8ecbecebf94f1501a648f50c4d997170c9cac1 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:41:32 +0530 Subject: [PATCH] feat: Adds image attachment for help center articles (#6426) * Added one more endpoint to attach tempfile and get logo * Added one more endpoint to attach tempfile and get logo * spec fixes * Upload file for articles irrespective of the association * Upload file for articles irrespective of the association * Add multiple images with different keys * feat: Adds image attachment for help center articles * Adds validation for file upload * Fixes space above image after adding to doc * chore: Removed svg from file upload type * Update app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue Co-authored-by: Shivam Mishra * Update app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue Co-authored-by: Shivam Mishra * Removes caption for the image * Fixes woot prosemirror package version * Update yarn.lock * Update yarn.lock --------- Co-authored-by: Tejaswini Chile Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Muhsin Keloth Co-authored-by: iamsivin Co-authored-by: Shivam Mishra Co-authored-by: Pranav Raj S --- .../dashboard/api/helpCenter/articles.js | 14 +++ .../widgets/WootWriter/FullEditor.vue | 89 +++++++++++++++++-- .../dashboard/i18n/locale/en/helpCenter.json | 11 +++ .../modules/helpCenterArticles/actions.js | 15 ++++ package.json | 2 +- yarn.lock | 4 +- 6 files changed, 127 insertions(+), 8 deletions(-) diff --git a/app/javascript/dashboard/api/helpCenter/articles.js b/app/javascript/dashboard/api/helpCenter/articles.js index 62328e8eb..bcbb4dc5b 100644 --- a/app/javascript/dashboard/api/helpCenter/articles.js +++ b/app/javascript/dashboard/api/helpCenter/articles.js @@ -46,6 +46,20 @@ class ArticlesAPI extends PortalsAPI { deleteArticle({ articleId, portalSlug }) { return axios.delete(`${this.url}/${portalSlug}/articles/${articleId}`); } + + uploadImage({ portalSlug, file }) { + let formData = new FormData(); + formData.append('background_image', file); + return axios.post( + `${this.url}/${portalSlug}/articles/attach_file`, + formData, + { + headers: { + 'Content-Type': 'multipart/form-data', + }, + } + ); + } } export default new ArticlesAPI(); diff --git a/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue b/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue index c5ed29721..991e5f2ed 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/FullEditor.vue @@ -1,6 +1,13 @@