Skip to content

Commit

Permalink
refactor: use rich text component from analytics (#2474)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo authored Jun 7, 2024
1 parent 8b3587e commit 7d22275
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 192 deletions.
7 changes: 2 additions & 5 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ msgstr "Spacer"
msgid "Use a spacer to create empty vertical space between other dashboard items."
msgstr "Use a spacer to create empty vertical space between other dashboard items."

msgid "Text item"
msgstr "Text item"
msgid "Text box"
msgstr "Text box"

msgid "Add text here"
msgstr "Add text here"
Expand Down Expand Up @@ -337,9 +337,6 @@ msgstr "Cannot search for dashboard items while offline"
msgid "Additional items"
msgstr "Additional items"

msgid "Text box"
msgstr "Text box"

msgid "Dashboard layout"
msgstr "Dashboard layout"

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
"private": true,
"license": "BSD-3-Clause",
"dependencies": {
"@dhis2/analytics": "^26.6.10",
"@dhis2/analytics": "^26.7.0",
"@dhis2/app-runtime": "^3.10.2",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/d2-i18n": "^1.1.3",
"@dhis2/d2-ui-rich-text": "^7.4.3",
"@dhis2/ui": "^9.2.0",
"@krakenjs/post-robot": "^11.0.0",
"classnames": "^2.3.2",
Expand Down
28 changes: 10 additions & 18 deletions src/components/Item/TextItem/Item.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { RichTextParser, RichTextEditor } from '@dhis2/analytics'
import i18n from '@dhis2/d2-i18n'
import {
Parser as RichTextParser,
Editor as RichTextEditor,
} from '@dhis2/d2-ui-rich-text'
import { Divider, TextArea, spacers } from '@dhis2/ui'
import { Divider, spacers } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { connect } from 'react-redux'
Expand All @@ -21,13 +18,11 @@ import PrintItemInfo from '../ItemHeader/PrintItemInfo.js'
const style = {
textDiv: {
padding: '10px',
whiteSpace: 'pre-line',
lineHeight: '20px',
lineHeight: '16px',
},
textField: {
fontSize: '14px',
fontStretch: 'normal',
width: '90%',
margin: '0 auto',
display: 'block',
lineHeight: '24px',
Expand Down Expand Up @@ -63,22 +58,19 @@ const TextItem = (props) => {
return (
<>
<ItemHeader
title={i18n.t('Text item')}
title={i18n.t('Text box')}
itemId={item.id}
dashboardMode={dashboardMode}
/>
<Divider margin={`0 0 ${spacers.dp4} 0`} />
<div className="dashboard-item-content">
<RichTextEditor
onEdit={(event) => onChangeText(event.target.value)}
>
<TextArea
rows={30}
value={text}
placeholder={i18n.t('Add text here')}
onChange={({ value }) => onChangeText(value)}
/>
</RichTextEditor>
onChange={onChangeText}
inputPlaceholder={i18n.t('Add text here')}
value={text}
initialFocus={false}
resizable={false}
/>
</div>
</>
)
Expand Down
4 changes: 4 additions & 0 deletions src/components/styles/ItemGrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
overflow: auto;
}

.TEXT .dashboard-item-content {
padding-bottom: var(--item-content-padding);
}

.EVENT_REPORT .dashboard-item-content {
position: relative;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/edit/ItemGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const EditItemGrid = ({
onWidthChange={onWidthChanged}
isDraggable={!hasLayout}
isResizable={!hasLayout}
draggableCancel="input,textarea"
draggableCancel="button,input,textarea"
>
{getItemComponents(dashboardItems)}
</ResponsiveReactGridLayout>
Expand Down
Loading

0 comments on commit 7d22275

Please sign in to comment.