1515 */
1616
1717import { useMemo , useState } from 'react'
18- import MDEditor , { commands } from '@uiw/react-md-editor'
18+ import MDEditor , { commands , MDEditorProps } from '@uiw/react-md-editor'
1919
2020import { ReactComponent as BoldIcon } from '@Icons/ic-bold.svg'
2121import { ReactComponent as CheckedListIcon } from '@Icons/ic-checked-list.svg'
@@ -31,18 +31,16 @@ import { ReactComponent as StrikethroughIcon } from '@Icons/ic-strikethrough.svg
3131import { ReactComponent as UnorderedListIcon } from '@Icons/ic-unordered-list.svg'
3232
3333import {
34- AppThemeType ,
3534 Button ,
3635 ButtonStyleType ,
3736 ButtonVariantType ,
3837 ComponentSizeType ,
3938 Icon ,
4039 ToastManager ,
4140 ToastVariantType ,
42- useTheme ,
4341} from '../../Shared'
4442import Markdown from '../Markdown/MarkDown'
45- import { showError } from '..'
43+ import { showError , Tooltip } from '..'
4644import { DESCRIPTION_EMPTY_ERROR_MSG , DESCRIPTION_UNSAVED_CHANGES_MSG } from './constant'
4745import { GenericDescriptionProps } from './types'
4846import { getParsedUpdatedOnDate } from './utils'
@@ -94,14 +92,6 @@ const extraCommands = [
9492 ...commands . checkedListCommand ,
9593 icon : < CheckedListIcon className = "icon-dim-16 flex" /> ,
9694 } ,
97- {
98- ...commands . help ,
99- icon : (
100- < div className = "flex dc__no-shrink" >
101- < Icon name = "ic-help-outline" color = "N700" size = { 16 } />
102- </ div >
103- ) ,
104- } ,
10595]
10696
10797const GenericDescription = ( {
@@ -118,23 +108,21 @@ const GenericDescription = ({
118108
119109 const [ editorViewState , setEditorViewState ] = useState < 'write' | 'preview' > ( 'write' )
120110
121- const { appTheme } = useTheme ( )
122-
123111 const _date = getParsedUpdatedOnDate ( updatedOn )
124112
125113 const myCommands = useMemo (
126114 ( ) => [
127115 {
128116 ...commands . codeEdit ,
129- icon : < span className = "fs-13 fw-6 lh-20" > Write</ span > ,
117+ icon : < span className = "fs-13 fw-4 lh-20" > Write</ span > ,
130118 execute : ( ...props ) => {
131119 setEditorViewState ( 'write' )
132120 return commands . codeEdit . execute ( ...props )
133121 } ,
134122 } satisfies typeof commands . codeEdit ,
135123 {
136124 ...commands . codePreview ,
137- icon : < span className = "fs-13 fw-6 lh-20" > Preview</ span > ,
125+ icon : < span className = "fs-13 fw-4 lh-20" > Preview</ span > ,
138126 execute : ( ...props ) => {
139127 setEditorViewState ( 'preview' )
140128 return commands . codePreview . execute ( ...props )
@@ -207,9 +195,47 @@ const GenericDescription = ({
207195 }
208196
209197 const renderMarkdown = ( source : string ) => (
210- < Markdown markdown = { source } breaks disableEscapedText className = "mh-150 pt-8" />
198+ < Markdown markdown = { source } breaks disableEscapedText className = "mh-150 pt-8 fs-14 fw-4 cn-9 " />
211199 )
212200
201+ const renderToolbar : MDEditorProps [ 'components' ] [ 'toolbar' ] = (
202+ command ,
203+ disabled ,
204+ executeCommand : ( command , name ) => void ,
205+ index : number ,
206+ ) => {
207+ if ( command . name === 'edit' || command . name === 'preview' ) {
208+ return (
209+ < button
210+ key = { index }
211+ type = "button"
212+ className = "markdown-editor__tab-button flex dc__transparent p-4"
213+ onClick = { ( ) => executeCommand ( command , command . name ) }
214+ disabled = { disabled }
215+ >
216+ { command . icon }
217+ </ button >
218+ )
219+ }
220+ return (
221+ < Tooltip
222+ key = { index }
223+ alwaysShowTippyOnHover = { ! ! command . buttonProps ?. title }
224+ content = { command . buttonProps ?. title }
225+ placement = "top"
226+ >
227+ < button
228+ type = "button"
229+ className = "flex dc__transparent p-4 mr-4"
230+ onClick = { ( ) => executeCommand ( command , command . name ) }
231+ disabled = { disabled }
232+ >
233+ { command . icon }
234+ </ button >
235+ </ Tooltip >
236+ )
237+ }
238+
213239 return (
214240 < div
215241 data-testid = "generic-description-wrapper"
@@ -246,16 +272,16 @@ const GenericDescription = ({
246272 < MDEditor
247273 value = { modifiedValue }
248274 onChange = { setModifiedValue }
249- data-color-mode = { appTheme === AppThemeType . dark ? 'dark' : 'light' }
250275 commands = { myCommands }
251276 extraCommands = { extraCommands }
252277 preview = { editorViewState === 'preview' ? 'preview' : 'edit' }
253278 components = { {
254279 preview : renderMarkdown ,
280+ toolbar : renderToolbar ,
255281 } }
256282 />
257283
258- < div className = "flexbox dc__content-end pt-12 pb-12 dc__contain--paint" >
284+ < div className = "flexbox dc__content-end pt-12 pb-12 dc__contain--paint border__primary--top " >
259285 < div className = "form__buttons dc__gap-16 px-16" >
260286 < Button
261287 dataTestId = "description-edit-cancel-button"
0 commit comments