Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
feat: add image extension to rich text editor
yassine.belkaide266334b17ba
diff --git a/frontend/package.json b/frontend/package.jsonindex 84ae139d4..6ddec80f3 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -40,6 +40,7 @@"@stripe/stripe-js": "^1.54.1","@tabler/icons-react": "^2.44.0","@tanstack/react-query": "5.52.2",+ "@tiptap/extension-image": "^2.8.0","@tiptap/extension-link": "^2.1.13","@tiptap/extension-text-align": "^2.1.13","@tiptap/extension-underline": "^2.1.13",diff --git a/frontend/src/components/common/Editor/index.tsx b/frontend/src/components/common/Editor/index.tsxindex 0b40d35d0..35421895b 100644--- a/frontend/src/components/common/Editor/index.tsx+++ b/frontend/src/components/common/Editor/index.tsx@@ -3,7 +3,8 @@ import {useEditor} from "@tiptap/react";import StarterKit from '@tiptap/starter-kit';import Underline from '@tiptap/extension-underline';import TextAlign from '@tiptap/extension-text-align';-import React, {useEffect, useState} from "react";+import Image from '@tiptap/extension-image';+import React, {useCallback, useEffect, useState} from "react";import {InputDescription, InputError, InputLabel} from "@mantine/core";import classes from "./Editor.module.scss";import classNames from "classnames";@@ -40,6 +41,7 @@ export const Editor = ({Underline,Link,TextAlign.configure({types: ['heading', 'paragraph']}),+ Image,],onUpdate: ({editor}) => {const html = editor.getHTML();@@ -69,6 +71,14 @@ export const Editor = ({}}}, [value, editor, maxLength]);++ const addImage = useCallback(() => {+ const url = window.prompt('Image URL');++ if (url && editor) {+ editor.chain().focus().setImage({ src: url }).run();+ }+ }, [editor]);return (<div className={classNames([classes.inputWrapper, className])}>@@ -112,6 +122,22 @@ export const Editor = ({<RichTextEditor.AlignJustify/><RichTextEditor.AlignRight/></RichTextEditor.ControlsGroup>+ <RichTextEditor.ControlsGroup>+ <button+ data-rich-text-editor-control+ className="mantine-focus-auto mantine-RichTextEditor-control"+ onClick={addImage}+ style={{+ display: 'flex',+ border: '#ced4da 1px solid',+ background: 'transparent',+ cursor: 'pointer',+ padding: '2px 4px',+ }}+ >+ <svg viewBox="0 0 20 20" width={"18"}><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037h9.494a2.97 2.97 0 0 1-.414-.287 2.998 2.998 0 0 1-1.055-2.03 3.003 3.003 0 0 1 .693-2.185l.383-.455-.02.018-3.65-3.41a.695.695 0 0 0-.957-.034L1.5 13.6V2.5h15v5.535a2.97 2.97 0 0 1 1.412.932l.088.105V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.713 2.803a2.146 2.146 0 0 0-2.049 1.992 2.14 2.14 0 0 0 1.28 2.096 2.13 2.13 0 0 0 2.644-3.11 2.134 2.134 0 0 0-1.875-.978Z"></path><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.784.784 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79Z"></path><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.784.784 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79Z"></path></svg>+ </button >+ </RichTextEditor.ControlsGroup></>)}diff --git a/frontend/yarn.lock b/frontend/yarn.lockindex 76ac473f7..b00a2f938 100644--- a/frontend/yarn.lock+++ b/frontend/yarn.lock@@ -1376,6 +1376,11 @@resolved "https://registry.yarnpkg.com/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-2.6.6.tgz#3bc88048a9eb22ef8b6a9c4514701f79176eb495"integrity sha512-cFEfv7euDpuLSe8exY8buwxkreKBAZY9Hn3EetKhPcLQo+ut5Y24chZTxFyf9b+Y0wz3UhOhLTZSz7fTobLqBA==+"@tiptap/extension-image@^2.8.0":+ version "2.8.0"+ resolved "https://registry.yarnpkg.com/@tiptap/extension-image/-/extension-image-2.8.0.tgz#e1b135c1fb079048bb4261a0546c3374fe6192d7"+ integrity sha512-5CReomgHGTUgxaX8P3i6qiC9VRWcWQgVoYtds4ZM52LVx/oGwMxQ4ECyzdVYKaRW+6PrNnAe6ew3Qpd5Wk0cIg==+"@tiptap/extension-italic@^2.6.6":version "2.6.6"resolved "https://registry.yarnpkg.com/@tiptap/extension-italic/-/extension-italic-2.6.6.tgz#18f1ec4461efca92ebe1bc6dfd79ec533d6bd68f"