Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: HTML to Markdown parser integration #3229

Merged
35 changes: 30 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"electron-log": "^4.3.5",
"electron-serve": "^1.0.0",
"electron-updater": "^4.3.4",
"expensify-common": "^1.0.1",
"expensify-common": "git://github.com/Expensify/expensify-common.git#c3465bf615390a2844087ec7f2343b0607ea484c",
"file-loader": "^6.0.0",
"html-entities": "^1.3.1",
"lodash": "4.17.21",
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class ReportActionItem extends Component {
<ReportActionItemMessageEdit
action={this.props.action}
draftMessage={this.props.draftMessage}
reportAction={this.props.action}
reportID={this.props.reportID}
index={this.props.index}
/>
Expand Down
13 changes: 11 additions & 2 deletions src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import lodashGet from 'lodash/get';
import ReportActionPropTypes from './ReportActionPropTypes';
import styles from '../../../styles/styles';
import TextInputFocusable from '../../../components/TextInputFocusable';
Expand All @@ -19,6 +21,9 @@ const propTypes = {
/** Draft message */
draftMessage: PropTypes.string.isRequired,

/** The report action this context menu is attached to. */
reportAction: PropTypes.shape(ReportActionPropTypes).isRequired,

/** ReportID that holds the comment we're editing */
reportID: PropTypes.number.isRequired,

Expand All @@ -39,8 +44,12 @@ class ReportActionItemMessageEdit extends React.Component {
this.triggerSaveOrCancel = this.triggerSaveOrCancel.bind(this);
this.onSelectionChange = this.onSelectionChange.bind(this);

const message = _.last(lodashGet(this.props.reportAction, 'message', this.props.draftMessage));
const parser = new ExpensiMark();
const draftMessage = parser.htmlToMarkdown(lodashGet(message, 'html', ''));

this.state = {
draft: this.props.draftMessage,
draft: draftMessage,
selection: {
start: this.props.draftMessage.length,
end: this.props.draftMessage.length,
Expand Down Expand Up @@ -119,7 +128,7 @@ class ReportActionItemMessageEdit extends React.Component {
ref={el => this.textInput = el}
onChangeText={this.updateDraft} // Debounced saveDraftComment
onKeyPress={this.triggerSaveOrCancel}
defaultValue={this.props.draftMessage}
defaultValue={this.state.draft}
maxLines={16} // This is the same that slack has
style={[styles.textInputCompose, styles.flex4]}
onFocus={() => {
Expand Down