From 5586001b791899d5f16c8a180a1e2e5321da9f00 Mon Sep 17 00:00:00 2001 From: Yinyin Liu Date: Thu, 30 Apr 2026 12:38:50 +0200 Subject: [PATCH] allow format ticket's description --- .../dashboards/Tickets/CreateTicketModal.tsx | 43 +++++++++++---- .../dashboards/Tickets/TicketDetail.tsx | 52 +++++++++++++------ 2 files changed, 69 insertions(+), 26 deletions(-) diff --git a/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx b/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx index 4dc2ddb03..18df0ca00 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx @@ -21,6 +21,8 @@ import { import AttachFileIcon from '@mui/icons-material/AttachFile'; import { FormattedMessage, useIntl } from 'react-intl'; import axiosConfig from 'src/Resources/axiosConfig'; +import CommentFormatToolbar from './CommentFormatToolbar'; +import { handleListEnter } from './commentMarkdown'; import { TicketPriority, TicketCategory, @@ -87,6 +89,7 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: // File attachments const fileInputRef = useRef(null); + const descriptionRef = useRef(null); const [selectedFiles, setSelectedFiles] = useState([]); const [uploading, setUploading] = useState(false); const [uploadProgress, setUploadProgress] = useState(0); @@ -547,17 +550,35 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: /> )} - - } - value={description} - onChange={(e) => setDescription(e.target.value)} - multiline - rows={4} - fullWidth - margin="dense" - /> + + + + + + + + + } + value={description} + onChange={(e) => setDescription(e.target.value)} + onKeyDown={(e) => handleListEnter(e, description, setDescription)} + inputRef={descriptionRef} + multiline + rows={4} + fullWidth + margin="dense" + /> + {/* File attachments */} diff --git a/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx b/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx index 62d16128c..38b112a20 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx @@ -50,6 +50,8 @@ import Footer from 'src/components/Footer'; import StatusChip from './StatusChip'; import AiDiagnosisPanel from './AiDiagnosisPanel'; import CommentThread from './CommentThread'; +import CommentFormatToolbar from './CommentFormatToolbar'; +import { renderCommentBody, handleListEnter } from './commentMarkdown'; import TimelinePanel from './TimelinePanel'; import FileUploadButton from 'src/components/FileUploadButton'; import DocumentList from 'src/components/DocumentList'; @@ -98,6 +100,7 @@ function TicketDetailPage() { const [solveGateOpen, setSolveGateOpen] = useState(false); const rootCauseRef = useRef(null); const solutionRef = useRef(null); + const descriptionRef = useRef(null); // Custom "Other" editing state const [editCustomSub, setEditCustomSub] = useState(''); @@ -411,7 +414,24 @@ function TicketDetailPage() { {editingDescription ? ( - + + + { + setDescription(next); + setDescriptionSaved(false); + }} + disabled={savingDescription} + /> + + + + + handleListEnter(e, description, (next) => { + setDescription(next); + setDescriptionSaved(false); + }) + } + inputRef={descriptionRef} /> {descriptionSaved && ( @@ -447,23 +474,18 @@ function TicketDetailPage() { + ) : ticket.description ? ( + renderCommentBody(ticket.description) ) : ( - {ticket.description || ( - - - - )} + )}